id int32 0 241k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,300 | SIELOnline/libAcumulus | src/Magento/Helpers/FormMapper.php | FormMapper.field | public function field($parent, array $field)
{
if (!isset($field['attributes'])) {
$field['attributes'] = array();
}
$magentoType = $this->getMagentoType($field);
$magentoElementSettings = $this->getMagentoElementSettings($field);
$element = $parent->addField($field['id'], $magentoType, $magentoElementSettings);
if ($magentoType === 'multiselect') {
if (!empty($magentoElementSettings['size'])) {
/** @noinspection PhpUndefinedMethodInspection */
$element->setSize($magentoElementSettings['size']);
}
}
if (!empty($field['fields'])) {
// Add description at the start of the fieldset/summary as a note
// element.
if (isset($field['description'])) {
$element->addField($field['id'] . '-note', 'note', array('text' => '<p class="note">' . $field['description'] . '</p>'));
}
// Add fields of fieldset.
$this->fields($element, $field['fields']);
}
} | php | public function field($parent, array $field)
{
if (!isset($field['attributes'])) {
$field['attributes'] = array();
}
$magentoType = $this->getMagentoType($field);
$magentoElementSettings = $this->getMagentoElementSettings($field);
$element = $parent->addField($field['id'], $magentoType, $magentoElementSettings);
if ($magentoType === 'multiselect') {
if (!empty($magentoElementSettings['size'])) {
/** @noinspection PhpUndefinedMethodInspection */
$element->setSize($magentoElementSettings['size']);
}
}
if (!empty($field['fields'])) {
// Add description at the start of the fieldset/summary as a note
// element.
if (isset($field['description'])) {
$element->addField($field['id'] . '-note', 'note', array('text' => '<p class="note">' . $field['description'] . '</p>'));
}
// Add fields of fieldset.
$this->fields($element, $field['fields']);
}
} | [
"public",
"function",
"field",
"(",
"$",
"parent",
",",
"array",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"[",
"'attributes'",
"]",
")",
")",
"{",
"$",
"field",
"[",
"'attributes'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"magentoType",
"=",
"$",
"this",
"->",
"getMagentoType",
"(",
"$",
"field",
")",
";",
"$",
"magentoElementSettings",
"=",
"$",
"this",
"->",
"getMagentoElementSettings",
"(",
"$",
"field",
")",
";",
"$",
"element",
"=",
"$",
"parent",
"->",
"addField",
"(",
"$",
"field",
"[",
"'id'",
"]",
",",
"$",
"magentoType",
",",
"$",
"magentoElementSettings",
")",
";",
"if",
"(",
"$",
"magentoType",
"===",
"'multiselect'",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"magentoElementSettings",
"[",
"'size'",
"]",
")",
")",
"{",
"/** @noinspection PhpUndefinedMethodInspection */",
"$",
"element",
"->",
"setSize",
"(",
"$",
"magentoElementSettings",
"[",
"'size'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
"[",
"'fields'",
"]",
")",
")",
"{",
"// Add description at the start of the fieldset/summary as a note",
"// element.",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'description'",
"]",
")",
")",
"{",
"$",
"element",
"->",
"addField",
"(",
"$",
"field",
"[",
"'id'",
"]",
".",
"'-note'",
",",
"'note'",
",",
"array",
"(",
"'text'",
"=>",
"'<p class=\"note\">'",
".",
"$",
"field",
"[",
"'description'",
"]",
".",
"'</p>'",
")",
")",
";",
"}",
"// Add fields of fieldset.",
"$",
"this",
"->",
"fields",
"(",
"$",
"element",
",",
"$",
"field",
"[",
"'fields'",
"]",
")",
";",
"}",
"}"
] | Maps a single field definition.
@param \Varien_Data_Form_Abstract|\Magento\Framework\Data\Form\AbstractForm $parent
@param array $field | [
"Maps",
"a",
"single",
"field",
"definition",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Helpers/FormMapper.php#L72-L98 |
30,301 | SIELOnline/libAcumulus | src/Magento/Helpers/FormMapper.php | FormMapper.getMagentoType | protected function getMagentoType(array $field)
{
switch ($field['type']) {
case 'email':
case 'number':
$type = 'text';
break;
case 'markup':
$type = 'note';
break;
case 'radio':
$type = 'radios';
break;
case 'checkbox':
$type = 'checkboxes';
break;
case 'select':
$type = empty($field['attributes']['multiple']) ? 'select' : 'multiselect';
break;
case 'details':
$type = 'fieldset';
break;
// Other types are returned as is: fieldset, text, password, date
default:
$type = $field['type'];
break;
}
return $type;
} | php | protected function getMagentoType(array $field)
{
switch ($field['type']) {
case 'email':
case 'number':
$type = 'text';
break;
case 'markup':
$type = 'note';
break;
case 'radio':
$type = 'radios';
break;
case 'checkbox':
$type = 'checkboxes';
break;
case 'select':
$type = empty($field['attributes']['multiple']) ? 'select' : 'multiselect';
break;
case 'details':
$type = 'fieldset';
break;
// Other types are returned as is: fieldset, text, password, date
default:
$type = $field['type'];
break;
}
return $type;
} | [
"protected",
"function",
"getMagentoType",
"(",
"array",
"$",
"field",
")",
"{",
"switch",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
"{",
"case",
"'email'",
":",
"case",
"'number'",
":",
"$",
"type",
"=",
"'text'",
";",
"break",
";",
"case",
"'markup'",
":",
"$",
"type",
"=",
"'note'",
";",
"break",
";",
"case",
"'radio'",
":",
"$",
"type",
"=",
"'radios'",
";",
"break",
";",
"case",
"'checkbox'",
":",
"$",
"type",
"=",
"'checkboxes'",
";",
"break",
";",
"case",
"'select'",
":",
"$",
"type",
"=",
"empty",
"(",
"$",
"field",
"[",
"'attributes'",
"]",
"[",
"'multiple'",
"]",
")",
"?",
"'select'",
":",
"'multiselect'",
";",
"break",
";",
"case",
"'details'",
":",
"$",
"type",
"=",
"'fieldset'",
";",
"break",
";",
"// Other types are returned as is: fieldset, text, password, date",
"default",
":",
"$",
"type",
"=",
"$",
"field",
"[",
"'type'",
"]",
";",
"break",
";",
"}",
"return",
"$",
"type",
";",
"}"
] | Returns the Magento form element type for the given Acumulus type string.
@param array $field
@return string | [
"Returns",
"the",
"Magento",
"form",
"element",
"type",
"for",
"the",
"given",
"Acumulus",
"type",
"string",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Helpers/FormMapper.php#L107-L135 |
30,302 | SIELOnline/libAcumulus | src/Magento/Helpers/FormMapper.php | FormMapper.getMagentoElementSettings | protected function getMagentoElementSettings(array $field)
{
$config = array();
if ($field['type'] === 'details') {
$config['collapsable'] = true;
$config['opened'] = false;
}
foreach ($field as $key => $value) {
$config += $this->getMagentoProperty($key, $value, $field['type']);
}
return $config;
} | php | protected function getMagentoElementSettings(array $field)
{
$config = array();
if ($field['type'] === 'details') {
$config['collapsable'] = true;
$config['opened'] = false;
}
foreach ($field as $key => $value) {
$config += $this->getMagentoProperty($key, $value, $field['type']);
}
return $config;
} | [
"protected",
"function",
"getMagentoElementSettings",
"(",
"array",
"$",
"field",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"field",
"[",
"'type'",
"]",
"===",
"'details'",
")",
"{",
"$",
"config",
"[",
"'collapsable'",
"]",
"=",
"true",
";",
"$",
"config",
"[",
"'opened'",
"]",
"=",
"false",
";",
"}",
"foreach",
"(",
"$",
"field",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"config",
"+=",
"$",
"this",
"->",
"getMagentoProperty",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"field",
"[",
"'type'",
"]",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Returns the Magento form element settings.
@param array $field
The Acumulus field settings.
@return array
The Magento form element settings. | [
"Returns",
"the",
"Magento",
"form",
"element",
"settings",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Helpers/FormMapper.php#L146-L159 |
30,303 | SIELOnline/libAcumulus | src/Magento/Helpers/FormMapper.php | FormMapper.getMagentoProperty | protected function getMagentoProperty($key, $value, $type)
{
switch ($key) {
// Fields to ignore:
case 'type':
case 'id':
case 'fields':
$result = array();
break;
case 'summary':
$result = array('legend' => $value);
break;
// Fields to return unchanged:
case 'legend':
case 'label':
case 'format':
$result = array($key => $value);
break;
case 'name':
if ($type === 'checkbox') {
// Make it an array for PHP POST processing, in case there
// are multiple checkboxes.
$value .= '[]';
}
$result = array($key => $value);
break;
case 'description':
// The description of a fieldset is handled elsewhere.
$result = $type !== 'fieldset' ? array('after_element_html' => '<p class="note">' . $value . '</p>') : array();
break;
case 'value':
if ($type === 'markup') {
$result = array('text' => $value);
} else { // $type === 'hidden'
$result = array('value' => $value);
}
break;
case 'attributes':
// In magento you add pure html attributes at the same level as
// the "field attributes" that are for Magento.
$result = $value;
if (!empty($value['required'])) {
if (isset($result['class'])) {
$result['class'] .= ' ';
} else {
$result['class'] = '';
}
if ($type === 'radio') {
unset($result['required']);
$result['class'] .= 'validate-one-required-by-name';
} else {
$result['class'] .= 'required-entry';
}
}
break;
case 'options':
$result = array('values' => $this->getMagentoOptions($value));
break;
default:
$this->log->warning(__METHOD__ . "Unknown key '$key'");
$result = array($key => $value);
break;
}
return $result;
} | php | protected function getMagentoProperty($key, $value, $type)
{
switch ($key) {
// Fields to ignore:
case 'type':
case 'id':
case 'fields':
$result = array();
break;
case 'summary':
$result = array('legend' => $value);
break;
// Fields to return unchanged:
case 'legend':
case 'label':
case 'format':
$result = array($key => $value);
break;
case 'name':
if ($type === 'checkbox') {
// Make it an array for PHP POST processing, in case there
// are multiple checkboxes.
$value .= '[]';
}
$result = array($key => $value);
break;
case 'description':
// The description of a fieldset is handled elsewhere.
$result = $type !== 'fieldset' ? array('after_element_html' => '<p class="note">' . $value . '</p>') : array();
break;
case 'value':
if ($type === 'markup') {
$result = array('text' => $value);
} else { // $type === 'hidden'
$result = array('value' => $value);
}
break;
case 'attributes':
// In magento you add pure html attributes at the same level as
// the "field attributes" that are for Magento.
$result = $value;
if (!empty($value['required'])) {
if (isset($result['class'])) {
$result['class'] .= ' ';
} else {
$result['class'] = '';
}
if ($type === 'radio') {
unset($result['required']);
$result['class'] .= 'validate-one-required-by-name';
} else {
$result['class'] .= 'required-entry';
}
}
break;
case 'options':
$result = array('values' => $this->getMagentoOptions($value));
break;
default:
$this->log->warning(__METHOD__ . "Unknown key '$key'");
$result = array($key => $value);
break;
}
return $result;
} | [
"protected",
"function",
"getMagentoProperty",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"key",
")",
"{",
"// Fields to ignore:",
"case",
"'type'",
":",
"case",
"'id'",
":",
"case",
"'fields'",
":",
"$",
"result",
"=",
"array",
"(",
")",
";",
"break",
";",
"case",
"'summary'",
":",
"$",
"result",
"=",
"array",
"(",
"'legend'",
"=>",
"$",
"value",
")",
";",
"break",
";",
"// Fields to return unchanged:",
"case",
"'legend'",
":",
"case",
"'label'",
":",
"case",
"'format'",
":",
"$",
"result",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"value",
")",
";",
"break",
";",
"case",
"'name'",
":",
"if",
"(",
"$",
"type",
"===",
"'checkbox'",
")",
"{",
"// Make it an array for PHP POST processing, in case there",
"// are multiple checkboxes.",
"$",
"value",
".=",
"'[]'",
";",
"}",
"$",
"result",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"value",
")",
";",
"break",
";",
"case",
"'description'",
":",
"// The description of a fieldset is handled elsewhere.",
"$",
"result",
"=",
"$",
"type",
"!==",
"'fieldset'",
"?",
"array",
"(",
"'after_element_html'",
"=>",
"'<p class=\"note\">'",
".",
"$",
"value",
".",
"'</p>'",
")",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"'value'",
":",
"if",
"(",
"$",
"type",
"===",
"'markup'",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'text'",
"=>",
"$",
"value",
")",
";",
"}",
"else",
"{",
"// $type === 'hidden'",
"$",
"result",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"value",
")",
";",
"}",
"break",
";",
"case",
"'attributes'",
":",
"// In magento you add pure html attributes at the same level as",
"// the \"field attributes\" that are for Magento.",
"$",
"result",
"=",
"$",
"value",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
"[",
"'required'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'class'",
"]",
".=",
"' '",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"'class'",
"]",
"=",
"''",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"'radio'",
")",
"{",
"unset",
"(",
"$",
"result",
"[",
"'required'",
"]",
")",
";",
"$",
"result",
"[",
"'class'",
"]",
".=",
"'validate-one-required-by-name'",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"'class'",
"]",
".=",
"'required-entry'",
";",
"}",
"}",
"break",
";",
"case",
"'options'",
":",
"$",
"result",
"=",
"array",
"(",
"'values'",
"=>",
"$",
"this",
"->",
"getMagentoOptions",
"(",
"$",
"value",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"log",
"->",
"warning",
"(",
"__METHOD__",
".",
"\"Unknown key '$key'\"",
")",
";",
"$",
"result",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"value",
")",
";",
"break",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Converts an Acumulus settings to a Magento setting.
@param string $key
The name of the setting to convert.
@param mixed $value
The value for the setting to convert.
@param string $type
The Acumulus field type.
@return array
The Magento setting. This will typically contain 1 element, but in some
cases 1 Acumulus field setting may result in multiple Magento settings. | [
"Converts",
"an",
"Acumulus",
"settings",
"to",
"a",
"Magento",
"setting",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Helpers/FormMapper.php#L175-L239 |
30,304 | SIELOnline/libAcumulus | src/Magento/Helpers/FormMapper.php | FormMapper.getMagentoOptions | protected function getMagentoOptions(array $options)
{
$result = array();
foreach ($options as $value => $label) {
$result[] = array(
'value' => $value,
'label' => $label,
);
}
return $result;
} | php | protected function getMagentoOptions(array $options)
{
$result = array();
foreach ($options as $value => $label) {
$result[] = array(
'value' => $value,
'label' => $label,
);
}
return $result;
} | [
"protected",
"function",
"getMagentoOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"value",
",",
"'label'",
"=>",
"$",
"label",
",",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Converts a list of Acumulus field options to a list of Magento options.
@param array $options
@return array
A list of Magento form element options. | [
"Converts",
"a",
"list",
"of",
"Acumulus",
"field",
"options",
"to",
"a",
"list",
"of",
"Magento",
"options",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Helpers/FormMapper.php#L249-L259 |
30,305 | SIELOnline/libAcumulus | src/PrestaShop/Invoice/Source.php | Source.setId | protected function setId()
{
$this->id = $this->source->id;
if ($this->getType() === Source::CreditNote) {
$this->addProperties();
}
} | php | protected function setId()
{
$this->id = $this->source->id;
if ($this->getType() === Source::CreditNote) {
$this->addProperties();
}
} | [
"protected",
"function",
"setId",
"(",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"this",
"->",
"source",
"->",
"id",
";",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"Source",
"::",
"CreditNote",
")",
"{",
"$",
"this",
"->",
"addProperties",
"(",
")",
";",
"}",
"}"
] | Sets the id based on the loaded Order. | [
"Sets",
"the",
"id",
"based",
"on",
"the",
"loaded",
"Order",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/PrestaShop/Invoice/Source.php#L55-L61 |
30,306 | ipunkt/rancherize | app/Blueprint/Volumes/VolumeService/VolumeService.php | VolumeService.parse | public function parse( Configuration $configuration, Service $mainService ) {
if( !$configuration->has('volumes') )
return;
$volumesDefinition = $configuration->get( 'volumes' );
foreach( $volumesDefinition as $key => $data ) {
$type = 'object';
if( is_string($data) )
$type = 'string';
$volumeParser = $this->volumeParserFactory->getParser( $type );
$volume = $volumeParser->parse($key, $data);
$mainService->addVolume($volume);
$this->applyToSidekicks($mainService, $volume);
}
} | php | public function parse( Configuration $configuration, Service $mainService ) {
if( !$configuration->has('volumes') )
return;
$volumesDefinition = $configuration->get( 'volumes' );
foreach( $volumesDefinition as $key => $data ) {
$type = 'object';
if( is_string($data) )
$type = 'string';
$volumeParser = $this->volumeParserFactory->getParser( $type );
$volume = $volumeParser->parse($key, $data);
$mainService->addVolume($volume);
$this->applyToSidekicks($mainService, $volume);
}
} | [
"public",
"function",
"parse",
"(",
"Configuration",
"$",
"configuration",
",",
"Service",
"$",
"mainService",
")",
"{",
"if",
"(",
"!",
"$",
"configuration",
"->",
"has",
"(",
"'volumes'",
")",
")",
"return",
";",
"$",
"volumesDefinition",
"=",
"$",
"configuration",
"->",
"get",
"(",
"'volumes'",
")",
";",
"foreach",
"(",
"$",
"volumesDefinition",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"$",
"type",
"=",
"'object'",
";",
"if",
"(",
"is_string",
"(",
"$",
"data",
")",
")",
"$",
"type",
"=",
"'string'",
";",
"$",
"volumeParser",
"=",
"$",
"this",
"->",
"volumeParserFactory",
"->",
"getParser",
"(",
"$",
"type",
")",
";",
"$",
"volume",
"=",
"$",
"volumeParser",
"->",
"parse",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"$",
"mainService",
"->",
"addVolume",
"(",
"$",
"volume",
")",
";",
"$",
"this",
"->",
"applyToSidekicks",
"(",
"$",
"mainService",
",",
"$",
"volume",
")",
";",
"}",
"}"
] | Parse configuration and add volumes
@param Configuration $configuration
@param Service $mainService | [
"Parse",
"configuration",
"and",
"add",
"volumes"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/Volumes/VolumeService/VolumeService.php#L39-L58 |
30,307 | ipunkt/rancherize | app/Blueprint/Volumes/VolumeService/VolumeService.php | VolumeService.applyToSidekicks | private function applyToSidekicks( Service $mainService, Volume $volume ) {
if( ! $this->onSidekicks )
return;
foreach( $mainService->getSidekicks() as $sidekick )
$sidekick->addVolume($volume);
} | php | private function applyToSidekicks( Service $mainService, Volume $volume ) {
if( ! $this->onSidekicks )
return;
foreach( $mainService->getSidekicks() as $sidekick )
$sidekick->addVolume($volume);
} | [
"private",
"function",
"applyToSidekicks",
"(",
"Service",
"$",
"mainService",
",",
"Volume",
"$",
"volume",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"onSidekicks",
")",
"return",
";",
"foreach",
"(",
"$",
"mainService",
"->",
"getSidekicks",
"(",
")",
"as",
"$",
"sidekick",
")",
"$",
"sidekick",
"->",
"addVolume",
"(",
"$",
"volume",
")",
";",
"}"
] | Applies the volumes to sidekicks of the mainService
In Rancher this could be done through volumes-from
with docker-compose volumes-from tends to create circular dependency problems
@param Service $mainService
@param Volume $volume | [
"Applies",
"the",
"volumes",
"to",
"sidekicks",
"of",
"the",
"mainService"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/Volumes/VolumeService/VolumeService.php#L78-L84 |
30,308 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.retrieveConfig | public function retrieveConfig(string $stackName) : array {
$stackId = $this->getStackIdByName($stackName);
$url = implode('/', [
$this->account->getUrl(),
'environments',
$stackId,
'?action=exportconfig'
]);
$headers = [];
$this->addAuthHeader($headers);
$jsonContent = json_encode([
'serviceIds' => []
]);
$data = $this->apiService->post($url, $jsonContent, $headers, [200]);
$decodedData = json_decode($data, true);
$dockerCompose = $decodedData['dockerComposeConfig'];
$rancherCompose = $decodedData['rancherComposeConfig'];
// Empty files are not sent empty so we force them to be
if(substr($dockerCompose, 0, 2) === '{}')
$dockerCompose = '';
if(substr($rancherCompose, 0, 2) === '{}')
$rancherCompose = '';
return [$dockerCompose, $rancherCompose];
} | php | public function retrieveConfig(string $stackName) : array {
$stackId = $this->getStackIdByName($stackName);
$url = implode('/', [
$this->account->getUrl(),
'environments',
$stackId,
'?action=exportconfig'
]);
$headers = [];
$this->addAuthHeader($headers);
$jsonContent = json_encode([
'serviceIds' => []
]);
$data = $this->apiService->post($url, $jsonContent, $headers, [200]);
$decodedData = json_decode($data, true);
$dockerCompose = $decodedData['dockerComposeConfig'];
$rancherCompose = $decodedData['rancherComposeConfig'];
// Empty files are not sent empty so we force them to be
if(substr($dockerCompose, 0, 2) === '{}')
$dockerCompose = '';
if(substr($rancherCompose, 0, 2) === '{}')
$rancherCompose = '';
return [$dockerCompose, $rancherCompose];
} | [
"public",
"function",
"retrieveConfig",
"(",
"string",
"$",
"stackName",
")",
":",
"array",
"{",
"$",
"stackId",
"=",
"$",
"this",
"->",
"getStackIdByName",
"(",
"$",
"stackName",
")",
";",
"$",
"url",
"=",
"implode",
"(",
"'/'",
",",
"[",
"$",
"this",
"->",
"account",
"->",
"getUrl",
"(",
")",
",",
"'environments'",
",",
"$",
"stackId",
",",
"'?action=exportconfig'",
"]",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"addAuthHeader",
"(",
"$",
"headers",
")",
";",
"$",
"jsonContent",
"=",
"json_encode",
"(",
"[",
"'serviceIds'",
"=>",
"[",
"]",
"]",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"apiService",
"->",
"post",
"(",
"$",
"url",
",",
"$",
"jsonContent",
",",
"$",
"headers",
",",
"[",
"200",
"]",
")",
";",
"$",
"decodedData",
"=",
"json_decode",
"(",
"$",
"data",
",",
"true",
")",
";",
"$",
"dockerCompose",
"=",
"$",
"decodedData",
"[",
"'dockerComposeConfig'",
"]",
";",
"$",
"rancherCompose",
"=",
"$",
"decodedData",
"[",
"'rancherComposeConfig'",
"]",
";",
"// Empty files are not sent empty so we force them to be",
"if",
"(",
"substr",
"(",
"$",
"dockerCompose",
",",
"0",
",",
"2",
")",
"===",
"'{}'",
")",
"$",
"dockerCompose",
"=",
"''",
";",
"if",
"(",
"substr",
"(",
"$",
"rancherCompose",
",",
"0",
",",
"2",
")",
"===",
"'{}'",
")",
"$",
"rancherCompose",
"=",
"''",
";",
"return",
"[",
"$",
"dockerCompose",
",",
"$",
"rancherCompose",
"]",
";",
"}"
] | Retrieve the docker-compose.yml and rancher-compose.yml for the given stack
@param string $stackName
@return array | [
"Retrieve",
"the",
"docker",
"-",
"compose",
".",
"yml",
"and",
"rancher",
"-",
"compose",
".",
"yml",
"for",
"the",
"given",
"stack"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L77-L108 |
30,309 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.getStackIdByName | private function getStackIdByName($stackName) {
$url = implode('/', [
$this->account->getUrl(),
'environments'
]);
$headers = [];
$this->addAuthHeader($headers);
$jsonData = $this->apiService->get($url, $headers);
$data = json_decode($jsonData, true);
if( !array_key_exists('data', $data) )
throw new MissingDataException('data', array_keys($data) );
$stacks = $data['data'];
try {
$stack = $this->byNameService->findName($stacks, $stackName);
return $stack['id'];
} catch(NameNotFoundException $e) {
throw new StackNotFoundException($stackName, 11);
}
} | php | private function getStackIdByName($stackName) {
$url = implode('/', [
$this->account->getUrl(),
'environments'
]);
$headers = [];
$this->addAuthHeader($headers);
$jsonData = $this->apiService->get($url, $headers);
$data = json_decode($jsonData, true);
if( !array_key_exists('data', $data) )
throw new MissingDataException('data', array_keys($data) );
$stacks = $data['data'];
try {
$stack = $this->byNameService->findName($stacks, $stackName);
return $stack['id'];
} catch(NameNotFoundException $e) {
throw new StackNotFoundException($stackName, 11);
}
} | [
"private",
"function",
"getStackIdByName",
"(",
"$",
"stackName",
")",
"{",
"$",
"url",
"=",
"implode",
"(",
"'/'",
",",
"[",
"$",
"this",
"->",
"account",
"->",
"getUrl",
"(",
")",
",",
"'environments'",
"]",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"addAuthHeader",
"(",
"$",
"headers",
")",
";",
"$",
"jsonData",
"=",
"$",
"this",
"->",
"apiService",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"headers",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"jsonData",
",",
"true",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'data'",
",",
"$",
"data",
")",
")",
"throw",
"new",
"MissingDataException",
"(",
"'data'",
",",
"array_keys",
"(",
"$",
"data",
")",
")",
";",
"$",
"stacks",
"=",
"$",
"data",
"[",
"'data'",
"]",
";",
"try",
"{",
"$",
"stack",
"=",
"$",
"this",
"->",
"byNameService",
"->",
"findName",
"(",
"$",
"stacks",
",",
"$",
"stackName",
")",
";",
"return",
"$",
"stack",
"[",
"'id'",
"]",
";",
"}",
"catch",
"(",
"NameNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"StackNotFoundException",
"(",
"$",
"stackName",
",",
"11",
")",
";",
"}",
"}"
] | Translate the given Stackname into an id.
Throws StackNotFoundException if no matching stack was found
@param $stackName
@return string
@throws StackNotFoundException | [
"Translate",
"the",
"given",
"Stackname",
"into",
"an",
"id",
".",
"Throws",
"StackNotFoundException",
"if",
"no",
"matching",
"stack",
"was",
"found"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L118-L140 |
30,310 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.addAuthHeader | protected function addAuthHeader(&$headers) {
$user = $this->account->getKey();
$password = $this->account->getSecret();
$headers['Authorization'] = 'Basic ' . base64_encode("$user:$password");
} | php | protected function addAuthHeader(&$headers) {
$user = $this->account->getKey();
$password = $this->account->getSecret();
$headers['Authorization'] = 'Basic ' . base64_encode("$user:$password");
} | [
"protected",
"function",
"addAuthHeader",
"(",
"&",
"$",
"headers",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"account",
"->",
"getKey",
"(",
")",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"account",
"->",
"getSecret",
"(",
")",
";",
"$",
"headers",
"[",
"'Authorization'",
"]",
"=",
"'Basic '",
".",
"base64_encode",
"(",
"\"$user:$password\"",
")",
";",
"}"
] | Helper function to add the basic auth header required to access the api to the array of headers provided
@param $headers | [
"Helper",
"function",
"to",
"add",
"the",
"basic",
"auth",
"header",
"required",
"to",
"access",
"the",
"api",
"to",
"the",
"array",
"of",
"headers",
"provided"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L147-L152 |
30,311 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.createStack | public function createStack(string $stackName, $dockerCompose = null, $rancherCompose = null) {
if($dockerCompose === null)
$dockerCompose = '';
if($rancherCompose === null)
$rancherCompose = '';
$url = implode('/', [
$this->account->getUrl(),
'environments'
]);
$headers = [];
$this->addAuthHeader($headers);
$jsonContent = json_encode([
'name' => $stackName,
'dockerCompose' => $dockerCompose,
'rancherCompose' => $rancherCompose,
]);
$headers['Content-Type'] = 'application/json';
$headers['Content-Length'] = strlen($jsonContent);
$this->apiService->post($url, $jsonContent, $headers);
} | php | public function createStack(string $stackName, $dockerCompose = null, $rancherCompose = null) {
if($dockerCompose === null)
$dockerCompose = '';
if($rancherCompose === null)
$rancherCompose = '';
$url = implode('/', [
$this->account->getUrl(),
'environments'
]);
$headers = [];
$this->addAuthHeader($headers);
$jsonContent = json_encode([
'name' => $stackName,
'dockerCompose' => $dockerCompose,
'rancherCompose' => $rancherCompose,
]);
$headers['Content-Type'] = 'application/json';
$headers['Content-Length'] = strlen($jsonContent);
$this->apiService->post($url, $jsonContent, $headers);
} | [
"public",
"function",
"createStack",
"(",
"string",
"$",
"stackName",
",",
"$",
"dockerCompose",
"=",
"null",
",",
"$",
"rancherCompose",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"dockerCompose",
"===",
"null",
")",
"$",
"dockerCompose",
"=",
"''",
";",
"if",
"(",
"$",
"rancherCompose",
"===",
"null",
")",
"$",
"rancherCompose",
"=",
"''",
";",
"$",
"url",
"=",
"implode",
"(",
"'/'",
",",
"[",
"$",
"this",
"->",
"account",
"->",
"getUrl",
"(",
")",
",",
"'environments'",
"]",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"addAuthHeader",
"(",
"$",
"headers",
")",
";",
"$",
"jsonContent",
"=",
"json_encode",
"(",
"[",
"'name'",
"=>",
"$",
"stackName",
",",
"'dockerCompose'",
"=>",
"$",
"dockerCompose",
",",
"'rancherCompose'",
"=>",
"$",
"rancherCompose",
",",
"]",
")",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/json'",
";",
"$",
"headers",
"[",
"'Content-Length'",
"]",
"=",
"strlen",
"(",
"$",
"jsonContent",
")",
";",
"$",
"this",
"->",
"apiService",
"->",
"post",
"(",
"$",
"url",
",",
"$",
"jsonContent",
",",
"$",
"headers",
")",
";",
"}"
] | Prompt Rnacher to create a stack with the given name using the provided dockerCompose and rancherCompose files
@param string $stackName
@param null $dockerCompose
@param null $rancherCompose | [
"Prompt",
"Rnacher",
"to",
"create",
"a",
"stack",
"with",
"the",
"given",
"name",
"using",
"the",
"provided",
"dockerCompose",
"and",
"rancherCompose",
"files"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L161-L186 |
30,312 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.start | public function start(string $directory, string $stackName, array $serviceNames = null, bool $upgrade = false, bool $forcedUpgrade = false) {
if($serviceNames === null)
$serviceNames = [];
if( !is_array($serviceNames) )
$serviceNames = [$serviceNames];
$url = $this->getUrl();
$account = $this->account;
if ($this->cliMode && $account instanceof RancherCliAccount)
$command = [
$account->getCliVersion(),
'up',
"-f",
"$directory/docker-compose.yml",
'--rancher-file',
"$directory/rancher-compose.yml",
'-s',
$stackName,
'-d',
'-p'
];
else
$command = [
$account->getRancherCompose(),
"-f",
"$directory/docker-compose.yml",
'-r',
"$directory/rancher-compose.yml",
'-p',
$stackName,
'up',
'-d',
'-p'
];
if($upgrade)
$command = array_merge($command, ['--upgrade']);
if($forcedUpgrade)
$command = array_merge($command, ['--force-upgrade']);
$command = array_merge($command, $serviceNames);
$process = ProcessBuilder::create( $command )
->setTimeout(null)
->addEnvironmentVariables([
'RANCHER_URL' => $url,
'RANCHER_ACCESS_KEY' => $this->account->getKey(),
'RANCHER_SECRET_KEY' => $this->account->getSecret(),
])->getProcess();
$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if( $ran->getExitCode() != 0 )
throw new StartFailedException("Command ".$ran->getCommandLine());
} | php | public function start(string $directory, string $stackName, array $serviceNames = null, bool $upgrade = false, bool $forcedUpgrade = false) {
if($serviceNames === null)
$serviceNames = [];
if( !is_array($serviceNames) )
$serviceNames = [$serviceNames];
$url = $this->getUrl();
$account = $this->account;
if ($this->cliMode && $account instanceof RancherCliAccount)
$command = [
$account->getCliVersion(),
'up',
"-f",
"$directory/docker-compose.yml",
'--rancher-file',
"$directory/rancher-compose.yml",
'-s',
$stackName,
'-d',
'-p'
];
else
$command = [
$account->getRancherCompose(),
"-f",
"$directory/docker-compose.yml",
'-r',
"$directory/rancher-compose.yml",
'-p',
$stackName,
'up',
'-d',
'-p'
];
if($upgrade)
$command = array_merge($command, ['--upgrade']);
if($forcedUpgrade)
$command = array_merge($command, ['--force-upgrade']);
$command = array_merge($command, $serviceNames);
$process = ProcessBuilder::create( $command )
->setTimeout(null)
->addEnvironmentVariables([
'RANCHER_URL' => $url,
'RANCHER_ACCESS_KEY' => $this->account->getKey(),
'RANCHER_SECRET_KEY' => $this->account->getSecret(),
])->getProcess();
$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if( $ran->getExitCode() != 0 )
throw new StartFailedException("Command ".$ran->getCommandLine());
} | [
"public",
"function",
"start",
"(",
"string",
"$",
"directory",
",",
"string",
"$",
"stackName",
",",
"array",
"$",
"serviceNames",
"=",
"null",
",",
"bool",
"$",
"upgrade",
"=",
"false",
",",
"bool",
"$",
"forcedUpgrade",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"serviceNames",
"===",
"null",
")",
"$",
"serviceNames",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"serviceNames",
")",
")",
"$",
"serviceNames",
"=",
"[",
"$",
"serviceNames",
"]",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
";",
"$",
"account",
"=",
"$",
"this",
"->",
"account",
";",
"if",
"(",
"$",
"this",
"->",
"cliMode",
"&&",
"$",
"account",
"instanceof",
"RancherCliAccount",
")",
"$",
"command",
"=",
"[",
"$",
"account",
"->",
"getCliVersion",
"(",
")",
",",
"'up'",
",",
"\"-f\"",
",",
"\"$directory/docker-compose.yml\"",
",",
"'--rancher-file'",
",",
"\"$directory/rancher-compose.yml\"",
",",
"'-s'",
",",
"$",
"stackName",
",",
"'-d'",
",",
"'-p'",
"]",
";",
"else",
"$",
"command",
"=",
"[",
"$",
"account",
"->",
"getRancherCompose",
"(",
")",
",",
"\"-f\"",
",",
"\"$directory/docker-compose.yml\"",
",",
"'-r'",
",",
"\"$directory/rancher-compose.yml\"",
",",
"'-p'",
",",
"$",
"stackName",
",",
"'up'",
",",
"'-d'",
",",
"'-p'",
"]",
";",
"if",
"(",
"$",
"upgrade",
")",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"[",
"'--upgrade'",
"]",
")",
";",
"if",
"(",
"$",
"forcedUpgrade",
")",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"[",
"'--force-upgrade'",
"]",
")",
";",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"$",
"serviceNames",
")",
";",
"$",
"process",
"=",
"ProcessBuilder",
"::",
"create",
"(",
"$",
"command",
")",
"->",
"setTimeout",
"(",
"null",
")",
"->",
"addEnvironmentVariables",
"(",
"[",
"'RANCHER_URL'",
"=>",
"$",
"url",
",",
"'RANCHER_ACCESS_KEY'",
"=>",
"$",
"this",
"->",
"account",
"->",
"getKey",
"(",
")",
",",
"'RANCHER_SECRET_KEY'",
"=>",
"$",
"this",
"->",
"account",
"->",
"getSecret",
"(",
")",
",",
"]",
")",
"->",
"getProcess",
"(",
")",
";",
"$",
"ran",
"=",
"$",
"this",
"->",
"processHelper",
"->",
"run",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"process",
",",
"null",
",",
"null",
",",
"OutputInterface",
"::",
"VERBOSITY_NORMAL",
")",
";",
"if",
"(",
"$",
"ran",
"->",
"getExitCode",
"(",
")",
"!=",
"0",
")",
"throw",
"new",
"StartFailedException",
"(",
"\"Command \"",
".",
"$",
"ran",
"->",
"getCommandLine",
"(",
")",
")",
";",
"}"
] | Start the currently built configuration inside the given rancher stack
@param string $directory
@param string $stackName
@param array $serviceNames only start a certain service
@param bool $upgrade
@param bool $forcedUpgrade | [
"Start",
"the",
"currently",
"built",
"configuration",
"inside",
"the",
"given",
"rancher",
"stack"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L215-L269 |
30,313 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.confirm | public function confirm(string $directory, string $stackName, array $serviceNames = null) {
if($serviceNames === null)
$serviceNames = [];
if( !is_array($serviceNames) )
$serviceNames = [$serviceNames];
$url = $this->getUrl();
$command = [
$this->account->getRancherCompose(), "-f", "$directory/docker-compose.yml", '-r',
"$directory/rancher-compose.yml", '-p', $stackName, 'up', '-d', '--confirm-upgrade'
];
$command = array_merge($command, $serviceNames);
$process = ProcessBuilder::create( $command )
->setTimeout(null)
->addEnvironmentVariables([
'RANCHER_URL' => $url,
'RANCHER_ACCESS_KEY' => $this->account->getKey(),
'RANCHER_SECRET_KEY' => $this->account->getSecret(),
])->getProcess();
$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if( $ran->getExitCode() != 0 )
throw new ConfirmFailedException("Command ".$ran->getCommandLine());
} | php | public function confirm(string $directory, string $stackName, array $serviceNames = null) {
if($serviceNames === null)
$serviceNames = [];
if( !is_array($serviceNames) )
$serviceNames = [$serviceNames];
$url = $this->getUrl();
$command = [
$this->account->getRancherCompose(), "-f", "$directory/docker-compose.yml", '-r',
"$directory/rancher-compose.yml", '-p', $stackName, 'up', '-d', '--confirm-upgrade'
];
$command = array_merge($command, $serviceNames);
$process = ProcessBuilder::create( $command )
->setTimeout(null)
->addEnvironmentVariables([
'RANCHER_URL' => $url,
'RANCHER_ACCESS_KEY' => $this->account->getKey(),
'RANCHER_SECRET_KEY' => $this->account->getSecret(),
])->getProcess();
$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if( $ran->getExitCode() != 0 )
throw new ConfirmFailedException("Command ".$ran->getCommandLine());
} | [
"public",
"function",
"confirm",
"(",
"string",
"$",
"directory",
",",
"string",
"$",
"stackName",
",",
"array",
"$",
"serviceNames",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"serviceNames",
"===",
"null",
")",
"$",
"serviceNames",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"serviceNames",
")",
")",
"$",
"serviceNames",
"=",
"[",
"$",
"serviceNames",
"]",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
";",
"$",
"command",
"=",
"[",
"$",
"this",
"->",
"account",
"->",
"getRancherCompose",
"(",
")",
",",
"\"-f\"",
",",
"\"$directory/docker-compose.yml\"",
",",
"'-r'",
",",
"\"$directory/rancher-compose.yml\"",
",",
"'-p'",
",",
"$",
"stackName",
",",
"'up'",
",",
"'-d'",
",",
"'--confirm-upgrade'",
"]",
";",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"$",
"serviceNames",
")",
";",
"$",
"process",
"=",
"ProcessBuilder",
"::",
"create",
"(",
"$",
"command",
")",
"->",
"setTimeout",
"(",
"null",
")",
"->",
"addEnvironmentVariables",
"(",
"[",
"'RANCHER_URL'",
"=>",
"$",
"url",
",",
"'RANCHER_ACCESS_KEY'",
"=>",
"$",
"this",
"->",
"account",
"->",
"getKey",
"(",
")",
",",
"'RANCHER_SECRET_KEY'",
"=>",
"$",
"this",
"->",
"account",
"->",
"getSecret",
"(",
")",
",",
"]",
")",
"->",
"getProcess",
"(",
")",
";",
"$",
"ran",
"=",
"$",
"this",
"->",
"processHelper",
"->",
"run",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"process",
",",
"null",
",",
"null",
",",
"OutputInterface",
"::",
"VERBOSITY_NORMAL",
")",
";",
"if",
"(",
"$",
"ran",
"->",
"getExitCode",
"(",
")",
"!=",
"0",
")",
"throw",
"new",
"ConfirmFailedException",
"(",
"\"Command \"",
".",
"$",
"ran",
"->",
"getCommandLine",
"(",
")",
")",
";",
"}"
] | Confirm an in-service upgrade
@param string $directory
@param string $stackName
@param array $serviceNames only start a certain service | [
"Confirm",
"an",
"in",
"-",
"service",
"upgrade"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L278-L303 |
30,314 | ipunkt/rancherize | app/RancherAccess/RancherService.php | RancherService.upgrade | public function upgrade(string $directory, string $stackName, string $activeService, string $replacementService) {
$baseCommand = [
$this->account->getRancherCompose(), "-f", "$directory/docker-compose.yml", '-r', "$directory/rancher-compose.yml", '-p', $stackName
];
$commands = [
'upgrade' => array_merge($baseCommand, ['upgrade', '-w', '-c', $activeService, $replacementService]),
'up' => array_merge($baseCommand, ['up', '-d', '-c']),
];
$usedCommand = 'upgrade';
if($activeService === $replacementService)
$usedCommand = 'up';
$url = $this->getUrl();
$process = ProcessBuilder::create( $commands[$usedCommand] )
->setTimeout(null)
->addEnvironmentVariables([
'RANCHER_URL' => $url,
'RANCHER_ACCESS_KEY' => $this->account->getKey(),
'RANCHER_SECRET_KEY' => $this->account->getSecret(),
])->getProcess();
$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if( $ran->getExitCode() != 0 )
throw new UpgradeFailedException("Command ".$ran->getCommandLine());
} | php | public function upgrade(string $directory, string $stackName, string $activeService, string $replacementService) {
$baseCommand = [
$this->account->getRancherCompose(), "-f", "$directory/docker-compose.yml", '-r', "$directory/rancher-compose.yml", '-p', $stackName
];
$commands = [
'upgrade' => array_merge($baseCommand, ['upgrade', '-w', '-c', $activeService, $replacementService]),
'up' => array_merge($baseCommand, ['up', '-d', '-c']),
];
$usedCommand = 'upgrade';
if($activeService === $replacementService)
$usedCommand = 'up';
$url = $this->getUrl();
$process = ProcessBuilder::create( $commands[$usedCommand] )
->setTimeout(null)
->addEnvironmentVariables([
'RANCHER_URL' => $url,
'RANCHER_ACCESS_KEY' => $this->account->getKey(),
'RANCHER_SECRET_KEY' => $this->account->getSecret(),
])->getProcess();
$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
if( $ran->getExitCode() != 0 )
throw new UpgradeFailedException("Command ".$ran->getCommandLine());
} | [
"public",
"function",
"upgrade",
"(",
"string",
"$",
"directory",
",",
"string",
"$",
"stackName",
",",
"string",
"$",
"activeService",
",",
"string",
"$",
"replacementService",
")",
"{",
"$",
"baseCommand",
"=",
"[",
"$",
"this",
"->",
"account",
"->",
"getRancherCompose",
"(",
")",
",",
"\"-f\"",
",",
"\"$directory/docker-compose.yml\"",
",",
"'-r'",
",",
"\"$directory/rancher-compose.yml\"",
",",
"'-p'",
",",
"$",
"stackName",
"]",
";",
"$",
"commands",
"=",
"[",
"'upgrade'",
"=>",
"array_merge",
"(",
"$",
"baseCommand",
",",
"[",
"'upgrade'",
",",
"'-w'",
",",
"'-c'",
",",
"$",
"activeService",
",",
"$",
"replacementService",
"]",
")",
",",
"'up'",
"=>",
"array_merge",
"(",
"$",
"baseCommand",
",",
"[",
"'up'",
",",
"'-d'",
",",
"'-c'",
"]",
")",
",",
"]",
";",
"$",
"usedCommand",
"=",
"'upgrade'",
";",
"if",
"(",
"$",
"activeService",
"===",
"$",
"replacementService",
")",
"$",
"usedCommand",
"=",
"'up'",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
";",
"$",
"process",
"=",
"ProcessBuilder",
"::",
"create",
"(",
"$",
"commands",
"[",
"$",
"usedCommand",
"]",
")",
"->",
"setTimeout",
"(",
"null",
")",
"->",
"addEnvironmentVariables",
"(",
"[",
"'RANCHER_URL'",
"=>",
"$",
"url",
",",
"'RANCHER_ACCESS_KEY'",
"=>",
"$",
"this",
"->",
"account",
"->",
"getKey",
"(",
")",
",",
"'RANCHER_SECRET_KEY'",
"=>",
"$",
"this",
"->",
"account",
"->",
"getSecret",
"(",
")",
",",
"]",
")",
"->",
"getProcess",
"(",
")",
";",
"$",
"ran",
"=",
"$",
"this",
"->",
"processHelper",
"->",
"run",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"process",
",",
"null",
",",
"null",
",",
"OutputInterface",
"::",
"VERBOSITY_NORMAL",
")",
";",
"if",
"(",
"$",
"ran",
"->",
"getExitCode",
"(",
")",
"!=",
"0",
")",
"throw",
"new",
"UpgradeFailedException",
"(",
"\"Command \"",
".",
"$",
"ran",
"->",
"getCommandLine",
"(",
")",
")",
";",
"}"
] | Upgrade the given activeService to the replacementService within the given stack, using the currently built
configuration in directory
@param string $directory
@param string $stackName
@param string $activeService
@param string $replacementService | [
"Upgrade",
"the",
"given",
"activeService",
"to",
"the",
"replacementService",
"within",
"the",
"given",
"stack",
"using",
"the",
"currently",
"built",
"configuration",
"in",
"directory"
] | 3c226da686b283e7fef961a9a79b54db53b8757b | https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/RancherAccess/RancherService.php#L314-L342 |
30,315 | SIELOnline/libAcumulus | src/Magento/Invoice/FlattenerInvoiceLines.php | FlattenerInvoiceLines.isChildSameAsParent | protected function isChildSameAsParent(array $parent, array $children)
{
if (count($children) === 1) {
$child = reset($children);
if ($parent[Tag::ItemNumber] === $child[Tag::ItemNumber]
&& $parent[Tag::Quantity] === $child[Tag::Quantity]
&& Number::isZero($child[Tag::UnitPrice])
) {
return true;
}
}
return false;
} | php | protected function isChildSameAsParent(array $parent, array $children)
{
if (count($children) === 1) {
$child = reset($children);
if ($parent[Tag::ItemNumber] === $child[Tag::ItemNumber]
&& $parent[Tag::Quantity] === $child[Tag::Quantity]
&& Number::isZero($child[Tag::UnitPrice])
) {
return true;
}
}
return false;
} | [
"protected",
"function",
"isChildSameAsParent",
"(",
"array",
"$",
"parent",
",",
"array",
"$",
"children",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"children",
")",
"===",
"1",
")",
"{",
"$",
"child",
"=",
"reset",
"(",
"$",
"children",
")",
";",
"if",
"(",
"$",
"parent",
"[",
"Tag",
"::",
"ItemNumber",
"]",
"===",
"$",
"child",
"[",
"Tag",
"::",
"ItemNumber",
"]",
"&&",
"$",
"parent",
"[",
"Tag",
"::",
"Quantity",
"]",
"===",
"$",
"child",
"[",
"Tag",
"::",
"Quantity",
"]",
"&&",
"Number",
"::",
"isZero",
"(",
"$",
"child",
"[",
"Tag",
"::",
"UnitPrice",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns whether a single child line is actually the same as its parent.
If:
- there is exactly 1 child line
- for the same item number and quantity
- with no price info on the child
We seem to be processing a configurable product that for some reason
appears twice: do not add the child, but copy the product description
to the result as it contains more option descriptions.
@param array $parent
@param array[] $children
@return bool
True if the single child line is actually the same as its parent. | [
"Returns",
"whether",
"a",
"single",
"child",
"line",
"is",
"actually",
"the",
"same",
"as",
"its",
"parent",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Invoice/FlattenerInvoiceLines.php#L89-L101 |
30,316 | SIELOnline/libAcumulus | src/Invoice/Source.php | Source.completeTotals | protected function completeTotals(array $totals)
{
if (!isset($totals[Meta::InvoiceAmount])) {
$totals[Meta::InvoiceAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceVatAmount];
$totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmount;
}
if (!isset($totals[Meta::InvoiceAmountInc])) {
$totals[Meta::InvoiceAmountInc] = $totals[Meta::InvoiceAmount] + $totals[Meta::InvoiceVatAmount];
$totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmountInc;
}
if (!isset($totals[Meta::InvoiceVatAmount])) {
$totals[Meta::InvoiceVatAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceAmount];
$totals[Meta::InvoiceCalculated ] = Meta::InvoiceVatAmount;
}
return $totals;
} | php | protected function completeTotals(array $totals)
{
if (!isset($totals[Meta::InvoiceAmount])) {
$totals[Meta::InvoiceAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceVatAmount];
$totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmount;
}
if (!isset($totals[Meta::InvoiceAmountInc])) {
$totals[Meta::InvoiceAmountInc] = $totals[Meta::InvoiceAmount] + $totals[Meta::InvoiceVatAmount];
$totals[Meta::InvoiceCalculated ] = Meta::InvoiceAmountInc;
}
if (!isset($totals[Meta::InvoiceVatAmount])) {
$totals[Meta::InvoiceVatAmount] = $totals[Meta::InvoiceAmountInc] - $totals[Meta::InvoiceAmount];
$totals[Meta::InvoiceCalculated ] = Meta::InvoiceVatAmount;
}
return $totals;
} | [
"protected",
"function",
"completeTotals",
"(",
"array",
"$",
"totals",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmount",
"]",
")",
")",
"{",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmount",
"]",
"=",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmountInc",
"]",
"-",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceVatAmount",
"]",
";",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceCalculated",
"]",
"=",
"Meta",
"::",
"InvoiceAmount",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmountInc",
"]",
")",
")",
"{",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmountInc",
"]",
"=",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmount",
"]",
"+",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceVatAmount",
"]",
";",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceCalculated",
"]",
"=",
"Meta",
"::",
"InvoiceAmountInc",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceVatAmount",
"]",
")",
")",
"{",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceVatAmount",
"]",
"=",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmountInc",
"]",
"-",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceAmount",
"]",
";",
"$",
"totals",
"[",
"Meta",
"::",
"InvoiceCalculated",
"]",
"=",
"Meta",
"::",
"InvoiceVatAmount",
";",
"}",
"return",
"$",
"totals",
";",
"}"
] | Completes the set of invoice totals as set by getInvoiceTotals.
Most shops only provide 2 out of these 3 in their data, so we calculate
the 3rd.
Do not override this method, just implement getAvailableTotals().
@param array $totals
The invoice totals to complete with missing total fields.
@return array
The invoice totals with all invoice total fields. | [
"Completes",
"the",
"set",
"of",
"invoice",
"totals",
"as",
"set",
"by",
"getInvoiceTotals",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Source.php#L299-L314 |
30,317 | SIELOnline/libAcumulus | src/Invoice/Source.php | Source.getCreditNotes | public function getCreditNotes()
{
$result = null;
if ($this->getType() === static::Order) {
$result = array();
$shopCreditNotes = $this->getShopCreditNotesOrIds();
foreach ($shopCreditNotes as $shopCreditNote) {
$result[] = new static(static::CreditNote, $shopCreditNote);
}
}
return $result;
} | php | public function getCreditNotes()
{
$result = null;
if ($this->getType() === static::Order) {
$result = array();
$shopCreditNotes = $this->getShopCreditNotesOrIds();
foreach ($shopCreditNotes as $shopCreditNote) {
$result[] = new static(static::CreditNote, $shopCreditNote);
}
}
return $result;
} | [
"public",
"function",
"getCreditNotes",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"static",
"::",
"Order",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"shopCreditNotes",
"=",
"$",
"this",
"->",
"getShopCreditNotesOrIds",
"(",
")",
";",
"foreach",
"(",
"$",
"shopCreditNotes",
"as",
"$",
"shopCreditNote",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"new",
"static",
"(",
"static",
"::",
"CreditNote",
",",
"$",
"shopCreditNote",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the set of credit note sources for an order source.
Do not override this method but override getShopCreditNotes() instead.
@return Source[]|null
If the invoice source is an order, an array of refunds is returned,
null otherwise. | [
"Returns",
"the",
"set",
"of",
"credit",
"note",
"sources",
"for",
"an",
"order",
"source",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Source.php#L420-L431 |
30,318 | SIELOnline/libAcumulus | src/Invoice/Source.php | Source.callTypeSpecificMethod | protected function callTypeSpecificMethod($method, $args = array())
{
$method .= $this->getType();
if (method_exists($this, $method)) {
return call_user_func_array(array($this, $method), $args);
}
return null;
} | php | protected function callTypeSpecificMethod($method, $args = array())
{
$method .= $this->getType();
if (method_exists($this, $method)) {
return call_user_func_array(array($this, $method), $args);
}
return null;
} | [
"protected",
"function",
"callTypeSpecificMethod",
"(",
"$",
"method",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"method",
".=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"method",
")",
",",
"$",
"args",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Calls a "sub" method whose logic depends on the type of invoice source.
This allows to separate logic for different source types into different
methods.
The method name is expected to be the original method name suffixed with
the source type (Order or CreditNote).
@param string $method
The original method called.
@param array $args
The parameters to pass to the type specific method.
@return mixed | [
"Calls",
"a",
"sub",
"method",
"whose",
"logic",
"depends",
"on",
"the",
"type",
"of",
"invoice",
"source",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Source.php#L466-L473 |
30,319 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Api_Basic.readFolder | public function readFolder($dir = null) {
$this->setPaymentMethodsFolder(DIR . DS . 'paymentmethods');
if ($dir)
$this->setPaymentMethodsFolder($dir);
$this->paymentMethods = array();
try {
$folder = $this->_folderPaymentMethods;
$handle = is_dir($folder) ? opendir($folder) : false;
if ($handle) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != ".svn") {
require_once (sprintf("%s/%s", $this->_folderPaymentMethods, $file));
$name = strtolower(substr($file, 0, strlen($file) - 4));
$className = "Icepay_Paymentmethod_" . ucfirst($name);
$this->paymentMethods[$name] = $className;
}
}
}
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
return $this;
} | php | public function readFolder($dir = null) {
$this->setPaymentMethodsFolder(DIR . DS . 'paymentmethods');
if ($dir)
$this->setPaymentMethodsFolder($dir);
$this->paymentMethods = array();
try {
$folder = $this->_folderPaymentMethods;
$handle = is_dir($folder) ? opendir($folder) : false;
if ($handle) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != ".svn") {
require_once (sprintf("%s/%s", $this->_folderPaymentMethods, $file));
$name = strtolower(substr($file, 0, strlen($file) - 4));
$className = "Icepay_Paymentmethod_" . ucfirst($name);
$this->paymentMethods[$name] = $className;
}
}
}
} catch (Exception $e) {
throw new Exception($e->getMessage());
}
return $this;
} | [
"public",
"function",
"readFolder",
"(",
"$",
"dir",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setPaymentMethodsFolder",
"(",
"DIR",
".",
"DS",
".",
"'paymentmethods'",
")",
";",
"if",
"(",
"$",
"dir",
")",
"$",
"this",
"->",
"setPaymentMethodsFolder",
"(",
"$",
"dir",
")",
";",
"$",
"this",
"->",
"paymentMethods",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"folder",
"=",
"$",
"this",
"->",
"_folderPaymentMethods",
";",
"$",
"handle",
"=",
"is_dir",
"(",
"$",
"folder",
")",
"?",
"opendir",
"(",
"$",
"folder",
")",
":",
"false",
";",
"if",
"(",
"$",
"handle",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"$",
"file",
"!=",
"\".\"",
"&&",
"$",
"file",
"!=",
"\"..\"",
"&&",
"$",
"file",
"!=",
"\".svn\"",
")",
"{",
"require_once",
"(",
"sprintf",
"(",
"\"%s/%s\"",
",",
"$",
"this",
"->",
"_folderPaymentMethods",
",",
"$",
"file",
")",
")",
";",
"$",
"name",
"=",
"strtolower",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"strlen",
"(",
"$",
"file",
")",
"-",
"4",
")",
")",
";",
"$",
"className",
"=",
"\"Icepay_Paymentmethod_\"",
".",
"ucfirst",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"paymentMethods",
"[",
"$",
"name",
"]",
"=",
"$",
"className",
";",
"}",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Store the paymentmethod class names in the paymentmethods array.
@since version 1.0.0
@access public
@param string $dir Folder of the paymentmethod classes | [
"Store",
"the",
"paymentmethod",
"class",
"names",
"in",
"the",
"paymentmethods",
"array",
"."
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L76-L101 |
30,320 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Api_Basic.filterByLanguage | public function filterByLanguage($language) {
foreach ($this->_paymentMethod as $name => $class) {
if (!in_array(strtoupper($language), $class->getSupportedLanguages()) && !in_array('00', $class->getSupportedLanguages()))
unset($this->paymentMethods[$name]);
}
return $this;
} | php | public function filterByLanguage($language) {
foreach ($this->_paymentMethod as $name => $class) {
if (!in_array(strtoupper($language), $class->getSupportedLanguages()) && !in_array('00', $class->getSupportedLanguages()))
unset($this->paymentMethods[$name]);
}
return $this;
} | [
"public",
"function",
"filterByLanguage",
"(",
"$",
"language",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_paymentMethod",
"as",
"$",
"name",
"=>",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"strtoupper",
"(",
"$",
"language",
")",
",",
"$",
"class",
"->",
"getSupportedLanguages",
"(",
")",
")",
"&&",
"!",
"in_array",
"(",
"'00'",
",",
"$",
"class",
"->",
"getSupportedLanguages",
"(",
")",
")",
")",
"unset",
"(",
"$",
"this",
"->",
"paymentMethods",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Filter the paymentmethods array by language
@since version 1.0.0
@access public
@param string $language Language ISO 639-1 code | [
"Filter",
"the",
"paymentmethods",
"array",
"by",
"language"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L159-L165 |
30,321 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Basicmode.validatePayment | public function validatePayment(Icepay_PaymentObject_Interface_Abstract $payment) {
/* Clear the generated URL */
$this->resetURL();
$this->data = (object) array_merge((array) $this->data, (array) $payment->getData());
if (!$payment->getPaymentMethod())
return $this;
$paymentmethod = $payment->getBasicPaymentmethodClass();
if (!$this->exists($payment->getCountry(), $paymentmethod->getSupportedCountries()))
throw new Exception('Country not supported');
if (!$this->exists($payment->getCurrency(), $paymentmethod->getSupportedCurrency()))
throw new Exception('Currency not supported');
if (!$this->exists($payment->getLanguage(), $paymentmethod->getSupportedLanguages()))
throw new Exception('Language not supported');
if (!$this->exists($payment->getIssuer(), $paymentmethod->getSupportedIssuers()) && $payment->getPaymentMethod() != null)
throw new Exception('Issuer not supported');
/* used for webservice call */
$this->paymentObj = $payment;
return $this;
} | php | public function validatePayment(Icepay_PaymentObject_Interface_Abstract $payment) {
/* Clear the generated URL */
$this->resetURL();
$this->data = (object) array_merge((array) $this->data, (array) $payment->getData());
if (!$payment->getPaymentMethod())
return $this;
$paymentmethod = $payment->getBasicPaymentmethodClass();
if (!$this->exists($payment->getCountry(), $paymentmethod->getSupportedCountries()))
throw new Exception('Country not supported');
if (!$this->exists($payment->getCurrency(), $paymentmethod->getSupportedCurrency()))
throw new Exception('Currency not supported');
if (!$this->exists($payment->getLanguage(), $paymentmethod->getSupportedLanguages()))
throw new Exception('Language not supported');
if (!$this->exists($payment->getIssuer(), $paymentmethod->getSupportedIssuers()) && $payment->getPaymentMethod() != null)
throw new Exception('Issuer not supported');
/* used for webservice call */
$this->paymentObj = $payment;
return $this;
} | [
"public",
"function",
"validatePayment",
"(",
"Icepay_PaymentObject_Interface_Abstract",
"$",
"payment",
")",
"{",
"/* Clear the generated URL */",
"$",
"this",
"->",
"resetURL",
"(",
")",
";",
"$",
"this",
"->",
"data",
"=",
"(",
"object",
")",
"array_merge",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"data",
",",
"(",
"array",
")",
"$",
"payment",
"->",
"getData",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"payment",
"->",
"getPaymentMethod",
"(",
")",
")",
"return",
"$",
"this",
";",
"$",
"paymentmethod",
"=",
"$",
"payment",
"->",
"getBasicPaymentmethodClass",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"payment",
"->",
"getCountry",
"(",
")",
",",
"$",
"paymentmethod",
"->",
"getSupportedCountries",
"(",
")",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Country not supported'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"payment",
"->",
"getCurrency",
"(",
")",
",",
"$",
"paymentmethod",
"->",
"getSupportedCurrency",
"(",
")",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Currency not supported'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"payment",
"->",
"getLanguage",
"(",
")",
",",
"$",
"paymentmethod",
"->",
"getSupportedLanguages",
"(",
")",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Language not supported'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"payment",
"->",
"getIssuer",
"(",
")",
",",
"$",
"paymentmethod",
"->",
"getSupportedIssuers",
"(",
")",
")",
"&&",
"$",
"payment",
"->",
"getPaymentMethod",
"(",
")",
"!=",
"null",
")",
"throw",
"new",
"Exception",
"(",
"'Issuer not supported'",
")",
";",
"/* used for webservice call */",
"$",
"this",
"->",
"paymentObj",
"=",
"$",
"payment",
";",
"return",
"$",
"this",
";",
"}"
] | Required for using the basicmode
@since version 2.1.0
@access public
@param Icepay_PaymentObject_Interface_Abstract $payment | [
"Required",
"for",
"using",
"the",
"basicmode"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L294-L321 |
30,322 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Basicmode.generateFingerPrint | public function generateFingerPrint() {
if ($this->_fingerPrint != null)
return $this->fingerPrint;
$this->fingerPrint = sha1($this->getVersion());
return $this->fingerPrint;
} | php | public function generateFingerPrint() {
if ($this->_fingerPrint != null)
return $this->fingerPrint;
$this->fingerPrint = sha1($this->getVersion());
return $this->fingerPrint;
} | [
"public",
"function",
"generateFingerPrint",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_fingerPrint",
"!=",
"null",
")",
"return",
"$",
"this",
"->",
"fingerPrint",
";",
"$",
"this",
"->",
"fingerPrint",
"=",
"sha1",
"(",
"$",
"this",
"->",
"getVersion",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"fingerPrint",
";",
"}"
] | Calls the API to generate a Fingerprint
@since version 1.0.0
@access protected
@return string SHA1 hash | [
"Calls",
"the",
"API",
"to",
"generate",
"a",
"Fingerprint"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L433-L438 |
30,323 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Basicmode.basicMode | protected function basicMode() {
if (isset($this->data->ic_paymentmethod)) {
$querystring = http_build_query(array(
'type' => $this->data->ic_paymentmethod,
'checkout' => 'yes',
'ic_redirect' => 'no',
'ic_country' => $this->data->ic_country,
'ic_language' => $this->data->ic_language,
'ic_fp' => $this->generateFingerPrint()
), '', '&');
} else {
$querystring = http_build_query(array(
'ic_country' => $this->data->ic_country,
'ic_language' => $this->data->ic_language,
'ic_fp' => $this->generateFingerPrint()
), '', '&');
}
return sprintf("%s://%s?%s", $this->_postProtocol, $this->_basicmodeURL, $querystring);
} | php | protected function basicMode() {
if (isset($this->data->ic_paymentmethod)) {
$querystring = http_build_query(array(
'type' => $this->data->ic_paymentmethod,
'checkout' => 'yes',
'ic_redirect' => 'no',
'ic_country' => $this->data->ic_country,
'ic_language' => $this->data->ic_language,
'ic_fp' => $this->generateFingerPrint()
), '', '&');
} else {
$querystring = http_build_query(array(
'ic_country' => $this->data->ic_country,
'ic_language' => $this->data->ic_language,
'ic_fp' => $this->generateFingerPrint()
), '', '&');
}
return sprintf("%s://%s?%s", $this->_postProtocol, $this->_basicmodeURL, $querystring);
} | [
"protected",
"function",
"basicMode",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"->",
"ic_paymentmethod",
")",
")",
"{",
"$",
"querystring",
"=",
"http_build_query",
"(",
"array",
"(",
"'type'",
"=>",
"$",
"this",
"->",
"data",
"->",
"ic_paymentmethod",
",",
"'checkout'",
"=>",
"'yes'",
",",
"'ic_redirect'",
"=>",
"'no'",
",",
"'ic_country'",
"=>",
"$",
"this",
"->",
"data",
"->",
"ic_country",
",",
"'ic_language'",
"=>",
"$",
"this",
"->",
"data",
"->",
"ic_language",
",",
"'ic_fp'",
"=>",
"$",
"this",
"->",
"generateFingerPrint",
"(",
")",
")",
",",
"''",
",",
"'&'",
")",
";",
"}",
"else",
"{",
"$",
"querystring",
"=",
"http_build_query",
"(",
"array",
"(",
"'ic_country'",
"=>",
"$",
"this",
"->",
"data",
"->",
"ic_country",
",",
"'ic_language'",
"=>",
"$",
"this",
"->",
"data",
"->",
"ic_language",
",",
"'ic_fp'",
"=>",
"$",
"this",
"->",
"generateFingerPrint",
"(",
")",
")",
",",
"''",
",",
"'&'",
")",
";",
"}",
"return",
"sprintf",
"(",
"\"%s://%s?%s\"",
",",
"$",
"this",
"->",
"_postProtocol",
",",
"$",
"this",
"->",
"_basicmodeURL",
",",
"$",
"querystring",
")",
";",
"}"
] | Generates a URL to the ICEPAY basic API service
@since version 1.0.0
@access protected
@return string URL | [
"Generates",
"a",
"URL",
"to",
"the",
"ICEPAY",
"basic",
"API",
"service"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L446-L465 |
30,324 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Basicmode.postRequest | protected function postRequest($url, $data) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
if (!$response)
throw new Exception("Error reading $url");
if (( substr(strtolower($response), 0, 7) == "http://" ) || ( substr(strtolower($response), 0, 8) == "https://" )) {
return $response;
}
else
throw new Exception("Server response: " . strip_tags($response));
} | php | protected function postRequest($url, $data) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
if (!$response)
throw new Exception("Error reading $url");
if (( substr(strtolower($response), 0, 7) == "http://" ) || ( substr(strtolower($response), 0, 8) == "https://" )) {
return $response;
}
else
throw new Exception("Server response: " . strip_tags($response));
} | [
"protected",
"function",
"postRequest",
"(",
"$",
"url",
",",
"$",
"data",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data",
")",
";",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"!",
"$",
"response",
")",
"throw",
"new",
"Exception",
"(",
"\"Error reading $url\"",
")",
";",
"if",
"(",
"(",
"substr",
"(",
"strtolower",
"(",
"$",
"response",
")",
",",
"0",
",",
"7",
")",
"==",
"\"http://\"",
")",
"||",
"(",
"substr",
"(",
"strtolower",
"(",
"$",
"response",
")",
",",
"0",
",",
"8",
")",
"==",
"\"https://\"",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"else",
"throw",
"new",
"Exception",
"(",
"\"Server response: \"",
".",
"strip_tags",
"(",
"$",
"response",
")",
")",
";",
"}"
] | Used to connect to the ICEPAY servers
@since version 1.0.0
@access protected
@param string $url
@param array $data
@return string Returns a response from the specified URL | [
"Used",
"to",
"connect",
"to",
"the",
"ICEPAY",
"servers"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L475-L493 |
30,325 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Basicmode.generateCheckSum | protected function generateCheckSum() {
return sha1(
sprintf("%s|%s|%s|%s|%s|%s|%s", $this->_merchantID, $this->_secretCode, $this->data->ic_amount, $this->data->ic_orderid, $this->data->ic_reference, $this->data->ic_currency, $this->data->ic_country
)
);
} | php | protected function generateCheckSum() {
return sha1(
sprintf("%s|%s|%s|%s|%s|%s|%s", $this->_merchantID, $this->_secretCode, $this->data->ic_amount, $this->data->ic_orderid, $this->data->ic_reference, $this->data->ic_currency, $this->data->ic_country
)
);
} | [
"protected",
"function",
"generateCheckSum",
"(",
")",
"{",
"return",
"sha1",
"(",
"sprintf",
"(",
"\"%s|%s|%s|%s|%s|%s|%s\"",
",",
"$",
"this",
"->",
"_merchantID",
",",
"$",
"this",
"->",
"_secretCode",
",",
"$",
"this",
"->",
"data",
"->",
"ic_amount",
",",
"$",
"this",
"->",
"data",
"->",
"ic_orderid",
",",
"$",
"this",
"->",
"data",
"->",
"ic_reference",
",",
"$",
"this",
"->",
"data",
"->",
"ic_currency",
",",
"$",
"this",
"->",
"data",
"->",
"ic_country",
")",
")",
";",
"}"
] | Generate checksum for basicmode checkout
@since version 1.0.0
@access protected
@return string SHA1 encoded | [
"Generate",
"checksum",
"for",
"basicmode",
"checkout"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L501-L506 |
30,326 | ICEPAY/deprecated-i | src/icepay_api_basic.php | Icepay_Basicmode.generateCheckSumDynamic | protected function generateCheckSumDynamic() {
return sha1(
sprintf("%s|%s|%s|%s|%s|%s|%s|%s|%s", $this->_merchantID, $this->_secretCode, $this->data->ic_amount, $this->data->ic_orderid, $this->data->ic_reference, $this->data->ic_currency, $this->data->ic_country, $this->data->ic_urlcompleted, $this->data->ic_urlerror
)
);
} | php | protected function generateCheckSumDynamic() {
return sha1(
sprintf("%s|%s|%s|%s|%s|%s|%s|%s|%s", $this->_merchantID, $this->_secretCode, $this->data->ic_amount, $this->data->ic_orderid, $this->data->ic_reference, $this->data->ic_currency, $this->data->ic_country, $this->data->ic_urlcompleted, $this->data->ic_urlerror
)
);
} | [
"protected",
"function",
"generateCheckSumDynamic",
"(",
")",
"{",
"return",
"sha1",
"(",
"sprintf",
"(",
"\"%s|%s|%s|%s|%s|%s|%s|%s|%s\"",
",",
"$",
"this",
"->",
"_merchantID",
",",
"$",
"this",
"->",
"_secretCode",
",",
"$",
"this",
"->",
"data",
"->",
"ic_amount",
",",
"$",
"this",
"->",
"data",
"->",
"ic_orderid",
",",
"$",
"this",
"->",
"data",
"->",
"ic_reference",
",",
"$",
"this",
"->",
"data",
"->",
"ic_currency",
",",
"$",
"this",
"->",
"data",
"->",
"ic_country",
",",
"$",
"this",
"->",
"data",
"->",
"ic_urlcompleted",
",",
"$",
"this",
"->",
"data",
"->",
"ic_urlerror",
")",
")",
";",
"}"
] | Generate checksum for basicmode checkout using dynamic urls
@since version 1.0.1
@access protected
@return string SHA1 encoded | [
"Generate",
"checksum",
"for",
"basicmode",
"checkout",
"using",
"dynamic",
"urls"
] | 9a22271dfaea7f318a555c00d7e3f8cca9f2a28e | https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_basic.php#L514-L519 |
30,327 | SIELOnline/libAcumulus | src/Helpers/Translator.php | Translator.get | public function get($key)
{
return (isset($this->translations[$key]) ? $this->translations[$key] : $key);
} | php | public function get($key)
{
return (isset($this->translations[$key]) ? $this->translations[$key] : $key);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"translations",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"translations",
"[",
"$",
"key",
"]",
":",
"$",
"key",
")",
";",
"}"
] | Returns the string in the current language for the given key.
@param string $key
The key to look up.
@return string
Return in order of being available:
- The string in the current language for the given key.
- The string in Dutch for the given key.
- The key itself. | [
"Returns",
"the",
"string",
"in",
"the",
"current",
"language",
"for",
"the",
"given",
"key",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Translator.php#L100-L103 |
30,328 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/Creator.php | Creator.getVatRateLookupMetadataByTaxClass | protected function getVatRateLookupMetadataByTaxClass($taxClassId)
{
// '' denotes the 'standard'tax class, use 'standard' in meta data, ''
// when searching.
if ($taxClassId === '') {
$taxClassId = 'standard';
}
$result = array(
Meta::VatClassId => sanitize_title($taxClassId),
// Vat class name is the non-sanitized version of the id
// and thus does not convey more information: don't add.
Meta::VatRateLookup => array(),
Meta::VatRateLookupLabel => array(),
);
if ($taxClassId === 'standard') {
$taxClassId = '';
}
// Find applicable vat rates. We use WC_Tax::find_rates() to find them.
$args = array(
'tax_class' => $taxClassId,
'country' => $this->invoice[Tag::Customer][Tag::CountryCode],
'city' => isset($this->invoice[Tag::Customer][Tag::City]) ? $this->invoice[Tag::Customer][Tag::City] : '',
'postcode' => isset($this->invoice[Tag::Customer][Tag::PostalCode]) ? $this->invoice[Tag::Customer][Tag::PostalCode] : '',
);
$taxRates = WC_Tax::find_rates($args);
foreach ($taxRates as $taxRate) {
$result[Meta::VatRateLookup][] = $taxRate['rate'];
$result[Meta::VatRateLookupLabel][] = $taxRate['label'];
}
return $result;
} | php | protected function getVatRateLookupMetadataByTaxClass($taxClassId)
{
// '' denotes the 'standard'tax class, use 'standard' in meta data, ''
// when searching.
if ($taxClassId === '') {
$taxClassId = 'standard';
}
$result = array(
Meta::VatClassId => sanitize_title($taxClassId),
// Vat class name is the non-sanitized version of the id
// and thus does not convey more information: don't add.
Meta::VatRateLookup => array(),
Meta::VatRateLookupLabel => array(),
);
if ($taxClassId === 'standard') {
$taxClassId = '';
}
// Find applicable vat rates. We use WC_Tax::find_rates() to find them.
$args = array(
'tax_class' => $taxClassId,
'country' => $this->invoice[Tag::Customer][Tag::CountryCode],
'city' => isset($this->invoice[Tag::Customer][Tag::City]) ? $this->invoice[Tag::Customer][Tag::City] : '',
'postcode' => isset($this->invoice[Tag::Customer][Tag::PostalCode]) ? $this->invoice[Tag::Customer][Tag::PostalCode] : '',
);
$taxRates = WC_Tax::find_rates($args);
foreach ($taxRates as $taxRate) {
$result[Meta::VatRateLookup][] = $taxRate['rate'];
$result[Meta::VatRateLookupLabel][] = $taxRate['label'];
}
return $result;
} | [
"protected",
"function",
"getVatRateLookupMetadataByTaxClass",
"(",
"$",
"taxClassId",
")",
"{",
"// '' denotes the 'standard'tax class, use 'standard' in meta data, ''",
"// when searching.",
"if",
"(",
"$",
"taxClassId",
"===",
"''",
")",
"{",
"$",
"taxClassId",
"=",
"'standard'",
";",
"}",
"$",
"result",
"=",
"array",
"(",
"Meta",
"::",
"VatClassId",
"=>",
"sanitize_title",
"(",
"$",
"taxClassId",
")",
",",
"// Vat class name is the non-sanitized version of the id",
"// and thus does not convey more information: don't add.",
"Meta",
"::",
"VatRateLookup",
"=>",
"array",
"(",
")",
",",
"Meta",
"::",
"VatRateLookupLabel",
"=>",
"array",
"(",
")",
",",
")",
";",
"if",
"(",
"$",
"taxClassId",
"===",
"'standard'",
")",
"{",
"$",
"taxClassId",
"=",
"''",
";",
"}",
"// Find applicable vat rates. We use WC_Tax::find_rates() to find them.",
"$",
"args",
"=",
"array",
"(",
"'tax_class'",
"=>",
"$",
"taxClassId",
",",
"'country'",
"=>",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"CountryCode",
"]",
",",
"'city'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"City",
"]",
")",
"?",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"City",
"]",
":",
"''",
",",
"'postcode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"PostalCode",
"]",
")",
"?",
"$",
"this",
"->",
"invoice",
"[",
"Tag",
"::",
"Customer",
"]",
"[",
"Tag",
"::",
"PostalCode",
"]",
":",
"''",
",",
")",
";",
"$",
"taxRates",
"=",
"WC_Tax",
"::",
"find_rates",
"(",
"$",
"args",
")",
";",
"foreach",
"(",
"$",
"taxRates",
"as",
"$",
"taxRate",
")",
"{",
"$",
"result",
"[",
"Meta",
"::",
"VatRateLookup",
"]",
"[",
"]",
"=",
"$",
"taxRate",
"[",
"'rate'",
"]",
";",
"$",
"result",
"[",
"Meta",
"::",
"VatRateLookupLabel",
"]",
"[",
"]",
"=",
"$",
"taxRate",
"[",
"'label'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Looks up and returns vat rate metadata for product lines.
A product has a tax class. A tax class can have multiple tax rates,
depending on the region of the customer. As we don't have that data here,
this method will only return metadata if only 1 rate was found.
@param string $taxClassId
The tax class of the product. For the default tax class it can be
'standard' or empty.
@return array
An array with keys:
- Meta::VatClassId: string
- Meta::VatRateLookup: float[]
- Meta::VatRateLookupLabel: string[] | [
"Looks",
"up",
"and",
"returns",
"vat",
"rate",
"metadata",
"for",
"product",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/Creator.php#L188-L219 |
30,329 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/Creator.php | Creator.getFeeLine | protected function getFeeLine($item)
{
$quantity = $item->get_quantity();
$feeEx = $item->get_total() / $quantity;
$feeVat = $item->get_total_tax() / $quantity;
$result = array(
Tag::Product => $this->t($item->get_name()),
Tag::UnitPrice => $feeEx,
Tag::Quantity => $item->get_quantity(),
) + $this->getVatRangeTags($feeVat, $feeEx, $this->precision, $this->precision);
return $result;
} | php | protected function getFeeLine($item)
{
$quantity = $item->get_quantity();
$feeEx = $item->get_total() / $quantity;
$feeVat = $item->get_total_tax() / $quantity;
$result = array(
Tag::Product => $this->t($item->get_name()),
Tag::UnitPrice => $feeEx,
Tag::Quantity => $item->get_quantity(),
) + $this->getVatRangeTags($feeVat, $feeEx, $this->precision, $this->precision);
return $result;
} | [
"protected",
"function",
"getFeeLine",
"(",
"$",
"item",
")",
"{",
"$",
"quantity",
"=",
"$",
"item",
"->",
"get_quantity",
"(",
")",
";",
"$",
"feeEx",
"=",
"$",
"item",
"->",
"get_total",
"(",
")",
"/",
"$",
"quantity",
";",
"$",
"feeVat",
"=",
"$",
"item",
"->",
"get_total_tax",
"(",
")",
"/",
"$",
"quantity",
";",
"$",
"result",
"=",
"array",
"(",
"Tag",
"::",
"Product",
"=>",
"$",
"this",
"->",
"t",
"(",
"$",
"item",
"->",
"get_name",
"(",
")",
")",
",",
"Tag",
"::",
"UnitPrice",
"=>",
"$",
"feeEx",
",",
"Tag",
"::",
"Quantity",
"=>",
"$",
"item",
"->",
"get_quantity",
"(",
")",
",",
")",
"+",
"$",
"this",
"->",
"getVatRangeTags",
"(",
"$",
"feeVat",
",",
"$",
"feeEx",
",",
"$",
"this",
"->",
"precision",
",",
"$",
"this",
"->",
"precision",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns an invoice line for 1 fee line.
@param \WC_Order_Item_Fee $item
@return array
The invoice line for the given fee line. | [
"Returns",
"an",
"invoice",
"line",
"for",
"1",
"fee",
"line",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/Creator.php#L312-L325 |
30,330 | SIELOnline/libAcumulus | src/WooCommerce/Invoice/Creator.php | Creator.getShippingVatRateLookupMetadata | protected function getShippingVatRateLookupMetadata($taxes)
{
$result = array();
if (is_array($taxes)) {
// Since version ?.?, $taxes has an indirection by key 'total'.
if (!is_numeric(key($taxes))) {
$taxes = current($taxes);
}
if (is_array($taxes)) {
foreach ($taxes as $taxRateId => $amount) {
if (!Number::isZero($amount)) {
$taxRate = WC_Tax::_get_tax_rate($taxRateId, OBJECT);
if ($taxRate) {
if (empty($result)) {
$result = array(
Meta::VatClassId => $taxRate->tax_rate_class !== '' ? $taxRate->tax_rate_class : 'standard',
// Vat class name is the non-sanitized
// version of the id and thus does not
// convey more information: don't add.
Meta::VatRateLookup => array(),
Meta::VatRateLookupLabel => array(),
Meta::VatRateLookupSource => 'shipping line taxes',
);
}
// get_rate_percent() contains a % at the end of the
// string: remove it.
$result[Meta::VatRateLookup][] = substr(WC_Tax::get_rate_percent($taxRateId), 0, -1);
$result[Meta::VatRateLookupLabel][] = WC_Tax::get_rate_label($taxRate);
}
}
}
}
}
if (empty($result)) {
// Apparently we have free shipping (or a misconfigured shipment
// method). Use a fall-back: WooCommerce only knows 1 tax rate
// for all shipping methods, stored in config:
$shippingTaxClass = get_option('woocommerce_shipping_tax_class');
if (is_string($shippingTaxClass)) {
/** @var \WC_Order $order */
$order = $this->invoiceSource->getOrder()->getSource();
// Since WC3, the shipping tax class can be "inherited" from the
// product items (which should be the preferred value for this
// setting). The code to get the "inherited" tax class is more
// or less copied from WC_Abstract_Order.
if ($shippingTaxClass === 'inherit') {
$foundClasses = array_intersect(array_merge(array(''), WC_Tax::get_tax_class_slugs()), $order->get_items_tax_classes());
$shippingTaxClass = count($foundClasses) === 1 ? reset($foundClasses) : false;
}
if (is_string($shippingTaxClass)) {
$result = $this->getVatRateLookupMetadataByTaxClass($shippingTaxClass);
if (!empty($result)) {
$result[Meta::VatRateLookupSource] = "get_option('woocommerce_shipping_tax_class')";
}
}
}
}
return $result;
} | php | protected function getShippingVatRateLookupMetadata($taxes)
{
$result = array();
if (is_array($taxes)) {
// Since version ?.?, $taxes has an indirection by key 'total'.
if (!is_numeric(key($taxes))) {
$taxes = current($taxes);
}
if (is_array($taxes)) {
foreach ($taxes as $taxRateId => $amount) {
if (!Number::isZero($amount)) {
$taxRate = WC_Tax::_get_tax_rate($taxRateId, OBJECT);
if ($taxRate) {
if (empty($result)) {
$result = array(
Meta::VatClassId => $taxRate->tax_rate_class !== '' ? $taxRate->tax_rate_class : 'standard',
// Vat class name is the non-sanitized
// version of the id and thus does not
// convey more information: don't add.
Meta::VatRateLookup => array(),
Meta::VatRateLookupLabel => array(),
Meta::VatRateLookupSource => 'shipping line taxes',
);
}
// get_rate_percent() contains a % at the end of the
// string: remove it.
$result[Meta::VatRateLookup][] = substr(WC_Tax::get_rate_percent($taxRateId), 0, -1);
$result[Meta::VatRateLookupLabel][] = WC_Tax::get_rate_label($taxRate);
}
}
}
}
}
if (empty($result)) {
// Apparently we have free shipping (or a misconfigured shipment
// method). Use a fall-back: WooCommerce only knows 1 tax rate
// for all shipping methods, stored in config:
$shippingTaxClass = get_option('woocommerce_shipping_tax_class');
if (is_string($shippingTaxClass)) {
/** @var \WC_Order $order */
$order = $this->invoiceSource->getOrder()->getSource();
// Since WC3, the shipping tax class can be "inherited" from the
// product items (which should be the preferred value for this
// setting). The code to get the "inherited" tax class is more
// or less copied from WC_Abstract_Order.
if ($shippingTaxClass === 'inherit') {
$foundClasses = array_intersect(array_merge(array(''), WC_Tax::get_tax_class_slugs()), $order->get_items_tax_classes());
$shippingTaxClass = count($foundClasses) === 1 ? reset($foundClasses) : false;
}
if (is_string($shippingTaxClass)) {
$result = $this->getVatRateLookupMetadataByTaxClass($shippingTaxClass);
if (!empty($result)) {
$result[Meta::VatRateLookupSource] = "get_option('woocommerce_shipping_tax_class')";
}
}
}
}
return $result;
} | [
"protected",
"function",
"getShippingVatRateLookupMetadata",
"(",
"$",
"taxes",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"taxes",
")",
")",
"{",
"// Since version ?.?, $taxes has an indirection by key 'total'.",
"if",
"(",
"!",
"is_numeric",
"(",
"key",
"(",
"$",
"taxes",
")",
")",
")",
"{",
"$",
"taxes",
"=",
"current",
"(",
"$",
"taxes",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"taxes",
")",
")",
"{",
"foreach",
"(",
"$",
"taxes",
"as",
"$",
"taxRateId",
"=>",
"$",
"amount",
")",
"{",
"if",
"(",
"!",
"Number",
"::",
"isZero",
"(",
"$",
"amount",
")",
")",
"{",
"$",
"taxRate",
"=",
"WC_Tax",
"::",
"_get_tax_rate",
"(",
"$",
"taxRateId",
",",
"OBJECT",
")",
";",
"if",
"(",
"$",
"taxRate",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"Meta",
"::",
"VatClassId",
"=>",
"$",
"taxRate",
"->",
"tax_rate_class",
"!==",
"''",
"?",
"$",
"taxRate",
"->",
"tax_rate_class",
":",
"'standard'",
",",
"// Vat class name is the non-sanitized",
"// version of the id and thus does not",
"// convey more information: don't add.",
"Meta",
"::",
"VatRateLookup",
"=>",
"array",
"(",
")",
",",
"Meta",
"::",
"VatRateLookupLabel",
"=>",
"array",
"(",
")",
",",
"Meta",
"::",
"VatRateLookupSource",
"=>",
"'shipping line taxes'",
",",
")",
";",
"}",
"// get_rate_percent() contains a % at the end of the",
"// string: remove it.",
"$",
"result",
"[",
"Meta",
"::",
"VatRateLookup",
"]",
"[",
"]",
"=",
"substr",
"(",
"WC_Tax",
"::",
"get_rate_percent",
"(",
"$",
"taxRateId",
")",
",",
"0",
",",
"-",
"1",
")",
";",
"$",
"result",
"[",
"Meta",
"::",
"VatRateLookupLabel",
"]",
"[",
"]",
"=",
"WC_Tax",
"::",
"get_rate_label",
"(",
"$",
"taxRate",
")",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"// Apparently we have free shipping (or a misconfigured shipment",
"// method). Use a fall-back: WooCommerce only knows 1 tax rate",
"// for all shipping methods, stored in config:",
"$",
"shippingTaxClass",
"=",
"get_option",
"(",
"'woocommerce_shipping_tax_class'",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"shippingTaxClass",
")",
")",
"{",
"/** @var \\WC_Order $order */",
"$",
"order",
"=",
"$",
"this",
"->",
"invoiceSource",
"->",
"getOrder",
"(",
")",
"->",
"getSource",
"(",
")",
";",
"// Since WC3, the shipping tax class can be \"inherited\" from the",
"// product items (which should be the preferred value for this",
"// setting). The code to get the \"inherited\" tax class is more",
"// or less copied from WC_Abstract_Order.",
"if",
"(",
"$",
"shippingTaxClass",
"===",
"'inherit'",
")",
"{",
"$",
"foundClasses",
"=",
"array_intersect",
"(",
"array_merge",
"(",
"array",
"(",
"''",
")",
",",
"WC_Tax",
"::",
"get_tax_class_slugs",
"(",
")",
")",
",",
"$",
"order",
"->",
"get_items_tax_classes",
"(",
")",
")",
";",
"$",
"shippingTaxClass",
"=",
"count",
"(",
"$",
"foundClasses",
")",
"===",
"1",
"?",
"reset",
"(",
"$",
"foundClasses",
")",
":",
"false",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"shippingTaxClass",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getVatRateLookupMetadataByTaxClass",
"(",
"$",
"shippingTaxClass",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"[",
"Meta",
"::",
"VatRateLookupSource",
"]",
"=",
"\"get_option('woocommerce_shipping_tax_class')\"",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Looks up and returns vat rate metadata for shipping lines.
In WooCommerce, a shipping line can have multiple taxes. I am not sure if
that is possible for Dutch web shops, but if a shipping line does have
multiple taxes we fall back to the tax class setting for shipping
methods, that can have multiple tax rates itself (@see
getVatRateLookupMetadataByTaxClass()). Anyway, this method will only
return metadata if only 1 rate was found.
@param array|null $taxes
The taxes applied to a shipping line.
@return array
An empty array or an array with keys:
- Meta::VatClassId
- Meta::VatRateLookup (*)
- Meta::VatRateLookupLabel (*)
- Meta::VatRateLookupSource (*) | [
"Looks",
"up",
"and",
"returns",
"vat",
"rate",
"metadata",
"for",
"shipping",
"lines",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/Creator.php#L423-L485 |
30,331 | fontis/composer-autoloader | src/app/code/community/Fontis/ComposerAutoloader/Model/Observer.php | Fontis_ComposerAutoloader_Model_Observer.addComposerAutoloader | public function addComposerAutoloader(Varien_Event_Observer $observer)
{
if (self::$added === false) {
/** @var Fontis_ComposerAutoloader_Helper_Data $helper */
$helper = Mage::helper('fontis_composerautoloader');
$helper->registerAutoloader();
self::$added = true;
}
} | php | public function addComposerAutoloader(Varien_Event_Observer $observer)
{
if (self::$added === false) {
/** @var Fontis_ComposerAutoloader_Helper_Data $helper */
$helper = Mage::helper('fontis_composerautoloader');
$helper->registerAutoloader();
self::$added = true;
}
} | [
"public",
"function",
"addComposerAutoloader",
"(",
"Varien_Event_Observer",
"$",
"observer",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"added",
"===",
"false",
")",
"{",
"/** @var Fontis_ComposerAutoloader_Helper_Data $helper */",
"$",
"helper",
"=",
"Mage",
"::",
"helper",
"(",
"'fontis_composerautoloader'",
")",
";",
"$",
"helper",
"->",
"registerAutoloader",
"(",
")",
";",
"self",
"::",
"$",
"added",
"=",
"true",
";",
"}",
"}"
] | Register the Composer autoloader.
@listen resource_get_tablename
@param Varien_Event_Observer $observer | [
"Register",
"the",
"Composer",
"autoloader",
"."
] | edebd4f638c3d60ce5a2329ff834c2f1048ef8be | https://github.com/fontis/composer-autoloader/blob/edebd4f638c3d60ce5a2329ff834c2f1048ef8be/src/app/code/community/Fontis/ComposerAutoloader/Model/Observer.php#L31-L39 |
30,332 | SIELOnline/libAcumulus | src/Helpers/Mailer.php | Mailer.getTo | protected function getTo()
{
$credentials = $this->config->getCredentials();
if (isset($credentials[Tag::EmailOnError])) {
return $credentials[Tag::EmailOnError];
}
$env = $this->config->getEnvironment();
return 'webshop@' . $env['hostName'];
} | php | protected function getTo()
{
$credentials = $this->config->getCredentials();
if (isset($credentials[Tag::EmailOnError])) {
return $credentials[Tag::EmailOnError];
}
$env = $this->config->getEnvironment();
return 'webshop@' . $env['hostName'];
} | [
"protected",
"function",
"getTo",
"(",
")",
"{",
"$",
"credentials",
"=",
"$",
"this",
"->",
"config",
"->",
"getCredentials",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"credentials",
"[",
"Tag",
"::",
"EmailOnError",
"]",
")",
")",
"{",
"return",
"$",
"credentials",
"[",
"Tag",
"::",
"EmailOnError",
"]",
";",
"}",
"$",
"env",
"=",
"$",
"this",
"->",
"config",
"->",
"getEnvironment",
"(",
")",
";",
"return",
"'webshop@'",
".",
"$",
"env",
"[",
"'hostName'",
"]",
";",
"}"
] | Returns the mail to address.
This base implementation returns the configured emailonerror address,
which normally is exactly what we want.
@return string | [
"Returns",
"the",
"mail",
"to",
"address",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Mailer.php#L149-L157 |
30,333 | SIELOnline/libAcumulus | src/Helpers/Mailer.php | Mailer.getSubject | protected function getSubject(Result $invoiceSendResult)
{
$pluginSettings = $this->config->getPluginSettings();
$isTestMode = $pluginSettings['debug'] === PluginConfig::Send_TestMode;
$resultInvoice = $invoiceSendResult->getResponse();
$isConcept = !$invoiceSendResult->hasError() && empty($resultInvoice['entryid']);
$subjectBase = 'mail_subject';
if ($isTestMode) {
$subjectBase .= '_test_mode';
} elseif ($isConcept) {
$subjectBase .= '_concept';
}
$subject = $this->t($subjectBase);
$subjectResult = 'mail_subject';
switch ($invoiceSendResult->getStatus()) {
case Result::Status_Exception:
$subjectResult .= '_exception';
break;
case Result::Status_Errors:
$subjectResult .= '_error';
break;
case Result::Status_Warnings:
$subjectResult .= '_warning';
break;
case Result::Status_Success:
default:
$subjectResult .= '_success';
break;
}
$subject .= ': ' . $this->t($subjectResult);
if ($isTestMode || $isConcept || $invoiceSendResult->hasError()) {
$emailAsPdfSettings = $this->config->getEmailAsPdfSettings();
if ($emailAsPdfSettings['emailAsPdf']) {
// Normally, Acumulus will send a pdf to the client, but due to
// 1 of the conditions above this was not done.
$subject .= ', ' . $this->t('mail_subject_no_pdf');
}
}
return $subject;
} | php | protected function getSubject(Result $invoiceSendResult)
{
$pluginSettings = $this->config->getPluginSettings();
$isTestMode = $pluginSettings['debug'] === PluginConfig::Send_TestMode;
$resultInvoice = $invoiceSendResult->getResponse();
$isConcept = !$invoiceSendResult->hasError() && empty($resultInvoice['entryid']);
$subjectBase = 'mail_subject';
if ($isTestMode) {
$subjectBase .= '_test_mode';
} elseif ($isConcept) {
$subjectBase .= '_concept';
}
$subject = $this->t($subjectBase);
$subjectResult = 'mail_subject';
switch ($invoiceSendResult->getStatus()) {
case Result::Status_Exception:
$subjectResult .= '_exception';
break;
case Result::Status_Errors:
$subjectResult .= '_error';
break;
case Result::Status_Warnings:
$subjectResult .= '_warning';
break;
case Result::Status_Success:
default:
$subjectResult .= '_success';
break;
}
$subject .= ': ' . $this->t($subjectResult);
if ($isTestMode || $isConcept || $invoiceSendResult->hasError()) {
$emailAsPdfSettings = $this->config->getEmailAsPdfSettings();
if ($emailAsPdfSettings['emailAsPdf']) {
// Normally, Acumulus will send a pdf to the client, but due to
// 1 of the conditions above this was not done.
$subject .= ', ' . $this->t('mail_subject_no_pdf');
}
}
return $subject;
} | [
"protected",
"function",
"getSubject",
"(",
"Result",
"$",
"invoiceSendResult",
")",
"{",
"$",
"pluginSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getPluginSettings",
"(",
")",
";",
"$",
"isTestMode",
"=",
"$",
"pluginSettings",
"[",
"'debug'",
"]",
"===",
"PluginConfig",
"::",
"Send_TestMode",
";",
"$",
"resultInvoice",
"=",
"$",
"invoiceSendResult",
"->",
"getResponse",
"(",
")",
";",
"$",
"isConcept",
"=",
"!",
"$",
"invoiceSendResult",
"->",
"hasError",
"(",
")",
"&&",
"empty",
"(",
"$",
"resultInvoice",
"[",
"'entryid'",
"]",
")",
";",
"$",
"subjectBase",
"=",
"'mail_subject'",
";",
"if",
"(",
"$",
"isTestMode",
")",
"{",
"$",
"subjectBase",
".=",
"'_test_mode'",
";",
"}",
"elseif",
"(",
"$",
"isConcept",
")",
"{",
"$",
"subjectBase",
".=",
"'_concept'",
";",
"}",
"$",
"subject",
"=",
"$",
"this",
"->",
"t",
"(",
"$",
"subjectBase",
")",
";",
"$",
"subjectResult",
"=",
"'mail_subject'",
";",
"switch",
"(",
"$",
"invoiceSendResult",
"->",
"getStatus",
"(",
")",
")",
"{",
"case",
"Result",
"::",
"Status_Exception",
":",
"$",
"subjectResult",
".=",
"'_exception'",
";",
"break",
";",
"case",
"Result",
"::",
"Status_Errors",
":",
"$",
"subjectResult",
".=",
"'_error'",
";",
"break",
";",
"case",
"Result",
"::",
"Status_Warnings",
":",
"$",
"subjectResult",
".=",
"'_warning'",
";",
"break",
";",
"case",
"Result",
"::",
"Status_Success",
":",
"default",
":",
"$",
"subjectResult",
".=",
"'_success'",
";",
"break",
";",
"}",
"$",
"subject",
".=",
"': '",
".",
"$",
"this",
"->",
"t",
"(",
"$",
"subjectResult",
")",
";",
"if",
"(",
"$",
"isTestMode",
"||",
"$",
"isConcept",
"||",
"$",
"invoiceSendResult",
"->",
"hasError",
"(",
")",
")",
"{",
"$",
"emailAsPdfSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getEmailAsPdfSettings",
"(",
")",
";",
"if",
"(",
"$",
"emailAsPdfSettings",
"[",
"'emailAsPdf'",
"]",
")",
"{",
"// Normally, Acumulus will send a pdf to the client, but due to",
"// 1 of the conditions above this was not done.",
"$",
"subject",
".=",
"', '",
".",
"$",
"this",
"->",
"t",
"(",
"'mail_subject_no_pdf'",
")",
";",
"}",
"}",
"return",
"$",
"subject",
";",
"}"
] | Returns the subject for the mail.
The subject depends on:
- the result status.
- whether the invoice was sent in test mode.
- whether the invoice was sent as concept.
- the emailAsPdf setting.
@param \Siel\Acumulus\Invoice\Result $invoiceSendResult
@return string | [
"Returns",
"the",
"subject",
"for",
"the",
"mail",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Mailer.php#L172-L215 |
30,334 | SIELOnline/libAcumulus | src/Helpers/Mailer.php | Mailer.getBody | protected function getBody(Result $result, $invoiceSourceType, $invoiceSourceReference)
{
$resultInvoice = $result->getResponse();
$bodyTexts = $this->getStatusSpecificBody($result);
$supportTexts = $this->getSupportMessages($result);
$messagesTexts = $this->getMessages($result);
$replacements = array(
'{invoice_source_type}' => $this->t($invoiceSourceType),
'{invoice_source_reference}' => $invoiceSourceReference,
'{acumulus_invoice_id}' => isset($resultInvoice['invoicenumber']) ? $resultInvoice['invoicenumber'] : $this->t('message_no_invoice'),
'{status}' => $result->getStatus(),
'{status_message}' => $result->getStatusText(),
'{status_specific_text}' => $bodyTexts['text'],
'{status_specific_html}' => $bodyTexts['html'],
'{messages_text}' => $messagesTexts['text'],
'{messages_html}' => $messagesTexts['html'],
'{support_messages_text}' => $supportTexts['text'],
'{support_messages_html}' => $supportTexts['html'],
);
$text = $this->t('mail_text');
$text = strtr($text, $replacements);
$html = $this->t('mail_html');
$html = strtr($html, $replacements);
return array('text' => $text, 'html' => $html);
} | php | protected function getBody(Result $result, $invoiceSourceType, $invoiceSourceReference)
{
$resultInvoice = $result->getResponse();
$bodyTexts = $this->getStatusSpecificBody($result);
$supportTexts = $this->getSupportMessages($result);
$messagesTexts = $this->getMessages($result);
$replacements = array(
'{invoice_source_type}' => $this->t($invoiceSourceType),
'{invoice_source_reference}' => $invoiceSourceReference,
'{acumulus_invoice_id}' => isset($resultInvoice['invoicenumber']) ? $resultInvoice['invoicenumber'] : $this->t('message_no_invoice'),
'{status}' => $result->getStatus(),
'{status_message}' => $result->getStatusText(),
'{status_specific_text}' => $bodyTexts['text'],
'{status_specific_html}' => $bodyTexts['html'],
'{messages_text}' => $messagesTexts['text'],
'{messages_html}' => $messagesTexts['html'],
'{support_messages_text}' => $supportTexts['text'],
'{support_messages_html}' => $supportTexts['html'],
);
$text = $this->t('mail_text');
$text = strtr($text, $replacements);
$html = $this->t('mail_html');
$html = strtr($html, $replacements);
return array('text' => $text, 'html' => $html);
} | [
"protected",
"function",
"getBody",
"(",
"Result",
"$",
"result",
",",
"$",
"invoiceSourceType",
",",
"$",
"invoiceSourceReference",
")",
"{",
"$",
"resultInvoice",
"=",
"$",
"result",
"->",
"getResponse",
"(",
")",
";",
"$",
"bodyTexts",
"=",
"$",
"this",
"->",
"getStatusSpecificBody",
"(",
"$",
"result",
")",
";",
"$",
"supportTexts",
"=",
"$",
"this",
"->",
"getSupportMessages",
"(",
"$",
"result",
")",
";",
"$",
"messagesTexts",
"=",
"$",
"this",
"->",
"getMessages",
"(",
"$",
"result",
")",
";",
"$",
"replacements",
"=",
"array",
"(",
"'{invoice_source_type}'",
"=>",
"$",
"this",
"->",
"t",
"(",
"$",
"invoiceSourceType",
")",
",",
"'{invoice_source_reference}'",
"=>",
"$",
"invoiceSourceReference",
",",
"'{acumulus_invoice_id}'",
"=>",
"isset",
"(",
"$",
"resultInvoice",
"[",
"'invoicenumber'",
"]",
")",
"?",
"$",
"resultInvoice",
"[",
"'invoicenumber'",
"]",
":",
"$",
"this",
"->",
"t",
"(",
"'message_no_invoice'",
")",
",",
"'{status}'",
"=>",
"$",
"result",
"->",
"getStatus",
"(",
")",
",",
"'{status_message}'",
"=>",
"$",
"result",
"->",
"getStatusText",
"(",
")",
",",
"'{status_specific_text}'",
"=>",
"$",
"bodyTexts",
"[",
"'text'",
"]",
",",
"'{status_specific_html}'",
"=>",
"$",
"bodyTexts",
"[",
"'html'",
"]",
",",
"'{messages_text}'",
"=>",
"$",
"messagesTexts",
"[",
"'text'",
"]",
",",
"'{messages_html}'",
"=>",
"$",
"messagesTexts",
"[",
"'html'",
"]",
",",
"'{support_messages_text}'",
"=>",
"$",
"supportTexts",
"[",
"'text'",
"]",
",",
"'{support_messages_html}'",
"=>",
"$",
"supportTexts",
"[",
"'html'",
"]",
",",
")",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_text'",
")",
";",
"$",
"text",
"=",
"strtr",
"(",
"$",
"text",
",",
"$",
"replacements",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_html'",
")",
";",
"$",
"html",
"=",
"strtr",
"(",
"$",
"html",
",",
"$",
"replacements",
")",
";",
"return",
"array",
"(",
"'text'",
"=>",
"$",
"text",
",",
"'html'",
"=>",
"$",
"html",
")",
";",
"}"
] | Returns the mail body as text and as html.
@param \Siel\Acumulus\Invoice\Result $result
@param string $invoiceSourceType
@param string $invoiceSourceReference
@return string[]
An array with keys text and html. | [
"Returns",
"the",
"mail",
"body",
"as",
"text",
"and",
"as",
"html",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Mailer.php#L227-L251 |
30,335 | SIELOnline/libAcumulus | src/Helpers/Mailer.php | Mailer.getStatusSpecificBody | protected function getStatusSpecificBody(Result $invoiceSendResult)
{
$pluginSettings = $this->config->getPluginSettings();
$isTestMode = $pluginSettings['debug'] === PluginConfig::Send_TestMode;
$resultInvoice = $invoiceSendResult->getResponse();
// @refactor: can be taken from invoice array if that would be part of the Result
$isConcept = !$invoiceSendResult->hasError() && empty($resultInvoice['entryid']);
$emailAsPdfSettings = $this->config->getEmailAsPdfSettings();
$isEmailAsPdf = (bool) $emailAsPdfSettings['emailAsPdf'];
// Collect the messages.
$sentences = array();
switch ($invoiceSendResult->getStatus()) {
case Result::Status_Exception:
$sentences[] = 'mail_body_exception';
$sentences[] = $invoiceSendResult->isSent() ? 'mail_body_exception_invoice_maybe_created' : 'mail_body_exception_invoice_not_created';
break;
case Result::Status_Errors:
$sentences[] = 'mail_body_errors';
$sentences[] = 'mail_body_errors_not_created';
if ($isEmailAsPdf) {
$sentences[] = 'mail_body_pdf_enabled';
$sentences[] = 'mail_body_pdf_not_sent_errors';
}
break;
case Result::Status_Warnings:
$sentences[] = 'mail_body_warnings';
if ($isTestMode) {
$sentences[] = 'mail_body_testmode';
} elseif ($isConcept) {
$sentences[] = 'mail_body_concept';
if ($isEmailAsPdf) {
$sentences[] = 'mail_body_pdf_enabled';
$sentences[] = 'mail_body_pdf_not_sent_concept';
}
} else {
$sentences[] = 'mail_body_warnings_created';
}
break;
case Result::Status_Success:
default:
$sentences[] = 'mail_body_success';
if ($isTestMode) {
$sentences[] = 'mail_body_testmode';
} elseif ($isConcept) {
$sentences[] = 'mail_body_concept';
if ($isEmailAsPdf) {
$sentences[] = 'mail_body_pdf_enabled';
$sentences[] = 'mail_body_pdf_not_sent_concept';
}
}
break;
}
// Translate the messages.
foreach ($sentences as &$sentence) {
$sentence = $this->t($sentence);
}
// Collapse and format the sentences.
$sentences = implode(' ', $sentences);
$texts = array(
'text' => wordwrap($sentences, 70),
'html' => "<p>$sentences</p>",
);
return $texts;
} | php | protected function getStatusSpecificBody(Result $invoiceSendResult)
{
$pluginSettings = $this->config->getPluginSettings();
$isTestMode = $pluginSettings['debug'] === PluginConfig::Send_TestMode;
$resultInvoice = $invoiceSendResult->getResponse();
// @refactor: can be taken from invoice array if that would be part of the Result
$isConcept = !$invoiceSendResult->hasError() && empty($resultInvoice['entryid']);
$emailAsPdfSettings = $this->config->getEmailAsPdfSettings();
$isEmailAsPdf = (bool) $emailAsPdfSettings['emailAsPdf'];
// Collect the messages.
$sentences = array();
switch ($invoiceSendResult->getStatus()) {
case Result::Status_Exception:
$sentences[] = 'mail_body_exception';
$sentences[] = $invoiceSendResult->isSent() ? 'mail_body_exception_invoice_maybe_created' : 'mail_body_exception_invoice_not_created';
break;
case Result::Status_Errors:
$sentences[] = 'mail_body_errors';
$sentences[] = 'mail_body_errors_not_created';
if ($isEmailAsPdf) {
$sentences[] = 'mail_body_pdf_enabled';
$sentences[] = 'mail_body_pdf_not_sent_errors';
}
break;
case Result::Status_Warnings:
$sentences[] = 'mail_body_warnings';
if ($isTestMode) {
$sentences[] = 'mail_body_testmode';
} elseif ($isConcept) {
$sentences[] = 'mail_body_concept';
if ($isEmailAsPdf) {
$sentences[] = 'mail_body_pdf_enabled';
$sentences[] = 'mail_body_pdf_not_sent_concept';
}
} else {
$sentences[] = 'mail_body_warnings_created';
}
break;
case Result::Status_Success:
default:
$sentences[] = 'mail_body_success';
if ($isTestMode) {
$sentences[] = 'mail_body_testmode';
} elseif ($isConcept) {
$sentences[] = 'mail_body_concept';
if ($isEmailAsPdf) {
$sentences[] = 'mail_body_pdf_enabled';
$sentences[] = 'mail_body_pdf_not_sent_concept';
}
}
break;
}
// Translate the messages.
foreach ($sentences as &$sentence) {
$sentence = $this->t($sentence);
}
// Collapse and format the sentences.
$sentences = implode(' ', $sentences);
$texts = array(
'text' => wordwrap($sentences, 70),
'html' => "<p>$sentences</p>",
);
return $texts;
} | [
"protected",
"function",
"getStatusSpecificBody",
"(",
"Result",
"$",
"invoiceSendResult",
")",
"{",
"$",
"pluginSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getPluginSettings",
"(",
")",
";",
"$",
"isTestMode",
"=",
"$",
"pluginSettings",
"[",
"'debug'",
"]",
"===",
"PluginConfig",
"::",
"Send_TestMode",
";",
"$",
"resultInvoice",
"=",
"$",
"invoiceSendResult",
"->",
"getResponse",
"(",
")",
";",
"// @refactor: can be taken from invoice array if that would be part of the Result",
"$",
"isConcept",
"=",
"!",
"$",
"invoiceSendResult",
"->",
"hasError",
"(",
")",
"&&",
"empty",
"(",
"$",
"resultInvoice",
"[",
"'entryid'",
"]",
")",
";",
"$",
"emailAsPdfSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getEmailAsPdfSettings",
"(",
")",
";",
"$",
"isEmailAsPdf",
"=",
"(",
"bool",
")",
"$",
"emailAsPdfSettings",
"[",
"'emailAsPdf'",
"]",
";",
"// Collect the messages.",
"$",
"sentences",
"=",
"array",
"(",
")",
";",
"switch",
"(",
"$",
"invoiceSendResult",
"->",
"getStatus",
"(",
")",
")",
"{",
"case",
"Result",
"::",
"Status_Exception",
":",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_exception'",
";",
"$",
"sentences",
"[",
"]",
"=",
"$",
"invoiceSendResult",
"->",
"isSent",
"(",
")",
"?",
"'mail_body_exception_invoice_maybe_created'",
":",
"'mail_body_exception_invoice_not_created'",
";",
"break",
";",
"case",
"Result",
"::",
"Status_Errors",
":",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_errors'",
";",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_errors_not_created'",
";",
"if",
"(",
"$",
"isEmailAsPdf",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_pdf_enabled'",
";",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_pdf_not_sent_errors'",
";",
"}",
"break",
";",
"case",
"Result",
"::",
"Status_Warnings",
":",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_warnings'",
";",
"if",
"(",
"$",
"isTestMode",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_testmode'",
";",
"}",
"elseif",
"(",
"$",
"isConcept",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_concept'",
";",
"if",
"(",
"$",
"isEmailAsPdf",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_pdf_enabled'",
";",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_pdf_not_sent_concept'",
";",
"}",
"}",
"else",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_warnings_created'",
";",
"}",
"break",
";",
"case",
"Result",
"::",
"Status_Success",
":",
"default",
":",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_success'",
";",
"if",
"(",
"$",
"isTestMode",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_testmode'",
";",
"}",
"elseif",
"(",
"$",
"isConcept",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_concept'",
";",
"if",
"(",
"$",
"isEmailAsPdf",
")",
"{",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_pdf_enabled'",
";",
"$",
"sentences",
"[",
"]",
"=",
"'mail_body_pdf_not_sent_concept'",
";",
"}",
"}",
"break",
";",
"}",
"// Translate the messages.",
"foreach",
"(",
"$",
"sentences",
"as",
"&",
"$",
"sentence",
")",
"{",
"$",
"sentence",
"=",
"$",
"this",
"->",
"t",
"(",
"$",
"sentence",
")",
";",
"}",
"// Collapse and format the sentences.",
"$",
"sentences",
"=",
"implode",
"(",
"' '",
",",
"$",
"sentences",
")",
";",
"$",
"texts",
"=",
"array",
"(",
"'text'",
"=>",
"wordwrap",
"(",
"$",
"sentences",
",",
"70",
")",
",",
"'html'",
"=>",
"\"<p>$sentences</p>\"",
",",
")",
";",
"return",
"$",
"texts",
";",
"}"
] | Returns the body for the mail.
The body depends on:
- the result status.
- the value of isSent (in the result object)
- whether the invoice was sent in test mode
- whether the invoice was sent as concept
- the emailAsPdf setting
@param \Siel\Acumulus\Invoice\Result $invoiceSendResult
@return string[] | [
"Returns",
"the",
"body",
"for",
"the",
"mail",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Mailer.php#L267-L333 |
30,336 | SIELOnline/libAcumulus | src/Helpers/Mailer.php | Mailer.getMessages | protected function getMessages(Result $result)
{
$messages = array(
'text' => '',
'html' => '',
);
if ($result->hasMessages()) {
$header = $this->t('mail_messages_header');
$description = $this->t('mail_messages_desc');
$descriptionHtml = $this->t('mail_messages_desc_html');
$messagesText = $result->getMessages(Result::Format_FormattedText);
$messagesHtml = $result->getMessages(Result::Format_Html);
$messages = array(
'text' => "\n$header\n\n$messagesText\n\n$description\n",
'html' => "<details open><summary>$header</summary>$messagesHtml<p>$descriptionHtml</p></details>",
);
}
return $messages;
} | php | protected function getMessages(Result $result)
{
$messages = array(
'text' => '',
'html' => '',
);
if ($result->hasMessages()) {
$header = $this->t('mail_messages_header');
$description = $this->t('mail_messages_desc');
$descriptionHtml = $this->t('mail_messages_desc_html');
$messagesText = $result->getMessages(Result::Format_FormattedText);
$messagesHtml = $result->getMessages(Result::Format_Html);
$messages = array(
'text' => "\n$header\n\n$messagesText\n\n$description\n",
'html' => "<details open><summary>$header</summary>$messagesHtml<p>$descriptionHtml</p></details>",
);
}
return $messages;
} | [
"protected",
"function",
"getMessages",
"(",
"Result",
"$",
"result",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
"'text'",
"=>",
"''",
",",
"'html'",
"=>",
"''",
",",
")",
";",
"if",
"(",
"$",
"result",
"->",
"hasMessages",
"(",
")",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_messages_header'",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_messages_desc'",
")",
";",
"$",
"descriptionHtml",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_messages_desc_html'",
")",
";",
"$",
"messagesText",
"=",
"$",
"result",
"->",
"getMessages",
"(",
"Result",
"::",
"Format_FormattedText",
")",
";",
"$",
"messagesHtml",
"=",
"$",
"result",
"->",
"getMessages",
"(",
"Result",
"::",
"Format_Html",
")",
";",
"$",
"messages",
"=",
"array",
"(",
"'text'",
"=>",
"\"\\n$header\\n\\n$messagesText\\n\\n$description\\n\"",
",",
"'html'",
"=>",
"\"<details open><summary>$header</summary>$messagesHtml<p>$descriptionHtml</p></details>\"",
",",
")",
";",
"}",
"return",
"$",
"messages",
";",
"}"
] | Returns the messages along with some descriptive text.
@param \Siel\Acumulus\Invoice\Result $result
@return string[]
An array with a plain text (key='text') and an html string (key='html')
containing the messages with some descriptive text. | [
"Returns",
"the",
"messages",
"along",
"with",
"some",
"descriptive",
"text",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Mailer.php#L344-L363 |
30,337 | SIELOnline/libAcumulus | src/Helpers/Mailer.php | Mailer.getSupportMessages | protected function getSupportMessages(Result $result)
{
$messages = array(
'text' => '',
'html' => '',
);
$pluginSettings = $this->config->getPluginSettings();
// We add the request and response messages when set so or if there were
// warnings or severer messages, thus not with notices.
$addReqResp = $pluginSettings['debug'] === PluginConfig::Send_SendAndMailOnError ? Result::AddReqResp_WithOther : Result::AddReqResp_Always;
if ($addReqResp === Result::AddReqResp_Always || ($addReqResp === Result::AddReqResp_WithOther && $result->getStatus() >= Result::Status_Warnings)) {
if ($result->getRawRequest() !== null || $result->getRawResponse() !== null) {
$header = $this->t('mail_support_header');
$description = $this->t('mail_support_desc');
$supportMessagesText = $result->getRawRequestResponse(Result::Format_FormattedText);
$supportMessagesHtml = $result->getRawRequestResponse(Result::Format_Html);
$messages = array(
'text' => "\n$header\n\n$description\n\n$supportMessagesText\n",
'html' => "<details><summary>$header</summary><p>$description</p>$supportMessagesHtml</details>",
);
}
}
return $messages;
} | php | protected function getSupportMessages(Result $result)
{
$messages = array(
'text' => '',
'html' => '',
);
$pluginSettings = $this->config->getPluginSettings();
// We add the request and response messages when set so or if there were
// warnings or severer messages, thus not with notices.
$addReqResp = $pluginSettings['debug'] === PluginConfig::Send_SendAndMailOnError ? Result::AddReqResp_WithOther : Result::AddReqResp_Always;
if ($addReqResp === Result::AddReqResp_Always || ($addReqResp === Result::AddReqResp_WithOther && $result->getStatus() >= Result::Status_Warnings)) {
if ($result->getRawRequest() !== null || $result->getRawResponse() !== null) {
$header = $this->t('mail_support_header');
$description = $this->t('mail_support_desc');
$supportMessagesText = $result->getRawRequestResponse(Result::Format_FormattedText);
$supportMessagesHtml = $result->getRawRequestResponse(Result::Format_Html);
$messages = array(
'text' => "\n$header\n\n$description\n\n$supportMessagesText\n",
'html' => "<details><summary>$header</summary><p>$description</p>$supportMessagesHtml</details>",
);
}
}
return $messages;
} | [
"protected",
"function",
"getSupportMessages",
"(",
"Result",
"$",
"result",
")",
"{",
"$",
"messages",
"=",
"array",
"(",
"'text'",
"=>",
"''",
",",
"'html'",
"=>",
"''",
",",
")",
";",
"$",
"pluginSettings",
"=",
"$",
"this",
"->",
"config",
"->",
"getPluginSettings",
"(",
")",
";",
"// We add the request and response messages when set so or if there were",
"// warnings or severer messages, thus not with notices.",
"$",
"addReqResp",
"=",
"$",
"pluginSettings",
"[",
"'debug'",
"]",
"===",
"PluginConfig",
"::",
"Send_SendAndMailOnError",
"?",
"Result",
"::",
"AddReqResp_WithOther",
":",
"Result",
"::",
"AddReqResp_Always",
";",
"if",
"(",
"$",
"addReqResp",
"===",
"Result",
"::",
"AddReqResp_Always",
"||",
"(",
"$",
"addReqResp",
"===",
"Result",
"::",
"AddReqResp_WithOther",
"&&",
"$",
"result",
"->",
"getStatus",
"(",
")",
">=",
"Result",
"::",
"Status_Warnings",
")",
")",
"{",
"if",
"(",
"$",
"result",
"->",
"getRawRequest",
"(",
")",
"!==",
"null",
"||",
"$",
"result",
"->",
"getRawResponse",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_support_header'",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"t",
"(",
"'mail_support_desc'",
")",
";",
"$",
"supportMessagesText",
"=",
"$",
"result",
"->",
"getRawRequestResponse",
"(",
"Result",
"::",
"Format_FormattedText",
")",
";",
"$",
"supportMessagesHtml",
"=",
"$",
"result",
"->",
"getRawRequestResponse",
"(",
"Result",
"::",
"Format_Html",
")",
";",
"$",
"messages",
"=",
"array",
"(",
"'text'",
"=>",
"\"\\n$header\\n\\n$description\\n\\n$supportMessagesText\\n\"",
",",
"'html'",
"=>",
"\"<details><summary>$header</summary><p>$description</p>$supportMessagesHtml</details>\"",
",",
")",
";",
"}",
"}",
"return",
"$",
"messages",
";",
"}"
] | Returns the support messages along with some descriptive text.
@param \Siel\Acumulus\Invoice\Result $result
@return string[]
An array with a plain text (key='text') and an html string (key='html')
containing the support messages with some descriptive text. | [
"Returns",
"the",
"support",
"messages",
"along",
"with",
"some",
"descriptive",
"text",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Mailer.php#L374-L398 |
30,338 | SIELOnline/libAcumulus | src/Magento/Magento1/Invoice/Source.php | Source.getPaymentStatusCreditNote | protected function getPaymentStatusCreditNote()
{
return $this->source->getState() == \Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED
? Api::PaymentStatus_Paid
: Api::PaymentStatus_Due;
} | php | protected function getPaymentStatusCreditNote()
{
return $this->source->getState() == \Mage_Sales_Model_Order_Creditmemo::STATE_REFUNDED
? Api::PaymentStatus_Paid
: Api::PaymentStatus_Due;
} | [
"protected",
"function",
"getPaymentStatusCreditNote",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"source",
"->",
"getState",
"(",
")",
"==",
"\\",
"Mage_Sales_Model_Order_Creditmemo",
"::",
"STATE_REFUNDED",
"?",
"Api",
"::",
"PaymentStatus_Paid",
":",
"Api",
"::",
"PaymentStatus_Due",
";",
"}"
] | Returns whether the credit memo has been paid or not.
@return int
\Siel\Acumulus\Api::PaymentStatus_Paid or
\Siel\Acumulus\Api::PaymentStatus_Due | [
"Returns",
"whether",
"the",
"credit",
"memo",
"has",
"been",
"paid",
"or",
"not",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Magento1/Invoice/Source.php#L50-L55 |
30,339 | SIELOnline/libAcumulus | src/Magento/Magento1/Invoice/Source.php | Source.getPaymentDateOrder | protected function getPaymentDateOrder()
{
// Take date of last payment as payment date.
$paymentDate = null;
foreach ($this->source->getStatusHistoryCollection() as $statusChange) {
/** @var \Mage_Sales_Model_Order_Status_History $statusChange */
if (!$paymentDate || $this->isPaidStatus($statusChange->getStatus())) {
$createdAt = substr($statusChange->getCreatedAt(), 0, strlen('yyyy-mm-dd'));
if (!$paymentDate || $createdAt < $paymentDate) {
$paymentDate = $createdAt;
}
}
}
return $paymentDate;
} | php | protected function getPaymentDateOrder()
{
// Take date of last payment as payment date.
$paymentDate = null;
foreach ($this->source->getStatusHistoryCollection() as $statusChange) {
/** @var \Mage_Sales_Model_Order_Status_History $statusChange */
if (!$paymentDate || $this->isPaidStatus($statusChange->getStatus())) {
$createdAt = substr($statusChange->getCreatedAt(), 0, strlen('yyyy-mm-dd'));
if (!$paymentDate || $createdAt < $paymentDate) {
$paymentDate = $createdAt;
}
}
}
return $paymentDate;
} | [
"protected",
"function",
"getPaymentDateOrder",
"(",
")",
"{",
"// Take date of last payment as payment date.",
"$",
"paymentDate",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"source",
"->",
"getStatusHistoryCollection",
"(",
")",
"as",
"$",
"statusChange",
")",
"{",
"/** @var \\Mage_Sales_Model_Order_Status_History $statusChange */",
"if",
"(",
"!",
"$",
"paymentDate",
"||",
"$",
"this",
"->",
"isPaidStatus",
"(",
"$",
"statusChange",
"->",
"getStatus",
"(",
")",
")",
")",
"{",
"$",
"createdAt",
"=",
"substr",
"(",
"$",
"statusChange",
"->",
"getCreatedAt",
"(",
")",
",",
"0",
",",
"strlen",
"(",
"'yyyy-mm-dd'",
")",
")",
";",
"if",
"(",
"!",
"$",
"paymentDate",
"||",
"$",
"createdAt",
"<",
"$",
"paymentDate",
")",
"{",
"$",
"paymentDate",
"=",
"$",
"createdAt",
";",
"}",
"}",
"}",
"return",
"$",
"paymentDate",
";",
"}"
] | Returns the payment date for the order.
@return string|null
The payment date (yyyy-mm-dd) or null if the order has not been paid yet. | [
"Returns",
"the",
"payment",
"date",
"for",
"the",
"order",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Magento/Magento1/Invoice/Source.php#L63-L77 |
30,340 | 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",
"->",
"replaceUpgradeChecker",
"->",
"isReplaceUpgrade",
"(",
"$",
"configuration",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | 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 |
30,341 | 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",
"->",
"registry",
"->",
"getLink",
"(",
"$",
"this",
"->",
"getLocation",
"(",
")",
".",
"'/confirmUninstall'",
")",
")",
";",
"}"
] | 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 |
30,342 | 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'] === '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');",
"}"
] | 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 |
30,343 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
30,344 | 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",
"->",
"getInvoiceManager",
"(",
")",
"->",
"sourceStatusChange",
"(",
"$",
"source",
")",
";",
"}"
] | 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 |
30,345 | 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'",
"]",
"[",
"]",
"=",
"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",
"(",
")",
",",
")",
",",
")",
",",
")",
";",
"}",
"}",
"}"
] | 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 |
30,346 | 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",
"->",
"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",
"(",
")",
";",
"}"
] | 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 |
30,347 | 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",
"->",
"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",
"(",
")",
";",
"}"
] | 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 |
30,348 | 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",
"(",
")",
".",
"'_form'",
",",
"$",
"this",
"->",
"data",
")",
")",
";",
"}"
] | Outputs the form. | [
"Outputs",
"the",
"form",
"."
] | 82f8d6c9c4929c41948c97d6cfdfac3f27c37255 | https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/OpenCart/Helpers/OcHelper.php#L406-L410 |
30,349 | 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_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",
";",
"}"
] | 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 |
30,350 | 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",
"(",
"'setting/setting'",
")",
";",
"$",
"this",
"->",
"registry",
"->",
"model_setting_setting",
"->",
"deleteSetting",
"(",
"'acumulus_siel'",
")",
";",
"return",
"true",
";",
"}"
] | 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 |
30,351 | 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'",
")",
";",
"$",
"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",
";",
"}"
] | 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 |
30,352 | 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",
"(",
")",
";",
"$",
"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'",
")",
";",
"}"
] | 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 |
30,353 | 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'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"warningMessages",
"[",
"'conflicting_options'",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'message_validate_conflicting_options'",
")",
";",
"}",
"}"
] | 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 |
30,354 | 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",
")",
"{",
"$",
"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'",
")",
";",
"}",
"}"
] | 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 |
30,355 | 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",
"->",
"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'",
")",
";",
"}",
"}"
] | 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 |
30,356 | 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'",
"=>",
"$",
"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",
";",
"}"
] | 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 |
30,357 | 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'",
"=>",
"$",
"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",
";",
"}"
] | 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 |
30,358 | 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'",
"=>",
"$",
"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",
",",
")",
",",
")",
",",
")",
";",
"}"
] | 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 |
30,359 | 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",
"->",
"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",
";",
"}"
] | 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 |
30,360 | 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",
"=",
"'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",
";",
"}"
] | 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 |
30,361 | 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'",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'option_empty_triggerOrderStatus'",
")",
";",
"$",
"result",
"+=",
"$",
"this",
"->",
"shopCapabilities",
"->",
"getShopOrderStatuses",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | 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 |
30,362 | 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",
"$",
"this",
"->",
"flags",
"[",
"$",
"flag",
"]",
";",
"}"
] | 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 |
30,363 | 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'",
",",
"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",
")",
";",
"}"
] | 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 |
30,364 | 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",
"->",
"container",
"[",
"$",
"modeName",
"]",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"createMode",
")",
"{",
"return",
"$",
"createMode",
";",
"}",
";",
"}"
] | 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 |
30,365 | 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",
"->",
"session",
"->",
"data",
"[",
"$",
"token",
"]",
",",
"$",
"secure",
")",
";",
"}"
] | 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 |
30,366 | 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 |
30,367 | 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",
"->",
"orderTotalLines",
"=",
"$",
"orderModel",
"->",
"getOrderTotals",
"(",
"$",
"this",
"->",
"source",
"[",
"'order_id'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"orderTotalLines",
";",
"}"
] | 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 |
30,368 | 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",
"[",
"]",
"=",
"$",
"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",
")",
";",
"}"
] | 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 |
30,369 | 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",
"[",
"$",
"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",
"]",
";",
"}"
] | 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 |
30,370 | 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",
")",
";",
"$",
"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",
":",
"''",
";",
"}"
] | 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 |
30,371 | 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",
"(",
"'/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",
")",
";",
"}",
"}"
] | 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 |
30,372 | 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",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'value'",
"=>",
"json_encode",
"(",
"$",
"this",
"->",
"getMeta",
"(",
")",
")",
",",
")",
";",
"return",
"$",
"fields",
";",
"}"
] | 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 |
30,373 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
30,374 | 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",
"[",
"$",
"key",
"]",
"->",
"name",
",",
"-",
"strlen",
"(",
"'[]'",
")",
")",
"===",
"'[]'",
";",
"}"
] | 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 |
30,375 | 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",
"]",
"->",
"type",
"===",
"'checkbox'",
";",
"}"
] | 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 |
30,376 | 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",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] | 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 |
30,377 | 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",
",",
"\"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",
")",
";",
"}"
] | 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 |
30,378 | 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'",
",",
"'Problem'",
"]",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"e",
"->",
"getFailures",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"messages",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"$",
"table",
"->",
"setRow",
"(",
"$",
"i",
"++",
",",
"[",
"$",
"field",
",",
"$",
"message",
"]",
")",
";",
"}",
"$",
"table",
"->",
"render",
"(",
")",
";",
"}"
] | 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 |
30,379 | 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}$/'",
",",
"$",
"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",
";",
"}"
] | 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 |
30,380 | 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",
"(",
"$",
"productID",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,381 | 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",
"=",
"trim",
"(",
"$",
"productName",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,382 | 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",
"(",
"$",
"quantity",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,383 | 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",
"(",
"$",
"initials",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,384 | 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",
"(",
"$",
"lastName",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,385 | 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",
"(",
"$",
"street",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,386 | 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",
"=",
"trim",
"(",
"$",
"houseNumber",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,387 | 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",
"(",
"' '",
",",
"''",
",",
"$",
"zipCode",
")",
";",
"$",
"this",
"->",
"zipCode",
"=",
"trim",
"(",
"$",
"zipCode",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,388 | 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",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,389 | 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",
"(",
"$",
"country",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,390 | 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",
"(",
"'Phone must be set and cannot be empty.'",
")",
";",
"$",
"this",
"->",
"phone",
"=",
"$",
"phone",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,391 | 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",
"(",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"_data",
"[",
"\"products\"",
"]",
",",
"$",
"obj",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,392 | 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",
"(",
"'02'",
")",
"->",
"setProductName",
"(",
"$",
"name",
")",
"->",
"setDescription",
"(",
"$",
"description",
")",
"->",
"setQuantity",
"(",
"'1'",
")",
"->",
"setUnitPrice",
"(",
"-",
"$",
"amount",
")",
"->",
"setVATCategory",
"(",
"Icepay_Order_VAT",
"::",
"getCategoryForPercentage",
"(",
"-",
"1",
")",
")",
";",
"$",
"this",
"->",
"addProduct",
"(",
"$",
"obj",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,393 | 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'",
")",
"->",
"setProductName",
"(",
"$",
"name",
")",
"->",
"setDescription",
"(",
"''",
")",
"->",
"setQuantity",
"(",
"'1'",
")",
"->",
"setUnitPrice",
"(",
"$",
"amount",
")",
"->",
"setVATCategory",
"(",
"Icepay_Order_VAT",
"::",
"getCategoryForPercentage",
"(",
"$",
"vat",
")",
")",
";",
"$",
"this",
"->",
"addProduct",
"(",
"$",
"obj",
")",
";",
"return",
"$",
"this",
";",
"}"
] | 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 |
30,394 | 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",
"[",
"'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",
";",
"}",
"}"
] | 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 |
30,395 | 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",
"->",
"_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",
"(",
")",
";",
"}"
] | 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 |
30,396 | 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",
",",
"$",
"assetHash",
",",
"$",
"options",
")",
";",
"$",
"lastCacheDate",
"=",
"$",
"this",
"->",
"storageManager",
"->",
"getLastCacheDate",
"(",
"$",
"config",
"->",
"getCacheKey",
"(",
")",
",",
"$",
"processor",
")",
";",
"if",
"(",
"!",
"$",
"config",
"->",
"isValid",
"(",
"$",
"lastCacheDate",
")",
")",
"{",
"$",
"this",
"->",
"generate",
"(",
"$",
"config",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | 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 |
30,397 | 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",
"->",
"isOc1",
"(",
")",
"?",
"'extension/payment/'",
":",
"'payment/'",
";",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"extension",
")",
"{",
"$",
"registry",
"->",
"language",
"->",
"load",
"(",
"$",
"directory",
".",
"$",
"extension",
")",
";",
"$",
"results",
"[",
"$",
"extension",
"]",
"=",
"$",
"registry",
"->",
"language",
"->",
"get",
"(",
"'heading_title'",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | 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 |
30,398 | 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",
"=>",
"$",
"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",
";",
"}"
] | 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 |
30,399 | 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_kind",
"==",
"$",
"calcKind",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"orderItemId",
")",
"||",
"$",
"calcRule",
"->",
"virtuemart_order_item_id",
"==",
"$",
"orderItemId",
")",
"{",
"return",
"$",
"calcRule",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | 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 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.