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
ipunkt/rancherize
app/Push/Modes/RollingUpgrade/RollingUpgradeParser.php
RollingUpgradeParser.isMode
public function isMode( Configuration $configuration ) { if( $this->inServiceChecker->isInService($configuration) ) return false; if( $this->replaceUpgradeChecker->isReplaceUpgrade($configuration) ) return false; return true; }
php
public function isMode( Configuration $configuration ) { if( $this->inServiceChecker->isInService($configuration) ) return false; if( $this->replaceUpgradeChecker->isReplaceUpgrade($configuration) ) return false; return true; }
[ "public", "function", "isMode", "(", "Configuration", "$", "configuration", ")", "{", "if", "(", "$", "this", "->", "inServiceChecker", "->", "isInService", "(", "$", "configuration", ")", ")", "return", "false", ";", "if", "(", "$", "this", "->", "replace...
Returns true if the associate PushMode was selected in the configuration @param Configuration $configuration @return bool
[ "Returns", "true", "if", "the", "associate", "PushMode", "was", "selected", "in", "the", "configuration" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Push/Modes/RollingUpgrade/RollingUpgradeParser.php#L41-L49
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.uninstall
public function uninstall() { // "Disable" (delete) events, regardless the confirmation answer. $this->uninstallEvents(); $this->registry->response->redirect($this->registry->getLink($this->getLocation() . '/confirmUninstall')); }
php
public function uninstall() { // "Disable" (delete) events, regardless the confirmation answer. $this->uninstallEvents(); $this->registry->response->redirect($this->registry->getLink($this->getLocation() . '/confirmUninstall')); }
[ "public", "function", "uninstall", "(", ")", "{", "// \"Disable\" (delete) events, regardless the confirmation answer.", "$", "this", "->", "uninstallEvents", "(", ")", ";", "$", "this", "->", "registry", "->", "response", "->", "redirect", "(", "$", "this", "->", ...
Uninstall function, called when the module is uninstalled by an admin. @throws \Exception
[ "Uninstall", "function", "called", "when", "the", "module", "is", "uninstalled", "by", "an", "admin", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L112-L117
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.confirmUninstall
public function confirmUninstall() { // @todo: implement uninstall form // $this->displayFormCommon('uninstall'); // // // Are we confirming, or should we show the confirm message? // if ($this->registry->request->server['REQUEST_METHOD'] === 'POST') { $this->doUninstall(); $this->registry->response->redirect($this->registry->getLink($this->getRedirectUrl())); // } // // // Add an intermediate level to the breadcrumb. // $this->data['breadcrumbs'][] = array( // 'text' => $this->t('modules'), // 'href' => $this->registry->getLink('extension/module',), // 'separator' => ' :: ' // ); // // $this->renderFormCommon('confirmUninstall', 'button_confirm_uninstall'); }
php
public function confirmUninstall() { // @todo: implement uninstall form // $this->displayFormCommon('uninstall'); // // // Are we confirming, or should we show the confirm message? // if ($this->registry->request->server['REQUEST_METHOD'] === 'POST') { $this->doUninstall(); $this->registry->response->redirect($this->registry->getLink($this->getRedirectUrl())); // } // // // Add an intermediate level to the breadcrumb. // $this->data['breadcrumbs'][] = array( // 'text' => $this->t('modules'), // 'href' => $this->registry->getLink('extension/module',), // 'separator' => ' :: ' // ); // // $this->renderFormCommon('confirmUninstall', 'button_confirm_uninstall'); }
[ "public", "function", "confirmUninstall", "(", ")", "{", "// @todo: implement uninstall form", "// $this->displayFormCommon('uninstall');", "//", "// // Are we confirming, or should we show the confirm message?", "// if ($this->registry->request->server['REQUEST_METHOD'] ===...
Explicit confirmation step to allow to retain the settings. The normal uninstall action will unconditionally delete all settings. @throws \Exception
[ "Explicit", "confirmation", "step", "to", "allow", "to", "retain", "the", "settings", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L183-L202
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.extractOrderId
public function extractOrderId(array $args) { if (is_numeric($args[0])) { // OC 2.0. $order_id = $args[0]; } elseif (is_array($args[1])) { // OC 2.3. $route = $args[0]; $event_args = $args[1]; $output = $args[2]; $order_id = substr($route, -strlen('/addOrder')) === '/addOrder' ? $output : $event_args[0]; } else { // OC 2.2. $order_id = $args[2]; } return $order_id; }
php
public function extractOrderId(array $args) { if (is_numeric($args[0])) { // OC 2.0. $order_id = $args[0]; } elseif (is_array($args[1])) { // OC 2.3. $route = $args[0]; $event_args = $args[1]; $output = $args[2]; $order_id = substr($route, -strlen('/addOrder')) === '/addOrder' ? $output : $event_args[0]; } else { // OC 2.2. $order_id = $args[2]; } return $order_id; }
[ "public", "function", "extractOrderId", "(", "array", "$", "args", ")", "{", "if", "(", "is_numeric", "(", "$", "args", "[", "0", "]", ")", ")", "{", "// OC 2.0.", "$", "order_id", "=", "$", "args", "[", "0", "]", ";", "}", "elseif", "(", "is_array...
Extracts the order id of the parameters as passed to the event handler. Event handling has undergone a lot of changes in OC, so where the order id can be found depends on the version. However we do not check the version itself but the (number and type of the) parameters passed in. Parameters for OC2.0: param int $order_id Parameters for OC 2.2: param string $route param mixed $output param int $order_id param int $order_status_id Parameters for OC 2.3+: param string $route checkout/order/addOrder or checkout/order/addOrderHistory. param array $args Array with numeric indices containing the arguments as passed to the model method. When route = checkout/order/addOrder it contains: order (but without order_id as that will be created and assigned by the method). When route = checkout/order/addOrderHistory it contains: order_id, order_status_id, comment, notify, override. param mixed $output If passed by event checkout/order/addOrder it contains the order_id of the just created order. It is null for checkout/order/addOrderHistory. @param array $args The arguments passed to the event handler. @return int The id of the order that triggered the event.
[ "Extracts", "the", "order", "id", "of", "the", "parameters", "as", "passed", "to", "the", "event", "handler", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L251-L267
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.eventOrderUpdate
public function eventOrderUpdate($order_id) { $source = $this->container->getSource(Source::Order, $order_id); $this->container->getInvoiceManager()->sourceStatusChange($source); }
php
public function eventOrderUpdate($order_id) { $source = $this->container->getSource(Source::Order, $order_id); $this->container->getInvoiceManager()->sourceStatusChange($source); }
[ "public", "function", "eventOrderUpdate", "(", "$", "order_id", ")", "{", "$", "source", "=", "$", "this", "->", "container", "->", "getSource", "(", "Source", "::", "Order", ",", "$", "order_id", ")", ";", "$", "this", "->", "container", "->", "getInvoi...
Event handler that executes on the creation or update of an order. @param int $order_id
[ "Event", "handler", "that", "executes", "on", "the", "creation", "or", "update", "of", "an", "order", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L274-L278
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.eventViewColumnLeft
public function eventViewColumnLeft(&$menus) { foreach ($menus as &$menu) { if ($menu['id'] === 'menu-sale') { $menu['children'][] = array( 'name' => 'Acumulus', 'href' => '', 'children' => array( array( 'name' => $this->t('batch_form_link_text'), 'href' => $this->container->getShopCapabilities()->getLink('batch'), 'children' => array(), ), array( 'name' => $this->t('advanced_form_link_text'), 'href' => $this->container->getShopCapabilities()->getLink('advanced'), 'children' => array(), ), ), ); } } }
php
public function eventViewColumnLeft(&$menus) { foreach ($menus as &$menu) { if ($menu['id'] === 'menu-sale') { $menu['children'][] = array( 'name' => 'Acumulus', 'href' => '', 'children' => array( array( 'name' => $this->t('batch_form_link_text'), 'href' => $this->container->getShopCapabilities()->getLink('batch'), 'children' => array(), ), array( 'name' => $this->t('advanced_form_link_text'), 'href' => $this->container->getShopCapabilities()->getLink('advanced'), 'children' => array(), ), ), ); } } }
[ "public", "function", "eventViewColumnLeft", "(", "&", "$", "menus", ")", "{", "foreach", "(", "$", "menus", "as", "&", "$", "menu", ")", "{", "if", "(", "$", "menu", "[", "'id'", "]", "===", "'menu-sale'", ")", "{", "$", "menu", "[", "'children'", ...
Adds our menu-items to the admin menu. @param array $menus The menus part of the data as will be passed to the view.
[ "Adds", "our", "menu", "-", "items", "to", "the", "admin", "menu", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L286-L308
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.displayFormCommon
protected function displayFormCommon($task) { // This will initialize the form translations. $this->container->getForm($task); $this->registry->document->addStyle('view/stylesheet/acumulus.css'); $this->data['success_messages'] = array(); $this->data['warning_messages'] = array(); $this->data['error_messages'] = array(); // Set the page title. $this->registry->document->setTitle($this->t("{$task}_form_title")); $this->data["page_title"] = $this->t("{$task}_form_title"); $this->data["heading_title"] = $this->t("{$task}_form_header"); $this->data["text_edit"] = $this->t("{$task}_form_header"); // Set up breadcrumb. $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array( 'text' => $this->t('text_home'), 'href' => $this->registry->getLink('common/dashboard'), 'separator' => false ); $this->displayCommonParts(); }
php
protected function displayFormCommon($task) { // This will initialize the form translations. $this->container->getForm($task); $this->registry->document->addStyle('view/stylesheet/acumulus.css'); $this->data['success_messages'] = array(); $this->data['warning_messages'] = array(); $this->data['error_messages'] = array(); // Set the page title. $this->registry->document->setTitle($this->t("{$task}_form_title")); $this->data["page_title"] = $this->t("{$task}_form_title"); $this->data["heading_title"] = $this->t("{$task}_form_header"); $this->data["text_edit"] = $this->t("{$task}_form_header"); // Set up breadcrumb. $this->data['breadcrumbs'] = array(); $this->data['breadcrumbs'][] = array( 'text' => $this->t('text_home'), 'href' => $this->registry->getLink('common/dashboard'), 'separator' => false ); $this->displayCommonParts(); }
[ "protected", "function", "displayFormCommon", "(", "$", "task", ")", "{", "// This will initialize the form translations.", "$", "this", "->", "container", "->", "getForm", "(", "$", "task", ")", ";", "$", "this", "->", "registry", "->", "document", "->", "addSt...
Performs the common tasks when displaying a form. @param string $task
[ "Performs", "the", "common", "tasks", "when", "displaying", "a", "form", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L315-L341
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.renderFormCommon
protected function renderFormCommon($task, $button) { // Process the form if it was submitted and render it again. $form = $this->container->getForm($task); $form->process(); // Force the creation of the fields to get connection error messages // shown. $form->getFields(); // Show messages. foreach ($form->getSuccessMessages() as $message) { $this->addSuccess($message); } foreach ($form->getWarningMessages() as $message) { $this->addWarning($this->t($message)); } foreach ($form->getErrorMessages() as $message) { $this->addError($this->t($message)); } $this->data['form'] = $form; $this->data['formRenderer'] = $this->container->getFormRenderer(); // Complete the breadcrumb with the current path. $link = $this->getLocation(); if ($task !== 'config') { $link .= "/$task"; } $this->data['breadcrumbs'][] = array( 'text' => $this->t("{$task}_form_header"), 'href' => $this->registry->getLink($link), 'separator' => ' :: ' ); // Set the action buttons (action + text). $this->data['action'] = $this->registry->getLink($link); $this->data['button_icon'] = $task === 'batch' ? 'fa-envelope-o' : ($task === 'uninstall' ? 'fa-delete' : 'fa-save'); $this->data['button_save'] = $this->t($button); $this->data['cancel'] = $this->registry->getLink('common/dashboard'); $this->data['button_cancel'] = $task === 'uninstall' ? $this->t('button_cancel_uninstall') : $this->t('button_cancel'); $this->setOutput(); }
php
protected function renderFormCommon($task, $button) { // Process the form if it was submitted and render it again. $form = $this->container->getForm($task); $form->process(); // Force the creation of the fields to get connection error messages // shown. $form->getFields(); // Show messages. foreach ($form->getSuccessMessages() as $message) { $this->addSuccess($message); } foreach ($form->getWarningMessages() as $message) { $this->addWarning($this->t($message)); } foreach ($form->getErrorMessages() as $message) { $this->addError($this->t($message)); } $this->data['form'] = $form; $this->data['formRenderer'] = $this->container->getFormRenderer(); // Complete the breadcrumb with the current path. $link = $this->getLocation(); if ($task !== 'config') { $link .= "/$task"; } $this->data['breadcrumbs'][] = array( 'text' => $this->t("{$task}_form_header"), 'href' => $this->registry->getLink($link), 'separator' => ' :: ' ); // Set the action buttons (action + text). $this->data['action'] = $this->registry->getLink($link); $this->data['button_icon'] = $task === 'batch' ? 'fa-envelope-o' : ($task === 'uninstall' ? 'fa-delete' : 'fa-save'); $this->data['button_save'] = $this->t($button); $this->data['cancel'] = $this->registry->getLink('common/dashboard'); $this->data['button_cancel'] = $task === 'uninstall' ? $this->t('button_cancel_uninstall') : $this->t('button_cancel'); $this->setOutput(); }
[ "protected", "function", "renderFormCommon", "(", "$", "task", ",", "$", "button", ")", "{", "// Process the form if it was submitted and render it again.", "$", "form", "=", "$", "this", "->", "container", "->", "getForm", "(", "$", "task", ")", ";", "$", "form...
Performs the common tasks when processing and rendering a form. @param string $task @param string $button
[ "Performs", "the", "common", "tasks", "when", "processing", "and", "rendering", "a", "form", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L359-L401
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.setOutput
protected function setOutput() { // Send the output. $this->registry->response->setOutput($this->registry->load->view($this->getLocation() . '_form', $this->data)); }
php
protected function setOutput() { // Send the output. $this->registry->response->setOutput($this->registry->load->view($this->getLocation() . '_form', $this->data)); }
[ "protected", "function", "setOutput", "(", ")", "{", "// Send the output.", "$", "this", "->", "registry", "->", "response", "->", "setOutput", "(", "$", "this", "->", "registry", "->", "load", "->", "view", "(", "$", "this", "->", "getLocation", "(", ")",...
Outputs the form.
[ "Outputs", "the", "form", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L406-L410
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.doInstall
protected function doInstall() { $result = true; $this->registry->load->model('setting/setting'); $setting = $this->registry->model_setting_setting->getSetting('acumulus_siel'); $currentDataModelVersion = isset($setting['acumulus_siel_datamodel_version']) ? $setting['acumulus_siel_datamodel_version'] : ''; $this->container->getLog()->info('%s: current version = %s', __METHOD__, $currentDataModelVersion); if ($currentDataModelVersion === '' || version_compare($currentDataModelVersion, '4.0', '<')) { // Check requirements (we assume this has been done successfully // before if the data model is at the latest version). $requirements = $this->container->getRequirements(); $messages = $requirements->check(); foreach ($messages as $message) { $this->addError($message['message']); $this->container->getLog()->error($message['message']); } if (!empty($messages)) { return false; } // Install tables. if ($result = $this->container->getAcumulusEntryManager()->install()) { $setting['acumulus_siel_datamodel_version'] = '4.0'; $this->registry->model_setting_setting->editSetting('acumulus_siel', $setting); } } elseif (version_compare($currentDataModelVersion, '4.4', '<')) { // Update table columns. if ($result = $this->container->getAcumulusEntryManager()->upgrade('4.4.0')) { $setting['acumulus_siel_datamodel_version'] = '4.4'; $this->registry->model_setting_setting->editSetting('acumulus_siel', $setting); } } // Install events if (empty($this->data['error_messages'])) { $this->installEvents(); } return $result; }
php
protected function doInstall() { $result = true; $this->registry->load->model('setting/setting'); $setting = $this->registry->model_setting_setting->getSetting('acumulus_siel'); $currentDataModelVersion = isset($setting['acumulus_siel_datamodel_version']) ? $setting['acumulus_siel_datamodel_version'] : ''; $this->container->getLog()->info('%s: current version = %s', __METHOD__, $currentDataModelVersion); if ($currentDataModelVersion === '' || version_compare($currentDataModelVersion, '4.0', '<')) { // Check requirements (we assume this has been done successfully // before if the data model is at the latest version). $requirements = $this->container->getRequirements(); $messages = $requirements->check(); foreach ($messages as $message) { $this->addError($message['message']); $this->container->getLog()->error($message['message']); } if (!empty($messages)) { return false; } // Install tables. if ($result = $this->container->getAcumulusEntryManager()->install()) { $setting['acumulus_siel_datamodel_version'] = '4.0'; $this->registry->model_setting_setting->editSetting('acumulus_siel', $setting); } } elseif (version_compare($currentDataModelVersion, '4.4', '<')) { // Update table columns. if ($result = $this->container->getAcumulusEntryManager()->upgrade('4.4.0')) { $setting['acumulus_siel_datamodel_version'] = '4.4'; $this->registry->model_setting_setting->editSetting('acumulus_siel', $setting); } } // Install events if (empty($this->data['error_messages'])) { $this->installEvents(); } return $result; }
[ "protected", "function", "doInstall", "(", ")", "{", "$", "result", "=", "true", ";", "$", "this", "->", "registry", "->", "load", "->", "model", "(", "'setting/setting'", ")", ";", "$", "setting", "=", "$", "this", "->", "registry", "->", "model_setting...
Checks requirements and installs tables for this module. @return bool Success. @throws \Exception
[ "Checks", "requirements", "and", "installs", "tables", "for", "this", "module", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L420-L461
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.doUninstall
protected function doUninstall() { $this->container->getAcumulusEntryManager()->uninstall(); // Delete all config values. $this->registry->load->model('setting/setting'); $this->registry->model_setting_setting->deleteSetting('acumulus_siel'); return true; }
php
protected function doUninstall() { $this->container->getAcumulusEntryManager()->uninstall(); // Delete all config values. $this->registry->load->model('setting/setting'); $this->registry->model_setting_setting->deleteSetting('acumulus_siel'); return true; }
[ "protected", "function", "doUninstall", "(", ")", "{", "$", "this", "->", "container", "->", "getAcumulusEntryManager", "(", ")", "->", "uninstall", "(", ")", ";", "// Delete all config values.", "$", "this", "->", "registry", "->", "load", "->", "model", "(",...
Uninstalls data and settings from this module. @return bool Whether the uninstall was successful. @throws \Exception
[ "Uninstalls", "data", "and", "settings", "from", "this", "module", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L471-L480
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.doUpgrade
protected function doUpgrade() { //Install/update datamodel first. $result = $this->doInstall(); $this->registry->load->model('setting/setting'); $setting = $this->registry->model_setting_setting->getSetting('acumulus_siel'); $currentDataModelVersion = isset($setting['acumulus_siel_datamodel_version']) ? $setting['acumulus_siel_datamodel_version'] : ''; $apiVersion = PluginConfig::Version; $this->container->getLog()->info('%s: installed version = %s, API = %s', __METHOD__, $currentDataModelVersion, $apiVersion); if (version_compare($currentDataModelVersion, $apiVersion, '<')) { // Update config settings. if ($result = $this->container->getConfig()->upgrade($currentDataModelVersion)) { // Refresh settings. $setting = $this->registry->model_setting_setting->getSetting('acumulus_siel'); $setting['acumulus_siel_datamodel_version'] = $apiVersion; $this->registry->model_setting_setting->editSetting('acumulus_siel', $setting); } } return $result; }
php
protected function doUpgrade() { //Install/update datamodel first. $result = $this->doInstall(); $this->registry->load->model('setting/setting'); $setting = $this->registry->model_setting_setting->getSetting('acumulus_siel'); $currentDataModelVersion = isset($setting['acumulus_siel_datamodel_version']) ? $setting['acumulus_siel_datamodel_version'] : ''; $apiVersion = PluginConfig::Version; $this->container->getLog()->info('%s: installed version = %s, API = %s', __METHOD__, $currentDataModelVersion, $apiVersion); if (version_compare($currentDataModelVersion, $apiVersion, '<')) { // Update config settings. if ($result = $this->container->getConfig()->upgrade($currentDataModelVersion)) { // Refresh settings. $setting = $this->registry->model_setting_setting->getSetting('acumulus_siel'); $setting['acumulus_siel_datamodel_version'] = $apiVersion; $this->registry->model_setting_setting->editSetting('acumulus_siel', $setting); } } return $result; }
[ "protected", "function", "doUpgrade", "(", ")", "{", "//Install/update datamodel first.", "$", "result", "=", "$", "this", "->", "doInstall", "(", ")", ";", "$", "this", "->", "registry", "->", "load", "->", "model", "(", "'setting/setting'", ")", ";", "$", ...
Upgrades the data and settings for this module if needed. The install now checks for the data model and can do an upgrade instead of a clean install. @return bool Whether the upgrade was successful. @throws \Exception
[ "Upgrades", "the", "data", "and", "settings", "for", "this", "module", "if", "needed", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L493-L516
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/OcHelper.php
OcHelper.installEvents
protected function installEvents() { $this->uninstallEvents(); $location = $this->getLocation(); $model = $this->registry->getEventModel(); $model->addEvent('acumulus','catalog/model/*/addOrder/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','catalog/model/*/addOrderHistory/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','admin/model/*/addOrder/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','admin/model/*/addOrderHistory/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','admin/view/common/column_left/before',$location . '/eventViewColumnLeft'); }
php
protected function installEvents() { $this->uninstallEvents(); $location = $this->getLocation(); $model = $this->registry->getEventModel(); $model->addEvent('acumulus','catalog/model/*/addOrder/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','catalog/model/*/addOrderHistory/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','admin/model/*/addOrder/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','admin/model/*/addOrderHistory/after',$location . '/eventOrderUpdate'); $model->addEvent('acumulus','admin/view/common/column_left/before',$location . '/eventViewColumnLeft'); }
[ "protected", "function", "installEvents", "(", ")", "{", "$", "this", "->", "uninstallEvents", "(", ")", ";", "$", "location", "=", "$", "this", "->", "getLocation", "(", ")", ";", "$", "model", "=", "$", "this", "->", "registry", "->", "getEventModel", ...
Installs our events. This will add them to the table 'event' from where they are registered on the start of each request. The controller actions can be found in the catalog controller for the catalog events and the admin controller for the admin events. To support updating, this will also be called by the index function. Therefore we will first remove any existing events from our module. To support other plugins, notably quick_status_updater, we do not only look at the checkout/order events at the catalog side, but at all addOrder and addOrderHistory events. @throws \Exception
[ "Installs", "our", "events", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L535-L545
train
SIELOnline/libAcumulus
src/Shop/AdvancedConfigForm.php
AdvancedConfigForm.validateRelationFields
protected function validateRelationFields() { if (empty($this->submittedValues['sendCustomer']) && !empty($this->submittedValues['emailAsPdf'])) { $this->warningMessages['conflicting_options'] = $this->t('message_validate_conflicting_options'); } }
php
protected function validateRelationFields() { if (empty($this->submittedValues['sendCustomer']) && !empty($this->submittedValues['emailAsPdf'])) { $this->warningMessages['conflicting_options'] = $this->t('message_validate_conflicting_options'); } }
[ "protected", "function", "validateRelationFields", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "submittedValues", "[", "'sendCustomer'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "submittedValues", "[", "'emailAsPdf'", "]", ")", ...
Validates fields in the relation management settings fieldset.
[ "Validates", "fields", "in", "the", "relation", "management", "settings", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AdvancedConfigForm.php#L28-L33
train
SIELOnline/libAcumulus
src/Shop/AdvancedConfigForm.php
AdvancedConfigForm.validateOptionsFields
protected function validateOptionsFields() { if ($this->submittedValues['optionsAllOn1Line'] == PHP_INT_MAX && $this->submittedValues['optionsAllOnOwnLine'] == 1) { $this->errorMessages['optionsAllOnOwnLine'] = $this->t('message_validate_options_0'); } if ($this->submittedValues['optionsAllOn1Line'] > $this->submittedValues['optionsAllOnOwnLine'] && $this->submittedValues['optionsAllOnOwnLine'] > 1) { $this->errorMessages['optionsAllOnOwnLine'] = $this->t('message_validate_options_1'); } if (isset($this->submittedValues['optionsMaxLength']) && !ctype_digit($this->submittedValues['optionsMaxLength'])) { $this->errorMessages['optionsMaxLength'] = $this->t('message_validate_options_2'); } }
php
protected function validateOptionsFields() { if ($this->submittedValues['optionsAllOn1Line'] == PHP_INT_MAX && $this->submittedValues['optionsAllOnOwnLine'] == 1) { $this->errorMessages['optionsAllOnOwnLine'] = $this->t('message_validate_options_0'); } if ($this->submittedValues['optionsAllOn1Line'] > $this->submittedValues['optionsAllOnOwnLine'] && $this->submittedValues['optionsAllOnOwnLine'] > 1) { $this->errorMessages['optionsAllOnOwnLine'] = $this->t('message_validate_options_1'); } if (isset($this->submittedValues['optionsMaxLength']) && !ctype_digit($this->submittedValues['optionsMaxLength'])) { $this->errorMessages['optionsMaxLength'] = $this->t('message_validate_options_2'); } }
[ "protected", "function", "validateOptionsFields", "(", ")", "{", "if", "(", "$", "this", "->", "submittedValues", "[", "'optionsAllOn1Line'", "]", "==", "PHP_INT_MAX", "&&", "$", "this", "->", "submittedValues", "[", "'optionsAllOnOwnLine'", "]", "==", "1", ")",...
Validates fields in the "Invoice" settings fieldset.
[ "Validates", "fields", "in", "the", "Invoice", "settings", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AdvancedConfigForm.php#L38-L50
train
SIELOnline/libAcumulus
src/Shop/AdvancedConfigForm.php
AdvancedConfigForm.validateEmailAsPdfFields
protected function validateEmailAsPdfFields() { // Check for valid email address if no token syntax is used. $regexpEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+$/'; if (!empty($this->submittedValues['emailTo']) && strpos($this->submittedValues['emailTo'], '[') === false && !preg_match($regexpEmail, $this->submittedValues['emailTo'])) { $this->errorMessages['emailTo'] = $this->t('message_validate_email_5'); } // Check for valid email addresses if no token syntax is used. $regexpMultiEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+([,;][^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+)*$/'; if (!empty($this->submittedValues['emailBcc']) && strpos($this->submittedValues['emailBcc'], '[') === false && !preg_match($regexpMultiEmail, $this->submittedValues['emailBcc'])) { $this->errorMessages['emailBcc'] = $this->t('message_validate_email_3'); } // Check for valid email address if no token syntax is used. if (!empty($this->submittedValues['emailFrom']) && strpos($this->submittedValues['emailFrom'], '[') === false && !preg_match($regexpEmail, $this->submittedValues['emailFrom'])) { $this->errorMessages['emailFrom'] = $this->t('message_validate_email_4'); } }
php
protected function validateEmailAsPdfFields() { // Check for valid email address if no token syntax is used. $regexpEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+$/'; if (!empty($this->submittedValues['emailTo']) && strpos($this->submittedValues['emailTo'], '[') === false && !preg_match($regexpEmail, $this->submittedValues['emailTo'])) { $this->errorMessages['emailTo'] = $this->t('message_validate_email_5'); } // Check for valid email addresses if no token syntax is used. $regexpMultiEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+([,;][^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+)*$/'; if (!empty($this->submittedValues['emailBcc']) && strpos($this->submittedValues['emailBcc'], '[') === false && !preg_match($regexpMultiEmail, $this->submittedValues['emailBcc'])) { $this->errorMessages['emailBcc'] = $this->t('message_validate_email_3'); } // Check for valid email address if no token syntax is used. if (!empty($this->submittedValues['emailFrom']) && strpos($this->submittedValues['emailFrom'], '[') === false && !preg_match($regexpEmail, $this->submittedValues['emailFrom'])) { $this->errorMessages['emailFrom'] = $this->t('message_validate_email_4'); } }
[ "protected", "function", "validateEmailAsPdfFields", "(", ")", "{", "// Check for valid email address if no token syntax is used.", "$", "regexpEmail", "=", "'/^[^@<>,; \"\\']+@([^.@ ,;]+\\.)+[^.@ ,;]+$/'", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "submittedValue...
Validates fields in the "Email as pdf" settings fieldset.
[ "Validates", "fields", "in", "the", "Email", "as", "pdf", "settings", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AdvancedConfigForm.php#L55-L73
train
SIELOnline/libAcumulus
src/Shop/AdvancedConfigForm.php
AdvancedConfigForm.getInvoiceLinesFields
protected function getInvoiceLinesFields() { $fields = array( 'itemNumber' => array( 'type' => 'text', 'label' => $this->t('field_itemNumber'), 'description' => $this->t('desc_itemNumber') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'productName' => array( 'type' => 'text', 'label' => $this->t('field_productName'), 'description' => $this->t('desc_productName') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'nature' => array( 'type' => 'text', 'label' => $this->t('field_nature'), 'description' => $this->t('desc_nature'), 'attributes' => array( 'size' => 30, ), ), 'costPrice' => array( 'type' => 'text', 'label' => $this->t('field_costPrice'), 'description' => $this->t('desc_costPrice') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), ); return $fields; }
php
protected function getInvoiceLinesFields() { $fields = array( 'itemNumber' => array( 'type' => 'text', 'label' => $this->t('field_itemNumber'), 'description' => $this->t('desc_itemNumber') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'productName' => array( 'type' => 'text', 'label' => $this->t('field_productName'), 'description' => $this->t('desc_productName') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'nature' => array( 'type' => 'text', 'label' => $this->t('field_nature'), 'description' => $this->t('desc_nature'), 'attributes' => array( 'size' => 30, ), ), 'costPrice' => array( 'type' => 'text', 'label' => $this->t('field_costPrice'), 'description' => $this->t('desc_costPrice') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), ); return $fields; }
[ "protected", "function", "getInvoiceLinesFields", "(", ")", "{", "$", "fields", "=", "array", "(", "'itemNumber'", "=>", "array", "(", "'type'", "=>", "'text'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'field_itemNumber'", ")", ",", "'description'...
Returns the set of invoice line related fields. The fields returned: - itemNumber - productName - nature - costPrice @return array[] The set of invoice line related fields.
[ "Returns", "the", "set", "of", "invoice", "line", "related", "fields", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AdvancedConfigForm.php#L556-L593
train
SIELOnline/libAcumulus
src/Shop/AdvancedConfigForm.php
AdvancedConfigForm.getOptionsFields
protected function getOptionsFields() { $fields = array( 'showOptions' => array( 'type' => 'checkbox', 'label' => $this->t('field_showOptions'), 'description' => $this->t('desc_showOptions'), 'options' => array( 'optionsShow' => $this->t('option_optionsShow'), ), ), 'optionsAllOn1Line' => array( 'type' => 'select', 'label' => $this->t('field_optionsAllOn1Line'), 'options' => array( 0 => $this->t('option_do_not_use'), PHP_INT_MAX => $this->t('option_always'), ) + array_combine(range(1, 10), range(1, 10)), ), 'optionsAllOnOwnLine' => array( 'type' => 'select', 'label' => $this->t('field_optionsAllOnOwnLine'), 'options' => array( PHP_INT_MAX => $this->t('option_do_not_use'), 1 => $this->t('option_always'), ) + array_combine(range(2, 10), range(2, 10)), ), 'optionsMaxLength' => array( 'type' => 'number', 'label' => $this->t('field_optionsMaxLength'), 'description' => $this->t('desc_optionsMaxLength'), 'attributes' => array( 'min' => 1, ), ), ); return $fields; }
php
protected function getOptionsFields() { $fields = array( 'showOptions' => array( 'type' => 'checkbox', 'label' => $this->t('field_showOptions'), 'description' => $this->t('desc_showOptions'), 'options' => array( 'optionsShow' => $this->t('option_optionsShow'), ), ), 'optionsAllOn1Line' => array( 'type' => 'select', 'label' => $this->t('field_optionsAllOn1Line'), 'options' => array( 0 => $this->t('option_do_not_use'), PHP_INT_MAX => $this->t('option_always'), ) + array_combine(range(1, 10), range(1, 10)), ), 'optionsAllOnOwnLine' => array( 'type' => 'select', 'label' => $this->t('field_optionsAllOnOwnLine'), 'options' => array( PHP_INT_MAX => $this->t('option_do_not_use'), 1 => $this->t('option_always'), ) + array_combine(range(2, 10), range(2, 10)), ), 'optionsMaxLength' => array( 'type' => 'number', 'label' => $this->t('field_optionsMaxLength'), 'description' => $this->t('desc_optionsMaxLength'), 'attributes' => array( 'min' => 1, ), ), ); return $fields; }
[ "protected", "function", "getOptionsFields", "(", ")", "{", "$", "fields", "=", "array", "(", "'showOptions'", "=>", "array", "(", "'type'", "=>", "'checkbox'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'field_showOptions'", ")", ",", "'description...
Returns the set of options related fields. The fields returned: - optionsAllOn1Line - optionsAllOnOwnLine - optionsMaxLength @return array[] The set of options related fields.
[ "Returns", "the", "set", "of", "options", "related", "fields", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AdvancedConfigForm.php#L606-L643
train
SIELOnline/libAcumulus
src/Shop/AdvancedConfigForm.php
AdvancedConfigForm.getEmailAsPdfFields
protected function getEmailAsPdfFields() { return array( 'emailAsPdf_cb' => array( 'type' => 'checkbox', 'label' => $this->t('field_emailAsPdf'), 'description' => $this->t('desc_emailAsPdf'), 'options' => array( 'emailAsPdf' => $this->t('option_emailAsPdf'), ), ), 'emailTo' => array( 'type' => 'email', 'label' => $this->t('field_emailTo'), 'description' => $this->t('desc_emailTo') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'emailBcc' => array( 'type' => 'email', 'label' => $this->t('field_emailBcc'), 'description' => $this->t('desc_emailBcc') . ' ' . $this->t('msg_token'), 'attributes' => array( 'multiple' => true, 'size' => 60, ), ), 'emailFrom' => array( 'type' => 'email', 'label' => $this->t('field_emailFrom'), 'description' => $this->t('desc_emailFrom') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'subject' => array( 'type' => 'text', 'label' => $this->t('field_subject'), 'description' => $this->t('desc_subject') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), ); }
php
protected function getEmailAsPdfFields() { return array( 'emailAsPdf_cb' => array( 'type' => 'checkbox', 'label' => $this->t('field_emailAsPdf'), 'description' => $this->t('desc_emailAsPdf'), 'options' => array( 'emailAsPdf' => $this->t('option_emailAsPdf'), ), ), 'emailTo' => array( 'type' => 'email', 'label' => $this->t('field_emailTo'), 'description' => $this->t('desc_emailTo') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'emailBcc' => array( 'type' => 'email', 'label' => $this->t('field_emailBcc'), 'description' => $this->t('desc_emailBcc') . ' ' . $this->t('msg_token'), 'attributes' => array( 'multiple' => true, 'size' => 60, ), ), 'emailFrom' => array( 'type' => 'email', 'label' => $this->t('field_emailFrom'), 'description' => $this->t('desc_emailFrom') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), 'subject' => array( 'type' => 'text', 'label' => $this->t('field_subject'), 'description' => $this->t('desc_subject') . ' ' . $this->t('msg_token'), 'attributes' => array( 'size' => 60, ), ), ); }
[ "protected", "function", "getEmailAsPdfFields", "(", ")", "{", "return", "array", "(", "'emailAsPdf_cb'", "=>", "array", "(", "'type'", "=>", "'checkbox'", ",", "'label'", "=>", "$", "this", "->", "t", "(", "'field_emailAsPdf'", ")", ",", "'description'", "=>"...
Returns the set of 'email invoice as PDF' related fields. The fields returned: - emailAsPdf - emailFrom - emailBcc - subject @return array[] The set of 'email invoice as PDF' related fields.
[ "Returns", "the", "set", "of", "email", "invoice", "as", "PDF", "related", "fields", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AdvancedConfigForm.php#L657-L702
train
SIELOnline/libAcumulus
src/Shop/BaseConfigForm.php
BaseConfigForm.checkAccountSettings
protected function checkAccountSettings() { // Check if we can retrieve a picklist. This indicates if the account // settings are correct. $message = ''; $credentials = $this->acumulusConfig->getCredentials(); if (!empty($credentials[Tag::ContractCode]) && !empty($credentials[Tag::UserName]) && !empty($credentials[Tag::Password])) { $this->about = $this->service->getAbout(); if ($this->about->hasError()) { $message = $this->about->hasCode(401) ? 'message_error_auth' : ($this->about->hasCode(403) ? 'message_error_forb' : 'message_error_comm'); $this->addErrorMessages($this->about->getExceptionMessage()); $this->addErrorMessages($this->about->getErrors(Result::Format_PlainTextArray)); $this->addWarningMessages($this->about->getWarnings(Result::Format_PlainTextArray)); } elseif ($this->about->hasCode(553)) { // Role has been deprecated role for use with the API. $this->addWarningMessages($this->t('message_warning_role_deprecated')); } else { // Check role for sufficient rights but no overkill. $response = $this->about->getResponse(); $roleId = (int) $response['roleid']; if ($roleId === Api::RoleApiCreator) { $this->addWarningMessages($this->t('message_warning_role_insufficient')); } elseif ($roleId === Api::RoleApiManager) { $this->addWarningMessages($this->t('message_warning_role_overkill')); } } } else { // First fill in your account details. $message = 'message_auth_unknown'; } // Translate and format message. if (!empty($message)) { $formType = $this->isAdvancedConfigForm() ? 'advanced' : 'config'; $message = sprintf($this->t($message), $this->t("message_error_arg1_$formType"), $this->t("message_error_arg2_$formType")); } return $message; }
php
protected function checkAccountSettings() { // Check if we can retrieve a picklist. This indicates if the account // settings are correct. $message = ''; $credentials = $this->acumulusConfig->getCredentials(); if (!empty($credentials[Tag::ContractCode]) && !empty($credentials[Tag::UserName]) && !empty($credentials[Tag::Password])) { $this->about = $this->service->getAbout(); if ($this->about->hasError()) { $message = $this->about->hasCode(401) ? 'message_error_auth' : ($this->about->hasCode(403) ? 'message_error_forb' : 'message_error_comm'); $this->addErrorMessages($this->about->getExceptionMessage()); $this->addErrorMessages($this->about->getErrors(Result::Format_PlainTextArray)); $this->addWarningMessages($this->about->getWarnings(Result::Format_PlainTextArray)); } elseif ($this->about->hasCode(553)) { // Role has been deprecated role for use with the API. $this->addWarningMessages($this->t('message_warning_role_deprecated')); } else { // Check role for sufficient rights but no overkill. $response = $this->about->getResponse(); $roleId = (int) $response['roleid']; if ($roleId === Api::RoleApiCreator) { $this->addWarningMessages($this->t('message_warning_role_insufficient')); } elseif ($roleId === Api::RoleApiManager) { $this->addWarningMessages($this->t('message_warning_role_overkill')); } } } else { // First fill in your account details. $message = 'message_auth_unknown'; } // Translate and format message. if (!empty($message)) { $formType = $this->isAdvancedConfigForm() ? 'advanced' : 'config'; $message = sprintf($this->t($message), $this->t("message_error_arg1_$formType"), $this->t("message_error_arg2_$formType")); } return $message; }
[ "protected", "function", "checkAccountSettings", "(", ")", "{", "// Check if we can retrieve a picklist. This indicates if the account", "// settings are correct.", "$", "message", "=", "''", ";", "$", "credentials", "=", "$", "this", "->", "acumulusConfig", "->", "getCrede...
Checks the account settings for correctness and sufficient authorization. This is done by calling the about API call and checking the result. @return string Message to show in the 2nd and 3rd fieldset. Empty if successful.
[ "Checks", "the", "account", "settings", "for", "correctness", "and", "sufficient", "authorization", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/BaseConfigForm.php#L112-L150
train
SIELOnline/libAcumulus
src/Shop/BaseConfigForm.php
BaseConfigForm.getOptionsOrHiddenField
protected function getOptionsOrHiddenField($name, $type, $required = true, array $options = null) { if ($options === null) { $methodName = 'get' . ucfirst($name) . 'Options'; $options = $this->shopCapabilities->$methodName(); } if (count($options) === 1) { // Make it a hidden field. $field = array( 'type' => 'hidden', 'value' => reset($options), ); } else { $field = array( 'type' => $type, 'label' => $this->t("field_$name"), 'description' => $this->t($this->t("desc_$name")), 'options' => $options, 'attributes' => array( 'required' => $required, ), ); } return $field; }
php
protected function getOptionsOrHiddenField($name, $type, $required = true, array $options = null) { if ($options === null) { $methodName = 'get' . ucfirst($name) . 'Options'; $options = $this->shopCapabilities->$methodName(); } if (count($options) === 1) { // Make it a hidden field. $field = array( 'type' => 'hidden', 'value' => reset($options), ); } else { $field = array( 'type' => $type, 'label' => $this->t("field_$name"), 'description' => $this->t($this->t("desc_$name")), 'options' => $options, 'attributes' => array( 'required' => $required, ), ); } return $field; }
[ "protected", "function", "getOptionsOrHiddenField", "(", "$", "name", ",", "$", "type", ",", "$", "required", "=", "true", ",", "array", "$", "options", "=", "null", ")", "{", "if", "(", "$", "options", "===", "null", ")", "{", "$", "methodName", "=", ...
Creates a hidden or an option field If there is only 1 option, a hidden value with a fixed value will be created, an option field that gives the user th choice otherwise. @param string $name The field name. @param string $type The field type: radio or select. @param bool $required Whether the required attribute should be rendered. @param array|null $options An array with value =>label pairs that can be used as an option set. If null, a similarly as $name named method on $this->shopCapabilities wil be called to get the options. @return array A form field definition.
[ "Creates", "a", "hidden", "or", "an", "option", "field" ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/BaseConfigForm.php#L198-L222
train
SIELOnline/libAcumulus
src/Shop/BaseConfigForm.php
BaseConfigForm.getOrderStatusesList
protected function getOrderStatusesList() { $result = array(); // Because many users won't know how to deselect a single option in a // multiple select element, an empty option is added. $result['0'] = $this->t('option_empty_triggerOrderStatus'); $result += $this->shopCapabilities->getShopOrderStatuses(); return $result; }
php
protected function getOrderStatusesList() { $result = array(); // Because many users won't know how to deselect a single option in a // multiple select element, an empty option is added. $result['0'] = $this->t('option_empty_triggerOrderStatus'); $result += $this->shopCapabilities->getShopOrderStatuses(); return $result; }
[ "protected", "function", "getOrderStatusesList", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// Because many users won't know how to deselect a single option in a", "// multiple select element, an empty option is added.", "$", "result", "[", "'0'", "]", "=", ...
Returns an option list of all order statuses including an empty choice. @return array An options array of all order statuses.
[ "Returns", "an", "option", "list", "of", "all", "order", "statuses", "including", "an", "empty", "choice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/BaseConfigForm.php#L282-L292
train
ipunkt/rancherize
app/Blueprint/Flags/HasFlagsTrait.php
HasFlagsTrait.getFlag
public function getFlag(string $flag, $default = null) { if( !array_key_exists($flag, $this->flags) ) return $default; return $this->flags[$flag]; }
php
public function getFlag(string $flag, $default = null) { if( !array_key_exists($flag, $this->flags) ) return $default; return $this->flags[$flag]; }
[ "public", "function", "getFlag", "(", "string", "$", "flag", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "flag", ",", "$", "this", "->", "flags", ")", ")", "return", "$", "default", ";", "return", "$", ...
Return the set value for the given flag. If the flag was not set then the given default value is returned @param string $flag @param mixed $default @return null
[ "Return", "the", "set", "value", "for", "the", "given", "flag", ".", "If", "the", "flag", "was", "not", "set", "then", "the", "given", "default", "value", "is", "returned" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/Flags/HasFlagsTrait.php#L35-L39
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceManager.php
InvoiceManager.query2Sources
protected function query2Sources(array $args, $invoiceSourceType, $sort = true) { $this->getLog()->info('WooCommerce\InvoiceManager::query2Sources: args = %s', str_replace(array(' ', "\r", "\n", "\t"), '', var_export($args, true))); // Add default arguments. $args = $args + array( 'fields' => 'ids', 'posts_per_page' => -1, 'post_type' => $this->sourceTypeToShopType($invoiceSourceType), 'post_status' => array_keys(wc_get_order_statuses()), ); $query = new WP_Query($args); $ids = $query->get_posts(); if ($sort) { sort($ids); } return $this->getSourcesByIdsOrSources($invoiceSourceType, $ids); }
php
protected function query2Sources(array $args, $invoiceSourceType, $sort = true) { $this->getLog()->info('WooCommerce\InvoiceManager::query2Sources: args = %s', str_replace(array(' ', "\r", "\n", "\t"), '', var_export($args, true))); // Add default arguments. $args = $args + array( 'fields' => 'ids', 'posts_per_page' => -1, 'post_type' => $this->sourceTypeToShopType($invoiceSourceType), 'post_status' => array_keys(wc_get_order_statuses()), ); $query = new WP_Query($args); $ids = $query->get_posts(); if ($sort) { sort($ids); } return $this->getSourcesByIdsOrSources($invoiceSourceType, $ids); }
[ "protected", "function", "query2Sources", "(", "array", "$", "args", ",", "$", "invoiceSourceType", ",", "$", "sort", "=", "true", ")", "{", "$", "this", "->", "getLog", "(", ")", "->", "info", "(", "'WooCommerce\\InvoiceManager::query2Sources: args = %s'", ",",...
Helper method to get a list of Source given a set of query arguments. @param array $args @param string $invoiceSourceType @param bool $sort @return \Siel\Acumulus\Invoice\Source[]
[ "Helper", "method", "to", "get", "a", "list", "of", "Source", "given", "a", "set", "of", "query", "arguments", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceManager.php#L227-L243
train
ipunkt/rancherize
app/Push/CreateModeFactory/ContainerCreateModeFactory.php
ContainerCreateModeFactory.register
public function register( $modeName, CreateMode $createMode ) { if( empty($this->defaultMode) ) $this->defaultMode = $modeName; $this->container[$modeName] = function() use ($createMode) { return $createMode; }; }
php
public function register( $modeName, CreateMode $createMode ) { if( empty($this->defaultMode) ) $this->defaultMode = $modeName; $this->container[$modeName] = function() use ($createMode) { return $createMode; }; }
[ "public", "function", "register", "(", "$", "modeName", ",", "CreateMode", "$", "createMode", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "defaultMode", ")", ")", "$", "this", "->", "defaultMode", "=", "$", "modeName", ";", "$", "this", "->",...
Register a createMode. If no Mode is registered yet it will be used as the default mode @param $modeName @param CreateMode $createMode
[ "Register", "a", "createMode", ".", "If", "no", "Mode", "is", "registered", "yet", "it", "will", "be", "used", "as", "the", "default", "mode" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Push/CreateModeFactory/ContainerCreateModeFactory.php#L56-L63
train
SIELOnline/libAcumulus
src/OpenCart/OpenCart2/OpenCart23/Helpers/Registry.php
Registry.getLink
public function getLink($route) { $token = 'token'; $secure = true; return $this->url->link($route, $token . '=' . $this->session->data[$token], $secure); }
php
public function getLink($route) { $token = 'token'; $secure = true; return $this->url->link($route, $token . '=' . $this->session->data[$token], $secure); }
[ "public", "function", "getLink", "(", "$", "route", ")", "{", "$", "token", "=", "'token'", ";", "$", "secure", "=", "true", ";", "return", "$", "this", "->", "url", "->", "link", "(", "$", "route", ",", "$", "token", ".", "'='", ".", "$", "this"...
Returns a link to the given route. @param string $route @return string The link to the given route, including standard arguments.
[ "Returns", "a", "link", "to", "the", "given", "route", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/OpenCart2/OpenCart23/Helpers/Registry.php#L55-L60
train
SIELOnline/libAcumulus
src/Magento/Invoice/Source.php
Source.getPaymentStatusOrder
protected function getPaymentStatusOrder() { return Number::isZero($this->source->getBaseTotalDue()) ? Api::PaymentStatus_Paid : Api::PaymentStatus_Due; }
php
protected function getPaymentStatusOrder() { return Number::isZero($this->source->getBaseTotalDue()) ? Api::PaymentStatus_Paid : Api::PaymentStatus_Due; }
[ "protected", "function", "getPaymentStatusOrder", "(", ")", "{", "return", "Number", "::", "isZero", "(", "$", "this", "->", "source", "->", "getBaseTotalDue", "(", ")", ")", "?", "Api", "::", "PaymentStatus_Paid", ":", "Api", "::", "PaymentStatus_Due", ";", ...
Returns whether the order has been paid or not. @return int \Siel\Acumulus\Api::PaymentStatus_Paid or \Siel\Acumulus\Api::PaymentStatus_Due
[ "Returns", "whether", "the", "order", "has", "been", "paid", "or", "not", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Invoice/Source.php#L115-L120
train
SIELOnline/libAcumulus
src/OpenCart/Invoice/Source.php
Source.getOrderTotalLines
public function getOrderTotalLines() { if (!$this->orderTotalLines) { $orderModel = $this->getRegistry()->getOrderModel(); $this->orderTotalLines = $orderModel->getOrderTotals($this->source['order_id']); } return $this->orderTotalLines; }
php
public function getOrderTotalLines() { if (!$this->orderTotalLines) { $orderModel = $this->getRegistry()->getOrderModel(); $this->orderTotalLines = $orderModel->getOrderTotals($this->source['order_id']); } return $this->orderTotalLines; }
[ "public", "function", "getOrderTotalLines", "(", ")", "{", "if", "(", "!", "$", "this", "->", "orderTotalLines", ")", "{", "$", "orderModel", "=", "$", "this", "->", "getRegistry", "(", ")", "->", "getOrderModel", "(", ")", ";", "$", "this", "->", "ord...
Returns a list of OpenCart order total records. These are shipment, other fee, tax, and discount lines. @return array[] @throws \Exception
[ "Returns", "a", "list", "of", "OpenCart", "order", "total", "records", ".", "These", "are", "shipment", "other", "fee", "tax", "and", "discount", "lines", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Invoice/Source.php#L155-L162
train
SIELOnline/libAcumulus
src/Helpers/Container.php
Container.getForm
public function getForm($type) { $arguments = array(); switch (strtolower($type)) { case 'config': $class = 'Config'; $arguments[] = $this->getService(); break; case 'advanced': $class = 'AdvancedConfig'; $arguments[] = $this->getService(); break; case 'batch': $class = 'Batch'; $arguments[] = $this->getInvoiceManager(); break; case 'invoice': $class = 'InvoiceStatusOverview'; $arguments[] = $this->getInvoiceManager(); $arguments[] = $this->getAcumulusEntryManager(); $arguments[] = $this->getService(); break; default; throw new \InvalidArgumentException("Unknown form type $type"); } $arguments = array_merge($arguments, array( $this->getFormHelper(), $this->getShopCapabilities(), $this->getConfig(), $this->getTranslator(), $this->getLog(), )); /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->getInstance($class . 'Form', 'Shop', $arguments); }
php
public function getForm($type) { $arguments = array(); switch (strtolower($type)) { case 'config': $class = 'Config'; $arguments[] = $this->getService(); break; case 'advanced': $class = 'AdvancedConfig'; $arguments[] = $this->getService(); break; case 'batch': $class = 'Batch'; $arguments[] = $this->getInvoiceManager(); break; case 'invoice': $class = 'InvoiceStatusOverview'; $arguments[] = $this->getInvoiceManager(); $arguments[] = $this->getAcumulusEntryManager(); $arguments[] = $this->getService(); break; default; throw new \InvalidArgumentException("Unknown form type $type"); } $arguments = array_merge($arguments, array( $this->getFormHelper(), $this->getShopCapabilities(), $this->getConfig(), $this->getTranslator(), $this->getLog(), )); /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->getInstance($class . 'Form', 'Shop', $arguments); }
[ "public", "function", "getForm", "(", "$", "type", ")", "{", "$", "arguments", "=", "array", "(", ")", ";", "switch", "(", "strtolower", "(", "$", "type", ")", ")", "{", "case", "'config'", ":", "$", "class", "=", "'Config'", ";", "$", "arguments", ...
Returns a form instance of the given type. @param string $type The type of form requested. @return \Siel\Acumulus\Helpers\Form
[ "Returns", "a", "form", "instance", "of", "the", "given", "type", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Container.php#L493-L527
train
SIELOnline/libAcumulus
src/Helpers/Container.php
Container.getInstance
public function getInstance($class, $subNamespace, array $constructorArgs = array(), $newInstance = false) { if (!isset($this->instances[$class]) || $newInstance) { // Try custom namespace. if (!empty($this->customNamespace)) { $fqClass = $this->tryNsInstance($class, $subNamespace, $this->customNamespace); } // Try the namespace passed to the constructor and any parent // namespaces, but stop at Acumulus. $namespaces = explode('\\', $this->shopNamespace); while (empty($fqClass) && !empty($namespaces)) { if (end($namespaces) === 'Acumulus') { // Base level is always \Siel\Acumulus, even if // \MyVendorName\Acumulus\MyWebShop was set as shopNamespace. $namespace = static::baseNamespace; $namespaces = array(); } else { $namespace = implode('\\', $namespaces); array_pop($namespaces); } $fqClass = $this->tryNsInstance($class, $subNamespace, $namespace); } if (empty($fqClass)) { throw new \InvalidArgumentException("Class $class not found in namespace $subNamespace"); } // Create a new instance. // As PHP5.3 produces a fatal error when a class has no constructor // and newInstanceArgs() is called, we have to differentiate between // no arguments and arguments. if (empty($constructorArgs)) { $this->instances[$class] = new $fqClass(); } else { /** @noinspection PhpUnhandledExceptionInspection */ $reflector = new ReflectionClass($fqClass); $this->instances[$class] = $reflector->newInstanceArgs($constructorArgs); } } return $this->instances[$class]; }
php
public function getInstance($class, $subNamespace, array $constructorArgs = array(), $newInstance = false) { if (!isset($this->instances[$class]) || $newInstance) { // Try custom namespace. if (!empty($this->customNamespace)) { $fqClass = $this->tryNsInstance($class, $subNamespace, $this->customNamespace); } // Try the namespace passed to the constructor and any parent // namespaces, but stop at Acumulus. $namespaces = explode('\\', $this->shopNamespace); while (empty($fqClass) && !empty($namespaces)) { if (end($namespaces) === 'Acumulus') { // Base level is always \Siel\Acumulus, even if // \MyVendorName\Acumulus\MyWebShop was set as shopNamespace. $namespace = static::baseNamespace; $namespaces = array(); } else { $namespace = implode('\\', $namespaces); array_pop($namespaces); } $fqClass = $this->tryNsInstance($class, $subNamespace, $namespace); } if (empty($fqClass)) { throw new \InvalidArgumentException("Class $class not found in namespace $subNamespace"); } // Create a new instance. // As PHP5.3 produces a fatal error when a class has no constructor // and newInstanceArgs() is called, we have to differentiate between // no arguments and arguments. if (empty($constructorArgs)) { $this->instances[$class] = new $fqClass(); } else { /** @noinspection PhpUnhandledExceptionInspection */ $reflector = new ReflectionClass($fqClass); $this->instances[$class] = $reflector->newInstanceArgs($constructorArgs); } } return $this->instances[$class]; }
[ "public", "function", "getInstance", "(", "$", "class", ",", "$", "subNamespace", ",", "array", "$", "constructorArgs", "=", "array", "(", ")", ",", "$", "newInstance", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "instances...
Returns an instance of the given class. This method should normally be avoided, use the get{Class}() methods as they know (and hide) what arguments to inject into the constructor. The class is looked for in multiple namespaces, starting with the $customNameSpace properties, continuing with the $shopNamespace property and finally the base namespace (\Siel\Acumulus). Normally, only 1 instance is created per class but the $newInstance argument can be used to change this behavior. @param string $class The name of the class without namespace. The class is searched for in multiple namespaces, see above. @param string $subNamespace The sub namespace (within the namespaces tried) in which the class resides. @param array $constructorArgs A list of arguments to pass to the constructor, may be an empty array. @param bool $newInstance Whether to create a new instance (true) or reuse an already existing instance (false, default) @return object @throws \InvalidArgumentException
[ "Returns", "an", "instance", "of", "the", "given", "class", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Container.php#L559-L600
train
SIELOnline/libAcumulus
src/Helpers/Container.php
Container.tryNsInstance
protected function tryNsInstance($class, $subNamespace, $namespace) { $fqClass = $this->getFqClass($class, $subNamespace, $namespace); $fileName = $this->getFileName($fqClass); // Checking if the file exists prevents warnings in Magento whose own // autoloader logs warnings when a class cannot be loaded. return is_readable($fileName) && class_exists($fqClass) ? $fqClass : ''; }
php
protected function tryNsInstance($class, $subNamespace, $namespace) { $fqClass = $this->getFqClass($class, $subNamespace, $namespace); $fileName = $this->getFileName($fqClass); // Checking if the file exists prevents warnings in Magento whose own // autoloader logs warnings when a class cannot be loaded. return is_readable($fileName) && class_exists($fqClass) ? $fqClass : ''; }
[ "protected", "function", "tryNsInstance", "(", "$", "class", ",", "$", "subNamespace", ",", "$", "namespace", ")", "{", "$", "fqClass", "=", "$", "this", "->", "getFqClass", "(", "$", "class", ",", "$", "subNamespace", ",", "$", "namespace", ")", ";", ...
Tries to find a class in the given namespace. @param $class The class to find. @param $subNamespace The sub namespace to add to the namespace. @param $namespace The namespace to search in. @return string The full name of the class or the empty string if it does not exist in the given namespace.
[ "Tries", "to", "find", "a", "class", "in", "the", "given", "namespace", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Container.php#L616-L623
train
SIELOnline/libAcumulus
src/OpenCart/Helpers/Registry.php
Registry.getOrder
public function getOrder($orderId) { if (strrpos(str_replace('\\', '/', DIR_APPLICATION), '/catalog/') === strlen(DIR_APPLICATION) - strlen('/catalog/')) { // We are in the catalog section, use the checkout/order model as // ModelAccountOrder::getOrder() also checks on user_id! if ($this->model_checkout_order === null) { $this->load->model('checkout/order'); } return $this->model_checkout_order->getOrder($orderId); } else { // We are in the admin section, we can use the normal order model. return $this->getOrderModel()->getOrder($orderId); } }
php
public function getOrder($orderId) { if (strrpos(str_replace('\\', '/', DIR_APPLICATION), '/catalog/') === strlen(DIR_APPLICATION) - strlen('/catalog/')) { // We are in the catalog section, use the checkout/order model as // ModelAccountOrder::getOrder() also checks on user_id! if ($this->model_checkout_order === null) { $this->load->model('checkout/order'); } return $this->model_checkout_order->getOrder($orderId); } else { // We are in the admin section, we can use the normal order model. return $this->getOrderModel()->getOrder($orderId); } }
[ "public", "function", "getOrder", "(", "$", "orderId", ")", "{", "if", "(", "strrpos", "(", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "DIR_APPLICATION", ")", ",", "'/catalog/'", ")", "===", "strlen", "(", "DIR_APPLICATION", ")", "-", "strlen", "(", ...
Returns the order. @param int $orderId @return array|false @throws \Exception
[ "Returns", "the", "order", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/Registry.php#L141-L154
train
SIELOnline/libAcumulus
src/Helpers/FormHelper.php
FormHelper.addMetaField
public function addMetaField(array $fields) { $this->setMeta($this->constructFieldMeta($fields)); $fields[static::Meta] = array( 'type' => 'hidden', 'value' => json_encode($this->getMeta()), ); return $fields; }
php
public function addMetaField(array $fields) { $this->setMeta($this->constructFieldMeta($fields)); $fields[static::Meta] = array( 'type' => 'hidden', 'value' => json_encode($this->getMeta()), ); return $fields; }
[ "public", "function", "addMetaField", "(", "array", "$", "fields", ")", "{", "$", "this", "->", "setMeta", "(", "$", "this", "->", "constructFieldMeta", "(", "$", "fields", ")", ")", ";", "$", "fields", "[", "static", "::", "Meta", "]", "=", "array", ...
Returns the keys of the fields in the given array. Internal method, do not call directly. @param array[] $fields @return array Array of key names, keyed by these names.
[ "Returns", "the", "keys", "of", "the", "fields", "in", "the", "given", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormHelper.php#L74-L82
train
SIELOnline/libAcumulus
src/Helpers/FormHelper.php
FormHelper.constructFieldMeta
protected function constructFieldMeta(array $fields) { $result = array(); foreach ($fields as $key => $field) { $name = isset($field['name']) ? $field['name'] : (isset($field['id']) ? $field['id'] : $key); $type = $field['type']; if ($type === 'checkbox') { foreach ($field['options'] as $checkboxKey => $option) { $data = new \stdClass(); $data->name = $name; $data->type = $type; $data->collection = $key; $result[$checkboxKey] = $data; } } else { $data = new \stdClass(); $data->name = $name; $data->type = $type; $result[$key] = $data; } if (!empty($field['fields'])) { $result += $this->constructFieldMeta($field['fields']); } } return $result; }
php
protected function constructFieldMeta(array $fields) { $result = array(); foreach ($fields as $key => $field) { $name = isset($field['name']) ? $field['name'] : (isset($field['id']) ? $field['id'] : $key); $type = $field['type']; if ($type === 'checkbox') { foreach ($field['options'] as $checkboxKey => $option) { $data = new \stdClass(); $data->name = $name; $data->type = $type; $data->collection = $key; $result[$checkboxKey] = $data; } } else { $data = new \stdClass(); $data->name = $name; $data->type = $type; $result[$key] = $data; } if (!empty($field['fields'])) { $result += $this->constructFieldMeta($field['fields']); } } return $result; }
[ "protected", "function", "constructFieldMeta", "(", "array", "$", "fields", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "key", "=>", "$", "field", ")", "{", "$", "name", "=", "isset", "(", "$", "f...
Returns meta data about the given fields. Internal method, do not call directly. @param array[] $fields @return array Associative array of field names and their types.
[ "Returns", "meta", "data", "about", "the", "given", "fields", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormHelper.php#L94-L120
train
SIELOnline/libAcumulus
src/Helpers/FormHelper.php
FormHelper.isArray
public function isArray($key) { $fieldMeta = $this->getMeta(); return isset($fieldMeta[$key]) && substr($fieldMeta[$key]->name, -strlen('[]')) === '[]'; }
php
public function isArray($key) { $fieldMeta = $this->getMeta(); return isset($fieldMeta[$key]) && substr($fieldMeta[$key]->name, -strlen('[]')) === '[]'; }
[ "public", "function", "isArray", "(", "$", "key", ")", "{", "$", "fieldMeta", "=", "$", "this", "->", "getMeta", "(", ")", ";", "return", "isset", "(", "$", "fieldMeta", "[", "$", "key", "]", ")", "&&", "substr", "(", "$", "fieldMeta", "[", "$", ...
Indicates whether the given key defines an array field. @param string $key The name of the field. @return bool Whether the given key defines an array field.
[ "Indicates", "whether", "the", "given", "key", "defines", "an", "array", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormHelper.php#L160-L164
train
SIELOnline/libAcumulus
src/Helpers/FormHelper.php
FormHelper.isCheckbox
public function isCheckbox($key) { $fieldMeta = $this->getMeta(); return isset($fieldMeta[$key]) && $fieldMeta[$key]->type === 'checkbox'; }
php
public function isCheckbox($key) { $fieldMeta = $this->getMeta(); return isset($fieldMeta[$key]) && $fieldMeta[$key]->type === 'checkbox'; }
[ "public", "function", "isCheckbox", "(", "$", "key", ")", "{", "$", "fieldMeta", "=", "$", "this", "->", "getMeta", "(", ")", ";", "return", "isset", "(", "$", "fieldMeta", "[", "$", "key", "]", ")", "&&", "$", "fieldMeta", "[", "$", "key", "]", ...
Indicates whether the given key defines a checkbox field. @param string $key The name of the field. @return bool Whether the given key defines a checkbox field.
[ "Indicates", "whether", "the", "given", "key", "defines", "a", "checkbox", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormHelper.php#L175-L179
train
SIELOnline/libAcumulus
src/Helpers/FormHelper.php
FormHelper.getPostedValues
public function getPostedValues() { $result = $_POST; $result = $this->alterPostedValues($result); unset($result[static::Meta]); return $result; }
php
public function getPostedValues() { $result = $_POST; $result = $this->alterPostedValues($result); unset($result[static::Meta]); return $result; }
[ "public", "function", "getPostedValues", "(", ")", "{", "$", "result", "=", "$", "_POST", ";", "$", "result", "=", "$", "this", "->", "alterPostedValues", "(", "$", "result", ")", ";", "unset", "(", "$", "result", "[", "static", "::", "Meta", "]", ")...
Returns a flat array of the posted values. As especially checkbox handling differs per webshop, often resulting in an array of checkbox values, this method returns a flattened version of the posted values. @return array
[ "Returns", "a", "flat", "array", "of", "the", "posted", "values", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormHelper.php#L190-L196
train
ipunkt/rancherize
app/Services/ValidateService.php
ValidateService.validate
public function validate(Blueprint $blueprint, Configuration $configuration, string $environment) { $projectConfigurable = new PrefixConfigurationDecorator($configuration, "project.default."); $environmentConfigurable = new PrefixConfigurationDecorator($configuration, "project.environments.$environment."); $fallbackConfiguration = new ConfigurationFallback($environmentConfigurable, $projectConfigurable); $event = ValidatingEvent::make() ->setBlueprint($blueprint) ->setConfiguration($fallbackConfiguration) ->setEnvironment($environment) ; $this->eventDispatcher->dispatch($event::NAME, $event); $blueprint->validate($configuration, $environment); }
php
public function validate(Blueprint $blueprint, Configuration $configuration, string $environment) { $projectConfigurable = new PrefixConfigurationDecorator($configuration, "project.default."); $environmentConfigurable = new PrefixConfigurationDecorator($configuration, "project.environments.$environment."); $fallbackConfiguration = new ConfigurationFallback($environmentConfigurable, $projectConfigurable); $event = ValidatingEvent::make() ->setBlueprint($blueprint) ->setConfiguration($fallbackConfiguration) ->setEnvironment($environment) ; $this->eventDispatcher->dispatch($event::NAME, $event); $blueprint->validate($configuration, $environment); }
[ "public", "function", "validate", "(", "Blueprint", "$", "blueprint", ",", "Configuration", "$", "configuration", ",", "string", "$", "environment", ")", "{", "$", "projectConfigurable", "=", "new", "PrefixConfigurationDecorator", "(", "$", "configuration", ",", "...
validate the configuration for the given environment @param Blueprint $blueprint @param string $environment @param Configuration $configuration
[ "validate", "the", "configuration", "for", "the", "given", "environment" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/ValidateService.php#L40-L55
train
ipunkt/rancherize
app/Services/ValidateService.php
ValidateService.print
public function print(ValidationFailedException $e, OutputInterface $output) { $table = new Table($output); $table->setHeaders( ['Field', 'Problem'] ); $i = 0; foreach( $e->getFailures() as $field => $messages ) { foreach($messages as $message) $table->setRow( $i++, [$field, $message] ); } $table->render(); }
php
public function print(ValidationFailedException $e, OutputInterface $output) { $table = new Table($output); $table->setHeaders( ['Field', 'Problem'] ); $i = 0; foreach( $e->getFailures() as $field => $messages ) { foreach($messages as $message) $table->setRow( $i++, [$field, $message] ); } $table->render(); }
[ "public", "function", "print", "(", "ValidationFailedException", "$", "e", ",", "OutputInterface", "$", "output", ")", "{", "$", "table", "=", "new", "Table", "(", "$", "output", ")", ";", "$", "table", "->", "setHeaders", "(", "[", "'Field'", ",", "'Pro...
Print a table with one "field", "message" per row for all messages left in the ValidationFailedException @param ValidationFailedException $e @param OutputInterface $output
[ "Print", "a", "table", "with", "one", "field", "message", "per", "row", "for", "all", "messages", "left", "in", "the", "ValidationFailedException" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/ValidateService.php#L63-L76
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Helper.validateZipCode
public static function validateZipCode($zipCode, $country) { switch (strtoupper($country)) { case 'NL': if (preg_match('/^[1-9]{1}[0-9]{3}[A-Z]{2}$/', $zipCode)) return true; break; case 'BE': if (preg_match('/^[1-9]{4}$/', $zipCode)) return true; break; case 'DE': if (preg_match('/^[1-9]{5}$/', $zipCode)) return true; break; } return false; }
php
public static function validateZipCode($zipCode, $country) { switch (strtoupper($country)) { case 'NL': if (preg_match('/^[1-9]{1}[0-9]{3}[A-Z]{2}$/', $zipCode)) return true; break; case 'BE': if (preg_match('/^[1-9]{4}$/', $zipCode)) return true; break; case 'DE': if (preg_match('/^[1-9]{5}$/', $zipCode)) return true; break; } return false; }
[ "public", "static", "function", "validateZipCode", "(", "$", "zipCode", ",", "$", "country", ")", "{", "switch", "(", "strtoupper", "(", "$", "country", ")", ")", "{", "case", "'NL'", ":", "if", "(", "preg_match", "(", "'/^[1-9]{1}[0-9]{3}[A-Z]{2}$/'", ",", ...
Validates a zipcode based on country @since 1.0.0 @param string $zipCode A string containing the zipcode @param string $country A string containing the ISO 3166-1 alpha-2 code of the country @example validateZipCode('1122AA', 'NL') @return boolean
[ "Validates", "a", "zipcode", "based", "on", "country" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L84-L101
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Product.setProductID
public function setProductID($productID) { if (empty($productID)) throw new Exception('Product ID must be set and cannot be empty.'); $this->productID = trim($productID); return $this; }
php
public function setProductID($productID) { if (empty($productID)) throw new Exception('Product ID must be set and cannot be empty.'); $this->productID = trim($productID); return $this; }
[ "public", "function", "setProductID", "(", "$", "productID", ")", "{", "if", "(", "empty", "(", "$", "productID", ")", ")", "throw", "new", "Exception", "(", "'Product ID must be set and cannot be empty.'", ")", ";", "$", "this", "->", "productID", "=", "trim"...
Sets the product ID @since 1.0.0 @param string Contains the product ID @return \Icepay_Order_Product @throws Exception when empty
[ "Sets", "the", "product", "ID" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L177-L184
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Product.setProductName
public function setProductName($productName) { if (empty($productName)) throw new Exception('Product name must be set and cannot be empty.'); $this->productName = trim($productName); return $this; }
php
public function setProductName($productName) { if (empty($productName)) throw new Exception('Product name must be set and cannot be empty.'); $this->productName = trim($productName); return $this; }
[ "public", "function", "setProductName", "(", "$", "productName", ")", "{", "if", "(", "empty", "(", "$", "productName", ")", ")", "throw", "new", "Exception", "(", "'Product name must be set and cannot be empty.'", ")", ";", "$", "this", "->", "productName", "="...
Sets the product name @since 1.0.0 @param string Contains the product name @return \Icepay_Order_Product @throws Exception when empty
[ "Sets", "the", "product", "name" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L194-L201
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Product.setQuantity
public function setQuantity($quantity) { if (empty($quantity)) throw new Exception('Quantity must be set and cannot be empty.'); $this->quantity = trim($quantity); return $this; }
php
public function setQuantity($quantity) { if (empty($quantity)) throw new Exception('Quantity must be set and cannot be empty.'); $this->quantity = trim($quantity); return $this; }
[ "public", "function", "setQuantity", "(", "$", "quantity", ")", "{", "if", "(", "empty", "(", "$", "quantity", ")", ")", "throw", "new", "Exception", "(", "'Quantity must be set and cannot be empty.'", ")", ";", "$", "this", "->", "quantity", "=", "trim", "(...
Sets the product quantity @since 1.0.0 @param string Contains the quantity of the product @return \Icepay_Order_Product @throws Exception when empty
[ "Sets", "the", "product", "quantity" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L225-L232
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setInitials
public function setInitials($initials) { if (empty($initials)) throw new Exception('Initials must be set and cannot be empty.'); $this->initials = trim($initials); return $this; }
php
public function setInitials($initials) { if (empty($initials)) throw new Exception('Initials must be set and cannot be empty.'); $this->initials = trim($initials); return $this; }
[ "public", "function", "setInitials", "(", "$", "initials", ")", "{", "if", "(", "empty", "(", "$", "initials", ")", ")", "throw", "new", "Exception", "(", "'Initials must be set and cannot be empty.'", ")", ";", "$", "this", "->", "initials", "=", "trim", "(...
Sets the initials @since 1.0.0 @param string A string containing the initials @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "initials" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L308-L315
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setLastName
public function setLastName($lastName) { if (empty($lastName)) throw new Exception('Lastname must be set and cannot be empty.'); $this->lastName = trim($lastName); return $this; }
php
public function setLastName($lastName) { if (empty($lastName)) throw new Exception('Lastname must be set and cannot be empty.'); $this->lastName = trim($lastName); return $this; }
[ "public", "function", "setLastName", "(", "$", "lastName", ")", "{", "if", "(", "empty", "(", "$", "lastName", ")", ")", "throw", "new", "Exception", "(", "'Lastname must be set and cannot be empty.'", ")", ";", "$", "this", "->", "lastName", "=", "trim", "(...
Sets the last name @since 1.0.0 @param string A string containing the family name @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "last", "name" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L339-L346
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setStreet
public function setStreet($street) { if (empty($street)) throw new Exception('Streetname must be set and cannot be empty.'); $this->street = trim($street); return $this; }
php
public function setStreet($street) { if (empty($street)) throw new Exception('Streetname must be set and cannot be empty.'); $this->street = trim($street); return $this; }
[ "public", "function", "setStreet", "(", "$", "street", ")", "{", "if", "(", "empty", "(", "$", "street", ")", ")", "throw", "new", "Exception", "(", "'Streetname must be set and cannot be empty.'", ")", ";", "$", "this", "->", "street", "=", "trim", "(", "...
Sets the streetname @since 1.0.0 @param string A string containing the streetname @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "streetname" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L356-L363
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setHouseNumber
public function setHouseNumber($houseNumber) { if (empty($houseNumber)) throw new Exception('Housenumber must be set and cannot be empty.'); $this->houseNumber = trim($houseNumber); return $this; }
php
public function setHouseNumber($houseNumber) { if (empty($houseNumber)) throw new Exception('Housenumber must be set and cannot be empty.'); $this->houseNumber = trim($houseNumber); return $this; }
[ "public", "function", "setHouseNumber", "(", "$", "houseNumber", ")", "{", "if", "(", "empty", "(", "$", "houseNumber", ")", ")", "throw", "new", "Exception", "(", "'Housenumber must be set and cannot be empty.'", ")", ";", "$", "this", "->", "houseNumber", "=",...
Sets the housenumber @since 1.0.0 @param string A string containing the housenumber @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "housenumber" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L373-L380
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setZipCode
public function setZipCode($zipCode) { if (empty($zipCode)) throw new Exception('Zipcode must be set and cannot be empty.'); $zipCode = str_replace(' ', '', $zipCode); $this->zipCode = trim($zipCode); return $this; }
php
public function setZipCode($zipCode) { if (empty($zipCode)) throw new Exception('Zipcode must be set and cannot be empty.'); $zipCode = str_replace(' ', '', $zipCode); $this->zipCode = trim($zipCode); return $this; }
[ "public", "function", "setZipCode", "(", "$", "zipCode", ")", "{", "if", "(", "empty", "(", "$", "zipCode", ")", ")", "throw", "new", "Exception", "(", "'Zipcode must be set and cannot be empty.'", ")", ";", "$", "zipCode", "=", "str_replace", "(", "' '", ",...
Sets the address zipcode @since 1.0.0 @param string A string containing the zipcode @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "address", "zipcode" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L403-L412
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setCity
public function setCity($city) { if (empty($city)) throw new Exception('City must be set and cannot be empty.'); $this->city = trim($city); return $this; }
php
public function setCity($city) { if (empty($city)) throw new Exception('City must be set and cannot be empty.'); $this->city = trim($city); return $this; }
[ "public", "function", "setCity", "(", "$", "city", ")", "{", "if", "(", "empty", "(", "$", "city", ")", ")", "throw", "new", "Exception", "(", "'City must be set and cannot be empty.'", ")", ";", "$", "this", "->", "city", "=", "trim", "(", "$", "city", ...
Sets the address city @since 1.0.0 @param string A string containing the cityname @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "address", "city" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L422-L429
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Address.setCountry
public function setCountry($country) { if (empty($country)) throw new Exception('Country must be set and cannot be empty.'); $this->country = trim($country); return $this; }
php
public function setCountry($country) { if (empty($country)) throw new Exception('Country must be set and cannot be empty.'); $this->country = trim($country); return $this; }
[ "public", "function", "setCountry", "(", "$", "country", ")", "{", "if", "(", "empty", "(", "$", "country", ")", ")", "throw", "new", "Exception", "(", "'Country must be set and cannot be empty.'", ")", ";", "$", "this", "->", "country", "=", "trim", "(", ...
Sets the country @since 1.0.0 @param string A string containing the countryname @return \Icepay_Order_Address @throws Exception when empty
[ "Sets", "the", "country" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L439-L446
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order_Consumer.setPhone
public function setPhone($phone) { $phone = trim(str_replace('-', '', $phone)); if (empty($phone)) throw new Exception('Phone must be set and cannot be empty.'); $this->phone = $phone; return $this; }
php
public function setPhone($phone) { $phone = trim(str_replace('-', '', $phone)); if (empty($phone)) throw new Exception('Phone must be set and cannot be empty.'); $this->phone = $phone; return $this; }
[ "public", "function", "setPhone", "(", "$", "phone", ")", "{", "$", "phone", "=", "trim", "(", "str_replace", "(", "'-'", ",", "''", ",", "$", "phone", ")", ")", ";", "if", "(", "empty", "(", "$", "phone", ")", ")", "throw", "new", "Exception", "...
Sets the consumer's phonenumber @since 1.0.0 @param string A string containing the consumer's phonenumber @return \Icepay_Order_Consumer @throws Exception when empty
[ "Sets", "the", "consumer", "s", "phonenumber" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L519-L528
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order.addProduct
public function addProduct(Icepay_Order_Product $obj) { if (!isset($this->_data["products"])) $this->_data["products"] = Array(); array_push($this->_data["products"], $obj); return $this; }
php
public function addProduct(Icepay_Order_Product $obj) { if (!isset($this->_data["products"])) $this->_data["products"] = Array(); array_push($this->_data["products"], $obj); return $this; }
[ "public", "function", "addProduct", "(", "Icepay_Order_Product", "$", "obj", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_data", "[", "\"products\"", "]", ")", ")", "$", "this", "->", "_data", "[", "\"products\"", "]", "=", "Array", "("...
Adds a product to the order @since 1.0.0 @param obj object containing the Icepay_Order_Product class @return \Icepay_Order
[ "Adds", "a", "product", "to", "the", "order" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L600-L605
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order.setOrderDiscountAmount
public function setOrderDiscountAmount($amount, $name = 'Discount', $description = 'Order Discount') { $obj = Icepay_Order_Product::create() ->setProductID('02') ->setProductName($name) ->setDescription($description) ->setQuantity('1') ->setUnitPrice(-$amount) ->setVATCategory(Icepay_Order_VAT::getCategoryForPercentage(-1)); $this->addProduct($obj); return $this; }
php
public function setOrderDiscountAmount($amount, $name = 'Discount', $description = 'Order Discount') { $obj = Icepay_Order_Product::create() ->setProductID('02') ->setProductName($name) ->setDescription($description) ->setQuantity('1') ->setUnitPrice(-$amount) ->setVATCategory(Icepay_Order_VAT::getCategoryForPercentage(-1)); $this->addProduct($obj); return $this; }
[ "public", "function", "setOrderDiscountAmount", "(", "$", "amount", ",", "$", "name", "=", "'Discount'", ",", "$", "description", "=", "'Order Discount'", ")", "{", "$", "obj", "=", "Icepay_Order_Product", "::", "create", "(", ")", "->", "setProductID", "(", ...
Sets the order discount @since 1.0.0 @param string $amount Contains the discount amount in cents @param string $name Contains the name of the discount @param string $description Contains description of the discount @return \Icepay_Order
[ "Sets", "the", "order", "discount" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L616-L628
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order.setShippingCosts
public function setShippingCosts($amount, $vat = -1, $name = 'Shipping Costs') { $obj = Icepay_Order_Product::create() ->setProductID('01') ->setProductName($name) ->setDescription('') ->setQuantity('1') ->setUnitPrice($amount) ->setVATCategory(Icepay_Order_VAT::getCategoryForPercentage($vat)); $this->addProduct($obj); return $this; }
php
public function setShippingCosts($amount, $vat = -1, $name = 'Shipping Costs') { $obj = Icepay_Order_Product::create() ->setProductID('01') ->setProductName($name) ->setDescription('') ->setQuantity('1') ->setUnitPrice($amount) ->setVATCategory(Icepay_Order_VAT::getCategoryForPercentage($vat)); $this->addProduct($obj); return $this; }
[ "public", "function", "setShippingCosts", "(", "$", "amount", ",", "$", "vat", "=", "-", "1", ",", "$", "name", "=", "'Shipping Costs'", ")", "{", "$", "obj", "=", "Icepay_Order_Product", "::", "create", "(", ")", "->", "setProductID", "(", "'01'", ")", ...
Sets the order shipping costs @since 1.0.0 @param string $amount Contains the shipping costs in cents @param int $vat Contains the VAT category in percentages @param string $name Contains the shipping name @return \Icepay_Order
[ "Sets", "the", "order", "shipping", "costs" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L639-L651
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order.validateOrder
public function validateOrder($paymentObj) { switch (strtoupper($paymentObj->getPaymentMethod())) { case 'AFTERPAY': if ($this->_data['shippingAddress']->country !== $this->_data['billingAddress']->country) throw new Exception('Billing and Shipping country must be equal in order to use Afterpay.'); if (!Icepay_Order_Helper::validateZipCode($this->_data['shippingAddress']->zipCode, $this->_data['shippingAddress']->country)) throw new Exception('Zipcode format for shipping address is incorrect.'); if (!Icepay_Order_Helper::validateZipCode($this->_data['billingAddress']->zipCode, $this->_data['billingAddress']->country)) throw new Exception('Zipcode format for billing address is incorrect.'); if (!Icepay_Order_Helper::validatePhonenumber($this->_data['consumer']->phone)) throw new Exception('Phonenumber is incorrect.'); break; } }
php
public function validateOrder($paymentObj) { switch (strtoupper($paymentObj->getPaymentMethod())) { case 'AFTERPAY': if ($this->_data['shippingAddress']->country !== $this->_data['billingAddress']->country) throw new Exception('Billing and Shipping country must be equal in order to use Afterpay.'); if (!Icepay_Order_Helper::validateZipCode($this->_data['shippingAddress']->zipCode, $this->_data['shippingAddress']->country)) throw new Exception('Zipcode format for shipping address is incorrect.'); if (!Icepay_Order_Helper::validateZipCode($this->_data['billingAddress']->zipCode, $this->_data['billingAddress']->country)) throw new Exception('Zipcode format for billing address is incorrect.'); if (!Icepay_Order_Helper::validatePhonenumber($this->_data['consumer']->phone)) throw new Exception('Phonenumber is incorrect.'); break; } }
[ "public", "function", "validateOrder", "(", "$", "paymentObj", ")", "{", "switch", "(", "strtoupper", "(", "$", "paymentObj", "->", "getPaymentMethod", "(", ")", ")", ")", "{", "case", "'AFTERPAY'", ":", "if", "(", "$", "this", "->", "_data", "[", "'ship...
Validates the Order <p>Validates the order information based on the paymentmethod and country used</p> <p>For example Afterpay, it will check the zipcodes and it makes sure that the billing and shipping address are in the same country</p> @param obj $paymentObj @throws Exception
[ "Validates", "the", "Order" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L662-L679
train
ICEPAY/deprecated-i
src/icepay_api_order.php
Icepay_Order.createXML
public function createXML() { $this->_orderData = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Order></Order>"); $this->_consumerNode = $this->_orderData->addChild('Consumer'); $this->_addressesNode = $this->_orderData->addChild('Addresses'); $this->_productsNode = $this->_orderData->addChild('Products'); // Set Consumer $this->array_to_xml($this->_data['consumer'], $this->_consumerNode); // Set Addresses $shippingNode = $this->_addressesNode->addChild('Address'); $shippingNode->addAttribute('id', 'shipping'); $this->array_to_xml($this->_data['shippingAddress'], $shippingNode); $billingNode = $this->_addressesNode->addChild('Address'); $billingNode->addAttribute('id', 'billing'); $this->array_to_xml($this->_data['billingAddress'], $billingNode); // Set Products foreach ($this->_data['products'] as $product) { $productNode = $this->_productsNode->addChild('Product'); $this->array_to_xml($product, $productNode); } if ($this->_debug == true) { header("Content-type: text/xml"); echo $this->_orderData->asXML(); exit; } return $this->_orderData->asXML(); }
php
public function createXML() { $this->_orderData = new SimpleXMLElement("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Order></Order>"); $this->_consumerNode = $this->_orderData->addChild('Consumer'); $this->_addressesNode = $this->_orderData->addChild('Addresses'); $this->_productsNode = $this->_orderData->addChild('Products'); // Set Consumer $this->array_to_xml($this->_data['consumer'], $this->_consumerNode); // Set Addresses $shippingNode = $this->_addressesNode->addChild('Address'); $shippingNode->addAttribute('id', 'shipping'); $this->array_to_xml($this->_data['shippingAddress'], $shippingNode); $billingNode = $this->_addressesNode->addChild('Address'); $billingNode->addAttribute('id', 'billing'); $this->array_to_xml($this->_data['billingAddress'], $billingNode); // Set Products foreach ($this->_data['products'] as $product) { $productNode = $this->_productsNode->addChild('Product'); $this->array_to_xml($product, $productNode); } if ($this->_debug == true) { header("Content-type: text/xml"); echo $this->_orderData->asXML(); exit; } return $this->_orderData->asXML(); }
[ "public", "function", "createXML", "(", ")", "{", "$", "this", "->", "_orderData", "=", "new", "SimpleXMLElement", "(", "\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><Order></Order>\"", ")", ";", "$", "this", "->", "_consumerNode", "=", "$", "this", "->", "_o...
Generates the XML for the webservice @since 1.0.0 @return XML
[ "Generates", "the", "XML", "for", "the", "webservice" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_order.php#L697-L731
train
ems-project/EMSCommonBundle
Storage/Processor/Processor.php
Processor.process
public function process(string $processor, string $assetHash, array $options = []): Config { $config = $this->getConfig($processor, $assetHash, $options); $lastCacheDate = $this->storageManager->getLastCacheDate($config->getCacheKey(), $processor); if (!$config->isValid($lastCacheDate)) { $this->generate($config); } return $config; }
php
public function process(string $processor, string $assetHash, array $options = []): Config { $config = $this->getConfig($processor, $assetHash, $options); $lastCacheDate = $this->storageManager->getLastCacheDate($config->getCacheKey(), $processor); if (!$config->isValid($lastCacheDate)) { $this->generate($config); } return $config; }
[ "public", "function", "process", "(", "string", "$", "processor", ",", "string", "$", "assetHash", ",", "array", "$", "options", "=", "[", "]", ")", ":", "Config", "{", "$", "config", "=", "$", "this", "->", "getConfig", "(", "$", "processor", ",", "...
Called from twig function, the config is used for generating the url
[ "Called", "from", "twig", "function", "the", "config", "is", "used", "for", "generating", "the", "url" ]
994fce2f727ebf702d327ba4cfce53d3c75bcef5
https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Storage/Processor/Processor.php#L125-L136
train
SIELOnline/libAcumulus
src/OpenCart/Config/ShopCapabilities.php
ShopCapabilities.paymentMethodToOptions
protected function paymentMethodToOptions(array $extensions) { $results = array(); $registry = $this->getRegistry(); $directory = !$registry->isOc1() ? 'extension/payment/' : 'payment/'; foreach ($extensions as $extension) { $registry->language->load($directory . $extension); $results[$extension] = $registry->language->get('heading_title'); } return $results; }
php
protected function paymentMethodToOptions(array $extensions) { $results = array(); $registry = $this->getRegistry(); $directory = !$registry->isOc1() ? 'extension/payment/' : 'payment/'; foreach ($extensions as $extension) { $registry->language->load($directory . $extension); $results[$extension] = $registry->language->get('heading_title'); } return $results; }
[ "protected", "function", "paymentMethodToOptions", "(", "array", "$", "extensions", ")", "{", "$", "results", "=", "array", "(", ")", ";", "$", "registry", "=", "$", "this", "->", "getRegistry", "(", ")", ";", "$", "directory", "=", "!", "$", "registry",...
Turns the list into a translated list of options for a select. @param array $extensions @return array an array with the extensions as key and their translated name as value.
[ "Turns", "the", "list", "into", "a", "translated", "list", "of", "options", "for", "a", "select", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Config/ShopCapabilities.php#L339-L349
train
SIELOnline/libAcumulus
src/Joomla/VirtueMart/Invoice/Creator.php
Creator.getCouponCodeDiscountLine
protected function getCouponCodeDiscountLine() { $result = array( Tag::ItemNumber => $this->order['details']['BT']->coupon_code, Tag::Product => $this->t('discount'), Tag::Quantity => 1, Meta::UnitPriceInc => (float) $this->order['details']['BT']->coupon_discount, Tag::VatRate => null, Meta::VatRateSource => static::VatRateSource_Strategy, Meta::StrategySplit => true, ); return $result; }
php
protected function getCouponCodeDiscountLine() { $result = array( Tag::ItemNumber => $this->order['details']['BT']->coupon_code, Tag::Product => $this->t('discount'), Tag::Quantity => 1, Meta::UnitPriceInc => (float) $this->order['details']['BT']->coupon_discount, Tag::VatRate => null, Meta::VatRateSource => static::VatRateSource_Strategy, Meta::StrategySplit => true, ); return $result; }
[ "protected", "function", "getCouponCodeDiscountLine", "(", ")", "{", "$", "result", "=", "array", "(", "Tag", "::", "ItemNumber", "=>", "$", "this", "->", "order", "[", "'details'", "]", "[", "'BT'", "]", "->", "coupon_code", ",", "Tag", "::", "Product", ...
Returns an item line for the coupon code discount on this order. @return array An item line array.
[ "Returns", "an", "item", "line", "for", "the", "coupon", "code", "discount", "on", "this", "order", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Joomla/VirtueMart/Invoice/Creator.php#L357-L370
train
SIELOnline/libAcumulus
src/Joomla/VirtueMart/Invoice/Creator.php
Creator.getCalcRule
protected function getCalcRule($calcKind, $orderItemId = 0) { foreach ($this->order['calc_rules'] as $calcRule) { if ($calcRule->calc_kind == $calcKind) { if (empty($orderItemId) || $calcRule->virtuemart_order_item_id == $orderItemId) { return $calcRule; } } } return null; }
php
protected function getCalcRule($calcKind, $orderItemId = 0) { foreach ($this->order['calc_rules'] as $calcRule) { if ($calcRule->calc_kind == $calcKind) { if (empty($orderItemId) || $calcRule->virtuemart_order_item_id == $orderItemId) { return $calcRule; } } } return null; }
[ "protected", "function", "getCalcRule", "(", "$", "calcKind", ",", "$", "orderItemId", "=", "0", ")", "{", "foreach", "(", "$", "this", "->", "order", "[", "'calc_rules'", "]", "as", "$", "calcRule", ")", "{", "if", "(", "$", "calcRule", "->", "calc_ki...
Returns a calculation rule identified by the given reference @param string $calcKind The value for the kind of calc rule. @param int $orderItemId The value for the order item id, or 0 for special lines. @return null|object The (1st) calculation rule for the given reference, or null if none found.
[ "Returns", "a", "calculation", "rule", "identified", "by", "the", "given", "reference" ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Joomla/VirtueMart/Invoice/Creator.php#L418-L428
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.setProperty
public function setProperty($property, $value) { if (property_exists($this, $property) && $property !== 'form') { $this->$property = $value; } return $this; }
php
public function setProperty($property, $value) { if (property_exists($this, $property) && $property !== 'form') { $this->$property = $value; } return $this; }
[ "public", "function", "setProperty", "(", "$", "property", ",", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "property", ")", "&&", "$", "property", "!==", "'form'", ")", "{", "$", "this", "->", "$", "property", "...
Sets the value of a property of this object. The property must exist as property @param string $property @param mixed $value @return $this
[ "Sets", "the", "value", "of", "a", "property", "of", "this", "object", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L171-L177
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderFields
protected function renderFields(array $fields) { $output = ''; foreach ($fields as $id => $field) { // Add defaults. $field += array( 'id' => $id, 'name' => $id, 'label' => '', 'value' => '', 'description' => '', 'attributes' => array(), 'options' => array(), ); $output .= $this->renderField($field); } return $output; }
php
protected function renderFields(array $fields) { $output = ''; foreach ($fields as $id => $field) { // Add defaults. $field += array( 'id' => $id, 'name' => $id, 'label' => '', 'value' => '', 'description' => '', 'attributes' => array(), 'options' => array(), ); $output .= $this->renderField($field); } return $output; }
[ "protected", "function", "renderFields", "(", "array", "$", "fields", ")", "{", "$", "output", "=", "''", ";", "foreach", "(", "$", "fields", "as", "$", "id", "=>", "$", "field", ")", "{", "// Add defaults.", "$", "field", "+=", "array", "(", "'id'", ...
Renders a set of field definitions. @param array[] $fields @return string
[ "Renders", "a", "set", "of", "field", "definitions", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L204-L221
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderFieldset
protected function renderFieldset(array $field) { $output = ''; $output .= $this->fieldsetBegin($field); $output .= $this->renderFields($field['fields']); $output .= $this->fieldsetEnd($field); return $output; }
php
protected function renderFieldset(array $field) { $output = ''; $output .= $this->fieldsetBegin($field); $output .= $this->renderFields($field['fields']); $output .= $this->fieldsetEnd($field); return $output; }
[ "protected", "function", "renderFieldset", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "fieldsetBegin", "(", "$", "field", ")", ";", "$", "output", ".=", "$", "this", "->", "renderFields"...
Renders a fieldset or details form element. @param array $field @return string The rendered fieldset or details form element.
[ "Renders", "a", "fieldset", "or", "details", "form", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L248-L255
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.fieldsetBegin
protected function fieldsetBegin(array $field) { $output = ''; $output .= $this->getWrapper($field['type'], $field['attributes']); $titleTag = $field['type'] === 'fieldset' ? 'legend' : 'summary'; if (!empty($field[$titleTag])) { $output .= $this->getWrapper($titleTag, $field['attributes']); $output .= $field[$titleTag]; $output .= $this->getWrapperEnd($titleTag); } $output .= $this->getWrapper('fieldsetContent'); if (!empty($field['description'])) { $output .= $this->renderDescription($field['description'], true); } return $output; }
php
protected function fieldsetBegin(array $field) { $output = ''; $output .= $this->getWrapper($field['type'], $field['attributes']); $titleTag = $field['type'] === 'fieldset' ? 'legend' : 'summary'; if (!empty($field[$titleTag])) { $output .= $this->getWrapper($titleTag, $field['attributes']); $output .= $field[$titleTag]; $output .= $this->getWrapperEnd($titleTag); } $output .= $this->getWrapper('fieldsetContent'); if (!empty($field['description'])) { $output .= $this->renderDescription($field['description'], true); } return $output; }
[ "protected", "function", "fieldsetBegin", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "$", "field", "[", "'type'", "]", ",", "$", "field", "[", "'attributes'", "]", "...
Outputs the beginning of a fieldset. @param array $field @return string
[ "Outputs", "the", "beginning", "of", "a", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L264-L279
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.fieldsetEnd
protected function fieldsetEnd(array $field) { $output = ''; $output .= $this->getWrapperEnd('fieldsetContent'); $output .= $this->getWrapperEnd($field['type']); return $output; }
php
protected function fieldsetEnd(array $field) { $output = ''; $output .= $this->getWrapperEnd('fieldsetContent'); $output .= $this->getWrapperEnd($field['type']); return $output; }
[ "protected", "function", "fieldsetEnd", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "getWrapperEnd", "(", "'fieldsetContent'", ")", ";", "$", "output", ".=", "$", "this", "->", "getWrapperE...
Outputs the end of a fieldset. @param array $field @return string
[ "Outputs", "the", "end", "of", "a", "fieldset", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L288-L294
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderSimpleField
protected function renderSimpleField(array $field) { if (!empty($field['ajax'])) { $field = $this->addAjax($field); } $output = ''; // Split attributes over label and element. $attributes = $field['attributes']; $labelAttributes = array(); if (!empty($attributes['label'])) { $labelAttributes = $attributes['label']; unset($attributes['label']); } if (!empty($attributes['required'])) { $labelAttributes['required'] = $attributes['required']; } $field['attributes'] = $attributes; if ($field['type'] !== 'hidden') { $output .= $this->getWrapper('element'); // Do not use a <label> with an "id" attribute on the label for a // set of radio buttons, a set of checkboxes, or on markup. $id = in_array($field['type'], array('radio', 'checkbox', 'markup')) ? '' : $field['id']; $output .= $this->renderLabel($field['label'], $id, $labelAttributes, true); $output .= $this->getWrapper('inputDescription'); } $output .= $this->renderElement($field); if ($field['type'] !== 'hidden') { $output .= $this->renderDescription($field['description']); $output .= $this->getWrapperEnd('inputDescription'); $output .= $this->getWrapperEnd('element'); } return $output; }
php
protected function renderSimpleField(array $field) { if (!empty($field['ajax'])) { $field = $this->addAjax($field); } $output = ''; // Split attributes over label and element. $attributes = $field['attributes']; $labelAttributes = array(); if (!empty($attributes['label'])) { $labelAttributes = $attributes['label']; unset($attributes['label']); } if (!empty($attributes['required'])) { $labelAttributes['required'] = $attributes['required']; } $field['attributes'] = $attributes; if ($field['type'] !== 'hidden') { $output .= $this->getWrapper('element'); // Do not use a <label> with an "id" attribute on the label for a // set of radio buttons, a set of checkboxes, or on markup. $id = in_array($field['type'], array('radio', 'checkbox', 'markup')) ? '' : $field['id']; $output .= $this->renderLabel($field['label'], $id, $labelAttributes, true); $output .= $this->getWrapper('inputDescription'); } $output .= $this->renderElement($field); if ($field['type'] !== 'hidden') { $output .= $this->renderDescription($field['description']); $output .= $this->getWrapperEnd('inputDescription'); $output .= $this->getWrapperEnd('element'); } return $output; }
[ "protected", "function", "renderSimpleField", "(", "array", "$", "field", ")", "{", "if", "(", "!", "empty", "(", "$", "field", "[", "'ajax'", "]", ")", ")", "{", "$", "field", "=", "$", "this", "->", "addAjax", "(", "$", "field", ")", ";", "}", ...
Renders a form field including its label and description. @param array $field @return string Html for this form field.
[ "Renders", "a", "form", "field", "including", "its", "label", "and", "description", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L304-L339
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderElement
protected function renderElement($field) { $type = $field['type']; switch ($type) { case 'textarea': case 'markup': case 'select': case 'radio': case 'checkbox': return $this->$type($field); default: return $this->input($field); } }
php
protected function renderElement($field) { $type = $field['type']; switch ($type) { case 'textarea': case 'markup': case 'select': case 'radio': case 'checkbox': return $this->$type($field); default: return $this->input($field); } }
[ "protected", "function", "renderElement", "(", "$", "field", ")", "{", "$", "type", "=", "$", "field", "[", "'type'", "]", ";", "switch", "(", "$", "type", ")", "{", "case", "'textarea'", ":", "case", "'markup'", ":", "case", "'select'", ":", "case", ...
Renders a form field itself, ie without label and description. @param $field @return string The html for the form element.
[ "Renders", "a", "form", "field", "itself", "ie", "without", "label", "and", "description", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L349-L362
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderDescription
protected function renderDescription($text, $isFieldset = false) { $output = ''; // Help text. if (!empty($text)) { // Allow for links in the help text, so no filtering anymore. $wrapperType = $isFieldset ? 'fieldsetDescription' : 'description'; $output .= $this->getWrapper($wrapperType); $output .= $text; $output .= $this->getWrapperEnd($wrapperType); } return $output; }
php
protected function renderDescription($text, $isFieldset = false) { $output = ''; // Help text. if (!empty($text)) { // Allow for links in the help text, so no filtering anymore. $wrapperType = $isFieldset ? 'fieldsetDescription' : 'description'; $output .= $this->getWrapper($wrapperType); $output .= $text; $output .= $this->getWrapperEnd($wrapperType); } return $output; }
[ "protected", "function", "renderDescription", "(", "$", "text", ",", "$", "isFieldset", "=", "false", ")", "{", "$", "output", "=", "''", ";", "// Help text.", "if", "(", "!", "empty", "(", "$", "text", ")", ")", "{", "// Allow for links in the help text, so...
Renders a descriptive help text. @param string $text @param bool $isFieldset @return string The rendered description.
[ "Renders", "a", "descriptive", "help", "text", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L373-L387
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderLabel
protected function renderLabel($text, $id, array $attributes, $wrapLabel, $prefix = '', $postfix = '') { $output = ''; // Split attributes over label and wrapper. $wrapperAttributes = array(); if (!empty($attributes['wrapper'])) { $wrapperAttributes = $attributes['wrapper']; unset($attributes['wrapper']); } if (!empty($attributes['required'])) { $wrapperAttributes['required'] = $attributes['required']; } // Tag around main labels. if ($wrapLabel) { $output .= $this->getWrapper('label', $wrapperAttributes); } // Label. $attributes = $this->addLabelAttributes($attributes, $id); $postfix .= !empty($attributes['required']) ? $this->requiredMarkup : ''; $tag = empty($id) ? $this->multiLabelTag : 'label'; $output .= $this->getOpenTag($tag, $attributes); $output .= $prefix . htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8') . $postfix; $output .= $this->getCloseTag($tag); // Tag around labels. if ($wrapLabel) { $output .= $this->getWrapperEnd('label'); } return $output; }
php
protected function renderLabel($text, $id, array $attributes, $wrapLabel, $prefix = '', $postfix = '') { $output = ''; // Split attributes over label and wrapper. $wrapperAttributes = array(); if (!empty($attributes['wrapper'])) { $wrapperAttributes = $attributes['wrapper']; unset($attributes['wrapper']); } if (!empty($attributes['required'])) { $wrapperAttributes['required'] = $attributes['required']; } // Tag around main labels. if ($wrapLabel) { $output .= $this->getWrapper('label', $wrapperAttributes); } // Label. $attributes = $this->addLabelAttributes($attributes, $id); $postfix .= !empty($attributes['required']) ? $this->requiredMarkup : ''; $tag = empty($id) ? $this->multiLabelTag : 'label'; $output .= $this->getOpenTag($tag, $attributes); $output .= $prefix . htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8') . $postfix; $output .= $this->getCloseTag($tag); // Tag around labels. if ($wrapLabel) { $output .= $this->getWrapperEnd('label'); } return $output; }
[ "protected", "function", "renderLabel", "(", "$", "text", ",", "$", "id", ",", "array", "$", "attributes", ",", "$", "wrapLabel", ",", "$", "prefix", "=", "''", ",", "$", "postfix", "=", "''", ")", "{", "$", "output", "=", "''", ";", "// Split attrib...
Renders a label. @param string $text The label text. @param string $id The value of the for attribute. If the empty string, not a label tag but a span with a class="label" will be rendered. @param array $attributes Any additional attributes to render for the label. The array is a keyed array, the keys being the attribute names, the values being the value of that attribute. If that value is an array it is rendered as a joined string of the values separated by a space (e.g. multiple classes). @param bool $wrapLabel Whether to wrap this label within the defined label wrapper tag. @param string $prefix Prefix to prepend to the label text, may contain html, so don't escape. Will come from code not users. @param string $postfix Postfix to append to the label text, may contain html, so don't escape. Will come from code not users. @return string The rendered label. The rendered label.
[ "Renders", "a", "label", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L414-L446
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.input
protected function input(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'type', $field['type']); $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $attributes = $this->addAttribute($attributes, 'value', $field['value']); $output .= $this->getOpenTag('input', $attributes, true); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function input(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'type', $field['type']); $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $attributes = $this->addAttribute($attributes, 'value', $field['value']); $output .= $this->getOpenTag('input', $attributes, true); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "input", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Tag around input element.", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ")", ";", "$", "attributes", "=", "$", "field", "...
Renders an input field. @param array $field @return string The rendered input field.
[ "Renders", "an", "input", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L456-L474
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.textarea
protected function textarea(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('textarea', $attributes); $output .= htmlspecialchars($field['value'], $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('textarea'); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function textarea(array $field) { $output = ''; // Tag around input element. $output .= $this->getWrapper('input'); $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('textarea', $attributes); $output .= htmlspecialchars($field['value'], $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('textarea'); // Tag around input element. $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "textarea", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Tag around input element.", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ")", ";", "$", "attributes", "=", "$", "field", ...
Renders a textarea field. @param $field @return string The rendered textarea field.
[ "Renders", "a", "textarea", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L484-L501
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.select
protected function select(array $field) { $output = ''; // Tag around select element: same as for an input element. $output .= $this->getWrapper('input'); // Select tag. $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('select', $attributes); // Options. foreach ($field['options'] as $value => $text) { $optionAttributes = array('value' => $value); if ($this->isOptionSelected($field['value'], $value)) { $optionAttributes['selected'] = true; } $output .= $this->getOpenTag('option', $optionAttributes); $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('option'); } // End tag. $output .= $this->getCloseTag('select'); // Tag around select element. $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function select(array $field) { $output = ''; // Tag around select element: same as for an input element. $output .= $this->getWrapper('input'); // Select tag. $attributes = $field['attributes']; $attributes = $this->addAttribute($attributes, 'id', $field['id']); $attributes = $this->addAttribute($attributes, 'name', $field['name']); $output .= $this->getOpenTag('select', $attributes); // Options. foreach ($field['options'] as $value => $text) { $optionAttributes = array('value' => $value); if ($this->isOptionSelected($field['value'], $value)) { $optionAttributes['selected'] = true; } $output .= $this->getOpenTag('option', $optionAttributes); $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8'); $output .= $this->getCloseTag('option'); } // End tag. $output .= $this->getCloseTag('select'); // Tag around select element. $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "select", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Tag around select element: same as for an input element.", "$", "output", ".=", "$", "this", "->", "getWrapper", "(", "'input'", ")", ";", "// Select tag.",...
Renders a select element. @param array $field @return string The rendered select element.
[ "Renders", "a", "select", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L531-L561
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.checkbox
protected function checkbox(array $field) { $output = ''; // Div tag. $attributes = $field['attributes']; //? unset($attributes['required']); $output .= $this->getWrapper('input', $attributes); $output .= $this->getWrapper('checkbox', $attributes); // Checkboxes. foreach ($field['options'] as $value => $text) { $checkboxAttributes = $this->getCheckboxAttributes($field['id'], $field['name'], $value); if (in_array($value, $field['value'], false)) { $checkboxAttributes['checked'] = true; } $output .= $this->getWrapper('checkbox1'); $checkboxInput = $this->getOpenTag('input', $checkboxAttributes); if ($this->checkboxInputInLabel) { $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false, $checkboxInput); } else { $output .= $checkboxInput; $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false); } $output .= $this->getWrapperEnd('checkbox1'); } // End tag. $output .= $this->getWrapperEnd('checkbox'); $output .= $this->getWrapperEnd('input'); return $output; }
php
protected function checkbox(array $field) { $output = ''; // Div tag. $attributes = $field['attributes']; //? unset($attributes['required']); $output .= $this->getWrapper('input', $attributes); $output .= $this->getWrapper('checkbox', $attributes); // Checkboxes. foreach ($field['options'] as $value => $text) { $checkboxAttributes = $this->getCheckboxAttributes($field['id'], $field['name'], $value); if (in_array($value, $field['value'], false)) { $checkboxAttributes['checked'] = true; } $output .= $this->getWrapper('checkbox1'); $checkboxInput = $this->getOpenTag('input', $checkboxAttributes); if ($this->checkboxInputInLabel) { $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false, $checkboxInput); } else { $output .= $checkboxInput; $output .= $this->renderLabel($text, $checkboxAttributes['id'], array(), false); } $output .= $this->getWrapperEnd('checkbox1'); } // End tag. $output .= $this->getWrapperEnd('checkbox'); $output .= $this->getWrapperEnd('input'); return $output; }
[ "protected", "function", "checkbox", "(", "array", "$", "field", ")", "{", "$", "output", "=", "''", ";", "// Div tag.", "$", "attributes", "=", "$", "field", "[", "'attributes'", "]", ";", "//? unset($attributes['required']);", "$", "output", ".=", "$"...
Renders a list of checkboxes. @param array $field @return string The rendered checkboxes.
[ "Renders", "a", "list", "of", "checkboxes", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L619-L652
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.getWrapper
protected function getWrapper($type, array $attributes = array()) { $tag = "{$type}WrapperTag"; $class = "{$type}WrapperClass"; $output = ''; if (!empty($this->$tag)) { if (!empty($this->$class)) { $attributes = $this->addAttribute($attributes, 'class', $this->$class); } $output .= $this->getOpenTag($this->$tag, $attributes); } return $output; }
php
protected function getWrapper($type, array $attributes = array()) { $tag = "{$type}WrapperTag"; $class = "{$type}WrapperClass"; $output = ''; if (!empty($this->$tag)) { if (!empty($this->$class)) { $attributes = $this->addAttribute($attributes, 'class', $this->$class); } $output .= $this->getOpenTag($this->$tag, $attributes); } return $output; }
[ "protected", "function", "getWrapper", "(", "$", "type", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "tag", "=", "\"{$type}WrapperTag\"", ";", "$", "class", "=", "\"{$type}WrapperClass\"", ";", "$", "output", "=", "''", ";", "...
Returns the open tag for a wrapper element. @param string $type @param array $attributes @return string
[ "Returns", "the", "open", "tag", "for", "a", "wrapper", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L662-L674
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.getWrapperEnd
protected function getWrapperEnd($type) { $tag = "{$type}WrapperTag"; $output = ''; if (!empty($this->$tag)) { $output .= $this->getCloseTag($this->$tag); } return $output; }
php
protected function getWrapperEnd($type) { $tag = "{$type}WrapperTag"; $output = ''; if (!empty($this->$tag)) { $output .= $this->getCloseTag($this->$tag); } return $output; }
[ "protected", "function", "getWrapperEnd", "(", "$", "type", ")", "{", "$", "tag", "=", "\"{$type}WrapperTag\"", ";", "$", "output", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "$", "tag", ")", ")", "{", "$", "output", ".=", "$"...
Returns the closing tag for a wrapper element. @param string $type @return string
[ "Returns", "the", "closing", "tag", "for", "a", "wrapper", "element", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L683-L691
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.getOpenTag
protected function getOpenTag($tag, array $attributes = array(), $selfClosing = false) { return '<' . htmlspecialchars($tag, ENT_QUOTES, 'ISO-8859-1') . $this->renderAttributes($attributes) . ($selfClosing && !$this->html5 ? '/' : '') . '>'; }
php
protected function getOpenTag($tag, array $attributes = array(), $selfClosing = false) { return '<' . htmlspecialchars($tag, ENT_QUOTES, 'ISO-8859-1') . $this->renderAttributes($attributes) . ($selfClosing && !$this->html5 ? '/' : '') . '>'; }
[ "protected", "function", "getOpenTag", "(", "$", "tag", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "selfClosing", "=", "false", ")", "{", "return", "'<'", ".", "htmlspecialchars", "(", "$", "tag", ",", "ENT_QUOTES", ",", "'ISO-885...
Returns a secured html open tag string. @param string $tag The html tag. @param array $attributes The attributes to render. @param bool $selfClosing Whether the tag is self closing. Only in html4 this will add a / character before the closing > character. @return string The rendered open tag.
[ "Returns", "a", "secured", "html", "open", "tag", "string", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L707-L710
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.renderAttributes
protected function renderAttributes(array $attributes) { $attributeString = ''; foreach ($attributes as $key => $value) { if (is_array($value)) { $value = implode(' ', $value); } // Skip attributes that are not to be set (required, disabled, ...). if ($value !== false && $value !== '') { $attributeString .= ' ' . htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); // HTML5: do not add a value to boolean attributes. // HTML4: add the name of the key as value for the attribute. if (!$this->html5 && $value === true) { $value = $key; } if ($value !== true) { $attributeString .= '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"'; } } } return $attributeString; }
php
protected function renderAttributes(array $attributes) { $attributeString = ''; foreach ($attributes as $key => $value) { if (is_array($value)) { $value = implode(' ', $value); } // Skip attributes that are not to be set (required, disabled, ...). if ($value !== false && $value !== '') { $attributeString .= ' ' . htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); // HTML5: do not add a value to boolean attributes. // HTML4: add the name of the key as value for the attribute. if (!$this->html5 && $value === true) { $value = $key; } if ($value !== true) { $attributeString .= '="' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . '"'; } } } return $attributeString; }
[ "protected", "function", "renderAttributes", "(", "array", "$", "attributes", ")", "{", "$", "attributeString", "=", "''", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ...
Renders a list of attributes. @param array $attributes @return string html string with the rendered attributes and 1 space in front of it.
[ "Renders", "a", "list", "of", "attributes", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L734-L755
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.addLabelAttributes
protected function addLabelAttributes(array $attributes, $id) { $attributes = $this->addAttribute($attributes, 'for', $id); if (empty($id)) { $attributes = $this->addAttribute($attributes, 'class', $this->multiLabelClass); } return $attributes; }
php
protected function addLabelAttributes(array $attributes, $id) { $attributes = $this->addAttribute($attributes, 'for', $id); if (empty($id)) { $attributes = $this->addAttribute($attributes, 'class', $this->multiLabelClass); } return $attributes; }
[ "protected", "function", "addLabelAttributes", "(", "array", "$", "attributes", ",", "$", "id", ")", "{", "$", "attributes", "=", "$", "this", "->", "addAttribute", "(", "$", "attributes", ",", "'for'", ",", "$", "id", ")", ";", "if", "(", "empty", "("...
Adds a set of attributes specific for a label. @param array $attributes @param string $id @return array
[ "Adds", "a", "set", "of", "attributes", "specific", "for", "a", "label", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L812-L819
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.isOptionSelected
protected function isOptionSelected($selectedValues, $option) { return is_array($selectedValues) ? in_array((string) $option, $selectedValues,false) : (string) $option === (string) $selectedValues; }
php
protected function isOptionSelected($selectedValues, $option) { return is_array($selectedValues) ? in_array((string) $option, $selectedValues,false) : (string) $option === (string) $selectedValues; }
[ "protected", "function", "isOptionSelected", "(", "$", "selectedValues", ",", "$", "option", ")", "{", "return", "is_array", "(", "$", "selectedValues", ")", "?", "in_array", "(", "(", "string", ")", "$", "option", ",", "$", "selectedValues", ",", "false", ...
Returns whether an option is part of a set of selected values. @param string|int|array $selectedValues The set of selected values, may be just 1 scalar value. @param string|int $option The option to search for in the set of selected values. @return bool If this option is part of the selected values.
[ "Returns", "whether", "an", "option", "is", "part", "of", "a", "set", "of", "selected", "values", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L872-L875
train
SIELOnline/libAcumulus
src/Helpers/FormRenderer.php
FormRenderer.addAjax
protected function addAjax(array $field) { // We add a class so this element can be recognised by js as having an // ajax action. $field['attributes'] = $this->addAttribute($field['attributes'], 'class', 'acumulus-ajax'); // Add the data`-* attributes. if (!empty($field['ajax']) && is_array($field['ajax'])) { foreach ($field['ajax'] as $dataName => $dataValue) { $field['attributes'] = $this->addAttribute($field['attributes'], 'data-acumulus-' . $dataName, $dataValue); } } return $field; }
php
protected function addAjax(array $field) { // We add a class so this element can be recognised by js as having an // ajax action. $field['attributes'] = $this->addAttribute($field['attributes'], 'class', 'acumulus-ajax'); // Add the data`-* attributes. if (!empty($field['ajax']) && is_array($field['ajax'])) { foreach ($field['ajax'] as $dataName => $dataValue) { $field['attributes'] = $this->addAttribute($field['attributes'], 'data-acumulus-' . $dataName, $dataValue); } } return $field; }
[ "protected", "function", "addAjax", "(", "array", "$", "field", ")", "{", "// We add a class so this element can be recognised by js as having an", "// ajax action.", "$", "field", "[", "'attributes'", "]", "=", "$", "this", "->", "addAttribute", "(", "$", "field", "[...
Processes the ajax setting on a field. The ajax setting is typically an array with data values to be added as data-* attributes tot he fom element. @param array $field The field for which an ajax action is to be enabled. @return array The field with ajax settings mapped to additional attributes.
[ "Processes", "the", "ajax", "setting", "on", "a", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/FormRenderer.php#L889-L903
train
SIELOnline/libAcumulus
src/Invoice/CompletorStrategy/ApplySameVatRate.php
ApplySameVatRate.tryVatRate
protected function tryVatRate($vatRate) { $this->description = "ApplySameVatRate($vatRate)"; $this->replacingLines = array(); $vatAmount = 0.0; foreach ($this->lines2Complete as $line2Complete) { $vatAmount += $this->completeLine($line2Complete, $vatRate); } $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategy . $this->getName()] = "tryVatRate($vatRate): $vatAmount"; // If the vat totals are equal, the strategy worked. // We allow for a reasonable margin, as rounding errors may add up. return Number::floatsAreEqual($vatAmount, $this->vat2Divide, 0.04); }
php
protected function tryVatRate($vatRate) { $this->description = "ApplySameVatRate($vatRate)"; $this->replacingLines = array(); $vatAmount = 0.0; foreach ($this->lines2Complete as $line2Complete) { $vatAmount += $this->completeLine($line2Complete, $vatRate); } $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategy . $this->getName()] = "tryVatRate($vatRate): $vatAmount"; // If the vat totals are equal, the strategy worked. // We allow for a reasonable margin, as rounding errors may add up. return Number::floatsAreEqual($vatAmount, $this->vat2Divide, 0.04); }
[ "protected", "function", "tryVatRate", "(", "$", "vatRate", ")", "{", "$", "this", "->", "description", "=", "\"ApplySameVatRate($vatRate)\"", ";", "$", "this", "->", "replacingLines", "=", "array", "(", ")", ";", "$", "vatAmount", "=", "0.0", ";", "foreach"...
Tries 1 of the possible vat rates. @param float $vatRate @return bool
[ "Tries", "1", "of", "the", "possible", "vat", "rates", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategy/ApplySameVatRate.php#L58-L71
train
SIELOnline/libAcumulus
src/WooCommerce/Helpers/Token.php
Token.getDataValue
protected function getDataValue(array $data, $property) { $value = null; if (array_key_exists($property, $data)) { // Found: return the value. $value = $data[$property]; } else { // Not found: check in meta data or descend recursively. if (isset($data['meta_data'])) { $value = $this->getMetaDataValue($data['meta_data'], $property); } if ($value === null) { // Not found in meta_data: check if we should descend a level. $propertyParts = explode('_', $property, 2); if (count($propertyParts) === 2 && array_key_exists($propertyParts[0], $data) && is_array($data[$propertyParts[0]])) { $value = $this->getDataValue($data[$propertyParts[0]], $propertyParts[1]); } } } return $value; }
php
protected function getDataValue(array $data, $property) { $value = null; if (array_key_exists($property, $data)) { // Found: return the value. $value = $data[$property]; } else { // Not found: check in meta data or descend recursively. if (isset($data['meta_data'])) { $value = $this->getMetaDataValue($data['meta_data'], $property); } if ($value === null) { // Not found in meta_data: check if we should descend a level. $propertyParts = explode('_', $property, 2); if (count($propertyParts) === 2 && array_key_exists($propertyParts[0], $data) && is_array($data[$propertyParts[0]])) { $value = $this->getDataValue($data[$propertyParts[0]], $propertyParts[1]); } } } return $value; }
[ "protected", "function", "getDataValue", "(", "array", "$", "data", ",", "$", "property", ")", "{", "$", "value", "=", "null", ";", "if", "(", "array_key_exists", "(", "$", "property", ",", "$", "data", ")", ")", "{", "// Found: return the value.", "$", ...
Extracts a value from a WooCommerce data object data array. A WooCommerce data array (array with key value pairs returned from the WC_Data::get_data() method may contain recursive data sets, e.g. 'billing' for the billing address, and a separate meta_data set. This method recursively searches for the property by stripping it into separate pieces delimited by underscores. E.g. billing_email may be found in $data['billing']['email']. @param array $data The key value data set to search in. @param string $property The name of the property to search for. @return null|string The value for the property of the given name, or null or the empty string if not available (or the property really equals null or the empty string). The return value may be a scalar (numeric type) that can be converted to a string.
[ "Extracts", "a", "value", "from", "a", "WooCommerce", "data", "object", "data", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Helpers/Token.php#L58-L78
train
SIELOnline/libAcumulus
src/WooCommerce/Helpers/Token.php
Token.getMetaDataValue
protected function getMetaDataValue(array $metaData, $property) { $property = ltrim($property, '_'); $value = null; foreach ($metaData as $metaItem) { $key = ltrim($metaItem->key, '_'); if ($property === $key) { $value = $metaItem->value; break; } } return $value; }
php
protected function getMetaDataValue(array $metaData, $property) { $property = ltrim($property, '_'); $value = null; foreach ($metaData as $metaItem) { $key = ltrim($metaItem->key, '_'); if ($property === $key) { $value = $metaItem->value; break; } } return $value; }
[ "protected", "function", "getMetaDataValue", "(", "array", "$", "metaData", ",", "$", "property", ")", "{", "$", "property", "=", "ltrim", "(", "$", "property", ",", "'_'", ")", ";", "$", "value", "=", "null", ";", "foreach", "(", "$", "metaData", "as"...
Extracts a value from a set of WooCommerce meta data objects. WooCommerce meta data is stored in objects having twice the set of properties id, key, and value, once in the property current_value and once in the property data. If 1 of the properties id, key or value is retrieved, its value from the current_value set is returned. @param object[] $metaData The meta data set to search in. @param string $property The name of the property to search for. May be with or without a leading underscore. @return null|string The value for the property of the given name, or null or the empty string if not available (or the property really equals null or the empty string). The return value may be a scalar (numeric type) that can be converted to a string.
[ "Extracts", "a", "value", "from", "a", "set", "of", "WooCommerce", "meta", "data", "objects", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Helpers/Token.php#L100-L112
train
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.getEntryId
public function getEntryId() { $entryId = $this->get(static::$keyEntryId); if (!empty($entryId)) { $entryId = (int) $entryId; } return $entryId; }
php
public function getEntryId() { $entryId = $this->get(static::$keyEntryId); if (!empty($entryId)) { $entryId = (int) $entryId; } return $entryId; }
[ "public", "function", "getEntryId", "(", ")", "{", "$", "entryId", "=", "$", "this", "->", "get", "(", "static", "::", "$", "keyEntryId", ")", ";", "if", "(", "!", "empty", "(", "$", "entryId", ")", ")", "{", "$", "entryId", "=", "(", "int", ")",...
Returns the entry id for this Acumulus entry. @return int|null The entry id of this Acumulus entry or null if it was stored as a concept.
[ "Returns", "the", "entry", "id", "for", "this", "Acumulus", "entry", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L76-L83
train
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.getCreated
public function getCreated($raw = false) { $result = $this->get(static::$keyCreated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
php
public function getCreated($raw = false) { $result = $this->get(static::$keyCreated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
[ "public", "function", "getCreated", "(", "$", "raw", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "get", "(", "static", "::", "$", "keyCreated", ")", ";", "if", "(", "!", "$", "raw", ")", "{", "$", "result", "=", "$", "this", ...
Returns the time when this record was created. @param bool $raw Whether to return the raw value as stored in the database, or a Datetime object. The raw value will differ per webshop. @return string|int|\DateTime The timestamp when this record was created.
[ "Returns", "the", "time", "when", "this", "record", "was", "created", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L129-L136
train
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.getUpdated
public function getUpdated($raw = false) { $result = $this->get(static::$keyUpdated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
php
public function getUpdated($raw = false) { $result = $this->get(static::$keyUpdated); if (!$raw) { $result = $this->toDateTime($result); } return $result; }
[ "public", "function", "getUpdated", "(", "$", "raw", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "get", "(", "static", "::", "$", "keyUpdated", ")", ";", "if", "(", "!", "$", "raw", ")", "{", "$", "result", "=", "$", "this", ...
Returns the time when this record was last updated. @param bool $raw Whether to return the raw value as stored in the database, or a Datetime object. The raw value will differ per webshop. @return string|int|\DateTime The timestamp when this record was last updated.
[ "Returns", "the", "time", "when", "this", "record", "was", "last", "updated", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L148-L155
train
SIELOnline/libAcumulus
src/Shop/AcumulusEntry.php
AcumulusEntry.get
protected function get($field) { $value = null; if (is_array($this->record)) { // Value may be null: use array_key_exists(), not isset(). if (array_key_exists($field, $this->record)) { $value = $this->record[$field]; } } elseif (is_object($this->record)) { // It's an object: try to get the property. // Safest way is via the get_object_vars() function. $properties = get_object_vars($this->record); if (!empty($properties) && array_key_exists($field, $properties)) { $value = $properties[$field]; } elseif (method_exists($this->record, $field)) { $value = call_user_func(array($this->record, $field)); } elseif (method_exists($this->record, '__get')) { @$value = $this->record->$field; } elseif (method_exists($this->record, '__call')) { @$value = $this->record->$field(); } } return $value; }
php
protected function get($field) { $value = null; if (is_array($this->record)) { // Value may be null: use array_key_exists(), not isset(). if (array_key_exists($field, $this->record)) { $value = $this->record[$field]; } } elseif (is_object($this->record)) { // It's an object: try to get the property. // Safest way is via the get_object_vars() function. $properties = get_object_vars($this->record); if (!empty($properties) && array_key_exists($field, $properties)) { $value = $properties[$field]; } elseif (method_exists($this->record, $field)) { $value = call_user_func(array($this->record, $field)); } elseif (method_exists($this->record, '__get')) { @$value = $this->record->$field; } elseif (method_exists($this->record, '__call')) { @$value = $this->record->$field(); } } return $value; }
[ "protected", "function", "get", "(", "$", "field", ")", "{", "$", "value", "=", "null", ";", "if", "(", "is_array", "(", "$", "this", "->", "record", ")", ")", "{", "// Value may be null: use array_key_exists(), not isset().", "if", "(", "array_key_exists", "(...
Returns the value of the given field in the given acumulus entry record. As different webshops may use different field and property names in their tables and models, we abstracted accessing a field of a record into this method. @param string $field The field to search for. @return mixed|null The value of the given field in this acumulus entry record.
[ "Returns", "the", "value", "of", "the", "given", "field", "in", "the", "given", "acumulus", "entry", "record", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/AcumulusEntry.php#L204-L227
train
SIELOnline/libAcumulus
SielAcumulusAutoloader.php
SielAcumulusAutoloader.register
public static function register() { // In some shops (OpenCart1) there's not one central entry point and // we may risk registering twice. static $hasBeenRegistered = false; if (!$hasBeenRegistered) { $dir = __DIR__ . '/src/'; $ourNamespace = 'Siel\\Acumulus\\'; $ourNamespaceLen = strlen($ourNamespace); $autoloadFunction = function ($class) use ($ourNamespace, $ourNamespaceLen, $dir) { if (strncmp($class, $ourNamespace, $ourNamespaceLen) === 0) { $fileName = $dir . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $ourNamespaceLen)) . '.php'; if (is_readable($fileName)) { /** @noinspection PhpIncludeInspection */ include($fileName); } } }; // Prepend this autoloader: it will not throw, nor warn, while the // shop specific autoloader might do so. spl_autoload_register($autoloadFunction, true, true); $hasBeenRegistered = true; } }
php
public static function register() { // In some shops (OpenCart1) there's not one central entry point and // we may risk registering twice. static $hasBeenRegistered = false; if (!$hasBeenRegistered) { $dir = __DIR__ . '/src/'; $ourNamespace = 'Siel\\Acumulus\\'; $ourNamespaceLen = strlen($ourNamespace); $autoloadFunction = function ($class) use ($ourNamespace, $ourNamespaceLen, $dir) { if (strncmp($class, $ourNamespace, $ourNamespaceLen) === 0) { $fileName = $dir . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $ourNamespaceLen)) . '.php'; if (is_readable($fileName)) { /** @noinspection PhpIncludeInspection */ include($fileName); } } }; // Prepend this autoloader: it will not throw, nor warn, while the // shop specific autoloader might do so. spl_autoload_register($autoloadFunction, true, true); $hasBeenRegistered = true; } }
[ "public", "static", "function", "register", "(", ")", "{", "// In some shops (OpenCart1) there's not one central entry point and", "// we may risk registering twice.", "static", "$", "hasBeenRegistered", "=", "false", ";", "if", "(", "!", "$", "hasBeenRegistered", ")", "{",...
Registers an autoloader for the Siel\Acumulus namespace. As not all web shops support auto-loading based on namespaces or have other glitches, eg. expecting lower cased file names, we define our own autoloader. If the module cannot use the autoloader of the web shop, this method should be called during bootstrapping of the module. Thanks to https://gist.github.com/mageekguy/8300961
[ "Registers", "an", "autoloader", "for", "the", "Siel", "\\", "Acumulus", "namespace", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/SielAcumulusAutoloader.php#L20-L44
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.setStatus
private function setStatus($status, $message = '') { if ($status > $this->status) { $this->status = $status; // Save the message belonging to this worse state. if (!empty($message)) { $this->statusMessage = $message; } } }
php
private function setStatus($status, $message = '') { if ($status > $this->status) { $this->status = $status; // Save the message belonging to this worse state. if (!empty($message)) { $this->statusMessage = $message; } } }
[ "private", "function", "setStatus", "(", "$", "status", ",", "$", "message", "=", "''", ")", "{", "if", "(", "$", "status", ">", "$", "this", "->", "status", ")", "{", "$", "this", "->", "status", "=", "$", "status", ";", "// Save the message belonging...
Sets the status, but only if it is "worse" than the current status. @param int $status The status to set. @param string $message Optionally, a message indicating what is wrong may be given.
[ "Sets", "the", "status", "but", "only", "if", "it", "is", "worse", "than", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L142-L151
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getStatusClass
public function getStatusClass($status) { switch ($status) { case static::Status_Success: $result = 'success'; break; case static::Status_Info: $result = 'info'; break; case static::Status_Warning: $result = 'warning'; break; case static::Status_Error: default: $result = 'error'; break; } return $result; }
php
public function getStatusClass($status) { switch ($status) { case static::Status_Success: $result = 'success'; break; case static::Status_Info: $result = 'info'; break; case static::Status_Warning: $result = 'warning'; break; case static::Status_Error: default: $result = 'error'; break; } return $result; }
[ "public", "function", "getStatusClass", "(", "$", "status", ")", "{", "switch", "(", "$", "status", ")", "{", "case", "static", "::", "Status_Success", ":", "$", "result", "=", "'success'", ";", "break", ";", "case", "static", "::", "Status_Info", ":", "...
Returns a string to use as css class for the current status. @param int $status @return string
[ "Returns", "a", "string", "to", "use", "as", "css", "class", "for", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L169-L187
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getStatusIcon
private function getStatusIcon($status) { switch ($status) { case static::Status_Success: $result = json_decode('"\u2714"'); break; case static::Status_Info: case static::Status_Warning: $result = '!'; break; case static::Status_Error: default: $result = json_decode('"\u2716"'); break; } return $result; }
php
private function getStatusIcon($status) { switch ($status) { case static::Status_Success: $result = json_decode('"\u2714"'); break; case static::Status_Info: case static::Status_Warning: $result = '!'; break; case static::Status_Error: default: $result = json_decode('"\u2716"'); break; } return $result; }
[ "private", "function", "getStatusIcon", "(", "$", "status", ")", "{", "switch", "(", "$", "status", ")", "{", "case", "static", "::", "Status_Success", ":", "$", "result", "=", "json_decode", "(", "'\"\\u2714\"'", ")", ";", "break", ";", "case", "static", ...
Returns an icon character that represents the current status. @param int $status @return string An icon character that represents the status.
[ "Returns", "an", "icon", "character", "that", "represents", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L197-L213
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getStatusLabelAttributes
private function getStatusLabelAttributes($status, $statusMessage) { $statusClass = $this->getStatusClass($status); $attributes = array( 'class' => array('notice', 'notice-' . $statusClass), 'wrapper' => array( 'class' => array('notice', 'notice-' . $statusClass), ), ); if (!empty($statusMessage)) { $attributes['title'] = $statusMessage; } return $attributes; }
php
private function getStatusLabelAttributes($status, $statusMessage) { $statusClass = $this->getStatusClass($status); $attributes = array( 'class' => array('notice', 'notice-' . $statusClass), 'wrapper' => array( 'class' => array('notice', 'notice-' . $statusClass), ), ); if (!empty($statusMessage)) { $attributes['title'] = $statusMessage; } return $attributes; }
[ "private", "function", "getStatusLabelAttributes", "(", "$", "status", ",", "$", "statusMessage", ")", "{", "$", "statusClass", "=", "$", "this", "->", "getStatusClass", "(", "$", "status", ")", ";", "$", "attributes", "=", "array", "(", "'class'", "=>", "...
Returns a set of label attributes for the current status. @param int $status @param string $statusMessage @return array A set of attributes to add to the label.
[ "Returns", "a", "set", "of", "label", "attributes", "for", "the", "current", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L224-L237
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getAmountStatusTitle
private function getAmountStatusTitle($status) { $result = ''; if ($status > static::Status_Success) { $result = $this->t('amount_status_' . $status); } return $result; }
php
private function getAmountStatusTitle($status) { $result = ''; if ($status > static::Status_Success) { $result = $this->t('amount_status_' . $status); } return $result; }
[ "private", "function", "getAmountStatusTitle", "(", "$", "status", ")", "{", "$", "result", "=", "''", ";", "if", "(", "$", "status", ">", "static", "::", "Status_Success", ")", "{", "$", "result", "=", "$", "this", "->", "t", "(", "'amount_status_'", ...
Returns a description of the amount status. @param int $status @return string A description of the amount status.
[ "Returns", "a", "description", "of", "the", "amount", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L247-L254
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.setSubmittedSource
private function setSubmittedSource() { // Get actual source ($this->source may be the parent, not the source to // execute on). Do so without trusting the input. $sourceType = $this->getSubmittedValue('type') === Source::Order ? Source::Order : Source::CreditNote; $sourceId = (int) $this->getSubmittedValue('source'); $this->submittedSource = null; if ($this->source->getType() === $sourceType && $this->source->getId() === $sourceId) { $this->submittedSource = $this->source; } else { $creditNotes = $this->source->getCreditNotes(); foreach ($creditNotes as $creditNote) { if ($creditNote->getType() === $sourceType && $creditNote->getId() === $sourceId) { $this->submittedSource = $creditNote; } } } }
php
private function setSubmittedSource() { // Get actual source ($this->source may be the parent, not the source to // execute on). Do so without trusting the input. $sourceType = $this->getSubmittedValue('type') === Source::Order ? Source::Order : Source::CreditNote; $sourceId = (int) $this->getSubmittedValue('source'); $this->submittedSource = null; if ($this->source->getType() === $sourceType && $this->source->getId() === $sourceId) { $this->submittedSource = $this->source; } else { $creditNotes = $this->source->getCreditNotes(); foreach ($creditNotes as $creditNote) { if ($creditNote->getType() === $sourceType && $creditNote->getId() === $sourceId) { $this->submittedSource = $creditNote; } } } }
[ "private", "function", "setSubmittedSource", "(", ")", "{", "// Get actual source ($this->source may be the parent, not the source to", "// execute on). Do so without trusting the input.", "$", "sourceType", "=", "$", "this", "->", "getSubmittedValue", "(", "'type'", ")", "===", ...
Extracts the source on which the submitted action is targeted.
[ "Extracts", "the", "source", "on", "which", "the", "submitted", "action", "is", "targeted", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L275-L292
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getFields1Source
private function getFields1Source(Source $source, $localEntryInfo) { $this->resetStatus(); // Get invoice status field and other invoice status related info. $statusInfo = $this->getInvoiceStatusInfo($localEntryInfo); $this->setStatus($statusInfo['severity'], $statusInfo['severity-message']); /** @var string $invoiceStatus */ $invoiceStatus = $statusInfo['status']; /** @var string $statusText */ $statusText = $statusInfo['text']; /** @var string $statusDescription */ $statusDescription = $statusInfo['description']; /** @var Result|null $result */ $result = $statusInfo['result']; /** @var array $entry */ $entry = $statusInfo['entry']; // Create and add additional fields based on invoice status. switch ($invoiceStatus) { case static::Invoice_NotSent: $additionalFields = $this->getNotSentFields($source); break; case static::Invoice_SentConcept: $additionalFields = $this->getConceptFields($source); break; case static::Invoice_CommunicationError: /** @noinspection PhpUndefinedVariableInspection */ $additionalFields = $this->getCommunicationErrorFields($result); break; case static::Invoice_NonExisting: $additionalFields = $this->getNonExistingFields($source); break; case static::Invoice_Deleted: $additionalFields = $this->getDeletedFields($source); break; case static::Invoice_Sent: $additionalFields = $this->getEntryFields($source, $localEntryInfo, $entry); break; default: $additionalFields = array( 'unknown' => array( 'type' => 'markup', 'value' => sprintf($this->t('invoice_status_unknown'), $invoiceStatus), ) ); break; } // Create main status field after we have the other fields, so we can // use the results in rendering the overall status. $fields = array( 'status' => array( 'type' => 'markup', 'label' => $this->getStatusIcon($this->status), 'attributes' => array( 'class' => str_replace('_', '-', $invoiceStatus), 'label' => $this->getStatusLabelAttributes($this->status, $this->statusMessage), ), 'value' => $statusText, 'description' => $statusDescription, ), ) + $additionalFields; return $fields; }
php
private function getFields1Source(Source $source, $localEntryInfo) { $this->resetStatus(); // Get invoice status field and other invoice status related info. $statusInfo = $this->getInvoiceStatusInfo($localEntryInfo); $this->setStatus($statusInfo['severity'], $statusInfo['severity-message']); /** @var string $invoiceStatus */ $invoiceStatus = $statusInfo['status']; /** @var string $statusText */ $statusText = $statusInfo['text']; /** @var string $statusDescription */ $statusDescription = $statusInfo['description']; /** @var Result|null $result */ $result = $statusInfo['result']; /** @var array $entry */ $entry = $statusInfo['entry']; // Create and add additional fields based on invoice status. switch ($invoiceStatus) { case static::Invoice_NotSent: $additionalFields = $this->getNotSentFields($source); break; case static::Invoice_SentConcept: $additionalFields = $this->getConceptFields($source); break; case static::Invoice_CommunicationError: /** @noinspection PhpUndefinedVariableInspection */ $additionalFields = $this->getCommunicationErrorFields($result); break; case static::Invoice_NonExisting: $additionalFields = $this->getNonExistingFields($source); break; case static::Invoice_Deleted: $additionalFields = $this->getDeletedFields($source); break; case static::Invoice_Sent: $additionalFields = $this->getEntryFields($source, $localEntryInfo, $entry); break; default: $additionalFields = array( 'unknown' => array( 'type' => 'markup', 'value' => sprintf($this->t('invoice_status_unknown'), $invoiceStatus), ) ); break; } // Create main status field after we have the other fields, so we can // use the results in rendering the overall status. $fields = array( 'status' => array( 'type' => 'markup', 'label' => $this->getStatusIcon($this->status), 'attributes' => array( 'class' => str_replace('_', '-', $invoiceStatus), 'label' => $this->getStatusLabelAttributes($this->status, $this->statusMessage), ), 'value' => $statusText, 'description' => $statusDescription, ), ) + $additionalFields; return $fields; }
[ "private", "function", "getFields1Source", "(", "Source", "$", "source", ",", "$", "localEntryInfo", ")", "{", "$", "this", "->", "resetStatus", "(", ")", ";", "// Get invoice status field and other invoice status related info.", "$", "statusInfo", "=", "$", "this", ...
Returns the overview for 1 source. @param \Siel\Acumulus\Invoice\Source $source @param \Siel\Acumulus\Shop\AcumulusEntry|null $localEntryInfo @return array[] The fields that describe the status for 1 source.
[ "Returns", "the", "overview", "for", "1", "source", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L414-L478
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getInvoiceStatusInfo
private function getInvoiceStatusInfo($localEntryInfo) { $result = null; $entry = null; $arg1 = null; $arg2 = null; $description = ''; $statusMessage = null; if ($localEntryInfo === null) { $invoiceStatus = static::Invoice_NotSent; $statusSeverity = static::Status_Info; } else { $arg1 = $this->getDate($localEntryInfo->getUpdated()); if ($localEntryInfo->getEntryId() === null) { $invoiceStatus = static::Invoice_SentConcept; $description = 'concept_description'; $statusSeverity = static::Status_Warning; } else { $result = $this->service->getEntry($localEntryInfo->getEntryId()); $entry = $this->sanitizeEntry($result->getResponse()); if ($result->hasCodeTag('XGYBSN000')) { $invoiceStatus = static::Invoice_NonExisting; $statusSeverity = static::Status_Error; // To prevent this error in the future, we delete the local // entry. $this->acumulusEntryManager->delete($localEntryInfo); } elseif (empty($entry)) { $invoiceStatus = static::Invoice_CommunicationError; $statusSeverity = static::Status_Error; } elseif (!empty($entry['deleted'])) { $invoiceStatus = static::Invoice_Deleted; $statusSeverity = static::Status_Warning; $arg2 = $entry['deleted']; } else { $invoiceStatus = static::Invoice_Sent; $arg1 = $entry['invoicenumber']; $arg2 = $entry['entrydate']; $statusSeverity = static::Status_Success; $statusMessage = $this->t('invoice_status_ok'); } } } return array( 'severity' => $statusSeverity, 'severity-message' => $statusMessage, 'status' => $invoiceStatus, 'result' => $result, 'entry' => $entry, 'text' => sprintf($this->t($invoiceStatus), $arg1, $arg2), 'description' => $this->t($description), ); }
php
private function getInvoiceStatusInfo($localEntryInfo) { $result = null; $entry = null; $arg1 = null; $arg2 = null; $description = ''; $statusMessage = null; if ($localEntryInfo === null) { $invoiceStatus = static::Invoice_NotSent; $statusSeverity = static::Status_Info; } else { $arg1 = $this->getDate($localEntryInfo->getUpdated()); if ($localEntryInfo->getEntryId() === null) { $invoiceStatus = static::Invoice_SentConcept; $description = 'concept_description'; $statusSeverity = static::Status_Warning; } else { $result = $this->service->getEntry($localEntryInfo->getEntryId()); $entry = $this->sanitizeEntry($result->getResponse()); if ($result->hasCodeTag('XGYBSN000')) { $invoiceStatus = static::Invoice_NonExisting; $statusSeverity = static::Status_Error; // To prevent this error in the future, we delete the local // entry. $this->acumulusEntryManager->delete($localEntryInfo); } elseif (empty($entry)) { $invoiceStatus = static::Invoice_CommunicationError; $statusSeverity = static::Status_Error; } elseif (!empty($entry['deleted'])) { $invoiceStatus = static::Invoice_Deleted; $statusSeverity = static::Status_Warning; $arg2 = $entry['deleted']; } else { $invoiceStatus = static::Invoice_Sent; $arg1 = $entry['invoicenumber']; $arg2 = $entry['entrydate']; $statusSeverity = static::Status_Success; $statusMessage = $this->t('invoice_status_ok'); } } } return array( 'severity' => $statusSeverity, 'severity-message' => $statusMessage, 'status' => $invoiceStatus, 'result' => $result, 'entry' => $entry, 'text' => sprintf($this->t($invoiceStatus), $arg1, $arg2), 'description' => $this->t($description), ); }
[ "private", "function", "getInvoiceStatusInfo", "(", "$", "localEntryInfo", ")", "{", "$", "result", "=", "null", ";", "$", "entry", "=", "null", ";", "$", "arg1", "=", "null", ";", "$", "arg2", "=", "null", ";", "$", "description", "=", "''", ";", "$...
Returns status related information. @param \Siel\Acumulus\Shop\AcumulusEntry|null $localEntryInfo @return array Keyed array with keys: - status (string): 1 of the ShopOrderOverviewForm::Status_ constants. - send-status (string): 1 of the ShopOrderOverviewForm::Invoice_ constants. - result (\Siel\Acumulus\Web\Result?): result of the getEntry API call. - entry (array|null): the <entry> part of the getEntry API call. - statusField (array): a form field array representing the status.
[ "Returns", "status", "related", "information", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L493-L545
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getNotSentFields
private function getNotSentFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 0, ), 'value' => $this->t('send_now'), ), ); return $fields; }
php
private function getNotSentFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 0, ), 'value' => $this->t('send_now'), ), ); return $fields; }
[ "private", "function", "getNotSentFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'ajax'", "=>", "array", "(...
Returns additional form fields to show when the invoice has not yet been sent. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice has not yet been sent. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "not", "yet", "been", "sent", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L557-L576
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getConceptFields
private function getConceptFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
php
private function getConceptFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
[ "private", "function", "getConceptFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'value'", "=>", "$", "this...
Returns additional form fields to show when the invoice has been sent as concept. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice was sent as concept. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "as", "concept", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L588-L606
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getCommunicationErrorFields
private function getCommunicationErrorFields(Result $result) { $fields = array(); $fields += array( 'messages' => array( 'type' => 'markup', 'label' => $this->t('messages'), 'value' => $result->getMessages(Result::Format_FormattedText), ), ); return $fields; }
php
private function getCommunicationErrorFields(Result $result) { $fields = array(); $fields += array( 'messages' => array( 'type' => 'markup', 'label' => $this->t('messages'), 'value' => $result->getMessages(Result::Format_FormattedText), ), ); return $fields; }
[ "private", "function", "getCommunicationErrorFields", "(", "Result", "$", "result", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'messages'", "=>", "array", "(", "'type'", "=>", "'markup'", ",", "'label'", "=>",...
Returns additional form fields to show when the invoice has been sent but a communication error occurred in retrieving the entry. @param \Siel\Acumulus\Web\Result $result The result that details the error. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "but", "a", "communication", "error", "occurred", "in", "retrieving", "the", "entry", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L618-L629
train
SIELOnline/libAcumulus
src/WooCommerce/Shop/InvoiceStatusOverviewForm.php
InvoiceStatusOverviewForm.getNonExistingFields
private function getNonExistingFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
php
private function getNonExistingFields(Source $source) { $fields = array(); $fields += array( 'send' => array( 'type' => 'button', 'value' => $this->t('send_again'), 'ajax' => array( 'service' => 'invoice_add', 'parent_type' => $this->source->getType(), 'parent_source' => $this->source->getId(), 'type' => $source->getType(), 'source' => $source->getId(), 'value' => 1, ), ), ); return $fields; }
[ "private", "function", "getNonExistingFields", "(", "Source", "$", "source", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "$", "fields", "+=", "array", "(", "'send'", "=>", "array", "(", "'type'", "=>", "'button'", ",", "'value'", "=>", "$", "...
Returns additional form fields to show when the invoice has been sent but does no longer exist. @param \Siel\Acumulus\Invoice\Source $source The Source for which the invoice does no longer exist. @return array[] Array of form fields.
[ "Returns", "additional", "form", "fields", "to", "show", "when", "the", "invoice", "has", "been", "sent", "but", "does", "no", "longer", "exist", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Shop/InvoiceStatusOverviewForm.php#L641-L659
train