repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
dotmailer/dotmailer-magento2-extension | Helper/Transactional.php | Transactional.getSmtpPassword | private function getSmtpPassword($storeId = null)
{
$value = $this->scopeConfig->getValue(
self::XML_PATH_DDG_TRANSACTIONAL_PASSWORD,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
return $this->encryptor->decrypt($value);
} | php | private function getSmtpPassword($storeId = null)
{
$value = $this->scopeConfig->getValue(
self::XML_PATH_DDG_TRANSACTIONAL_PASSWORD,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
return $this->encryptor->decrypt($value);
} | [
"private",
"function",
"getSmtpPassword",
"(",
"$",
"storeId",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"scopeConfig",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_DDG_TRANSACTIONAL_PASSWORD",
",",
"\\",
"Magento",
"\\",
"Store",
"\\",
... | Get smtp password.
@param int $storeId
@return boolean|string | [
"Get",
"smtp",
"password",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Transactional.php#L94-L102 | train |
dotmailer/dotmailer-magento2-extension | Helper/Transactional.php | Transactional.getSmtpPort | private function getSmtpPort($storeId)
{
return $this->scopeConfig->getValue(
self::XML_PATH_DDG_TRANSACTIONAL_PORT,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | private function getSmtpPort($storeId)
{
return $this->scopeConfig->getValue(
self::XML_PATH_DDG_TRANSACTIONAL_PORT,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"private",
"function",
"getSmtpPort",
"(",
"$",
"storeId",
")",
"{",
"return",
"$",
"this",
"->",
"scopeConfig",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_DDG_TRANSACTIONAL_PORT",
",",
"\\",
"Magento",
"\\",
"Store",
"\\",
"Model",
"\\",
"ScopeInterface",
... | Get smtp port.
@param int $storeId
@return boolean|string | [
"Get",
"smtp",
"port",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Transactional.php#L111-L118 | train |
dotmailer/dotmailer-magento2-extension | Helper/Transactional.php | Transactional.isDebugEnabled | private function isDebugEnabled($storeId)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_DDG_TRANSACTIONAL_DEBUG,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
} | php | private function isDebugEnabled($storeId)
{
return $this->scopeConfig->isSetFlag(
self::XML_PATH_DDG_TRANSACTIONAL_DEBUG,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$storeId
);
} | [
"private",
"function",
"isDebugEnabled",
"(",
"$",
"storeId",
")",
"{",
"return",
"$",
"this",
"->",
"scopeConfig",
"->",
"isSetFlag",
"(",
"self",
"::",
"XML_PATH_DDG_TRANSACTIONAL_DEBUG",
",",
"\\",
"Magento",
"\\",
"Store",
"\\",
"Model",
"\\",
"ScopeInterfac... | Get transactional log enabled.
@param int $storeId
@return bool | [
"Get",
"transactional",
"log",
"enabled",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Transactional.php#L127-L134 | train |
dotmailer/dotmailer-magento2-extension | Helper/Transactional.php | Transactional.getTransportConfig | public function getTransportConfig($storeId)
{
$config = [
'port' => $this->getSmtpPort($storeId),
'auth' => 'login',
'username' => $this->getSmtpUsername($storeId),
'password' => $this->getSmtpPassword($storeId),
'ssl' => 'tls',
];
if ($this->isDebugEnabled($storeId)) {
$this->_logger->debug('Mail transport config : ' . implode(',', $config));
}
return $config;
} | php | public function getTransportConfig($storeId)
{
$config = [
'port' => $this->getSmtpPort($storeId),
'auth' => 'login',
'username' => $this->getSmtpUsername($storeId),
'password' => $this->getSmtpPassword($storeId),
'ssl' => 'tls',
];
if ($this->isDebugEnabled($storeId)) {
$this->_logger->debug('Mail transport config : ' . implode(',', $config));
}
return $config;
} | [
"public",
"function",
"getTransportConfig",
"(",
"$",
"storeId",
")",
"{",
"$",
"config",
"=",
"[",
"'port'",
"=>",
"$",
"this",
"->",
"getSmtpPort",
"(",
"$",
"storeId",
")",
",",
"'auth'",
"=>",
"'login'",
",",
"'username'",
"=>",
"$",
"this",
"->",
... | Get config values for transport.
@param int $storeId
@return array | [
"Get",
"config",
"values",
"for",
"transport",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Transactional.php#L143-L158 | train |
dotmailer/dotmailer-magento2-extension | Controller/Adminhtml/Rules/Edit.php | Edit.checkRuleExistAndLoad | private function checkRuleExistAndLoad($id, $emailRules)
{
if ($id) {
$this->rulesResource->load($emailRules, $id);
if (!$emailRules->getId()) {
$this->messageManager->addErrorMessage(__('This rule no longer exists.'));
$this->_redirect('*/*');
}
}
$this->_view->getPage()->getConfig()->getTitle()->prepend(
$emailRules->getId() ? $emailRules->getName() : __('New Rule')
);
// set entered data if was error when we do save
$data = $this->_session->getPageData(true);
if (!empty($data)) {
$this->rules->addData($data);
}
} | php | private function checkRuleExistAndLoad($id, $emailRules)
{
if ($id) {
$this->rulesResource->load($emailRules, $id);
if (!$emailRules->getId()) {
$this->messageManager->addErrorMessage(__('This rule no longer exists.'));
$this->_redirect('*/*');
}
}
$this->_view->getPage()->getConfig()->getTitle()->prepend(
$emailRules->getId() ? $emailRules->getName() : __('New Rule')
);
// set entered data if was error when we do save
$data = $this->_session->getPageData(true);
if (!empty($data)) {
$this->rules->addData($data);
}
} | [
"private",
"function",
"checkRuleExistAndLoad",
"(",
"$",
"id",
",",
"$",
"emailRules",
")",
"{",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"rulesResource",
"->",
"load",
"(",
"$",
"emailRules",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$... | Check rule exist
@param int|null $id
@param \Dotdigitalgroup\Email\Model\Rules $emailRules
@return void | [
"Check",
"rule",
"exist"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Adminhtml/Rules/Edit.php#L96-L116 | train |
dotmailer/dotmailer-magento2-extension | Model/FailedAuth.php | FailedAuth.isLocked | public function isLocked()
{
if ($this->getFailuresNum() == \Dotdigitalgroup\Email\Model\FailedAuth::NUMBER_MAX_FAILS_LIMIT &&
strtotime($this->getLastAttemptDate() . '+5 min') > time()) {
return true;
}
return false;
} | php | public function isLocked()
{
if ($this->getFailuresNum() == \Dotdigitalgroup\Email\Model\FailedAuth::NUMBER_MAX_FAILS_LIMIT &&
strtotime($this->getLastAttemptDate() . '+5 min') > time()) {
return true;
}
return false;
} | [
"public",
"function",
"isLocked",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getFailuresNum",
"(",
")",
"==",
"\\",
"Dotdigitalgroup",
"\\",
"Email",
"\\",
"Model",
"\\",
"FailedAuth",
"::",
"NUMBER_MAX_FAILS_LIMIT",
"&&",
"strtotime",
"(",
"$",
"this",
... | Check if the store is in the locked state. | [
"Check",
"if",
"the",
"store",
"is",
"in",
"the",
"locked",
"state",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/FailedAuth.php#L17-L25 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Automation.php | Automation.updateStatus | public function updateStatus($contactIds, $status, $message, $updatedAt, $type)
{
$bind = [
'enrolment_status' => $status,
'message' => $message,
'updated_at' => $updatedAt,
];
$where = ['id IN(?)' => $contactIds];
$num = $this->getConnection()->update(
$this->getTable(Schema::EMAIL_AUTOMATION_TABLE),
$bind,
$where
);
//number of updated records
if ($num) {
$this->helper->log(
'Automation type : ' . $type . ', updated : ' . $num
);
}
} | php | public function updateStatus($contactIds, $status, $message, $updatedAt, $type)
{
$bind = [
'enrolment_status' => $status,
'message' => $message,
'updated_at' => $updatedAt,
];
$where = ['id IN(?)' => $contactIds];
$num = $this->getConnection()->update(
$this->getTable(Schema::EMAIL_AUTOMATION_TABLE),
$bind,
$where
);
//number of updated records
if ($num) {
$this->helper->log(
'Automation type : ' . $type . ', updated : ' . $num
);
}
} | [
"public",
"function",
"updateStatus",
"(",
"$",
"contactIds",
",",
"$",
"status",
",",
"$",
"message",
",",
"$",
"updatedAt",
",",
"$",
"type",
")",
"{",
"$",
"bind",
"=",
"[",
"'enrolment_status'",
"=>",
"$",
"status",
",",
"'message'",
"=>",
"$",
"me... | update status for automation entries
@param array $contactIds
@param string $status
@param string $message
@param string $updatedAt
@param string $type
@return null | [
"update",
"status",
"for",
"automation",
"entries"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Automation.php#L47-L66 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Rules/Collection.php | Collection.getActiveRuleByWebsiteAndType | public function getActiveRuleByWebsiteAndType($type, $websiteId)
{
$collection = $this->addFieldToFilter('type', ['eq' => $type])
->addFieldToFilter('status', ['eq' => 1])
->addFieldToFilter('website_ids', ['finset' => $websiteId])
->setPageSize(1);
if ($collection->getSize()) {
return $collection->getFirstItem();
}
return [];
} | php | public function getActiveRuleByWebsiteAndType($type, $websiteId)
{
$collection = $this->addFieldToFilter('type', ['eq' => $type])
->addFieldToFilter('status', ['eq' => 1])
->addFieldToFilter('website_ids', ['finset' => $websiteId])
->setPageSize(1);
if ($collection->getSize()) {
return $collection->getFirstItem();
}
return [];
} | [
"public",
"function",
"getActiveRuleByWebsiteAndType",
"(",
"$",
"type",
",",
"$",
"websiteId",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"addFieldToFilter",
"(",
"'type'",
",",
"[",
"'eq'",
"=>",
"$",
"type",
"]",
")",
"->",
"addFieldToFilter",
... | Get rule for website.
@param string $type
@param int|array $websiteId
@return array|\Magento\Framework\DataObject | [
"Get",
"rule",
"for",
"website",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Rules/Collection.php#L72-L84 | train |
dotmailer/dotmailer-magento2-extension | Model/Newsletter/SubscriberExporter.php | SubscriberExporter.getStoreIdForSubscriber | public function getStoreIdForSubscriber($email, $subscribers)
{
$defaultStore = 1;
foreach ($subscribers as $subscriber) {
if ($subscriber['subscriber_email'] == $email) {
return $subscriber['store_id'];
}
}
return $defaultStore;
} | php | public function getStoreIdForSubscriber($email, $subscribers)
{
$defaultStore = 1;
foreach ($subscribers as $subscriber) {
if ($subscriber['subscriber_email'] == $email) {
return $subscriber['store_id'];
}
}
return $defaultStore;
} | [
"public",
"function",
"getStoreIdForSubscriber",
"(",
"$",
"email",
",",
"$",
"subscribers",
")",
"{",
"$",
"defaultStore",
"=",
"1",
";",
"foreach",
"(",
"$",
"subscribers",
"as",
"$",
"subscriber",
")",
"{",
"if",
"(",
"$",
"subscriber",
"[",
"'subscribe... | Get the store id from newsletter_subscriber, return default if not found.
@param string $email
@param array $subscribers
@return int | [
"Get",
"the",
"store",
"id",
"from",
"newsletter_subscriber",
"return",
"default",
"if",
"not",
"found",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Newsletter/SubscriberExporter.php#L196-L205 | train |
dotmailer/dotmailer-magento2-extension | Setup/Schema/Shared.php | Shared.createAbandonedCartTable | public function createAbandonedCartTable($installer, $tableName)
{
$abandonedCartTable = $installer->getConnection()->newTable($installer->getTable($tableName));
$abandonedCartTable = $this->addColumnForAbandonedCartTable($abandonedCartTable);
$abandonedCartTable = $this->addIndexKeyForAbandonedCarts($installer, $abandonedCartTable);
$abandonedCartTable->setComment('Abandoned Carts Table');
$installer->getConnection()->createTable($abandonedCartTable);
} | php | public function createAbandonedCartTable($installer, $tableName)
{
$abandonedCartTable = $installer->getConnection()->newTable($installer->getTable($tableName));
$abandonedCartTable = $this->addColumnForAbandonedCartTable($abandonedCartTable);
$abandonedCartTable = $this->addIndexKeyForAbandonedCarts($installer, $abandonedCartTable);
$abandonedCartTable->setComment('Abandoned Carts Table');
$installer->getConnection()->createTable($abandonedCartTable);
} | [
"public",
"function",
"createAbandonedCartTable",
"(",
"$",
"installer",
",",
"$",
"tableName",
")",
"{",
"$",
"abandonedCartTable",
"=",
"$",
"installer",
"->",
"getConnection",
"(",
")",
"->",
"newTable",
"(",
"$",
"installer",
"->",
"getTable",
"(",
"$",
... | Create abandoned cart table
@param SchemaSetupInterface $installer
@param string $tableName | [
"Create",
"abandoned",
"cart",
"table"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Setup/Schema/Shared.php#L16-L23 | train |
dotmailer/dotmailer-magento2-extension | Setup/Schema/Shared.php | Shared.createConsentTable | public function createConsentTable($installer, $tableName)
{
$emailContactConsentTable = $installer->getConnection()->newTable($installer->getTable($tableName));
$emailContactConsentTable = $this->addColumnForConsentTable($emailContactConsentTable);
$emailContactConsentTable = $this->addIndexToConsentTable($installer, $emailContactConsentTable);
$emailContactConsentTable = $this->addKeyForConsentTable($installer, $emailContactConsentTable);
$emailContactConsentTable->setComment('Email contact consent table.');
$installer->getConnection()->createTable($emailContactConsentTable);
} | php | public function createConsentTable($installer, $tableName)
{
$emailContactConsentTable = $installer->getConnection()->newTable($installer->getTable($tableName));
$emailContactConsentTable = $this->addColumnForConsentTable($emailContactConsentTable);
$emailContactConsentTable = $this->addIndexToConsentTable($installer, $emailContactConsentTable);
$emailContactConsentTable = $this->addKeyForConsentTable($installer, $emailContactConsentTable);
$emailContactConsentTable->setComment('Email contact consent table.');
$installer->getConnection()->createTable($emailContactConsentTable);
} | [
"public",
"function",
"createConsentTable",
"(",
"$",
"installer",
",",
"$",
"tableName",
")",
"{",
"$",
"emailContactConsentTable",
"=",
"$",
"installer",
"->",
"getConnection",
"(",
")",
"->",
"newTable",
"(",
"$",
"installer",
"->",
"getTable",
"(",
"$",
... | Create consent table
@param SchemaSetupInterface $installer
@param string $tableName | [
"Create",
"consent",
"table"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Setup/Schema/Shared.php#L160-L168 | train |
dotmailer/dotmailer-magento2-extension | Setup/Schema/Shared.php | Shared.createFailedAuthTable | public function createFailedAuthTable($installer, $tableName)
{
$emailAuthEdc = $installer->getConnection()->newTable($installer->getTable($tableName));
$emailAuthEdc = $this->addColumnForFailedAuthTable($emailAuthEdc);
$emailAuthEdc = $this->addIndexToFailedAuthTable($installer, $emailAuthEdc);
$emailAuthEdc->setComment('Email Failed Auth Table.');
$installer->getConnection()->createTable($emailAuthEdc);
} | php | public function createFailedAuthTable($installer, $tableName)
{
$emailAuthEdc = $installer->getConnection()->newTable($installer->getTable($tableName));
$emailAuthEdc = $this->addColumnForFailedAuthTable($emailAuthEdc);
$emailAuthEdc = $this->addIndexToFailedAuthTable($installer, $emailAuthEdc);
$emailAuthEdc->setComment('Email Failed Auth Table.');
$installer->getConnection()->createTable($emailAuthEdc);
} | [
"public",
"function",
"createFailedAuthTable",
"(",
"$",
"installer",
",",
"$",
"tableName",
")",
"{",
"$",
"emailAuthEdc",
"=",
"$",
"installer",
"->",
"getConnection",
"(",
")",
"->",
"newTable",
"(",
"$",
"installer",
"->",
"getTable",
"(",
"$",
"tableNam... | Create failed auth table
@param SchemaSetupInterface $installer
@param string $tableName | [
"Create",
"failed",
"auth",
"table"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Setup/Schema/Shared.php#L263-L270 | train |
dotmailer/dotmailer-magento2-extension | Helper/Recommended.php | Recommended.getDisplayType | public function getDisplayType()
{
$mode = $this->context->getRequest()->getActionName();
$type = '';
switch ($mode) {
case 'related':
$type = $this->getRelatedProductsType();
break;
case 'upsell':
$type = $this->getUpsellProductsType();
break;
case 'crosssell':
$type = $this->getCrosssellProductsType();
break;
case 'bestsellers':
$type = $this->getBestSellerProductsType();
break;
case 'mostviewed':
$type = $this->getMostViewedProductsType();
break;
case 'recentlyviewed':
$type = $this->getRecentlyviewedProductsType();
break;
case 'push':
$type = $this->getProductpushProductsType();
}
return $type;
} | php | public function getDisplayType()
{
$mode = $this->context->getRequest()->getActionName();
$type = '';
switch ($mode) {
case 'related':
$type = $this->getRelatedProductsType();
break;
case 'upsell':
$type = $this->getUpsellProductsType();
break;
case 'crosssell':
$type = $this->getCrosssellProductsType();
break;
case 'bestsellers':
$type = $this->getBestSellerProductsType();
break;
case 'mostviewed':
$type = $this->getMostViewedProductsType();
break;
case 'recentlyviewed':
$type = $this->getRecentlyviewedProductsType();
break;
case 'push':
$type = $this->getProductpushProductsType();
}
return $type;
} | [
"public",
"function",
"getDisplayType",
"(",
")",
"{",
"$",
"mode",
"=",
"$",
"this",
"->",
"context",
"->",
"getRequest",
"(",
")",
"->",
"getActionName",
"(",
")",
";",
"$",
"type",
"=",
"''",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"'... | Dispay type.
@return string grid:list | [
"Dispay",
"type",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Recommended.php#L93-L123 | train |
dotmailer/dotmailer-magento2-extension | Helper/Recommended.php | Recommended.getDisplayLimitByMode | public function getDisplayLimitByMode($mode)
{
$result = 0;
switch ($mode) {
case 'related':
$result = $this->scopeConfig->getValue(
self::XML_PATH_RELATED_PRODUCTS_ITEMS
);
break;
case 'upsell':
$result = $this->scopeConfig->getValue(
self::XML_PATH_UPSELL_PRODUCTS_ITEMS
);
break;
case 'crosssell':
$result = $this->scopeConfig->getValue(
self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS
);
break;
case 'bestsellers':
$result = $this->scopeConfig->getValue(
self::XML_PATH_BESTSELLER_PRODUCT_ITEMS
);
break;
case 'mostviewed':
$result = $this->scopeConfig->getValue(
self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS
);
break;
case 'recentlyviewed':
$result = $this->scopeConfig->getValue(
self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS
);
break;
case 'push':
$result = $this->scopeConfig->getValue(
self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS
);
}
return $result;
} | php | public function getDisplayLimitByMode($mode)
{
$result = 0;
switch ($mode) {
case 'related':
$result = $this->scopeConfig->getValue(
self::XML_PATH_RELATED_PRODUCTS_ITEMS
);
break;
case 'upsell':
$result = $this->scopeConfig->getValue(
self::XML_PATH_UPSELL_PRODUCTS_ITEMS
);
break;
case 'crosssell':
$result = $this->scopeConfig->getValue(
self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS
);
break;
case 'bestsellers':
$result = $this->scopeConfig->getValue(
self::XML_PATH_BESTSELLER_PRODUCT_ITEMS
);
break;
case 'mostviewed':
$result = $this->scopeConfig->getValue(
self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS
);
break;
case 'recentlyviewed':
$result = $this->scopeConfig->getValue(
self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS
);
break;
case 'push':
$result = $this->scopeConfig->getValue(
self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS
);
}
return $result;
} | [
"public",
"function",
"getDisplayLimitByMode",
"(",
"$",
"mode",
")",
"{",
"$",
"result",
"=",
"0",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"'related'",
":",
"$",
"result",
"=",
"$",
"this",
"->",
"scopeConfig",
"->",
"getValue",
"(",
"self"... | Limit of products displayed.
@param string $mode
@return int|mixed | [
"Limit",
"of",
"products",
"displayed",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Recommended.php#L214-L256 | train |
dotmailer/dotmailer-magento2-extension | Helper/Recommended.php | Recommended.getFallbackIds | public function getFallbackIds()
{
$fallbackIds = $this->scopeConfig->getValue(
self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
);
if ($fallbackIds) {
return explode(
',',
$this->scopeConfig->getValue(
self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
)
);
}
return [];
} | php | public function getFallbackIds()
{
$fallbackIds = $this->scopeConfig->getValue(
self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
);
if ($fallbackIds) {
return explode(
',',
$this->scopeConfig->getValue(
self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
)
);
}
return [];
} | [
"public",
"function",
"getFallbackIds",
"(",
")",
"{",
"$",
"fallbackIds",
"=",
"$",
"this",
"->",
"scopeConfig",
"->",
"getValue",
"(",
"self",
"::",
"XML_PATH_FALLBACK_PRODUCTS_ITEMS",
")",
";",
"if",
"(",
"$",
"fallbackIds",
")",
"{",
"return",
"explode",
... | Fallback product ids.
@return array | [
"Fallback",
"product",
"ids",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Recommended.php#L263-L278 | train |
dotmailer/dotmailer-magento2-extension | Helper/Recommended.php | Recommended.getTimeFromConfig | public function getTimeFromConfig($config)
{
$now = $this->date;
$period = $this->processConfig($config);
$sub = $this->processPeriod($period);
if (isset($sub)) {
$period = $now->sub(1, $sub);
}
return $period->toString(\Zend_Date::ISO_8601);
} | php | public function getTimeFromConfig($config)
{
$now = $this->date;
$period = $this->processConfig($config);
$sub = $this->processPeriod($period);
if (isset($sub)) {
$period = $now->sub(1, $sub);
}
return $period->toString(\Zend_Date::ISO_8601);
} | [
"public",
"function",
"getTimeFromConfig",
"(",
"$",
"config",
")",
"{",
"$",
"now",
"=",
"$",
"this",
"->",
"date",
";",
"$",
"period",
"=",
"$",
"this",
"->",
"processConfig",
"(",
"$",
"config",
")",
";",
"$",
"sub",
"=",
"$",
"this",
"->",
"pro... | Get time period from config.
@param string $config
@return string | [
"Get",
"time",
"period",
"from",
"config",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Recommended.php#L287-L299 | train |
dotmailer/dotmailer-magento2-extension | Helper/Recommended.php | Recommended.getProductsToDisplay | public function getProductsToDisplay($items, $mode, &$productsToDisplayCounter, $limit, $maxPerChild)
{
$productsToDisplay = [];
foreach ($items as $item) {
//parent product
$productModel = $item->getProduct();
//check for product exists
if ($productModel->getId()) {
//get single product for current mode
$recommendedProductIds = $this->getRecommendedProduct($productModel, $mode);
$recommendedProducts = $this->catalog->getProductCollectionFromIds($recommendedProductIds);
$this->addRecommendedProducts(
$productsToDisplayCounter,
$limit,
$maxPerChild,
$recommendedProducts,
$productsToDisplay
);
}
//have reached the limit don't loop for more
if ($productsToDisplayCounter == $limit) {
break;
}
}
return $productsToDisplay;
} | php | public function getProductsToDisplay($items, $mode, &$productsToDisplayCounter, $limit, $maxPerChild)
{
$productsToDisplay = [];
foreach ($items as $item) {
//parent product
$productModel = $item->getProduct();
//check for product exists
if ($productModel->getId()) {
//get single product for current mode
$recommendedProductIds = $this->getRecommendedProduct($productModel, $mode);
$recommendedProducts = $this->catalog->getProductCollectionFromIds($recommendedProductIds);
$this->addRecommendedProducts(
$productsToDisplayCounter,
$limit,
$maxPerChild,
$recommendedProducts,
$productsToDisplay
);
}
//have reached the limit don't loop for more
if ($productsToDisplayCounter == $limit) {
break;
}
}
return $productsToDisplay;
} | [
"public",
"function",
"getProductsToDisplay",
"(",
"$",
"items",
",",
"$",
"mode",
",",
"&",
"$",
"productsToDisplayCounter",
",",
"$",
"limit",
",",
"$",
"maxPerChild",
")",
"{",
"$",
"productsToDisplay",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"items",
... | Get products to display
@param array $items
@param string $mode
@param int $productsToDisplayCounter
@param int $limit
@param int $maxPerChild
@return array | [
"Get",
"products",
"to",
"display"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Helper/Recommended.php#L372-L400 | train |
dotmailer/dotmailer-magento2-extension | Model/Newsletter/SubscriberWithSalesExporter.php | SubscriberWithSalesExporter.registerWithImporter | private function registerWithImporter($emailContactIds, $subscribersFile, $websiteId)
{
$subscriberNum = count($emailContactIds);
if (is_file($this->file->getFilePath($subscribersFile))) {
if ($subscriberNum > 0) {
//register in queue with importer
$check = $this->importerFactory->create()
->registerQueue(
\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_SUBSCRIBERS,
'',
\Dotdigitalgroup\Email\Model\Importer::MODE_BULK,
$websiteId,
$subscribersFile
);
//mark contacts as imported
if ($check) {
$this->emailContactResource->updateSubscribers($emailContactIds);
}
}
}
} | php | private function registerWithImporter($emailContactIds, $subscribersFile, $websiteId)
{
$subscriberNum = count($emailContactIds);
if (is_file($this->file->getFilePath($subscribersFile))) {
if ($subscriberNum > 0) {
//register in queue with importer
$check = $this->importerFactory->create()
->registerQueue(
\Dotdigitalgroup\Email\Model\Importer::IMPORT_TYPE_SUBSCRIBERS,
'',
\Dotdigitalgroup\Email\Model\Importer::MODE_BULK,
$websiteId,
$subscribersFile
);
//mark contacts as imported
if ($check) {
$this->emailContactResource->updateSubscribers($emailContactIds);
}
}
}
} | [
"private",
"function",
"registerWithImporter",
"(",
"$",
"emailContactIds",
",",
"$",
"subscribersFile",
",",
"$",
"websiteId",
")",
"{",
"$",
"subscriberNum",
"=",
"count",
"(",
"$",
"emailContactIds",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"this",
"->",... | Register data with importer
@param array $emailContactIds
@param string $subscribersFile
@param $websiteId | [
"Register",
"data",
"with",
"importer"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Newsletter/SubscriberWithSalesExporter.php#L213-L233 | train |
dotmailer/dotmailer-magento2-extension | Plugin/TemplatePlugin.php | TemplatePlugin.getProcessedTemplateBeforeSave | private function getProcessedTemplateBeforeSave($result)
{
//saving array values
if (empty($args)) {
$this->getResultIfArgsEmptyForBeforeSave($result);
} else {
//saving string value
$field = $args[0];
//compress the text body when is a dotmailer template
if ($field == 'template_text' && ! $this->isStringCompressed($result) &&
$this->transactionalHelper->isDotmailerTemplate($this->templateCode)
) {
$result = $this->compressString($result);
}
if ($field == 'template_id') {
$this->saveTemplateIdInRegistry($result);
}
}
return $result;
} | php | private function getProcessedTemplateBeforeSave($result)
{
//saving array values
if (empty($args)) {
$this->getResultIfArgsEmptyForBeforeSave($result);
} else {
//saving string value
$field = $args[0];
//compress the text body when is a dotmailer template
if ($field == 'template_text' && ! $this->isStringCompressed($result) &&
$this->transactionalHelper->isDotmailerTemplate($this->templateCode)
) {
$result = $this->compressString($result);
}
if ($field == 'template_id') {
$this->saveTemplateIdInRegistry($result);
}
}
return $result;
} | [
"private",
"function",
"getProcessedTemplateBeforeSave",
"(",
"$",
"result",
")",
"{",
"//saving array values",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"getResultIfArgsEmptyForBeforeSave",
"(",
"$",
"result",
")",
";",
"}",
"els... | Get data before saving
@param mixed $result
@return mixed | [
"Get",
"data",
"before",
"saving"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Plugin/TemplatePlugin.php#L73-L94 | train |
dotmailer/dotmailer-magento2-extension | Model/Apiconnector/EngagementCloudAddressBookApi.php | EngagementCloudAddressBookApi.postAddressBookContactResubscribe | public function postAddressBookContactResubscribe($addressBookId, $email)
{
$contact = ['unsubscribedContact' => ['email' => $email]];
$url = $this->getApiEndpoint() . Client::REST_ADDRESS_BOOKS . $addressBookId
. '/contacts/resubscribe';
$this->setUrl($url)
->setVerb('POST')
->buildPostBody($contact);
$response = $this->execute();
if (isset($response->message)) {
$message = 'POST ADDRESS BOOK CONTACT RESUBSCRIBE ' . $url . ', '
. $response->message;
$this->helper->debug('postAddressBookContactResubscribe', [$message]);
}
return $response;
} | php | public function postAddressBookContactResubscribe($addressBookId, $email)
{
$contact = ['unsubscribedContact' => ['email' => $email]];
$url = $this->getApiEndpoint() . Client::REST_ADDRESS_BOOKS . $addressBookId
. '/contacts/resubscribe';
$this->setUrl($url)
->setVerb('POST')
->buildPostBody($contact);
$response = $this->execute();
if (isset($response->message)) {
$message = 'POST ADDRESS BOOK CONTACT RESUBSCRIBE ' . $url . ', '
. $response->message;
$this->helper->debug('postAddressBookContactResubscribe', [$message]);
}
return $response;
} | [
"public",
"function",
"postAddressBookContactResubscribe",
"(",
"$",
"addressBookId",
",",
"$",
"email",
")",
"{",
"$",
"contact",
"=",
"[",
"'unsubscribedContact'",
"=>",
"[",
"'email'",
"=>",
"$",
"email",
"]",
"]",
";",
"$",
"url",
"=",
"$",
"this",
"->... | Resubscribes a previously unsubscribed contact to a given address book
@param int $addressBookId
@param string $email
@return mixed | [
"Resubscribes",
"a",
"previously",
"unsubscribed",
"contact",
"to",
"a",
"given",
"address",
"book"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Apiconnector/EngagementCloudAddressBookApi.php#L46-L64 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Importer/Collection.php | Collection.getItemsWithImportingStatus | public function getItemsWithImportingStatus($limit)
{
$collection = $this->addFieldToFilter(
'import_status',
['eq' => \Dotdigitalgroup\Email\Model\Importer::IMPORTING]
)
->addFieldToFilter('import_id', ['neq' => ''])
->setPageSize($limit)
->setCurPage(1);
if ($collection->getSize()) {
return $collection;
}
return false;
} | php | public function getItemsWithImportingStatus($limit)
{
$collection = $this->addFieldToFilter(
'import_status',
['eq' => \Dotdigitalgroup\Email\Model\Importer::IMPORTING]
)
->addFieldToFilter('import_id', ['neq' => ''])
->setPageSize($limit)
->setCurPage(1);
if ($collection->getSize()) {
return $collection;
}
return false;
} | [
"public",
"function",
"getItemsWithImportingStatus",
"(",
"$",
"limit",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"addFieldToFilter",
"(",
"'import_status'",
",",
"[",
"'eq'",
"=>",
"\\",
"Dotdigitalgroup",
"\\",
"Email",
"\\",
"Model",
"\\",
"Impor... | Get imports marked as importing.
@param int $limit
@return $this|boolean | [
"Get",
"imports",
"marked",
"as",
"importing",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Importer/Collection.php#L44-L59 | train |
dotmailer/dotmailer-magento2-extension | Model/ResourceModel/Importer/Collection.php | Collection.getQueueByTypeAndMode | public function getQueueByTypeAndMode($importType, $importMode, $limit)
{
if (is_array($importType)) {
$condition = [];
foreach ($importType as $type) {
if ($type == 'Catalog') {
$condition[] = ['like' => $type . '%'];
} else {
$condition[] = ['eq' => $type];
}
}
$this->addFieldToFilter('import_type', $condition);
} else {
$this->addFieldToFilter(
'import_type',
['eq' => $importType]
);
}
$this->addFieldToFilter('import_mode', ['eq' => $importMode])
->addFieldToFilter(
'import_status',
['eq' => \Dotdigitalgroup\Email\Model\Importer::NOT_IMPORTED]
)
->setPageSize($limit)
->setCurPage(1);
return $this;
} | php | public function getQueueByTypeAndMode($importType, $importMode, $limit)
{
if (is_array($importType)) {
$condition = [];
foreach ($importType as $type) {
if ($type == 'Catalog') {
$condition[] = ['like' => $type . '%'];
} else {
$condition[] = ['eq' => $type];
}
}
$this->addFieldToFilter('import_type', $condition);
} else {
$this->addFieldToFilter(
'import_type',
['eq' => $importType]
);
}
$this->addFieldToFilter('import_mode', ['eq' => $importMode])
->addFieldToFilter(
'import_status',
['eq' => \Dotdigitalgroup\Email\Model\Importer::NOT_IMPORTED]
)
->setPageSize($limit)
->setCurPage(1);
return $this;
} | [
"public",
"function",
"getQueueByTypeAndMode",
"(",
"$",
"importType",
",",
"$",
"importMode",
",",
"$",
"limit",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"importType",
")",
")",
"{",
"$",
"condition",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"import... | Get the imports by type and mode.
@param string $importType
@param string $importMode
@param int $limit
@return $this | [
"Get",
"the",
"imports",
"by",
"type",
"and",
"mode",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/ResourceModel/Importer/Collection.php#L70-L98 | train |
dotmailer/dotmailer-magento2-extension | Plugin/MinificationPlugin.php | MinificationPlugin.aroundGetExcludes | public function aroundGetExcludes(
\Magento\Framework\View\Asset\Minification $subject,
callable $proceed,
$contentType
) {
$result = $proceed($contentType);
//Content type can be css or js
if ($contentType == 'js') {
$result[] = 'trackedlink.net/_dmpt.js';
$result[] = 'trackedlink.net/_dmmpt.js';
}
return $result;
} | php | public function aroundGetExcludes(
\Magento\Framework\View\Asset\Minification $subject,
callable $proceed,
$contentType
) {
$result = $proceed($contentType);
//Content type can be css or js
if ($contentType == 'js') {
$result[] = 'trackedlink.net/_dmpt.js';
$result[] = 'trackedlink.net/_dmmpt.js';
}
return $result;
} | [
"public",
"function",
"aroundGetExcludes",
"(",
"\\",
"Magento",
"\\",
"Framework",
"\\",
"View",
"\\",
"Asset",
"\\",
"Minification",
"$",
"subject",
",",
"callable",
"$",
"proceed",
",",
"$",
"contentType",
")",
"{",
"$",
"result",
"=",
"$",
"proceed",
"... | Exclude external js from minification
@param \Magento\Framework\View\Asset\Minification $subject
@param callable $proceed
@param string $contentType
@return array | [
"Exclude",
"external",
"js",
"from",
"minification"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Plugin/MinificationPlugin.php#L21-L35 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Campaign.php | Campaign.sendCampaigns | public function sendCampaigns()
{
/** @var \Magento\Store\Api\Data\WebsiteInterface $website */
foreach ($this->storeManager->getWebsites(true) as $website) {
$storeIds = $website->getStoreIds();
//check send status for processing
$this->_checkSendStatus($website, $storeIds);
//start send process
$emailsToSend = $this->_getEmailCampaigns($storeIds);
$campaignsToSend = $this->getCampaignsToSend($emailsToSend, $website);
$this->sendCampaignsViaEngagementCloud($campaignsToSend);
}
} | php | public function sendCampaigns()
{
/** @var \Magento\Store\Api\Data\WebsiteInterface $website */
foreach ($this->storeManager->getWebsites(true) as $website) {
$storeIds = $website->getStoreIds();
//check send status for processing
$this->_checkSendStatus($website, $storeIds);
//start send process
$emailsToSend = $this->_getEmailCampaigns($storeIds);
$campaignsToSend = $this->getCampaignsToSend($emailsToSend, $website);
$this->sendCampaignsViaEngagementCloud($campaignsToSend);
}
} | [
"public",
"function",
"sendCampaigns",
"(",
")",
"{",
"/** @var \\Magento\\Store\\Api\\Data\\WebsiteInterface $website */",
"foreach",
"(",
"$",
"this",
"->",
"storeManager",
"->",
"getWebsites",
"(",
"true",
")",
"as",
"$",
"website",
")",
"{",
"$",
"storeIds",
"="... | Sending the campaigns
@throws \Magento\Framework\Exception\LocalizedException
@return null | [
"Sending",
"the",
"campaigns"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Campaign.php#L76-L90 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Campaign.php | Campaign.getCampaignsToSend | private function getCampaignsToSend($emailsToSend, $website)
{
$campaignsToSend = [];
foreach ($emailsToSend as $campaign) {
$email = $campaign->getEmail();
$campaignId = $campaign->getCampaignId();
$websiteId = $website->getId();
$client = false;
if ($this->helper->isEnabled($websiteId)) {
$client = $this->helper->getWebsiteApiClient($websiteId);
}
//Only if valid client is returned
if ($client && $this->isCampaignValid($campaign)) {
$campaignsToSend[$campaignId]['client'] = $client;
$contact = $this->helper->getContact(
$campaign->getEmail(),
$websiteId
);
if ($contact && isset($contact->id)) {
//update data fields
if ($campaign->getEventName() == 'Order Review') {
$this->updateDataFieldsForORderReviewCampaigns($campaign, $websiteId, $client, $email);
} elseif ($campaign->getEventName() ==
\Dotdigitalgroup\Email\Model\Campaign::CAMPAIGN_EVENT_LOST_BASKET
) {
$campaignCollection = $this->campaignCollection->create();
// If AC campaigns found with status processing for given email then skip for current cron run
if ($campaignCollection->getNumberOfAcCampaignsWithStatusProcessingExistForContact($email)) {
continue;
}
$this->helper->updateLastQuoteId($campaign->getQuoteId(), $email, $websiteId);
}
$campaignsToSend[$campaignId]['contacts'][] = $contact->id;
$campaignsToSend[$campaignId]['ids'][] = $campaign->getId();
} else {
//update the failed to send email message error message
$campaign->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED)
->setMessage('Send not permitted. Contact is suppressed.');
$this->campaignResourceModel->saveItem($campaign);
}
}
}
return $campaignsToSend;
} | php | private function getCampaignsToSend($emailsToSend, $website)
{
$campaignsToSend = [];
foreach ($emailsToSend as $campaign) {
$email = $campaign->getEmail();
$campaignId = $campaign->getCampaignId();
$websiteId = $website->getId();
$client = false;
if ($this->helper->isEnabled($websiteId)) {
$client = $this->helper->getWebsiteApiClient($websiteId);
}
//Only if valid client is returned
if ($client && $this->isCampaignValid($campaign)) {
$campaignsToSend[$campaignId]['client'] = $client;
$contact = $this->helper->getContact(
$campaign->getEmail(),
$websiteId
);
if ($contact && isset($contact->id)) {
//update data fields
if ($campaign->getEventName() == 'Order Review') {
$this->updateDataFieldsForORderReviewCampaigns($campaign, $websiteId, $client, $email);
} elseif ($campaign->getEventName() ==
\Dotdigitalgroup\Email\Model\Campaign::CAMPAIGN_EVENT_LOST_BASKET
) {
$campaignCollection = $this->campaignCollection->create();
// If AC campaigns found with status processing for given email then skip for current cron run
if ($campaignCollection->getNumberOfAcCampaignsWithStatusProcessingExistForContact($email)) {
continue;
}
$this->helper->updateLastQuoteId($campaign->getQuoteId(), $email, $websiteId);
}
$campaignsToSend[$campaignId]['contacts'][] = $contact->id;
$campaignsToSend[$campaignId]['ids'][] = $campaign->getId();
} else {
//update the failed to send email message error message
$campaign->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED)
->setMessage('Send not permitted. Contact is suppressed.');
$this->campaignResourceModel->saveItem($campaign);
}
}
}
return $campaignsToSend;
} | [
"private",
"function",
"getCampaignsToSend",
"(",
"$",
"emailsToSend",
",",
"$",
"website",
")",
"{",
"$",
"campaignsToSend",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"emailsToSend",
"as",
"$",
"campaign",
")",
"{",
"$",
"email",
"=",
"$",
"campaign",
"-... | Get campaigns to send.
@param \Dotdigitalgroup\Email\Model\ResourceModel\Campaign\Collection $emailsToSend
@param \Magento\Store\Api\Data\WebsiteInterface $website
@return array | [
"Get",
"campaigns",
"to",
"send",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Campaign.php#L149-L194 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Campaign.php | Campaign.isCampaignValid | private function isCampaignValid($campaign)
{
if (! $campaign->getCampaignId()) {
$campaign->setMessage('Missing campaign id: ' . $campaign->getCampaignId())
->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED);
$this->campaignResourceModel->saveItem($campaign);
return false;
} elseif (! $campaign->getEmail()) {
$campaign->setMessage('Missing email')
->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED);
$this->campaignResourceModel->saveItem($campaign);
return false;
}
return true;
} | php | private function isCampaignValid($campaign)
{
if (! $campaign->getCampaignId()) {
$campaign->setMessage('Missing campaign id: ' . $campaign->getCampaignId())
->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED);
$this->campaignResourceModel->saveItem($campaign);
return false;
} elseif (! $campaign->getEmail()) {
$campaign->setMessage('Missing email')
->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED);
$this->campaignResourceModel->saveItem($campaign);
return false;
}
return true;
} | [
"private",
"function",
"isCampaignValid",
"(",
"$",
"campaign",
")",
"{",
"if",
"(",
"!",
"$",
"campaign",
"->",
"getCampaignId",
"(",
")",
")",
"{",
"$",
"campaign",
"->",
"setMessage",
"(",
"'Missing campaign id: '",
".",
"$",
"campaign",
"->",
"getCampaig... | Check if campaign item is valid
@param \Dotdigitalgroup\Email\Model\Campaign $campaign
@return bool | [
"Check",
"if",
"campaign",
"item",
"is",
"valid"
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Campaign.php#L203-L217 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Campaign.php | Campaign.sendCampaignsViaEngagementCloud | private function sendCampaignsViaEngagementCloud($campaignsToSend)
{
foreach ($campaignsToSend as $campaignId => $data) {
if (isset($data['contacts']) && isset($data['client'])) {
$contacts = $data['contacts'];
/** @var \Dotdigitalgroup\Email\Model\Apiconnector\Client $client */
$client = $data['client'];
$response = $client->postCampaignsSend(
$campaignId,
$contacts
);
if (isset($response->message)) {
//update the failed to send email message
$this->campaignResourceModel->setMessage($data['ids'], $response->message);
} elseif (isset($response->id)) {
$this->campaignResourceModel->setProcessing($data['ids'], $response->id);
} else {
//update the failed to send email message
$this->campaignResourceModel->setMessage($data['ids'], 'No send id returned.');
}
}
}
} | php | private function sendCampaignsViaEngagementCloud($campaignsToSend)
{
foreach ($campaignsToSend as $campaignId => $data) {
if (isset($data['contacts']) && isset($data['client'])) {
$contacts = $data['contacts'];
/** @var \Dotdigitalgroup\Email\Model\Apiconnector\Client $client */
$client = $data['client'];
$response = $client->postCampaignsSend(
$campaignId,
$contacts
);
if (isset($response->message)) {
//update the failed to send email message
$this->campaignResourceModel->setMessage($data['ids'], $response->message);
} elseif (isset($response->id)) {
$this->campaignResourceModel->setProcessing($data['ids'], $response->id);
} else {
//update the failed to send email message
$this->campaignResourceModel->setMessage($data['ids'], 'No send id returned.');
}
}
}
} | [
"private",
"function",
"sendCampaignsViaEngagementCloud",
"(",
"$",
"campaignsToSend",
")",
"{",
"foreach",
"(",
"$",
"campaignsToSend",
"as",
"$",
"campaignId",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'contacts'",
"]",
")",
... | Send campaigns.
@param array $campaignsToSend
@return null | [
"Send",
"campaigns",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Campaign.php#L226-L248 | train |
dotmailer/dotmailer-magento2-extension | Model/Config/Configuration/Attributes.php | Attributes.toOptionArray | public function toOptionArray()
{
$fields = $this->dataHelper->getOrderTableDescription();
$customFields[] = [
'label' => __('---- Default Option ----'),
'value' => '0',
];
foreach ($fields as $field) {
$customFields[] = [
'value' => $field['COLUMN_NAME'],
'label' => $field['COLUMN_NAME'],
];
}
return $customFields;
} | php | public function toOptionArray()
{
$fields = $this->dataHelper->getOrderTableDescription();
$customFields[] = [
'label' => __('---- Default Option ----'),
'value' => '0',
];
foreach ($fields as $field) {
$customFields[] = [
'value' => $field['COLUMN_NAME'],
'label' => $field['COLUMN_NAME'],
];
}
return $customFields;
} | [
"public",
"function",
"toOptionArray",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"dataHelper",
"->",
"getOrderTableDescription",
"(",
")",
";",
"$",
"customFields",
"[",
"]",
"=",
"[",
"'label'",
"=>",
"__",
"(",
"'---- Default Option ----'",
")"... | Returns custom order attributes.
@return array | [
"Returns",
"custom",
"order",
"attributes",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Config/Configuration/Attributes.php#L28-L44 | train |
dotmailer/dotmailer-magento2-extension | Controller/Email/Accountcallback.php | Accountcallback.sendAjaxResponse | private function sendAjaxResponse($error)
{
$message = [
'err' => $error
];
$this->getResponse()
->setHeader('Content-type', 'application/javascript', true)
->setBody(
'signupCallback(' . $this->jsonHelper->jsonEncode($message) . ')'
)
->sendResponse();
} | php | private function sendAjaxResponse($error)
{
$message = [
'err' => $error
];
$this->getResponse()
->setHeader('Content-type', 'application/javascript', true)
->setBody(
'signupCallback(' . $this->jsonHelper->jsonEncode($message) . ')'
)
->sendResponse();
} | [
"private",
"function",
"sendAjaxResponse",
"(",
"$",
"error",
")",
"{",
"$",
"message",
"=",
"[",
"'err'",
"=>",
"$",
"error",
"]",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setHeader",
"(",
"'Content-type'",
",",
"'application/javascript'",
... | Send ajax response.
@param string $error
@param string $msg
@return void | [
"Send",
"ajax",
"response",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Controller/Email/Accountcallback.php#L127-L139 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Wishlist.php | Wishlist.sync | public function sync()
{
$response = ['success' => true, 'message' => 'Done.'];
$websites = $this->helper->getWebsites();
foreach ($websites as $website) {
$wishlistEnabled = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED,
$website
);
$apiEnabled = $this->helper->isEnabled($website);
$storeIds = $website->getStoreIds();
if ($wishlistEnabled && $apiEnabled && ! empty($storeIds)) {
//using bulk api
$this->start = microtime(true);
$this->exportWishlistForWebsite($website);
//send wishlist as transactional data
if (isset($this->wishlists[$website->getId()])) {
$websiteWishlists = $this->wishlists[$website->getId()];
//register in queue with importer
$this->importerFactory->create()
->registerQueue(
Importer::IMPORT_TYPE_WISHLIST,
$websiteWishlists,
Importer::MODE_BULK,
$website->getId()
);
//mark connector wishlist as imported
$this->setImported($this->wishlistIds);
}
if (! empty($this->wishlists)) {
$message = '----------- Wishlist bulk sync ----------- : ' .
gmdate('H:i:s', microtime(true) - $this->start) .
', Total synced = ' . $this->countWishlists;
$this->helper->log($message);
}
//using single api
$this->exportWishlistForWebsiteInSingle($website);
}
}
$response['message'] = 'wishlists updated: ' . $this->countWishlists;
return $response;
} | php | public function sync()
{
$response = ['success' => true, 'message' => 'Done.'];
$websites = $this->helper->getWebsites();
foreach ($websites as $website) {
$wishlistEnabled = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED,
$website
);
$apiEnabled = $this->helper->isEnabled($website);
$storeIds = $website->getStoreIds();
if ($wishlistEnabled && $apiEnabled && ! empty($storeIds)) {
//using bulk api
$this->start = microtime(true);
$this->exportWishlistForWebsite($website);
//send wishlist as transactional data
if (isset($this->wishlists[$website->getId()])) {
$websiteWishlists = $this->wishlists[$website->getId()];
//register in queue with importer
$this->importerFactory->create()
->registerQueue(
Importer::IMPORT_TYPE_WISHLIST,
$websiteWishlists,
Importer::MODE_BULK,
$website->getId()
);
//mark connector wishlist as imported
$this->setImported($this->wishlistIds);
}
if (! empty($this->wishlists)) {
$message = '----------- Wishlist bulk sync ----------- : ' .
gmdate('H:i:s', microtime(true) - $this->start) .
', Total synced = ' . $this->countWishlists;
$this->helper->log($message);
}
//using single api
$this->exportWishlistForWebsiteInSingle($website);
}
}
$response['message'] = 'wishlists updated: ' . $this->countWishlists;
return $response;
} | [
"public",
"function",
"sync",
"(",
")",
"{",
"$",
"response",
"=",
"[",
"'success'",
"=>",
"true",
",",
"'message'",
"=>",
"'Done.'",
"]",
";",
"$",
"websites",
"=",
"$",
"this",
"->",
"helper",
"->",
"getWebsites",
"(",
")",
";",
"foreach",
"(",
"$"... | Sync Wishlists.
@return array | [
"Sync",
"Wishlists",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Wishlist.php#L119-L164 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Wishlist.php | Wishlist.exportWishlistForWebsiteInSingle | public function exportWishlistForWebsiteInSingle(\Magento\Store\Api\Data\WebsiteInterface $website)
{
//transactional data limit
$limit = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT,
$website
);
$collection = $this->getModifiedWishlistToImport(
$website,
$limit
);
$this->wishlistIds = [];
//email_wishlist wishlist ids
$wishlistIds = $collection->getColumnValues('wishlist_id');
$wishlistCollection = $this->wishlist->create()
->getWishlistByIds($wishlistIds);
foreach ($wishlistCollection as $wishlist) {
$wishlistId = $wishlist->getid();
$wishlistItems = $this->itemCollection->create()
->addWishlistFilter($wishlist);
$connectorWishlist = $this->wishlistFactory->create();
$connectorWishlist->setId($wishlistId)
->setUpdatedAt($wishlist->getUpdatedAt())
->setCustomerId($wishlist->getCustomerId())
->setEmail($wishlist->getEmail());
if ($wishlistItems->getSize()) {
/** @var \Magento\Wishlist\Model\Item $item */
foreach ($wishlistItems as $item) {
try {
$product = $item->getProduct();
$connectorWishlistItem = $this->createConnectorWishlistItem($product, $item);
if ($connectorWishlistItem) {
$connectorWishlist->setItem($connectorWishlistItem);
}
$this->countWishlists++;
} catch (\Exception $e) {
//Product does not exist. Continue to next item
continue;
}
}
//send wishlist as transactional data
$this->start = microtime(true);
//register in queue with importer
$check = $this->importerFactory->create()
->registerQueue(
Importer::IMPORT_TYPE_WISHLIST,
$connectorWishlist->expose(),
Importer::MODE_SINGLE,
$website->getId()
);
if ($check) {
$this->wishlistIds[] = $wishlistId;
}
} else {
//register in queue with importer
$check = $this->importerFactory->create()
->registerQueue(
Importer::IMPORT_TYPE_WISHLIST,
[$wishlist->getId()],
Importer::MODE_SINGLE_DELETE,
$website->getId()
);
if ($check) {
$this->wishlistIds[] = $wishlistId;
}
}
}
if (! empty($this->wishlistIds)) {
$this->setImported($this->wishlistIds, true);
}
} | php | public function exportWishlistForWebsiteInSingle(\Magento\Store\Api\Data\WebsiteInterface $website)
{
//transactional data limit
$limit = $this->helper->getWebsiteConfig(
\Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT,
$website
);
$collection = $this->getModifiedWishlistToImport(
$website,
$limit
);
$this->wishlistIds = [];
//email_wishlist wishlist ids
$wishlistIds = $collection->getColumnValues('wishlist_id');
$wishlistCollection = $this->wishlist->create()
->getWishlistByIds($wishlistIds);
foreach ($wishlistCollection as $wishlist) {
$wishlistId = $wishlist->getid();
$wishlistItems = $this->itemCollection->create()
->addWishlistFilter($wishlist);
$connectorWishlist = $this->wishlistFactory->create();
$connectorWishlist->setId($wishlistId)
->setUpdatedAt($wishlist->getUpdatedAt())
->setCustomerId($wishlist->getCustomerId())
->setEmail($wishlist->getEmail());
if ($wishlistItems->getSize()) {
/** @var \Magento\Wishlist\Model\Item $item */
foreach ($wishlistItems as $item) {
try {
$product = $item->getProduct();
$connectorWishlistItem = $this->createConnectorWishlistItem($product, $item);
if ($connectorWishlistItem) {
$connectorWishlist->setItem($connectorWishlistItem);
}
$this->countWishlists++;
} catch (\Exception $e) {
//Product does not exist. Continue to next item
continue;
}
}
//send wishlist as transactional data
$this->start = microtime(true);
//register in queue with importer
$check = $this->importerFactory->create()
->registerQueue(
Importer::IMPORT_TYPE_WISHLIST,
$connectorWishlist->expose(),
Importer::MODE_SINGLE,
$website->getId()
);
if ($check) {
$this->wishlistIds[] = $wishlistId;
}
} else {
//register in queue with importer
$check = $this->importerFactory->create()
->registerQueue(
Importer::IMPORT_TYPE_WISHLIST,
[$wishlist->getId()],
Importer::MODE_SINGLE_DELETE,
$website->getId()
);
if ($check) {
$this->wishlistIds[] = $wishlistId;
}
}
}
if (! empty($this->wishlistIds)) {
$this->setImported($this->wishlistIds, true);
}
} | [
"public",
"function",
"exportWishlistForWebsiteInSingle",
"(",
"\\",
"Magento",
"\\",
"Store",
"\\",
"Api",
"\\",
"Data",
"\\",
"WebsiteInterface",
"$",
"website",
")",
"{",
"//transactional data limit",
"$",
"limit",
"=",
"$",
"this",
"->",
"helper",
"->",
"get... | Export single wishlist for website.
@param \Magento\Store\Api\Data\WebsiteInterface $website
@return null | [
"Export",
"single",
"wishlist",
"for",
"website",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Wishlist.php#L244-L318 | train |
dotmailer/dotmailer-magento2-extension | Model/Sync/Wishlist.php | Wishlist.getModifiedWishlistToImport | public function getModifiedWishlistToImport(\Magento\Store\Api\Data\WebsiteInterface $website, $limit = 100)
{
return $this->wishlistCollection->create()
->getModifiedWishlistToImportByWebsite($website, $limit);
} | php | public function getModifiedWishlistToImport(\Magento\Store\Api\Data\WebsiteInterface $website, $limit = 100)
{
return $this->wishlistCollection->create()
->getModifiedWishlistToImportByWebsite($website, $limit);
} | [
"public",
"function",
"getModifiedWishlistToImport",
"(",
"\\",
"Magento",
"\\",
"Store",
"\\",
"Api",
"\\",
"Data",
"\\",
"WebsiteInterface",
"$",
"website",
",",
"$",
"limit",
"=",
"100",
")",
"{",
"return",
"$",
"this",
"->",
"wishlistCollection",
"->",
"... | Get wishlists marked as modified for website.
@param \Magento\Store\Api\Data\WebsiteInterface $website
@param int $limit
@return mixed | [
"Get",
"wishlists",
"marked",
"as",
"modified",
"for",
"website",
"."
] | 125eb29932edb08fe3438635034ced12debe2528 | https://github.com/dotmailer/dotmailer-magento2-extension/blob/125eb29932edb08fe3438635034ced12debe2528/Model/Sync/Wishlist.php#L328-L332 | train |
hiqdev/composer-config-plugin | src/Package.php | Package.collectAliases | public function collectAliases(): array
{
$aliases = array_merge(
$this->prepareAliases('psr-0'),
$this->prepareAliases('psr-4')
);
if ($this->isRoot()) {
$aliases = array_merge($aliases,
$this->prepareAliases('psr-0', true),
$this->prepareAliases('psr-4', true)
);
}
return $aliases;
} | php | public function collectAliases(): array
{
$aliases = array_merge(
$this->prepareAliases('psr-0'),
$this->prepareAliases('psr-4')
);
if ($this->isRoot()) {
$aliases = array_merge($aliases,
$this->prepareAliases('psr-0', true),
$this->prepareAliases('psr-4', true)
);
}
return $aliases;
} | [
"public",
"function",
"collectAliases",
"(",
")",
":",
"array",
"{",
"$",
"aliases",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"prepareAliases",
"(",
"'psr-0'",
")",
",",
"$",
"this",
"->",
"prepareAliases",
"(",
"'psr-4'",
")",
")",
";",
"if",
"(",
... | Collects package aliases.
@return array collected aliases | [
"Collects",
"package",
"aliases",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Package.php#L59-L73 | train |
hiqdev/composer-config-plugin | src/Package.php | Package.preparePath | public function preparePath(string $file): string
{
if (0 === strncmp($file, '$', 1)) {
return $file;
}
$skippable = 0 === strncmp($file, '?', 1) ? '?' : '';
if ($skippable) {
$file = substr($file, 1);
}
if (!$this->getFilesystem()->isAbsolutePath($file)) {
$prefix = $this->isRoot()
? $this->getBaseDir()
: $this->getVendorDir() . '/' . $this->getPrettyName();
$file = $prefix . '/' . $file;
}
return $skippable . $this->getFilesystem()->normalizePath($file);
} | php | public function preparePath(string $file): string
{
if (0 === strncmp($file, '$', 1)) {
return $file;
}
$skippable = 0 === strncmp($file, '?', 1) ? '?' : '';
if ($skippable) {
$file = substr($file, 1);
}
if (!$this->getFilesystem()->isAbsolutePath($file)) {
$prefix = $this->isRoot()
? $this->getBaseDir()
: $this->getVendorDir() . '/' . $this->getPrettyName();
$file = $prefix . '/' . $file;
}
return $skippable . $this->getFilesystem()->normalizePath($file);
} | [
"public",
"function",
"preparePath",
"(",
"string",
"$",
"file",
")",
":",
"string",
"{",
"if",
"(",
"0",
"===",
"strncmp",
"(",
"$",
"file",
",",
"'$'",
",",
"1",
")",
")",
"{",
"return",
"$",
"file",
";",
"}",
"$",
"skippable",
"=",
"0",
"===",... | Builds path inside of a package.
@param string $file
@return string absolute paths will stay untouched | [
"Builds",
"path",
"inside",
"of",
"a",
"package",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Package.php#L253-L272 | train |
hiqdev/composer-config-plugin | src/Package.php | Package.getBaseDir | public function getBaseDir()
{
if (null === $this->baseDir) {
$this->baseDir = dirname($this->getVendorDir());
}
return $this->baseDir;
} | php | public function getBaseDir()
{
if (null === $this->baseDir) {
$this->baseDir = dirname($this->getVendorDir());
}
return $this->baseDir;
} | [
"public",
"function",
"getBaseDir",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"baseDir",
")",
"{",
"$",
"this",
"->",
"baseDir",
"=",
"dirname",
"(",
"$",
"this",
"->",
"getVendorDir",
"(",
")",
")",
";",
"}",
"return",
"$",
"this... | Get absolute path to package base dir.
@return string | [
"Get",
"absolute",
"path",
"to",
"package",
"base",
"dir",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Package.php#L278-L285 | train |
hiqdev/composer-config-plugin | src/readers/EnvReader.php | EnvReader.createDotenv | private function createDotenv($dir, $file)
{
if (method_exists(Dotenv::class, 'create')) {
return Dotenv::create($dir, $file);
} else {
return new Dotenv($dir, $file);
}
} | php | private function createDotenv($dir, $file)
{
if (method_exists(Dotenv::class, 'create')) {
return Dotenv::create($dir, $file);
} else {
return new Dotenv($dir, $file);
}
} | [
"private",
"function",
"createDotenv",
"(",
"$",
"dir",
",",
"$",
"file",
")",
"{",
"if",
"(",
"method_exists",
"(",
"Dotenv",
"::",
"class",
",",
"'create'",
")",
")",
"{",
"return",
"Dotenv",
"::",
"create",
"(",
"$",
"dir",
",",
"$",
"file",
")",
... | Creates Dotenv object.
Supports both 2 and 3 version of `phpdotenv`
@param mixed $dir
@param mixed $file
@return Dotenv | [
"Creates",
"Dotenv",
"object",
".",
"Supports",
"both",
"2",
"and",
"3",
"version",
"of",
"phpdotenv"
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/readers/EnvReader.php#L44-L51 | train |
hiqdev/composer-config-plugin | src/Plugin.php | Plugin.processPackage | protected function processPackage(Package $package)
{
$extra = $package->getExtra();
$files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
$this->originalFiles[$package->getPrettyName()] = $files;
if (is_array($files)) {
$this->addFiles($package, $files);
}
if ($package->isRoot()) {
$this->loadDotEnv($package);
if (!empty($extra[self::EXTRA_DEV_OPTION_NAME])) {
$this->addFiles($package, $extra[self::EXTRA_DEV_OPTION_NAME]);
}
}
$aliases = $package->collectAliases();
$this->builder->mergeAliases($aliases);
$this->builder->setPackage($package->getPrettyName(), array_filter([
'name' => $package->getPrettyName(),
'version' => $package->getVersion(),
'reference' => $package->getSourceReference() ?: $package->getDistReference(),
'aliases' => $aliases,
]));
} | php | protected function processPackage(Package $package)
{
$extra = $package->getExtra();
$files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
$this->originalFiles[$package->getPrettyName()] = $files;
if (is_array($files)) {
$this->addFiles($package, $files);
}
if ($package->isRoot()) {
$this->loadDotEnv($package);
if (!empty($extra[self::EXTRA_DEV_OPTION_NAME])) {
$this->addFiles($package, $extra[self::EXTRA_DEV_OPTION_NAME]);
}
}
$aliases = $package->collectAliases();
$this->builder->mergeAliases($aliases);
$this->builder->setPackage($package->getPrettyName(), array_filter([
'name' => $package->getPrettyName(),
'version' => $package->getVersion(),
'reference' => $package->getSourceReference() ?: $package->getDistReference(),
'aliases' => $aliases,
]));
} | [
"protected",
"function",
"processPackage",
"(",
"Package",
"$",
"package",
")",
"{",
"$",
"extra",
"=",
"$",
"package",
"->",
"getExtra",
"(",
")",
";",
"$",
"files",
"=",
"isset",
"(",
"$",
"extra",
"[",
"self",
"::",
"EXTRA_OPTION_NAME",
"]",
")",
"?... | Scans the given package and collects packages data.
@param Package $package | [
"Scans",
"the",
"given",
"package",
"and",
"collects",
"packages",
"data",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Plugin.php#L171-L196 | train |
hiqdev/composer-config-plugin | src/Plugin.php | Plugin.iteratePackage | protected function iteratePackage(Package $package, $includingDev = false)
{
$name = $package->getPrettyName();
/// prevent infinite loop in case of circular dependencies
static $processed = [];
if (isset($processed[$name])) {
return;
} else {
$processed[$name] = 1;
}
/// package depth in dependency hierarchy
static $depth = 0;
++$depth;
$this->iterateDependencies($package);
if ($includingDev) {
$this->iterateDependencies($package, true);
}
if (!isset($this->orderedList[$name])) {
$this->orderedList[$name] = $depth;
}
--$depth;
} | php | protected function iteratePackage(Package $package, $includingDev = false)
{
$name = $package->getPrettyName();
/// prevent infinite loop in case of circular dependencies
static $processed = [];
if (isset($processed[$name])) {
return;
} else {
$processed[$name] = 1;
}
/// package depth in dependency hierarchy
static $depth = 0;
++$depth;
$this->iterateDependencies($package);
if ($includingDev) {
$this->iterateDependencies($package, true);
}
if (!isset($this->orderedList[$name])) {
$this->orderedList[$name] = $depth;
}
--$depth;
} | [
"protected",
"function",
"iteratePackage",
"(",
"Package",
"$",
"package",
",",
"$",
"includingDev",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
";",
"/// prevent infinite loop in case of circular dependencies",
"static... | Iterates through package dependencies.
@param Package $package to iterate
@param bool $includingDev process development dependencies, defaults to not process | [
"Iterates",
"through",
"package",
"dependencies",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Plugin.php#L309-L334 | train |
hiqdev/composer-config-plugin | src/Plugin.php | Plugin.iterateDependencies | protected function iterateDependencies(Package $package, $dev = false)
{
$deps = $dev ? $package->getDevRequires() : $package->getRequires();
foreach (array_keys($deps) as $target) {
if (isset($this->plainList[$target]) && empty($this->orderedList[$target])) {
$this->iteratePackage($this->plainList[$target]);
}
}
} | php | protected function iterateDependencies(Package $package, $dev = false)
{
$deps = $dev ? $package->getDevRequires() : $package->getRequires();
foreach (array_keys($deps) as $target) {
if (isset($this->plainList[$target]) && empty($this->orderedList[$target])) {
$this->iteratePackage($this->plainList[$target]);
}
}
} | [
"protected",
"function",
"iterateDependencies",
"(",
"Package",
"$",
"package",
",",
"$",
"dev",
"=",
"false",
")",
"{",
"$",
"deps",
"=",
"$",
"dev",
"?",
"$",
"package",
"->",
"getDevRequires",
"(",
")",
":",
"$",
"package",
"->",
"getRequires",
"(",
... | Iterates dependencies of the given package.
@param Package $package
@param bool $dev which dependencies to iterate: true - dev, default - general | [
"Iterates",
"dependencies",
"of",
"the",
"given",
"package",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Plugin.php#L341-L349 | train |
hiqdev/composer-config-plugin | src/configs/Config.php | Config.loadFile | protected function loadFile($path): array
{
$reader = ReaderFactory::get($this->builder, $path);
return $reader->read($path);
} | php | protected function loadFile($path): array
{
$reader = ReaderFactory::get($this->builder, $path);
return $reader->read($path);
} | [
"protected",
"function",
"loadFile",
"(",
"$",
"path",
")",
":",
"array",
"{",
"$",
"reader",
"=",
"ReaderFactory",
"::",
"get",
"(",
"$",
"this",
"->",
"builder",
",",
"$",
"path",
")",
";",
"return",
"$",
"reader",
"->",
"read",
"(",
"$",
"path",
... | Reads config file.
@param string $path
@return array configuration read from file | [
"Reads",
"config",
"file",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/configs/Config.php#L89-L94 | train |
hiqdev/composer-config-plugin | src/configs/Config.php | Config.writePhpFile | protected function writePhpFile(string $path, $data, bool $withEnv, bool $withDefines): void
{
static::putFile($path, $this->replaceMarkers(implode("\n\n", array_filter([
'header' => '<?php',
'baseDir' => '$baseDir = dirname(dirname(dirname(__DIR__)));',
'BASEDIR' => "defined('COMPOSER_CONFIG_PLUGIN_BASEDIR') or define('COMPOSER_CONFIG_PLUGIN_BASEDIR', \$baseDir);",
'dotenv' => $withEnv ? "\$_ENV = array_merge((array) require __DIR__ . '/dotenv.php', (array) \$_ENV);" : '',
'defines' => $withDefines ? $this->builder->getConfig('defines')->buildRequires() : '',
'content' => is_array($data) ? $this->renderVars($data) : $data,
]))) . "\n");
} | php | protected function writePhpFile(string $path, $data, bool $withEnv, bool $withDefines): void
{
static::putFile($path, $this->replaceMarkers(implode("\n\n", array_filter([
'header' => '<?php',
'baseDir' => '$baseDir = dirname(dirname(dirname(__DIR__)));',
'BASEDIR' => "defined('COMPOSER_CONFIG_PLUGIN_BASEDIR') or define('COMPOSER_CONFIG_PLUGIN_BASEDIR', \$baseDir);",
'dotenv' => $withEnv ? "\$_ENV = array_merge((array) require __DIR__ . '/dotenv.php', (array) \$_ENV);" : '',
'defines' => $withDefines ? $this->builder->getConfig('defines')->buildRequires() : '',
'content' => is_array($data) ? $this->renderVars($data) : $data,
]))) . "\n");
} | [
"protected",
"function",
"writePhpFile",
"(",
"string",
"$",
"path",
",",
"$",
"data",
",",
"bool",
"$",
"withEnv",
",",
"bool",
"$",
"withDefines",
")",
":",
"void",
"{",
"static",
"::",
"putFile",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"replaceMar... | Writes complete PHP config file by full path.
@param string $path
@param string|array $data
@param bool $withEnv
@param bool $withDefines
@throws FailedWriteException
@throws \ReflectionException | [
"Writes",
"complete",
"PHP",
"config",
"file",
"by",
"full",
"path",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/configs/Config.php#L135-L145 | train |
hiqdev/composer-config-plugin | src/configs/Config.php | Config.putFile | protected static function putFile($path, $content): void
{
if (file_exists($path) && $content === file_get_contents($path)) {
return;
}
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0777, true);
}
if (false === file_put_contents($path, $content)) {
throw new FailedWriteException("Failed write file $path");
}
} | php | protected static function putFile($path, $content): void
{
if (file_exists($path) && $content === file_get_contents($path)) {
return;
}
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0777, true);
}
if (false === file_put_contents($path, $content)) {
throw new FailedWriteException("Failed write file $path");
}
} | [
"protected",
"static",
"function",
"putFile",
"(",
"$",
"path",
",",
"$",
"content",
")",
":",
"void",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
"&&",
"$",
"content",
"===",
"file_get_contents",
"(",
"$",
"path",
")",
")",
"{",
"return",
... | Writes file if content changed.
@param string $path
@param string $content
@throws FailedWriteException | [
"Writes",
"file",
"if",
"content",
"changed",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/configs/Config.php#L170-L181 | train |
hiqdev/composer-config-plugin | src/configs/Config.php | Config.substituteOutputDirs | public function substituteOutputDirs(array $data): array
{
$dir = static::normalizePath(dirname(dirname(dirname($this->getOutputDir()))));
return static::substitutePaths($data, $dir, static::BASE_DIR_MARKER);
} | php | public function substituteOutputDirs(array $data): array
{
$dir = static::normalizePath(dirname(dirname(dirname($this->getOutputDir()))));
return static::substitutePaths($data, $dir, static::BASE_DIR_MARKER);
} | [
"public",
"function",
"substituteOutputDirs",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"dir",
"=",
"static",
"::",
"normalizePath",
"(",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"$",
"this",
"->",
"getOutputDir",
"(",
")",
")",
")",... | Substitute output paths in given data array recursively with marker.
@param array $data
@return array | [
"Substitute",
"output",
"paths",
"in",
"given",
"data",
"array",
"recursively",
"with",
"marker",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/configs/Config.php#L188-L193 | train |
hiqdev/composer-config-plugin | src/configs/Config.php | Config.normalizePath | public static function normalizePath($path, $ds = self::UNIX_DS): string
{
return rtrim(strtr($path, '/\\', $ds . $ds), $ds);
} | php | public static function normalizePath($path, $ds = self::UNIX_DS): string
{
return rtrim(strtr($path, '/\\', $ds . $ds), $ds);
} | [
"public",
"static",
"function",
"normalizePath",
"(",
"$",
"path",
",",
"$",
"ds",
"=",
"self",
"::",
"UNIX_DS",
")",
":",
"string",
"{",
"return",
"rtrim",
"(",
"strtr",
"(",
"$",
"path",
",",
"'/\\\\'",
",",
"$",
"ds",
".",
"$",
"ds",
")",
",",
... | Normalizes given path with given directory separator.
Default forced to Unix directory separator for substitutePaths to work properly in Windows.
@param string $path path to be normalized
@param string $ds directory separator
@return string | [
"Normalizes",
"given",
"path",
"with",
"given",
"directory",
"separator",
".",
"Default",
"forced",
"to",
"Unix",
"directory",
"separator",
"for",
"substitutePaths",
"to",
"work",
"properly",
"in",
"Windows",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/configs/Config.php#L202-L205 | train |
hiqdev/composer-config-plugin | src/configs/Config.php | Config.substitutePaths | public static function substitutePaths($data, $dir, $alias): array
{
foreach ($data as &$value) {
if (is_string($value)) {
$value = static::substitutePath($value, $dir, $alias);
} elseif (is_array($value)) {
$value = static::substitutePaths($value, $dir, $alias);
}
}
return $data;
} | php | public static function substitutePaths($data, $dir, $alias): array
{
foreach ($data as &$value) {
if (is_string($value)) {
$value = static::substitutePath($value, $dir, $alias);
} elseif (is_array($value)) {
$value = static::substitutePaths($value, $dir, $alias);
}
}
return $data;
} | [
"public",
"static",
"function",
"substitutePaths",
"(",
"$",
"data",
",",
"$",
"dir",
",",
"$",
"alias",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
... | Substitute all paths in given array recursively with alias if applicable.
@param array $data
@param string $dir
@param string $alias
@return array | [
"Substitute",
"all",
"paths",
"in",
"given",
"array",
"recursively",
"with",
"alias",
"if",
"applicable",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/configs/Config.php#L214-L225 | train |
hiqdev/composer-config-plugin | src/Builder.php | Builder.findOutputDir | public static function findOutputDir($vendor = null)
{
if ($vendor) {
$dir = $vendor . '/hiqdev/' . basename(dirname(__DIR__));
} else {
$dir = \dirname(__DIR__);
}
return $dir . static::OUTPUT_DIR_SUFFIX;
} | php | public static function findOutputDir($vendor = null)
{
if ($vendor) {
$dir = $vendor . '/hiqdev/' . basename(dirname(__DIR__));
} else {
$dir = \dirname(__DIR__);
}
return $dir . static::OUTPUT_DIR_SUFFIX;
} | [
"public",
"static",
"function",
"findOutputDir",
"(",
"$",
"vendor",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"vendor",
")",
"{",
"$",
"dir",
"=",
"$",
"vendor",
".",
"'/hiqdev/'",
".",
"basename",
"(",
"dirname",
"(",
"__DIR__",
")",
")",
";",
"}",
... | Returns default output dir.
@param string $vendor path to vendor dir
@return string | [
"Returns",
"default",
"output",
"dir",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Builder.php#L71-L80 | train |
hiqdev/composer-config-plugin | src/Builder.php | Builder.buildUserConfigs | public function buildUserConfigs(array $files): array
{
$resolver = new Resolver($files);
$files = $resolver->get();
foreach ($files as $name => $paths) {
$this->getConfig($name)->load($paths)->build()->write();
}
return $files;
} | php | public function buildUserConfigs(array $files): array
{
$resolver = new Resolver($files);
$files = $resolver->get();
foreach ($files as $name => $paths) {
$this->getConfig($name)->load($paths)->build()->write();
}
return $files;
} | [
"public",
"function",
"buildUserConfigs",
"(",
"array",
"$",
"files",
")",
":",
"array",
"{",
"$",
"resolver",
"=",
"new",
"Resolver",
"(",
"$",
"files",
")",
";",
"$",
"files",
"=",
"$",
"resolver",
"->",
"get",
"(",
")",
";",
"foreach",
"(",
"$",
... | Builds configs by given files list.
@param null|array $files files to process: config name => list of files | [
"Builds",
"configs",
"by",
"given",
"files",
"list",
"."
] | 4f8d841d57a0015af48bf6451ad3342aa56b9559 | https://github.com/hiqdev/composer-config-plugin/blob/4f8d841d57a0015af48bf6451ad3342aa56b9559/src/Builder.php#L107-L116 | train |
trustly/trustly-client-php | Trustly/Api/unsigned.php | Trustly_Api_Unsigned.insertCredentials | public function insertCredentials($request) {
$request->setParam('Username', $this->api_username);
if(isset($this->session_uuid)) {
$request->setParam('Password', $this->session_uuid);
} else {
$request->setParam('Password', $this->api_password);
}
return TRUE;
} | php | public function insertCredentials($request) {
$request->setParam('Username', $this->api_username);
if(isset($this->session_uuid)) {
$request->setParam('Password', $this->session_uuid);
} else {
$request->setParam('Password', $this->api_password);
}
return TRUE;
} | [
"public",
"function",
"insertCredentials",
"(",
"$",
"request",
")",
"{",
"$",
"request",
"->",
"setParam",
"(",
"'Username'",
",",
"$",
"this",
"->",
"api_username",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"session_uuid",
")",
")",
"{",
... | Callback for populating the outgoing request with the criterias needed
for communication.
@param Trustly_Data_JSONRPCRequest $request Request to be used in the outgoing
call | [
"Callback",
"for",
"populating",
"the",
"outgoing",
"request",
"with",
"the",
"criterias",
"needed",
"for",
"communication",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/unsigned.php#L127-L135 | train |
trustly/trustly-client-php | Trustly/Api/unsigned.php | Trustly_Api_Unsigned.newSessionCookie | public function newSessionCookie() {
$this->session_uuid = NULL;
$request = new Trustly_Data_JSONRPCRequest('NewSessionCookie');
/* Call parent directly here as we will attempt to detect the
* missing session uuid here and call this function if it is not set */
$response = parent::call($request);
if(isset($response)) {
if($response->isSuccess()) {
$this->session_uuid = $response->getResult('sessionuuid');
}
}
if(!isset($this->session_uuid)) {
throw new Trustly_AuthentificationException();
}
return $response;
} | php | public function newSessionCookie() {
$this->session_uuid = NULL;
$request = new Trustly_Data_JSONRPCRequest('NewSessionCookie');
/* Call parent directly here as we will attempt to detect the
* missing session uuid here and call this function if it is not set */
$response = parent::call($request);
if(isset($response)) {
if($response->isSuccess()) {
$this->session_uuid = $response->getResult('sessionuuid');
}
}
if(!isset($this->session_uuid)) {
throw new Trustly_AuthentificationException();
}
return $response;
} | [
"public",
"function",
"newSessionCookie",
"(",
")",
"{",
"$",
"this",
"->",
"session_uuid",
"=",
"NULL",
";",
"$",
"request",
"=",
"new",
"Trustly_Data_JSONRPCRequest",
"(",
"'NewSessionCookie'",
")",
";",
"/* Call parent directly here as we will attempt to detect the\n\t... | Call NewSessionCookie to obtain a session cookie we can use for the rest
of our calls. This is automatically called when doing a call if we do
not have a session. Call manually if needed at session timeout etc.
@throws Trustly_AuthentificationException If the supplied credentials
cannot be used for communicating with the API.
@return Trustly_Data_JSONRPCResponse Response from the API. | [
"Call",
"NewSessionCookie",
"to",
"obtain",
"a",
"session",
"cookie",
"we",
"can",
"use",
"for",
"the",
"rest",
"of",
"our",
"calls",
".",
"This",
"is",
"automatically",
"called",
"when",
"doing",
"a",
"call",
"if",
"we",
"do",
"not",
"have",
"a",
"sessi... | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/unsigned.php#L158-L175 | train |
trustly/trustly-client-php | Trustly/Data/response.php | Trustly_Data_Response.getResult | public function getResult($name=NULL) {
if($name === NULL) {
# An array is always copied
return $this->response_result;
}
if(is_array($this->response_result) && isset($this->response_result[$name])) {
return $this->response_result[$name];
}
return NULL;
} | php | public function getResult($name=NULL) {
if($name === NULL) {
# An array is always copied
return $this->response_result;
}
if(is_array($this->response_result) && isset($this->response_result[$name])) {
return $this->response_result[$name];
}
return NULL;
} | [
"public",
"function",
"getResult",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"NULL",
")",
"{",
"# An array is always copied",
"return",
"$",
"this",
"->",
"response_result",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",... | Get data from the result section of the response
@param string $name Name of the result parameter to fetch. NULL value
will return entire result section.
@return mixed The value for parameter $name or the entire result block
if no name was given | [
"Get",
"data",
"from",
"the",
"result",
"section",
"of",
"the",
"response"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/response.php#L174-L185 | train |
trustly/trustly-client-php | Trustly/Data/data.php | Trustly_Data.vacuum | public function vacuum($data) {
if(is_null($data)) {
return NULL;
} elseif(is_array($data)) {
$ret = array();
foreach($data as $k => $v) {
$nv = $this->vacuum($v);
if(isset($nv)) {
$ret[$k] = $nv;
}
}
if(count($ret)) {
return $ret;
}
return NULL;
} else {
return $data;
}
} | php | public function vacuum($data) {
if(is_null($data)) {
return NULL;
} elseif(is_array($data)) {
$ret = array();
foreach($data as $k => $v) {
$nv = $this->vacuum($v);
if(isset($nv)) {
$ret[$k] = $nv;
}
}
if(count($ret)) {
return $ret;
}
return NULL;
} else {
return $data;
}
} | [
"public",
"function",
"vacuum",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
... | Utility function to vacuum the supplied data end remove unset
values. This is used to keep the requests cleaner rather then
supplying NULL values in the payload
@param array $data data to clean
@return array cleaned data | [
"Utility",
"function",
"to",
"vacuum",
"the",
"supplied",
"data",
"end",
"remove",
"unset",
"values",
".",
"This",
"is",
"used",
"to",
"keep",
"the",
"requests",
"cleaner",
"rather",
"then",
"supplying",
"NULL",
"values",
"in",
"the",
"payload"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/data.php#L61-L79 | train |
trustly/trustly-client-php | Trustly/Data/data.php | Trustly_Data.get | public function get($name=NULL) {
if($name === NULL) {
return $this->payload;
} else {
if(isset($this->payload[$name])) {
return $this->payload[$name];
}
}
return NULL;
} | php | public function get($name=NULL) {
if($name === NULL) {
return $this->payload;
} else {
if(isset($this->payload[$name])) {
return $this->payload[$name];
}
}
return NULL;
} | [
"public",
"function",
"get",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"payload",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"$... | Get the specific data value from the payload or the full payload if
no value is supplied
@param string $name The optional data parameter to get. If NULL then the
entire payload will be returned.
@return mixed value | [
"Get",
"the",
"specific",
"data",
"value",
"from",
"the",
"payload",
"or",
"the",
"full",
"payload",
"if",
"no",
"value",
"is",
"supplied"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/data.php#L91-L100 | train |
trustly/trustly-client-php | Trustly/Data/data.php | Trustly_Data.ensureUTF8 | public static function ensureUTF8($str) {
if($str == NULL) {
return NULL;
}
$enc = mb_detect_encoding($str, array('ISO-8859-1', 'ISO-8859-15', 'UTF-8', 'ASCII'));
if($enc !== FALSE) {
if($enc == 'ISO-8859-1' || $enc == 'ISO-8859-15') {
$str = mb_convert_encoding($str, 'UTF-8', $enc);
}
}
return $str;
} | php | public static function ensureUTF8($str) {
if($str == NULL) {
return NULL;
}
$enc = mb_detect_encoding($str, array('ISO-8859-1', 'ISO-8859-15', 'UTF-8', 'ASCII'));
if($enc !== FALSE) {
if($enc == 'ISO-8859-1' || $enc == 'ISO-8859-15') {
$str = mb_convert_encoding($str, 'UTF-8', $enc);
}
}
return $str;
} | [
"public",
"static",
"function",
"ensureUTF8",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"$",
"str",
"==",
"NULL",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"enc",
"=",
"mb_detect_encoding",
"(",
"$",
"str",
",",
"array",
"(",
"'ISO-8859-1'",
",",
"'ISO-... | Function to ensure that the given value is in UTF8. Used to make sure
all outgoing data is properly encoded in the call
@param string $str String to process
@return string UTF-8 variant of string | [
"Function",
"to",
"ensure",
"that",
"the",
"given",
"value",
"is",
"in",
"UTF8",
".",
"Used",
"to",
"make",
"sure",
"all",
"outgoing",
"data",
"is",
"properly",
"encoded",
"in",
"the",
"call"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/data.php#L111-L122 | train |
trustly/trustly-client-php | Trustly/Data/data.php | Trustly_Data.pop | public function pop($name) {
$v = NULL;
if(isset($this->payload[$name])) {
$v = $this->payload[$name];
}
unset($this->payload[$name]);
return $v;
} | php | public function pop($name) {
$v = NULL;
if(isset($this->payload[$name])) {
$v = $this->payload[$name];
}
unset($this->payload[$name]);
return $v;
} | [
"public",
"function",
"pop",
"(",
"$",
"name",
")",
"{",
"$",
"v",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"payload",
"[",
"$",
"name",
... | pop a value from the payload, i.e. fetch value and clear it in the
payload.
@param string $name
@return mixed The value | [
"pop",
"a",
"value",
"from",
"the",
"payload",
"i",
".",
"e",
".",
"fetch",
"value",
"and",
"clear",
"it",
"in",
"the",
"payload",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/data.php#L145-L152 | train |
trustly/trustly-client-php | Trustly/Data/data.php | Trustly_Data.json | public function json($pretty=FALSE) {
if($pretty) {
$sorted = $this->payload;
$this->sortRecursive($sorted);
return json_encode($sorted, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
} else {
return json_encode($this->payload);
}
} | php | public function json($pretty=FALSE) {
if($pretty) {
$sorted = $this->payload;
$this->sortRecursive($sorted);
return json_encode($sorted, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
} else {
return json_encode($this->payload);
}
} | [
"public",
"function",
"json",
"(",
"$",
"pretty",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"pretty",
")",
"{",
"$",
"sorted",
"=",
"$",
"this",
"->",
"payload",
";",
"$",
"this",
"->",
"sortRecursive",
"(",
"$",
"sorted",
")",
";",
"return",
"json_e... | Get the payload in JSON form.
@param boolean $pretty Format the output in a prettified easy-to-read
formatting
@return string The current payload in JSON | [
"Get",
"the",
"payload",
"in",
"JSON",
"form",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/data.php#L163-L171 | train |
trustly/trustly-client-php | Trustly/Data/data.php | Trustly_Data.sortRecursive | private function sortRecursive(&$data) {
if(is_array($data)) {
foreach($data as $k => $v) {
if(is_array($v)) {
$this->sortRecursive($v);
$data[$k] = $v;
}
}
ksort($data);
}
} | php | private function sortRecursive(&$data) {
if(is_array($data)) {
foreach($data as $k => $v) {
if(is_array($v)) {
$this->sortRecursive($v);
$data[$k] = $v;
}
}
ksort($data);
}
} | [
"private",
"function",
"sortRecursive",
"(",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
... | Sort the data in the payload.
Extremely naivly done and does not by far handle all cases, but
handles the case it should, i.e. sort the data for the json
pretty printer
@param mixed $data Payload to sort. Will be sorted in place | [
"Sort",
"the",
"data",
"in",
"the",
"payload",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/data.php#L183-L193 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcrequest.php | Trustly_Data_JSONRPCRequest.setParam | public function setParam($name, $value) {
$this->payload['params'][$name] = Trustly_Data::ensureUTF8($value);
return $value;
} | php | public function setParam($name, $value) {
$this->payload['params'][$name] = Trustly_Data::ensureUTF8($value);
return $value;
} | [
"public",
"function",
"setParam",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"$",
"name",
"]",
"=",
"Trustly_Data",
"::",
"ensureUTF8",
"(",
"$",
"value",
")",
";",
"return",
"$",
"value",
... | Set a value in the params section of the request
@param string $name Name of parameter
@param mixed $value Value of parameter
@return mixed $value | [
"Set",
"a",
"value",
"in",
"the",
"params",
"section",
"of",
"the",
"request"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcrequest.php#L97-L100 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcrequest.php | Trustly_Data_JSONRPCRequest.getParam | public function getParam($name) {
if(isset($this->payload['params'][$name])) {
return $this->payload['params'][$name];
}
return NULL;
} | php | public function getParam($name) {
if(isset($this->payload['params'][$name])) {
return $this->payload['params'][$name];
}
return NULL;
} | [
"public",
"function",
"getParam",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"$... | Get the value of a params parameter in the request
@param string $name Name of parameter of which to obtain the value
@return mixed The value | [
"Get",
"the",
"value",
"of",
"a",
"params",
"parameter",
"in",
"the",
"request"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcrequest.php#L110-L115 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcrequest.php | Trustly_Data_JSONRPCRequest.setData | public function setData($name, $value) {
if(!isset($this->payload['params']['Data'])) {
$this->payload['params']['Data'] = array();
}
$this->payload['params']['Data'][$name] = Trustly_Data::ensureUTF8($value);
return $value;
} | php | public function setData($name, $value) {
if(!isset($this->payload['params']['Data'])) {
$this->payload['params']['Data'] = array();
}
$this->payload['params']['Data'][$name] = Trustly_Data::ensureUTF8($value);
return $value;
} | [
"public",
"function",
"setData",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"'Data'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]... | Set a value in the params->Data part of the payload.
@param string $name The name of the Data parameter to set
@param mixed $value The value of the Data parameter to set
@return mixed $value | [
"Set",
"a",
"value",
"in",
"the",
"params",
"-",
">",
"Data",
"part",
"of",
"the",
"payload",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcrequest.php#L192-L198 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcrequest.php | Trustly_Data_JSONRPCRequest.getData | public function getData($name=NULL) {
if(isset($name)) {
if(isset($this->payload['params']['Data'][$name])) {
return $this->payload['params']['Data'][$name];
}
} else {
if(isset($this->payload['params']['Data'])) {
return $this->payload['params']['Data'];
}
}
return NULL;
} | php | public function getData($name=NULL) {
if(isset($name)) {
if(isset($this->payload['params']['Data'][$name])) {
return $this->payload['params']['Data'][$name];
}
} else {
if(isset($this->payload['params']['Data'])) {
return $this->payload['params']['Data'];
}
}
return NULL;
} | [
"public",
"function",
"getData",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"'Data'",
"]",
"[",
"$",
"name",
"]... | Get the value of one parameter in the params->Data section of the
request. Or the entire Data section if no name is given.
@param string $name Name of the Data param to obtain. Leave as NULL to
get the entire structure.
@return mixed The value or the entire Data depending on $name | [
"Get",
"the",
"value",
"of",
"one",
"parameter",
"in",
"the",
"params",
"-",
">",
"Data",
"section",
"of",
"the",
"request",
".",
"Or",
"the",
"entire",
"Data",
"section",
"if",
"no",
"name",
"is",
"given",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcrequest.php#L210-L221 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcrequest.php | Trustly_Data_JSONRPCRequest.setAttribute | public function setAttribute($name, $value) {
if(!isset($this->payload['params']['Data'])) {
$this->payload['params']['Data'] = array();
}
if(!isset($this->payload['params']['Data']['Attributes'])) {
$this->payload['params']['Data']['Attributes'] = array();
}
$this->payload['params']['Data']['Attributes'][$name] = Trustly_Data::ensureUTF8($value);
return $value;
} | php | public function setAttribute($name, $value) {
if(!isset($this->payload['params']['Data'])) {
$this->payload['params']['Data'] = array();
}
if(!isset($this->payload['params']['Data']['Attributes'])) {
$this->payload['params']['Data']['Attributes'] = array();
}
$this->payload['params']['Data']['Attributes'][$name] = Trustly_Data::ensureUTF8($value);
return $value;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"'Data'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"payload",
"[",
"'params'",... | Set a value in the params->Data->Attributes part of the payload.
@param string $name The name of the Attributes parameter to set
@param mixed $value The value of the Attributes parameter to set
@return mixed $value | [
"Set",
"a",
"value",
"in",
"the",
"params",
"-",
">",
"Data",
"-",
">",
"Attributes",
"part",
"of",
"the",
"payload",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcrequest.php#L233-L243 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcrequest.php | Trustly_Data_JSONRPCRequest.getAttribute | public function getAttribute($name) {
if(isset($this->payload['params']['Data']['Attributes'][$name])) {
return $this->payload['params']['Data']['Attributes'][$name];
}
return NULL;
} | php | public function getAttribute($name) {
if(isset($this->payload['params']['Data']['Attributes'][$name])) {
return $this->payload['params']['Data']['Attributes'][$name];
}
return NULL;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"'Data'",
"]",
"[",
"'Attributes'",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this"... | Get the value of one parameter in the params->Data->Attributes section
of the request. Or the entire Attributes section if no name is given.
@param string $name Name of the Attributes param to obtain. Leave as NULL to
get the entire structure.
@return mixed The value or the entire Attributes depending on $name | [
"Get",
"the",
"value",
"of",
"one",
"parameter",
"in",
"the",
"params",
"-",
">",
"Data",
"-",
">",
"Attributes",
"section",
"of",
"the",
"request",
".",
"Or",
"the",
"entire",
"Attributes",
"section",
"if",
"no",
"name",
"is",
"given",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcrequest.php#L255-L260 | train |
trustly/trustly-client-php | Trustly/Api/api.php | Trustly_Api.serializeData | public function serializeData($data) {
if(is_array($data)) {
ksort($data);
$return = '';
foreach($data as $key => $value) {
if(is_numeric($key)) {
$return .= $this->serializeData($value);
} else {
$return .= $key . $this->serializeData($value);
}
}
return $return;
} else {
return (string)$data;
}
} | php | public function serializeData($data) {
if(is_array($data)) {
ksort($data);
$return = '';
foreach($data as $key => $value) {
if(is_numeric($key)) {
$return .= $this->serializeData($value);
} else {
$return .= $key . $this->serializeData($value);
}
}
return $return;
} else {
return (string)$data;
}
} | [
"public",
"function",
"serializeData",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"ksort",
"(",
"$",
"data",
")",
";",
"$",
"return",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
... | Serializes the given data in a form suitable for creating a signature.
@link https://trustly.com/en/developer/api#/signature
@param array $data Input data to serialize
@return array The input data in a serialized form | [
"Serializes",
"the",
"given",
"data",
"in",
"a",
"form",
"suitable",
"for",
"creating",
"a",
"signature",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/api.php#L146-L161 | train |
trustly/trustly-client-php | Trustly/Api/api.php | Trustly_Api.setHost | public function setHost($host=NULL, $port=NULL, $is_https=NULL) {
if(!isset($host)) {
$host = $this->api_host;
}
if(!isset($port)) {
$port = $this->api_port;
}
if($this->loadTrustlyPublicKey($host, $port) === FALSE) {
$error = openssl_error_string();
throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".(isset($error)?", error $error":''));
}
if(isset($is_https)) {
$this->api_is_https = $is_https;
}
} | php | public function setHost($host=NULL, $port=NULL, $is_https=NULL) {
if(!isset($host)) {
$host = $this->api_host;
}
if(!isset($port)) {
$port = $this->api_port;
}
if($this->loadTrustlyPublicKey($host, $port) === FALSE) {
$error = openssl_error_string();
throw new InvalidArgumentException("Cannot load Trustly public key file for host $host".(isset($error)?", error $error":''));
}
if(isset($is_https)) {
$this->api_is_https = $is_https;
}
} | [
"public",
"function",
"setHost",
"(",
"$",
"host",
"=",
"NULL",
",",
"$",
"port",
"=",
"NULL",
",",
"$",
"is_https",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"host",
")",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"api_host... | Update the host settings within the API. Use this method to switch API peer.
@throws InvalidArgumentException If the public key for the API host
cannot be loaded.
@param string $host API host used for communication. Fully qualified
hostname. When integrating with our public API this is typically
either 'test.trustly.com' or 'trustly.com'. NULL means do not change.
@param integer $port Port on API host used for communicaiton. Normally
443 for https, or 80 for http. NULL means do not change.
@param bool $is_https Indicator wether the port on the API host expects
https. NULL means do not change. | [
"Update",
"the",
"host",
"settings",
"within",
"the",
"API",
".",
"Use",
"this",
"method",
"to",
"switch",
"API",
"peer",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/api.php#L256-L273 | train |
trustly/trustly-client-php | Trustly/Api/api.php | Trustly_Api.baseURL | public function baseURL() {
if($this->api_is_https) {
$url = 'https://' . $this->api_host . ($this->api_port != 443?':'.$this->api_port:'');
} else {
$url = 'http://' . $this->api_host . ($this->api_port != 80?':'.$this->api_port:'');
}
return $url;
} | php | public function baseURL() {
if($this->api_is_https) {
$url = 'https://' . $this->api_host . ($this->api_port != 443?':'.$this->api_port:'');
} else {
$url = 'http://' . $this->api_host . ($this->api_port != 80?':'.$this->api_port:'');
}
return $url;
} | [
"public",
"function",
"baseURL",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"api_is_https",
")",
"{",
"$",
"url",
"=",
"'https://'",
".",
"$",
"this",
"->",
"api_host",
".",
"(",
"$",
"this",
"->",
"api_port",
"!=",
"443",
"?",
"':'",
".",
"$",
... | Return a properly formed url to communicate with this API.
@return URL pointing to the API peer. | [
"Return",
"a",
"properly",
"formed",
"url",
"to",
"communicate",
"with",
"this",
"API",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/api.php#L383-L390 | train |
trustly/trustly-client-php | Trustly/Api/api.php | Trustly_Api.call | public function call($request) {
if($this->insertCredentials($request) !== TRUE) {
throw new Trustly_DataException('Unable to add authorization criterias to outgoing request');
}
$this->last_request = $request;
$jsonstr = $request->json();
$url = $this->url($request);
list($body, $response_code) = $this->post($url, $jsonstr);
$result = $this->handleResponse($request, $body, $response_code);
return $result;
} | php | public function call($request) {
if($this->insertCredentials($request) !== TRUE) {
throw new Trustly_DataException('Unable to add authorization criterias to outgoing request');
}
$this->last_request = $request;
$jsonstr = $request->json();
$url = $this->url($request);
list($body, $response_code) = $this->post($url, $jsonstr);
$result = $this->handleResponse($request, $body, $response_code);
return $result;
} | [
"public",
"function",
"call",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"insertCredentials",
"(",
"$",
"request",
")",
"!==",
"TRUE",
")",
"{",
"throw",
"new",
"Trustly_DataException",
"(",
"'Unable to add authorization criterias to outgoing req... | Call the trustly API with the given request.
@throws Trustly_DataException Upon failure to add all the communication
parameters to the data.
@throws Trustly_ConnectionException When failing to communicate with the
API.
@param Trustly_Data_Request $request Outgoing data request. | [
"Call",
"the",
"trustly",
"API",
"with",
"the",
"given",
"request",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/api.php#L469-L482 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcsignedresponse.php | Trustly_Data_JSONRPCSignedResponse.getData | public function getData($name=NULL) {
$data = NULL;
if(isset($this->response_result['data'])) {
$data = $this->response_result['data'];
}else {
return NULL;
}
if(isset($name)) {
if(isset($data[$name])) {
return $data[$name];
}
} else {
return $data;
}
} | php | public function getData($name=NULL) {
$data = NULL;
if(isset($this->response_result['data'])) {
$data = $this->response_result['data'];
}else {
return NULL;
}
if(isset($name)) {
if(isset($data[$name])) {
return $data[$name];
}
} else {
return $data;
}
} | [
"public",
"function",
"getData",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"$",
"data",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"response_result",
"[",
"'data'",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"respo... | Get data from the data section of the response
@param string $name Name of the data parameter to fetch. NULL value will
return entire data section.
@return mixed The value for parameter $name or the entire data block if
no name was given | [
"Get",
"data",
"from",
"the",
"data",
"section",
"of",
"the",
"response"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcsignedresponse.php#L97-L113 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.loadMerchantPrivateKey | public function loadMerchantPrivateKey($filename) {
$cert = @file_get_contents($filename);
if($cert === FALSE) {
return FALSE;
}
return $this->useMerchantPrivateKey($cert);
} | php | public function loadMerchantPrivateKey($filename) {
$cert = @file_get_contents($filename);
if($cert === FALSE) {
return FALSE;
}
return $this->useMerchantPrivateKey($cert);
} | [
"public",
"function",
"loadMerchantPrivateKey",
"(",
"$",
"filename",
")",
"{",
"$",
"cert",
"=",
"@",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"cert",
"===",
"FALSE",
")",
"{",
"return",
"FALSE",
";",
"}",
"return",
"$",
"t... | Load up the merchants key for signing data from the supplied filename.
Inializes the internal openssl certificate needed for the signing
@param string $filename Filename containing the private key to load.
@return boolean indicating success. | [
"Load",
"up",
"the",
"merchants",
"key",
"for",
"signing",
"data",
"from",
"the",
"supplied",
"filename",
".",
"Inializes",
"the",
"internal",
"openssl",
"certificate",
"needed",
"for",
"the",
"signing"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L96-L102 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.useMerchantPrivateKey | public function useMerchantPrivateKey($cert) {
if($cert !== FALSE) {
$this->merchant_privatekey = openssl_pkey_get_private($cert);
return TRUE;
}
return FALSE;
} | php | public function useMerchantPrivateKey($cert) {
if($cert !== FALSE) {
$this->merchant_privatekey = openssl_pkey_get_private($cert);
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"useMerchantPrivateKey",
"(",
"$",
"cert",
")",
"{",
"if",
"(",
"$",
"cert",
"!==",
"FALSE",
")",
"{",
"$",
"this",
"->",
"merchant_privatekey",
"=",
"openssl_pkey_get_private",
"(",
"$",
"cert",
")",
";",
"return",
"TRUE",
";",
"}",
... | Use this RSA private key for signing outgoing requests.
@see https://trustly.com/en/developer/api#/signature
@param string $cert Loaded private RSA key as a string | [
"Use",
"this",
"RSA",
"private",
"key",
"for",
"signing",
"outgoing",
"requests",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L112-L118 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.signMerchantRequest | public function signMerchantRequest($request) {
if(!isset($this->merchant_privatekey)) {
throw new Trustly_SignatureException('No private key has been loaded for signing');
}
$method = $request->getMethod();
if($method === NULL) {
$method = '';
}
$uuid = $request->getUUID();
if($uuid === NULL) {
$uuid = '';
}
$data = $request->getData();
$serial_data = $method . $uuid . $this->serializeData($data);
$raw_signature = '';
$this->clearOpenSSLError();
if(openssl_sign($serial_data, $raw_signature, $this->merchant_privatekey, OPENSSL_ALGO_SHA1) === TRUE) {
return base64_encode($raw_signature);
}
throw new Trustly_SignatureException('Failed to sign the outgoing merchant request. '. openssl_error_string());
} | php | public function signMerchantRequest($request) {
if(!isset($this->merchant_privatekey)) {
throw new Trustly_SignatureException('No private key has been loaded for signing');
}
$method = $request->getMethod();
if($method === NULL) {
$method = '';
}
$uuid = $request->getUUID();
if($uuid === NULL) {
$uuid = '';
}
$data = $request->getData();
$serial_data = $method . $uuid . $this->serializeData($data);
$raw_signature = '';
$this->clearOpenSSLError();
if(openssl_sign($serial_data, $raw_signature, $this->merchant_privatekey, OPENSSL_ALGO_SHA1) === TRUE) {
return base64_encode($raw_signature);
}
throw new Trustly_SignatureException('Failed to sign the outgoing merchant request. '. openssl_error_string());
} | [
"public",
"function",
"signMerchantRequest",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"merchant_privatekey",
")",
")",
"{",
"throw",
"new",
"Trustly_SignatureException",
"(",
"'No private key has been loaded for signing'",
")",... | Insert a signature into the outgoing request.
@throws Trustly_SignatureException if private key has not been loaded
yet or if we for some other reason fail to sign the request.
@param Trustly_Data_JSONRPCRequest $request Request to sign. | [
"Insert",
"a",
"signature",
"into",
"the",
"outgoing",
"request",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L129-L154 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.handleResponse | protected function handleResponse($request, $body, $response_code) {
$response = new Trustly_Data_JSONRPCSignedResponse($body, $response_code);
if($this->verifyTrustlySignedResponse($response) !== TRUE) {
throw new Trustly_SignatureException('Incomming message signature is not valid', $response);
}
if($response->getUUID() !== $request->getUUID()) {
throw new Trustly_DataException('Incoming message is not related to request. UUID mismatch');
}
return $response;
} | php | protected function handleResponse($request, $body, $response_code) {
$response = new Trustly_Data_JSONRPCSignedResponse($body, $response_code);
if($this->verifyTrustlySignedResponse($response) !== TRUE) {
throw new Trustly_SignatureException('Incomming message signature is not valid', $response);
}
if($response->getUUID() !== $request->getUUID()) {
throw new Trustly_DataException('Incoming message is not related to request. UUID mismatch');
}
return $response;
} | [
"protected",
"function",
"handleResponse",
"(",
"$",
"request",
",",
"$",
"body",
",",
"$",
"response_code",
")",
"{",
"$",
"response",
"=",
"new",
"Trustly_Data_JSONRPCSignedResponse",
"(",
"$",
"body",
",",
"$",
"response_code",
")",
";",
"if",
"(",
"$",
... | Callback for handling the response from an API call. Takes
the input data and create an instance of a response object.
@throws Trustly_SignatureException If the incoming message has an
invalid signature
@throws Trustly_DataException If the incoming message fails the sanity
checks.
@param Trustly_Data_JSONRPCRequest $request Outgoing request
@param string $body The body recieved in response to the request
@param integer $response_code the HTTP response code for the call
@return Trustly_Data_JSONRPCSignedResponse | [
"Callback",
"for",
"handling",
"the",
"response",
"from",
"an",
"API",
"call",
".",
"Takes",
"the",
"input",
"data",
"and",
"create",
"an",
"instance",
"of",
"a",
"response",
"object",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L196-L208 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.notificationResponse | public function notificationResponse($request, $success=TRUE) {
$response = new Trustly_Data_JSONRPCNotificationResponse($request, $success);
$signature = $this->signMerchantRequest($response);
if($signature === FALSE) {
return FALSE;
}
$response->setSignature($signature);
return $response;
} | php | public function notificationResponse($request, $success=TRUE) {
$response = new Trustly_Data_JSONRPCNotificationResponse($request, $success);
$signature = $this->signMerchantRequest($response);
if($signature === FALSE) {
return FALSE;
}
$response->setSignature($signature);
return $response;
} | [
"public",
"function",
"notificationResponse",
"(",
"$",
"request",
",",
"$",
"success",
"=",
"TRUE",
")",
"{",
"$",
"response",
"=",
"new",
"Trustly_Data_JSONRPCNotificationResponse",
"(",
"$",
"request",
",",
"$",
"success",
")",
";",
"$",
"signature",
"=",
... | Given an object from an incoming notification request build a response
object that can be used to respond to trustly with
@param Trustly_Data_JSONRPCNotificationRequest $request
@param boolean $success Indicator if we should respond with processing
success or failure to the notification.
@return Trustly_Data_JSONRPCNotificationResponse response object. | [
"Given",
"an",
"object",
"from",
"an",
"incoming",
"notification",
"request",
"build",
"a",
"response",
"object",
"that",
"can",
"be",
"used",
"to",
"respond",
"to",
"trustly",
"with"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L222-L232 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.call | public function call($request) {
$uuid = $request->getUUID();
if($uuid === NULL) {
$request->setUUID($this->generateUUID());
}
return parent::call($request);
} | php | public function call($request) {
$uuid = $request->getUUID();
if($uuid === NULL) {
$request->setUUID($this->generateUUID());
}
return parent::call($request);
} | [
"public",
"function",
"call",
"(",
"$",
"request",
")",
"{",
"$",
"uuid",
"=",
"$",
"request",
"->",
"getUUID",
"(",
")",
";",
"if",
"(",
"$",
"uuid",
"===",
"NULL",
")",
"{",
"$",
"request",
"->",
"setUUID",
"(",
"$",
"this",
"->",
"generateUUID",... | Call the API with the prepared request
@throws Trustly_DataException Upon failure to add all the communication
parameters to the data or if the incoming data fails the basic
sanity checks
@throws Trustly_ConnectionException When failing to communicate with the
API.
@throws Trustly_SignatureException If the incoming message has an
invalid signature
@param Trustly_Data_JSONRPCRequest $request Outgoing request
@return Trustly_Data_JSONRPCSignedResponse Response from the API. | [
"Call",
"the",
"API",
"with",
"the",
"prepared",
"request"
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L310-L316 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.deposit | public function deposit($notificationurl, $enduserid, $messageid,
$locale=NULL, $amount=NULL, $currency=NULL, $country=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL,
$nationalidentificationnumber=NULL, $shopperstatement=NULL,
$ip=NULL, $successurl=NULL, $failurl=NULL, $templateurl=NULL,
$urltarget=NULL, $suggestedminamount=NULL, $suggestedmaxamount=NULL,
$integrationmodule=NULL, $holdnotifications=NULL,
$email=NULL, $shippingaddresscountry=NULL,
$shippingaddresspostalcode=NULL, $shippingaddresscity=NULL,
$shippingaddressline1=NULL, $shippingaddressline2=NULL,
$shippingaddress=NULL, $unchangeablenationalidentificationnumber=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
);
$attributes = array(
'Locale' => $locale,
'Amount' => $amount,
'Currency' => $currency,
'Country' => $country,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'ShopperStatement' => $shopperstatement,
'IP' => $ip,
'SuccessURL' => $successurl,
'FailURL' => $failurl,
'TemplateURL' => $templateurl,
'URLTarget' => $urltarget,
'SuggestedMinAmount' => $suggestedminamount,
'SuggestedMaxAmount' => $suggestedmaxamount,
'IntegrationModule' => $integrationmodule,
'Email' => $email,
'ShippingAddressCountry' => $shippingaddresscountry,
'ShippingAddressPostalcode' => $shippingaddresspostalcode,
'ShippingAddressCity' => $shippingaddresscity,
'ShippingAddressLine1' => $shippingaddressline1,
'ShippingAddressLine2' => $shippingaddressline2,
'ShippingAddress' => $shippingaddress,
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
if($unchangeablenationalidentificationnumber) {
$attributes['UnchangeableNationalIdentificationNumber'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('Deposit', $data, $attributes);
return $this->call($request);
} | php | public function deposit($notificationurl, $enduserid, $messageid,
$locale=NULL, $amount=NULL, $currency=NULL, $country=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL,
$nationalidentificationnumber=NULL, $shopperstatement=NULL,
$ip=NULL, $successurl=NULL, $failurl=NULL, $templateurl=NULL,
$urltarget=NULL, $suggestedminamount=NULL, $suggestedmaxamount=NULL,
$integrationmodule=NULL, $holdnotifications=NULL,
$email=NULL, $shippingaddresscountry=NULL,
$shippingaddresspostalcode=NULL, $shippingaddresscity=NULL,
$shippingaddressline1=NULL, $shippingaddressline2=NULL,
$shippingaddress=NULL, $unchangeablenationalidentificationnumber=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
);
$attributes = array(
'Locale' => $locale,
'Amount' => $amount,
'Currency' => $currency,
'Country' => $country,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'ShopperStatement' => $shopperstatement,
'IP' => $ip,
'SuccessURL' => $successurl,
'FailURL' => $failurl,
'TemplateURL' => $templateurl,
'URLTarget' => $urltarget,
'SuggestedMinAmount' => $suggestedminamount,
'SuggestedMaxAmount' => $suggestedmaxamount,
'IntegrationModule' => $integrationmodule,
'Email' => $email,
'ShippingAddressCountry' => $shippingaddresscountry,
'ShippingAddressPostalcode' => $shippingaddresspostalcode,
'ShippingAddressCity' => $shippingaddresscity,
'ShippingAddressLine1' => $shippingaddressline1,
'ShippingAddressLine2' => $shippingaddressline2,
'ShippingAddress' => $shippingaddress,
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
if($unchangeablenationalidentificationnumber) {
$attributes['UnchangeableNationalIdentificationNumber'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('Deposit', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"deposit",
"(",
"$",
"notificationurl",
",",
"$",
"enduserid",
",",
"$",
"messageid",
",",
"$",
"locale",
"=",
"NULL",
",",
"$",
"amount",
"=",
"NULL",
",",
"$",
"currency",
"=",
"NULL",
",",
"$",
"country",
"=",
"NULL",
",",
"$... | Call the Deposit API Method.
Initiates a new deposit by generating a new OrderID and returning the
url where the end-user can complete the deposit.
@see https://trustly.com/en/developer/api#/deposit
@param string $notificationurl The URL to which notifications for this
payment should be sent to. This URL should be hard to guess and not
contain a ? ("question mark").
@param string $enduserid ID, username, hash or anything uniquely
identifying the end-user requesting the withdrawal. Preferably the
same ID/username as used in the merchant's own backoffice in order
to simplify for the merchant's support department.
@param string $messageid Your unique ID for the deposit.
@param string $locale The end-users localization preference in the
format [language[_territory]]. Language is the ISO 639-1 code and
territory the ISO 3166-1-alpha-2 code.
@param float $amount with exactly two decimals in the currency specified
by Currency. Do not use this attribute in combination with
SuggestedMinAmount or SuggestedMaxAmount. Only digits. Use dot (.)
as decimal separator.
@param string $currency The currency of the end-user's account in the
merchant's system.
@param string $country The ISO 3166-1-alpha-2 code of the end-user's
country. This will be used for preselecting the correct country for
the end-user in the iframe.
@param string $mobilephone The mobile phonenumber to the end-user in
international format. This is used for KYC and AML routines.
@param string $firstname The end-user's firstname. Useful for some banks
for identifying transactions.
@param string $lastname The end-user's lastname. Useful for some banks
for identifying transactions.
@param string $nationalidentificationnumber The end-user's social
security number / personal number / birth number / etc. Useful for
some banks for identifying transactions and KYC/AML.
@param string $shopperstatement The text to show on the end-user's bank
statement.
@param string $ip The IP-address of the end-user.
@param string $successurl The URL to which the end-user should be
redirected after a successful deposit. Do not put any logic on that
page since it's not guaranteed that the end-user will in fact visit
it.
@param string $failurl The URL to which the end-user should be
redirected after a failed deposit. Do not put any logic on that
page since it's not guaranteed that the end-user will in fact visit
it.
@param string $templateurl The URL to your template page for the
checkout process.
@param string $urltarget The html target/framename of the SuccessURL.
Only _top, _self and _parent are suported.
@param float $suggestedminamount The minimum amount the end-user is
allowed to deposit in the currency specified by Currency. Only
digits. Use dot (.) as decimal separator.
@param float $suggestedmaxamount The maximum amount the end-user is
allowed to deposit in the currency specified by Currency. Only
digits. Use dot (.) as decimal separator.
@param string $integrationmodule Version information for your
integration module. This is for informational purposes only and can
be useful when troubleshooting problems. Should contain enough
version information to be useful.
@param boolean $holdnotifications Do not deliver notifications for this
order. This is a parameter available when using test.trustly.com
and can be used for manually delivering notifications to your local
system during development. Intead you can get you notifications on
https://test.trustly.com/notifications.html . Never set this in the
live environment.
@param string $email The email address of the end user.
@param string $shippingaddresscountry The ISO 3166-1-alpha-2 code of the
shipping address country.
Shipping address should be provided for merchants sending
physical goods to customers. Use either these separated fields or
use the $shippingaddress field below if you do not keep separated
address fields.
@param string $shippingaddresspostalcode The postal code of the shipping
address.
@param string $shippingaddresscity The city of the shipping address.
@param string $shippingaddressline1 The first line of the shipping
address field.
@param string $shippingaddressline2 The second line of the shipping
address information.
@param string $shippingaddress The full shipping address. Use either the
separated fields or use this combined field if you do not keep
separated address fields.
@param string $unchangeablenationalidentificationnumber The supplied
$nationalidentificationnumber should be considered read only information
and will not be changable by end the enduser. Only valid in Sweden,
the $nationalidentification number needs to be well formed.
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"Deposit",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L439-L493 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.refund | public function refund($orderid, $amount, $currency) {
$data = array(
'OrderID' => $orderid,
'Amount' => $amount,
'Currency' => $currency,
);
$request = new Trustly_Data_JSONRPCRequest('Refund', $data);
return $this->call($request);
} | php | public function refund($orderid, $amount, $currency) {
$data = array(
'OrderID' => $orderid,
'Amount' => $amount,
'Currency' => $currency,
);
$request = new Trustly_Data_JSONRPCRequest('Refund', $data);
return $this->call($request);
} | [
"public",
"function",
"refund",
"(",
"$",
"orderid",
",",
"$",
"amount",
",",
"$",
"currency",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'OrderID'",
"=>",
"$",
"orderid",
",",
"'Amount'",
"=>",
"$",
"amount",
",",
"'Currency'",
"=>",
"$",
"currency",
... | Call the Refund API Method.
Refunds the customer on a previous deposit.
@see https://trustly.com/en/developer/api#/refund
@param integer $orderid The OrderID of the initial deposit.
@param float $amount The amount to refund the customer with exactly two
decimals. Only digits. Use dot (.) as decimal separator.
@param string currency The currency of the amount to refund the
customer.
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"Refund",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L512-L522 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.withdraw | public function withdraw($notificationurl, $enduserid, $messageid,
$locale=NULL, $currency=NULL, $country=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL,
$nationalidentificationnumber=NULL, $clearinghouse=NULL,
$banknumber=NULL, $accountnumber=NULL, $holdnotifications=NULL,
$email=NULL, $dateofbirth=NULL,
$addresscountry=NULL, $addresspostalcode=NULL,
$addresscity=NULL, $addressline1=NULL,
$addressline2=NULL, $address=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
'Currency' => $currency,
'Amount' => null
);
$attributes = array(
'Locale' => $locale,
'Country' => $country,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'ClearingHouse' => $clearinghouse,
'BankNumber' => $banknumber,
'AccountNumber' => $accountnumber,
'Email' => $email,
'DateOfBirth' => $dateofbirth,
'AddressCountry' => $addresscountry,
'AddressPostalcode' => $addresspostalcode,
'AddressCity' => $addresscity,
'AddressLine1' => $addressline1,
'AddressLine2' => $addressline2,
'Address' => $address,
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('Withdraw', $data, $attributes);
return $this->call($request);
} | php | public function withdraw($notificationurl, $enduserid, $messageid,
$locale=NULL, $currency=NULL, $country=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL,
$nationalidentificationnumber=NULL, $clearinghouse=NULL,
$banknumber=NULL, $accountnumber=NULL, $holdnotifications=NULL,
$email=NULL, $dateofbirth=NULL,
$addresscountry=NULL, $addresspostalcode=NULL,
$addresscity=NULL, $addressline1=NULL,
$addressline2=NULL, $address=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
'Currency' => $currency,
'Amount' => null
);
$attributes = array(
'Locale' => $locale,
'Country' => $country,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'ClearingHouse' => $clearinghouse,
'BankNumber' => $banknumber,
'AccountNumber' => $accountnumber,
'Email' => $email,
'DateOfBirth' => $dateofbirth,
'AddressCountry' => $addresscountry,
'AddressPostalcode' => $addresspostalcode,
'AddressCity' => $addresscity,
'AddressLine1' => $addressline1,
'AddressLine2' => $addressline2,
'Address' => $address,
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('Withdraw', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"withdraw",
"(",
"$",
"notificationurl",
",",
"$",
"enduserid",
",",
"$",
"messageid",
",",
"$",
"locale",
"=",
"NULL",
",",
"$",
"currency",
"=",
"NULL",
",",
"$",
"country",
"=",
"NULL",
",",
"$",
"mobilephone",
"=",
"NULL",
","... | Call the Withdraw API Method.
Initiates a new withdrawal returning the url where the end-user can
complete the process.
@see https://trustly.com/en/developer/api#/withdraw
@param string $notificationurl The URL to which notifications for this
payment should be sent to. This URL should be hard to guess and not
contain a ? ("question mark").
@param string $enduserid ID, username, hash or anything uniquely
identifying the end-user requesting the withdrawal. Preferably the
same ID/username as used in the merchant's own backoffice in order
to simplify for the merchant's support department.
@param string $messageid Your unique ID for the withdrawal.
@param string $locale The end-users localization preference in the
format [language[_territory]]. Language is the ISO 639-1 code and
territory the ISO 3166-1-alpha-2 code.
@param string $currency The currency of the end-user's account in the
merchant's system.
@param string $country The ISO 3166-1-alpha-2 code of the end-user's
country. This will be used for preselecting the correct country for
the end-user in the iframe.
@param string $mobilephone The mobile phonenumber to the end-user in
international format. This is used for KYC and AML routines.
@param string $firstname The end-user's firstname. Some banks require
the recipients name.
@param string $lastname The end-user's lastname. Some banks require the
recipients name.
@param string $nationalidentificationnumber The end-user's social
security number / personal number / birth number / etc. Useful for
some banks for identifying transactions and KYC/AML.
@param string $clearinghouse The clearing house of the end-user's bank
account. Typically the name of a country in uppercase but might
also be IBAN. This will be used to automatically fill-in the
withdrawal form for the end-user.
@param string $banknumber The bank number identifying the end-user's
bank in the given clearing house. This will be used to
automatically fill-in the withdrawal form for the end-user.
@param string $accountnumber The account number, identifying the
end-user's account in the bank. This will be used to automatically
fill-in the withdrawal form for the end-user. If using Spanish
Banks, send full IBAN number in this attribute.
@param boolean $holdnotifications Do not deliver notifications for this
order. This is a parameter available when using test.trustly.com
and can be used for manually delivering notifications to your local
system during development. Intead you can get you notifications on
https://test.trustly.com/notifications.html
@param string $email The email address of the end user.
@param string $dateofbirth The ISO 8601 date of birth of the end user.
@param string $addresscountry The ISO 3166-1-alpha-2 code of the
account holders country.
Use either these separated fields or use the $address field below
if you do not keep separated address fields.
@param string $addresspostalcode The postal code of the account holder
address.
@param string $addresscity The city of the account holder address.
@param string $addressline1 The first line of the account holder
address field.
@param string $addressline2 The second line of the account holder
address information.
@param string $address The account holders address
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"Withdraw",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L611-L655 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.approveWithdrawal | public function approveWithdrawal($orderid) {
$data = array(
'OrderID' => $orderid,
);
$request = new Trustly_Data_JSONRPCRequest('ApproveWithdrawal', $data);
return $this->call($request);
} | php | public function approveWithdrawal($orderid) {
$data = array(
'OrderID' => $orderid,
);
$request = new Trustly_Data_JSONRPCRequest('ApproveWithdrawal', $data);
return $this->call($request);
} | [
"public",
"function",
"approveWithdrawal",
"(",
"$",
"orderid",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'OrderID'",
"=>",
"$",
"orderid",
",",
")",
";",
"$",
"request",
"=",
"new",
"Trustly_Data_JSONRPCRequest",
"(",
"'ApproveWithdrawal'",
",",
"$",
"data... | Call the approveWithdrawal API Method.
Approves a withdrawal prepared by the user. Please contact your
integration manager at Trustly if you want to enable automatic approval
of the withdrawals.
@see https://trustly.com/en/developer/api#/approvwwithdrawal
@param integer $orderid The OrderID of the withdrawal to approve.
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"approveWithdrawal",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L670-L678 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.denyWithdrawal | public function denyWithdrawal($orderid) {
$data = array(
'OrderID' => $orderid,
);
$request = new Trustly_Data_JSONRPCRequest('DenyWithdrawal', $data);
return $this->call($request);
} | php | public function denyWithdrawal($orderid) {
$data = array(
'OrderID' => $orderid,
);
$request = new Trustly_Data_JSONRPCRequest('DenyWithdrawal', $data);
return $this->call($request);
} | [
"public",
"function",
"denyWithdrawal",
"(",
"$",
"orderid",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'OrderID'",
"=>",
"$",
"orderid",
",",
")",
";",
"$",
"request",
"=",
"new",
"Trustly_Data_JSONRPCRequest",
"(",
"'DenyWithdrawal'",
",",
"$",
"data",
"... | Call the denyWithdrawal API Method.
Denies a withdrawal prepared by the user. Please contact your
integration manager at Trustly if you want to enable automatic approval
of the withdrawals
@see https://trustly.com/en/developer/api#/denywithdrawal
@param integer $orderid The OrderID of the withdrawal to deny.
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"denyWithdrawal",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L693-L701 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.selectAccount | public function selectAccount($notificationurl, $enduserid, $messageid,
$locale=NULL, $country=NULL, $ip=NULL, $successurl=NULL, $urltarget=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL, $holdnotifications=NULL,
$email=NULL, $dateofbirth=NULL, $requestdirectdebitmandate=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
);
$attributes = array(
'Locale' => $locale,
'Country' => $country,
'IP' => $ip,
'SuccessURL' => $successurl,
'URLTarget' => $urltarget,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'Email' => $email,
'DateOfBirth' => $dateofbirth,
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
if($requestdirectdebitmandate) {
$attributes['RequestDirectDebitMandate'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('SelectAccount', $data, $attributes);
return $this->call($request);
} | php | public function selectAccount($notificationurl, $enduserid, $messageid,
$locale=NULL, $country=NULL, $ip=NULL, $successurl=NULL, $urltarget=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL, $holdnotifications=NULL,
$email=NULL, $dateofbirth=NULL, $requestdirectdebitmandate=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
);
$attributes = array(
'Locale' => $locale,
'Country' => $country,
'IP' => $ip,
'SuccessURL' => $successurl,
'URLTarget' => $urltarget,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'Email' => $email,
'DateOfBirth' => $dateofbirth,
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
if($requestdirectdebitmandate) {
$attributes['RequestDirectDebitMandate'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('SelectAccount', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"selectAccount",
"(",
"$",
"notificationurl",
",",
"$",
"enduserid",
",",
"$",
"messageid",
",",
"$",
"locale",
"=",
"NULL",
",",
"$",
"country",
"=",
"NULL",
",",
"$",
"ip",
"=",
"NULL",
",",
"$",
"successurl",
"=",
"NULL",
",",
... | Call the selectAccount API Method.
Initiates a new order where the end-user can select and verify one of
his/her bank accounts.
@see https://trustly.com/en/developer/api#/selectaccount
@param string $notificationurl The URL to which notifications for this
order should be sent to. This URL should be hard to guess and not
contain a ? ("question mark").
@param string $enduserid ID, username, hash or anything uniquely
identifying the end-user to be identified. Preferably the same
ID/username as used in the merchant's own backoffice in order to
simplify for the merchant's support department.
@param string $messageid Your unique ID for the account selection order.
Each order you create must have an unique MessageID.
@param string $locale The end-users localization preference in the
format [language[_territory]]. Language is the ISO 639-1 code and
territory the ISO 3166-1-alpha-2 code.
@param string $country The ISO 3166-1-alpha-2 code of the end-user's
country. This will be used for preselecting the correct country for
the end-user in the iframe.
@param string $ip The IP-address of the end-user.
@param string $successurl The URL to which the end-user should be
redirected after he/she has completed the initial identification
process. Do not put any logic on that page since it's not
guaranteed that the end-user will in fact visit it.
@param string $urltarget The html target/framename of the SuccessURL. Only _top, _self and _parent are suported.
@param string $mobilephone The mobile phonenumber to the end-user in international format.
@param string $firstname The end-user's firstname.
@param string $lastname The end-user's lastname.
@param boolean $holdnotifications Do not deliver notifications for this
order. This is a parameter available when using test.trustly.com
and can be used for manually delivering notifications to your local
system during development. Intead you can get you notifications on
https://test.trustly.com/notifications.html
@param string $email The email address of the end user.
@param string $dateofbirth The ISO 8601 date of birth of the end user.
@param boolean $requestdirectdebitmandate Initiate a direct debit
mandate request for the selected account.
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"selectAccount",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L761-L794 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.registerAccount | public function registerAccount($enduserid, $clearinghouse, $banknumber,
$accountnumber, $firstname, $lastname, $mobilephone=NULL,
$nationalidentificationnumber=NULL, $address=NULL,
$email=NULL, $dateofbirth=NULL,
$addresscountry=NULL, $addresspostalcode=NULL,
$addresscity=NULL, $addressline1=NULL,
$addressline2=NULL) {
$data = array(
'EndUserID' => $enduserid,
'ClearingHouse' => $clearinghouse,
'BankNumber' => $banknumber,
'AccountNumber' => $accountnumber,
'Firstname' => $firstname,
'Lastname' => $lastname,
);
$attributes = array(
'MobilePhone' => $mobilephone,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'Email' => $email,
'DateOfBirth' => $dateofbirth,
'AddressCountry' => $addresscountry,
'AddressPostalcode' => $addresspostalcode,
'AddressCity' => $addresscity,
'AddressLine1' => $addressline1,
'AddressLine2' => $addressline2,
'Address' => $address,
);
$request = new Trustly_Data_JSONRPCRequest('RegisterAccount', $data, $attributes);
return $this->call($request);
} | php | public function registerAccount($enduserid, $clearinghouse, $banknumber,
$accountnumber, $firstname, $lastname, $mobilephone=NULL,
$nationalidentificationnumber=NULL, $address=NULL,
$email=NULL, $dateofbirth=NULL,
$addresscountry=NULL, $addresspostalcode=NULL,
$addresscity=NULL, $addressline1=NULL,
$addressline2=NULL) {
$data = array(
'EndUserID' => $enduserid,
'ClearingHouse' => $clearinghouse,
'BankNumber' => $banknumber,
'AccountNumber' => $accountnumber,
'Firstname' => $firstname,
'Lastname' => $lastname,
);
$attributes = array(
'MobilePhone' => $mobilephone,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'Email' => $email,
'DateOfBirth' => $dateofbirth,
'AddressCountry' => $addresscountry,
'AddressPostalcode' => $addresspostalcode,
'AddressCity' => $addresscity,
'AddressLine1' => $addressline1,
'AddressLine2' => $addressline2,
'Address' => $address,
);
$request = new Trustly_Data_JSONRPCRequest('RegisterAccount', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"registerAccount",
"(",
"$",
"enduserid",
",",
"$",
"clearinghouse",
",",
"$",
"banknumber",
",",
"$",
"accountnumber",
",",
"$",
"firstname",
",",
"$",
"lastname",
",",
"$",
"mobilephone",
"=",
"NULL",
",",
"$",
"nationalidentificationnu... | Call the registerAccount API Method.
Registers and verifies the format of an account to be used in
AccountPayout.
@see https://trustly.com/en/developer/api#/registeraccount
@param string $enduserid ID, username, hash or anything uniquely
identifying the end-user holding this account. Preferably the same
ID/username as used in the merchant's own backoffice in order to
simplify for the merchant's support department.
@param string $clearinghouse The clearing house of the end-user's bank
account. Typically the name of a country in uppercase but might
also be IBAN.
@param string $banknumber The bank number identifying the end-user's
bank in the given clearing house.
@param string $accountnumber The account number, identifying the
end-user's account in the bank.
@param string $firstname The account holders firstname.
@param string $lastname The account holders lastname.
@param string $mobilephone The mobile phonenumber to the account holder
in international format. This is used for KYC and AML routines.
@param string $email The email address of the end user.
@param string $dateofbirth The ISO 8601 date of birth of the end user.
@param string $nationalidentificationnumber The account holder's social
security number / personal number / birth number / etc. Useful for
some banks for identifying transactions and KYC/AML.
@param string $addresscountry The ISO 3166-1-alpha-2 code of the
account holders country.
Use either these separated fields or use the $address field below
if you do not keep separated address fields.
@param string $addresspostalcode The postal code of the account holder
address.
@param string $addresscity The city of the account holder address.
@param string $addressline1 The first line of the account holder
address field.
@param string $addressline2 The second line of the account holder
address information.
@param string $address The account holders address
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"registerAccount",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L854-L886 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.p2p | public function p2p($notificationurl,$enduserid, $messageid,
$locale=NULL, $amount=NULL, $currency=NULL, $country=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL,
$nationalidentificationnumber=NULL, $shopperstatement=NULL,
$ip=NULL, $successurl=NULL, $failurl=NULL, $templateurl=NULL,
$urltarget=NULL, $suggestedminamount=NULL, $suggestedmaxamount=NULL,
$integrationmodule=NULL, $holdnotifications=NULL,
$authorizeonly=NULL, $templatedata=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid
);
$attributes = array(
'AuthorizeOnly' => $this->apiBool($authorizeonly),
'TemplateData' => $templatedata,
'Locale' => $locale,
'Amount' => $amount,
'Currency' => $currency,
'Country' => $country,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'ShopperStatement' => $shopperstatement,
'IP' => $ip,
'SuccessURL' => $successurl,
'FailURL' => $failurl,
'TemplateURL' => $templateurl,
'URLTarget' => $urltarget,
'SuggestedMinAmount' => $suggestedminamount,
'SuggestedMaxAmount' => $suggestedmaxamount,
'IntegrationModule' => $integrationmodule
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('P2P', $data, $attributes);
return $this->call($request);
} | php | public function p2p($notificationurl,$enduserid, $messageid,
$locale=NULL, $amount=NULL, $currency=NULL, $country=NULL,
$mobilephone=NULL, $firstname=NULL, $lastname=NULL,
$nationalidentificationnumber=NULL, $shopperstatement=NULL,
$ip=NULL, $successurl=NULL, $failurl=NULL, $templateurl=NULL,
$urltarget=NULL, $suggestedminamount=NULL, $suggestedmaxamount=NULL,
$integrationmodule=NULL, $holdnotifications=NULL,
$authorizeonly=NULL, $templatedata=NULL) {
$data = array(
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid
);
$attributes = array(
'AuthorizeOnly' => $this->apiBool($authorizeonly),
'TemplateData' => $templatedata,
'Locale' => $locale,
'Amount' => $amount,
'Currency' => $currency,
'Country' => $country,
'MobilePhone' => $mobilephone,
'Firstname' => $firstname,
'Lastname' => $lastname,
'NationalIdentificationNumber' => $nationalidentificationnumber,
'ShopperStatement' => $shopperstatement,
'IP' => $ip,
'SuccessURL' => $successurl,
'FailURL' => $failurl,
'TemplateURL' => $templateurl,
'URLTarget' => $urltarget,
'SuggestedMinAmount' => $suggestedminamount,
'SuggestedMaxAmount' => $suggestedmaxamount,
'IntegrationModule' => $integrationmodule
);
if($holdnotifications) {
$attributes['HoldNotifications'] = 1;
}
$request = new Trustly_Data_JSONRPCRequest('P2P', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"p2p",
"(",
"$",
"notificationurl",
",",
"$",
"enduserid",
",",
"$",
"messageid",
",",
"$",
"locale",
"=",
"NULL",
",",
"$",
"amount",
"=",
"NULL",
",",
"$",
"currency",
"=",
"NULL",
",",
"$",
"country",
"=",
"NULL",
",",
"$",
... | Call the P2P API Method.
Initiates a new P2P transfer by generating a new OrderID and returning
an URL to which the end-user should be redirected.
@see https://trustly.com/en/developer/api#/p2p
@param string $notificationurl The URL to which notifications for this
payment should be sent to. This URL should be hard to guess and not
contain a ? ("question mark").
@param string $enduserid ID, username, hash or anything uniquely
identifying the end-user requesting the withdrawal. Preferably the
same ID/username as used in the merchant's own backoffice in order
to simplify for the merchant's support department.
@param string $messageid Your unique ID for the deposit.
@param string $locale The end-users localization preference in the
format [language[_territory]]. Language is the ISO 639-1 code and
territory the ISO 3166-1-alpha-2 code.
@param float $amount with exactly two decimals in the currency specified
by Currency. Do not use this attribute in combination with
SuggestedMinAmount or SuggestedMaxAmount. Only digits. Use dot (.)
as decimal separator.
@param string $currency The currency of the end-user's account in the
merchant's system.
@param string $country The ISO 3166-1-alpha-2 code of the end-user's
country. This will be used for preselecting the correct country for
the end-user in the iframe.
@param string $mobilephone The mobile phonenumber to the end-user in
international format. This is used for KYC and AML routines.
@param string $firstname The end-user's firstname. Useful for some banks
for identifying transactions.
@param string $lastname The end-user's lastname. Useful for some banks
for identifying transactions.
@param string $nationalidentificationnumber The end-user's social
security number / personal number / birth number / etc. Useful for
some banks for identifying transactions and KYC/AML.
@param string $shopperstatement The text to show on the end-user's bank
statement.
@param string $ip The IP-address of the end-user.
@param string $successurl The URL to which the end-user should be
redirected after a successful deposit. Do not put any logic on that
page since it's not guaranteed that the end-user will in fact visit
it.
@param string $failurl The URL to which the end-user should be
redirected after a failed deposit. Do not put any logic on that
page since it's not guaranteed that the end-user will in fact visit
it.
@param string $templateurl The URL to your template page for the
checkout process.
@param string $urltarget The html target/framename of the SuccessURL.
Only _top, _self and _parent are suported.
@param float $suggestedminamount The minimum amount the end-user is
allowed to deposit in the currency specified by Currency. Only
digits. Use dot (.) as decimal separator.
@param float $suggestedmaxamount The maximum amount the end-user is
allowed to deposit in the currency specified by Currency. Only
digits. Use dot (.) as decimal separator.
@param string $integrationmodule Version information for your
integration module. This is for informational purposes only and can
be useful when troubleshooting problems. Should contain enough
version information to be useful.
@param boolean $holdnotifications Do not deliver notifications for this
order. This is a parameter available when using test.trustly.com
and can be used for manually delivering notifications to your local
system during development. Intead you can get you notifications on
https://test.trustly.com/notifications.html
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"P2P",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L1043-L1087 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.capture | public function capture($orderid, $amount, $currency) {
$data = array(
'OrderID' => $orderid,
'Amount' => $amount,
'Currency' => $currency
);
$attributes = array(
);
$request = new Trustly_Data_JSONRPCRequest('Capture', $data, $attributes);
return $this->call($request);
} | php | public function capture($orderid, $amount, $currency) {
$data = array(
'OrderID' => $orderid,
'Amount' => $amount,
'Currency' => $currency
);
$attributes = array(
);
$request = new Trustly_Data_JSONRPCRequest('Capture', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"capture",
"(",
"$",
"orderid",
",",
"$",
"amount",
",",
"$",
"currency",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'OrderID'",
"=>",
"$",
"orderid",
",",
"'Amount'",
"=>",
"$",
"amount",
",",
"'Currency'",
"=>",
"$",
"currency",... | Call the Capture API Method.
Captures a previously completed Deposit where
Deposit.Attributes.AuthorizeOnly was set to 1
@see https://trustly.com/en/developer/api#/capture
@param integer $orderid The OrderID of the deposit to capture
@param integer $amount The amount to capture with exactly two decimals.
Only digits. Use dot (.) as decimal separator. The amount must be
less than or equal to the authorized amount. If not specified, the
authorized amount will be captured.
@param integer $currency The currency of the amount
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"Capture",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L1109-L1122 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.void | public function void($orderid) {
$data = array(
'OrderID' => $orderid
);
$attributes = array(
);
$request = new Trustly_Data_JSONRPCRequest('Void', $data, $attributes);
return $this->call($request);
} | php | public function void($orderid) {
$data = array(
'OrderID' => $orderid
);
$attributes = array(
);
$request = new Trustly_Data_JSONRPCRequest('Void', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"void",
"(",
"$",
"orderid",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'OrderID'",
"=>",
"$",
"orderid",
")",
";",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"$",
"request",
"=",
"new",
"Trustly_Data_JSONRPCRequest",
"(",
"'... | Call the Void API Method.
Voids a previously completed Deposit where Deposit.Attributes.AuthorizeOnly was set to 1.
@see https://trustly.com/en/developer/api#/void
@param integer $orderid The OrderID of the deposit to void
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"Void",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L1136-L1147 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.charge | public function charge($accountid, $notificationurl, $enduserid, $messageid,
$amount, $currency, $shopperstatement=NULL) {
$data = array(
'AccountID' => $accountid,
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
'Amount' => $amount,
'Currency' => $currency,
);
$attributes = array(
'ShopperStatement' => $shopperstatement,
);
$request = new Trustly_Data_JSONRPCRequest('Charge', $data, $attributes);
return $this->call($request);
} | php | public function charge($accountid, $notificationurl, $enduserid, $messageid,
$amount, $currency, $shopperstatement=NULL) {
$data = array(
'AccountID' => $accountid,
'NotificationURL' => $notificationurl,
'EndUserID' => $enduserid,
'MessageID' => $messageid,
'Amount' => $amount,
'Currency' => $currency,
);
$attributes = array(
'ShopperStatement' => $shopperstatement,
);
$request = new Trustly_Data_JSONRPCRequest('Charge', $data, $attributes);
return $this->call($request);
} | [
"public",
"function",
"charge",
"(",
"$",
"accountid",
",",
"$",
"notificationurl",
",",
"$",
"enduserid",
",",
"$",
"messageid",
",",
"$",
"amount",
",",
"$",
"currency",
",",
"$",
"shopperstatement",
"=",
"NULL",
")",
"{",
"$",
"data",
"=",
"array",
... | Call the Charge API Method.
Initiates a new drect debit charge.
@see https://trustly.com/en/developer/api#/charge
@param string $accountid The AccountID received from an account
notification with granted direct debit mandate from which the money
should be sent.
@param string $notificationurl The URL to which notifications for this
payment should be sent to. This URL should be hard to guess and not
contain a ? ("question mark").
@param string $enduserid ID, username, hash or anything uniquely
identifying the end-user requesting the withdrawal. Preferably the
same ID/username as used in the merchant's own backoffice in order
to simplify for the merchant's support department.
@param string $messageid Your unique ID for the charge.
@param float $amount with exactly two decimals in the currency specified
by Currency. Only digits. Use dot (.) as decimal separator.
@param string $currency The currency of the end-user's account in the
merchant's system.
@param string $shopperstatement The text to show on the end-user's bank
statement.
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"Charge",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L1183-L1201 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.getWithdrawals | public function getWithdrawals($orderid) {
$data = array(
'OrderID' => $orderid,
);
$request = new Trustly_Data_JSONRPCRequest('getWithdrawals', $data);
return $this->call($request);
} | php | public function getWithdrawals($orderid) {
$data = array(
'OrderID' => $orderid,
);
$request = new Trustly_Data_JSONRPCRequest('getWithdrawals', $data);
return $this->call($request);
} | [
"public",
"function",
"getWithdrawals",
"(",
"$",
"orderid",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'OrderID'",
"=>",
"$",
"orderid",
",",
")",
";",
"$",
"request",
"=",
"new",
"Trustly_Data_JSONRPCRequest",
"(",
"'getWithdrawals'",
",",
"$",
"data",
"... | Call the getWithdrawals API Method.
Get a list of withdrawals from an executed order.
@see https://trustly.com/en/developer/api#/getwithdrawals
@param integer $orderid The OrderID of the order to query
@return Trustly_Data_JSONRPCSignedResponse | [
"Call",
"the",
"getWithdrawals",
"API",
"Method",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L1214-L1222 | train |
trustly/trustly-client-php | Trustly/Api/signed.php | Trustly_Api_Signed.hello | public function hello() {
/* The hello call is not signed, use an unsigned API to do the request and then void it */
$api = new Trustly_Api_Unsigned($this->api_username, $this->api_password, $this->api_host, $this->api_port, $this->api_is_https);
return $api->hello();
} | php | public function hello() {
/* The hello call is not signed, use an unsigned API to do the request and then void it */
$api = new Trustly_Api_Unsigned($this->api_username, $this->api_password, $this->api_host, $this->api_port, $this->api_is_https);
return $api->hello();
} | [
"public",
"function",
"hello",
"(",
")",
"{",
"/* The hello call is not signed, use an unsigned API to do the request and then void it */",
"$",
"api",
"=",
"new",
"Trustly_Api_Unsigned",
"(",
"$",
"this",
"->",
"api_username",
",",
"$",
"this",
"->",
"api_password",
",",... | Basic communication test to the API.
@return Trustly_Data_JSONRPCResponse Response from the API | [
"Basic",
"communication",
"test",
"to",
"the",
"API",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Api/signed.php#L1230-L1234 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcnotificationrequest.php | Trustly_Data_JSONRPCNotificationRequest.getParams | public function getParams($name=NULL) {
if(!isset($this->payload['params'])) {
return NULL;
}
$params = $this->payload['params'];
if(isset($name)) {
if(isset($params[$name])) {
return $params[$name];
}
} else {
return $params;
}
return NULL;
} | php | public function getParams($name=NULL) {
if(!isset($this->payload['params'])) {
return NULL;
}
$params = $this->payload['params'];
if(isset($name)) {
if(isset($params[$name])) {
return $params[$name];
}
} else {
return $params;
}
return NULL;
} | [
"public",
"function",
"getParams",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"params",
"=",
"$",
"this",
"->",
"paylo... | Get value from or the entire params payload.
@param string $name Name of the params parameter to obtain. Leave blank
to get the entire payload
@return mixed The value for the params parameter or the entire payload
depending on $name | [
"Get",
"value",
"from",
"or",
"the",
"entire",
"params",
"payload",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcnotificationrequest.php#L93-L106 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcnotificationrequest.php | Trustly_Data_JSONRPCNotificationRequest.getData | public function getData($name=NULL) {
if(!isset($this->payload['params']['data'])) {
return NULL;
}
$data = $this->payload['params']['data'];
if(isset($name)) {
if(isset($data[$name])) {
return $data[$name];
}
} else {
return $data;
}
return NULL;
} | php | public function getData($name=NULL) {
if(!isset($this->payload['params']['data'])) {
return NULL;
}
$data = $this->payload['params']['data'];
if(isset($name)) {
if(isset($data[$name])) {
return $data[$name];
}
} else {
return $data;
}
return NULL;
} | [
"public",
"function",
"getData",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'params'",
"]",
"[",
"'data'",
"]",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"data",
"=",
"$",
"t... | Get the value of a parameter in the params->data section of the
notification response.
@param string $name The name of the parameter. Leave as NULL to get the
entire payload.
@return mixed The value sought after or the entire payload depending on
$name. | [
"Get",
"the",
"value",
"of",
"a",
"parameter",
"in",
"the",
"params",
"-",
">",
"data",
"section",
"of",
"the",
"notification",
"response",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcnotificationrequest.php#L119-L132 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcnotificationresponse.php | Trustly_Data_JSONRPCNotificationResponse.setSuccess | public function setSuccess($success=NULL) {
$status = 'OK';
if(isset($success) && $success !== TRUE) {
$status = 'FAILED';
}
$this->setData('status', $status);
return $success;
} | php | public function setSuccess($success=NULL) {
$status = 'OK';
if(isset($success) && $success !== TRUE) {
$status = 'FAILED';
}
$this->setData('status', $status);
return $success;
} | [
"public",
"function",
"setSuccess",
"(",
"$",
"success",
"=",
"NULL",
")",
"{",
"$",
"status",
"=",
"'OK'",
";",
"if",
"(",
"isset",
"(",
"$",
"success",
")",
"&&",
"$",
"success",
"!==",
"TRUE",
")",
"{",
"$",
"status",
"=",
"'FAILED'",
";",
"}",
... | Set the success status in the response.
@param boolean $success Set to true to indicate that the notification
was successfully processed.
@return $success | [
"Set",
"the",
"success",
"status",
"in",
"the",
"response",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcnotificationresponse.php#L78-L86 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcnotificationresponse.php | Trustly_Data_JSONRPCNotificationResponse.setResult | public function setResult($name, $value) {
if(!isset($this->payload['result'])) {
$this->payload['result'] = array();
}
$this->payload['result'][$name] = $value;
return $value;
} | php | public function setResult($name, $value) {
if(!isset($this->payload['result'])) {
$this->payload['result'] = array();
}
$this->payload['result'][$name] = $value;
return $value;
} | [
"public",
"function",
"setResult",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'result'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"payload",
"[",
"'result'",
"]",
"=",
"array",
"... | Set a parameter in the result section of the notification response.
@param string $name The name of the parameter to set
@param mixed $value The value of the parameter
@return mixed $value | [
"Set",
"a",
"parameter",
"in",
"the",
"result",
"section",
"of",
"the",
"notification",
"response",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcnotificationresponse.php#L110-L116 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcnotificationresponse.php | Trustly_Data_JSONRPCNotificationResponse.getResult | public function getResult($name=NULL) {
$result = NULL;
if(isset($this->payload['result'])) {
$result = $this->payload['result'];
} else {
return NULL;
}
if(isset($name)) {
if(isset($result[$name])) {
return $result[$name];
}
} else {
return $result;
}
} | php | public function getResult($name=NULL) {
$result = NULL;
if(isset($this->payload['result'])) {
$result = $this->payload['result'];
} else {
return NULL;
}
if(isset($name)) {
if(isset($result[$name])) {
return $result[$name];
}
} else {
return $result;
}
} | [
"public",
"function",
"getResult",
"(",
"$",
"name",
"=",
"NULL",
")",
"{",
"$",
"result",
"=",
"NULL",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'result'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"paylo... | Get the value of a parameter in the result section of the notification
response.
@param string $name The name of the parameter. Leave as NULL to get the
entire payload.
@return mixed The value sought after or the entire payload depending on
$name. | [
"Get",
"the",
"value",
"of",
"a",
"parameter",
"in",
"the",
"result",
"section",
"of",
"the",
"notification",
"response",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcnotificationresponse.php#L129-L144 | train |
trustly/trustly-client-php | Trustly/Data/jsonrpcnotificationresponse.php | Trustly_Data_JSONRPCNotificationResponse.setData | public function setData($name, $value) {
if(!isset($this->payload['result'])) {
$this->payload['result'] = array();
}
if(!isset($this->payload['result']['data'])) {
$this->payload['result']['data'] = array($name => $value);
} else {
$this->payload['result']['data'][$name] = $value;
}
return $value;
} | php | public function setData($name, $value) {
if(!isset($this->payload['result'])) {
$this->payload['result'] = array();
}
if(!isset($this->payload['result']['data'])) {
$this->payload['result']['data'] = array($name => $value);
} else {
$this->payload['result']['data'][$name] = $value;
}
return $value;
} | [
"public",
"function",
"setData",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"payload",
"[",
"'result'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"payload",
"[",
"'result'",
"]",
"=",
"array",
"("... | Set a parameter in the result->data section of the notification
response.
@param string $name The name of the parameter to set
@param mixed $value The value of the parameter
@return mixed $value | [
"Set",
"a",
"parameter",
"in",
"the",
"result",
"-",
">",
"data",
"section",
"of",
"the",
"notification",
"response",
"."
] | 6977d2cd5ffde0606a4e1d5df72a1227b98ccee2 | https://github.com/trustly/trustly-client-php/blob/6977d2cd5ffde0606a4e1d5df72a1227b98ccee2/Trustly/Data/jsonrpcnotificationresponse.php#L185-L195 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.requestUrl | public function requestUrl(string $url): EmbeddedAsset
{
$cacheService = Craft::$app->getCache();
$cacheKey = 'embeddedasset:' . $url;
$embeddedAsset = $cacheService->get($cacheKey);
if (!$embeddedAsset)
{
$pluginSettings = EmbeddedAssets::$plugin->getSettings();
$options = [
'min_image_width' => $pluginSettings->minImageSize,
'min_image_height' => $pluginSettings->minImageSize,
'oembed' => ['parameters' => []],
];
if (!empty($pluginSettings->parameters))
{
foreach ($pluginSettings->parameters as $parameter)
{
$param = $parameter['param'];
$value = $parameter['value'];
$options['oembed']['parameters'][$param] = $value;
}
}
if ($pluginSettings->embedlyKey) $options['oembed']['embedly_key'] = $pluginSettings->embedlyKey;
if ($pluginSettings->iframelyKey) $options['oembed']['iframely_key'] = $pluginSettings->iframelyKey;
if ($pluginSettings->googleKey) $options['google'] = ['key' => $pluginSettings->googleKey];
if ($pluginSettings->soundcloudKey) $options['soundcloud'] = ['key' => $pluginSettings->soundcloudKey];
if ($pluginSettings->facebookKey) $options['facebook'] = ['key' => $pluginSettings->facebookKey];
$adapter = Embed::create($url, $options);
$array = $this->_convertFromAdapter($adapter);
$embeddedAsset = $this->createEmbeddedAsset($array);
$cacheService->set($cacheKey, $embeddedAsset, $pluginSettings->cacheDuration);
}
return $embeddedAsset;
} | php | public function requestUrl(string $url): EmbeddedAsset
{
$cacheService = Craft::$app->getCache();
$cacheKey = 'embeddedasset:' . $url;
$embeddedAsset = $cacheService->get($cacheKey);
if (!$embeddedAsset)
{
$pluginSettings = EmbeddedAssets::$plugin->getSettings();
$options = [
'min_image_width' => $pluginSettings->minImageSize,
'min_image_height' => $pluginSettings->minImageSize,
'oembed' => ['parameters' => []],
];
if (!empty($pluginSettings->parameters))
{
foreach ($pluginSettings->parameters as $parameter)
{
$param = $parameter['param'];
$value = $parameter['value'];
$options['oembed']['parameters'][$param] = $value;
}
}
if ($pluginSettings->embedlyKey) $options['oembed']['embedly_key'] = $pluginSettings->embedlyKey;
if ($pluginSettings->iframelyKey) $options['oembed']['iframely_key'] = $pluginSettings->iframelyKey;
if ($pluginSettings->googleKey) $options['google'] = ['key' => $pluginSettings->googleKey];
if ($pluginSettings->soundcloudKey) $options['soundcloud'] = ['key' => $pluginSettings->soundcloudKey];
if ($pluginSettings->facebookKey) $options['facebook'] = ['key' => $pluginSettings->facebookKey];
$adapter = Embed::create($url, $options);
$array = $this->_convertFromAdapter($adapter);
$embeddedAsset = $this->createEmbeddedAsset($array);
$cacheService->set($cacheKey, $embeddedAsset, $pluginSettings->cacheDuration);
}
return $embeddedAsset;
} | [
"public",
"function",
"requestUrl",
"(",
"string",
"$",
"url",
")",
":",
"EmbeddedAsset",
"{",
"$",
"cacheService",
"=",
"Craft",
"::",
"$",
"app",
"->",
"getCache",
"(",
")",
";",
"$",
"cacheKey",
"=",
"'embeddedasset:'",
".",
"$",
"url",
";",
"$",
"e... | Requests embed data from a URL.
@param string $url
@return EmbeddedAsset | [
"Requests",
"embed",
"data",
"from",
"a",
"URL",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L43-L84 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.checkWhitelist | public function checkWhitelist(string $url): bool
{
$pluginSettings = EmbeddedAssets::$plugin->getSettings();
$whitelist = array_merge($pluginSettings->whitelist, $pluginSettings->extraWhitelist);
foreach ($whitelist as $whitelistUrl)
{
if ($whitelistUrl)
{
$pattern = explode('*', $whitelistUrl);
$pattern = array_map('preg_quote', $pattern);
$pattern = implode('[a-z][a-z0-9]*', $pattern);
$pattern = "%^(https?:)?//([a-z0-9\-]+\\.)?$pattern([:/].*)?$%";
if (preg_match($pattern, $url))
{
return true;
}
}
}
return false;
} | php | public function checkWhitelist(string $url): bool
{
$pluginSettings = EmbeddedAssets::$plugin->getSettings();
$whitelist = array_merge($pluginSettings->whitelist, $pluginSettings->extraWhitelist);
foreach ($whitelist as $whitelistUrl)
{
if ($whitelistUrl)
{
$pattern = explode('*', $whitelistUrl);
$pattern = array_map('preg_quote', $pattern);
$pattern = implode('[a-z][a-z0-9]*', $pattern);
$pattern = "%^(https?:)?//([a-z0-9\-]+\\.)?$pattern([:/].*)?$%";
if (preg_match($pattern, $url))
{
return true;
}
}
}
return false;
} | [
"public",
"function",
"checkWhitelist",
"(",
"string",
"$",
"url",
")",
":",
"bool",
"{",
"$",
"pluginSettings",
"=",
"EmbeddedAssets",
"::",
"$",
"plugin",
"->",
"getSettings",
"(",
")",
";",
"$",
"whitelist",
"=",
"array_merge",
"(",
"$",
"pluginSettings",... | Checks a URL against the whitelist set on the plugin settings model.
@param string $url
@return bool Whether the URL is in the whitelist. | [
"Checks",
"a",
"URL",
"against",
"the",
"whitelist",
"set",
"on",
"the",
"plugin",
"settings",
"model",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L92-L114 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.getEmbeddedAsset | public function getEmbeddedAsset(Asset $asset)
{
$embeddedAsset = null;
if ($asset->kind === Asset::KIND_JSON)
{
try
{
// Note - 2018-05-09
// As of Craft 3.0.6 this can be replaced with $asset->getContents()
// This version was released on 2018-05-08 so need to wait for majority adoption
$fileContents = stream_get_contents($asset->getStream());
$decodedJson = Json::decodeIfJson($fileContents);
if (is_array($decodedJson))
{
$embeddedAsset = $this->createEmbeddedAsset($decodedJson);
}
}
catch (Exception $e)
{
// Ignore errors and assume it's not an embedded asset
$embeddedAsset = null;
}
}
return $embeddedAsset;
} | php | public function getEmbeddedAsset(Asset $asset)
{
$embeddedAsset = null;
if ($asset->kind === Asset::KIND_JSON)
{
try
{
// Note - 2018-05-09
// As of Craft 3.0.6 this can be replaced with $asset->getContents()
// This version was released on 2018-05-08 so need to wait for majority adoption
$fileContents = stream_get_contents($asset->getStream());
$decodedJson = Json::decodeIfJson($fileContents);
if (is_array($decodedJson))
{
$embeddedAsset = $this->createEmbeddedAsset($decodedJson);
}
}
catch (Exception $e)
{
// Ignore errors and assume it's not an embedded asset
$embeddedAsset = null;
}
}
return $embeddedAsset;
} | [
"public",
"function",
"getEmbeddedAsset",
"(",
"Asset",
"$",
"asset",
")",
"{",
"$",
"embeddedAsset",
"=",
"null",
";",
"if",
"(",
"$",
"asset",
"->",
"kind",
"===",
"Asset",
"::",
"KIND_JSON",
")",
"{",
"try",
"{",
"// Note - 2018-05-09",
"// As of Craft 3.... | Retrieves an embedded asset model from an asset element, if one exists.
@param Asset $asset
@return EmbeddedAsset|null
@throws \yii\base\InvalidConfigException
@throws \craft\errors\AssetException | [
"Retrieves",
"an",
"embedded",
"asset",
"model",
"from",
"an",
"asset",
"element",
"if",
"one",
"exists",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L124-L151 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.createAsset | public function createAsset(EmbeddedAsset $embeddedAsset, VolumeFolder $folder): Asset
{
$hasReplaceMb4 = method_exists(StringHelper::class, 'replaceMb4');
$assetsService = Craft::$app->getAssets();
$pluginSettings = EmbeddedAssets::$plugin->getSettings();
$tempFilePath = Assets::tempFilePath();
$fileContents = Json::encode($embeddedAsset, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
FileHelper::writeToFile($tempFilePath, $fileContents);
$assetTitle = $embeddedAsset->title ?: $embeddedAsset->url;
// Ensure the title contains no emoji
if ($hasReplaceMb4)
{
$assetTitle = StringHelper::replaceMb4($assetTitle, '');
}
else if (StringHelper::containsMb4($assetTitle))
{
$assetTitle = preg_replace_callback('/./u', function(array $match): string
{
return strlen($match[0]) >= 4 ? '' : $match[0];
}, $assetTitle);
}
$fileName = Assets::prepareAssetName($assetTitle, false);
$fileName = str_replace('.', '', $fileName);
$fileName = $fileName ?: 'embedded-asset';
$fileName = StringHelper::safeTruncate($fileName, $pluginSettings->maxFileNameLength) . '.json';
$fileName = $assetsService->getNameReplacementInFolder($fileName, $folder->id);
$asset = new Asset();
$asset->title = StringHelper::safeTruncate($assetTitle, $pluginSettings->maxAssetNameLength);
$asset->tempFilePath = $tempFilePath;
$asset->filename = $fileName;
$asset->newFolderId = $folder->id;
$asset->volumeId = $folder->volumeId;
$asset->avoidFilenameConflicts = true;
$asset->setScenario(Asset::SCENARIO_CREATE);
return $asset;
} | php | public function createAsset(EmbeddedAsset $embeddedAsset, VolumeFolder $folder): Asset
{
$hasReplaceMb4 = method_exists(StringHelper::class, 'replaceMb4');
$assetsService = Craft::$app->getAssets();
$pluginSettings = EmbeddedAssets::$plugin->getSettings();
$tempFilePath = Assets::tempFilePath();
$fileContents = Json::encode($embeddedAsset, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
FileHelper::writeToFile($tempFilePath, $fileContents);
$assetTitle = $embeddedAsset->title ?: $embeddedAsset->url;
// Ensure the title contains no emoji
if ($hasReplaceMb4)
{
$assetTitle = StringHelper::replaceMb4($assetTitle, '');
}
else if (StringHelper::containsMb4($assetTitle))
{
$assetTitle = preg_replace_callback('/./u', function(array $match): string
{
return strlen($match[0]) >= 4 ? '' : $match[0];
}, $assetTitle);
}
$fileName = Assets::prepareAssetName($assetTitle, false);
$fileName = str_replace('.', '', $fileName);
$fileName = $fileName ?: 'embedded-asset';
$fileName = StringHelper::safeTruncate($fileName, $pluginSettings->maxFileNameLength) . '.json';
$fileName = $assetsService->getNameReplacementInFolder($fileName, $folder->id);
$asset = new Asset();
$asset->title = StringHelper::safeTruncate($assetTitle, $pluginSettings->maxAssetNameLength);
$asset->tempFilePath = $tempFilePath;
$asset->filename = $fileName;
$asset->newFolderId = $folder->id;
$asset->volumeId = $folder->volumeId;
$asset->avoidFilenameConflicts = true;
$asset->setScenario(Asset::SCENARIO_CREATE);
return $asset;
} | [
"public",
"function",
"createAsset",
"(",
"EmbeddedAsset",
"$",
"embeddedAsset",
",",
"VolumeFolder",
"$",
"folder",
")",
":",
"Asset",
"{",
"$",
"hasReplaceMb4",
"=",
"method_exists",
"(",
"StringHelper",
"::",
"class",
",",
"'replaceMb4'",
")",
";",
"$",
"as... | Creates an asset element ready to be saved from an embedded asset model.
@param EmbeddedAsset $embeddedAsset
@param VolumeFolder $folder The folder to save the asset to.
@return Asset
@throws \craft\errors\AssetLogicException
@throws \yii\base\ErrorException
@throws \yii\base\Exception | [
"Creates",
"an",
"asset",
"element",
"ready",
"to",
"be",
"saved",
"from",
"an",
"embedded",
"asset",
"model",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L218-L261 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.getEmbedCode | public function getEmbedCode(EmbeddedAsset $embeddedAsset)
{
$dom = null;
if ($embeddedAsset->code)
{
$errors = libxml_use_internal_errors(true);
$entities = libxml_disable_entity_loader(true);
try
{
$dom = new DOMDocument();
$code = "<div>$embeddedAsset->code</div>";
$isHtml = $dom->loadHTML($code, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
if (!$isHtml)
{
throw new ErrorException();
}
}
catch (ErrorException $e)
{
// Corrupted code property, like due to invalid HTML.
$dom = null;
}
finally
{
libxml_use_internal_errors($errors);
libxml_disable_entity_loader($entities);
}
}
return $dom;
} | php | public function getEmbedCode(EmbeddedAsset $embeddedAsset)
{
$dom = null;
if ($embeddedAsset->code)
{
$errors = libxml_use_internal_errors(true);
$entities = libxml_disable_entity_loader(true);
try
{
$dom = new DOMDocument();
$code = "<div>$embeddedAsset->code</div>";
$isHtml = $dom->loadHTML($code, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
if (!$isHtml)
{
throw new ErrorException();
}
}
catch (ErrorException $e)
{
// Corrupted code property, like due to invalid HTML.
$dom = null;
}
finally
{
libxml_use_internal_errors($errors);
libxml_disable_entity_loader($entities);
}
}
return $dom;
} | [
"public",
"function",
"getEmbedCode",
"(",
"EmbeddedAsset",
"$",
"embeddedAsset",
")",
"{",
"$",
"dom",
"=",
"null",
";",
"if",
"(",
"$",
"embeddedAsset",
"->",
"code",
")",
"{",
"$",
"errors",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",... | Gets the embed code as DOM, if one exists and is valid.
@param EmbeddedAsset $embeddedAsset
@return DOMDocument|null | [
"Gets",
"the",
"embed",
"code",
"as",
"DOM",
"if",
"one",
"exists",
"and",
"is",
"valid",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L305-L338 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.getImageToSize | public function getImageToSize(EmbeddedAsset $embeddedAsset, int $size)
{
return is_array($embeddedAsset->images) ?
$this->_getImageToSize($embeddedAsset->images, $size) : null;
} | php | public function getImageToSize(EmbeddedAsset $embeddedAsset, int $size)
{
return is_array($embeddedAsset->images) ?
$this->_getImageToSize($embeddedAsset->images, $size) : null;
} | [
"public",
"function",
"getImageToSize",
"(",
"EmbeddedAsset",
"$",
"embeddedAsset",
",",
"int",
"$",
"size",
")",
"{",
"return",
"is_array",
"(",
"$",
"embeddedAsset",
"->",
"images",
")",
"?",
"$",
"this",
"->",
"_getImageToSize",
"(",
"$",
"embeddedAsset",
... | Returns the image from an embedded asset closest to some size.
It favours images that most minimally exceed the supplied size.
@param EmbeddedAsset $embeddedAsset
@param int $size
@return array|null | [
"Returns",
"the",
"image",
"from",
"an",
"embedded",
"asset",
"closest",
"to",
"some",
"size",
".",
"It",
"favours",
"images",
"that",
"most",
"minimally",
"exceed",
"the",
"supplied",
"size",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L375-L379 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service.getProviderIconToSize | public function getProviderIconToSize(EmbeddedAsset $embeddedAsset, int $size)
{
return is_array($embeddedAsset->providerIcons) ?
$this->_getImageToSize($embeddedAsset->providerIcons, $size) : null;
} | php | public function getProviderIconToSize(EmbeddedAsset $embeddedAsset, int $size)
{
return is_array($embeddedAsset->providerIcons) ?
$this->_getImageToSize($embeddedAsset->providerIcons, $size) : null;
} | [
"public",
"function",
"getProviderIconToSize",
"(",
"EmbeddedAsset",
"$",
"embeddedAsset",
",",
"int",
"$",
"size",
")",
"{",
"return",
"is_array",
"(",
"$",
"embeddedAsset",
"->",
"providerIcons",
")",
"?",
"$",
"this",
"->",
"_getImageToSize",
"(",
"$",
"emb... | Returns the provider icon from an embedded asset closest to some size.
It favours icons that most minimally exceed the supplied size.
@param EmbeddedAsset $embeddedAsset
@param int $size
@return array|null | [
"Returns",
"the",
"provider",
"icon",
"from",
"an",
"embedded",
"asset",
"closest",
"to",
"some",
"size",
".",
"It",
"favours",
"icons",
"that",
"most",
"minimally",
"exceed",
"the",
"supplied",
"size",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L389-L393 | train |
spicywebau/craft-embedded-assets | src/Service.php | Service._getImageToSize | private function _getImageToSize(array $images, int $size)
{
$selectedImage = null;
$selectedSize = 0;
foreach ($images as $image)
{
if (is_array($image))
{
$imageWidth = isset($image['width']) && is_numeric($image['width']) ? $image['width'] : 0;
$imageHeight = isset($image['height']) && is_numeric($image['height']) ? $image['height'] : 0;
$imageSize = max($imageWidth, $imageHeight);
if (!$selectedImage ||
($selectedSize < $size && $imageSize > $selectedSize) ||
($selectedSize > $imageSize && $imageSize > $size))
{
$selectedImage = $image;
$selectedSize = $imageSize;
}
}
}
return $selectedImage;
} | php | private function _getImageToSize(array $images, int $size)
{
$selectedImage = null;
$selectedSize = 0;
foreach ($images as $image)
{
if (is_array($image))
{
$imageWidth = isset($image['width']) && is_numeric($image['width']) ? $image['width'] : 0;
$imageHeight = isset($image['height']) && is_numeric($image['height']) ? $image['height'] : 0;
$imageSize = max($imageWidth, $imageHeight);
if (!$selectedImage ||
($selectedSize < $size && $imageSize > $selectedSize) ||
($selectedSize > $imageSize && $imageSize > $size))
{
$selectedImage = $image;
$selectedSize = $imageSize;
}
}
}
return $selectedImage;
} | [
"private",
"function",
"_getImageToSize",
"(",
"array",
"$",
"images",
",",
"int",
"$",
"size",
")",
"{",
"$",
"selectedImage",
"=",
"null",
";",
"$",
"selectedSize",
"=",
"0",
";",
"foreach",
"(",
"$",
"images",
"as",
"$",
"image",
")",
"{",
"if",
"... | Helper method for retrieving an image closest to some size.
@param array $images
@param int $size
@return array|null | [
"Helper",
"method",
"for",
"retrieving",
"an",
"image",
"closest",
"to",
"some",
"size",
"."
] | c751fbecb2357cb63994875600722ed18dac9b06 | https://github.com/spicywebau/craft-embedded-assets/blob/c751fbecb2357cb63994875600722ed18dac9b06/src/Service.php#L452-L476 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.