repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
ems-project/EMSCommonBundle
Helper/ArrayTool.php
ArrayTool.normalizeAndSerializeArray
public static function normalizeAndSerializeArray(array &$array, int $sort_flags = SORT_REGULAR, int $jsonEncodeOptions = 0) { ArrayTool::normalizeArray($array, $sort_flags); return json_encode($array, $jsonEncodeOptions); }
php
public static function normalizeAndSerializeArray(array &$array, int $sort_flags = SORT_REGULAR, int $jsonEncodeOptions = 0) { ArrayTool::normalizeArray($array, $sort_flags); return json_encode($array, $jsonEncodeOptions); }
[ "public", "static", "function", "normalizeAndSerializeArray", "(", "array", "&", "$", "array", ",", "int", "$", "sort_flags", "=", "SORT_REGULAR", ",", "int", "$", "jsonEncodeOptions", "=", "0", ")", "{", "ArrayTool", "::", "normalizeArray", "(", "$", "array",...
Normalize and json encode an array in order to compute it's hash @param array $array @param int $sort_flags @param int $jsonEncodeOptions @return false|string
[ "Normalize", "and", "json", "encode", "an", "array", "in", "order", "to", "compute", "it", "s", "hash" ]
994fce2f727ebf702d327ba4cfce53d3c75bcef5
https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Helper/ArrayTool.php#L15-L19
train
ems-project/EMSCommonBundle
Helper/ArrayTool.php
ArrayTool.normalizeArray
public static function normalizeArray(array &$array, int $sort_flags = SORT_REGULAR) { ksort($array, $sort_flags); foreach ($array as $index => &$arr) { if (is_array($arr)) { ArrayTool::normalizeArray($arr, $sort_flags); } if (is_array($array[$index]) && empty($array[$index])) { unset($array[$index]); } } }
php
public static function normalizeArray(array &$array, int $sort_flags = SORT_REGULAR) { ksort($array, $sort_flags); foreach ($array as $index => &$arr) { if (is_array($arr)) { ArrayTool::normalizeArray($arr, $sort_flags); } if (is_array($array[$index]) && empty($array[$index])) { unset($array[$index]); } } }
[ "public", "static", "function", "normalizeArray", "(", "array", "&", "$", "array", ",", "int", "$", "sort_flags", "=", "SORT_REGULAR", ")", "{", "ksort", "(", "$", "array", ",", "$", "sort_flags", ")", ";", "foreach", "(", "$", "array", "as", "$", "ind...
Normalize an array in order to compute it's hash @param array $array @param int $sort_flags
[ "Normalize", "an", "array", "in", "order", "to", "compute", "it", "s", "hash" ]
994fce2f727ebf702d327ba4cfce53d3c75bcef5
https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Helper/ArrayTool.php#L27-L40
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.getStatusText
public function getStatusText() { switch ($this->getStatus()) { case self::Status_Success: return $this->t('message_response_success'); case self::Status_Notices: return $this->t('message_response_notices'); case self::Status_Warnings: return $this->t('message_response_warnings'); case self::Status_Errors: return $this->t('message_response_errors'); case self::Status_Exception: return $this->t('message_response_exception'); case null: return $this->t('message_response_not_set'); default: return sprintf($this->t('message_response_unknown'), $this->getStatus()); } }
php
public function getStatusText() { switch ($this->getStatus()) { case self::Status_Success: return $this->t('message_response_success'); case self::Status_Notices: return $this->t('message_response_notices'); case self::Status_Warnings: return $this->t('message_response_warnings'); case self::Status_Errors: return $this->t('message_response_errors'); case self::Status_Exception: return $this->t('message_response_exception'); case null: return $this->t('message_response_not_set'); default: return sprintf($this->t('message_response_unknown'), $this->getStatus()); } }
[ "public", "function", "getStatusText", "(", ")", "{", "switch", "(", "$", "this", "->", "getStatus", "(", ")", ")", "{", "case", "self", "::", "Status_Success", ":", "return", "$", "this", "->", "t", "(", "'message_response_success'", ")", ";", "case", "...
Returns a textual representation of the status. @return string
[ "Returns", "a", "textual", "representation", "of", "the", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L190-L208
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.getExceptionMessage
public function getExceptionMessage() { $message = ''; if (($e = $this->getException()) !== null) { $message = $e->getCode() . ': ' . $e->getMessage(); $message = $this->t('message_exception') . ' ' . $message; } return $message; }
php
public function getExceptionMessage() { $message = ''; if (($e = $this->getException()) !== null) { $message = $e->getCode() . ': ' . $e->getMessage(); $message = $this->t('message_exception') . ' ' . $message; } return $message; }
[ "public", "function", "getExceptionMessage", "(", ")", "{", "$", "message", "=", "''", ";", "if", "(", "(", "$", "e", "=", "$", "this", "->", "getException", "(", ")", ")", "!==", "null", ")", "{", "$", "message", "=", "$", "e", "->", "getCode", ...
Returns the exception message, if an exception was set. @return string
[ "Returns", "the", "exception", "message", "if", "an", "exception", "was", "set", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L285-L293
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.addMessages
protected function addMessages($method, array $messages) { // If there was exactly 1 message, it wasn't put in an array of messages. if (array_key_exists('code', $messages)) { $messages = array($messages); } foreach ($messages as $message) { call_user_func(array($this, $method), $message); } return $this; }
php
protected function addMessages($method, array $messages) { // If there was exactly 1 message, it wasn't put in an array of messages. if (array_key_exists('code', $messages)) { $messages = array($messages); } foreach ($messages as $message) { call_user_func(array($this, $method), $message); } return $this; }
[ "protected", "function", "addMessages", "(", "$", "method", ",", "array", "$", "messages", ")", "{", "// If there was exactly 1 message, it wasn't put in an array of messages.", "if", "(", "array_key_exists", "(", "'code'", ",", "$", "messages", ")", ")", "{", "$", ...
Adds multiple warnings to the list of warnings. A single warning may be passed in as a 1-dimensional array. @param string $method @param array $messages @return $this
[ "Adds", "multiple", "warnings", "to", "the", "list", "of", "warnings", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L383-L393
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.addError
public function addError($code, $codeTag = '', $message = '') { return $this->addMessage($code, $codeTag, $message, $this->errors, self::Status_Errors); }
php
public function addError($code, $codeTag = '', $message = '') { return $this->addMessage($code, $codeTag, $message, $this->errors, self::Status_Errors); }
[ "public", "function", "addError", "(", "$", "code", ",", "$", "codeTag", "=", "''", ",", "$", "message", "=", "''", ")", "{", "return", "$", "this", "->", "addMessage", "(", "$", "code", ",", "$", "codeTag", ",", "$", "message", ",", "$", "this", ...
Adds an error to the list of errors. @param int|array $code Error code number. Usually of type 4xx, 5xx, 6xx or 7xx (internal). It may also be an already completed error array. @param string $codeTag Special code tag. Use this as a reference when communicating with Acumulus technical support. @param string $message A message describing the error. @return $this
[ "Adds", "an", "error", "to", "the", "list", "of", "errors", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L409-L412
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.addNotice
public function addNotice($code, $codeTag = '', $message = '') { return $this->addMessage($code, $codeTag, $message, $this->notices, self::Status_Notices); }
php
public function addNotice($code, $codeTag = '', $message = '') { return $this->addMessage($code, $codeTag, $message, $this->notices, self::Status_Notices); }
[ "public", "function", "addNotice", "(", "$", "code", ",", "$", "codeTag", "=", "''", ",", "$", "message", "=", "''", ")", "{", "return", "$", "this", "->", "addMessage", "(", "$", "code", ",", "$", "codeTag", ",", "$", "message", ",", "$", "this", ...
Adds a notice to the list of notices. @param int $code Notice code number. Usually of type 4xx, 5xx, 6xx or 7xx (internal). It may also be an already completed notice array. @param string $codeTag Special code tag. Use this as a reference when communicating with Acumulus technical support. @param string $message A message describing the notice. @return $this
[ "Adds", "a", "notice", "to", "the", "list", "of", "notices", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L447-L450
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.mergeMessages
public function mergeMessages(Result $other, $errorsAsWarnings = false) { if ($this->getException() === null && $other->getException() !== null) { $this->setException($other->getException()); } if ($errorsAsWarnings) { $this->addWarnings($other->getErrors()); } else { $this->addErrors($other->getErrors()); } return $this->addWarnings($other->getWarnings())->addNotices($other->getNotices()); }
php
public function mergeMessages(Result $other, $errorsAsWarnings = false) { if ($this->getException() === null && $other->getException() !== null) { $this->setException($other->getException()); } if ($errorsAsWarnings) { $this->addWarnings($other->getErrors()); } else { $this->addErrors($other->getErrors()); } return $this->addWarnings($other->getWarnings())->addNotices($other->getNotices()); }
[ "public", "function", "mergeMessages", "(", "Result", "$", "other", ",", "$", "errorsAsWarnings", "=", "false", ")", "{", "if", "(", "$", "this", "->", "getException", "(", ")", "===", "null", "&&", "$", "other", "->", "getException", "(", ")", "!==", ...
Merges sets of exception, error and warning messages of 2 results. This allows to inform the user about errors and warnings that occurred during additional API calls, e.g. querying VAT rates or deleteing old entries. @param \Siel\Acumulus\Web\Result $other The other result to add the messages from. @param bool $errorsAsWarnings Whether errors should be merged as errors or as mere warnings because the main result is not really influenced by these errors. @return $this
[ "Merges", "sets", "of", "exception", "error", "and", "warning", "messages", "of", "2", "results", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L508-L519
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.hasMessages
public function hasMessages() { return !empty($this->notices) || !empty($this->warnings) || !empty($this->errors) || !empty($this->exception); }
php
public function hasMessages() { return !empty($this->notices) || !empty($this->warnings) || !empty($this->errors) || !empty($this->exception); }
[ "public", "function", "hasMessages", "(", ")", "{", "return", "!", "empty", "(", "$", "this", "->", "notices", ")", "||", "!", "empty", "(", "$", "this", "->", "warnings", ")", "||", "!", "empty", "(", "$", "this", "->", "errors", ")", "||", "!", ...
Returns whether the result contains a warning, error or exception. @return bool True if the result contains at least 1 warning, error or exception, false otherwise.
[ "Returns", "whether", "the", "result", "contains", "a", "warning", "error", "or", "exception", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L528-L531
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.hasCode
public function hasCode($code) { if ($this->getException() !== null && $this->getException()->getCode() === $code) { return true; } foreach ($this->getErrors() as $message) { if ($message['code'] == $code) { return true; } } foreach ($this->getWarnings() as $message) { if ($message['code'] == $code) { return true; } } foreach ($this->getNotices() as $message) { if ($message['code'] == $code) { return true; } } return false; }
php
public function hasCode($code) { if ($this->getException() !== null && $this->getException()->getCode() === $code) { return true; } foreach ($this->getErrors() as $message) { if ($message['code'] == $code) { return true; } } foreach ($this->getWarnings() as $message) { if ($message['code'] == $code) { return true; } } foreach ($this->getNotices() as $message) { if ($message['code'] == $code) { return true; } } return false; }
[ "public", "function", "hasCode", "(", "$", "code", ")", "{", "if", "(", "$", "this", "->", "getException", "(", ")", "!==", "null", "&&", "$", "this", "->", "getException", "(", ")", "->", "getCode", "(", ")", "===", "$", "code", ")", "{", "return"...
Returns whether the result contains a given code. @param int $code @return bool True if the result contains a given code, false otherwise.
[ "Returns", "whether", "the", "result", "contains", "a", "given", "code", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L553-L578
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.hasCodeTag
public function hasCodeTag($codeTag) { return array_key_exists($codeTag, $this->errors) || array_key_exists($codeTag, $this->warnings) || array_key_exists($codeTag, $this->notices); }
php
public function hasCodeTag($codeTag) { return array_key_exists($codeTag, $this->errors) || array_key_exists($codeTag, $this->warnings) || array_key_exists($codeTag, $this->notices); }
[ "public", "function", "hasCodeTag", "(", "$", "codeTag", ")", "{", "return", "array_key_exists", "(", "$", "codeTag", ",", "$", "this", "->", "errors", ")", "||", "array_key_exists", "(", "$", "codeTag", ",", "$", "this", "->", "warnings", ")", "||", "ar...
Returns whether the result contains a given codeTag. @param string $codeTag @return bool True if the result contains a given codeTag, false otherwise.
[ "Returns", "whether", "the", "result", "contains", "a", "given", "codeTag", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L588-L591
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.getMessages
public function getMessages($format = self::Format_Array) { $messages = array(); // Collect the messages. if (($message = $this->getExceptionMessage()) !== '') { $messages[] = $message; } $messages = array_merge($messages, $this->getErrors(self::Format_PlainTextArray)); $messages = array_merge($messages, $this->getWarnings(self::Format_PlainTextArray)); $messages = array_merge($messages, $this->getNotices(self::Format_PlainTextArray)); return $this->formatMessages($messages, $format); }
php
public function getMessages($format = self::Format_Array) { $messages = array(); // Collect the messages. if (($message = $this->getExceptionMessage()) !== '') { $messages[] = $message; } $messages = array_merge($messages, $this->getErrors(self::Format_PlainTextArray)); $messages = array_merge($messages, $this->getWarnings(self::Format_PlainTextArray)); $messages = array_merge($messages, $this->getNotices(self::Format_PlainTextArray)); return $this->formatMessages($messages, $format); }
[ "public", "function", "getMessages", "(", "$", "format", "=", "self", "::", "Format_Array", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "// Collect the messages.", "if", "(", "(", "$", "message", "=", "$", "this", "->", "getExceptionMessage", "...
If the result contains any errors or warnings, a list of verbose messages is returned. @param int $format The format in which to return the messages: - Result::Format_PlainTextArray: an array of strings - Result::Format_FormattedText: a plain text string with all messages on its own line indented by a '*'. - Result::Format_Html: a html string with all messages in an unordered HTML list @return string|string[] An string or array with textual messages that can be used to inform the user.
[ "If", "the", "result", "contains", "any", "errors", "or", "warnings", "a", "list", "of", "verbose", "messages", "is", "returned", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L609-L622
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.formatMessages
protected function formatMessages($messages, $format, $type = '') { if ($format === self::Format_Array) { $result = $messages; } else { $result = array(); foreach ($messages as $message) { if (is_array($message)) { $messagePart = "{$message['code']}: "; $messagePart .= $this->t($message['message']); if ($message['codetag']) { $messagePart .= " ({$message['codetag']})"; } $message = $this->t($type) . ' ' . $messagePart; } if ($format === self::Format_FormattedText) { $message = "* $message\n\n"; } elseif ($format === self::Format_Html) { $message = "<li>" . nl2br(htmlspecialchars($message, ENT_NOQUOTES)) . "</li>\n"; } $result[] = $message; } if ($format === self::Format_FormattedText) { $result = implode('', $result); } elseif ($format === self::Format_Html) { $result = "<ul>\n" . implode('', $result) . "</ul>\n"; } } return $result; }
php
protected function formatMessages($messages, $format, $type = '') { if ($format === self::Format_Array) { $result = $messages; } else { $result = array(); foreach ($messages as $message) { if (is_array($message)) { $messagePart = "{$message['code']}: "; $messagePart .= $this->t($message['message']); if ($message['codetag']) { $messagePart .= " ({$message['codetag']})"; } $message = $this->t($type) . ' ' . $messagePart; } if ($format === self::Format_FormattedText) { $message = "* $message\n\n"; } elseif ($format === self::Format_Html) { $message = "<li>" . nl2br(htmlspecialchars($message, ENT_NOQUOTES)) . "</li>\n"; } $result[] = $message; } if ($format === self::Format_FormattedText) { $result = implode('', $result); } elseif ($format === self::Format_Html) { $result = "<ul>\n" . implode('', $result) . "</ul>\n"; } } return $result; }
[ "protected", "function", "formatMessages", "(", "$", "messages", ",", "$", "format", ",", "$", "type", "=", "''", ")", "{", "if", "(", "$", "format", "===", "self", "::", "Format_Array", ")", "{", "$", "result", "=", "$", "messages", ";", "}", "else"...
Formats a set of messages. @param string[] $messages @param int $format @param string $type @return string|\string[]
[ "Formats", "a", "set", "of", "messages", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L634-L664
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.ApiStatus2InternalStatus
protected function ApiStatus2InternalStatus($status) { switch ($status) { case Api::Success: return self::Status_Success; case Api::Errors: return self::Status_Errors; case Api::Warnings: return self::Status_Warnings; case Api::Exception: default: return self::Status_Exception; } }
php
protected function ApiStatus2InternalStatus($status) { switch ($status) { case Api::Success: return self::Status_Success; case Api::Errors: return self::Status_Errors; case Api::Warnings: return self::Status_Warnings; case Api::Exception: default: return self::Status_Exception; } }
[ "protected", "function", "ApiStatus2InternalStatus", "(", "$", "status", ")", "{", "switch", "(", "$", "status", ")", "{", "case", "Api", "::", "Success", ":", "return", "self", "::", "Status_Success", ";", "case", "Api", "::", "Errors", ":", "return", "se...
Returns the corresponding internal status. @param $status The status as returned by the API. @return int The corresponding internal status.
[ "Returns", "the", "corresponding", "internal", "status", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L721-L734
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.getRawRequestResponse
public function getRawRequestResponse($format) { $result = ''; if ($this->getRawRequest() !== null || $this->getRawResponse() !== null) { $messages = array(); if ($this->getRawRequest() !== null) { $messages[] = $this->t('message_sent') . ":\n" . $this->getRawRequest(); } if ($this->getRawResponse() !== null) { $messages[] = $this->t('message_received') . ":\n" . $this->getRawResponse(); } $result .= $this->formatMessages($messages, $format); } return $result; }
php
public function getRawRequestResponse($format) { $result = ''; if ($this->getRawRequest() !== null || $this->getRawResponse() !== null) { $messages = array(); if ($this->getRawRequest() !== null) { $messages[] = $this->t('message_sent') . ":\n" . $this->getRawRequest(); } if ($this->getRawResponse() !== null) { $messages[] = $this->t('message_received') . ":\n" . $this->getRawResponse(); } $result .= $this->formatMessages($messages, $format); } return $result; }
[ "public", "function", "getRawRequestResponse", "(", "$", "format", ")", "{", "$", "result", "=", "''", ";", "if", "(", "$", "this", "->", "getRawRequest", "(", ")", "!==", "null", "||", "$", "this", "->", "getRawResponse", "(", ")", "!==", "null", ")",...
Returns a string with messages for support, ie the request and response. In html format it will be formatted in a details tag so that it is closed by default. @param $format @return string
[ "Returns", "a", "string", "with", "messages", "for", "support", "ie", "the", "request", "and", "response", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L801-L815
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.toLogString
public function toLogString() { $logParts = array(); if ($this->getStatus() !== null) { $logParts[] = 'status=' . $this->getStatus(); } if ($this->getRawRequest() !== null) { $logParts[] = 'request=' . $this->getRawRequest(); } if ($this->getRawResponse() !== null) { $logParts[] = 'response=' . $this->getRawResponse(); } if ($this->getException() !== null) { $logParts[] = $this->getException()->__toString(); } return implode('; ', $logParts); }
php
public function toLogString() { $logParts = array(); if ($this->getStatus() !== null) { $logParts[] = 'status=' . $this->getStatus(); } if ($this->getRawRequest() !== null) { $logParts[] = 'request=' . $this->getRawRequest(); } if ($this->getRawResponse() !== null) { $logParts[] = 'response=' . $this->getRawResponse(); } if ($this->getException() !== null) { $logParts[] = $this->getException()->__toString(); } return implode('; ', $logParts); }
[ "public", "function", "toLogString", "(", ")", "{", "$", "logParts", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "getStatus", "(", ")", "!==", "null", ")", "{", "$", "logParts", "[", "]", "=", "'status='", ".", "$", "this", "->", "...
Returns a string representation of the result object for logging purposes. @return string A string representation of the result object for logging purposes.
[ "Returns", "a", "string", "representation", "of", "the", "result", "object", "for", "logging", "purposes", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L823-L839
train
SIELOnline/libAcumulus
src/Web/Result.php
Result.simplifyResponse
protected function simplifyResponse(array $response) { // Simplify response by removing main key (which should be the only // remaining one). if (!empty($this->mainResponseKey) && isset($response[$this->mainResponseKey])) { $response = $response[$this->mainResponseKey]; if ($this->isList) { // Remove further indirection, i.e. get value of "singular", // which will be the first (and only) key. $response = reset($response); // If there was only 1 list result, it wasn't put in an array. if (!is_array(reset($response))) { $response = array($response); } } } return $response; }
php
protected function simplifyResponse(array $response) { // Simplify response by removing main key (which should be the only // remaining one). if (!empty($this->mainResponseKey) && isset($response[$this->mainResponseKey])) { $response = $response[$this->mainResponseKey]; if ($this->isList) { // Remove further indirection, i.e. get value of "singular", // which will be the first (and only) key. $response = reset($response); // If there was only 1 list result, it wasn't put in an array. if (!is_array(reset($response))) { $response = array($response); } } } return $response; }
[ "protected", "function", "simplifyResponse", "(", "array", "$", "response", ")", "{", "// Simplify response by removing main key (which should be the only", "// remaining one).", "if", "(", "!", "empty", "(", "$", "this", "->", "mainResponseKey", ")", "&&", "isset", "("...
Simplify the response by removing the main key. @param array $response @return array
[ "Simplify", "the", "response", "by", "removing", "the", "main", "key", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Result.php#L848-L866
train
ems-project/EMSCommonBundle
Storage/Processor/Config.php
Config.isValid
public function isValid(\DateTime $lastCacheDate = null): bool { $publishedDateTime = $this->getLastUpdateDate(); if ($publishedDateTime && $publishedDateTime < $lastCacheDate) { return true; } return null === $publishedDateTime && null !== $lastCacheDate; }
php
public function isValid(\DateTime $lastCacheDate = null): bool { $publishedDateTime = $this->getLastUpdateDate(); if ($publishedDateTime && $publishedDateTime < $lastCacheDate) { return true; } return null === $publishedDateTime && null !== $lastCacheDate; }
[ "public", "function", "isValid", "(", "\\", "DateTime", "$", "lastCacheDate", "=", "null", ")", ":", "bool", "{", "$", "publishedDateTime", "=", "$", "this", "->", "getLastUpdateDate", "(", ")", ";", "if", "(", "$", "publishedDateTime", "&&", "$", "publish...
Asset_config_type is optional, so _published_datetime can be null
[ "Asset_config_type", "is", "optional", "so", "_published_datetime", "can", "be", "null" ]
994fce2f727ebf702d327ba4cfce53d3c75bcef5
https://github.com/ems-project/EMSCommonBundle/blob/994fce2f727ebf702d327ba4cfce53d3c75bcef5/Storage/Processor/Config.php#L57-L66
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.getUri
public function getUri($apiFunction) { $environment = $this->config->getEnvironment(); $uri = $environment['baseUri'] . '/' . $environment['apiVersion'] . '/' . $apiFunction . '.php'; return $uri; }
php
public function getUri($apiFunction) { $environment = $this->config->getEnvironment(); $uri = $environment['baseUri'] . '/' . $environment['apiVersion'] . '/' . $apiFunction . '.php'; return $uri; }
[ "public", "function", "getUri", "(", "$", "apiFunction", ")", "{", "$", "environment", "=", "$", "this", "->", "config", "->", "getEnvironment", "(", ")", ";", "$", "uri", "=", "$", "environment", "[", "'baseUri'", "]", ".", "'/'", ".", "$", "environme...
Returns the uri to the requested API call. @param string $apiFunction @return string The uri to the requested API call.
[ "Returns", "the", "uri", "to", "the", "requested", "API", "call", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L63-L68
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.callApiFunction
public function callApiFunction($apiFunction, array $message, Result $result = null) { if ($result === null) { $result = $this->container->getResult(); } $uri = $this->getUri($apiFunction); try { $commonMessagePart = $this->getCommonPart(); $message = array_merge($commonMessagePart, $message); // Send message, receive response. $result = $this->sendApiMessage($uri, $message, $result); } catch (RuntimeException $e) { $result->setException($e); } $this->log->debug('Communicator::callApiFunction() uri=%s; %s', $uri, $result->toLogString()); return $result; }
php
public function callApiFunction($apiFunction, array $message, Result $result = null) { if ($result === null) { $result = $this->container->getResult(); } $uri = $this->getUri($apiFunction); try { $commonMessagePart = $this->getCommonPart(); $message = array_merge($commonMessagePart, $message); // Send message, receive response. $result = $this->sendApiMessage($uri, $message, $result); } catch (RuntimeException $e) { $result->setException($e); } $this->log->debug('Communicator::callApiFunction() uri=%s; %s', $uri, $result->toLogString()); return $result; }
[ "public", "function", "callApiFunction", "(", "$", "apiFunction", ",", "array", "$", "message", ",", "Result", "$", "result", "=", "null", ")", "{", "if", "(", "$", "result", "===", "null", ")", "{", "$", "result", "=", "$", "this", "->", "container", ...
Sends a message to the given API function and returns the results. @param string $apiFunction The API function to invoke. @param array $message The values to submit. @param \Siel\Acumulus\Web\Result $result It is possible to already create a Result object before calling the Web Service to store local messages. By passing this Result object these local messages will be merged with any remote messages in the returned Result object. @return \Siel\Acumulus\Web\Result A Result object containing the results.
[ "Sends", "a", "message", "to", "the", "given", "API", "function", "and", "returns", "the", "results", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L86-L105
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.getCommonPart
protected function getCommonPart() { $environment = $this->config->getEnvironment(); $pluginSettings = $this->config->getPluginSettings(); // Complete message with values common to all API calls: // - contract part // - format part // - environment part $commonMessagePart = array( 'contract' => $this->config->getCredentials(), 'format' => $pluginSettings['outputFormat'], 'testmode' => $pluginSettings['debug'] === PluginConfig::Send_TestMode ? Api::TestMode_Test : Api::TestMode_Normal, 'connector' => array( 'application' => "{$environment['shopName']} {$environment['shopVersion']}", 'webkoppel' => "Acumulus {$environment['moduleVersion']}", 'development' => 'SIEL - Buro RaDer', 'remark' => "Library {$environment['libraryVersion']} - PHP {$environment['phpVersion']}", 'sourceuri' => 'https://www.siel.nl/', ), ); return $commonMessagePart; }
php
protected function getCommonPart() { $environment = $this->config->getEnvironment(); $pluginSettings = $this->config->getPluginSettings(); // Complete message with values common to all API calls: // - contract part // - format part // - environment part $commonMessagePart = array( 'contract' => $this->config->getCredentials(), 'format' => $pluginSettings['outputFormat'], 'testmode' => $pluginSettings['debug'] === PluginConfig::Send_TestMode ? Api::TestMode_Test : Api::TestMode_Normal, 'connector' => array( 'application' => "{$environment['shopName']} {$environment['shopVersion']}", 'webkoppel' => "Acumulus {$environment['moduleVersion']}", 'development' => 'SIEL - Buro RaDer', 'remark' => "Library {$environment['libraryVersion']} - PHP {$environment['phpVersion']}", 'sourceuri' => 'https://www.siel.nl/', ), ); return $commonMessagePart; }
[ "protected", "function", "getCommonPart", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "config", "->", "getEnvironment", "(", ")", ";", "$", "pluginSettings", "=", "$", "this", "->", "config", "->", "getPluginSettings", "(", ")", ";", "// Com...
Returns the common part of each API message. The common part consists of the following tags: - contract - format - testmode - connector @return array The common part of each API message.
[ "Returns", "the", "common", "part", "of", "each", "API", "message", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L119-L141
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.sendApiMessage
protected function sendApiMessage($uri, array $message, Result $result) { // Convert message to XML. XML requires 1 top level tag, so add one. // The tagname is ignored by the Acumulus WebAPI. $message = $this->convertArrayToXml(array('myxml' => $message)); // Keep track of communication for debugging/logging at higher levels. $result->setRawRequest($message); $rawResponse = $this->sendHttpPost($uri, array('xmlstring' => $message), $result); $result->setRawResponse($rawResponse); if (empty($rawResponse)) { // CURL may get a time-out and return an empty response without // further error messages: Add an error to tell the user to check if // the invoice was sent or not. $result->addError(701, 'Empty response', ''); } elseif ($this->isHtmlResponse($result->getRawResponse())) { // When the API is gone we might receive an html error message page. $this->raiseHtmlReceivedError($result->getRawResponse()); } else { // Decode the response as either json or xml. $response = array(); $pluginSettings = $this->config->getPluginSettings(); if ($pluginSettings['outputFormat'] === 'json') { $response = json_decode($result->getRawResponse(), true); } // Even if we pass <format>json</format> we might receive an XML // response in case the XML was rejected before or during parsing. // So if the response is null we also try to decode the response as // XML. if ($pluginSettings['outputFormat'] === 'xml' || $response === null) { try { $response = $this->convertXmlToArray($result->getRawResponse()); } catch (RuntimeException $e) { // Not an XML response. Treat it as an json error if we were // expecting a json response. if ($pluginSettings['outputFormat'] === 'json') { $this->raiseJsonError(); } // Otherwise treat it as the XML exception that was raised. throw $e; } } $result->setResponse($response); } return $result; }
php
protected function sendApiMessage($uri, array $message, Result $result) { // Convert message to XML. XML requires 1 top level tag, so add one. // The tagname is ignored by the Acumulus WebAPI. $message = $this->convertArrayToXml(array('myxml' => $message)); // Keep track of communication for debugging/logging at higher levels. $result->setRawRequest($message); $rawResponse = $this->sendHttpPost($uri, array('xmlstring' => $message), $result); $result->setRawResponse($rawResponse); if (empty($rawResponse)) { // CURL may get a time-out and return an empty response without // further error messages: Add an error to tell the user to check if // the invoice was sent or not. $result->addError(701, 'Empty response', ''); } elseif ($this->isHtmlResponse($result->getRawResponse())) { // When the API is gone we might receive an html error message page. $this->raiseHtmlReceivedError($result->getRawResponse()); } else { // Decode the response as either json or xml. $response = array(); $pluginSettings = $this->config->getPluginSettings(); if ($pluginSettings['outputFormat'] === 'json') { $response = json_decode($result->getRawResponse(), true); } // Even if we pass <format>json</format> we might receive an XML // response in case the XML was rejected before or during parsing. // So if the response is null we also try to decode the response as // XML. if ($pluginSettings['outputFormat'] === 'xml' || $response === null) { try { $response = $this->convertXmlToArray($result->getRawResponse()); } catch (RuntimeException $e) { // Not an XML response. Treat it as an json error if we were // expecting a json response. if ($pluginSettings['outputFormat'] === 'json') { $this->raiseJsonError(); } // Otherwise treat it as the XML exception that was raised. throw $e; } } $result->setResponse($response); } return $result; }
[ "protected", "function", "sendApiMessage", "(", "$", "uri", ",", "array", "$", "message", ",", "Result", "$", "result", ")", "{", "// Convert message to XML. XML requires 1 top level tag, so add one.", "// The tagname is ignored by the Acumulus WebAPI.", "$", "message", "=", ...
Sends a message to the Acumulus API and returns the answer. Any errors during: - conversion of the message to xml, - communication with the Acumulus web service - converting the answer to an array are returned as an Exception. Any errors (or warnings) returned in the response structure of the web service are returned via the result value and should be handled at a higher level. @param string $uri The URI of the Acumulus WebAPI call to send the message to. @param array $message The message to send to the Acumulus WebAPI. @param \Siel\Acumulus\Web\Result $result The result structure to add the results to. @return \Siel\Acumulus\Web\Result The result of the web service call. @see https://www.siel.nl/acumulus/API/Basic_Response/ For the structure of a response.
[ "Sends", "a", "message", "to", "the", "Acumulus", "API", "and", "returns", "the", "answer", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L169-L217
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.convertXmlToArray
protected function convertXmlToArray($xml) { // Convert the response to an array via a 3-way conversion: // - create a simplexml object // - convert that to json // - convert json to array libxml_use_internal_errors(true); if (!($result = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA))) { $this->raiseLibxmlError(libxml_get_errors()); } if (!($result = json_encode($result))) { $this->raiseJsonError(); } if (($result = json_decode($result, true)) === null) { $this->raiseJsonError(); } return $result; }
php
protected function convertXmlToArray($xml) { // Convert the response to an array via a 3-way conversion: // - create a simplexml object // - convert that to json // - convert json to array libxml_use_internal_errors(true); if (!($result = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA))) { $this->raiseLibxmlError(libxml_get_errors()); } if (!($result = json_encode($result))) { $this->raiseJsonError(); } if (($result = json_decode($result, true)) === null) { $this->raiseJsonError(); } return $result; }
[ "protected", "function", "convertXmlToArray", "(", "$", "xml", ")", "{", "// Convert the response to an array via a 3-way conversion:", "// - create a simplexml object", "// - convert that to json", "// - convert json to array", "libxml_use_internal_errors", "(", "true", ")", ";", ...
Converts an XML string to an array. @param string $xml A string containing XML. @return array An array representation of the XML string. @throws \RuntimeException
[ "Converts", "an", "XML", "string", "to", "an", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L302-L321
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.convertArrayToXml
protected function convertArrayToXml(array $values) { $dom = new DOMDocument('1.0', 'utf-8'); $dom->xmlStandalone = true; $dom->formatOutput = true; try { $dom = $this->convertToDom($values, $dom); $result = $dom->saveXML(); if (!$result) { throw new RuntimeException('DOMDocument::saveXML failed'); } // Backslashes get lost between here and the Acumulus API, but // encoding them makes them get through. Solve here until the // real error has been found and solved. $result = str_replace('\\', '&#92;', $result); return $result; } catch (\DOMException $e) { // Convert a DOMException to a RuntimeException, so we only have to // handle RuntimeExceptions. throw new RuntimeException($e->getMessage(), $e->getCode(), $e); } }
php
protected function convertArrayToXml(array $values) { $dom = new DOMDocument('1.0', 'utf-8'); $dom->xmlStandalone = true; $dom->formatOutput = true; try { $dom = $this->convertToDom($values, $dom); $result = $dom->saveXML(); if (!$result) { throw new RuntimeException('DOMDocument::saveXML failed'); } // Backslashes get lost between here and the Acumulus API, but // encoding them makes them get through. Solve here until the // real error has been found and solved. $result = str_replace('\\', '&#92;', $result); return $result; } catch (\DOMException $e) { // Convert a DOMException to a RuntimeException, so we only have to // handle RuntimeExceptions. throw new RuntimeException($e->getMessage(), $e->getCode(), $e); } }
[ "protected", "function", "convertArrayToXml", "(", "array", "$", "values", ")", "{", "$", "dom", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "dom", "->", "xmlStandalone", "=", "true", ";", "$", "dom", "->", "formatOutput", "="...
Converts a keyed, optionally multi-level, array to XML. Each key is converted to a tag, no attributes are used. Numeric sub-arrays are repeated using the same key. @param array $values The array to convert to XML. @return string The XML string @throws \RuntimeException
[ "Converts", "a", "keyed", "optionally", "multi", "-", "level", "array", "to", "XML", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L337-L359
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.convertToDom
protected function convertToDom($values, $element) { /** @var DOMDocument $document */ static $document = null; $isFirstElement = true; if ($element instanceof DOMDocument) { $document = $element; } if (is_array($values)) { foreach ($values as $key => $value) { if (is_int($key)) { if ($isFirstElement) { $node = $element; $isFirstElement = false; } else { $node = $document->createElement($element->tagName); $element->parentNode->appendChild($node); } } else { $node = $document->createElement($key); $element->appendChild($node); } $this->convertToDom($value, $node); } } else { $element->appendChild($document->createTextNode(is_bool($values) ? ($values ? 'true' : 'false') : $values)); } return $element; }
php
protected function convertToDom($values, $element) { /** @var DOMDocument $document */ static $document = null; $isFirstElement = true; if ($element instanceof DOMDocument) { $document = $element; } if (is_array($values)) { foreach ($values as $key => $value) { if (is_int($key)) { if ($isFirstElement) { $node = $element; $isFirstElement = false; } else { $node = $document->createElement($element->tagName); $element->parentNode->appendChild($node); } } else { $node = $document->createElement($key); $element->appendChild($node); } $this->convertToDom($value, $node); } } else { $element->appendChild($document->createTextNode(is_bool($values) ? ($values ? 'true' : 'false') : $values)); } return $element; }
[ "protected", "function", "convertToDom", "(", "$", "values", ",", "$", "element", ")", "{", "/** @var DOMDocument $document */", "static", "$", "document", "=", "null", ";", "$", "isFirstElement", "=", "true", ";", "if", "(", "$", "element", "instanceof", "DOM...
Recursively converts a value to a DOMDocument|DOMElement. @param mixed $values A keyed array, an numerically indexed array, or a scalar type. @param DOMDocument|DOMElement $element The element to append the values to. @return DOMDocument|DOMElement @throws \DOMException
[ "Recursively", "converts", "a", "value", "to", "a", "DOMDocument|DOMElement", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L373-L403
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.raiseCurlError
protected function raiseCurlError($ch, $function) { $env = $this->config->getEnvironment(); $message = sprintf('%s (curl: %s): ', $function, $env['curlVersion']); if ($ch) { $code = curl_errno($ch); $message .= sprintf('%d - %s', $code, curl_error($ch)); } else { $code = 703; $message .= 'no curl handle'; } curl_close($ch); throw new RuntimeException($message, $code); }
php
protected function raiseCurlError($ch, $function) { $env = $this->config->getEnvironment(); $message = sprintf('%s (curl: %s): ', $function, $env['curlVersion']); if ($ch) { $code = curl_errno($ch); $message .= sprintf('%d - %s', $code, curl_error($ch)); } else { $code = 703; $message .= 'no curl handle'; } curl_close($ch); throw new RuntimeException($message, $code); }
[ "protected", "function", "raiseCurlError", "(", "$", "ch", ",", "$", "function", ")", "{", "$", "env", "=", "$", "this", "->", "config", "->", "getEnvironment", "(", ")", ";", "$", "message", "=", "sprintf", "(", "'%s (curl: %s): '", ",", "$", "function"...
Adds a curl error message to the result. @param resource|bool $ch @param string $function
[ "Adds", "a", "curl", "error", "message", "to", "the", "result", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L411-L424
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.raiseLibxmlError
protected function raiseLibxmlError(array $errors) { $messages = array(); $code = 704; foreach ($errors as $error) { // Overwrite our own code with the 1st code we get from libxml. if ($code === 704) { $code = $error->code; } $messages[] = sprintf('Line %d, column: %d: %s %d - %s', $error->line, $error->column, $error->level === LIBXML_ERR_WARNING ? 'warning' : 'error', $error->code, trim($error->message)); } throw new RuntimeException(implode("\n", $messages), $code); }
php
protected function raiseLibxmlError(array $errors) { $messages = array(); $code = 704; foreach ($errors as $error) { // Overwrite our own code with the 1st code we get from libxml. if ($code === 704) { $code = $error->code; } $messages[] = sprintf('Line %d, column: %d: %s %d - %s', $error->line, $error->column, $error->level === LIBXML_ERR_WARNING ? 'warning' : 'error', $error->code, trim($error->message)); } throw new RuntimeException(implode("\n", $messages), $code); }
[ "protected", "function", "raiseLibxmlError", "(", "array", "$", "errors", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "$", "code", "=", "704", ";", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "// Overwrite our own code with the...
Adds a libxml error messages to the result. @param LibXMLError[] $errors @throws \RuntimeException
[ "Adds", "a", "libxml", "error", "messages", "to", "the", "result", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L433-L445
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.raiseJsonError
protected function raiseJsonError() { $code = json_last_error(); switch ($code) { case JSON_ERROR_NONE: $message = 'No error'; break; case JSON_ERROR_DEPTH: $message = 'Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: $message = 'Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: $message = 'Unexpected control character found'; break; case JSON_ERROR_SYNTAX: $message = 'Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: $message = 'Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: $code = 705; $message = 'Unknown error'; break; } $env = $this->config->getEnvironment(); $message = sprintf('json (%s): %d - %s', $env['jsonVersion'], $code, $message); throw new RuntimeException($message, $code); }
php
protected function raiseJsonError() { $code = json_last_error(); switch ($code) { case JSON_ERROR_NONE: $message = 'No error'; break; case JSON_ERROR_DEPTH: $message = 'Maximum stack depth exceeded'; break; case JSON_ERROR_STATE_MISMATCH: $message = 'Underflow or the modes mismatch'; break; case JSON_ERROR_CTRL_CHAR: $message = 'Unexpected control character found'; break; case JSON_ERROR_SYNTAX: $message = 'Syntax error, malformed JSON'; break; case JSON_ERROR_UTF8: $message = 'Malformed UTF-8 characters, possibly incorrectly encoded'; break; default: $code = 705; $message = 'Unknown error'; break; } $env = $this->config->getEnvironment(); $message = sprintf('json (%s): %d - %s', $env['jsonVersion'], $code, $message); throw new RuntimeException($message, $code); }
[ "protected", "function", "raiseJsonError", "(", ")", "{", "$", "code", "=", "json_last_error", "(", ")", ";", "switch", "(", "$", "code", ")", "{", "case", "JSON_ERROR_NONE", ":", "$", "message", "=", "'No error'", ";", "break", ";", "case", "JSON_ERROR_DE...
Adds a json error message to the result. @throws \RuntimeException
[ "Adds", "a", "json", "error", "message", "to", "the", "result", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L452-L482
train
SIELOnline/libAcumulus
src/Web/Communicator.php
Communicator.raiseHtmlReceivedError
protected function raiseHtmlReceivedError($response) { libxml_use_internal_errors(true); $doc = new DOMDocument('1.0', 'utf-8'); $doc->loadHTML($response); $body = $doc->getElementsByTagName('body'); if ($body->length > 0) { $body = $body->item(0)->textContent; } else { $body = ''; } throw new RuntimeException("HTML response received: $body", 702); }
php
protected function raiseHtmlReceivedError($response) { libxml_use_internal_errors(true); $doc = new DOMDocument('1.0', 'utf-8'); $doc->loadHTML($response); $body = $doc->getElementsByTagName('body'); if ($body->length > 0) { $body = $body->item(0)->textContent; } else { $body = ''; } throw new RuntimeException("HTML response received: $body", 702); }
[ "protected", "function", "raiseHtmlReceivedError", "(", "$", "response", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "doc", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'utf-8'", ")", ";", "$", "doc", "->", "loadHTML", "(", "$", "...
Returns an error message containing the received HTML. @param string $response String containing an html document. @trows \RuntimeException
[ "Returns", "an", "error", "message", "containing", "the", "received", "HTML", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Web/Communicator.php#L492-L504
train
SIELOnline/libAcumulus
src/MyWebShop/Invoice/Creator.php
Creator.getItemLine
protected function getItemLine($item) { $result = array(); // @todo: add property source(s) for this item line. $this->addPropertySource('item', $item); $this->addProductInfo($result); $sign = $this->invoiceSource->getSign(); // @todo: add other tags and available meta tags (* = required): // * quantity // * unitprice and/or unitpriceinc // * vat related tags: // * vatrate and/or vatamount // * vat range tags (call method getVatRangeTags() // * vat rate source // - meta-unitprice-recalculate: if admin enters product prices inc vat // (which is normal) then the product price ex vat may be imprecise. // If the exact vat rate is not yet known, it may be recalculated in // the Completor phase. // - line totals // Should result in something like this: // Check for cost price. $productPriceEx = $sign * $item->priceEx; $precisionEx = 0.01; $productVat = $sign * $item->productTax; $precisionVat = 0.01; $productPriceInc = $sign * $item->priceInc; $quantity = $item->quantity; // Check for cost price and margin scheme. if (!empty($line['costPrice']) && $this->allowMarginScheme()) { // Margin scheme: // - Do not put VAT on invoice: send price incl VAT as unitprice. // - But still send the VAT rate to Acumulus. $result[Tag::UnitPrice] = $productPriceInc; } else { $result += array( Tag::UnitPrice => $productPriceEx, Meta::UnitPriceInc => $productPriceInc, Meta::RecalculatePrice => $productPricesIncludeTax ? Tag::UnitPrice : Meta::UnitPriceInc, ); } $result[Tag::Quantity] = $quantity; // Add tax info. $result += $this->getVatRangeTags($productVat, $productPriceEx, $precisionVat, $precisionEx); // @todo: remove property source(s) for this item line. $this->removePropertySource('item'); return $result; }
php
protected function getItemLine($item) { $result = array(); // @todo: add property source(s) for this item line. $this->addPropertySource('item', $item); $this->addProductInfo($result); $sign = $this->invoiceSource->getSign(); // @todo: add other tags and available meta tags (* = required): // * quantity // * unitprice and/or unitpriceinc // * vat related tags: // * vatrate and/or vatamount // * vat range tags (call method getVatRangeTags() // * vat rate source // - meta-unitprice-recalculate: if admin enters product prices inc vat // (which is normal) then the product price ex vat may be imprecise. // If the exact vat rate is not yet known, it may be recalculated in // the Completor phase. // - line totals // Should result in something like this: // Check for cost price. $productPriceEx = $sign * $item->priceEx; $precisionEx = 0.01; $productVat = $sign * $item->productTax; $precisionVat = 0.01; $productPriceInc = $sign * $item->priceInc; $quantity = $item->quantity; // Check for cost price and margin scheme. if (!empty($line['costPrice']) && $this->allowMarginScheme()) { // Margin scheme: // - Do not put VAT on invoice: send price incl VAT as unitprice. // - But still send the VAT rate to Acumulus. $result[Tag::UnitPrice] = $productPriceInc; } else { $result += array( Tag::UnitPrice => $productPriceEx, Meta::UnitPriceInc => $productPriceInc, Meta::RecalculatePrice => $productPricesIncludeTax ? Tag::UnitPrice : Meta::UnitPriceInc, ); } $result[Tag::Quantity] = $quantity; // Add tax info. $result += $this->getVatRangeTags($productVat, $productPriceEx, $precisionVat, $precisionEx); // @todo: remove property source(s) for this item line. $this->removePropertySource('item'); return $result; }
[ "protected", "function", "getItemLine", "(", "$", "item", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// @todo: add property source(s) for this item line.", "$", "this", "->", "addPropertySource", "(", "'item'", ",", "$", "item", ")", ";", "$", "thi...
Returns 1 item line, be it for an order or credit slip. @todo: specify type of this parameter @param $item An OrderDetail line. @return array
[ "Returns", "1", "item", "line", "be", "it", "for", "an", "order", "or", "credit", "slip", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/MyWebShop/Invoice/Creator.php#L97-L151
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.completeInvoiceLinesRecursive
protected function completeInvoiceLinesRecursive(array $invoice) { $lines = $invoice[Tag::Customer][Tag::Invoice][Tag::Line]; if ($this->completor->shouldConvertCurrency($invoice)) { $lines = $this->convertToEuro($lines, $invoice[Tag::Customer][Tag::Invoice][Meta::CurrencyRate]); } // @todo: we could combine all completor phase methods of getting the // correct vat rate: // - possible vat rates // - filter by range // - filter by tax class = foreign vat (or not) // - filter by lookup vat // Why? addVatRateUsingLookupData() actually already does so, but will // not work when we do have a lookup vat class but not a lookup vat // rate. // This would allow to combine VatRateSource_Calculated and // VatRateSource_Completor. // correctCalculatedVatRates() only uses vatrate, meta-vatrate-min, and // meta-vatrate-max and may lead to more (required) data filled in, so // should be called before completeLineRequiredData(). $lines = $this->correctCalculatedVatRates($lines); // addVatRateToLookupLines() only uses meta-vat-rate-lookup and may lead // to more (required) data filled in, so should be called before // completeLineRequiredData(). $lines = $this->addVatRateUsingLookupData($lines); $lines = $this->completeLineRequiredData($lines); // Completing the required data may lead to new lines that contain // calculated VAT rates and thus can be corrected with // correctCalculatedVatRates(): call again. $lines = $this->correctCalculatedVatRates($lines); $invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $lines; return $invoice; }
php
protected function completeInvoiceLinesRecursive(array $invoice) { $lines = $invoice[Tag::Customer][Tag::Invoice][Tag::Line]; if ($this->completor->shouldConvertCurrency($invoice)) { $lines = $this->convertToEuro($lines, $invoice[Tag::Customer][Tag::Invoice][Meta::CurrencyRate]); } // @todo: we could combine all completor phase methods of getting the // correct vat rate: // - possible vat rates // - filter by range // - filter by tax class = foreign vat (or not) // - filter by lookup vat // Why? addVatRateUsingLookupData() actually already does so, but will // not work when we do have a lookup vat class but not a lookup vat // rate. // This would allow to combine VatRateSource_Calculated and // VatRateSource_Completor. // correctCalculatedVatRates() only uses vatrate, meta-vatrate-min, and // meta-vatrate-max and may lead to more (required) data filled in, so // should be called before completeLineRequiredData(). $lines = $this->correctCalculatedVatRates($lines); // addVatRateToLookupLines() only uses meta-vat-rate-lookup and may lead // to more (required) data filled in, so should be called before // completeLineRequiredData(). $lines = $this->addVatRateUsingLookupData($lines); $lines = $this->completeLineRequiredData($lines); // Completing the required data may lead to new lines that contain // calculated VAT rates and thus can be corrected with // correctCalculatedVatRates(): call again. $lines = $this->correctCalculatedVatRates($lines); $invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $lines; return $invoice; }
[ "protected", "function", "completeInvoiceLinesRecursive", "(", "array", "$", "invoice", ")", "{", "$", "lines", "=", "$", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Tag", "::", "Line", "]", ";", "if", "(", "$"...
Completes the invoice lines before they are flattened. This means that the lines have to be walked recursively. The actions that can be done this way are those who operate on a line in isolation and thus do not need totals, maximums or things like that. @param array[] $invoice The invoice with the lines to complete recursively. @return array[] The invoice with the completed invoice lines.
[ "Completes", "the", "invoice", "lines", "before", "they", "are", "flattened", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L114-L148
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.completeInvoiceLines
protected function completeInvoiceLines(array $lines) { $lines = $this->addVatRateTo0PriceLines($lines); $lines = $this->recalculateLineData($lines); $lines = $this->completeLineMetaData($lines); return $lines; }
php
protected function completeInvoiceLines(array $lines) { $lines = $this->addVatRateTo0PriceLines($lines); $lines = $this->recalculateLineData($lines); $lines = $this->completeLineMetaData($lines); return $lines; }
[ "protected", "function", "completeInvoiceLines", "(", "array", "$", "lines", ")", "{", "$", "lines", "=", "$", "this", "->", "addVatRateTo0PriceLines", "(", "$", "lines", ")", ";", "$", "lines", "=", "$", "this", "->", "recalculateLineData", "(", "$", "lin...
Completes the invoice lines after they have been flattened. @param array[] $lines The invoice lines to complete. @return array[] The completed invoice lines.
[ "Completes", "the", "invoice", "lines", "after", "they", "have", "been", "flattened", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L159-L165
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.correctCalculatedVatRates
protected function correctCalculatedVatRates(array $lines) { foreach ($lines as &$line) { if (!empty($line[Meta::VatRateSource]) && $line[Meta::VatRateSource] === Creator::VatRateSource_Calculated) { $line = $this->correctVatRateByRange($line); } if (!empty($line[Meta::ChildrenLines])) { $line[Meta::ChildrenLines] = $this->correctCalculatedVatRates($line[Meta::ChildrenLines]); } } return $lines; }
php
protected function correctCalculatedVatRates(array $lines) { foreach ($lines as &$line) { if (!empty($line[Meta::VatRateSource]) && $line[Meta::VatRateSource] === Creator::VatRateSource_Calculated) { $line = $this->correctVatRateByRange($line); } if (!empty($line[Meta::ChildrenLines])) { $line[Meta::ChildrenLines] = $this->correctCalculatedVatRates($line[Meta::ChildrenLines]); } } return $lines; }
[ "protected", "function", "correctCalculatedVatRates", "(", "array", "$", "lines", ")", "{", "foreach", "(", "$", "lines", "as", "&", "$", "line", ")", "{", "if", "(", "!", "empty", "(", "$", "line", "[", "Meta", "::", "VatRateSource", "]", ")", "&&", ...
Corrects 'calculated' vat rates. Tries to correct 'calculated' vat rates for rounding errors by matching them with possible vatRates obtained from the vat lookup service. @param array[] $lines The invoice lines to correct. @return array[] The corrected invoice lines.
[ "Corrects", "calculated", "vat", "rates", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L214-L225
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.correctVatRateByRange
public function correctVatRateByRange(array $line) { $line[Meta::VatRateRangeMatches] = $this->filterVatRateInfosByRange($line[Meta::VatRateMin], $line[Meta::VatRateMax]); $vatRate = $this->getUniqueVatRate($line[Meta::VatRateRangeMatches]); if ($vatRate === null) { // No match at all. unset($line[Tag::VatRate]); if (!empty($line[Meta::StrategySplit])) { // If this line may be split, we make it a strategy line (even // though 2 out of the 3 fields ex, inc, and vat are known). // This way the strategy phase may be able to correct this line. $line[Tag::VatRate] = null; $line[Meta::VatRateSource] = Creator::VatRateSource_Strategy; } else { // Set vatrate to null and try to use lookup data to get a vat // rate. It will be invalid but may be better than the "setting // to standard 21%". $line[Tag::VatRate] = null; $line[Meta::VatRateSource] = Creator::VatRateSource_Completor; $this->completor->changeInvoiceToConcept('message_warning_no_vatrate', 821); // @todo: this can also happen with exact or looked up vat rates // add a checker in the Completor that checks all lines for // no or an incorrect vat rate and changes the invoice into a // concept. } } elseif ($vatRate === false) { // Multiple matches: set vatrate to null and try to use lookup data. $line[Tag::VatRate] = null; $line[Meta::VatRateSource] = Creator::VatRateSource_Completor; } else { // Single match: fill it in as the vat rate for this line. $line[Tag::VatRate] = $vatRate; $line[Meta::VatRateSource] = Completor::VatRateSource_Completor_Range; } return $line; }
php
public function correctVatRateByRange(array $line) { $line[Meta::VatRateRangeMatches] = $this->filterVatRateInfosByRange($line[Meta::VatRateMin], $line[Meta::VatRateMax]); $vatRate = $this->getUniqueVatRate($line[Meta::VatRateRangeMatches]); if ($vatRate === null) { // No match at all. unset($line[Tag::VatRate]); if (!empty($line[Meta::StrategySplit])) { // If this line may be split, we make it a strategy line (even // though 2 out of the 3 fields ex, inc, and vat are known). // This way the strategy phase may be able to correct this line. $line[Tag::VatRate] = null; $line[Meta::VatRateSource] = Creator::VatRateSource_Strategy; } else { // Set vatrate to null and try to use lookup data to get a vat // rate. It will be invalid but may be better than the "setting // to standard 21%". $line[Tag::VatRate] = null; $line[Meta::VatRateSource] = Creator::VatRateSource_Completor; $this->completor->changeInvoiceToConcept('message_warning_no_vatrate', 821); // @todo: this can also happen with exact or looked up vat rates // add a checker in the Completor that checks all lines for // no or an incorrect vat rate and changes the invoice into a // concept. } } elseif ($vatRate === false) { // Multiple matches: set vatrate to null and try to use lookup data. $line[Tag::VatRate] = null; $line[Meta::VatRateSource] = Creator::VatRateSource_Completor; } else { // Single match: fill it in as the vat rate for this line. $line[Tag::VatRate] = $vatRate; $line[Meta::VatRateSource] = Completor::VatRateSource_Completor_Range; } return $line; }
[ "public", "function", "correctVatRateByRange", "(", "array", "$", "line", ")", "{", "$", "line", "[", "Meta", "::", "VatRateRangeMatches", "]", "=", "$", "this", "->", "filterVatRateInfosByRange", "(", "$", "line", "[", "Meta", "::", "VatRateMin", "]", ",", ...
Checks and corrects a 'calculated' vat rate to an allowed vat rate. The meta-vatrate-source must be Creator::VatRateSource_Calculated. The check is done on comparing allowed vat rates with the meta-vatrate-min and meta-vatrate-max values. If only 1 match is found that will be used. If multiple matches are found with all equal rates - e.g. Dutch and Belgium 21% - the vat rate will be corrected, but the VAT Type will remain undecided, unless the vat class could be looked up and thus used to differentiate between national and foreign vat. This method is public to allow a 2nd call to just this method for a single line (a missing amount line) added after a 1st round of correcting. Do not use unless $this->possibleVatRates has been initialized. @param array $line An invoice line with a calculated vat rate. @return array The invoice line with a corrected vat rate.
[ "Checks", "and", "corrects", "a", "calculated", "vat", "rate", "to", "an", "allowed", "vat", "rate", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L252-L289
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.getMaxAppearingVatRate
public static function getMaxAppearingVatRate(array $lines, &$index = 0) { $index = null; $maxVatRate = -1.0; foreach ($lines as $key => $line) { if (isset($line[Tag::VatRate]) && (float) $line[Tag::VatRate] > $maxVatRate) { $index = $key; $maxVatRate = (float) $line[Tag::VatRate]; } } return $index !== null ? $maxVatRate : null; }
php
public static function getMaxAppearingVatRate(array $lines, &$index = 0) { $index = null; $maxVatRate = -1.0; foreach ($lines as $key => $line) { if (isset($line[Tag::VatRate]) && (float) $line[Tag::VatRate] > $maxVatRate) { $index = $key; $maxVatRate = (float) $line[Tag::VatRate]; } } return $index !== null ? $maxVatRate : null; }
[ "public", "static", "function", "getMaxAppearingVatRate", "(", "array", "$", "lines", ",", "&", "$", "index", "=", "0", ")", "{", "$", "index", "=", "null", ";", "$", "maxVatRate", "=", "-", "1.0", ";", "foreach", "(", "$", "lines", "as", "$", "key",...
Returns the maximum vat rate that appears in the given set of lines. @param array[] $lines The invoice lines to search. @param int $index If passed, the index of the max vat rate is returned via this parameter. @return float|null The maximum vat rate in the given set of lines or null if no vat rates could be found.
[ "Returns", "the", "maximum", "vat", "rate", "that", "appears", "in", "the", "given", "set", "of", "lines", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L547-L558
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.filterVatRateInfosByRange
protected function filterVatRateInfosByRange($min, $max, array $vatRateInfos = null) { if ($vatRateInfos === null) { $vatRateInfos = $this->possibleVatRates; } $result = array(); foreach ($vatRateInfos as $vatRateInfo) { $vatRate = is_array($vatRateInfo) ? $vatRateInfo[Tag::VatRate] : $vatRateInfo; if ($min <= $vatRate && $vatRate <= $max) { $result[] = $vatRateInfo; } } return $result; }
php
protected function filterVatRateInfosByRange($min, $max, array $vatRateInfos = null) { if ($vatRateInfos === null) { $vatRateInfos = $this->possibleVatRates; } $result = array(); foreach ($vatRateInfos as $vatRateInfo) { $vatRate = is_array($vatRateInfo) ? $vatRateInfo[Tag::VatRate] : $vatRateInfo; if ($min <= $vatRate && $vatRate <= $max) { $result[] = $vatRateInfo; } } return $result; }
[ "protected", "function", "filterVatRateInfosByRange", "(", "$", "min", ",", "$", "max", ",", "array", "$", "vatRateInfos", "=", "null", ")", "{", "if", "(", "$", "vatRateInfos", "===", "null", ")", "{", "$", "vatRateInfos", "=", "$", "this", "->", "possi...
Returns the set of possible vat rates that fall in the given vat range. @param float $min @param float $max @param array|null $vatRateInfos The set of vat rate infos to filter. If not given, the property $this->possibleVatRates is used. @return array[] The, possibly empty, set of vat rate infos that have a vat rate that falls within the given vat range.
[ "Returns", "the", "set", "of", "possible", "vat", "rates", "that", "fall", "in", "the", "given", "vat", "range", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L573-L587
train
SIELOnline/libAcumulus
src/Invoice/CompletorInvoiceLines.php
CompletorInvoiceLines.filterVatRateInfosByVatRates
protected function filterVatRateInfosByVatRates($vatRates, array $vatRateInfos = null) { $vatRates = (array) $vatRates; if ($vatRateInfos === null) { $vatRateInfos = $this->possibleVatRates; } $result = array(); foreach ($vatRateInfos as $vatRateInfo) { $vatRate = $vatRateInfo[Tag::VatRate]; foreach ($vatRates as $vatRateInfo2) { $vatRate2 = is_array($vatRateInfo2) ? $vatRateInfo2[Tag::VatRate] : $vatRateInfo2; if (Number::floatsAreEqual($vatRate, $vatRate2)) { $result[] = $vatRateInfo; } } } return $result; }
php
protected function filterVatRateInfosByVatRates($vatRates, array $vatRateInfos = null) { $vatRates = (array) $vatRates; if ($vatRateInfos === null) { $vatRateInfos = $this->possibleVatRates; } $result = array(); foreach ($vatRateInfos as $vatRateInfo) { $vatRate = $vatRateInfo[Tag::VatRate]; foreach ($vatRates as $vatRateInfo2) { $vatRate2 = is_array($vatRateInfo2) ? $vatRateInfo2[Tag::VatRate] : $vatRateInfo2; if (Number::floatsAreEqual($vatRate, $vatRate2)) { $result[] = $vatRateInfo; } } } return $result; }
[ "protected", "function", "filterVatRateInfosByVatRates", "(", "$", "vatRates", ",", "array", "$", "vatRateInfos", "=", "null", ")", "{", "$", "vatRates", "=", "(", "array", ")", "$", "vatRates", ";", "if", "(", "$", "vatRateInfos", "===", "null", ")", "{",...
Returns the subset of the vat rate infos that have a vat rate that appears within the given set of vat rates. @param float|float[] $vatRates The vat rate(s) to filter. @param array|null $vatRateInfos The set of vat rate infos to filter. If not given, the property $this->possibleVatRates is used. @return array[] The, possibly empty, set of vat rate infos that have a vat rate that appears within the set of $vatRates.
[ "Returns", "the", "subset", "of", "the", "vat", "rate", "infos", "that", "have", "a", "vat", "rate", "that", "appears", "within", "the", "given", "set", "of", "vat", "rates", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorInvoiceLines.php#L603-L621
train
ipunkt/rancherize
app/Blueprint/ResourceLimit/EventListener/ServiceBuiltListener.php
ServiceBuiltListener.sidekickBuilt
public function sidekickBuilt(SidekickBuiltEvent $event) { $service = $event->getService(); $config = $event->getConfiguration(); $this->parser->parseLimit( $service, $config ); }
php
public function sidekickBuilt(SidekickBuiltEvent $event) { $service = $event->getService(); $config = $event->getConfiguration(); $this->parser->parseLimit( $service, $config ); }
[ "public", "function", "sidekickBuilt", "(", "SidekickBuiltEvent", "$", "event", ")", "{", "$", "service", "=", "$", "event", "->", "getService", "(", ")", ";", "$", "config", "=", "$", "event", "->", "getConfiguration", "(", ")", ";", "$", "this", "->", ...
This allows overriding the limits inherited by the main service @param SidekickBuiltEvent $event
[ "This", "allows", "overriding", "the", "limits", "inherited", "by", "the", "main", "service" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/ResourceLimit/EventListener/ServiceBuiltListener.php#L58-L65
train
SIELOnline/libAcumulus
src/Config/ShopCapabilities.php
ShopCapabilities.getTokenInfo
public function getTokenInfo() { $result = array(); $result['invoiceSource'] = array( 'more-info' => ucfirst($this->t('invoice_source')), 'class' => '\Siel\Acumulus\Invoice\Source', 'properties' => array( 'type (' . $this->t(Source::Order) . ' ' . $this->t('or') . ' ' . $this->t(Source::CreditNote) . ')', 'id (' . $this->t('internal_id') . ')', 'reference (' . $this->t('external_id') . ')', 'date', 'status (' . $this->t('internal_not_label') . ')', 'paymentMethod (' . $this->t('internal_not_label') . ')', 'paymentStatus (1: ' . $this->t('payment_status_1') . '; 2: ' . $this->t('payment_status_2') . ')', 'paymentDate', 'countryCode', 'currency', 'invoiceReference (' . $this->t('external_id') . ')', 'invoiceDate', ), 'properties-more' => false, ); if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) { $result['originalInvoiceSource'] = array( 'more-info' => ucfirst($this->t('original_invoice_source')), 'properties' => array($this->t('see_invoice_source_above')), 'properties-more' => false, ); } $result['source'] = array_merge(array('more-info' => ucfirst($this->t('order_or_refund'))), $this->getTokenInfoSource()); if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) { $result['refund'] = array_merge(array('more-info' => ucfirst($this->t('refund_only'))), $this->getTokenInfoRefund()); $result['order'] = array_merge(array('more-info' => ucfirst($this->t('original_order_for_refund'))), $this->getTokenInfoOrder()); $result['refundedInvoiceSource'] = array( 'more-info' => ucfirst($this->t('original_invoice_source') . ' ' . ucfirst($this->t('refund_only'))), 'properties' => array($this->t('see_invoice_source_above')), 'properties-more' => false, ); $result['refundedOrder'] = array( 'more-info' => ucfirst($this->t('original_order_for_refund') . ' ' . ucfirst($this->t('refund_only'))), 'properties' => array($this->t('see_order_above')), 'properties-more' => false, ); } $result += $this->getTokenInfoShopProperties(); return $result; }
php
public function getTokenInfo() { $result = array(); $result['invoiceSource'] = array( 'more-info' => ucfirst($this->t('invoice_source')), 'class' => '\Siel\Acumulus\Invoice\Source', 'properties' => array( 'type (' . $this->t(Source::Order) . ' ' . $this->t('or') . ' ' . $this->t(Source::CreditNote) . ')', 'id (' . $this->t('internal_id') . ')', 'reference (' . $this->t('external_id') . ')', 'date', 'status (' . $this->t('internal_not_label') . ')', 'paymentMethod (' . $this->t('internal_not_label') . ')', 'paymentStatus (1: ' . $this->t('payment_status_1') . '; 2: ' . $this->t('payment_status_2') . ')', 'paymentDate', 'countryCode', 'currency', 'invoiceReference (' . $this->t('external_id') . ')', 'invoiceDate', ), 'properties-more' => false, ); if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) { $result['originalInvoiceSource'] = array( 'more-info' => ucfirst($this->t('original_invoice_source')), 'properties' => array($this->t('see_invoice_source_above')), 'properties-more' => false, ); } $result['source'] = array_merge(array('more-info' => ucfirst($this->t('order_or_refund'))), $this->getTokenInfoSource()); if (array_key_exists(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) { $result['refund'] = array_merge(array('more-info' => ucfirst($this->t('refund_only'))), $this->getTokenInfoRefund()); $result['order'] = array_merge(array('more-info' => ucfirst($this->t('original_order_for_refund'))), $this->getTokenInfoOrder()); $result['refundedInvoiceSource'] = array( 'more-info' => ucfirst($this->t('original_invoice_source') . ' ' . ucfirst($this->t('refund_only'))), 'properties' => array($this->t('see_invoice_source_above')), 'properties-more' => false, ); $result['refundedOrder'] = array( 'more-info' => ucfirst($this->t('original_order_for_refund') . ' ' . ucfirst($this->t('refund_only'))), 'properties' => array($this->t('see_order_above')), 'properties-more' => false, ); } $result += $this->getTokenInfoShopProperties(); return $result; }
[ "public", "function", "getTokenInfo", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'invoiceSource'", "]", "=", "array", "(", "'more-info'", "=>", "ucfirst", "(", "$", "this", "->", "t", "(", "'invoice_source'", ")", "...
Returns a list with the shop specific token info. Many fields of an Acumulus invoice can be filled with user configured and dynamically looked up values of properties or method return values from webshop objects that are made available when creating the invoice. The advanced settings form gives the user an overview of what objects, properties and methods are available. This overview is based on the info that this method returns. This base implementation returns the info that is available in all webshops. Overriding methods should add the webshop specific info, which must at least include the "property source" 'source', being the webshop's order or refund object or array. This method returns an array of token infos keyed by the "property source" name. A token info is an array that can have the following keys: * more-info (string, optional): free text to tell the use where to look for more info. * class (string|string[], optional): class or array of class names where the properties come from. * file (string|string[], optional): file or array of file names where the properties come from. * table (string|string[], optional): database table or array of table names where the properties come from. * additional-info (string, optional): free text to give the user additional info. * properties (string[], required): array of property and method names that can be used as token. * properties-more: bool indicating if not all properties were listed and a message indicating where to look for more properties should be shown. It is expected that 1 of the keys class, file, or table is defined. If class is defined, file may also be defined. @return array[] An array of token infos keyed by the "property source" name.
[ "Returns", "a", "list", "with", "the", "shop", "specific", "token", "info", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L128-L175
train
SIELOnline/libAcumulus
src/Config/ShopCapabilities.php
ShopCapabilities.getSupportedInvoiceSourceTypes
public function getSupportedInvoiceSourceTypes() { return array( Source::Order => ucfirst($this->t(Source::Order)), Source::CreditNote => ucfirst($this->t(Source::CreditNote)), ); }
php
public function getSupportedInvoiceSourceTypes() { return array( Source::Order => ucfirst($this->t(Source::Order)), Source::CreditNote => ucfirst($this->t(Source::CreditNote)), ); }
[ "public", "function", "getSupportedInvoiceSourceTypes", "(", ")", "{", "return", "array", "(", "Source", "::", "Order", "=>", "ucfirst", "(", "$", "this", "->", "t", "(", "Source", "::", "Order", ")", ")", ",", "Source", "::", "CreditNote", "=>", "ucfirst"...
Returns a list of invoice source types supported by this shop. The default implementation returns order and credit note. Override if the specific shop does not support credit notes (or supports other types). @return string[] The list of supported invoice source types. The keys are the internal {@see \Siel\Acumulus\Invoice\Source} constants, the values are translated labels.
[ "Returns", "a", "list", "of", "invoice", "source", "types", "supported", "by", "this", "shop", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L242-L248
train
SIELOnline/libAcumulus
src/Config/ShopCapabilities.php
ShopCapabilities.getTriggerCreditNoteEventOptions
public function getTriggerCreditNoteEventOptions() { $result = array( PluginConfig::TriggerCreditNoteEvent_None => $this->t('option_triggerCreditNoteEvent_0'), ); if (in_array(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) { $result[PluginConfig::TriggerCreditNoteEvent_Create] = $this->t('option_triggerCreditNoteEvent_1'); } return $result; }
php
public function getTriggerCreditNoteEventOptions() { $result = array( PluginConfig::TriggerCreditNoteEvent_None => $this->t('option_triggerCreditNoteEvent_0'), ); if (in_array(Source::CreditNote, $this->getSupportedInvoiceSourceTypes())) { $result[PluginConfig::TriggerCreditNoteEvent_Create] = $this->t('option_triggerCreditNoteEvent_1'); } return $result; }
[ "public", "function", "getTriggerCreditNoteEventOptions", "(", ")", "{", "$", "result", "=", "array", "(", "PluginConfig", "::", "TriggerCreditNoteEvent_None", "=>", "$", "this", "->", "t", "(", "'option_triggerCreditNoteEvent_0'", ")", ",", ")", ";", "if", "(", ...
Returns an option list of credit note related events. This list represents the shop initiated events that may trigger the sending of a credit invoice to Acumulus. This default implementation returns - PluginConfig::TriggerCreditNoteEvent_None for all shops, and as only value for shops that do not support credit notes - PluginConfig::TriggerCreditNoteEvent_Create for shops that do support credit notes (based on {@see getSupportedInvoiceSourceTypes()}). @return string[] An array of all credit note related events, with the key being the ID for the dropdown item, 1 of the {@see \Siel\Acumulus\PluginConfig} TriggerCreditNoteEvent_... constants, and the value being the label for the dropdown item.
[ "Returns", "an", "option", "list", "of", "credit", "note", "related", "events", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L287-L298
train
SIELOnline/libAcumulus
src/Config/ShopCapabilities.php
ShopCapabilities.getInvoiceNrSourceOptions
public function getInvoiceNrSourceOptions() { return array( PluginConfig::InvoiceNrSource_ShopInvoice => $this->t('option_invoiceNrSource_1'), PluginConfig::InvoiceNrSource_ShopOrder => $this->t('option_invoiceNrSource_2'), PluginConfig::InvoiceNrSource_Acumulus => $this->t('option_invoiceNrSource_3'), ); }
php
public function getInvoiceNrSourceOptions() { return array( PluginConfig::InvoiceNrSource_ShopInvoice => $this->t('option_invoiceNrSource_1'), PluginConfig::InvoiceNrSource_ShopOrder => $this->t('option_invoiceNrSource_2'), PluginConfig::InvoiceNrSource_Acumulus => $this->t('option_invoiceNrSource_3'), ); }
[ "public", "function", "getInvoiceNrSourceOptions", "(", ")", "{", "return", "array", "(", "PluginConfig", "::", "InvoiceNrSource_ShopInvoice", "=>", "$", "this", "->", "t", "(", "'option_invoiceNrSource_1'", ")", ",", "PluginConfig", "::", "InvoiceNrSource_ShopOrder", ...
Returns a list of valid sources that can be used as invoice number. This may differ per shop as not all shops support invoices as a separate entity. Overrides should typically return a subset of the constants defined in this base implementation, but including at least {@see \Siel\Acumulus\PluginConfig::InvoiceNrSource_Acumulus}. @return string[] An array keyed by the option values and having translated descriptions as values.
[ "Returns", "a", "list", "of", "valid", "sources", "that", "can", "be", "used", "as", "invoice", "number", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L314-L321
train
SIELOnline/libAcumulus
src/Config/ShopCapabilities.php
ShopCapabilities.getDateToUseOptions
public function getDateToUseOptions() { return array( PluginConfig::InvoiceDate_InvoiceCreate => $this->t('option_dateToUse_1'), PluginConfig::InvoiceDate_OrderCreate => $this->t('option_dateToUse_2'), PluginConfig::InvoiceDate_Transfer => $this->t('option_dateToUse_3'), ); }
php
public function getDateToUseOptions() { return array( PluginConfig::InvoiceDate_InvoiceCreate => $this->t('option_dateToUse_1'), PluginConfig::InvoiceDate_OrderCreate => $this->t('option_dateToUse_2'), PluginConfig::InvoiceDate_Transfer => $this->t('option_dateToUse_3'), ); }
[ "public", "function", "getDateToUseOptions", "(", ")", "{", "return", "array", "(", "PluginConfig", "::", "InvoiceDate_InvoiceCreate", "=>", "$", "this", "->", "t", "(", "'option_dateToUse_1'", ")", ",", "PluginConfig", "::", "InvoiceDate_OrderCreate", "=>", "$", ...
Returns a list of valid date sources that can be used as invoice date. This may differ per shop as not all shops support invoices as a separate entity. Overrides should typically return a subset of the constants defined in this base implementation, but including at least {@see \Siel\Acumulus\PluginConfig::InvoiceDate_Transfer}. @return string[] An array keyed by the option values and having translated descriptions as values.
[ "Returns", "a", "list", "of", "valid", "date", "sources", "that", "can", "be", "used", "as", "invoice", "date", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Config/ShopCapabilities.php#L337-L344
train
SIELOnline/libAcumulus
src/WooCommerce/Invoice/CreatorPluginSupport.php
CreatorPluginSupport.getItemLineBeforeBookings
public function getItemLineBeforeBookings(Creator $creator, WC_Order_Item_Product $item, $product) { if ($product instanceof WC_Product) { if (function_exists('is_wc_booking_product') && is_wc_booking_product($product)) { $booking_ids = WC_Booking_Data_Store::get_booking_ids_from_order_item_id($item->get_id()); if ($booking_ids) { // I cannot imagine multiple bookings belonging to the same // order line, but if that occurs, only the 1st booking will // be added as a property source. $booking = new WC_Booking(reset($booking_ids)); $creator->addPropertySource('booking', $booking); $resource = $booking->get_resource(); if ($resource) { $creator->addPropertySource('resource', $resource); } } } } }
php
public function getItemLineBeforeBookings(Creator $creator, WC_Order_Item_Product $item, $product) { if ($product instanceof WC_Product) { if (function_exists('is_wc_booking_product') && is_wc_booking_product($product)) { $booking_ids = WC_Booking_Data_Store::get_booking_ids_from_order_item_id($item->get_id()); if ($booking_ids) { // I cannot imagine multiple bookings belonging to the same // order line, but if that occurs, only the 1st booking will // be added as a property source. $booking = new WC_Booking(reset($booking_ids)); $creator->addPropertySource('booking', $booking); $resource = $booking->get_resource(); if ($resource) { $creator->addPropertySource('resource', $resource); } } } } }
[ "public", "function", "getItemLineBeforeBookings", "(", "Creator", "$", "creator", ",", "WC_Order_Item_Product", "$", "item", ",", "$", "product", ")", "{", "if", "(", "$", "product", "instanceof", "WC_Product", ")", "{", "if", "(", "function_exists", "(", "'i...
Support for the "WooCommerce Bookings" plugin. Bookings are stored in a separate entity, we add that as a separate property source, so its properties can be used. @param \Siel\Acumulus\WooCommerce\Invoice\Creator $creator @param WC_Order_Item_Product $item @param WC_Product|bool $product
[ "Support", "for", "the", "WooCommerce", "Bookings", "plugin", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L72-L90
train
SIELOnline/libAcumulus
src/WooCommerce/Invoice/CreatorPluginSupport.php
CreatorPluginSupport.acumulusInvoiceCreated
public function acumulusInvoiceCreated($invoice, BaseSource $invoiceSource, Result $localResult) { $invoice = $this->supportBundleProducts($invoice, $invoiceSource, $localResult); $invoice = $this->supportTMExtraProductOptions($invoice, $invoiceSource, $localResult); return $invoice; }
php
public function acumulusInvoiceCreated($invoice, BaseSource $invoiceSource, Result $localResult) { $invoice = $this->supportBundleProducts($invoice, $invoiceSource, $localResult); $invoice = $this->supportTMExtraProductOptions($invoice, $invoiceSource, $localResult); return $invoice; }
[ "public", "function", "acumulusInvoiceCreated", "(", "$", "invoice", ",", "BaseSource", "$", "invoiceSource", ",", "Result", "$", "localResult", ")", "{", "$", "invoice", "=", "$", "this", "->", "supportBundleProducts", "(", "$", "invoice", ",", "$", "invoiceS...
Filter that reacts to the acumulus_invoice_created event. @param array|null $invoice @param \Siel\Acumulus\Invoice\Source $invoiceSource @param \Siel\Acumulus\Invoice\Result $localResult @return array|null
[ "Filter", "that", "reacts", "to", "the", "acumulus_invoice_created", "event", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L115-L120
train
SIELOnline/libAcumulus
src/WooCommerce/Invoice/CreatorPluginSupport.php
CreatorPluginSupport.supportBundleProducts
protected function supportBundleProducts($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult) { /** @var \WC_Abstract_Order $shopSource */ $shopSource = $invoiceSource->getSource(); /** @var WC_Order_Item_Product[] $items */ $items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item')); foreach ($items as $item) { $bundleId = $item->get_meta('_bundle_cart_key'); $bundledBy = $item->get_meta('_bundled_by'); if (!empty($bundleId) || !empty($bundledBy)) { $line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id()); if ($line !== null) { // Add bundle meta data. if ( !empty($bundleId)) { // Bundle or bundled product. $line[Meta::BundleId] = $bundleId; } if ( !empty($bundledBy)) { // Bundled products only. $line[Meta::BundleParentId] = $bundledBy; $line[Meta::BundleVisible] = $item->get_meta('bundled_item_hidden') !== 'yes'; } } } } $invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $this->groupBundles($invoice[Tag::Customer][Tag::Invoice][Tag::Line]); return $invoice; }
php
protected function supportBundleProducts($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult) { /** @var \WC_Abstract_Order $shopSource */ $shopSource = $invoiceSource->getSource(); /** @var WC_Order_Item_Product[] $items */ $items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item')); foreach ($items as $item) { $bundleId = $item->get_meta('_bundle_cart_key'); $bundledBy = $item->get_meta('_bundled_by'); if (!empty($bundleId) || !empty($bundledBy)) { $line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id()); if ($line !== null) { // Add bundle meta data. if ( !empty($bundleId)) { // Bundle or bundled product. $line[Meta::BundleId] = $bundleId; } if ( !empty($bundledBy)) { // Bundled products only. $line[Meta::BundleParentId] = $bundledBy; $line[Meta::BundleVisible] = $item->get_meta('bundled_item_hidden') !== 'yes'; } } } } $invoice[Tag::Customer][Tag::Invoice][Tag::Line] = $this->groupBundles($invoice[Tag::Customer][Tag::Invoice][Tag::Line]); return $invoice; }
[ "protected", "function", "supportBundleProducts", "(", "$", "invoice", ",", "BaseSource", "$", "invoiceSource", ",", "/** @noinspection PhpUnusedParameterInspection */", "Result", "$", "localResult", ")", "{", "/** @var \\WC_Abstract_Order $shopSource */", "$", "shopSource", ...
Supports the "WooCommerce Bundle Products" plugin. This method supports the woocommerce-product-bundles extension that stores the bundle products as separate item lines below the bundle line and uses the meta data described below to link them to each other. This method hierarchically groups bundled products into the bundle product and can do so multi-level. Meta data on bundle lines: - bundle_cart_key (hash) unique identifier. - bundled_items (hash[]) refers to the bundle_cart_key of the bundled products. Meta data on bundled items: - bundled_by (hash) refers to bundle_cart_key of the bundle line. - bundle_cart_key (hash) unique identifier. - bundled_item_hidden: 'yes'|'no' or absent (= 'no'). 1) In a 1st pass, we first add bundle meta data to each invoice line that represents a bundle or bundled item. 2) In a 2nd pass, we group the bundled items as children into the parent line. @param array|null $invoice @param \Siel\Acumulus\Invoice\Source $invoiceSource @param \Siel\Acumulus\Invoice\Result $localResult @return array|null
[ "Supports", "the", "WooCommerce", "Bundle", "Products", "plugin", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L153-L182
train
SIELOnline/libAcumulus
src/WooCommerce/Invoice/CreatorPluginSupport.php
CreatorPluginSupport.groupBundles
protected function groupBundles(array $itemLines) { $result = array(); foreach ($itemLines as &$itemLine) { if (!empty($itemLine[Meta::BundleParentId])) { // Find the parent, note that we expect bundle products to // appear before their bundled products, so we can search in // $result and have a reference to a line in $result returned! $parent = &$this->getParentBundle($result, $itemLine[Meta::BundleParentId]); if ($parent !== null) { // Add the bundled product as a child to the bundle. $parent[Meta::ChildrenLines][] = $itemLine; } else { // Oops: not found. Store a message in the line meta data // and keep it as a separate line. $itemLine[Meta::BundleParentId] .= ': not found'; $result[] = $itemLine; } } else { // Not a bundled product: just add it to the result. $result[] = $itemLine; } } return $result; }
php
protected function groupBundles(array $itemLines) { $result = array(); foreach ($itemLines as &$itemLine) { if (!empty($itemLine[Meta::BundleParentId])) { // Find the parent, note that we expect bundle products to // appear before their bundled products, so we can search in // $result and have a reference to a line in $result returned! $parent = &$this->getParentBundle($result, $itemLine[Meta::BundleParentId]); if ($parent !== null) { // Add the bundled product as a child to the bundle. $parent[Meta::ChildrenLines][] = $itemLine; } else { // Oops: not found. Store a message in the line meta data // and keep it as a separate line. $itemLine[Meta::BundleParentId] .= ': not found'; $result[] = $itemLine; } } else { // Not a bundled product: just add it to the result. $result[] = $itemLine; } } return $result; }
[ "protected", "function", "groupBundles", "(", "array", "$", "itemLines", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "itemLines", "as", "&", "$", "itemLine", ")", "{", "if", "(", "!", "empty", "(", "$", "itemLine", "[",...
Groups bundled products into the bundle product. @param array $itemLines The set of invoice lines that may contain bundle lines and bundled lines. @return array The set of item lines but with the lines of bundled items hierarchically placed in their bundle line.
[ "Groups", "bundled", "products", "into", "the", "bundle", "product", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L206-L230
train
SIELOnline/libAcumulus
src/WooCommerce/Invoice/CreatorPluginSupport.php
CreatorPluginSupport.&
protected function &getParentBundle(array &$lines, $parentId) { foreach ($lines as &$line) { if (!empty($line[Meta::BundleId]) && $line[Meta::BundleId] === $parentId) { return $line; } elseif (!empty($line[Meta::ChildrenLines])) { // Recursively search for the parent bundle. $parent = &$this->getParentBundle($line[Meta::ChildrenLines], $parentId); if ($parent !== null) { return $parent; } } } // Not found. return null; }
php
protected function &getParentBundle(array &$lines, $parentId) { foreach ($lines as &$line) { if (!empty($line[Meta::BundleId]) && $line[Meta::BundleId] === $parentId) { return $line; } elseif (!empty($line[Meta::ChildrenLines])) { // Recursively search for the parent bundle. $parent = &$this->getParentBundle($line[Meta::ChildrenLines], $parentId); if ($parent !== null) { return $parent; } } } // Not found. return null; }
[ "protected", "function", "&", "getParentBundle", "(", "array", "&", "$", "lines", ",", "$", "parentId", ")", "{", "foreach", "(", "$", "lines", "as", "&", "$", "line", ")", "{", "if", "(", "!", "empty", "(", "$", "line", "[", "Meta", "::", "BundleI...
Searches for, and returns by reference, the parent bundle line. @param array $lines The lines to search for the parent bundle line. @param $parentId The meta-bundle-id value to search for. @return array|null The parent bundle line or null if not found.
[ "Searches", "for", "and", "returns", "by", "reference", "the", "parent", "bundle", "line", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L243-L258
train
SIELOnline/libAcumulus
src/WooCommerce/Invoice/CreatorPluginSupport.php
CreatorPluginSupport.supportTMExtraProductOptions
protected function supportTMExtraProductOptions($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult) { /** @var \WC_Abstract_Order $shopSource */ $shopSource = $invoiceSource->getSource(); /** @var WC_Order_Item_Product[] $items */ $items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item')); foreach ($items as $item) { // If the plugin is no longer used, we may still have an order with // products where the plugin was used. Moreover we don't use any // function or method from the plugin, only its stored data, so we // don'have to check for it being active, just the data being there. if (!empty($item['tmcartepo_data'])) { $line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id()); if ($line !== null) { $commonTags = array( Tag::Quantity => $line[Tag::Quantity], Meta::VatRateSource => Creator::VatRateSource_Parent, ); $result[Meta::ChildrenLines] = $this->getExtraProductOptionsLines($item, $commonTags); } } } return $invoice; }
php
protected function supportTMExtraProductOptions($invoice, BaseSource $invoiceSource, /** @noinspection PhpUnusedParameterInspection */ Result $localResult) { /** @var \WC_Abstract_Order $shopSource */ $shopSource = $invoiceSource->getSource(); /** @var WC_Order_Item_Product[] $items */ $items = $shopSource->get_items(apply_filters('woocommerce_admin_order_item_types', 'line_item')); foreach ($items as $item) { // If the plugin is no longer used, we may still have an order with // products where the plugin was used. Moreover we don't use any // function or method from the plugin, only its stored data, so we // don'have to check for it being active, just the data being there. if (!empty($item['tmcartepo_data'])) { $line = &$this->getLineByMetaId($invoice[Tag::Customer][Tag::Invoice][Tag::Line], $item->get_id()); if ($line !== null) { $commonTags = array( Tag::Quantity => $line[Tag::Quantity], Meta::VatRateSource => Creator::VatRateSource_Parent, ); $result[Meta::ChildrenLines] = $this->getExtraProductOptionsLines($item, $commonTags); } } } return $invoice; }
[ "protected", "function", "supportTMExtraProductOptions", "(", "$", "invoice", ",", "BaseSource", "$", "invoiceSource", ",", "/** @noinspection PhpUnusedParameterInspection */", "Result", "$", "localResult", ")", "{", "/** @var \\WC_Abstract_Order $shopSource */", "$", "shopSour...
Supports the "WooCommerce TM Extra Product Options" plugin. This method supports the tm-woo-extra-product-options extension that places its data in the meta data under keys that start wth tm_epo or tmcartepo. We need the the tncartepo_data value as that contains the options. This method adds the option data as children to the invoice line. @param array|null $invoice @param \Siel\Acumulus\Invoice\Source $invoiceSource @param \Siel\Acumulus\Invoice\Result $localResult @return array|null
[ "Supports", "the", "WooCommerce", "TM", "Extra", "Product", "Options", "plugin", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/WooCommerce/Invoice/CreatorPluginSupport.php#L276-L300
train
dreamfactorysoftware/df-user
src/Services/User.php
User.handlesAlternateAuth
public function handlesAlternateAuth() { if ( config('df.alternate_auth') === true && !empty(array_get($this->config, 'alt_auth_db_service_id')) && !empty(array_get($this->config, 'alt_auth_table')) && !empty(array_get($this->config, 'alt_auth_username_field')) && !empty(array_get($this->config, 'alt_auth_password_field')) && !empty(array_get($this->config, 'alt_auth_email_field')) ) { return true; } return false; }
php
public function handlesAlternateAuth() { if ( config('df.alternate_auth') === true && !empty(array_get($this->config, 'alt_auth_db_service_id')) && !empty(array_get($this->config, 'alt_auth_table')) && !empty(array_get($this->config, 'alt_auth_username_field')) && !empty(array_get($this->config, 'alt_auth_password_field')) && !empty(array_get($this->config, 'alt_auth_email_field')) ) { return true; } return false; }
[ "public", "function", "handlesAlternateAuth", "(", ")", "{", "if", "(", "config", "(", "'df.alternate_auth'", ")", "===", "true", "&&", "!", "empty", "(", "array_get", "(", "$", "this", "->", "config", ",", "'alt_auth_db_service_id'", ")", ")", "&&", "!", ...
Checks to see if the service handles alternative authentication @return bool
[ "Checks", "to", "see", "if", "the", "service", "handles", "alternative", "authentication" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Services/User.php#L120-L134
train
dreamfactorysoftware/df-user
src/Services/User.php
User.getAltAuthenticator
public function getAltAuthenticator() { if ($this->handlesAlternateAuth()) { $authenticator = new AlternateAuth( array_get($this->config, 'alt_auth_db_service_id'), array_get($this->config, 'alt_auth_table'), array_get($this->config, 'alt_auth_username_field'), array_get($this->config, 'alt_auth_password_field'), array_get($this->config, 'alt_auth_email_field') ); $authenticator->setOtherFields(array_get($this->config, 'alt_auth_other_fields')); $authenticator->setFilters(array_get($this->config, 'alt_auth_filter')); return $authenticator; } else { throw new InternalServerErrorException('No alternate authentication is configured for this service.'); } }
php
public function getAltAuthenticator() { if ($this->handlesAlternateAuth()) { $authenticator = new AlternateAuth( array_get($this->config, 'alt_auth_db_service_id'), array_get($this->config, 'alt_auth_table'), array_get($this->config, 'alt_auth_username_field'), array_get($this->config, 'alt_auth_password_field'), array_get($this->config, 'alt_auth_email_field') ); $authenticator->setOtherFields(array_get($this->config, 'alt_auth_other_fields')); $authenticator->setFilters(array_get($this->config, 'alt_auth_filter')); return $authenticator; } else { throw new InternalServerErrorException('No alternate authentication is configured for this service.'); } }
[ "public", "function", "getAltAuthenticator", "(", ")", "{", "if", "(", "$", "this", "->", "handlesAlternateAuth", "(", ")", ")", "{", "$", "authenticator", "=", "new", "AlternateAuth", "(", "array_get", "(", "$", "this", "->", "config", ",", "'alt_auth_db_se...
If the service handles alternative authentication then this method will return the alternative authenticator @return \DreamFactory\Core\User\Components\AlternateAuth @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "If", "the", "service", "handles", "alternative", "authentication", "then", "this", "method", "will", "return", "the", "alternative", "authenticator" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Services/User.php#L143-L160
train
fontis/composer-autoloader
src/app/code/community/Fontis/ComposerAutoloader/Helper/Data.php
Fontis_ComposerAutoloader_Helper_Data.getVendorDirectoryPath
public function getVendorDirectoryPath() { $path = (string) Mage::getConfig()->getNode('global/composer_autoloader/path'); if (!$path) { $path = self::DEFAULT_PATH; } $path = str_replace('/', DS, $path); $path = str_replace('{{basedir}}', Mage::getBaseDir(), $path); $path = str_replace('{{libdir}}', Mage::getBaseDir('lib'), $path); $path = rtrim($path, DS); return realpath($path); }
php
public function getVendorDirectoryPath() { $path = (string) Mage::getConfig()->getNode('global/composer_autoloader/path'); if (!$path) { $path = self::DEFAULT_PATH; } $path = str_replace('/', DS, $path); $path = str_replace('{{basedir}}', Mage::getBaseDir(), $path); $path = str_replace('{{libdir}}', Mage::getBaseDir('lib'), $path); $path = rtrim($path, DS); return realpath($path); }
[ "public", "function", "getVendorDirectoryPath", "(", ")", "{", "$", "path", "=", "(", "string", ")", "Mage", "::", "getConfig", "(", ")", "->", "getNode", "(", "'global/composer_autoloader/path'", ")", ";", "if", "(", "!", "$", "path", ")", "{", "$", "pa...
The location of the vendor directory on the machine the site is running on. It always comes without a trailing slash. @return string
[ "The", "location", "of", "the", "vendor", "directory", "on", "the", "machine", "the", "site", "is", "running", "on", ".", "It", "always", "comes", "without", "a", "trailing", "slash", "." ]
edebd4f638c3d60ce5a2329ff834c2f1048ef8be
https://github.com/fontis/composer-autoloader/blob/edebd4f638c3d60ce5a2329ff834c2f1048ef8be/src/app/code/community/Fontis/ComposerAutoloader/Helper/Data.php#L31-L43
train
ipunkt/rancherize
app/Blueprint/Infrastructure/Volume/VolumeWriter.php
VolumeWriter.clear
public function clear(FileWriter $fileWriter) { $fileWriter->put($this->path.'/docker-compose.yml', ''); $fileWriter->put($this->path.'/rancher-compose.yml', ''); }
php
public function clear(FileWriter $fileWriter) { $fileWriter->put($this->path.'/docker-compose.yml', ''); $fileWriter->put($this->path.'/rancher-compose.yml', ''); }
[ "public", "function", "clear", "(", "FileWriter", "$", "fileWriter", ")", "{", "$", "fileWriter", "->", "put", "(", "$", "this", "->", "path", ".", "'/docker-compose.yml'", ",", "''", ")", ";", "$", "fileWriter", "->", "put", "(", "$", "this", "->", "p...
Clear the written files. Necessary because the write function appends to them so if fresh files are expected they have to be cleared first @param FileWriter $fileWriter
[ "Clear", "the", "written", "files", ".", "Necessary", "because", "the", "write", "function", "appends", "to", "them", "so", "if", "fresh", "files", "are", "expected", "they", "have", "to", "be", "cleared", "first" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Blueprint/Infrastructure/Volume/VolumeWriter.php#L68-L71
train
ipunkt/rancherize
app/Services/BlueprintService.php
BlueprintService.byConfiguration
public function byConfiguration(Configuration $configuration, array $flags) : Blueprint { $blueprintName = $configuration->get('project.blueprint'); return $this->load($blueprintName, $flags); }
php
public function byConfiguration(Configuration $configuration, array $flags) : Blueprint { $blueprintName = $configuration->get('project.blueprint'); return $this->load($blueprintName, $flags); }
[ "public", "function", "byConfiguration", "(", "Configuration", "$", "configuration", ",", "array", "$", "flags", ")", ":", "Blueprint", "{", "$", "blueprintName", "=", "$", "configuration", "->", "get", "(", "'project.blueprint'", ")", ";", "return", "$", "thi...
Retrieve the blueprint that was set in the configuration @param Configuration $configuration @param array $flags @return \Rancherize\Blueprint\Blueprint
[ "Retrieve", "the", "blueprint", "that", "was", "set", "in", "the", "configuration" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/BlueprintService.php#L33-L37
train
ipunkt/rancherize
app/Services/BlueprintService.php
BlueprintService.load
public function load(string $blueprintName, array $flags) : Blueprint { $blueprint = $this->blueprintFactory->get($blueprintName); foreach($flags as $name => $value) $blueprint->setFlag($name, $value); return $blueprint; }
php
public function load(string $blueprintName, array $flags) : Blueprint { $blueprint = $this->blueprintFactory->get($blueprintName); foreach($flags as $name => $value) $blueprint->setFlag($name, $value); return $blueprint; }
[ "public", "function", "load", "(", "string", "$", "blueprintName", ",", "array", "$", "flags", ")", ":", "Blueprint", "{", "$", "blueprint", "=", "$", "this", "->", "blueprintFactory", "->", "get", "(", "$", "blueprintName", ")", ";", "foreach", "(", "$"...
Load by name @param string $blueprintName @param array $flags @return \Rancherize\Blueprint\Blueprint @internal param array $options
[ "Load", "by", "name" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Services/BlueprintService.php#L47-L54
train
SIELOnline/libAcumulus
src/Invoice/CompletorStrategy/TryAllVatRatePermutations.php
TryAllVatRatePermutations.setVatRates
protected function setVatRates($vatType, $include0) { $this->vatRates = array(); foreach ($this->possibleVatRates as $vatRate) { if ($vatRate[Tag::VatType] === $vatType) { $this->vatRates[] = $vatRate[Tag::VatRate]; } } if ($include0) { $this->vatRates[] = 0.0; } }
php
protected function setVatRates($vatType, $include0) { $this->vatRates = array(); foreach ($this->possibleVatRates as $vatRate) { if ($vatRate[Tag::VatType] === $vatType) { $this->vatRates[] = $vatRate[Tag::VatRate]; } } if ($include0) { $this->vatRates[] = 0.0; } }
[ "protected", "function", "setVatRates", "(", "$", "vatType", ",", "$", "include0", ")", "{", "$", "this", "->", "vatRates", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "possibleVatRates", "as", "$", "vatRate", ")", "{", "if", "(", ...
Initializes the array of vat rates to use for this permutation. @param float $vatType @param bool $include0
[ "Initializes", "the", "array", "of", "vat", "rates", "to", "use", "for", "this", "permutation", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategy/TryAllVatRatePermutations.php#L60-L71
train
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyLines.php
CompletorStrategyLines.completeStrategyLines
protected function completeStrategyLines() { if ($this->invoiceHasStrategyLine()) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-rates'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($this->possibleVatRates, true)); $isFirst = true; $strategies = $this->getStrategyClasses(); foreach ($strategies as $strategyClass) { /** @var CompletorStrategyBase $strategy */ $strategy = new $strategyClass($this->config, $this->translator, $this->invoice, $this->possibleVatTypes, $this->possibleVatRates, $this->source); if ($isFirst) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-2-divide'] = $strategy->getVat2Divide(); $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-breakdown'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($strategy->getVatBreakdown(), true)); $isFirst = false; } if ($strategy->apply()) { $this->replaceLinesCompleted($strategy->getLinesCompleted(), $strategy->getReplacingLines(), $strategy->getName()); if (empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed])) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] = $strategy->getDescription(); } else { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] .= '; ' . $strategy->getDescription(); } // Allow for partial solutions: a strategy may correct only some of // the strategy lines and leave the rest up to other strategies. if (!$this->invoiceHasStrategyLine()) { break; } } } } }
php
protected function completeStrategyLines() { if ($this->invoiceHasStrategyLine()) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-rates'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($this->possibleVatRates, true)); $isFirst = true; $strategies = $this->getStrategyClasses(); foreach ($strategies as $strategyClass) { /** @var CompletorStrategyBase $strategy */ $strategy = new $strategyClass($this->config, $this->translator, $this->invoice, $this->possibleVatTypes, $this->possibleVatRates, $this->source); if ($isFirst) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-2-divide'] = $strategy->getVat2Divide(); $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyInput]['vat-breakdown'] = str_replace(array('=>', ' ', "\r", "\n", "\t"), array('='), var_export($strategy->getVatBreakdown(), true)); $isFirst = false; } if ($strategy->apply()) { $this->replaceLinesCompleted($strategy->getLinesCompleted(), $strategy->getReplacingLines(), $strategy->getName()); if (empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed])) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] = $strategy->getDescription(); } else { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyUsed] .= '; ' . $strategy->getDescription(); } // Allow for partial solutions: a strategy may correct only some of // the strategy lines and leave the rest up to other strategies. if (!$this->invoiceHasStrategyLine()) { break; } } } } }
[ "protected", "function", "completeStrategyLines", "(", ")", "{", "if", "(", "$", "this", "->", "invoiceHasStrategyLine", "(", ")", ")", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", ...
Complete all lines that need a vat divide strategy to compute correct values.
[ "Complete", "all", "lines", "that", "need", "a", "vat", "divide", "strategy", "to", "compute", "correct", "values", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L89-L119
train
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyLines.php
CompletorStrategyLines.invoiceHasStrategyLine
public function invoiceHasStrategyLine() { $result = false; foreach ($this->invoiceLines as $line) { if ($line[Meta::VatRateSource] === Creator::VatRateSource_Strategy) { $result = true; break; } } return $result; }
php
public function invoiceHasStrategyLine() { $result = false; foreach ($this->invoiceLines as $line) { if ($line[Meta::VatRateSource] === Creator::VatRateSource_Strategy) { $result = true; break; } } return $result; }
[ "public", "function", "invoiceHasStrategyLine", "(", ")", "{", "$", "result", "=", "false", ";", "foreach", "(", "$", "this", "->", "invoiceLines", "as", "$", "line", ")", "{", "if", "(", "$", "line", "[", "Meta", "::", "VatRateSource", "]", "===", "Cr...
Returns whether the invoice has lines that are to be completed using a tax divide strategy. @return bool
[ "Returns", "whether", "the", "invoice", "has", "lines", "that", "are", "to", "be", "completed", "using", "a", "tax", "divide", "strategy", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L127-L137
train
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyLines.php
CompletorStrategyLines.getStrategyClasses
protected function getStrategyClasses() { $result = array(); // For now hardcoded, but this can be turned into a discovery. $namespace = '\Siel\Acumulus\Invoice\CompletorStrategy'; $result[] = "$namespace\\ApplySameVatRate"; $result[] = "$namespace\\SplitKnownDiscountLine"; $result[] = "$namespace\\SplitLine"; $result[] = "$namespace\\SplitNonMatchingLine"; $result[] = "$namespace\\TryAllVatRatePermutations"; usort($result, function($class1, $class2) { return $class1::$tryOrder - $class2::$tryOrder; }); return $result; }
php
protected function getStrategyClasses() { $result = array(); // For now hardcoded, but this can be turned into a discovery. $namespace = '\Siel\Acumulus\Invoice\CompletorStrategy'; $result[] = "$namespace\\ApplySameVatRate"; $result[] = "$namespace\\SplitKnownDiscountLine"; $result[] = "$namespace\\SplitLine"; $result[] = "$namespace\\SplitNonMatchingLine"; $result[] = "$namespace\\TryAllVatRatePermutations"; usort($result, function($class1, $class2) { return $class1::$tryOrder - $class2::$tryOrder; }); return $result; }
[ "protected", "function", "getStrategyClasses", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "// For now hardcoded, but this can be turned into a discovery.", "$", "namespace", "=", "'\\Siel\\Acumulus\\Invoice\\CompletorStrategy'", ";", "$", "result", "[", "]...
Returns a list of strategy class names. @return string[]
[ "Returns", "a", "list", "of", "strategy", "class", "names", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L144-L161
train
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyLines.php
CompletorStrategyLines.replaceLinesCompleted
protected function replaceLinesCompleted(array $linesCompleted, array $completedLines, $strategyName) { // Remove old strategy lines that are now completed. $lines = array(); foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as $key => $line) { if (!in_array($key, $linesCompleted)) { $lines[] = $line; } } // And merge in the new completed ones. foreach ($completedLines as &$completedLine) { if ($completedLine[Meta::VatRateSource] === Creator::VatRateSource_Strategy) { $completedLine[Meta::VatRateSource] = Completor::VatRateSource_Strategy_Completed; $completedLine[Meta::CompletorStrategyUsed] = $strategyName; } } $this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] = array_merge($lines, $completedLines); }
php
protected function replaceLinesCompleted(array $linesCompleted, array $completedLines, $strategyName) { // Remove old strategy lines that are now completed. $lines = array(); foreach ($this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] as $key => $line) { if (!in_array($key, $linesCompleted)) { $lines[] = $line; } } // And merge in the new completed ones. foreach ($completedLines as &$completedLine) { if ($completedLine[Meta::VatRateSource] === Creator::VatRateSource_Strategy) { $completedLine[Meta::VatRateSource] = Completor::VatRateSource_Strategy_Completed; $completedLine[Meta::CompletorStrategyUsed] = $strategyName; } } $this->invoice[Tag::Customer][Tag::Invoice][Tag::Line] = array_merge($lines, $completedLines); }
[ "protected", "function", "replaceLinesCompleted", "(", "array", "$", "linesCompleted", ",", "array", "$", "completedLines", ",", "$", "strategyName", ")", "{", "// Remove old strategy lines that are now completed.", "$", "lines", "=", "array", "(", ")", ";", "foreach"...
Replaces all completed strategy lines with the given completed lines. @param int[] $linesCompleted @param array[] $completedLines An array of completed invoice lines to replace the strategy lines with. @param string $strategyName
[ "Replaces", "all", "completed", "strategy", "lines", "with", "the", "given", "completed", "lines", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyLines.php#L171-L189
train
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", "(", ")", ";", "}"...
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
train
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...
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
train
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'", "]", ...
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
train
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"...
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
train
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",...
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
train
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", "->", "add...
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
train
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", "=", "$", "conf...
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
train
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", "(", ")",...
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
train
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",...
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
train
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", "=", "[", "]",...
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
train
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", "(", ")", ";", "$", ...
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
train
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", "=", "''", ";", "i...
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
train
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", ...
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
train
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", "=", "[", "]", ";", "i...
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
train
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", "->", "g...
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
train
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...
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
train
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", "]", "=", "$", "...
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
train
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", ...
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
train
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", ",", "$", "meth...
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
train
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", ...
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
train
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", ")", ",...
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
train
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", "("...
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
train
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", "->", "getVersi...
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
train
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", ...
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
train
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", ",", "CURL...
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
train
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", ",...
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
train
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_...
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
train
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
train
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", "=", "'st...
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
train
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", "=", "...
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
train
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", ...
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
train
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", "::", "h...
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
train
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", ...
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
train
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'", "]", "...
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
train
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", ...
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
train
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'",...
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
train
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", "(", ")", ")", "{", "...
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
train
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", "->", "g...
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
train
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", ":...
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
train
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", ...
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
train