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
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.get_plugin_files
private function get_plugin_files( $path ) { $folder = dirname( $this->get_absolute_path( $path ) ); // Return single file plugins immediately, to avoid iterating over the // entire plugins folder. if ( WP_PLUGIN_DIR === $folder ) { return (array) $path; } return $this->get_files( trailingslashit( $folder ) ); }
php
private function get_plugin_files( $path ) { $folder = dirname( $this->get_absolute_path( $path ) ); // Return single file plugins immediately, to avoid iterating over the // entire plugins folder. if ( WP_PLUGIN_DIR === $folder ) { return (array) $path; } return $this->get_files( trailingslashit( $folder ) ); }
[ "private", "function", "get_plugin_files", "(", "$", "path", ")", "{", "$", "folder", "=", "dirname", "(", "$", "this", "->", "get_absolute_path", "(", "$", "path", ")", ")", ";", "// Return single file plugins immediately, to avoid iterating over the", "// entire plu...
Gets the list of files that are part of the given plugin. @param string $path Relative path to the main plugin file. @return array<string> Array of files with their relative paths.
[ "Gets", "the", "list", "of", "files", "that", "are", "part", "of", "the", "given", "plugin", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L248-L258
train
wp-cli/checksum-command
src/Checksum_Plugin_Command.php
Checksum_Plugin_Command.check_file_checksum
private function check_file_checksum( $path, $checksums ) { if ( $this->supports_sha256() && array_key_exists( 'sha256', $checksums ) ) { $sha256 = $this->get_sha256( $this->get_absolute_path( $path ) ); return in_array( $sha256, (array) $checksums['sha256'], true ); } if ( ! array_key_exists( 'md5', $checksums ) ) { return 'No matching checksum algorithm found'; } $md5 = $this->get_md5( $this->get_absolute_path( $path ) ); return in_array( $md5, (array) $checksums['md5'], true ); }
php
private function check_file_checksum( $path, $checksums ) { if ( $this->supports_sha256() && array_key_exists( 'sha256', $checksums ) ) { $sha256 = $this->get_sha256( $this->get_absolute_path( $path ) ); return in_array( $sha256, (array) $checksums['sha256'], true ); } if ( ! array_key_exists( 'md5', $checksums ) ) { return 'No matching checksum algorithm found'; } $md5 = $this->get_md5( $this->get_absolute_path( $path ) ); return in_array( $md5, (array) $checksums['md5'], true ); }
[ "private", "function", "check_file_checksum", "(", "$", "path", ",", "$", "checksums", ")", "{", "if", "(", "$", "this", "->", "supports_sha256", "(", ")", "&&", "array_key_exists", "(", "'sha256'", ",", "$", "checksums", ")", ")", "{", "$", "sha256", "=...
Checks the integrity of a single plugin file by comparing it to the officially provided checksum. @param string $path Relative path to the plugin file to check the integrity of. @param array $checksums Array of provided checksums to compare against. @return true|string
[ "Checks", "the", "integrity", "of", "a", "single", "plugin", "file", "by", "comparing", "it", "to", "the", "officially", "provided", "checksum", "." ]
7db66668ec116c5ccef7bc27b4354fa81b85018a
https://github.com/wp-cli/checksum-command/blob/7db66668ec116c5ccef7bc27b4354fa81b85018a/src/Checksum_Plugin_Command.php#L270-L286
train
checkout/checkout-magento2-plugin
Model/Validator/Rule.php
Rule.getErrorMessage
public function getErrorMessage() { if($this->errorMessage) { return $this->errorMessage; } return sprintf(self::$defaultErrorMessagePattern, $this->getName()); }
php
public function getErrorMessage() { if($this->errorMessage) { return $this->errorMessage; } return sprintf(self::$defaultErrorMessagePattern, $this->getName()); }
[ "public", "function", "getErrorMessage", "(", ")", "{", "if", "(", "$", "this", "->", "errorMessage", ")", "{", "return", "$", "this", "->", "errorMessage", ";", "}", "return", "sprintf", "(", "self", "::", "$", "defaultErrorMessagePattern", ",", "$", "thi...
Returns error message. If the error message has not been defined in the object constructor the default message will be returned. @return string
[ "Returns", "error", "message", ".", "If", "the", "error", "message", "has", "not", "been", "defined", "in", "the", "object", "constructor", "the", "default", "message", "will", "be", "returned", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Validator/Rule.php#L70-L76
train
checkout/checkout-magento2-plugin
Observer/DataAssignObserver.php
DataAssignObserver.execute
public function execute(Observer $observer) { $data = $this->readDataArgument($observer); $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA); if (!is_array($additionalData)) { return; } $paymentInfo = $this->readPaymentModelArgument($observer); foreach (self::$additionalInformationList as $additionalInformationKey) { if( array_key_exists($additionalInformationKey, $additionalData) ) { $paymentInfo->setAdditionalInformation($additionalInformationKey, $additionalData[$additionalInformationKey]); } } }
php
public function execute(Observer $observer) { $data = $this->readDataArgument($observer); $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA); if (!is_array($additionalData)) { return; } $paymentInfo = $this->readPaymentModelArgument($observer); foreach (self::$additionalInformationList as $additionalInformationKey) { if( array_key_exists($additionalInformationKey, $additionalData) ) { $paymentInfo->setAdditionalInformation($additionalInformationKey, $additionalData[$additionalInformationKey]); } } }
[ "public", "function", "execute", "(", "Observer", "$", "observer", ")", "{", "$", "data", "=", "$", "this", "->", "readDataArgument", "(", "$", "observer", ")", ";", "$", "additionalData", "=", "$", "data", "->", "getData", "(", "PaymentInterface", "::", ...
Handles the observer for payment. @param Observer $observer @return void
[ "Handles", "the", "observer", "for", "payment", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Observer/DataAssignObserver.php#L34-L49
train
checkout/checkout-magento2-plugin
Block/Adminhtml/System/Config/Fieldset/Logo.php
Logo.render
public function render(AbstractElement $element) { $pattern = '<div id="checkout_com_adminhtml_logo"><a href="%s" target="_blank"><img src="%s" alt="Checkout.com Logo"></a></div>'; $url = 'https://checkout.com'; $src = 'https://cdn.checkout.com/img/checkout-logo-online-payments.jpg'; return sprintf($pattern, $url, $src); }
php
public function render(AbstractElement $element) { $pattern = '<div id="checkout_com_adminhtml_logo"><a href="%s" target="_blank"><img src="%s" alt="Checkout.com Logo"></a></div>'; $url = 'https://checkout.com'; $src = 'https://cdn.checkout.com/img/checkout-logo-online-payments.jpg'; return sprintf($pattern, $url, $src); }
[ "public", "function", "render", "(", "AbstractElement", "$", "element", ")", "{", "$", "pattern", "=", "'<div id=\"checkout_com_adminhtml_logo\"><a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"Checkout.com Logo\"></a></div>'", ";", "$", "url", "=", "'https://checkout.com'", ...
Renders form element as HTML @param AbstractElement $element @return string
[ "Renders", "form", "element", "as", "HTML" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/System/Config/Fieldset/Logo.php#L25-L31
train
checkout/checkout-magento2-plugin
Block/Adminhtml/System/Config/Field/AbstractCallbackUrl.php
AbstractCallbackUrl._getElementHtml
protected function _getElementHtml(AbstractElement $element) { $callbackUrl= $this->getBaseUrl() . 'checkout_com/' . $this->getControllerUrl(); $element->setData('value', $callbackUrl); $element->setReadonly('readonly'); return $element->getElementHtml(); }
php
protected function _getElementHtml(AbstractElement $element) { $callbackUrl= $this->getBaseUrl() . 'checkout_com/' . $this->getControllerUrl(); $element->setData('value', $callbackUrl); $element->setReadonly('readonly'); return $element->getElementHtml(); }
[ "protected", "function", "_getElementHtml", "(", "AbstractElement", "$", "element", ")", "{", "$", "callbackUrl", "=", "$", "this", "->", "getBaseUrl", "(", ")", ".", "'checkout_com/'", ".", "$", "this", "->", "getControllerUrl", "(", ")", ";", "$", "element...
Overridden method for rendering a field. In this case the field must be only for read. @param AbstractElement $element @return string
[ "Overridden", "method", "for", "rendering", "a", "field", ".", "In", "this", "case", "the", "field", "must", "be", "only", "for", "read", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/System/Config/Field/AbstractCallbackUrl.php#L24-L31
train
checkout/checkout-magento2-plugin
Gateway/Response/VaultDetailsHandler.php
VaultDetailsHandler.getExtensionAttributes
private function getExtensionAttributes(InfoInterface $payment) { $extensionAttributes = $payment->getExtensionAttributes(); if (null === $extensionAttributes) { $extensionAttributes = $this->paymentExtensionFactory->create(); $payment->setExtensionAttributes($extensionAttributes); } return $extensionAttributes; }
php
private function getExtensionAttributes(InfoInterface $payment) { $extensionAttributes = $payment->getExtensionAttributes(); if (null === $extensionAttributes) { $extensionAttributes = $this->paymentExtensionFactory->create(); $payment->setExtensionAttributes($extensionAttributes); } return $extensionAttributes; }
[ "private", "function", "getExtensionAttributes", "(", "InfoInterface", "$", "payment", ")", "{", "$", "extensionAttributes", "=", "$", "payment", "->", "getExtensionAttributes", "(", ")", ";", "if", "(", "null", "===", "$", "extensionAttributes", ")", "{", "$", ...
Get payment extension attributes @param InfoInterface $payment @return OrderPaymentExtensionInterface
[ "Get", "payment", "extension", "attributes" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Response/VaultDetailsHandler.php#L88-L97
train
checkout/checkout-magento2-plugin
Block/Adminhtml/Plan/Edit/Form.php
Form._getSaveSplitButtonOptions
protected function _getSaveSplitButtonOptions() { $options = []; $options[] = [ 'id' => 'edit-button', 'label' => __('Save & Edit'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndContinueEdit', 'target' => '[data-form=edit-product]'], ], ], 'default' => true, //'onclick'=>'setLocation("ACTION CONTROLLER")', ]; $options[] = [ 'id' => 'new-button', 'label' => __('Save & New'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndNew', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'duplicate-button', 'label' => __('Save & Duplicate'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndDuplicate', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'close-button', 'label' => __('Save & Close'), 'data_attribute' => [ 'mage-init' => ['button' => ['event' => 'save', 'target' => '[data-form=edit-product]']], ], ]; return $options; }
php
protected function _getSaveSplitButtonOptions() { $options = []; $options[] = [ 'id' => 'edit-button', 'label' => __('Save & Edit'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndContinueEdit', 'target' => '[data-form=edit-product]'], ], ], 'default' => true, //'onclick'=>'setLocation("ACTION CONTROLLER")', ]; $options[] = [ 'id' => 'new-button', 'label' => __('Save & New'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndNew', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'duplicate-button', 'label' => __('Save & Duplicate'), 'data_attribute' => [ 'mage-init' => [ 'button' => ['event' => 'saveAndDuplicate', 'target' => '[data-form=edit-product]'], ], ], ]; $options[] = [ 'id' => 'close-button', 'label' => __('Save & Close'), 'data_attribute' => [ 'mage-init' => ['button' => ['event' => 'save', 'target' => '[data-form=edit-product]']], ], ]; return $options; }
[ "protected", "function", "_getSaveSplitButtonOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "$", "options", "[", "]", "=", "[", "'id'", "=>", "'edit-button'", ",", "'label'", "=>", "__", "(", "'Save & Edit'", ")", ",", "'data_attribute'", "=>...
Get dropdown options for save split button @return array
[ "Get", "dropdown", "options", "for", "save", "split", "button" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/Plan/Edit/Form.php#L307-L351
train
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/ApplePayButton.php
ApplePayButton.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::BUTTON_BLACK, 'label' => __('Black') ], [ 'value' => self::BUTTON_WHITE, 'label' => __('White') ], [ 'value' => self::BUTTON_WHITE_LINE, 'label' => __('White with line') ], ]; }
php
public function toOptionArray() { return [ [ 'value' => self::BUTTON_BLACK, 'label' => __('Black') ], [ 'value' => self::BUTTON_WHITE, 'label' => __('White') ], [ 'value' => self::BUTTON_WHITE_LINE, 'label' => __('White with line') ], ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "BUTTON_BLACK", ",", "'label'", "=>", "__", "(", "'Black'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "BUTTON_WHITE", ",", "'label'", "=>", ...
Possible Apple Pay button styles @return array
[ "Possible", "Apple", "Pay", "button", "styles" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/ApplePayButton.php#L26-L41
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getIntegrationLanguage
public function getIntegrationLanguage() { // Get and format the user language $userLanguage = $this->localeResolver->getLocale(); $userLanguage = strtoupper(str_replace('_', '-', $userLanguage)); // Get and format the supported languages $supportedLanguages = []; foreach (self::getSupportedLanguages() as $arr) { $supportedLanguages[] = $arr['value']; } // Get the fallback language $fallbackLanguage = $this->getValue( self::KEY_FALLBACK_LANGUAGE, $this->storeManager->getStore() ); // Compare user language with supported if (in_array($userLanguage, $supportedLanguages)) { return $userLanguage; } else { return ($fallbackLanguage) ? $fallbackLanguage : 'EN-EN'; } }
php
public function getIntegrationLanguage() { // Get and format the user language $userLanguage = $this->localeResolver->getLocale(); $userLanguage = strtoupper(str_replace('_', '-', $userLanguage)); // Get and format the supported languages $supportedLanguages = []; foreach (self::getSupportedLanguages() as $arr) { $supportedLanguages[] = $arr['value']; } // Get the fallback language $fallbackLanguage = $this->getValue( self::KEY_FALLBACK_LANGUAGE, $this->storeManager->getStore() ); // Compare user language with supported if (in_array($userLanguage, $supportedLanguages)) { return $userLanguage; } else { return ($fallbackLanguage) ? $fallbackLanguage : 'EN-EN'; } }
[ "public", "function", "getIntegrationLanguage", "(", ")", "{", "// Get and format the user language", "$", "userLanguage", "=", "$", "this", "->", "localeResolver", "->", "getLocale", "(", ")", ";", "$", "userLanguage", "=", "strtoupper", "(", "str_replace", "(", ...
Returns the integration language. @return string
[ "Returns", "the", "integration", "language", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L174-L198
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getDesignSettings
public function getDesignSettings() { return (array) array ( 'hosted' => array ( 'theme_color' => $this->getValue( self::KEY_THEME_COLOR, $this->storeManager->getStore() ), 'button_label' => $this->getValue( self::KEY_BUTTON_LABEL, $this->storeManager->getStore() ), 'box_title' => $this->getValue( self::KEY_BOX_TITLE, $this->storeManager->getStore() ), 'box_subtitle' => $this->getValue( self::KEY_BOX_SUBTITLE, $this->storeManager->getStore() ), 'logo_url' => $this->getLogoUrl() ) ); }
php
public function getDesignSettings() { return (array) array ( 'hosted' => array ( 'theme_color' => $this->getValue( self::KEY_THEME_COLOR, $this->storeManager->getStore() ), 'button_label' => $this->getValue( self::KEY_BUTTON_LABEL, $this->storeManager->getStore() ), 'box_title' => $this->getValue( self::KEY_BOX_TITLE, $this->storeManager->getStore() ), 'box_subtitle' => $this->getValue( self::KEY_BOX_SUBTITLE, $this->storeManager->getStore() ), 'logo_url' => $this->getLogoUrl() ) ); }
[ "public", "function", "getDesignSettings", "(", ")", "{", "return", "(", "array", ")", "array", "(", "'hosted'", "=>", "array", "(", "'theme_color'", "=>", "$", "this", "->", "getValue", "(", "self", "::", "KEY_THEME_COLOR", ",", "$", "this", "->", "storeM...
Returns the design settings. @return array
[ "Returns", "the", "design", "settings", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L325-L347
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getLogoUrl
public function getLogoUrl() { $logoUrl = $this->getValue( self::KEY_LOGO_URL, $this->storeManager->getStore() ); return (string) (isset($logoUrl) && !empty($logoUrl)) ? $logoUrl : 'none'; }
php
public function getLogoUrl() { $logoUrl = $this->getValue( self::KEY_LOGO_URL, $this->storeManager->getStore() ); return (string) (isset($logoUrl) && !empty($logoUrl)) ? $logoUrl : 'none'; }
[ "public", "function", "getLogoUrl", "(", ")", "{", "$", "logoUrl", "=", "$", "this", "->", "getValue", "(", "self", "::", "KEY_LOGO_URL", ",", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", ")", ";", "return", "(", "string", ")", "(", ...
Returns the hosted logo URL. @return string
[ "Returns", "the", "hosted", "logo", "URL", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L354-L361
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.isActive
public function isActive() { if (!$this->getValue( self::KEY_ACTIVE, $this->storeManager->getStore() )) { return false; } $quote = $this->checkoutSession->getQuote(); return (bool) in_array($quote->getQuoteCurrencyCode(), $this->getAcceptedCurrencies()); }
php
public function isActive() { if (!$this->getValue( self::KEY_ACTIVE, $this->storeManager->getStore() )) { return false; } $quote = $this->checkoutSession->getQuote(); return (bool) in_array($quote->getQuoteCurrencyCode(), $this->getAcceptedCurrencies()); }
[ "public", "function", "isActive", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getValue", "(", "self", "::", "KEY_ACTIVE", ",", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", ")", ")", "{", "return", "false", ";", "}", "$", "q...
Determines if the gateway is active. @return bool
[ "Determines", "if", "the", "gateway", "is", "active", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L407-L418
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getStoreName
public function getStoreName() { $storeName = $this->scopeConfig->getValue( 'general/store_information/name', ScopeInterface::SCOPE_STORE ); trim($storeName); if (empty($storeName)) { $storeName = parse_url($this->storeManager->getStore()->getBaseUrl())['host'] ; } return (string) $storeName; }
php
public function getStoreName() { $storeName = $this->scopeConfig->getValue( 'general/store_information/name', ScopeInterface::SCOPE_STORE ); trim($storeName); if (empty($storeName)) { $storeName = parse_url($this->storeManager->getStore()->getBaseUrl())['host'] ; } return (string) $storeName; }
[ "public", "function", "getStoreName", "(", ")", "{", "$", "storeName", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'general/store_information/name'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ";", "trim", "(", "$", "storeName", ")", "...
Returns the store name. @return string
[ "Returns", "the", "store", "name", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L425-L438
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getGooglePayAllowedNetworks
public function getGooglePayAllowedNetworks() { $allowedNetworks = $this->scopeConfig->getValue( 'payment/checkout_com_googlepay/allowed_card_networks', ScopeInterface::SCOPE_STORE ); return (string) !empty($allowedNetworks) ? $allowedNetworks : 'VISA'; }
php
public function getGooglePayAllowedNetworks() { $allowedNetworks = $this->scopeConfig->getValue( 'payment/checkout_com_googlepay/allowed_card_networks', ScopeInterface::SCOPE_STORE ); return (string) !empty($allowedNetworks) ? $allowedNetworks : 'VISA'; }
[ "public", "function", "getGooglePayAllowedNetworks", "(", ")", "{", "$", "allowedNetworks", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'payment/checkout_com_googlepay/allowed_card_networks'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ";", "ret...
Gets the Google Pay allowed networks. @return string
[ "Gets", "the", "Google", "Pay", "allowed", "networks", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L485-L492
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getApplePayTokenRequestUrl
public function getApplePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_APPLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_APPLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
php
public function getApplePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_APPLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_APPLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
[ "public", "function", "getApplePayTokenRequestUrl", "(", ")", "{", "$", "path", "=", "(", "$", "this", "->", "isLive", "(", ")", ")", "?", "self", "::", "KEY_LIVE_APPLEPAY_TOKEN_REQUEST_URL", ":", "self", "::", "KEY_SANDBOX_APPLEPAY_TOKEN_REQUEST_URL", ";", "retur...
Returns the Apple Pay token request URL. @return string
[ "Returns", "the", "Apple", "Pay", "token", "request", "URL", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L551-L560
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getGooglePayTokenRequestUrl
public function getGooglePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_GOOGLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_GOOGLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
php
public function getGooglePayTokenRequestUrl() { $path = ($this->isLive()) ? self::KEY_LIVE_GOOGLEPAY_TOKEN_REQUEST_URL : self::KEY_SANDBOX_GOOGLEPAY_TOKEN_REQUEST_URL; return (string) $this->getValue( $path, $this->storeManager->getStore() ); }
[ "public", "function", "getGooglePayTokenRequestUrl", "(", ")", "{", "$", "path", "=", "(", "$", "this", "->", "isLive", "(", ")", ")", "?", "self", "::", "KEY_LIVE_GOOGLEPAY_TOKEN_REQUEST_URL", ":", "self", "::", "KEY_SANDBOX_GOOGLEPAY_TOKEN_REQUEST_URL", ";", "re...
Returns the Google Pay token request URL. @return string
[ "Returns", "the", "Google", "Pay", "token", "request", "URL", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L567-L576
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getApplePaySupportedCountries
public function getApplePaySupportedCountries() { $supportedCountries = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/supported_countries', ScopeInterface::SCOPE_STORE ); return !empty($supportedCountries) ? $supportedCountries : 'US,GB'; }
php
public function getApplePaySupportedCountries() { $supportedCountries = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/supported_countries', ScopeInterface::SCOPE_STORE ); return !empty($supportedCountries) ? $supportedCountries : 'US,GB'; }
[ "public", "function", "getApplePaySupportedCountries", "(", ")", "{", "$", "supportedCountries", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'payment/checkout_com_applepay/supported_countries'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ";", "r...
Return the countries supported by Apple Pay. @return array
[ "Return", "the", "countries", "supported", "by", "Apple", "Pay", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L595-L602
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getApplePayProcessingCertificatePassword
public function getApplePayProcessingCertificatePassword() { $pass = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/processing_certificate_password', ScopeInterface::SCOPE_STORE ); trim($pass); return ($pass) ? $pass : ''; }
php
public function getApplePayProcessingCertificatePassword() { $pass = $this->scopeConfig->getValue( 'payment/checkout_com_applepay/processing_certificate_password', ScopeInterface::SCOPE_STORE ); trim($pass); return ($pass) ? $pass : ''; }
[ "public", "function", "getApplePayProcessingCertificatePassword", "(", ")", "{", "$", "pass", "=", "$", "this", "->", "scopeConfig", "->", "getValue", "(", "'payment/checkout_com_applepay/processing_certificate_password'", ",", "ScopeInterface", "::", "SCOPE_STORE", ")", ...
Gets the ApplePay processing certificate password. @return string
[ "Gets", "the", "ApplePay", "processing", "certificate", "password", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L657-L664
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getPublicKey
public function getPublicKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PUBLIC_KEY, $this->storeManager->getStore() )); }
php
public function getPublicKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PUBLIC_KEY, $this->storeManager->getStore() )); }
[ "public", "function", "getPublicKey", "(", ")", "{", "return", "(", "string", ")", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_PUBLIC_KEY", ",", "$", "this", "->", "storeManager", "->", "ge...
Returns the public key for client-side functionality. @return string
[ "Returns", "the", "public", "key", "for", "client", "-", "side", "functionality", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L743-L748
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getSecretKey
public function getSecretKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_SECRET_KEY, $this->storeManager->getStore() )); }
php
public function getSecretKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_SECRET_KEY, $this->storeManager->getStore() )); }
[ "public", "function", "getSecretKey", "(", ")", "{", "return", "(", "string", ")", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_SECRET_KEY", ",", "$", "this", "->", "storeManager", "->", "ge...
Returns the secret key for server-side functionality. @return string
[ "Returns", "the", "secret", "key", "for", "server", "-", "side", "functionality", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L755-L760
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getMadaBinsPath
public function getMadaBinsPath() { return (string) (($this->isLive()) ? $this->getValue( self::KEY_MADA_BINS_PATH, $this->storeManager->getStore() ) : $this->getValue( self::KEY_MADA_BINS_PATH_TEST, $this->storeManager->getStore() )); }
php
public function getMadaBinsPath() { return (string) (($this->isLive()) ? $this->getValue( self::KEY_MADA_BINS_PATH, $this->storeManager->getStore() ) : $this->getValue( self::KEY_MADA_BINS_PATH_TEST, $this->storeManager->getStore() )); }
[ "public", "function", "getMadaBinsPath", "(", ")", "{", "return", "(", "string", ")", "(", "(", "$", "this", "->", "isLive", "(", ")", ")", "?", "$", "this", "->", "getValue", "(", "self", "::", "KEY_MADA_BINS_PATH", ",", "$", "this", "->", "storeManag...
Return the MADA BINS file path. @return string
[ "Return", "the", "MADA", "BINS", "file", "path", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L779-L789
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getPrivateSharedKey
public function getPrivateSharedKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PRIVATE_SHARED_KEY, $this->storeManager->getStore() )); }
php
public function getPrivateSharedKey() { return (string) $this->encryptor->decrypt($this->getValue( self::KEY_PRIVATE_SHARED_KEY, $this->storeManager->getStore() )); }
[ "public", "function", "getPrivateSharedKey", "(", ")", "{", "return", "(", "string", ")", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_PRIVATE_SHARED_KEY", ",", "$", "this", "->", "storeManager"...
Returns the private shared key used for callback function. @return string
[ "Returns", "the", "private", "shared", "key", "used", "for", "callback", "function", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L796-L801
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getCustomCss
public function getCustomCss() { // Prepare the paths $base_url = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $file_path = $this->getValue( 'payment/checkout_com/checkout_com_base_settings/custom_css', $this->storeManager->getStore() ); return $base_url . 'checkout_com/' . $file_path; }
php
public function getCustomCss() { // Prepare the paths $base_url = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $file_path = $this->getValue( 'payment/checkout_com/checkout_com_base_settings/custom_css', $this->storeManager->getStore() ); return $base_url . 'checkout_com/' . $file_path; }
[ "public", "function", "getCustomCss", "(", ")", "{", "// Prepare the paths", "$", "base_url", "=", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", "->", "getBaseUrl", "(", "\\", "Magento", "\\", "Framework", "\\", "UrlInterface", "::", "URL_TYPE...
Returns the custom CSS URL for embedded integration. @return string
[ "Returns", "the", "custom", "CSS", "URL", "for", "embedded", "integration", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1004-L1013
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getCountrySpecificCardTypeConfig
public function getCountrySpecificCardTypeConfig() { $countriesCardTypes = unserialize($this->getValue( self::KEY_COUNTRY_CREDIT_CARD, $this->storeManager->getStore() )); return is_array($countriesCardTypes) ? $countriesCardTypes : []; }
php
public function getCountrySpecificCardTypeConfig() { $countriesCardTypes = unserialize($this->getValue( self::KEY_COUNTRY_CREDIT_CARD, $this->storeManager->getStore() )); return is_array($countriesCardTypes) ? $countriesCardTypes : []; }
[ "public", "function", "getCountrySpecificCardTypeConfig", "(", ")", "{", "$", "countriesCardTypes", "=", "unserialize", "(", "$", "this", "->", "getValue", "(", "self", "::", "KEY_COUNTRY_CREDIT_CARD", ",", "$", "this", "->", "storeManager", "->", "getStore", "(",...
Return the country specific card type config. @return array
[ "Return", "the", "country", "specific", "card", "type", "config", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1044-L1051
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getCountryAvailableCardTypes
public function getCountryAvailableCardTypes($country) { $types = $this->getCountrySpecificCardTypeConfig(); return (!empty($types[$country])) ? $types[$country] : []; }
php
public function getCountryAvailableCardTypes($country) { $types = $this->getCountrySpecificCardTypeConfig(); return (!empty($types[$country])) ? $types[$country] : []; }
[ "public", "function", "getCountryAvailableCardTypes", "(", "$", "country", ")", "{", "$", "types", "=", "$", "this", "->", "getCountrySpecificCardTypeConfig", "(", ")", ";", "return", "(", "!", "empty", "(", "$", "types", "[", "$", "country", "]", ")", ")"...
Get list of card types available for country. @param string $country @return array
[ "Get", "list", "of", "card", "types", "available", "for", "country", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1059-L1062
train
checkout/checkout-magento2-plugin
Gateway/Config/Config.php
Config.getAvailableCardTypes
public function getAvailableCardTypes() { $ccTypes = $this->getValue( self::KEY_CC_TYPES, $this->storeManager->getStore() ); return ! empty($ccTypes) ? explode(',', $ccTypes) : []; }
php
public function getAvailableCardTypes() { $ccTypes = $this->getValue( self::KEY_CC_TYPES, $this->storeManager->getStore() ); return ! empty($ccTypes) ? explode(',', $ccTypes) : []; }
[ "public", "function", "getAvailableCardTypes", "(", ")", "{", "$", "ccTypes", "=", "$", "this", "->", "getValue", "(", "self", "::", "KEY_CC_TYPES", ",", "$", "this", "->", "storeManager", "->", "getStore", "(", ")", ")", ";", "return", "!", "empty", "("...
Retrieve available credit card types. @return array
[ "Retrieve", "available", "credit", "card", "types", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Config/Config.php#L1069-L1076
train
checkout/checkout-magento2-plugin
Model/Factory/VaultTokenFactory.php
VaultTokenFactory.create
public function create(array $card, $customerId = null) { $expiryMonth = str_pad($card['expiryMonth'], 2, '0', STR_PAD_LEFT); $expiryYear = $card['expiryYear']; $expiresAt = $this->getExpirationDate($expiryMonth, $expiryYear); $ccType = $this->ccTypeAdapter->getFromGateway($card['paymentMethod']); /** @var PaymentTokenInterface $paymentToken */ $paymentToken = $this->creditCardTokenFactory->create(); $paymentToken->setExpiresAt($expiresAt); if( array_key_exists('id', $card) ) { $paymentToken->setGatewayToken($card['id']); } $tokenDetails = [ 'type' => $ccType, 'maskedCC' => $card['last4'], 'expirationDate' => $expiryMonth . '/' . $expiryYear, ]; $paymentToken->setTokenDetails($this->convertDetailsToJSON($tokenDetails)); $paymentToken->setIsActive(true); $paymentToken->setPaymentMethodCode(ConfigProvider::CODE); if($customerId) { $paymentToken->setCustomerId($customerId); } $paymentToken->setPublicHash($this->generatePublicHash($paymentToken)); return $paymentToken; }
php
public function create(array $card, $customerId = null) { $expiryMonth = str_pad($card['expiryMonth'], 2, '0', STR_PAD_LEFT); $expiryYear = $card['expiryYear']; $expiresAt = $this->getExpirationDate($expiryMonth, $expiryYear); $ccType = $this->ccTypeAdapter->getFromGateway($card['paymentMethod']); /** @var PaymentTokenInterface $paymentToken */ $paymentToken = $this->creditCardTokenFactory->create(); $paymentToken->setExpiresAt($expiresAt); if( array_key_exists('id', $card) ) { $paymentToken->setGatewayToken($card['id']); } $tokenDetails = [ 'type' => $ccType, 'maskedCC' => $card['last4'], 'expirationDate' => $expiryMonth . '/' . $expiryYear, ]; $paymentToken->setTokenDetails($this->convertDetailsToJSON($tokenDetails)); $paymentToken->setIsActive(true); $paymentToken->setPaymentMethodCode(ConfigProvider::CODE); if($customerId) { $paymentToken->setCustomerId($customerId); } $paymentToken->setPublicHash($this->generatePublicHash($paymentToken)); return $paymentToken; }
[ "public", "function", "create", "(", "array", "$", "card", ",", "$", "customerId", "=", "null", ")", "{", "$", "expiryMonth", "=", "str_pad", "(", "$", "card", "[", "'expiryMonth'", "]", ",", "2", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "$", "expi...
Returns the prepared payment token. @param array $card @param int|null $customerId @return PaymentTokenInterface
[ "Returns", "the", "prepared", "payment", "token", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Factory/VaultTokenFactory.php#L60-L91
train
checkout/checkout-magento2-plugin
Model/Factory/VaultTokenFactory.php
VaultTokenFactory.getExpirationDate
private function getExpirationDate($expiryMonth, $expiryYear) { $expDate = new DateTime( $expiryYear . '-' . $expiryMonth . '-' . '01' . ' ' . '00:00:00', new DateTimeZone('UTC') ); return $expDate->add(new DateInterval('P1M'))->format('Y-m-d 00:00:00'); }
php
private function getExpirationDate($expiryMonth, $expiryYear) { $expDate = new DateTime( $expiryYear . '-' . $expiryMonth . '-' . '01' . ' ' . '00:00:00', new DateTimeZone('UTC') ); return $expDate->add(new DateInterval('P1M'))->format('Y-m-d 00:00:00'); }
[ "private", "function", "getExpirationDate", "(", "$", "expiryMonth", ",", "$", "expiryYear", ")", "{", "$", "expDate", "=", "new", "DateTime", "(", "$", "expiryYear", ".", "'-'", ".", "$", "expiryMonth", ".", "'-'", ".", "'01'", ".", "' '", ".", "'00:00:...
Returns the date time object with the given expiration month and year. @param string $expiryMonth @param string $expiryYear @return string
[ "Returns", "the", "date", "time", "object", "with", "the", "given", "expiration", "month", "and", "year", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Factory/VaultTokenFactory.php#L100-L113
train
checkout/checkout-magento2-plugin
Model/Factory/VaultTokenFactory.php
VaultTokenFactory.generatePublicHash
private function generatePublicHash(PaymentTokenInterface $paymentToken) { $hashKey = $paymentToken->getGatewayToken(); if ($paymentToken->getCustomerId()) { $hashKey = $paymentToken->getCustomerId(); } $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails(); return $this->encryptor->getHash($hashKey); }
php
private function generatePublicHash(PaymentTokenInterface $paymentToken) { $hashKey = $paymentToken->getGatewayToken(); if ($paymentToken->getCustomerId()) { $hashKey = $paymentToken->getCustomerId(); } $hashKey .= $paymentToken->getPaymentMethodCode() . $paymentToken->getType() . $paymentToken->getTokenDetails(); return $this->encryptor->getHash($hashKey); }
[ "private", "function", "generatePublicHash", "(", "PaymentTokenInterface", "$", "paymentToken", ")", "{", "$", "hashKey", "=", "$", "paymentToken", "->", "getGatewayToken", "(", ")", ";", "if", "(", "$", "paymentToken", "->", "getCustomerId", "(", ")", ")", "{...
Generate vault payment public hash @param PaymentTokenInterface $paymentToken @return string
[ "Generate", "vault", "payment", "public", "hash" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Factory/VaultTokenFactory.php#L121-L133
train
checkout/checkout-magento2-plugin
Gateway/Validator/ResponseValidator.php
ResponseValidator.validate
public function validate(array $validationSubject) { $isValid = true; $errorMessages = []; foreach($this->rules() as $rule) { $isRuleValid = $rule->isValid($validationSubject); if( ! $isRuleValid ) { $isValid = false; $errorMessages[] = $rule->getErrorMessage(); if($this->stopInFirstError) { break; } } } return $this->createResult($isValid, $errorMessages); }
php
public function validate(array $validationSubject) { $isValid = true; $errorMessages = []; foreach($this->rules() as $rule) { $isRuleValid = $rule->isValid($validationSubject); if( ! $isRuleValid ) { $isValid = false; $errorMessages[] = $rule->getErrorMessage(); if($this->stopInFirstError) { break; } } } return $this->createResult($isValid, $errorMessages); }
[ "public", "function", "validate", "(", "array", "$", "validationSubject", ")", "{", "$", "isValid", "=", "true", ";", "$", "errorMessages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "rules", "(", ")", "as", "$", "rule", ")", "{", "$", ...
Performs domain-related validation for business object @param array $validationSubject @return ResultInterface
[ "Performs", "domain", "-", "related", "validation", "for", "business", "object" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Validator/ResponseValidator.php#L32-L52
train
checkout/checkout-magento2-plugin
Block/Adminhtml/Plan/AddRow.php
AddRow._construct
protected function _construct() { $this->_objectId = 'row_id'; $this->_blockGroup = 'CheckoutCom_Magento2'; $this->_controller = 'adminhtml_plan'; parent::_construct(); if ($this->_isAllowedAction('CheckoutCom_Magento2::add_row')) { $this->buttonList->update('save', 'label', __('Save')); } else { $this->buttonList->remove('save'); } $this->buttonList->remove('reset'); }
php
protected function _construct() { $this->_objectId = 'row_id'; $this->_blockGroup = 'CheckoutCom_Magento2'; $this->_controller = 'adminhtml_plan'; parent::_construct(); if ($this->_isAllowedAction('CheckoutCom_Magento2::add_row')) { $this->buttonList->update('save', 'label', __('Save')); } else { $this->buttonList->remove('save'); } $this->buttonList->remove('reset'); }
[ "protected", "function", "_construct", "(", ")", "{", "$", "this", "->", "_objectId", "=", "'row_id'", ";", "$", "this", "->", "_blockGroup", "=", "'CheckoutCom_Magento2'", ";", "$", "this", "->", "_controller", "=", "'adminhtml_plan'", ";", "parent", "::", ...
Initialize Imagegallery Images Edit Block.
[ "Initialize", "Imagegallery", "Images", "Edit", "Block", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Adminhtml/Plan/AddRow.php#L42-L54
train
checkout/checkout-magento2-plugin
Model/Fields/SubscriptionStatus.php
SubscriptionStatus.getOptions
public function getOptions() { $res = []; foreach ($this->getOptionArray() as $index => $value) { $res[] = ['value' => $index, 'label' => $value]; } return $res; }
php
public function getOptions() { $res = []; foreach ($this->getOptionArray() as $index => $value) { $res[] = ['value' => $index, 'label' => $value]; } return $res; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getOptionArray", "(", ")", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "res", "[", "]", "=", "[", "'value'", "=>", ...
Get Grid row type array for option element. @return array
[ "Get", "Grid", "row", "type", "array", "for", "option", "element", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Fields/SubscriptionStatus.php#L51-L58
train
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/ApplePayNetworks.php
ApplePayNetworks.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], ]; }
php
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "CARD_VISA", ",", "'label'", "=>", "__", "(", "'Visa'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "CARD_MASTERCARD", ",", "'label'", "=>", ...
Possible Apple Pay Cards @return array
[ "Possible", "Apple", "Pay", "Cards" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/ApplePayNetworks.php#L26-L41
train
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/PaymentMode.php
PaymentMode.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::MODE_CARDS, 'label' => __('Cards') ], [ 'value' => self::MODE_MIXED, 'label' => __('Mixed') ], [ 'value' => self::MODE_LOCAL, 'label' => __('Local payments') ] ]; }
php
public function toOptionArray() { return [ [ 'value' => self::MODE_CARDS, 'label' => __('Cards') ], [ 'value' => self::MODE_MIXED, 'label' => __('Mixed') ], [ 'value' => self::MODE_LOCAL, 'label' => __('Local payments') ] ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "MODE_CARDS", ",", "'label'", "=>", "__", "(", "'Cards'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "MODE_MIXED", ",", "'label'", "=>", "_...
Possible payment modes @return array
[ "Possible", "payment", "modes" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/PaymentMode.php#L26-L41
train
checkout/checkout-magento2-plugin
Model/Fields/UserCards.php
UserCards.getOptionArray
public function getOptionArray() { // Prepare the options array $options = []; // Get the customer id // TODO get from model or user select $customerId = 2; // Get the cards list $cardList = $this->paymentTokenManagement->getListByCustomerId($customerId); // Prepare the options list foreach ($cardList as $card) { // Get the card data $cardData = $card->getData(); // Create the option //if ((int) $cardData->is_active == 1 && (int) $cardData->is_visible == 1) { if ($cardData) { $options[$cardData['gateway_token']] = $this->_getOptionString(json_decode($cardData['details'])); } } return $options; }
php
public function getOptionArray() { // Prepare the options array $options = []; // Get the customer id // TODO get from model or user select $customerId = 2; // Get the cards list $cardList = $this->paymentTokenManagement->getListByCustomerId($customerId); // Prepare the options list foreach ($cardList as $card) { // Get the card data $cardData = $card->getData(); // Create the option //if ((int) $cardData->is_active == 1 && (int) $cardData->is_visible == 1) { if ($cardData) { $options[$cardData['gateway_token']] = $this->_getOptionString(json_decode($cardData['details'])); } } return $options; }
[ "public", "function", "getOptionArray", "(", ")", "{", "// Prepare the options array", "$", "options", "=", "[", "]", ";", "// Get the customer id ", "// TODO get from model or user select", "$", "customerId", "=", "2", ";", "// Get the cards list", "$", "cardList", "="...
Get Grid row type labels array. @return array
[ "Get", "Grid", "row", "type", "labels", "array", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Fields/UserCards.php#L39-L64
train
checkout/checkout-magento2-plugin
Model/Service/CallbackService.php
CallbackService.getAssociatedOrder
private function getAssociatedOrder() { $orderId = $this->gatewayResponse['response']['message']['trackId']; $order = $this->orderFactory->create()->loadByIncrementId($orderId); if($order->isEmpty()) { throw new DomainException('The order does not exists.'); } return $order; }
php
private function getAssociatedOrder() { $orderId = $this->gatewayResponse['response']['message']['trackId']; $order = $this->orderFactory->create()->loadByIncrementId($orderId); if($order->isEmpty()) { throw new DomainException('The order does not exists.'); } return $order; }
[ "private", "function", "getAssociatedOrder", "(", ")", "{", "$", "orderId", "=", "$", "this", "->", "gatewayResponse", "[", "'response'", "]", "[", "'message'", "]", "[", "'trackId'", "]", ";", "$", "order", "=", "$", "this", "->", "orderFactory", "->", ...
Returns the order instance. @return \Magento\Sales\Model\Order @throws DomainException
[ "Returns", "the", "order", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Service/CallbackService.php#L261-L270
train
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getGatewayAmountOfCurrency
public static function getGatewayAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); if ( ! is_numeric($amount) ) { throw new InvalidArgumentException('The amount value is not numeric. The [' . $amount . '] value has been given.'); } $amount = (float) $amount; if ($amount < 0) { throw new InvalidArgumentException('The amount value must be positive. The [' . $amount . '] value has been given.'); } if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (int) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (int) ($amount * self::DIV_1000); } return (int) ($amount * self::DIV_100); }
php
public static function getGatewayAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); if ( ! is_numeric($amount) ) { throw new InvalidArgumentException('The amount value is not numeric. The [' . $amount . '] value has been given.'); } $amount = (float) $amount; if ($amount < 0) { throw new InvalidArgumentException('The amount value must be positive. The [' . $amount . '] value has been given.'); } if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (int) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (int) ($amount * self::DIV_1000); } return (int) ($amount * self::DIV_100); }
[ "public", "static", "function", "getGatewayAmountOfCurrency", "(", "$", "amount", ",", "$", "currencyCode", ")", "{", "$", "currencyCode", "=", "strtoupper", "(", "$", "currencyCode", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "amount", ")", ")", "{...
Returns transformed amount by the given currency code which can be handled by the gateway API. @param float $amount Value from the store. @param string $currencyCode @return int @throws InvalidArgumentException
[ "Returns", "transformed", "amount", "by", "the", "given", "currency", "code", "which", "can", "be", "handled", "by", "the", "gateway", "API", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L78-L100
train
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getStoreAmountOfCurrency
public static function getStoreAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); $amount = (int) $amount; if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (float) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (float) ($amount / self::DIV_1000); } return (float) ($amount / self::DIV_100); }
php
public static function getStoreAmountOfCurrency($amount, $currencyCode) { $currencyCode = strtoupper($currencyCode); $amount = (int) $amount; if( in_array($currencyCode, self::FULL_VALUE_CURRENCIES, true) ) { return (float) $amount; } if( in_array($currencyCode, self::DIV_1000_VALUE_CURRENCIES, true) ) { return (float) ($amount / self::DIV_1000); } return (float) ($amount / self::DIV_100); }
[ "public", "static", "function", "getStoreAmountOfCurrency", "(", "$", "amount", ",", "$", "currencyCode", ")", "{", "$", "currencyCode", "=", "strtoupper", "(", "$", "currencyCode", ")", ";", "$", "amount", "=", "(", "int", ")", "$", "amount", ";", "if", ...
Returns transformed amount by the given currency code which can be handled by the store. @param string|int $amount Value from the gateway. @param $currencyCode @return float
[ "Returns", "transformed", "amount", "by", "the", "given", "currency", "code", "which", "can", "be", "handled", "by", "the", "store", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L109-L122
train
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getConfigArray
public static function getConfigArray() { $data = []; foreach(self::FULL_VALUE_CURRENCIES as $currency) { $data[ $currency ] = 1; } foreach(self::DIV_1000_VALUE_CURRENCIES as $currency) { $data[ $currency ] = self::DIV_1000; } $data['others'] = self::DIV_100; return $data; }
php
public static function getConfigArray() { $data = []; foreach(self::FULL_VALUE_CURRENCIES as $currency) { $data[ $currency ] = 1; } foreach(self::DIV_1000_VALUE_CURRENCIES as $currency) { $data[ $currency ] = self::DIV_1000; } $data['others'] = self::DIV_100; return $data; }
[ "public", "static", "function", "getConfigArray", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "self", "::", "FULL_VALUE_CURRENCIES", "as", "$", "currency", ")", "{", "$", "data", "[", "$", "currency", "]", "=", "1", ";", "}", "for...
Returns a config array for the JS implementation. @return array
[ "Returns", "a", "config", "array", "for", "the", "JS", "implementation", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L129-L143
train
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getPaymentFinalCurrencyCode
public static function getPaymentFinalCurrencyCode($orderCurrencyCode) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { // Use the store base currency code $finalCurrencyCode = $storeBaseCurrencyCode; } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { // Use the order currency code $finalCurrencyCode = $userCurrencyCode; } else { // We have a specific currency code to use for the payment $finalCurrencyCode = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getCustomCurrency(); } return $finalCurrencyCode; }
php
public static function getPaymentFinalCurrencyCode($orderCurrencyCode) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { // Use the store base currency code $finalCurrencyCode = $storeBaseCurrencyCode; } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { // Use the order currency code $finalCurrencyCode = $userCurrencyCode; } else { // We have a specific currency code to use for the payment $finalCurrencyCode = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getCustomCurrency(); } return $finalCurrencyCode; }
[ "public", "static", "function", "getPaymentFinalCurrencyCode", "(", "$", "orderCurrencyCode", ")", "{", "// Get the object manager", "$", "manager", "=", "\\", "Magento", "\\", "Framework", "\\", "App", "\\", "ObjectManager", "::", "getInstance", "(", ")", ";", "/...
Returns a converted currency code. @param string $orderCurrencyCode @return string
[ "Returns", "a", "converted", "currency", "code", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L150-L195
train
checkout/checkout-magento2-plugin
Model/Adapter/ChargeAmountAdapter.php
ChargeAmountAdapter.getPaymentFinalCurrencyValue
public static function getPaymentFinalCurrencyValue($orderAmount) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { if ($userCurrencyCode == $storeBaseCurrencyCode) { // Convert the user currency amount to base currency amount $finalAmount = $orderAmount / $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { $finalAmount = $orderAmount; } } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { if ($userCurrencyCode != $storeBaseCurrencyCode) { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { // Convert the base amount to user currency amount $finalAmount = $orderAmount; } } else { if ($userCurrencyCode != $gatewayPaymentCurrency) { // We have a specific currency to use for the payment $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($userCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } else { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } } return $finalAmount; }
php
public static function getPaymentFinalCurrencyValue($orderAmount) { // Get the object manager $manager = \Magento\Framework\App\ObjectManager::getInstance(); // Load the gateway config and get the gateway payment currency $gatewayPaymentCurrency = $manager->create('CheckoutCom\Magento2\Gateway\Config\Config')->getPaymentCurrency(); // Get the storoe id $storeId = $manager->create('Magento\Checkout\Model\Session')->getQuote()->getStoreId(); // Get the user currency display $quote = $manager->create('Magento\Checkout\Model\Session')->getQuote(); $order = $manager->create('Magento\Checkout\Model\Session')->getLastRealOrder(); if ($quote) { $userCurrencyCode = $quote->getQuoteCurrencyCode(); } else if ($order) { $userCurrencyCode = $quote->getOrderCurrencyCode(); } else { $userCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getCurrentCurrencyCode(); } // Load the store currency $storeBaseCurrencyCode = $manager->create('Magento\Store\Model\StoreManagerInterface')->getStore($storeId)->getBaseCurrency()->getCode(); // Test the store and gateway config conditions if ($gatewayPaymentCurrency == self::BASE_CURRENCY) { if ($userCurrencyCode == $storeBaseCurrencyCode) { // Convert the user currency amount to base currency amount $finalAmount = $orderAmount / $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { $finalAmount = $orderAmount; } } elseif ($gatewayPaymentCurrency == self::ORDER_CURRENCY) { if ($userCurrencyCode != $storeBaseCurrencyCode) { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($userCurrencyCode); } else { // Convert the base amount to user currency amount $finalAmount = $orderAmount; } } else { if ($userCurrencyCode != $gatewayPaymentCurrency) { // We have a specific currency to use for the payment $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($userCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } else { $finalAmount = $orderAmount * $manager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($storeBaseCurrencyCode)->getAnyRate($gatewayPaymentCurrency); } } return $finalAmount; }
[ "public", "static", "function", "getPaymentFinalCurrencyValue", "(", "$", "orderAmount", ")", "{", "// Get the object manager", "$", "manager", "=", "\\", "Magento", "\\", "Framework", "\\", "App", "\\", "ObjectManager", "::", "getInstance", "(", ")", ";", "// Loa...
Returns a converted currency value. @param float $orderAmount @return float
[ "Returns", "a", "converted", "currency", "value", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/ChargeAmountAdapter.php#L202-L264
train
checkout/checkout-magento2-plugin
Model/Resource/MobilePayment.php
MobilePayment.charge
public function charge($data) { // JSON post data to object $this->data = json_decode($data); // Load the customer from email $this->customer = $this->customerRepository->get(filter_var($this->data->email, FILTER_SANITIZE_EMAIL)); // If customer exists and amount is valid if ( (int) $this->customer->getId() > 0 && (float) $this->data->value > 0) { // Prepare the product list if ( isset($this->data->products) && is_array($this->data->products) && count($this->data->products) > 0 ) { // Submit request return (int) $this->submitRequest(); } } return false; }
php
public function charge($data) { // JSON post data to object $this->data = json_decode($data); // Load the customer from email $this->customer = $this->customerRepository->get(filter_var($this->data->email, FILTER_SANITIZE_EMAIL)); // If customer exists and amount is valid if ( (int) $this->customer->getId() > 0 && (float) $this->data->value > 0) { // Prepare the product list if ( isset($this->data->products) && is_array($this->data->products) && count($this->data->products) > 0 ) { // Submit request return (int) $this->submitRequest(); } } return false; }
[ "public", "function", "charge", "(", "$", "data", ")", "{", "// JSON post data to object", "$", "this", "->", "data", "=", "json_decode", "(", "$", "data", ")", ";", "// Load the customer from email", "$", "this", "->", "customer", "=", "$", "this", "->", "c...
Perfom a charge given the required parameters. @api @param mixed $data. @return int.
[ "Perfom", "a", "charge", "given", "the", "required", "parameters", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Resource/MobilePayment.php#L108-L127
train
checkout/checkout-magento2-plugin
Model/Fields/PaymentPlan.php
PaymentPlan.formatData
public function formatData(array $rows) { $options = []; if (($rows) && count($rows) > 0) { foreach ($rows as $row) { $options[$row['id']] = $row['plan_name']; } } return $options; }
php
public function formatData(array $rows) { $options = []; if (($rows) && count($rows) > 0) { foreach ($rows as $row) { $options[$row['id']] = $row['plan_name']; } } return $options; }
[ "public", "function", "formatData", "(", "array", "$", "rows", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "(", "$", "rows", ")", "&&", "count", "(", "$", "rows", ")", ">", "0", ")", "{", "foreach", "(", "$", "rows", "as", "$", "...
Format the data from DB. @return array
[ "Format", "the", "data", "from", "DB", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Fields/PaymentPlan.php#L76-L87
train
checkout/checkout-magento2-plugin
Gateway/Response/TransactionHandler.php
TransactionHandler.vaultCard
public function vaultCard( array $response ){ if (isset($response['card'])) { // Get the card token $cardToken = $response['card']['id']; // Prepare the card data $cardData = []; $cardData['expiryMonth'] = $response['card']['expiryMonth']; $cardData['expiryYear'] = $response['card']['expiryYear']; $cardData['last4'] = $response['card']['last4']; $cardData['paymentMethod'] = $response['card']['paymentMethod']; // Get the payment token $paymentToken = $this->vaultTokenFactory->create($cardData, $this->customerSession->getCustomer()->getId()); try { // Check if the payment token exists $foundPaymentToken = $this->paymentTokenManagement->getByPublicHash( $paymentToken->getPublicHash(), $paymentToken->getCustomerId()); // If the token exists activate it, otherwise create it if ($foundPaymentToken) { $foundPaymentToken->setIsVisible(true); $foundPaymentToken->setIsActive(true); $this->paymentTokenRepository->save($foundPaymentToken); } else { $paymentToken->setGatewayToken($cardToken); $paymentToken->setIsVisible(true); $this->paymentTokenRepository->save($paymentToken); } $this->messageManager->addSuccessMessage( __('The payment card has been stored successfully') ); } catch (\Exception $ex) { $this->messageManager->addErrorMessage( $ex->getMessage() ); } } else { $this->messageManager->addErrorMessage( __('Invalid gateway response. Please contact the site administrator.') ); } }
php
public function vaultCard( array $response ){ if (isset($response['card'])) { // Get the card token $cardToken = $response['card']['id']; // Prepare the card data $cardData = []; $cardData['expiryMonth'] = $response['card']['expiryMonth']; $cardData['expiryYear'] = $response['card']['expiryYear']; $cardData['last4'] = $response['card']['last4']; $cardData['paymentMethod'] = $response['card']['paymentMethod']; // Get the payment token $paymentToken = $this->vaultTokenFactory->create($cardData, $this->customerSession->getCustomer()->getId()); try { // Check if the payment token exists $foundPaymentToken = $this->paymentTokenManagement->getByPublicHash( $paymentToken->getPublicHash(), $paymentToken->getCustomerId()); // If the token exists activate it, otherwise create it if ($foundPaymentToken) { $foundPaymentToken->setIsVisible(true); $foundPaymentToken->setIsActive(true); $this->paymentTokenRepository->save($foundPaymentToken); } else { $paymentToken->setGatewayToken($cardToken); $paymentToken->setIsVisible(true); $this->paymentTokenRepository->save($paymentToken); } $this->messageManager->addSuccessMessage( __('The payment card has been stored successfully') ); } catch (\Exception $ex) { $this->messageManager->addErrorMessage( $ex->getMessage() ); } } else { $this->messageManager->addErrorMessage( __('Invalid gateway response. Please contact the site administrator.') ); } }
[ "public", "function", "vaultCard", "(", "array", "$", "response", ")", "{", "if", "(", "isset", "(", "$", "response", "[", "'card'", "]", ")", ")", "{", "// Get the card token", "$", "cardToken", "=", "$", "response", "[", "'card'", "]", "[", "'id'", "...
Adds a new card. @param array $response @return void
[ "Adds", "a", "new", "card", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Response/TransactionHandler.php#L186-L226
train
checkout/checkout-magento2-plugin
Gateway/Response/TransactionHandler.php
TransactionHandler.setTransactionId
protected function setTransactionId(Payment $payment, $transactionId) { $payment->setTransactionId($transactionId); $payment->setLastTransId($transactionId); $payment->setCcTransId($transactionId); }
php
protected function setTransactionId(Payment $payment, $transactionId) { $payment->setTransactionId($transactionId); $payment->setLastTransId($transactionId); $payment->setCcTransId($transactionId); }
[ "protected", "function", "setTransactionId", "(", "Payment", "$", "payment", ",", "$", "transactionId", ")", "{", "$", "payment", "->", "setTransactionId", "(", "$", "transactionId", ")", ";", "$", "payment", "->", "setLastTransId", "(", "$", "transactionId", ...
Sets the transaction Ids for the payment. @param Payment $payment @param string $transactionId @return void
[ "Sets", "the", "transaction", "Ids", "for", "the", "payment", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Response/TransactionHandler.php#L235-L239
train
checkout/checkout-magento2-plugin
Controller/Payment/AbstractAction.php
AbstractAction.assignGuestEmail
protected function assignGuestEmail(Quote $quote, $email) { $quote->setCustomerEmail($email); $quote->getCustomer()->setEmail($email); $quote->getBillingAddress()->setEmail($email); }
php
protected function assignGuestEmail(Quote $quote, $email) { $quote->setCustomerEmail($email); $quote->getCustomer()->setEmail($email); $quote->getBillingAddress()->setEmail($email); }
[ "protected", "function", "assignGuestEmail", "(", "Quote", "$", "quote", ",", "$", "email", ")", "{", "$", "quote", "->", "setCustomerEmail", "(", "$", "email", ")", ";", "$", "quote", "->", "getCustomer", "(", ")", "->", "setEmail", "(", "$", "email", ...
Assigns the given email to the provided quote instance. @param Quote $quote @param $email
[ "Assigns", "the", "given", "email", "to", "the", "provided", "quote", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Controller/Payment/AbstractAction.php#L84-L88
train
checkout/checkout-magento2-plugin
Gateway/Http/Client/AbstractTransaction.php
AbstractTransaction.placeRequest
public function placeRequest(TransferInterface $transferObject) { if ($this->gatewayResponseHolder->hasCallbackResponse()) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->logger->debug([ 'action' => 'callback', 'response' => $response, ]); return $response; } // Prepare the transfert data $this->prepareTransfer($transferObject); // Update the email field for guest users $this->updateGuestEmail($this->body); // Prepare some log data $log = [ 'request' => $this->body, 'request_uri' => $this->fullUri, 'request_headers' => $transferObject->getHeaders(), 'request_method' => $this->getMethod(), ]; $result = []; $client = $this->clientFactory; $client->setConfig($transferObject->getClientConfig()); $client->setMethod($this->getMethod()); switch($this->getMethod()) { case \Zend_Http_Client::GET: $client->setRawData( json_encode($this->body) ) ; break; case \Zend_Http_Client::POST: $client->setRawData( json_encode($this->body) ) ; break; default: throw new \LogicException( sprintf('Unsupported HTTP method %s', $transferObject->getMethod()) ); } $client->setHeaders($transferObject->getHeaders()); $client->setUri($this->fullUri); try { $response = $client->request(); $result = json_decode($response->getBody(), true); $log['response'] = $result; if( array_key_exists('errorCode', $result) ) { $exception = new ApiClientException($result['message'], $result['errorCode'], $result['eventId']); $this->messageManager->addErrorMessage( $exception->getFullMessage() ); throw $exception; } } catch (Zend_Http_Client_Exception $e) { throw new ClientException(__($e->getMessage())); } finally { $this->logger->debug($log); } return $result; }
php
public function placeRequest(TransferInterface $transferObject) { if ($this->gatewayResponseHolder->hasCallbackResponse()) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->logger->debug([ 'action' => 'callback', 'response' => $response, ]); return $response; } // Prepare the transfert data $this->prepareTransfer($transferObject); // Update the email field for guest users $this->updateGuestEmail($this->body); // Prepare some log data $log = [ 'request' => $this->body, 'request_uri' => $this->fullUri, 'request_headers' => $transferObject->getHeaders(), 'request_method' => $this->getMethod(), ]; $result = []; $client = $this->clientFactory; $client->setConfig($transferObject->getClientConfig()); $client->setMethod($this->getMethod()); switch($this->getMethod()) { case \Zend_Http_Client::GET: $client->setRawData( json_encode($this->body) ) ; break; case \Zend_Http_Client::POST: $client->setRawData( json_encode($this->body) ) ; break; default: throw new \LogicException( sprintf('Unsupported HTTP method %s', $transferObject->getMethod()) ); } $client->setHeaders($transferObject->getHeaders()); $client->setUri($this->fullUri); try { $response = $client->request(); $result = json_decode($response->getBody(), true); $log['response'] = $result; if( array_key_exists('errorCode', $result) ) { $exception = new ApiClientException($result['message'], $result['errorCode'], $result['eventId']); $this->messageManager->addErrorMessage( $exception->getFullMessage() ); throw $exception; } } catch (Zend_Http_Client_Exception $e) { throw new ClientException(__($e->getMessage())); } finally { $this->logger->debug($log); } return $result; }
[ "public", "function", "placeRequest", "(", "TransferInterface", "$", "transferObject", ")", "{", "if", "(", "$", "this", "->", "gatewayResponseHolder", "->", "hasCallbackResponse", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "gatewayResponseHold...
Places request to gateway. Returns result as ENV array @param TransferInterface $transferObject @return array @throws ClientException @throws ApiClientException @throws Zend_Http_Client_Exception @throws \LogicException
[ "Places", "request", "to", "gateway", ".", "Returns", "result", "as", "ENV", "array" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Http/Client/AbstractTransaction.php#L117-L187
train
checkout/checkout-magento2-plugin
Gateway/Http/Client/AbstractTransaction.php
AbstractTransaction.prepareTransfer
protected function prepareTransfer(TransferInterface $transferObject) { $uri = $this->getUri(); $body = $transferObject->getBody(); if( array_key_exists('chargeId', $body) ) { $uri = str_replace('{chargeId}', $body['chargeId'], $uri); unset($body['chargeId']); } $this->fullUri = $transferObject->getUri() . $uri; $this->body = $body; }
php
protected function prepareTransfer(TransferInterface $transferObject) { $uri = $this->getUri(); $body = $transferObject->getBody(); if( array_key_exists('chargeId', $body) ) { $uri = str_replace('{chargeId}', $body['chargeId'], $uri); unset($body['chargeId']); } $this->fullUri = $transferObject->getUri() . $uri; $this->body = $body; }
[ "protected", "function", "prepareTransfer", "(", "TransferInterface", "$", "transferObject", ")", "{", "$", "uri", "=", "$", "this", "->", "getUri", "(", ")", ";", "$", "body", "=", "$", "transferObject", "->", "getBody", "(", ")", ";", "if", "(", "array...
Prepares the URI and body based on the given transfer object. @param TransferInterface $transferObject
[ "Prepares", "the", "URI", "and", "body", "based", "on", "the", "given", "transfer", "object", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Http/Client/AbstractTransaction.php#L209-L221
train
checkout/checkout-magento2-plugin
Model/Adapter/CcTypeAdapter.php
CcTypeAdapter.getFromGateway
public function getFromGateway($type) { $mapper = $this->config->getCcTypesMapper(); $type = strtolower($type); if( array_key_exists($type, $mapper) ) { return $mapper[$type]; } return 'OT'; }
php
public function getFromGateway($type) { $mapper = $this->config->getCcTypesMapper(); $type = strtolower($type); if( array_key_exists($type, $mapper) ) { return $mapper[$type]; } return 'OT'; }
[ "public", "function", "getFromGateway", "(", "$", "type", ")", "{", "$", "mapper", "=", "$", "this", "->", "config", "->", "getCcTypesMapper", "(", ")", ";", "$", "type", "=", "strtolower", "(", "$", "type", ")", ";", "if", "(", "array_key_exists", "("...
Returns Credit Card type for a store. @param string $type @return string
[ "Returns", "Credit", "Card", "type", "for", "a", "store", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/CcTypeAdapter.php#L36-L45
train
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/GooglePayNetworks.php
GooglePayNetworks.toOptionArray
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], [ 'value' => self::CARD_JCB, 'label' => __('JCB') ], [ 'value' => self::CARD_DISCOVER, 'label' => __('Discover') ], ]; }
php
public function toOptionArray() { return [ [ 'value' => self::CARD_VISA, 'label' => __('Visa') ], [ 'value' => self::CARD_MASTERCARD, 'label' => __('Mastercard') ], [ 'value' => self::CARD_AMEX, 'label' => __('American Express') ], [ 'value' => self::CARD_JCB, 'label' => __('JCB') ], [ 'value' => self::CARD_DISCOVER, 'label' => __('Discover') ], ]; }
[ "public", "function", "toOptionArray", "(", ")", "{", "return", "[", "[", "'value'", "=>", "self", "::", "CARD_VISA", ",", "'label'", "=>", "__", "(", "'Visa'", ")", "]", ",", "[", "'value'", "=>", "self", "::", "CARD_MASTERCARD", ",", "'label'", "=>", ...
Possible Google Pay Cards @return array
[ "Possible", "Google", "Pay", "Cards" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/GooglePayNetworks.php#L28-L51
train
checkout/checkout-magento2-plugin
Gateway/Command/WebHookCommand.php
WebHookCommand.execute
public function execute(array $commandSubject) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->handler->handle($commandSubject, $response); }
php
public function execute(array $commandSubject) { $response = $this->gatewayResponseHolder->getGatewayResponse(); $this->handler->handle($commandSubject, $response); }
[ "public", "function", "execute", "(", "array", "$", "commandSubject", ")", "{", "$", "response", "=", "$", "this", "->", "gatewayResponseHolder", "->", "getGatewayResponse", "(", ")", ";", "$", "this", "->", "handler", "->", "handle", "(", "$", "commandSubje...
Executes command basing on business object @param array $commandSubject @return null|Command\ResultInterface @throws CommandException
[ "Executes", "command", "basing", "on", "business", "object" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Command/WebHookCommand.php#L48-L52
train
checkout/checkout-magento2-plugin
Observer/OrderCancelObserver.php
OrderCancelObserver.execute
public function execute(Observer $observer) { // Get the order $order = $observer->getEvent()->getOrder(); // Get the payment method $paymentMethod = $order->getPayment()->getMethod(); // Test the current method used if ($paymentMethod == ConfigProvider::CODE || $paymentMethod == ConfigProvider::CC_VAULT_CODE || $paymentMethod == ConfigProvider::THREE_DS_CODE) { // Update the hub API for cancelled order $this->orderService->cancelTransactionToRemote($order); } return $this; }
php
public function execute(Observer $observer) { // Get the order $order = $observer->getEvent()->getOrder(); // Get the payment method $paymentMethod = $order->getPayment()->getMethod(); // Test the current method used if ($paymentMethod == ConfigProvider::CODE || $paymentMethod == ConfigProvider::CC_VAULT_CODE || $paymentMethod == ConfigProvider::THREE_DS_CODE) { // Update the hub API for cancelled order $this->orderService->cancelTransactionToRemote($order); } return $this; }
[ "public", "function", "execute", "(", "Observer", "$", "observer", ")", "{", "// Get the order", "$", "order", "=", "$", "observer", "->", "getEvent", "(", ")", "->", "getOrder", "(", ")", ";", "// Get the payment method", "$", "paymentMethod", "=", "$", "or...
Handles the observer for order cancellation. @param Observer $observer @return void
[ "Handles", "the", "observer", "for", "order", "cancellation", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Observer/OrderCancelObserver.php#L35-L51
train
checkout/checkout-magento2-plugin
Block/Form.php
Form.isVaultEnabled
public function isVaultEnabled() { $storeId = $this->_storeManager->getStore()->getId(); $vaultPayment = $this->getVaultPayment(); return $vaultPayment->isActive($storeId); }
php
public function isVaultEnabled() { $storeId = $this->_storeManager->getStore()->getId(); $vaultPayment = $this->getVaultPayment(); return $vaultPayment->isActive($storeId); }
[ "public", "function", "isVaultEnabled", "(", ")", "{", "$", "storeId", "=", "$", "this", "->", "_storeManager", "->", "getStore", "(", ")", "->", "getId", "(", ")", ";", "$", "vaultPayment", "=", "$", "this", "->", "getVaultPayment", "(", ")", ";", "re...
Determines if the gateway supports CC store for later use. @return bool
[ "Determines", "if", "the", "gateway", "supports", "CC", "store", "for", "later", "use", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Form.php#L64-L69
train
checkout/checkout-magento2-plugin
Block/Form.php
Form.getPaymentDataHelper
private function getPaymentDataHelper() { if ($this->paymentDataHelper === null) { $this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class); } return $this->paymentDataHelper; }
php
private function getPaymentDataHelper() { if ($this->paymentDataHelper === null) { $this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class); } return $this->paymentDataHelper; }
[ "private", "function", "getPaymentDataHelper", "(", ")", "{", "if", "(", "$", "this", "->", "paymentDataHelper", "===", "null", ")", "{", "$", "this", "->", "paymentDataHelper", "=", "ObjectManager", "::", "getInstance", "(", ")", "->", "get", "(", "Data", ...
Returns payment data helper instance. @return Data @throws \RuntimeException
[ "Returns", "payment", "data", "helper", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Block/Form.php#L87-L92
train
checkout/checkout-magento2-plugin
Gateway/Http/TransferFactory.php
TransferFactory.create
public function create(array $request) { $headers = self::$headers; $headers['Authorization'] = $this->config->getSecretKey(); return $this->transferBuilder ->setClientConfig(self::$clientConfig) ->setHeaders($headers) ->setUri($this->config->getApiUrl()) ->setBody($request) ->build(); }
php
public function create(array $request) { $headers = self::$headers; $headers['Authorization'] = $this->config->getSecretKey(); return $this->transferBuilder ->setClientConfig(self::$clientConfig) ->setHeaders($headers) ->setUri($this->config->getApiUrl()) ->setBody($request) ->build(); }
[ "public", "function", "create", "(", "array", "$", "request", ")", "{", "$", "headers", "=", "self", "::", "$", "headers", ";", "$", "headers", "[", "'Authorization'", "]", "=", "$", "this", "->", "config", "->", "getSecretKey", "(", ")", ";", "return"...
Builds gateway transfer object @param array $request @return TransferInterface
[ "Builds", "gateway", "transfer", "object" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Gateway/Http/TransferFactory.php#L61-L72
train
checkout/checkout-magento2-plugin
Controller/Adminhtml/Subscription/AddRow.php
AddRow.execute
public function execute() { $rowId = (int) $this->getRequest()->getParam('id'); $rowData = $this->_objectManager->create('CheckoutCom\Magento2\Model\Subscription'); if ($rowId) { $rowData = $rowData->load($rowId); $rowTitle = $rowData->getTitle(); if (!$rowData->getEntityId()) { $this->messageManager->addError(__('This item no longer exists.')); $this->_redirect('checkout_com/subscription/rowdata'); return; } } $this->_coreRegistry->register('row_data', $rowData); $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $title = $rowId ? __('Edit Item').$rowTitle : __('Add New Item'); $resultPage->getConfig()->getTitle()->prepend($title); return $resultPage; }
php
public function execute() { $rowId = (int) $this->getRequest()->getParam('id'); $rowData = $this->_objectManager->create('CheckoutCom\Magento2\Model\Subscription'); if ($rowId) { $rowData = $rowData->load($rowId); $rowTitle = $rowData->getTitle(); if (!$rowData->getEntityId()) { $this->messageManager->addError(__('This item no longer exists.')); $this->_redirect('checkout_com/subscription/rowdata'); return; } } $this->_coreRegistry->register('row_data', $rowData); $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $title = $rowId ? __('Edit Item').$rowTitle : __('Add New Item'); $resultPage->getConfig()->getTitle()->prepend($title); return $resultPage; }
[ "public", "function", "execute", "(", ")", "{", "$", "rowId", "=", "(", "int", ")", "$", "this", "->", "getRequest", "(", ")", "->", "getParam", "(", "'id'", ")", ";", "$", "rowData", "=", "$", "this", "->", "_objectManager", "->", "create", "(", "...
Add New Row Form page. @return \Magento\Backend\Model\View\Result\Page
[ "Add", "New", "Row", "Form", "page", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Controller/Adminhtml/Subscription/AddRow.php#L34-L53
train
checkout/checkout-magento2-plugin
Helper/Helper.php
Helper.getModuleVersion
public function getModuleVersion() { // Get the module path $module_path = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2'); // Get the content of composer.json $json = file_get_contents($module_path . '/composer.json'); // Decode the data and return $data = json_decode($json); return $data->version; }
php
public function getModuleVersion() { // Get the module path $module_path = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2'); // Get the content of composer.json $json = file_get_contents($module_path . '/composer.json'); // Decode the data and return $data = json_decode($json); return $data->version; }
[ "public", "function", "getModuleVersion", "(", ")", "{", "// Get the module path", "$", "module_path", "=", "$", "this", "->", "directoryReader", "->", "getModuleDir", "(", "''", ",", "'CheckoutCom_Magento2'", ")", ";", "// Get the content of composer.json", "$", "jso...
Get the module version from composer.json file
[ "Get", "the", "module", "version", "from", "composer", ".", "json", "file" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Helper/Helper.php#L66-L77
train
checkout/checkout-magento2-plugin
Helper/Helper.php
Helper.isMadaBin
public function isMadaBin($bin) { // Set the root path $csvPath = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2') . '/' . $this->config->getMadaBinsPath(); // Get the data $csvData = $this->csvParser->getData($csvPath); // Remove the first row of csv columns unset($csvData[0]); // Build the MADA BIN array $binArray = []; foreach ($csvData as $row) { $binArray[] = $row[1]; } return in_array($bin, $binArray); }
php
public function isMadaBin($bin) { // Set the root path $csvPath = $this->directoryReader->getModuleDir('', 'CheckoutCom_Magento2') . '/' . $this->config->getMadaBinsPath(); // Get the data $csvData = $this->csvParser->getData($csvPath); // Remove the first row of csv columns unset($csvData[0]); // Build the MADA BIN array $binArray = []; foreach ($csvData as $row) { $binArray[] = $row[1]; } return in_array($bin, $binArray); }
[ "public", "function", "isMadaBin", "(", "$", "bin", ")", "{", "// Set the root path", "$", "csvPath", "=", "$", "this", "->", "directoryReader", "->", "getModuleDir", "(", "''", ",", "'CheckoutCom_Magento2'", ")", ".", "'/'", ".", "$", "this", "->", "config"...
Checks the MADA BIN @return bool
[ "Checks", "the", "MADA", "BIN" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Helper/Helper.php#L84-L101
train
checkout/checkout-magento2-plugin
Helper/Helper.php
Helper.prepareGuestQuote
public function prepareGuestQuote($quote, $email = null) { // Retrieve the user email $guestEmail = $email ?? $this->customerSession->getData('checkoutSessionData')['customerEmail'] ?? $quote->getCustomerEmail() ?? $quote->getBillingAddress()->getEmail() ?? $this->cookieManager->getCookie(self::EMAIL_COOKIE_NAME); // Set the quote as guest $quote->setCustomerId(null) ->setCustomerEmail($guestEmail) ->setCustomerIsGuest(true) ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); // Delete the cookie $this->cookieManager->deleteCookie(self::EMAIL_COOKIE_NAME); return $quote; }
php
public function prepareGuestQuote($quote, $email = null) { // Retrieve the user email $guestEmail = $email ?? $this->customerSession->getData('checkoutSessionData')['customerEmail'] ?? $quote->getCustomerEmail() ?? $quote->getBillingAddress()->getEmail() ?? $this->cookieManager->getCookie(self::EMAIL_COOKIE_NAME); // Set the quote as guest $quote->setCustomerId(null) ->setCustomerEmail($guestEmail) ->setCustomerIsGuest(true) ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID); // Delete the cookie $this->cookieManager->deleteCookie(self::EMAIL_COOKIE_NAME); return $quote; }
[ "public", "function", "prepareGuestQuote", "(", "$", "quote", ",", "$", "email", "=", "null", ")", "{", "// Retrieve the user email ", "$", "guestEmail", "=", "$", "email", "??", "$", "this", "->", "customerSession", "->", "getData", "(", "'checkoutSessionData'"...
Sets the email for guest users @return bool
[ "Sets", "the", "email", "for", "guest", "users" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Helper/Helper.php#L108-L126
train
checkout/checkout-magento2-plugin
Model/Service/OrderService.php
OrderService.getCheckoutMethod
private function getCheckoutMethod(Quote $quote) { if ($this->customerSession->isLoggedIn()) { return Onepage::METHOD_CUSTOMER; } if (!$quote->getCheckoutMethod()) { if ($this->checkoutHelper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Onepage::METHOD_GUEST); } else { $quote->setCheckoutMethod(Onepage::METHOD_REGISTER); } } return $quote->getCheckoutMethod(); }
php
private function getCheckoutMethod(Quote $quote) { if ($this->customerSession->isLoggedIn()) { return Onepage::METHOD_CUSTOMER; } if (!$quote->getCheckoutMethod()) { if ($this->checkoutHelper->isAllowedGuestCheckout($quote)) { $quote->setCheckoutMethod(Onepage::METHOD_GUEST); } else { $quote->setCheckoutMethod(Onepage::METHOD_REGISTER); } } return $quote->getCheckoutMethod(); }
[ "private", "function", "getCheckoutMethod", "(", "Quote", "$", "quote", ")", "{", "if", "(", "$", "this", "->", "customerSession", "->", "isLoggedIn", "(", ")", ")", "{", "return", "Onepage", "::", "METHOD_CUSTOMER", ";", "}", "if", "(", "!", "$", "quote...
Get checkout method. @param Quote $quote @return string
[ "Get", "checkout", "method", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Service/OrderService.php#L297-L311
train
checkout/checkout-magento2-plugin
Model/Service/OrderService.php
OrderService.disabledQuoteAddressValidation
protected function disabledQuoteAddressValidation(Quote $quote) { $billingAddress = $quote->getBillingAddress(); $billingAddress->setShouldIgnoreValidation(true); if (!$quote->getIsVirtual()) { $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setShouldIgnoreValidation(true); if (!$billingAddress->getEmail()) { $billingAddress->setSameAsBilling(1); } } }
php
protected function disabledQuoteAddressValidation(Quote $quote) { $billingAddress = $quote->getBillingAddress(); $billingAddress->setShouldIgnoreValidation(true); if (!$quote->getIsVirtual()) { $shippingAddress = $quote->getShippingAddress(); $shippingAddress->setShouldIgnoreValidation(true); if (!$billingAddress->getEmail()) { $billingAddress->setSameAsBilling(1); } } }
[ "protected", "function", "disabledQuoteAddressValidation", "(", "Quote", "$", "quote", ")", "{", "$", "billingAddress", "=", "$", "quote", "->", "getBillingAddress", "(", ")", ";", "$", "billingAddress", "->", "setShouldIgnoreValidation", "(", "true", ")", ";", ...
Disables the address validation for the given quote instance. @param Quote $quote
[ "Disables", "the", "address", "validation", "for", "the", "given", "quote", "instance", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Service/OrderService.php#L318-L330
train
checkout/checkout-magento2-plugin
Model/Adapter/CallbackEventAdapter.php
CallbackEventAdapter.getTargetCommandName
public function getTargetCommandName($eventType) { $eventParts = explode('.', $eventType); $command = null; if( array_key_exists(1, $eventParts)) { $command = self::$map[ $eventParts[1] ] ?? null; } return $command; }
php
public function getTargetCommandName($eventType) { $eventParts = explode('.', $eventType); $command = null; if( array_key_exists(1, $eventParts)) { $command = self::$map[ $eventParts[1] ] ?? null; } return $command; }
[ "public", "function", "getTargetCommandName", "(", "$", "eventType", ")", "{", "$", "eventParts", "=", "explode", "(", "'.'", ",", "$", "eventType", ")", ";", "$", "command", "=", "null", ";", "if", "(", "array_key_exists", "(", "1", ",", "$", "eventPart...
Returns the target command name based on received gateway event type. @param string $eventType @return string|null
[ "Returns", "the", "target", "command", "name", "based", "on", "received", "gateway", "event", "type", "." ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adapter/CallbackEventAdapter.php#L31-L40
train
checkout/checkout-magento2-plugin
Model/Adminhtml/Source/PaymentCurrency.php
PaymentCurrency.getPaymentCurrencyOptions
public function getPaymentCurrencyOptions() { // Create the base options $options = [ [ 'value' => self::BASE_CURRENCY, 'label' => __('Use Magento default') ], [ 'value' => self::ORDER_CURRENCY, 'label' => __('Order currency') ], [ 'value' => self::CUSTOM_CURRENCY, 'label' => __('Custom currency') ], ]; // Return the options as array return $options; }
php
public function getPaymentCurrencyOptions() { // Create the base options $options = [ [ 'value' => self::BASE_CURRENCY, 'label' => __('Use Magento default') ], [ 'value' => self::ORDER_CURRENCY, 'label' => __('Order currency') ], [ 'value' => self::CUSTOM_CURRENCY, 'label' => __('Custom currency') ], ]; // Return the options as array return $options; }
[ "public", "function", "getPaymentCurrencyOptions", "(", ")", "{", "// Create the base options", "$", "options", "=", "[", "[", "'value'", "=>", "self", "::", "BASE_CURRENCY", ",", "'label'", "=>", "__", "(", "'Use Magento default'", ")", "]", ",", "[", "'value'"...
Get the payment currency options @return array
[ "Get", "the", "payment", "currency", "options" ]
4017a44d9f3328742a5d7731b1421574681ec817
https://github.com/checkout/checkout-magento2-plugin/blob/4017a44d9f3328742a5d7731b1421574681ec817/Model/Adminhtml/Source/PaymentCurrency.php#L35-L55
train
kaystrobach/TYPO3.dyncss
Classes/Parser/AbstractParser.php
AbstractParser._postCompile
public function _postCompile($string) { /** * $relativePath seems to be unused? * * @todo missing declaration of inputFilename */ $relativePath = dirname(substr($this->inputFilename, strlen(PATH_site))).'/'; /* * find all matches of url() and adjust uris */ preg_match_all('|url[\s]*\([\s]*(?<url>[^\)]*)[\s]*\)[\s]*|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { // Don't modify inline SVGs if (strpos($value['url'], 'data:image') === false) { $url = trim($value[0], '\'"'); $orgPath = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($orgPath); $string = str_replace($url, 'url("' . $newPath . '")', $string); } } } /* * find all matches of src= and adjust uris */ preg_match_all('|src=([\'"])(?<url>[^\'"]*)\1|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { $url = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($url); $string = str_replace($url, $newPath, $string); } } return $string; }
php
public function _postCompile($string) { /** * $relativePath seems to be unused? * * @todo missing declaration of inputFilename */ $relativePath = dirname(substr($this->inputFilename, strlen(PATH_site))).'/'; /* * find all matches of url() and adjust uris */ preg_match_all('|url[\s]*\([\s]*(?<url>[^\)]*)[\s]*\)[\s]*|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { // Don't modify inline SVGs if (strpos($value['url'], 'data:image') === false) { $url = trim($value[0], '\'"'); $orgPath = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($orgPath); $string = str_replace($url, 'url("' . $newPath . '")', $string); } } } /* * find all matches of src= and adjust uris */ preg_match_all('|src=([\'"])(?<url>[^\'"]*)\1|Ui', $string, $matches, PREG_SET_ORDER); if (is_array($matches) && count($matches)) { foreach ($matches as $key => $value) { $url = trim($value['url'], '\'"'); $newPath = $this->resolveUrlInCss($url); $string = str_replace($url, $newPath, $string); } } return $string; }
[ "public", "function", "_postCompile", "(", "$", "string", ")", "{", "/**\n * $relativePath seems to be unused?\n *\n * @todo missing declaration of inputFilename\n */", "$", "relativePath", "=", "dirname", "(", "substr", "(", "$", "this", "->", "...
Fixes pathes to compliant with original location of the file. @param $string @return mixed @todo add typehinting
[ "Fixes", "pathes", "to", "compliant", "with", "original", "location", "of", "the", "file", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Parser/AbstractParser.php#L145-L185
train
kaystrobach/TYPO3.dyncss
Classes/Parser/AbstractParser.php
AbstractParser.resolveUrlInCss
public function resolveUrlInCss($url) { if (substr($url, 0, 2) === '//') { // double slashed indicate a fully fledged url like //typo3.org return $url; } if (strpos($url, '://') !== false) { // http://, ftp:// etc. should not be touched return $url; } if (substr($url, 0, 1) === '/') { if (substr($url, 0, strlen(PATH_site)) === PATH_site) { return '../../'.substr($url, strlen(PATH_site)); } return $url; } if (substr($url, 0, 5) === 'data:') { // data:image/svg+xml;base64,... should not be touched return $url; } // anything inside TYPO3 has to be adjusted return '../../../../'.dirname($this->removePrefixFromString(PATH_site, $this->inputFilename)).'/'.$url; }
php
public function resolveUrlInCss($url) { if (substr($url, 0, 2) === '//') { // double slashed indicate a fully fledged url like //typo3.org return $url; } if (strpos($url, '://') !== false) { // http://, ftp:// etc. should not be touched return $url; } if (substr($url, 0, 1) === '/') { if (substr($url, 0, strlen(PATH_site)) === PATH_site) { return '../../'.substr($url, strlen(PATH_site)); } return $url; } if (substr($url, 0, 5) === 'data:') { // data:image/svg+xml;base64,... should not be touched return $url; } // anything inside TYPO3 has to be adjusted return '../../../../'.dirname($this->removePrefixFromString(PATH_site, $this->inputFilename)).'/'.$url; }
[ "public", "function", "resolveUrlInCss", "(", "$", "url", ")", "{", "if", "(", "substr", "(", "$", "url", ",", "0", ",", "2", ")", "===", "'//'", ")", "{", "// double slashed indicate a fully fledged url like //typo3.org", "return", "$", "url", ";", "}", "if...
fixes URLs for use in CSS files. @param $url @return string @todo add typehinting
[ "fixes", "URLs", "for", "use", "in", "CSS", "files", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Parser/AbstractParser.php#L196-L219
train
kaystrobach/TYPO3.dyncss
Classes/Parser/AbstractParser.php
AbstractParser.removePrefixFromString
public function removePrefixFromString($prefix, $string) { if (GeneralUtility::isFirstPartOfStr($string, $prefix)) { return substr($string, strlen($prefix)); } else { return $string; } }
php
public function removePrefixFromString($prefix, $string) { if (GeneralUtility::isFirstPartOfStr($string, $prefix)) { return substr($string, strlen($prefix)); } else { return $string; } }
[ "public", "function", "removePrefixFromString", "(", "$", "prefix", ",", "$", "string", ")", "{", "if", "(", "GeneralUtility", "::", "isFirstPartOfStr", "(", "$", "string", ",", "$", "prefix", ")", ")", "{", "return", "substr", "(", "$", "string", ",", "...
removes a prefix from a string. @param $prefix @param $string @return string @todo add typehinting
[ "removes", "a", "prefix", "from", "a", "string", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Parser/AbstractParser.php#L231-L238
train
kaystrobach/TYPO3.dyncss
Classes/Service/DyncssService.php
DyncssService.fixPathForInput
protected static function fixPathForInput($file) { if (empty($file)) { throw new \InvalidArgumentException('fixPathForInput needs a valid $file, the given value was empty'); } if (TYPO3_MODE === 'FE') { return GeneralUtility::getFileAbsFileName($file); } if (TYPO3_MODE === 'BE' && !self::isCliRequest()) { return GeneralUtility::resolveBackPath(PATH_typo3 . $file); } return $file; }
php
protected static function fixPathForInput($file) { if (empty($file)) { throw new \InvalidArgumentException('fixPathForInput needs a valid $file, the given value was empty'); } if (TYPO3_MODE === 'FE') { return GeneralUtility::getFileAbsFileName($file); } if (TYPO3_MODE === 'BE' && !self::isCliRequest()) { return GeneralUtility::resolveBackPath(PATH_typo3 . $file); } return $file; }
[ "protected", "static", "function", "fixPathForInput", "(", "$", "file", ")", "{", "if", "(", "empty", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'fixPathForInput needs a valid $file, the given value was empty'", ")", ";"...
Just makes path absolute. @param $file @return string @todo add typehinting
[ "Just", "makes", "path", "absolute", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Service/DyncssService.php#L43-L55
train
kaystrobach/TYPO3.dyncss
Classes/Service/DyncssService.php
DyncssService.fixPathForOutput
protected static function fixPathForOutput($file) { if (TYPO3_MODE === 'FE') { $file = str_replace(PATH_site, '', $file); } elseif (TYPO3_MODE === 'BE') { $file = str_replace(PATH_site, '../', $file); if (array_key_exists('BACK_PATH', $GLOBALS)) { $file = $GLOBALS['BACK_PATH'].$file; } } return $file; }
php
protected static function fixPathForOutput($file) { if (TYPO3_MODE === 'FE') { $file = str_replace(PATH_site, '', $file); } elseif (TYPO3_MODE === 'BE') { $file = str_replace(PATH_site, '../', $file); if (array_key_exists('BACK_PATH', $GLOBALS)) { $file = $GLOBALS['BACK_PATH'].$file; } } return $file; }
[ "protected", "static", "function", "fixPathForOutput", "(", "$", "file", ")", "{", "if", "(", "TYPO3_MODE", "===", "'FE'", ")", "{", "$", "file", "=", "str_replace", "(", "PATH_site", ",", "''", ",", "$", "file", ")", ";", "}", "elseif", "(", "TYPO3_MO...
Fixes the path for fe or be usage. @param $file @return mixed @todo add typehinting
[ "Fixes", "the", "path", "for", "fe", "or", "be", "usage", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Service/DyncssService.php#L74-L86
train
kaystrobach/TYPO3.dyncss
Classes/Hooks/T3libPageRendererRenderPreProcessHook.php
T3libPageRendererRenderPreProcessHook.execute
public function execute(&$params, &$pagerenderer) { if (!is_array($params['cssFiles'])) { return; } $cssFilesArray = []; foreach ($params['cssFiles'] as $cssFile => $cssFileSettings) { $compiledFile = \KayStrobach\Dyncss\Service\DyncssService::getCompiledFile($cssFile); if ($compiledFile !== $cssFile) { $cssFileSettings['file'] = $compiledFile; //needed for TYPO3 4.6+ ;) $cssFileSettings['compress'] = 0; $cssFilesArray[$compiledFile] = $cssFileSettings; } else { $cssFilesArray[$cssFile] = $cssFileSettings; } } $params['cssFiles'] = $cssFilesArray; }
php
public function execute(&$params, &$pagerenderer) { if (!is_array($params['cssFiles'])) { return; } $cssFilesArray = []; foreach ($params['cssFiles'] as $cssFile => $cssFileSettings) { $compiledFile = \KayStrobach\Dyncss\Service\DyncssService::getCompiledFile($cssFile); if ($compiledFile !== $cssFile) { $cssFileSettings['file'] = $compiledFile; //needed for TYPO3 4.6+ ;) $cssFileSettings['compress'] = 0; $cssFilesArray[$compiledFile] = $cssFileSettings; } else { $cssFilesArray[$cssFile] = $cssFileSettings; } } $params['cssFiles'] = $cssFilesArray; }
[ "public", "function", "execute", "(", "&", "$", "params", ",", "&", "$", "pagerenderer", ")", "{", "if", "(", "!", "is_array", "(", "$", "params", "[", "'cssFiles'", "]", ")", ")", "{", "return", ";", "}", "$", "cssFilesArray", "=", "[", "]", ";", ...
This function iterates over the arrays and rebuild them to keep the order, as keynames may change. @param array $params @param \TYPO3\CMS\Core\Page\PageRenderer $pagerenderer
[ "This", "function", "iterates", "over", "the", "arrays", "and", "rebuild", "them", "to", "keep", "the", "order", "as", "keynames", "may", "change", "." ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Hooks/T3libPageRendererRenderPreProcessHook.php#L40-L57
train
kaystrobach/TYPO3.dyncss
Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php
ClearCacheActionsHook.manipulateCacheActions
public function manipulateCacheActions(&$cacheActions, &$optionValues) { if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->getBackendUser()->isAdmin()) ) { $hrefParams = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1]; /** @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class); $translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.'; if (version_compare(TYPO3_version, '8.7', '<')) { $cacheActions[] = [ 'id' => 'dyncss', 'title' => LocalizationUtility::translate($translationPrefix . 'title', 'Dyncss'), 'description' => LocalizationUtility::translate($translationPrefix . 'description', 'Dyncss'), 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'icon' => $iconFactory->getIcon('actions-system-cache-clear-dyncss', Icon::SIZE_SMALL)->render() ]; } else { $cacheActions[] = [ 'id' => 'dyncss', 'title' => $translationPrefix . 'title', 'description' => $translationPrefix . 'description', 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'iconIdentifier' => 'actions-system-cache-clear-dyncss' ]; } $optionValues[] = 'dyncss'; } }
php
public function manipulateCacheActions(&$cacheActions, &$optionValues) { if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $this->getBackendUser()->isAdmin()) ) { $hrefParams = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1]; /** @var \TYPO3\CMS\Core\Imaging\IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconFactory::class); $translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.'; if (version_compare(TYPO3_version, '8.7', '<')) { $cacheActions[] = [ 'id' => 'dyncss', 'title' => LocalizationUtility::translate($translationPrefix . 'title', 'Dyncss'), 'description' => LocalizationUtility::translate($translationPrefix . 'description', 'Dyncss'), 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'icon' => $iconFactory->getIcon('actions-system-cache-clear-dyncss', Icon::SIZE_SMALL)->render() ]; } else { $cacheActions[] = [ 'id' => 'dyncss', 'title' => $translationPrefix . 'title', 'description' => $translationPrefix . 'description', 'href' => BackendUtility::getModuleUrl('tce_db', $hrefParams), 'iconIdentifier' => 'actions-system-cache-clear-dyncss' ]; } $optionValues[] = 'dyncss'; } }
[ "public", "function", "manipulateCacheActions", "(", "&", "$", "cacheActions", ",", "&", "$", "optionValues", ")", "{", "if", "(", "$", "this", "->", "getBackendUser", "(", ")", "->", "getTSConfigVal", "(", "'options.clearCache.system'", ")", "||", "GeneralUtili...
Modifies CacheMenuItems array @param array $cacheActions Array of CacheMenuItems @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier) @return void
[ "Modifies", "CacheMenuItems", "array" ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php#L27-L56
train
kaystrobach/TYPO3.dyncss
Classes/ExtMgm/Statefield.php
Statefield.main
public function main() { $buffer = ''; $registry = GeneralUtility::makeInstance('KayStrobach\Dyncss\Configuration\BeRegistry'); $handlers = $registry->getAllFileHandler(); if (count($handlers)) { foreach ($handlers as $extension => $class) { /** @var AbstractParser $parser */ $parser = new $class(); $buffer .= '<tr><td>*.'.$extension.'</td>'; $buffer .= '<td>'.$class.'</td>'; $buffer .= '<td><a href="'.$parser->getParserHomepage().'" target="_blank">'.$parser->getParserName().'</a></td>'; $buffer .= '<td>'.$parser->getVersion().'</td>'; $buffer .= '</tr>'; } /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Congrats, you have '.count($handlers).' handlers registered.', '', FlashMessage::OK, true ); $this->addFlashMessage($flashMessage); $buffer = '<table class="t3-table table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>'; } else { /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Please install one of the dyncss_* extensions', 'No handler registered! - No dynamic css is handled at all ;/', FlashMessage::WARNING, true ); $this->addFlashMessage($flashMessage); return $this->renderFlashMessage(); } $renderedFlashMessages = $this->renderFlashMessage(); return $renderedFlashMessages . $buffer; }
php
public function main() { $buffer = ''; $registry = GeneralUtility::makeInstance('KayStrobach\Dyncss\Configuration\BeRegistry'); $handlers = $registry->getAllFileHandler(); if (count($handlers)) { foreach ($handlers as $extension => $class) { /** @var AbstractParser $parser */ $parser = new $class(); $buffer .= '<tr><td>*.'.$extension.'</td>'; $buffer .= '<td>'.$class.'</td>'; $buffer .= '<td><a href="'.$parser->getParserHomepage().'" target="_blank">'.$parser->getParserName().'</a></td>'; $buffer .= '<td>'.$parser->getVersion().'</td>'; $buffer .= '</tr>'; } /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Congrats, you have '.count($handlers).' handlers registered.', '', FlashMessage::OK, true ); $this->addFlashMessage($flashMessage); $buffer = '<table class="t3-table table"><thead><tr><th>extension</th><th>class</th><th>name</th><th>version</th></tr></thead>'.$buffer.'</table>'; } else { /** @var FlashMessage $flashMessage */ $flashMessage = GeneralUtility::makeInstance( FlashMessage::class, 'Please install one of the dyncss_* extensions', 'No handler registered! - No dynamic css is handled at all ;/', FlashMessage::WARNING, true ); $this->addFlashMessage($flashMessage); return $this->renderFlashMessage(); } $renderedFlashMessages = $this->renderFlashMessage(); return $renderedFlashMessages . $buffer; }
[ "public", "function", "main", "(", ")", "{", "$", "buffer", "=", "''", ";", "$", "registry", "=", "GeneralUtility", "::", "makeInstance", "(", "'KayStrobach\\Dyncss\\Configuration\\BeRegistry'", ")", ";", "$", "handlers", "=", "$", "registry", "->", "getAllFileH...
Render state field
[ "Render", "state", "field" ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/ExtMgm/Statefield.php#L25-L64
train
kaystrobach/TYPO3.dyncss
Classes/ExtMgm/Statefield.php
Statefield.addFlashMessage
protected function addFlashMessage(FlashMessage $flashMessage) { if (!($this->flashMessageService instanceof FlashMessageService)) { $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); } /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); }
php
protected function addFlashMessage(FlashMessage $flashMessage) { if (!($this->flashMessageService instanceof FlashMessageService)) { $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); } /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ $defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier(); $defaultFlashMessageQueue->enqueue($flashMessage); }
[ "protected", "function", "addFlashMessage", "(", "FlashMessage", "$", "flashMessage", ")", "{", "if", "(", "!", "(", "$", "this", "->", "flashMessageService", "instanceof", "FlashMessageService", ")", ")", "{", "$", "this", "->", "flashMessageService", "=", "Gen...
Add flash message to message queue @param FlashMessage $flashMessage @return void
[ "Add", "flash", "message", "to", "message", "queue" ]
9f2bd68923c3656611d993c7528bfb18ab3196fa
https://github.com/kaystrobach/TYPO3.dyncss/blob/9f2bd68923c3656611d993c7528bfb18ab3196fa/Classes/ExtMgm/Statefield.php#L72-L80
train
phly/http
src/Server.php
Server.listen
public function listen(callable $finalHandler = null) { $callback = $this->callback; ob_start(); $bufferLevel = ob_get_level(); $response = $callback($this->request, $this->response, $finalHandler); if (! $response instanceof ResponseInterface) { $response = $this->response; } $this->getEmitter()->emit($response, $bufferLevel); }
php
public function listen(callable $finalHandler = null) { $callback = $this->callback; ob_start(); $bufferLevel = ob_get_level(); $response = $callback($this->request, $this->response, $finalHandler); if (! $response instanceof ResponseInterface) { $response = $this->response; } $this->getEmitter()->emit($response, $bufferLevel); }
[ "public", "function", "listen", "(", "callable", "$", "finalHandler", "=", "null", ")", "{", "$", "callback", "=", "$", "this", "->", "callback", ";", "ob_start", "(", ")", ";", "$", "bufferLevel", "=", "ob_get_level", "(", ")", ";", "$", "response", "...
"Listen" to an incoming request If provided a $finalHandler, that callable will be used for incomplete requests. Output buffering is enabled prior to invoking the attached callback; any output buffered will be sent prior to any response body content. @param null|callable $finalHandler
[ "Listen", "to", "an", "incoming", "request" ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Server.php#L151-L163
train
phly/http
src/RequestTrait.php
RequestTrait.initialize
private function initialize($uri = null, $method = null, $body = 'php://memory', array $headers = []) { if (! $uri instanceof UriInterface && ! is_string($uri) && null !== $uri) { throw new InvalidArgumentException( 'Invalid URI provided; must be null, a string, or a Psr\Http\Message\UriInterface instance' ); } $this->validateMethod($method); if (! is_string($body) && ! is_resource($body) && ! $body instanceof StreamInterface) { throw new InvalidArgumentException( 'Body must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (is_string($uri)) { $uri = new Uri($uri); } $this->method = $method; $this->uri = $uri; $this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'r'); list($this->headerNames, $headers) = $this->filterHeaders($headers); $this->assertHeaders($headers); $this->headers = $headers; }
php
private function initialize($uri = null, $method = null, $body = 'php://memory', array $headers = []) { if (! $uri instanceof UriInterface && ! is_string($uri) && null !== $uri) { throw new InvalidArgumentException( 'Invalid URI provided; must be null, a string, or a Psr\Http\Message\UriInterface instance' ); } $this->validateMethod($method); if (! is_string($body) && ! is_resource($body) && ! $body instanceof StreamInterface) { throw new InvalidArgumentException( 'Body must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (is_string($uri)) { $uri = new Uri($uri); } $this->method = $method; $this->uri = $uri; $this->stream = ($body instanceof StreamInterface) ? $body : new Stream($body, 'r'); list($this->headerNames, $headers) = $this->filterHeaders($headers); $this->assertHeaders($headers); $this->headers = $headers; }
[ "private", "function", "initialize", "(", "$", "uri", "=", "null", ",", "$", "method", "=", "null", ",", "$", "body", "=", "'php://memory'", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "!", "$", "uri", "instanceof", "UriInterfac...
Initialize request state. Used by constructors. @param null|string $uri URI for the request, if any. @param null|string $method HTTP method for the request, if any. @param string|resource|StreamInterface $body Message body, if any. @param array $headers Headers for the message, if any. @throws InvalidArgumentException for any invalid value.
[ "Initialize", "request", "state", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/RequestTrait.php#L66-L95
train
phly/http
src/RequestTrait.php
RequestTrait.assertHeaders
private function assertHeaders(array $headers) { foreach ($headers as $name => $headerValues) { HeaderSecurity::assertValidName($name); array_walk($headerValues, __NAMESPACE__ . '\HeaderSecurity::assertValid'); } }
php
private function assertHeaders(array $headers) { foreach ($headers as $name => $headerValues) { HeaderSecurity::assertValidName($name); array_walk($headerValues, __NAMESPACE__ . '\HeaderSecurity::assertValid'); } }
[ "private", "function", "assertHeaders", "(", "array", "$", "headers", ")", "{", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "headerValues", ")", "{", "HeaderSecurity", "::", "assertValidName", "(", "$", "name", ")", ";", "array_walk", "("...
Ensure header names and values are valid. @param array $headers @throws InvalidArgumentException
[ "Ensure", "header", "names", "and", "values", "are", "valid", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/RequestTrait.php#L309-L315
train
phly/http
src/AbstractSerializer.php
AbstractSerializer.getLine
protected static function getLine(StreamInterface $stream) { $line = ''; $crFound = false; while (! $stream->eof()) { $char = $stream->read(1); if ($crFound && $char === self::LF) { $crFound = false; break; } // CR NOT followed by LF if ($crFound && $char !== self::LF) { throw new UnexpectedValueException('Unexpected carriage return detected'); } // LF in isolation if (! $crFound && $char === self::LF) { throw new UnexpectedValueException('Unexpected line feed detected'); } // CR found; do not append if ($char === self::CR) { $crFound = true; continue; } // Any other character: append $line .= $char; } // CR found at end of stream if ($crFound) { throw new UnexpectedValueException("Unexpected end of headers"); } return $line; }
php
protected static function getLine(StreamInterface $stream) { $line = ''; $crFound = false; while (! $stream->eof()) { $char = $stream->read(1); if ($crFound && $char === self::LF) { $crFound = false; break; } // CR NOT followed by LF if ($crFound && $char !== self::LF) { throw new UnexpectedValueException('Unexpected carriage return detected'); } // LF in isolation if (! $crFound && $char === self::LF) { throw new UnexpectedValueException('Unexpected line feed detected'); } // CR found; do not append if ($char === self::CR) { $crFound = true; continue; } // Any other character: append $line .= $char; } // CR found at end of stream if ($crFound) { throw new UnexpectedValueException("Unexpected end of headers"); } return $line; }
[ "protected", "static", "function", "getLine", "(", "StreamInterface", "$", "stream", ")", "{", "$", "line", "=", "''", ";", "$", "crFound", "=", "false", ";", "while", "(", "!", "$", "stream", "->", "eof", "(", ")", ")", "{", "$", "char", "=", "$",...
Retrieve a single line from the stream. Retrieves a line from the stream; a line is defined as a sequence of characters ending in a CRLF sequence. @param StreamInterface $stream @return string @throws UnexpectedValueException if the sequence contains a CR or LF in isolation, or ends in a CR.
[ "Retrieve", "a", "single", "line", "from", "the", "stream", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/AbstractSerializer.php#L29-L67
train
phly/http
src/AbstractSerializer.php
AbstractSerializer.splitStream
protected static function splitStream(StreamInterface $stream) { $headers = []; $currentHeader = false; while ($line = self::getLine($stream)) { if (preg_match(';^(?P<name>[!#$%&\'*+.^_`\|~0-9a-zA-Z-]+):(?P<value>.*)$;', $line, $matches)) { $currentHeader = $matches['name']; if (! isset($headers[$currentHeader])) { $headers[$currentHeader] = []; } $headers[$currentHeader][] = ltrim($matches['value']); continue; } if (! $currentHeader) { throw new UnexpectedValueException('Invalid header detected'); } if (! preg_match('#^[ \t]#', $line)) { throw new UnexpectedValueException('Invalid header continuation'); } // Append continuation to last header value found $value = array_pop($headers[$currentHeader]); $headers[$currentHeader][] = $value . ltrim($line); } $body = new Stream('php://temp', 'wb+'); if (! $stream->eof()) { while ($data = $stream->read(4096)) { $body->write($data); } $body->rewind(); } return [$headers, $body]; }
php
protected static function splitStream(StreamInterface $stream) { $headers = []; $currentHeader = false; while ($line = self::getLine($stream)) { if (preg_match(';^(?P<name>[!#$%&\'*+.^_`\|~0-9a-zA-Z-]+):(?P<value>.*)$;', $line, $matches)) { $currentHeader = $matches['name']; if (! isset($headers[$currentHeader])) { $headers[$currentHeader] = []; } $headers[$currentHeader][] = ltrim($matches['value']); continue; } if (! $currentHeader) { throw new UnexpectedValueException('Invalid header detected'); } if (! preg_match('#^[ \t]#', $line)) { throw new UnexpectedValueException('Invalid header continuation'); } // Append continuation to last header value found $value = array_pop($headers[$currentHeader]); $headers[$currentHeader][] = $value . ltrim($line); } $body = new Stream('php://temp', 'wb+'); if (! $stream->eof()) { while ($data = $stream->read(4096)) { $body->write($data); } $body->rewind(); } return [$headers, $body]; }
[ "protected", "static", "function", "splitStream", "(", "StreamInterface", "$", "stream", ")", "{", "$", "headers", "=", "[", "]", ";", "$", "currentHeader", "=", "false", ";", "while", "(", "$", "line", "=", "self", "::", "getLine", "(", "$", "stream", ...
Split the stream into headers and body content. Returns an array containing two elements - The first is an array of headers - The second is a StreamInterface containing the body content @param StreamInterface $stream @return array @throws UnexpectedValueException For invalid headers.
[ "Split", "the", "stream", "into", "headers", "and", "body", "content", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/AbstractSerializer.php#L81-L118
train
phly/http
src/AbstractSerializer.php
AbstractSerializer.serializeHeaders
protected static function serializeHeaders(array $headers) { $lines = []; foreach ($headers as $header => $values) { $normalized = self::filterHeader($header); foreach ($values as $value) { $lines[] = sprintf('%s: %s', $normalized, $value); } } return implode("\r\n", $lines); }
php
protected static function serializeHeaders(array $headers) { $lines = []; foreach ($headers as $header => $values) { $normalized = self::filterHeader($header); foreach ($values as $value) { $lines[] = sprintf('%s: %s', $normalized, $value); } } return implode("\r\n", $lines); }
[ "protected", "static", "function", "serializeHeaders", "(", "array", "$", "headers", ")", "{", "$", "lines", "=", "[", "]", ";", "foreach", "(", "$", "headers", "as", "$", "header", "=>", "$", "values", ")", "{", "$", "normalized", "=", "self", "::", ...
Serialize headers to string values. @param array $headers @return string
[ "Serialize", "headers", "to", "string", "values", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/AbstractSerializer.php#L126-L137
train
phly/http
src/Request/Serializer.php
Serializer.fromString
public static function fromString($message) { $stream = new Stream('php://temp', 'wb+'); $stream->write($message); return self::fromStream($stream); }
php
public static function fromString($message) { $stream = new Stream('php://temp', 'wb+'); $stream->write($message); return self::fromStream($stream); }
[ "public", "static", "function", "fromString", "(", "$", "message", ")", "{", "$", "stream", "=", "new", "Stream", "(", "'php://temp'", ",", "'wb+'", ")", ";", "$", "stream", "->", "write", "(", "$", "message", ")", ";", "return", "self", "::", "fromStr...
Deserialize a request string to a request instance. Internally, casts the message to a stream and invokes fromStream(). @param string $message @return Request @throws UnexpectedValueException when errors occur parsing the message.
[ "Deserialize", "a", "request", "string", "to", "a", "request", "instance", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L31-L36
train
phly/http
src/Request/Serializer.php
Serializer.fromStream
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($method, $requestTarget, $version) = self::getRequestLine($stream); $uri = self::createUriFromRequestTarget($requestTarget); list($headers, $body) = self::splitStream($stream); return (new Request($uri, $method, $body, $headers)) ->withProtocolVersion($version) ->withRequestTarget($requestTarget); }
php
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($method, $requestTarget, $version) = self::getRequestLine($stream); $uri = self::createUriFromRequestTarget($requestTarget); list($headers, $body) = self::splitStream($stream); return (new Request($uri, $method, $body, $headers)) ->withProtocolVersion($version) ->withRequestTarget($requestTarget); }
[ "public", "static", "function", "fromStream", "(", "StreamInterface", "$", "stream", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", "||", "!", "$", "stream", "->", "isSeekable", "(", ")", ")", "{", "throw", "new", "InvalidArgument...
Deserialize a request stream to a request instance. @param StreamInterface $stream @return Request @throws UnexpectedValueException when errors occur parsing the message.
[ "Deserialize", "a", "request", "stream", "to", "a", "request", "instance", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L45-L61
train
phly/http
src/Request/Serializer.php
Serializer.getRequestLine
private static function getRequestLine(StreamInterface $stream) { $requestLine = self::getLine($stream); if (! preg_match( '#^(?P<method>[!\#$%&\'*+.^_`|~a-zA-Z0-9-]+) (?P<target>[^\s]+) HTTP/(?P<version>[1-9]\d*\.\d+)$#', $requestLine, $matches )) { throw new UnexpectedValueException('Invalid request line detected'); } return [$matches['method'], $matches['target'], $matches['version']]; }
php
private static function getRequestLine(StreamInterface $stream) { $requestLine = self::getLine($stream); if (! preg_match( '#^(?P<method>[!\#$%&\'*+.^_`|~a-zA-Z0-9-]+) (?P<target>[^\s]+) HTTP/(?P<version>[1-9]\d*\.\d+)$#', $requestLine, $matches )) { throw new UnexpectedValueException('Invalid request line detected'); } return [$matches['method'], $matches['target'], $matches['version']]; }
[ "private", "static", "function", "getRequestLine", "(", "StreamInterface", "$", "stream", ")", "{", "$", "requestLine", "=", "self", "::", "getLine", "(", "$", "stream", ")", ";", "if", "(", "!", "preg_match", "(", "'#^(?P<method>[!\\#$%&\\'*+.^_`|~a-zA-Z0-9-]+) (...
Retrieve the components of the request line. Retrieves the first line of the stream and parses it, raising an exception if it does not follow specifications; if valid, returns a list with the method, target, and version, in that order. @param StreamInterface $stream @return array
[ "Retrieve", "the", "components", "of", "the", "request", "line", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L102-L115
train
phly/http
src/Request/Serializer.php
Serializer.createUriFromRequestTarget
private static function createUriFromRequestTarget($requestTarget) { if (preg_match('#^https?://#', $requestTarget)) { return new Uri($requestTarget); } if (preg_match('#^(\*|[^/])#', $requestTarget)) { return new Uri(); } return new Uri($requestTarget); }
php
private static function createUriFromRequestTarget($requestTarget) { if (preg_match('#^https?://#', $requestTarget)) { return new Uri($requestTarget); } if (preg_match('#^(\*|[^/])#', $requestTarget)) { return new Uri(); } return new Uri($requestTarget); }
[ "private", "static", "function", "createUriFromRequestTarget", "(", "$", "requestTarget", ")", "{", "if", "(", "preg_match", "(", "'#^https?://#'", ",", "$", "requestTarget", ")", ")", "{", "return", "new", "Uri", "(", "$", "requestTarget", ")", ";", "}", "i...
Create and return a Uri instance based on the provided request target. If the request target is of authority or asterisk form, an empty Uri instance is returned; otherwise, the value is used to create and return a new Uri instance. @param string $requestTarget @return Uri
[ "Create", "and", "return", "a", "Uri", "instance", "based", "on", "the", "provided", "request", "target", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Request/Serializer.php#L127-L138
train
phly/http
src/Response/Serializer.php
Serializer.fromStream
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($version, $status, $reasonPhrase) = self::getStatusLine($stream); list($headers, $body) = self::splitStream($stream); return (new Response($body, $status, $headers)) ->withProtocolVersion($version) ->withStatus($status, $reasonPhrase); }
php
public static function fromStream(StreamInterface $stream) { if (! $stream->isReadable() || ! $stream->isSeekable()) { throw new InvalidArgumentException('Message stream must be both readable and seekable'); } $stream->rewind(); list($version, $status, $reasonPhrase) = self::getStatusLine($stream); list($headers, $body) = self::splitStream($stream); return (new Response($body, $status, $headers)) ->withProtocolVersion($version) ->withStatus($status, $reasonPhrase); }
[ "public", "static", "function", "fromStream", "(", "StreamInterface", "$", "stream", ")", "{", "if", "(", "!", "$", "stream", "->", "isReadable", "(", ")", "||", "!", "$", "stream", "->", "isSeekable", "(", ")", ")", "{", "throw", "new", "InvalidArgument...
Parse a response from a stream. @param StreamInterface $stream @return ResponseInterface @throws InvalidArgumentException when the stream is not readable. @throws UnexpectedValueException when errors occur parsing the message.
[ "Parse", "a", "response", "from", "a", "stream", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Response/Serializer.php#L36-L50
train
phly/http
src/Response/Serializer.php
Serializer.getStatusLine
private static function getStatusLine(StreamInterface $stream) { $line = self::getLine($stream); if (! preg_match( '#^HTTP/(?P<version>[1-9]\d*\.\d) (?P<status>[1-5]\d{2})(\s+(?P<reason>.+))?$#', $line, $matches )) { throw new UnexpectedValueException('No status line detected'); } return [$matches['version'], $matches['status'], isset($matches['reason']) ? $matches['reason'] : '']; }
php
private static function getStatusLine(StreamInterface $stream) { $line = self::getLine($stream); if (! preg_match( '#^HTTP/(?P<version>[1-9]\d*\.\d) (?P<status>[1-5]\d{2})(\s+(?P<reason>.+))?$#', $line, $matches )) { throw new UnexpectedValueException('No status line detected'); } return [$matches['version'], $matches['status'], isset($matches['reason']) ? $matches['reason'] : '']; }
[ "private", "static", "function", "getStatusLine", "(", "StreamInterface", "$", "stream", ")", "{", "$", "line", "=", "self", "::", "getLine", "(", "$", "stream", ")", ";", "if", "(", "!", "preg_match", "(", "'#^HTTP/(?P<version>[1-9]\\d*\\.\\d) (?P<status>[1-5]\\d...
Retrieve the status line for the message. @param StreamInterface $stream @return array Array with three elements: 0 => version, 1 => status, 2 => reason @throws UnexpectedValueException if line is malformed
[ "Retrieve", "the", "status", "line", "for", "the", "message", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Response/Serializer.php#L89-L102
train
phly/http
src/ServerRequest.php
ServerRequest.getStream
private function getStream($stream) { if ($stream === 'php://input') { return new PhpInputStream(); } if (! is_string($stream) && ! is_resource($stream) && ! $stream instanceof StreamInterface) { throw new InvalidArgumentException( 'Stream must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (! $stream instanceof StreamInterface) { return new Stream($stream, 'r'); } return $stream; }
php
private function getStream($stream) { if ($stream === 'php://input') { return new PhpInputStream(); } if (! is_string($stream) && ! is_resource($stream) && ! $stream instanceof StreamInterface) { throw new InvalidArgumentException( 'Stream must be a string stream resource identifier, ' . 'an actual stream resource, ' . 'or a Psr\Http\Message\StreamInterface implementation' ); } if (! $stream instanceof StreamInterface) { return new Stream($stream, 'r'); } return $stream; }
[ "private", "function", "getStream", "(", "$", "stream", ")", "{", "if", "(", "$", "stream", "===", "'php://input'", ")", "{", "return", "new", "PhpInputStream", "(", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "stream", ")", "&&", "!", "is_...
Set the body stream @param string|resource|StreamInterface $stream @return void
[ "Set", "the", "body", "stream" ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/ServerRequest.php#L249-L268
train
phly/http
src/MessageTrait.php
MessageTrait.getHeaderLine
public function getHeaderLine($header) { $value = $this->getHeader($header); if (empty($value)) { return null; } return implode(',', $value); }
php
public function getHeaderLine($header) { $value = $this->getHeader($header); if (empty($value)) { return null; } return implode(',', $value); }
[ "public", "function", "getHeaderLine", "(", "$", "header", ")", "{", "$", "value", "=", "$", "this", "->", "getHeader", "(", "$", "header", ")", ";", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "return", "implo...
Retrieves the line for a single header, with the header values as a comma-separated string. This method returns all of the header values of the given case-insensitive header name as a string concatenated together using a comma. NOTE: Not all header values may be appropriately represented using comma concatenation. For such headers, use getHeader() instead and supply your own delimiter when concatenating. If the header does not appear in the message, this method MUST return a null value. @param string $name Case-insensitive header field name. @return string|null A string of values as provided for the given header concatenated together using a comma. If the header does not appear in the message, this method MUST return a null value.
[ "Retrieves", "the", "line", "for", "a", "single", "header", "with", "the", "header", "values", "as", "a", "comma", "-", "separated", "string", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/MessageTrait.php#L157-L165
train
phly/http
src/MessageTrait.php
MessageTrait.withHeader
public function withHeader($header, $value) { if (is_string($value)) { $value = [ $value ]; } if (! is_array($value) || ! $this->arrayContainsOnlyStrings($value)) { throw new InvalidArgumentException( 'Invalid header value; must be a string or array of strings' ); } HeaderSecurity::assertValidName($header); self::assertValidHeaderValue($value); $normalized = strtolower($header); $new = clone $this; $new->headerNames[$normalized] = $header; $new->headers[$header] = $value; return $new; }
php
public function withHeader($header, $value) { if (is_string($value)) { $value = [ $value ]; } if (! is_array($value) || ! $this->arrayContainsOnlyStrings($value)) { throw new InvalidArgumentException( 'Invalid header value; must be a string or array of strings' ); } HeaderSecurity::assertValidName($header); self::assertValidHeaderValue($value); $normalized = strtolower($header); $new = clone $this; $new->headerNames[$normalized] = $header; $new->headers[$header] = $value; return $new; }
[ "public", "function", "withHeader", "(", "$", "header", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "value", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "value", "...
Return an instance with the provided header, replacing any existing values of any headers with the same case-insensitive name. While header names are case-insensitive, the casing of the header will be preserved by this function, and returned from getHeaders(). This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new and/or updated header and value. @param string $name Case-insensitive header field name. @param string|string[] $value Header value(s). @return self @throws \InvalidArgumentException for invalid header names or values.
[ "Return", "an", "instance", "with", "the", "provided", "header", "replacing", "any", "existing", "values", "of", "any", "headers", "with", "the", "same", "case", "-", "insensitive", "name", "." ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/MessageTrait.php#L183-L205
train
phly/http
src/Response/SapiEmitter.php
SapiEmitter.filterHeader
private function filterHeader($header) { $filtered = str_replace('-', ' ', $header); $filtered = ucwords($filtered); return str_replace(' ', '-', $filtered); }
php
private function filterHeader($header) { $filtered = str_replace('-', ' ', $header); $filtered = ucwords($filtered); return str_replace(' ', '-', $filtered); }
[ "private", "function", "filterHeader", "(", "$", "header", ")", "{", "$", "filtered", "=", "str_replace", "(", "'-'", ",", "' '", ",", "$", "header", ")", ";", "$", "filtered", "=", "ucwords", "(", "$", "filtered", ")", ";", "return", "str_replace", "(...
Filter a header name to wordcase @param string $header @return string
[ "Filter", "a", "header", "name", "to", "wordcase" ]
2860c9eaef224e348be71c5ca3da42665fd66b7d
https://github.com/phly/http/blob/2860c9eaef224e348be71c5ca3da42665fd66b7d/src/Response/SapiEmitter.php#L101-L106
train
WyriHaximus/TwigView
src/Lib/Twig/Extension/Inflector.php
Inflector.getFilters
public function getFilters(): array { return [ new TwigFilter('pluralize', 'Cake\Utility\Inflector::pluralize'), new TwigFilter('singularize', 'Cake\Utility\Inflector::singularize'), new TwigFilter('camelize', 'Cake\Utility\Inflector::camelize'), new TwigFilter('underscore', 'Cake\Utility\Inflector::underscore'), new TwigFilter('humanize', 'Cake\Utility\Inflector::humanize'), new TwigFilter('tableize', 'Cake\Utility\Inflector::tableize'), new TwigFilter('classify', 'Cake\Utility\Inflector::classify'), new TwigFilter('variable', 'Cake\Utility\Inflector::variable'), new TwigFilter('dasherize', 'Cake\Utility\Inflector::dasherize'), new TwigFilter('slug', 'Cake\Utility\Text::slug'), ]; }
php
public function getFilters(): array { return [ new TwigFilter('pluralize', 'Cake\Utility\Inflector::pluralize'), new TwigFilter('singularize', 'Cake\Utility\Inflector::singularize'), new TwigFilter('camelize', 'Cake\Utility\Inflector::camelize'), new TwigFilter('underscore', 'Cake\Utility\Inflector::underscore'), new TwigFilter('humanize', 'Cake\Utility\Inflector::humanize'), new TwigFilter('tableize', 'Cake\Utility\Inflector::tableize'), new TwigFilter('classify', 'Cake\Utility\Inflector::classify'), new TwigFilter('variable', 'Cake\Utility\Inflector::variable'), new TwigFilter('dasherize', 'Cake\Utility\Inflector::dasherize'), new TwigFilter('slug', 'Cake\Utility\Text::slug'), ]; }
[ "public", "function", "getFilters", "(", ")", ":", "array", "{", "return", "[", "new", "TwigFilter", "(", "'pluralize'", ",", "'Cake\\Utility\\Inflector::pluralize'", ")", ",", "new", "TwigFilter", "(", "'singularize'", ",", "'Cake\\Utility\\Inflector::singularize'", ...
Get filters for this extension. @return \Twig\TwigFunction[]
[ "Get", "filters", "for", "this", "extension", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Extension/Inflector.php#L28-L42
train
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.all
public function all() { $this->out('<info>Compiling all templates</info>'); foreach (Scanner::all() as $section => $templates) { $this->out('<info>Compiling ' . $section . '\'s templates</info>'); $this->walkIterator($templates); } }
php
public function all() { $this->out('<info>Compiling all templates</info>'); foreach (Scanner::all() as $section => $templates) { $this->out('<info>Compiling ' . $section . '\'s templates</info>'); $this->walkIterator($templates); } }
[ "public", "function", "all", "(", ")", "{", "$", "this", "->", "out", "(", "'<info>Compiling all templates</info>'", ")", ";", "foreach", "(", "Scanner", "::", "all", "(", ")", "as", "$", "section", "=>", "$", "templates", ")", "{", "$", "this", "->", ...
Compile all templates.
[ "Compile", "all", "templates", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L61-L69
train
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.plugin
public function plugin($plugin) { $this->out('<info>Compiling one ' . $plugin . '\'s templates</info>'); $this->walkIterator(Scanner::plugin($plugin)); }
php
public function plugin($plugin) { $this->out('<info>Compiling one ' . $plugin . '\'s templates</info>'); $this->walkIterator(Scanner::plugin($plugin)); }
[ "public", "function", "plugin", "(", "$", "plugin", ")", "{", "$", "this", "->", "out", "(", "'<info>Compiling one '", ".", "$", "plugin", ".", "'\\'s templates</info>'", ")", ";", "$", "this", "->", "walkIterator", "(", "Scanner", "::", "plugin", "(", "$"...
Compile only this plugin. @param string $plugin Plugin name.
[ "Compile", "only", "this", "plugin", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L77-L81
train
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.getOptionParser
public function getOptionParser(): ConsoleOptionParser { return parent::getOptionParser()->addSubcommand( 'all', [ 'short' => 'a', 'help' => __('Searches and precompiles all twig templates it finds.'), ] )->addSubcommand( 'plugin', [ 'short' => 'p', 'help' => __('Searches and precompiles all twig templates for a specific plugin.'), ] )->addSubcommand( 'file', [ 'short' => 'f', 'help' => __('Precompile a specific file.'), ] )->setDescription(__('TwigView templates precompiler')); }
php
public function getOptionParser(): ConsoleOptionParser { return parent::getOptionParser()->addSubcommand( 'all', [ 'short' => 'a', 'help' => __('Searches and precompiles all twig templates it finds.'), ] )->addSubcommand( 'plugin', [ 'short' => 'p', 'help' => __('Searches and precompiles all twig templates for a specific plugin.'), ] )->addSubcommand( 'file', [ 'short' => 'f', 'help' => __('Precompile a specific file.'), ] )->setDescription(__('TwigView templates precompiler')); }
[ "public", "function", "getOptionParser", "(", ")", ":", "ConsoleOptionParser", "{", "return", "parent", "::", "getOptionParser", "(", ")", "->", "addSubcommand", "(", "'all'", ",", "[", "'short'", "=>", "'a'", ",", "'help'", "=>", "__", "(", "'Searches and pre...
Set options for this console. @return \Cake\Console\ConsoleOptionParser
[ "Set", "options", "for", "this", "console", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L100-L121
train
WyriHaximus/TwigView
src/Shell/CompileShell.php
CompileShell.compileTemplate
protected function compileTemplate($fileName) { try { $this-> twigView-> getTwig()-> loadTemplate($fileName); $this->out('<success>' . $fileName . '</success>'); } catch (\Exception $exception) { $this->out('<error>' . $fileName . '</error>'); $this->out('<error>' . $exception->getMessage() . '</error>'); } }
php
protected function compileTemplate($fileName) { try { $this-> twigView-> getTwig()-> loadTemplate($fileName); $this->out('<success>' . $fileName . '</success>'); } catch (\Exception $exception) { $this->out('<error>' . $fileName . '</error>'); $this->out('<error>' . $exception->getMessage() . '</error>'); } }
[ "protected", "function", "compileTemplate", "(", "$", "fileName", ")", "{", "try", "{", "$", "this", "->", "twigView", "->", "getTwig", "(", ")", "->", "loadTemplate", "(", "$", "fileName", ")", ";", "$", "this", "->", "out", "(", "'<success>'", ".", "...
Compile a template. @param string $fileName Template to compile.
[ "Compile", "a", "template", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/CompileShell.php#L142-L154
train
WyriHaximus/TwigView
src/Lib/TreeScanner.php
TreeScanner.convertToTree
protected static function convertToTree(array $paths): array { foreach ($paths as $index => $path) { static::convertPathToTree($paths, $index, $path); } return $paths; }
php
protected static function convertToTree(array $paths): array { foreach ($paths as $index => $path) { static::convertPathToTree($paths, $index, $path); } return $paths; }
[ "protected", "static", "function", "convertToTree", "(", "array", "$", "paths", ")", ":", "array", "{", "foreach", "(", "$", "paths", "as", "$", "index", "=>", "$", "path", ")", "{", "static", "::", "convertPathToTree", "(", "$", "paths", ",", "$", "in...
Turn a set of paths into a tree. @param array $paths Paths to turn into a tree. @return array
[ "Turn", "a", "set", "of", "paths", "into", "a", "tree", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/TreeScanner.php#L58-L65
train
WyriHaximus/TwigView
src/Lib/TreeScanner.php
TreeScanner.convertPathToTree
protected static function convertPathToTree(array &$paths, $index, $path) { if (strpos($path, DIRECTORY_SEPARATOR) !== false) { $chunks = explode(DIRECTORY_SEPARATOR, $path); $paths = static::branch($paths, $chunks); unset($paths[$index]); } }
php
protected static function convertPathToTree(array &$paths, $index, $path) { if (strpos($path, DIRECTORY_SEPARATOR) !== false) { $chunks = explode(DIRECTORY_SEPARATOR, $path); $paths = static::branch($paths, $chunks); unset($paths[$index]); } }
[ "protected", "static", "function", "convertPathToTree", "(", "array", "&", "$", "paths", ",", "$", "index", ",", "$", "path", ")", "{", "if", "(", "strpos", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", "!==", "false", ")", "{", "$", "chunks", "="...
Convert a path into a tree when it contains a directory separator. @param array $paths The paths to work on. @param mixed $index Index of $path. @param string $path Path to breakup and turn into a tree.
[ "Convert", "a", "path", "into", "a", "tree", "when", "it", "contains", "a", "directory", "separator", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/TreeScanner.php#L75-L82
train
WyriHaximus/TwigView
src/Lib/TreeScanner.php
TreeScanner.branch
protected static function branch(array $paths, array $branches): array { $twig = array_shift($branches); if (count($branches) == 0) { $paths[] = $twig; return $paths; } if (!isset($paths[$twig])) { $paths[$twig] = []; } $paths[$twig] = static::branch($paths[$twig], $branches); return $paths; }
php
protected static function branch(array $paths, array $branches): array { $twig = array_shift($branches); if (count($branches) == 0) { $paths[] = $twig; return $paths; } if (!isset($paths[$twig])) { $paths[$twig] = []; } $paths[$twig] = static::branch($paths[$twig], $branches); return $paths; }
[ "protected", "static", "function", "branch", "(", "array", "$", "paths", ",", "array", "$", "branches", ")", ":", "array", "{", "$", "twig", "=", "array_shift", "(", "$", "branches", ")", ";", "if", "(", "count", "(", "$", "branches", ")", "==", "0",...
Create a branch for the current level and push a twig on it. @param array $paths Paths to append. @param array $branches Branches to use untill only one left. @return array
[ "Create", "a", "branch", "for", "the", "current", "level", "and", "push", "a", "twig", "on", "it", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/TreeScanner.php#L92-L108
train
WyriHaximus/TwigView
src/Shell/Task/TwigTemplateTask.php
TwigTemplateTask.bake
public function bake($action, $content = '', $outputFile = null): string { if ($outputFile === null) { $outputFile = $action; } if ($content === true) { $content = $this->getContent($action); } if (empty($content)) { $this->err("<warning>No generated content for '{$action}.php', not generating template.</warning>"); return false; } $this->out("\n" . sprintf('Baking `%s` view twig template file...', $outputFile), 1, Shell::QUIET); $path = $this->getPath(); $filename = $path . Inflector::underscore($outputFile) . '.twig'; $this->createFile($filename, $content); return $content; }
php
public function bake($action, $content = '', $outputFile = null): string { if ($outputFile === null) { $outputFile = $action; } if ($content === true) { $content = $this->getContent($action); } if (empty($content)) { $this->err("<warning>No generated content for '{$action}.php', not generating template.</warning>"); return false; } $this->out("\n" . sprintf('Baking `%s` view twig template file...', $outputFile), 1, Shell::QUIET); $path = $this->getPath(); $filename = $path . Inflector::underscore($outputFile) . '.twig'; $this->createFile($filename, $content); return $content; }
[ "public", "function", "bake", "(", "$", "action", ",", "$", "content", "=", "''", ",", "$", "outputFile", "=", "null", ")", ":", "string", "{", "if", "(", "$", "outputFile", "===", "null", ")", "{", "$", "outputFile", "=", "$", "action", ";", "}", ...
Assembles and writes bakes the twig view file. @param string $action Action to bake. @param string $content Content to write. @param string $outputFile The destination action name. If null, will fallback to $template. @return string Generated file content.
[ "Assembles", "and", "writes", "bakes", "the", "twig", "view", "file", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Shell/Task/TwigTemplateTask.php#L36-L55
train
WyriHaximus/TwigView
src/Lib/Cache.php
Cache.fetch
public function fetch($identifier) { [$config, $key] = $this->configSplit($identifier); return CakeCache::read(static::CACHE_PREFIX . $key, $config); }
php
public function fetch($identifier) { [$config, $key] = $this->configSplit($identifier); return CakeCache::read(static::CACHE_PREFIX . $key, $config); }
[ "public", "function", "fetch", "(", "$", "identifier", ")", "{", "[", "$", "config", ",", "$", "key", "]", "=", "$", "this", "->", "configSplit", "(", "$", "identifier", ")", ";", "return", "CakeCache", "::", "read", "(", "static", "::", "CACHE_PREFIX"...
Retrieve data from the cache. @param string $identifier Identifier for this bit of data to read. @return mixed The cached data, or false if the data doesn't exist, has expired, or on error while fetching.
[ "Retrieve", "data", "from", "the", "cache", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Cache.php#L19-L24
train
WyriHaximus/TwigView
src/Lib/Twig/Node/Cell.php
Cell.compile
public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); if ($this->assign) { $compiler->raw('$context[\'' . $this->getAttribute('variable') . '\'] = '); } else { $compiler->raw('echo '); } $compiler->raw('$context[\'_view\']->cell('); $compiler->subcompile($this->getNode('name')); $data = $this->getNode('data'); if ($data !== null) { $compiler->raw(','); $compiler->subcompile($data); } $options = $this->getNode('options'); if ($options !== null) { $compiler->raw(','); $compiler->subcompile($options); } $compiler->raw(");\n"); }
php
public function compile(Compiler $compiler) { $compiler->addDebugInfo($this); if ($this->assign) { $compiler->raw('$context[\'' . $this->getAttribute('variable') . '\'] = '); } else { $compiler->raw('echo '); } $compiler->raw('$context[\'_view\']->cell('); $compiler->subcompile($this->getNode('name')); $data = $this->getNode('data'); if ($data !== null) { $compiler->raw(','); $compiler->subcompile($data); } $options = $this->getNode('options'); if ($options !== null) { $compiler->raw(','); $compiler->subcompile($options); } $compiler->raw(");\n"); }
[ "public", "function", "compile", "(", "Compiler", "$", "compiler", ")", "{", "$", "compiler", "->", "addDebugInfo", "(", "$", "this", ")", ";", "if", "(", "$", "this", "->", "assign", ")", "{", "$", "compiler", "->", "raw", "(", "'$context[\\''", ".", ...
Compile tag. @param \Twig\Compiler $compiler Compiler.
[ "Compile", "tag", "." ]
65527d6a7828086f7d16c73e95afce11c96a49f2
https://github.com/WyriHaximus/TwigView/blob/65527d6a7828086f7d16c73e95afce11c96a49f2/src/Lib/Twig/Node/Cell.php#L82-L104
train