id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,800 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.start_with | public static function start_with($string, $needle, $case_sensitive = true)
{
if(!is_string($string))
{
$string = (string)$string;
}
if(!is_string($needle))
{
$needle = (string)$needle;
}
if($case_sensitive)
{
return strpos($string, $needle) === 0;
}
else
{
return stripos($string, $needle) === 0;
}
} | php | public static function start_with($string, $needle, $case_sensitive = true)
{
if(!is_string($string))
{
$string = (string)$string;
}
if(!is_string($needle))
{
$needle = (string)$needle;
}
if($case_sensitive)
{
return strpos($string, $needle) === 0;
}
else
{
return stripos($string, $needle) === 0;
}
} | [
"public",
"static",
"function",
"start_with",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"case_sensitive",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"string",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"$",
"needle",
"=",
"(",
"string",
")",
"$",
"needle",
";",
"}",
"if",
"(",
"$",
"case_sensitive",
")",
"{",
"return",
"strpos",
"(",
"$",
"string",
",",
"$",
"needle",
")",
"===",
"0",
";",
"}",
"else",
"{",
"return",
"stripos",
"(",
"$",
"string",
",",
"$",
"needle",
")",
"===",
"0",
";",
"}",
"}"
] | Tests if a string starts with a given string
@param string
@param string
@return bool | [
"Tests",
"if",
"a",
"string",
"starts",
"with",
"a",
"given",
"string"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L18-L38 |
28,801 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.end_with | public static function end_with($string, $needle, $case_sensitive = true)
{
if(!is_string($string))
{
$string = (string)$string;
}
if(!is_string($needle))
{
$needle = (string)$needle;
}
if($case_sensitive)
{
return strrpos($string, $needle) === strlen($string) - strlen($needle);
}
else
{
return strripos($string, $needle) === strlen($string) - strlen($needle);
}
} | php | public static function end_with($string, $needle, $case_sensitive = true)
{
if(!is_string($string))
{
$string = (string)$string;
}
if(!is_string($needle))
{
$needle = (string)$needle;
}
if($case_sensitive)
{
return strrpos($string, $needle) === strlen($string) - strlen($needle);
}
else
{
return strripos($string, $needle) === strlen($string) - strlen($needle);
}
} | [
"public",
"static",
"function",
"end_with",
"(",
"$",
"string",
",",
"$",
"needle",
",",
"$",
"case_sensitive",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"string",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"needle",
")",
")",
"{",
"$",
"needle",
"=",
"(",
"string",
")",
"$",
"needle",
";",
"}",
"if",
"(",
"$",
"case_sensitive",
")",
"{",
"return",
"strrpos",
"(",
"$",
"string",
",",
"$",
"needle",
")",
"===",
"strlen",
"(",
"$",
"string",
")",
"-",
"strlen",
"(",
"$",
"needle",
")",
";",
"}",
"else",
"{",
"return",
"strripos",
"(",
"$",
"string",
",",
"$",
"needle",
")",
"===",
"strlen",
"(",
"$",
"string",
")",
"-",
"strlen",
"(",
"$",
"needle",
")",
";",
"}",
"}"
] | Tests if a string ends with the given string
@param string
@param string
@return bool | [
"Tests",
"if",
"a",
"string",
"ends",
"with",
"the",
"given",
"string"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L48-L68 |
28,802 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.get_value_between_chars | public static function get_value_between_chars($haystack, $index = 0, $opening_char = '[', $closing_char = ']')
{
$offset = 0;
$found = true;
$value = null;
for ($i = 0; $i < $index + 1; $i++)
{
$op_pos = strpos($haystack, $opening_char, $offset);
if($op_pos !== false)
{
$cl_pos = strpos($haystack, $closing_char, $op_pos + strlen($opening_char));
if($cl_pos !== false)
{
$value = substr($haystack, $op_pos + strlen($opening_char), $cl_pos - $op_pos - strlen($opening_char));
$offset = $cl_pos + strlen($closing_char);
}
else
{
$found = false;
break;
}
}
else
{
$found = false;
break;
}
}
if($found)
{
return $value;
}
else
{
return null;
}
} | php | public static function get_value_between_chars($haystack, $index = 0, $opening_char = '[', $closing_char = ']')
{
$offset = 0;
$found = true;
$value = null;
for ($i = 0; $i < $index + 1; $i++)
{
$op_pos = strpos($haystack, $opening_char, $offset);
if($op_pos !== false)
{
$cl_pos = strpos($haystack, $closing_char, $op_pos + strlen($opening_char));
if($cl_pos !== false)
{
$value = substr($haystack, $op_pos + strlen($opening_char), $cl_pos - $op_pos - strlen($opening_char));
$offset = $cl_pos + strlen($closing_char);
}
else
{
$found = false;
break;
}
}
else
{
$found = false;
break;
}
}
if($found)
{
return $value;
}
else
{
return null;
}
} | [
"public",
"static",
"function",
"get_value_between_chars",
"(",
"$",
"haystack",
",",
"$",
"index",
"=",
"0",
",",
"$",
"opening_char",
"=",
"'['",
",",
"$",
"closing_char",
"=",
"']'",
")",
"{",
"$",
"offset",
"=",
"0",
";",
"$",
"found",
"=",
"true",
";",
"$",
"value",
"=",
"null",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"index",
"+",
"1",
";",
"$",
"i",
"++",
")",
"{",
"$",
"op_pos",
"=",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"opening_char",
",",
"$",
"offset",
")",
";",
"if",
"(",
"$",
"op_pos",
"!==",
"false",
")",
"{",
"$",
"cl_pos",
"=",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"closing_char",
",",
"$",
"op_pos",
"+",
"strlen",
"(",
"$",
"opening_char",
")",
")",
";",
"if",
"(",
"$",
"cl_pos",
"!==",
"false",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"haystack",
",",
"$",
"op_pos",
"+",
"strlen",
"(",
"$",
"opening_char",
")",
",",
"$",
"cl_pos",
"-",
"$",
"op_pos",
"-",
"strlen",
"(",
"$",
"opening_char",
")",
")",
";",
"$",
"offset",
"=",
"$",
"cl_pos",
"+",
"strlen",
"(",
"$",
"closing_char",
")",
";",
"}",
"else",
"{",
"$",
"found",
"=",
"false",
";",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"found",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"found",
")",
"{",
"return",
"$",
"value",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Return the string found between two characters. If an index is given, it returns the
value at the index position
@param string $opening_char
@param string $closing_char
@param int $index 0 based index
@return string or null | [
"Return",
"the",
"string",
"found",
"between",
"two",
"characters",
".",
"If",
"an",
"index",
"is",
"given",
"it",
"returns",
"the",
"value",
"at",
"the",
"index",
"position"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L80-L119 |
28,803 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.get_random_string | public static function get_random_string($length = 10, $chars)
{
$random_string = '';
for($i = 0; $i < $length; $i++)
{
$index = rand(0, strlen($chars) - 1);
$random_string .= $chars{$index};
}
return $random_string;
} | php | public static function get_random_string($length = 10, $chars)
{
$random_string = '';
for($i = 0; $i < $length; $i++)
{
$index = rand(0, strlen($chars) - 1);
$random_string .= $chars{$index};
}
return $random_string;
} | [
"public",
"static",
"function",
"get_random_string",
"(",
"$",
"length",
"=",
"10",
",",
"$",
"chars",
")",
"{",
"$",
"random_string",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"index",
"=",
"rand",
"(",
"0",
",",
"strlen",
"(",
"$",
"chars",
")",
"-",
"1",
")",
";",
"$",
"random_string",
".=",
"$",
"chars",
"{",
"$",
"index",
"}",
";",
"}",
"return",
"$",
"random_string",
";",
"}"
] | Return a random string made of the given chars
@param number $length The length of the string to get
@param string $chars A string containing the chars that can compose the generated random string
@return string | [
"Return",
"a",
"random",
"string",
"made",
"of",
"the",
"given",
"chars"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L139-L150 |
28,804 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.ensure_start_with | public static function ensure_start_with($string, $leading_string)
{
if (StringTool :: start_with($string, $leading_string))
{
return $string;
}
else
{
return $leading_string . $string;
}
} | php | public static function ensure_start_with($string, $leading_string)
{
if (StringTool :: start_with($string, $leading_string))
{
return $string;
}
else
{
return $leading_string . $string;
}
} | [
"public",
"static",
"function",
"ensure_start_with",
"(",
"$",
"string",
",",
"$",
"leading_string",
")",
"{",
"if",
"(",
"StringTool",
"::",
"start_with",
"(",
"$",
"string",
",",
"$",
"leading_string",
")",
")",
"{",
"return",
"$",
"string",
";",
"}",
"else",
"{",
"return",
"$",
"leading_string",
".",
"$",
"string",
";",
"}",
"}"
] | Ensure a string starts with another given string
@param $string The string that must start with a leading string
@param $leading_string The string to add at the beginning of the main string if necessary
@return string | [
"Ensure",
"a",
"string",
"starts",
"with",
"another",
"given",
"string"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L159-L169 |
28,805 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.ensure_end_with | public static function ensure_end_with($string, $trailing_string)
{
if (StringTool :: end_with($string, $trailing_string))
{
return $string;
}
else
{
return $string . $trailing_string;
}
} | php | public static function ensure_end_with($string, $trailing_string)
{
if (StringTool :: end_with($string, $trailing_string))
{
return $string;
}
else
{
return $string . $trailing_string;
}
} | [
"public",
"static",
"function",
"ensure_end_with",
"(",
"$",
"string",
",",
"$",
"trailing_string",
")",
"{",
"if",
"(",
"StringTool",
"::",
"end_with",
"(",
"$",
"string",
",",
"$",
"trailing_string",
")",
")",
"{",
"return",
"$",
"string",
";",
"}",
"else",
"{",
"return",
"$",
"string",
".",
"$",
"trailing_string",
";",
"}",
"}"
] | Ensure a string ends with another given string
@param $string The string that must end with a trailing string
@param $trailing_string The string to add at the end of the main string if necessary
@return string | [
"Ensure",
"a",
"string",
"ends",
"with",
"another",
"given",
"string"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L178-L188 |
28,806 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.remove_trailing | public static function remove_trailing($string, $trailing_string)
{
if (StringTool :: end_with($string, $trailing_string))
{
return substr($string, 0, strlen($string) - strlen($trailing_string));
}
else
{
return $string;
}
} | php | public static function remove_trailing($string, $trailing_string)
{
if (StringTool :: end_with($string, $trailing_string))
{
return substr($string, 0, strlen($string) - strlen($trailing_string));
}
else
{
return $string;
}
} | [
"public",
"static",
"function",
"remove_trailing",
"(",
"$",
"string",
",",
"$",
"trailing_string",
")",
"{",
"if",
"(",
"StringTool",
"::",
"end_with",
"(",
"$",
"string",
",",
"$",
"trailing_string",
")",
")",
"{",
"return",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"strlen",
"(",
"$",
"string",
")",
"-",
"strlen",
"(",
"$",
"trailing_string",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"string",
";",
"}",
"}"
] | Remove a trailing string from a string if it exists
@param $string The string that must be shortened if it ends with a trailing string
@param $trailing_string The trailing string
@return string | [
"Remove",
"a",
"trailing",
"string",
"from",
"a",
"string",
"if",
"it",
"exists"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L197-L207 |
28,807 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.remove_leading | public static function remove_leading($string, $leading_string)
{
if (StringTool :: start_with($string, $leading_string))
{
return substr($string, strlen($leading_string));
}
else
{
return $string;
}
} | php | public static function remove_leading($string, $leading_string)
{
if (StringTool :: start_with($string, $leading_string))
{
return substr($string, strlen($leading_string));
}
else
{
return $string;
}
} | [
"public",
"static",
"function",
"remove_leading",
"(",
"$",
"string",
",",
"$",
"leading_string",
")",
"{",
"if",
"(",
"StringTool",
"::",
"start_with",
"(",
"$",
"string",
",",
"$",
"leading_string",
")",
")",
"{",
"return",
"substr",
"(",
"$",
"string",
",",
"strlen",
"(",
"$",
"leading_string",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"string",
";",
"}",
"}"
] | Remove a leading string from a string if it exists
@param string $string The string that must be shortened if it starts with a leading string
@param string $leading_string The leading string
@return string | [
"Remove",
"a",
"leading",
"string",
"from",
"a",
"string",
"if",
"it",
"exists"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L215-L225 |
28,808 | alaxos/cakephp3-libs | src/Lib/StringTool.php | StringTool.last_replace | public static function last_replace($search, $replace, $string)
{
$pos = strrpos($string, $search);
if($pos !== false)
{
return substr_replace($string, $replace, $pos, strlen($search));
}
else
{
return $string;
}
} | php | public static function last_replace($search, $replace, $string)
{
$pos = strrpos($string, $search);
if($pos !== false)
{
return substr_replace($string, $replace, $pos, strlen($search));
}
else
{
return $string;
}
} | [
"public",
"static",
"function",
"last_replace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"string",
")",
"{",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"string",
",",
"$",
"search",
")",
";",
"if",
"(",
"$",
"pos",
"!==",
"false",
")",
"{",
"return",
"substr_replace",
"(",
"$",
"string",
",",
"$",
"replace",
",",
"$",
"pos",
",",
"strlen",
"(",
"$",
"search",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"string",
";",
"}",
"}"
] | Replace the last occurence of a substring in a string
@param string $search
@param string $replace
@param string $string | [
"Replace",
"the",
"last",
"occurence",
"of",
"a",
"substring",
"in",
"a",
"string"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/StringTool.php#L296-L308 |
28,809 | smartboxgroup/integration-framework-bundle | Core/Consumers/AbstractConsumer.php | AbstractConsumer.dispatchConsumerTimingEvent | protected function dispatchConsumerTimingEvent($intervalMs, MessageInterface $message)
{
$event = new TimingEvent(TimingEvent::CONSUMER_TIMING);
$event->setIntervalMs($intervalMs);
$event->setMessage($message);
if (null !== ($dispatcher = $this->getEventDispatcher())) {
$dispatcher->dispatch(TimingEvent::CONSUMER_TIMING, $event);
}
} | php | protected function dispatchConsumerTimingEvent($intervalMs, MessageInterface $message)
{
$event = new TimingEvent(TimingEvent::CONSUMER_TIMING);
$event->setIntervalMs($intervalMs);
$event->setMessage($message);
if (null !== ($dispatcher = $this->getEventDispatcher())) {
$dispatcher->dispatch(TimingEvent::CONSUMER_TIMING, $event);
}
} | [
"protected",
"function",
"dispatchConsumerTimingEvent",
"(",
"$",
"intervalMs",
",",
"MessageInterface",
"$",
"message",
")",
"{",
"$",
"event",
"=",
"new",
"TimingEvent",
"(",
"TimingEvent",
"::",
"CONSUMER_TIMING",
")",
";",
"$",
"event",
"->",
"setIntervalMs",
"(",
"$",
"intervalMs",
")",
";",
"$",
"event",
"->",
"setMessage",
"(",
"$",
"message",
")",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"dispatcher",
"=",
"$",
"this",
"->",
"getEventDispatcher",
"(",
")",
")",
")",
"{",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"TimingEvent",
"::",
"CONSUMER_TIMING",
",",
"$",
"event",
")",
";",
"}",
"}"
] | This function dispatchs a timing event with the amount of time it took to consume a message.
@param $intervalMs int the timing interval that we would like to emanate
@param MessageInterface $message
@return mixed | [
"This",
"function",
"dispatchs",
"a",
"timing",
"event",
"with",
"the",
"amount",
"of",
"time",
"it",
"took",
"to",
"consume",
"a",
"message",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Consumers/AbstractConsumer.php#L135-L144 |
28,810 | smartboxgroup/integration-framework-bundle | Core/Consumers/AbstractConsumer.php | AbstractConsumer.logConsumeMessage | protected function logConsumeMessage()
{
if ($this->logger) {
$now = DateTimeCreator::getNowDateTime();
$this->logger->info(
'A message was consumed on {date}', [
'date' => $now->format('Y-m-d H:i:s.u'),
]
);
}
} | php | protected function logConsumeMessage()
{
if ($this->logger) {
$now = DateTimeCreator::getNowDateTime();
$this->logger->info(
'A message was consumed on {date}', [
'date' => $now->format('Y-m-d H:i:s.u'),
]
);
}
} | [
"protected",
"function",
"logConsumeMessage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"now",
"=",
"DateTimeCreator",
"::",
"getNowDateTime",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'A message was consumed on {date}'",
",",
"[",
"'date'",
"=>",
"$",
"now",
"->",
"format",
"(",
"'Y-m-d H:i:s.u'",
")",
",",
"]",
")",
";",
"}",
"}"
] | Log the moment a message was consumed. | [
"Log",
"the",
"moment",
"a",
"message",
"was",
"consumed",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Consumers/AbstractConsumer.php#L149-L160 |
28,811 | smartboxgroup/integration-framework-bundle | Components/Queues/QueueManager.php | QueueManager.connect | public function connect(bool $shuffle = true)
{
if (!$this->isConnected()) {
if (empty($this->connections)) {
throw new \InvalidArgumentException('You have to specify at least one connection.');
}
if ($shuffle) {
shuffle($this->connections);
}
$this->connection = null;
$tested = [];
foreach ($this->connections as $connection) {
try {
$connection->connect();
$this->connection = $connection;
break;
} catch (\AMQPConnectionException $e) {
$tested[] = "{$connection->getHost()}: {$e->getMessage()}";
}
}
if (!$this->connection) {
throw new \RuntimeException(sprintf('Unable to connect to any of the following hosts:%s%s', PHP_EOL, implode(PHP_EOL, $tested)));
}
//Create and declare channel
$this->channel = new \AMQPChannel($this->connection);
$this->channel->setPrefetchCount(1);
//AMQPC Exchange is the publishing mechanism
$this->exchange = new \AMQPExchange($this->channel);
}
} | php | public function connect(bool $shuffle = true)
{
if (!$this->isConnected()) {
if (empty($this->connections)) {
throw new \InvalidArgumentException('You have to specify at least one connection.');
}
if ($shuffle) {
shuffle($this->connections);
}
$this->connection = null;
$tested = [];
foreach ($this->connections as $connection) {
try {
$connection->connect();
$this->connection = $connection;
break;
} catch (\AMQPConnectionException $e) {
$tested[] = "{$connection->getHost()}: {$e->getMessage()}";
}
}
if (!$this->connection) {
throw new \RuntimeException(sprintf('Unable to connect to any of the following hosts:%s%s', PHP_EOL, implode(PHP_EOL, $tested)));
}
//Create and declare channel
$this->channel = new \AMQPChannel($this->connection);
$this->channel->setPrefetchCount(1);
//AMQPC Exchange is the publishing mechanism
$this->exchange = new \AMQPExchange($this->channel);
}
} | [
"public",
"function",
"connect",
"(",
"bool",
"$",
"shuffle",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isConnected",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"connections",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to specify at least one connection.'",
")",
";",
"}",
"if",
"(",
"$",
"shuffle",
")",
"{",
"shuffle",
"(",
"$",
"this",
"->",
"connections",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"=",
"null",
";",
"$",
"tested",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"connections",
"as",
"$",
"connection",
")",
"{",
"try",
"{",
"$",
"connection",
"->",
"connect",
"(",
")",
";",
"$",
"this",
"->",
"connection",
"=",
"$",
"connection",
";",
"break",
";",
"}",
"catch",
"(",
"\\",
"AMQPConnectionException",
"$",
"e",
")",
"{",
"$",
"tested",
"[",
"]",
"=",
"\"{$connection->getHost()}: {$e->getMessage()}\"",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to connect to any of the following hosts:%s%s'",
",",
"PHP_EOL",
",",
"implode",
"(",
"PHP_EOL",
",",
"$",
"tested",
")",
")",
")",
";",
"}",
"//Create and declare channel",
"$",
"this",
"->",
"channel",
"=",
"new",
"\\",
"AMQPChannel",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"this",
"->",
"channel",
"->",
"setPrefetchCount",
"(",
"1",
")",
";",
"//AMQPC Exchange is the publishing mechanism",
"$",
"this",
"->",
"exchange",
"=",
"new",
"\\",
"AMQPExchange",
"(",
"$",
"this",
"->",
"channel",
")",
";",
"}",
"}"
] | Opens a connection with a queuing system.
@param bool $shuffle Shuffle connections to avoid connecting to the seame endpoint everytime
@throws \AMQPException | [
"Opens",
"a",
"connection",
"with",
"a",
"queuing",
"system",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/Queues/QueueManager.php#L53-L88 |
28,812 | netgen/site-bundle | bundle/Templating/Twig/Extension/TopicUrlRuntime.php | TopicUrlRuntime.getTopicUrl | public function getTopicUrl(Tag $tag, array $parameters = [], bool $schemeRelative = false): string
{
return $this->topicUrlGenerator->generate(
$tag,
$parameters,
$schemeRelative ?
UrlGeneratorInterface::NETWORK_PATH :
UrlGeneratorInterface::ABSOLUTE_URL
);
} | php | public function getTopicUrl(Tag $tag, array $parameters = [], bool $schemeRelative = false): string
{
return $this->topicUrlGenerator->generate(
$tag,
$parameters,
$schemeRelative ?
UrlGeneratorInterface::NETWORK_PATH :
UrlGeneratorInterface::ABSOLUTE_URL
);
} | [
"public",
"function",
"getTopicUrl",
"(",
"Tag",
"$",
"tag",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"bool",
"$",
"schemeRelative",
"=",
"false",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"topicUrlGenerator",
"->",
"generate",
"(",
"$",
"tag",
",",
"$",
"parameters",
",",
"$",
"schemeRelative",
"?",
"UrlGeneratorInterface",
"::",
"NETWORK_PATH",
":",
"UrlGeneratorInterface",
"::",
"ABSOLUTE_URL",
")",
";",
"}"
] | Returns the URL for the topic specified by provided tag. | [
"Returns",
"the",
"URL",
"for",
"the",
"topic",
"specified",
"by",
"provided",
"tag",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Templating/Twig/Extension/TopicUrlRuntime.php#L40-L49 |
28,813 | IconoCoders/otp-simple-sdk | Source/SimpleIdn.php | SimpleIdn.nameData | protected function nameData($data = array())
{
return array(
"ORDER_REF" => (isset($data[0])) ? $data[0] : 'N/A',
"RESPONSE_CODE" => (isset($data[1])) ? $data[1] : 'N/A',
"RESPONSE_MSG" => (isset($data[2])) ? $data[2] : 'N/A',
"IDN_DATE" => (isset($data[3])) ? $data[3] : 'N/A',
"ORDER_HASH" => (isset($data[4])) ? $data[4] : 'N/A',
);
} | php | protected function nameData($data = array())
{
return array(
"ORDER_REF" => (isset($data[0])) ? $data[0] : 'N/A',
"RESPONSE_CODE" => (isset($data[1])) ? $data[1] : 'N/A',
"RESPONSE_MSG" => (isset($data[2])) ? $data[2] : 'N/A',
"IDN_DATE" => (isset($data[3])) ? $data[3] : 'N/A',
"ORDER_HASH" => (isset($data[4])) ? $data[4] : 'N/A',
);
} | [
"protected",
"function",
"nameData",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"return",
"array",
"(",
"\"ORDER_REF\"",
"=>",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
")",
"?",
"$",
"data",
"[",
"0",
"]",
":",
"'N/A'",
",",
"\"RESPONSE_CODE\"",
"=>",
"(",
"isset",
"(",
"$",
"data",
"[",
"1",
"]",
")",
")",
"?",
"$",
"data",
"[",
"1",
"]",
":",
"'N/A'",
",",
"\"RESPONSE_MSG\"",
"=>",
"(",
"isset",
"(",
"$",
"data",
"[",
"2",
"]",
")",
")",
"?",
"$",
"data",
"[",
"2",
"]",
":",
"'N/A'",
",",
"\"IDN_DATE\"",
"=>",
"(",
"isset",
"(",
"$",
"data",
"[",
"3",
"]",
")",
")",
"?",
"$",
"data",
"[",
"3",
"]",
":",
"'N/A'",
",",
"\"ORDER_HASH\"",
"=>",
"(",
"isset",
"(",
"$",
"data",
"[",
"4",
"]",
")",
")",
"?",
"$",
"data",
"[",
"4",
"]",
":",
"'N/A'",
",",
")",
";",
"}"
] | Creates associative array for the received data
@param array $data Processed data
@return void | [
"Creates",
"associative",
"array",
"for",
"the",
"received",
"data"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleIdn.php#L96-L105 |
28,814 | IconoCoders/otp-simple-sdk | Source/SimpleIdn.php | SimpleIdn.requestIdn | public function requestIdn($data = array())
{
if (count($data) == 0) {
$this->errorMessage[] = 'IDN DATA: EMPTY';
return $this->nameData();
}
$data['MERCHANT'] = $this->merchantId;
$this->refnoext = $data['REFNOEXT'];
unset($data['REFNOEXT']);
foreach ($this->hashFields as $fieldKey) {
$data2[$fieldKey] = $data[$fieldKey];
}
$irnHash = $this->createHashString($data2);
$data2['ORDER_HASH'] = $irnHash;
$this->idnRequest = $data2;
$this->logFunc("IDN", $this->idnRequest, $this->refnoext);
$result = $this->startRequest($this->targetUrl, $this->idnRequest, 'POST');
$this->debugMessage[] = 'IDN RESULT: ' . $result;
if (is_string($result)) {
$processed = $this->processResponse($result);
$this->logFunc("IDN", $processed, $this->refnoext);
return $processed;
}
$this->debugMessage[] = 'IDN RESULT: NOT STRING';
return false;
} | php | public function requestIdn($data = array())
{
if (count($data) == 0) {
$this->errorMessage[] = 'IDN DATA: EMPTY';
return $this->nameData();
}
$data['MERCHANT'] = $this->merchantId;
$this->refnoext = $data['REFNOEXT'];
unset($data['REFNOEXT']);
foreach ($this->hashFields as $fieldKey) {
$data2[$fieldKey] = $data[$fieldKey];
}
$irnHash = $this->createHashString($data2);
$data2['ORDER_HASH'] = $irnHash;
$this->idnRequest = $data2;
$this->logFunc("IDN", $this->idnRequest, $this->refnoext);
$result = $this->startRequest($this->targetUrl, $this->idnRequest, 'POST');
$this->debugMessage[] = 'IDN RESULT: ' . $result;
if (is_string($result)) {
$processed = $this->processResponse($result);
$this->logFunc("IDN", $processed, $this->refnoext);
return $processed;
}
$this->debugMessage[] = 'IDN RESULT: NOT STRING';
return false;
} | [
"public",
"function",
"requestIdn",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'IDN DATA: EMPTY'",
";",
"return",
"$",
"this",
"->",
"nameData",
"(",
")",
";",
"}",
"$",
"data",
"[",
"'MERCHANT'",
"]",
"=",
"$",
"this",
"->",
"merchantId",
";",
"$",
"this",
"->",
"refnoext",
"=",
"$",
"data",
"[",
"'REFNOEXT'",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"'REFNOEXT'",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"hashFields",
"as",
"$",
"fieldKey",
")",
"{",
"$",
"data2",
"[",
"$",
"fieldKey",
"]",
"=",
"$",
"data",
"[",
"$",
"fieldKey",
"]",
";",
"}",
"$",
"irnHash",
"=",
"$",
"this",
"->",
"createHashString",
"(",
"$",
"data2",
")",
";",
"$",
"data2",
"[",
"'ORDER_HASH'",
"]",
"=",
"$",
"irnHash",
";",
"$",
"this",
"->",
"idnRequest",
"=",
"$",
"data2",
";",
"$",
"this",
"->",
"logFunc",
"(",
"\"IDN\"",
",",
"$",
"this",
"->",
"idnRequest",
",",
"$",
"this",
"->",
"refnoext",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"startRequest",
"(",
"$",
"this",
"->",
"targetUrl",
",",
"$",
"this",
"->",
"idnRequest",
",",
"'POST'",
")",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IDN RESULT: '",
".",
"$",
"result",
";",
"if",
"(",
"is_string",
"(",
"$",
"result",
")",
")",
"{",
"$",
"processed",
"=",
"$",
"this",
"->",
"processResponse",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"logFunc",
"(",
"\"IDN\"",
",",
"$",
"processed",
",",
"$",
"this",
"->",
"refnoext",
")",
";",
"return",
"$",
"processed",
";",
"}",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IDN RESULT: NOT STRING'",
";",
"return",
"false",
";",
"}"
] | Sends notification via cURL
@param array $data Data array to be sent
@return array $this->nameData() Result | [
"Sends",
"notification",
"via",
"cURL"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleIdn.php#L115-L143 |
28,815 | netgen/site-bundle | bundle/Controller/UserController.php | UserController.activationForm | public function activationForm(Request $request): Response
{
$form = $this->createActivationForm();
$form->handleRequest($request);
if (!$form->isValid()) {
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate', 'ngsite'),
[
'form' => $form->createView(),
]
);
}
$users = $this->userService->loadUsersByEmail($form->get('email')->getData());
$activationRequestEvent = new UserEvents\ActivationRequestEvent(
$form->get('email')->getData(),
$users[0] ?? null
);
$this->eventDispatcher->dispatch(SiteEvents::USER_ACTIVATION_REQUEST, $activationRequestEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate_sent', 'ngsite')
);
} | php | public function activationForm(Request $request): Response
{
$form = $this->createActivationForm();
$form->handleRequest($request);
if (!$form->isValid()) {
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate', 'ngsite'),
[
'form' => $form->createView(),
]
);
}
$users = $this->userService->loadUsersByEmail($form->get('email')->getData());
$activationRequestEvent = new UserEvents\ActivationRequestEvent(
$form->get('email')->getData(),
$users[0] ?? null
);
$this->eventDispatcher->dispatch(SiteEvents::USER_ACTIVATION_REQUEST, $activationRequestEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate_sent', 'ngsite')
);
} | [
"public",
"function",
"activationForm",
"(",
"Request",
"$",
"request",
")",
":",
"Response",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createActivationForm",
"(",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.activate'",
",",
"'ngsite'",
")",
",",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
")",
";",
"}",
"$",
"users",
"=",
"$",
"this",
"->",
"userService",
"->",
"loadUsersByEmail",
"(",
"$",
"form",
"->",
"get",
"(",
"'email'",
")",
"->",
"getData",
"(",
")",
")",
";",
"$",
"activationRequestEvent",
"=",
"new",
"UserEvents",
"\\",
"ActivationRequestEvent",
"(",
"$",
"form",
"->",
"get",
"(",
"'email'",
")",
"->",
"getData",
"(",
")",
",",
"$",
"users",
"[",
"0",
"]",
"??",
"null",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"USER_ACTIVATION_REQUEST",
",",
"$",
"activationRequestEvent",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.activate_sent'",
",",
"'ngsite'",
")",
")",
";",
"}"
] | Displays and validates the form for sending an activation mail. | [
"Displays",
"and",
"validates",
"the",
"form",
"for",
"sending",
"an",
"activation",
"mail",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/UserController.php#L172-L198 |
28,816 | netgen/site-bundle | bundle/Controller/UserController.php | UserController.activate | public function activate(string $hash): Response
{
$accountKey = $this->accountKeyRepository->getByHash($hash);
if (!$accountKey instanceof EzUserAccountKey) {
throw new NotFoundHttpException();
}
if (time() - $accountKey->getTime() > $this->getConfigResolver()->getParameter('user.activate_hash_validity_time', 'ngsite')) {
$this->accountKeyRepository->removeByHash($hash);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate_done', 'ngsite'),
[
'error' => 'hash_expired',
]
);
}
try {
$user = $this->userService->loadUser($accountKey->getUserId());
} catch (NotFoundException $e) {
throw new NotFoundHttpException();
}
$userUpdateStruct = $this->userService->newUserUpdateStruct();
$userUpdateStruct->enabled = true;
$preActivateEvent = new UserEvents\PreActivateEvent($user, $userUpdateStruct);
$this->eventDispatcher->dispatch(SiteEvents::USER_PRE_ACTIVATE, $preActivateEvent);
$userUpdateStruct = $preActivateEvent->getUserUpdateStruct();
$user = $this->getRepository()->sudo(
static function (Repository $repository) use ($user, $userUpdateStruct): User {
return $repository->getUserService()->updateUser($user, $userUpdateStruct);
}
);
$postActivateEvent = new UserEvents\PostActivateEvent($user);
$this->eventDispatcher->dispatch(SiteEvents::USER_POST_ACTIVATE, $postActivateEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate_done', 'ngsite')
);
} | php | public function activate(string $hash): Response
{
$accountKey = $this->accountKeyRepository->getByHash($hash);
if (!$accountKey instanceof EzUserAccountKey) {
throw new NotFoundHttpException();
}
if (time() - $accountKey->getTime() > $this->getConfigResolver()->getParameter('user.activate_hash_validity_time', 'ngsite')) {
$this->accountKeyRepository->removeByHash($hash);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate_done', 'ngsite'),
[
'error' => 'hash_expired',
]
);
}
try {
$user = $this->userService->loadUser($accountKey->getUserId());
} catch (NotFoundException $e) {
throw new NotFoundHttpException();
}
$userUpdateStruct = $this->userService->newUserUpdateStruct();
$userUpdateStruct->enabled = true;
$preActivateEvent = new UserEvents\PreActivateEvent($user, $userUpdateStruct);
$this->eventDispatcher->dispatch(SiteEvents::USER_PRE_ACTIVATE, $preActivateEvent);
$userUpdateStruct = $preActivateEvent->getUserUpdateStruct();
$user = $this->getRepository()->sudo(
static function (Repository $repository) use ($user, $userUpdateStruct): User {
return $repository->getUserService()->updateUser($user, $userUpdateStruct);
}
);
$postActivateEvent = new UserEvents\PostActivateEvent($user);
$this->eventDispatcher->dispatch(SiteEvents::USER_POST_ACTIVATE, $postActivateEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.activate_done', 'ngsite')
);
} | [
"public",
"function",
"activate",
"(",
"string",
"$",
"hash",
")",
":",
"Response",
"{",
"$",
"accountKey",
"=",
"$",
"this",
"->",
"accountKeyRepository",
"->",
"getByHash",
"(",
"$",
"hash",
")",
";",
"if",
"(",
"!",
"$",
"accountKey",
"instanceof",
"EzUserAccountKey",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"if",
"(",
"time",
"(",
")",
"-",
"$",
"accountKey",
"->",
"getTime",
"(",
")",
">",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'user.activate_hash_validity_time'",
",",
"'ngsite'",
")",
")",
"{",
"$",
"this",
"->",
"accountKeyRepository",
"->",
"removeByHash",
"(",
"$",
"hash",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.activate_done'",
",",
"'ngsite'",
")",
",",
"[",
"'error'",
"=>",
"'hash_expired'",
",",
"]",
")",
";",
"}",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userService",
"->",
"loadUser",
"(",
"$",
"accountKey",
"->",
"getUserId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"userUpdateStruct",
"=",
"$",
"this",
"->",
"userService",
"->",
"newUserUpdateStruct",
"(",
")",
";",
"$",
"userUpdateStruct",
"->",
"enabled",
"=",
"true",
";",
"$",
"preActivateEvent",
"=",
"new",
"UserEvents",
"\\",
"PreActivateEvent",
"(",
"$",
"user",
",",
"$",
"userUpdateStruct",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"USER_PRE_ACTIVATE",
",",
"$",
"preActivateEvent",
")",
";",
"$",
"userUpdateStruct",
"=",
"$",
"preActivateEvent",
"->",
"getUserUpdateStruct",
"(",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"sudo",
"(",
"static",
"function",
"(",
"Repository",
"$",
"repository",
")",
"use",
"(",
"$",
"user",
",",
"$",
"userUpdateStruct",
")",
":",
"User",
"{",
"return",
"$",
"repository",
"->",
"getUserService",
"(",
")",
"->",
"updateUser",
"(",
"$",
"user",
",",
"$",
"userUpdateStruct",
")",
";",
"}",
")",
";",
"$",
"postActivateEvent",
"=",
"new",
"UserEvents",
"\\",
"PostActivateEvent",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"USER_POST_ACTIVATE",
",",
"$",
"postActivateEvent",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.activate_done'",
",",
"'ngsite'",
")",
")",
";",
"}"
] | Activates the user by hash key.
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If hash key does not exist | [
"Activates",
"the",
"user",
"by",
"hash",
"key",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/UserController.php#L205-L249 |
28,817 | netgen/site-bundle | bundle/Controller/UserController.php | UserController.forgotPassword | public function forgotPassword(Request $request): Response
{
$form = $this->createForgotPasswordForm();
$form->handleRequest($request);
if (!$form->isValid()) {
return $this->render(
$this->getConfigResolver()->getParameter('template.user.forgot_password', 'ngsite'),
[
'form' => $form->createView(),
]
);
}
$users = $this->userService->loadUsersByEmail($form->get('email')->getData());
$passwordResetRequestEvent = new UserEvents\PasswordResetRequestEvent(
$form->get('email')->getData(),
$users[0] ?? null
);
$this->eventDispatcher->dispatch(SiteEvents::USER_PASSWORD_RESET_REQUEST, $passwordResetRequestEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.forgot_password_sent', 'ngsite')
);
} | php | public function forgotPassword(Request $request): Response
{
$form = $this->createForgotPasswordForm();
$form->handleRequest($request);
if (!$form->isValid()) {
return $this->render(
$this->getConfigResolver()->getParameter('template.user.forgot_password', 'ngsite'),
[
'form' => $form->createView(),
]
);
}
$users = $this->userService->loadUsersByEmail($form->get('email')->getData());
$passwordResetRequestEvent = new UserEvents\PasswordResetRequestEvent(
$form->get('email')->getData(),
$users[0] ?? null
);
$this->eventDispatcher->dispatch(SiteEvents::USER_PASSWORD_RESET_REQUEST, $passwordResetRequestEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.forgot_password_sent', 'ngsite')
);
} | [
"public",
"function",
"forgotPassword",
"(",
"Request",
"$",
"request",
")",
":",
"Response",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createForgotPasswordForm",
"(",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.forgot_password'",
",",
"'ngsite'",
")",
",",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
")",
";",
"}",
"$",
"users",
"=",
"$",
"this",
"->",
"userService",
"->",
"loadUsersByEmail",
"(",
"$",
"form",
"->",
"get",
"(",
"'email'",
")",
"->",
"getData",
"(",
")",
")",
";",
"$",
"passwordResetRequestEvent",
"=",
"new",
"UserEvents",
"\\",
"PasswordResetRequestEvent",
"(",
"$",
"form",
"->",
"get",
"(",
"'email'",
")",
"->",
"getData",
"(",
")",
",",
"$",
"users",
"[",
"0",
"]",
"??",
"null",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"USER_PASSWORD_RESET_REQUEST",
",",
"$",
"passwordResetRequestEvent",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.forgot_password_sent'",
",",
"'ngsite'",
")",
")",
";",
"}"
] | Displays and validates the forgot password form. | [
"Displays",
"and",
"validates",
"the",
"forgot",
"password",
"form",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/UserController.php#L254-L280 |
28,818 | netgen/site-bundle | bundle/Controller/UserController.php | UserController.resetPassword | public function resetPassword(Request $request, string $hash): Response
{
$accountKey = $this->accountKeyRepository->getByHash($hash);
if (!$accountKey instanceof EzUserAccountKey) {
throw new NotFoundHttpException();
}
if (time() - $accountKey->getTime() > $this->getConfigResolver()->getParameter('user.forgot_password_hash_validity_time', 'ngsite')) {
$this->accountKeyRepository->removeByHash($hash);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.reset_password_done', 'ngsite'),
[
'error' => 'hash_expired',
]
);
}
try {
$user = $this->userService->loadUser($accountKey->getUserId());
} catch (NotFoundException $e) {
throw new NotFoundHttpException();
}
$form = $this->createResetPasswordForm();
$form->handleRequest($request);
if (!$form->isValid()) {
return $this->render(
$this->getConfigResolver()->getParameter('template.user.reset_password', 'ngsite'),
[
'form' => $form->createView(),
]
);
}
$data = $form->getData();
$userUpdateStruct = $this->userService->newUserUpdateStruct();
$userUpdateStruct->password = $data['password'];
$prePasswordResetEvent = new UserEvents\PrePasswordResetEvent($user, $userUpdateStruct);
$this->eventDispatcher->dispatch(SiteEvents::USER_PRE_PASSWORD_RESET, $prePasswordResetEvent);
$userUpdateStruct = $prePasswordResetEvent->getUserUpdateStruct();
$user = $this->getRepository()->sudo(
static function (Repository $repository) use ($user, $userUpdateStruct): User {
return $repository->getUserService()->updateUser($user, $userUpdateStruct);
}
);
$postPasswordResetEvent = new UserEvents\PostPasswordResetEvent($user);
$this->eventDispatcher->dispatch(SiteEvents::USER_POST_PASSWORD_RESET, $postPasswordResetEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.reset_password_done', 'ngsite')
);
} | php | public function resetPassword(Request $request, string $hash): Response
{
$accountKey = $this->accountKeyRepository->getByHash($hash);
if (!$accountKey instanceof EzUserAccountKey) {
throw new NotFoundHttpException();
}
if (time() - $accountKey->getTime() > $this->getConfigResolver()->getParameter('user.forgot_password_hash_validity_time', 'ngsite')) {
$this->accountKeyRepository->removeByHash($hash);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.reset_password_done', 'ngsite'),
[
'error' => 'hash_expired',
]
);
}
try {
$user = $this->userService->loadUser($accountKey->getUserId());
} catch (NotFoundException $e) {
throw new NotFoundHttpException();
}
$form = $this->createResetPasswordForm();
$form->handleRequest($request);
if (!$form->isValid()) {
return $this->render(
$this->getConfigResolver()->getParameter('template.user.reset_password', 'ngsite'),
[
'form' => $form->createView(),
]
);
}
$data = $form->getData();
$userUpdateStruct = $this->userService->newUserUpdateStruct();
$userUpdateStruct->password = $data['password'];
$prePasswordResetEvent = new UserEvents\PrePasswordResetEvent($user, $userUpdateStruct);
$this->eventDispatcher->dispatch(SiteEvents::USER_PRE_PASSWORD_RESET, $prePasswordResetEvent);
$userUpdateStruct = $prePasswordResetEvent->getUserUpdateStruct();
$user = $this->getRepository()->sudo(
static function (Repository $repository) use ($user, $userUpdateStruct): User {
return $repository->getUserService()->updateUser($user, $userUpdateStruct);
}
);
$postPasswordResetEvent = new UserEvents\PostPasswordResetEvent($user);
$this->eventDispatcher->dispatch(SiteEvents::USER_POST_PASSWORD_RESET, $postPasswordResetEvent);
return $this->render(
$this->getConfigResolver()->getParameter('template.user.reset_password_done', 'ngsite')
);
} | [
"public",
"function",
"resetPassword",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"hash",
")",
":",
"Response",
"{",
"$",
"accountKey",
"=",
"$",
"this",
"->",
"accountKeyRepository",
"->",
"getByHash",
"(",
"$",
"hash",
")",
";",
"if",
"(",
"!",
"$",
"accountKey",
"instanceof",
"EzUserAccountKey",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"if",
"(",
"time",
"(",
")",
"-",
"$",
"accountKey",
"->",
"getTime",
"(",
")",
">",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'user.forgot_password_hash_validity_time'",
",",
"'ngsite'",
")",
")",
"{",
"$",
"this",
"->",
"accountKeyRepository",
"->",
"removeByHash",
"(",
"$",
"hash",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.reset_password_done'",
",",
"'ngsite'",
")",
",",
"[",
"'error'",
"=>",
"'hash_expired'",
",",
"]",
")",
";",
"}",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userService",
"->",
"loadUser",
"(",
"$",
"accountKey",
"->",
"getUserId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"createResetPasswordForm",
"(",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.reset_password'",
",",
"'ngsite'",
")",
",",
"[",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"]",
")",
";",
"}",
"$",
"data",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"$",
"userUpdateStruct",
"=",
"$",
"this",
"->",
"userService",
"->",
"newUserUpdateStruct",
"(",
")",
";",
"$",
"userUpdateStruct",
"->",
"password",
"=",
"$",
"data",
"[",
"'password'",
"]",
";",
"$",
"prePasswordResetEvent",
"=",
"new",
"UserEvents",
"\\",
"PrePasswordResetEvent",
"(",
"$",
"user",
",",
"$",
"userUpdateStruct",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"USER_PRE_PASSWORD_RESET",
",",
"$",
"prePasswordResetEvent",
")",
";",
"$",
"userUpdateStruct",
"=",
"$",
"prePasswordResetEvent",
"->",
"getUserUpdateStruct",
"(",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"sudo",
"(",
"static",
"function",
"(",
"Repository",
"$",
"repository",
")",
"use",
"(",
"$",
"user",
",",
"$",
"userUpdateStruct",
")",
":",
"User",
"{",
"return",
"$",
"repository",
"->",
"getUserService",
"(",
")",
"->",
"updateUser",
"(",
"$",
"user",
",",
"$",
"userUpdateStruct",
")",
";",
"}",
")",
";",
"$",
"postPasswordResetEvent",
"=",
"new",
"UserEvents",
"\\",
"PostPasswordResetEvent",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"SiteEvents",
"::",
"USER_POST_PASSWORD_RESET",
",",
"$",
"postPasswordResetEvent",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.user.reset_password_done'",
",",
"'ngsite'",
")",
")",
";",
"}"
] | Displays and validates the reset password form.
@throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException If hash key does not exist | [
"Displays",
"and",
"validates",
"the",
"reset",
"password",
"form",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/UserController.php#L287-L345 |
28,819 | netgen/site-bundle | bundle/Controller/UserController.php | UserController.createActivationForm | protected function createActivationForm(): FormInterface
{
return $this->createFormBuilder(null, ['translation_domain' => 'ngsite_user'])
->add(
'email',
EmailType::class,
[
'constraints' => [
new Constraints\Email(),
new Constraints\NotBlank(),
],
]
)->getForm();
} | php | protected function createActivationForm(): FormInterface
{
return $this->createFormBuilder(null, ['translation_domain' => 'ngsite_user'])
->add(
'email',
EmailType::class,
[
'constraints' => [
new Constraints\Email(),
new Constraints\NotBlank(),
],
]
)->getForm();
} | [
"protected",
"function",
"createActivationForm",
"(",
")",
":",
"FormInterface",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
"null",
",",
"[",
"'translation_domain'",
"=>",
"'ngsite_user'",
"]",
")",
"->",
"add",
"(",
"'email'",
",",
"EmailType",
"::",
"class",
",",
"[",
"'constraints'",
"=>",
"[",
"new",
"Constraints",
"\\",
"Email",
"(",
")",
",",
"new",
"Constraints",
"\\",
"NotBlank",
"(",
")",
",",
"]",
",",
"]",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] | Creates activation form. | [
"Creates",
"activation",
"form",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/UserController.php#L350-L363 |
28,820 | netgen/site-bundle | bundle/Controller/UserController.php | UserController.createResetPasswordForm | protected function createResetPasswordForm(): FormInterface
{
$minLength = (int) $this->getParameter('netgen.ezforms.form.type.fieldtype.ezuser.parameters.min_password_length');
$passwordConstraints = [
new Constraints\NotBlank(),
];
if ($minLength > 0) {
$passwordConstraints[] = new Constraints\Length(
[
'min' => $minLength,
]
);
}
$passwordOptions = [
'type' => PasswordType::class,
'required' => true,
'options' => [
'constraints' => $passwordConstraints,
],
];
return $this->createFormBuilder(null, ['translation_domain' => 'ngsite_user'])
->add('password', RepeatedType::class, $passwordOptions)
->getForm();
} | php | protected function createResetPasswordForm(): FormInterface
{
$minLength = (int) $this->getParameter('netgen.ezforms.form.type.fieldtype.ezuser.parameters.min_password_length');
$passwordConstraints = [
new Constraints\NotBlank(),
];
if ($minLength > 0) {
$passwordConstraints[] = new Constraints\Length(
[
'min' => $minLength,
]
);
}
$passwordOptions = [
'type' => PasswordType::class,
'required' => true,
'options' => [
'constraints' => $passwordConstraints,
],
];
return $this->createFormBuilder(null, ['translation_domain' => 'ngsite_user'])
->add('password', RepeatedType::class, $passwordOptions)
->getForm();
} | [
"protected",
"function",
"createResetPasswordForm",
"(",
")",
":",
"FormInterface",
"{",
"$",
"minLength",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"getParameter",
"(",
"'netgen.ezforms.form.type.fieldtype.ezuser.parameters.min_password_length'",
")",
";",
"$",
"passwordConstraints",
"=",
"[",
"new",
"Constraints",
"\\",
"NotBlank",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"minLength",
">",
"0",
")",
"{",
"$",
"passwordConstraints",
"[",
"]",
"=",
"new",
"Constraints",
"\\",
"Length",
"(",
"[",
"'min'",
"=>",
"$",
"minLength",
",",
"]",
")",
";",
"}",
"$",
"passwordOptions",
"=",
"[",
"'type'",
"=>",
"PasswordType",
"::",
"class",
",",
"'required'",
"=>",
"true",
",",
"'options'",
"=>",
"[",
"'constraints'",
"=>",
"$",
"passwordConstraints",
",",
"]",
",",
"]",
";",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
"null",
",",
"[",
"'translation_domain'",
"=>",
"'ngsite_user'",
"]",
")",
"->",
"add",
"(",
"'password'",
",",
"RepeatedType",
"::",
"class",
",",
"$",
"passwordOptions",
")",
"->",
"getForm",
"(",
")",
";",
"}"
] | Creates reset password form. | [
"Creates",
"reset",
"password",
"form",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/UserController.php#L386-L413 |
28,821 | netgen/site-bundle | bundle/DependencyInjection/Compiler/LocationFactoryPass.php | LocationFactoryPass.process | public function process(ContainerBuilder $container): void
{
if (!$container->has('ngsite.menu.factory.location')) {
return;
}
$factory = $container->findDefinition('ngsite.menu.factory.location');
$extensions = [];
foreach ($container->findTaggedServiceIds('ngsite.menu.factory.location.extension') as $extension => $tags) {
foreach ($tags as $tag) {
$priority = (int) ($tag[0]['priority'] ?? 0);
$extensions[$priority][] = new Reference($extension);
}
}
krsort($extensions);
$extensions = array_merge(...$extensions);
$factory->replaceArgument(2, $extensions);
} | php | public function process(ContainerBuilder $container): void
{
if (!$container->has('ngsite.menu.factory.location')) {
return;
}
$factory = $container->findDefinition('ngsite.menu.factory.location');
$extensions = [];
foreach ($container->findTaggedServiceIds('ngsite.menu.factory.location.extension') as $extension => $tags) {
foreach ($tags as $tag) {
$priority = (int) ($tag[0]['priority'] ?? 0);
$extensions[$priority][] = new Reference($extension);
}
}
krsort($extensions);
$extensions = array_merge(...$extensions);
$factory->replaceArgument(2, $extensions);
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"'ngsite.menu.factory.location'",
")",
")",
"{",
"return",
";",
"}",
"$",
"factory",
"=",
"$",
"container",
"->",
"findDefinition",
"(",
"'ngsite.menu.factory.location'",
")",
";",
"$",
"extensions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'ngsite.menu.factory.location.extension'",
")",
"as",
"$",
"extension",
"=>",
"$",
"tags",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"tag",
")",
"{",
"$",
"priority",
"=",
"(",
"int",
")",
"(",
"$",
"tag",
"[",
"0",
"]",
"[",
"'priority'",
"]",
"??",
"0",
")",
";",
"$",
"extensions",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"new",
"Reference",
"(",
"$",
"extension",
")",
";",
"}",
"}",
"krsort",
"(",
"$",
"extensions",
")",
";",
"$",
"extensions",
"=",
"array_merge",
"(",
"...",
"$",
"extensions",
")",
";",
"$",
"factory",
"->",
"replaceArgument",
"(",
"2",
",",
"$",
"extensions",
")",
";",
"}"
] | Injects location factory extensions into the factory. | [
"Injects",
"location",
"factory",
"extensions",
"into",
"the",
"factory",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/DependencyInjection/Compiler/LocationFactoryPass.php#L16-L37 |
28,822 | cedx/coveralls.php | RoboFile.php | RoboFile.upgrade | function upgrade(): Result {
$composer = PHP_OS_FAMILY == 'Windows' ? 'php '.escapeshellarg('C:\Program Files\PHP\share\composer.phar') : 'composer';
return $this->taskExecStack()
->exec('git reset --hard')
->exec('git fetch --all --prune')
->exec('git pull --rebase')
->exec("$composer update --no-interaction")
->run();
} | php | function upgrade(): Result {
$composer = PHP_OS_FAMILY == 'Windows' ? 'php '.escapeshellarg('C:\Program Files\PHP\share\composer.phar') : 'composer';
return $this->taskExecStack()
->exec('git reset --hard')
->exec('git fetch --all --prune')
->exec('git pull --rebase')
->exec("$composer update --no-interaction")
->run();
} | [
"function",
"upgrade",
"(",
")",
":",
"Result",
"{",
"$",
"composer",
"=",
"PHP_OS_FAMILY",
"==",
"'Windows'",
"?",
"'php '",
".",
"escapeshellarg",
"(",
"'C:\\Program Files\\PHP\\share\\composer.phar'",
")",
":",
"'composer'",
";",
"return",
"$",
"this",
"->",
"taskExecStack",
"(",
")",
"->",
"exec",
"(",
"'git reset --hard'",
")",
"->",
"exec",
"(",
"'git fetch --all --prune'",
")",
"->",
"exec",
"(",
"'git pull --rebase'",
")",
"->",
"exec",
"(",
"\"$composer update --no-interaction\"",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Upgrades the project to the latest revision.
@return Result The task result. | [
"Upgrades",
"the",
"project",
"to",
"the",
"latest",
"revision",
"."
] | c196de0f92e06d5143ba90ebab18c8e384316cc0 | https://github.com/cedx/coveralls.php/blob/c196de0f92e06d5143ba90ebab18c8e384316cc0/RoboFile.php#L85-L93 |
28,823 | cedx/coveralls.php | RoboFile.php | RoboFile.watch | function watch(): Result {
$this->build();
return $this->taskWatch()
->monitor('lib', function() { $this->build(); })
->monitor('test', function() { $this->test(); })
->run();
} | php | function watch(): Result {
$this->build();
return $this->taskWatch()
->monitor('lib', function() { $this->build(); })
->monitor('test', function() { $this->test(); })
->run();
} | [
"function",
"watch",
"(",
")",
":",
"Result",
"{",
"$",
"this",
"->",
"build",
"(",
")",
";",
"return",
"$",
"this",
"->",
"taskWatch",
"(",
")",
"->",
"monitor",
"(",
"'lib'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"build",
"(",
")",
";",
"}",
")",
"->",
"monitor",
"(",
"'test'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"test",
"(",
")",
";",
"}",
")",
"->",
"run",
"(",
")",
";",
"}"
] | Watches for file changes.
@return Result The task result. | [
"Watches",
"for",
"file",
"changes",
"."
] | c196de0f92e06d5143ba90ebab18c8e384316cc0 | https://github.com/cedx/coveralls.php/blob/c196de0f92e06d5143ba90ebab18c8e384316cc0/RoboFile.php#L108-L114 |
28,824 | smartboxgroup/integration-framework-bundle | Components/Queues/Drivers/AmqpQueueDriver.php | AmqpQueueDriver.receiveNoWait | public function receiveNoWait()
{
if ($this->currentEnvelope) {
throw new \RuntimeException(
'AmqpQueueDriver: This driver has a message that was not acknowledged yet. A message must be processed and acknowledged before receiving new messages.'
);
}
$this->dequeueingTimeMs = 0;
$this->currentEnvelope = $this->queue->get();
$msg = null;
if (!$this->currentEnvelope) {
return null;
}
$start = microtime(true);
$deserializationContext = new DeserializationContext();
/** @var QueueMessageInterface $msg */
$msg = $this->getSerializer()->deserialize($this->currentEnvelope->getBody(), SerializableInterface::class, $this->format, $deserializationContext);
foreach ($this->currentEnvelope->getHeaders() as $header => $value) {
$msg->setHeader($header, $value);
}
// Calculate how long it took to deserilize the message
$this->dequeueingTimeMs = (int) ((microtime(true) - $start) * 1000);
return $msg;
} | php | public function receiveNoWait()
{
if ($this->currentEnvelope) {
throw new \RuntimeException(
'AmqpQueueDriver: This driver has a message that was not acknowledged yet. A message must be processed and acknowledged before receiving new messages.'
);
}
$this->dequeueingTimeMs = 0;
$this->currentEnvelope = $this->queue->get();
$msg = null;
if (!$this->currentEnvelope) {
return null;
}
$start = microtime(true);
$deserializationContext = new DeserializationContext();
/** @var QueueMessageInterface $msg */
$msg = $this->getSerializer()->deserialize($this->currentEnvelope->getBody(), SerializableInterface::class, $this->format, $deserializationContext);
foreach ($this->currentEnvelope->getHeaders() as $header => $value) {
$msg->setHeader($header, $value);
}
// Calculate how long it took to deserilize the message
$this->dequeueingTimeMs = (int) ((microtime(true) - $start) * 1000);
return $msg;
} | [
"public",
"function",
"receiveNoWait",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentEnvelope",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'AmqpQueueDriver: This driver has a message that was not acknowledged yet. A message must be processed and acknowledged before receiving new messages.'",
")",
";",
"}",
"$",
"this",
"->",
"dequeueingTimeMs",
"=",
"0",
";",
"$",
"this",
"->",
"currentEnvelope",
"=",
"$",
"this",
"->",
"queue",
"->",
"get",
"(",
")",
";",
"$",
"msg",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"currentEnvelope",
")",
"{",
"return",
"null",
";",
"}",
"$",
"start",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"deserializationContext",
"=",
"new",
"DeserializationContext",
"(",
")",
";",
"/** @var QueueMessageInterface $msg */",
"$",
"msg",
"=",
"$",
"this",
"->",
"getSerializer",
"(",
")",
"->",
"deserialize",
"(",
"$",
"this",
"->",
"currentEnvelope",
"->",
"getBody",
"(",
")",
",",
"SerializableInterface",
"::",
"class",
",",
"$",
"this",
"->",
"format",
",",
"$",
"deserializationContext",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"currentEnvelope",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"$",
"msg",
"->",
"setHeader",
"(",
"$",
"header",
",",
"$",
"value",
")",
";",
"}",
"// Calculate how long it took to deserilize the message",
"$",
"this",
"->",
"dequeueingTimeMs",
"=",
"(",
"int",
")",
"(",
"(",
"microtime",
"(",
"true",
")",
"-",
"$",
"start",
")",
"*",
"1000",
")",
";",
"return",
"$",
"msg",
";",
"}"
] | Returns One Serializable object from the queue.
It requires to subscribe previously to a specific queue
@throws \Exception
@return \Smartbox\Integration\FrameworkBundle\Components\Queues\QueueMessageInterface|null | [
"Returns",
"One",
"Serializable",
"object",
"from",
"the",
"queue",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/Queues/Drivers/AmqpQueueDriver.php#L223-L255 |
28,825 | netgen/site-bundle | bundle/DependencyInjection/Compiler/ImagineIOResolverPass.php | ImagineIOResolverPass.process | public function process(ContainerBuilder $container): void
{
if ($container->has('ezpublish.image_alias.imagine.cache_resolver')) {
$container
->findDefinition('ezpublish.image_alias.imagine.cache_resolver')
->setClass(IORepositoryResolver::class);
}
} | php | public function process(ContainerBuilder $container): void
{
if ($container->has('ezpublish.image_alias.imagine.cache_resolver')) {
$container
->findDefinition('ezpublish.image_alias.imagine.cache_resolver')
->setClass(IORepositoryResolver::class);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"$",
"container",
"->",
"has",
"(",
"'ezpublish.image_alias.imagine.cache_resolver'",
")",
")",
"{",
"$",
"container",
"->",
"findDefinition",
"(",
"'ezpublish.image_alias.imagine.cache_resolver'",
")",
"->",
"setClass",
"(",
"IORepositoryResolver",
"::",
"class",
")",
";",
"}",
"}"
] | Overrides the IO resolver to disable generating absolute URIs to images. | [
"Overrides",
"the",
"IO",
"resolver",
"to",
"disable",
"generating",
"absolute",
"URIs",
"to",
"images",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/DependencyInjection/Compiler/ImagineIOResolverPass.php#L16-L23 |
28,826 | netgen/site-bundle | bundle/Helper/MailHelper.php | MailHelper.sendMail | public function sendMail($receivers, string $subject, string $template, array $templateParameters = [], $sender = null): int
{
try {
$sender = $this->getSender($sender);
} catch (InvalidArgumentException $e) {
$this->logger->error($e->getMessage());
return -1;
}
$body = $this->twig->render($template, $templateParameters + $this->getDefaultTemplateParameters());
$subject = $this->translator->trans($subject, [], 'ngsite_mail');
$message = new Swift_Message();
$message
->setTo($receivers)
->setSubject($this->siteName . ': ' . $subject)
->setBody($body, 'text/html');
$message->setSender($sender);
$message->setFrom($sender);
return $this->mailer->send($message);
} | php | public function sendMail($receivers, string $subject, string $template, array $templateParameters = [], $sender = null): int
{
try {
$sender = $this->getSender($sender);
} catch (InvalidArgumentException $e) {
$this->logger->error($e->getMessage());
return -1;
}
$body = $this->twig->render($template, $templateParameters + $this->getDefaultTemplateParameters());
$subject = $this->translator->trans($subject, [], 'ngsite_mail');
$message = new Swift_Message();
$message
->setTo($receivers)
->setSubject($this->siteName . ': ' . $subject)
->setBody($body, 'text/html');
$message->setSender($sender);
$message->setFrom($sender);
return $this->mailer->send($message);
} | [
"public",
"function",
"sendMail",
"(",
"$",
"receivers",
",",
"string",
"$",
"subject",
",",
"string",
"$",
"template",
",",
"array",
"$",
"templateParameters",
"=",
"[",
"]",
",",
"$",
"sender",
"=",
"null",
")",
":",
"int",
"{",
"try",
"{",
"$",
"sender",
"=",
"$",
"this",
"->",
"getSender",
"(",
"$",
"sender",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"-",
"1",
";",
"}",
"$",
"body",
"=",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"$",
"template",
",",
"$",
"templateParameters",
"+",
"$",
"this",
"->",
"getDefaultTemplateParameters",
"(",
")",
")",
";",
"$",
"subject",
"=",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"$",
"subject",
",",
"[",
"]",
",",
"'ngsite_mail'",
")",
";",
"$",
"message",
"=",
"new",
"Swift_Message",
"(",
")",
";",
"$",
"message",
"->",
"setTo",
"(",
"$",
"receivers",
")",
"->",
"setSubject",
"(",
"$",
"this",
"->",
"siteName",
".",
"': '",
".",
"$",
"subject",
")",
"->",
"setBody",
"(",
"$",
"body",
",",
"'text/html'",
")",
";",
"$",
"message",
"->",
"setSender",
"(",
"$",
"sender",
")",
";",
"$",
"message",
"->",
"setFrom",
"(",
"$",
"sender",
")",
";",
"return",
"$",
"this",
"->",
"mailer",
"->",
"send",
"(",
"$",
"message",
")",
";",
"}"
] | Sends an mail.
Receivers can be:
a string: info@netgen.hr
or:
array( 'info@netgen.hr' => 'Netgen Site' ) or
array( 'info@netgen.hr', 'example@netgen.hr' ) or
array( 'info@netgen.hr' => 'Netgen Site', 'example@netgen.hr' => 'Example' )
Sender can be:
a string: info@netgen.hr
an array: array( 'info@netgen.hr' => 'Netgen Site' )
@param mixed $receivers
@param mixed|null $sender | [
"Sends",
"an",
"mail",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Helper/MailHelper.php#L99-L124 |
28,827 | netgen/site-bundle | bundle/Helper/MailHelper.php | MailHelper.getDefaultTemplateParameters | protected function getDefaultTemplateParameters(): array
{
if ($this->siteUrl === null) {
$this->siteUrl = $this->urlGenerator->generate(
'ez_urlalias',
[
'locationId' => $this->configResolver->getParameter('content.tree_root.location_id'),
],
UrlGeneratorInterface::ABSOLUTE_URL
);
}
if ($this->siteName === null) {
$this->siteName = trim($this->siteInfoHelper->getSiteInfoContent()->getField('site_name')->value->text);
}
return [
'site_url' => $this->siteUrl,
'site_name' => $this->siteName,
];
} | php | protected function getDefaultTemplateParameters(): array
{
if ($this->siteUrl === null) {
$this->siteUrl = $this->urlGenerator->generate(
'ez_urlalias',
[
'locationId' => $this->configResolver->getParameter('content.tree_root.location_id'),
],
UrlGeneratorInterface::ABSOLUTE_URL
);
}
if ($this->siteName === null) {
$this->siteName = trim($this->siteInfoHelper->getSiteInfoContent()->getField('site_name')->value->text);
}
return [
'site_url' => $this->siteUrl,
'site_name' => $this->siteName,
];
} | [
"protected",
"function",
"getDefaultTemplateParameters",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"siteUrl",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"siteUrl",
"=",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"'ez_urlalias'",
",",
"[",
"'locationId'",
"=>",
"$",
"this",
"->",
"configResolver",
"->",
"getParameter",
"(",
"'content.tree_root.location_id'",
")",
",",
"]",
",",
"UrlGeneratorInterface",
"::",
"ABSOLUTE_URL",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"siteName",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"siteName",
"=",
"trim",
"(",
"$",
"this",
"->",
"siteInfoHelper",
"->",
"getSiteInfoContent",
"(",
")",
"->",
"getField",
"(",
"'site_name'",
")",
"->",
"value",
"->",
"text",
")",
";",
"}",
"return",
"[",
"'site_url'",
"=>",
"$",
"this",
"->",
"siteUrl",
",",
"'site_name'",
"=>",
"$",
"this",
"->",
"siteName",
",",
"]",
";",
"}"
] | Returns an array of parameters that will be passed to every mail template. | [
"Returns",
"an",
"array",
"of",
"parameters",
"that",
"will",
"be",
"passed",
"to",
"every",
"mail",
"template",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Helper/MailHelper.php#L129-L149 |
28,828 | netgen/ngsymfonytools | classes/ngsymfonytoolsapicontentconverter.php | NgSymfonyToolsApiContentConverter.instance | public static function instance()
{
if ( self::$instance === null )
{
$serviceContainer = ezpKernel::instance()->getServiceContainer();
self::$instance = new self( $serviceContainer->get( 'ezpublish.api.repository' ) );
}
return self::$instance;
} | php | public static function instance()
{
if ( self::$instance === null )
{
$serviceContainer = ezpKernel::instance()->getServiceContainer();
self::$instance = new self( $serviceContainer->get( 'ezpublish.api.repository' ) );
}
return self::$instance;
} | [
"public",
"static",
"function",
"instance",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"instance",
"===",
"null",
")",
"{",
"$",
"serviceContainer",
"=",
"ezpKernel",
"::",
"instance",
"(",
")",
"->",
"getServiceContainer",
"(",
")",
";",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
"(",
"$",
"serviceContainer",
"->",
"get",
"(",
"'ezpublish.api.repository'",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] | Instantiates the class object
@return NgSymfonyToolsApiContentConverter | [
"Instantiates",
"the",
"class",
"object"
] | 58abf97996ddd1d4f969d8c64ce6998b9d1a5c27 | https://github.com/netgen/ngsymfonytools/blob/58abf97996ddd1d4f969d8c64ce6998b9d1a5c27/classes/ngsymfonytoolsapicontentconverter.php#L22-L31 |
28,829 | netgen/ngsymfonytools | classes/ngsymfonytoolsapicontentconverter.php | NgSymfonyToolsApiContentConverter.convert | public function convert( $object )
{
if ( $object instanceof eZContentObject )
{
return $this->repository->getContentService()->loadContent( $object->attribute( 'id' ) );
}
else if ( $object instanceof eZContentObjectTreeNode )
{
return $this->repository->getLocationService()->loadLocation( $object->attribute( 'node_id' ) );
}
return $object;
} | php | public function convert( $object )
{
if ( $object instanceof eZContentObject )
{
return $this->repository->getContentService()->loadContent( $object->attribute( 'id' ) );
}
else if ( $object instanceof eZContentObjectTreeNode )
{
return $this->repository->getLocationService()->loadLocation( $object->attribute( 'node_id' ) );
}
return $object;
} | [
"public",
"function",
"convert",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"eZContentObject",
")",
"{",
"return",
"$",
"this",
"->",
"repository",
"->",
"getContentService",
"(",
")",
"->",
"loadContent",
"(",
"$",
"object",
"->",
"attribute",
"(",
"'id'",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"object",
"instanceof",
"eZContentObjectTreeNode",
")",
"{",
"return",
"$",
"this",
"->",
"repository",
"->",
"getLocationService",
"(",
")",
"->",
"loadLocation",
"(",
"$",
"object",
"->",
"attribute",
"(",
"'node_id'",
")",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | Converts eZ Publish legacy objects and nodes to content and locations
@param mixed $object
@return mixed | [
"Converts",
"eZ",
"Publish",
"legacy",
"objects",
"and",
"nodes",
"to",
"content",
"and",
"locations"
] | 58abf97996ddd1d4f969d8c64ce6998b9d1a5c27 | https://github.com/netgen/ngsymfonytools/blob/58abf97996ddd1d4f969d8c64ce6998b9d1a5c27/classes/ngsymfonytoolsapicontentconverter.php#L59-L71 |
28,830 | netgen/site-bundle | bundle/DependencyInjection/Compiler/RelationListFieldTypePass.php | RelationListFieldTypePass.process | public function process(ContainerBuilder $container): void
{
if ($container->has('ezpublish.fieldType.ezobjectrelationlist')) {
$container
->findDefinition('ezpublish.fieldType.ezobjectrelationlist')
->setClass(Type::class);
}
if ($container->has('ezpublish.fieldType.ezobjectrelationlist.converter')) {
$container
->findDefinition('ezpublish.fieldType.ezobjectrelationlist.converter')
->setClass(RelationListConverter::class);
}
} | php | public function process(ContainerBuilder $container): void
{
if ($container->has('ezpublish.fieldType.ezobjectrelationlist')) {
$container
->findDefinition('ezpublish.fieldType.ezobjectrelationlist')
->setClass(Type::class);
}
if ($container->has('ezpublish.fieldType.ezobjectrelationlist.converter')) {
$container
->findDefinition('ezpublish.fieldType.ezobjectrelationlist.converter')
->setClass(RelationListConverter::class);
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"$",
"container",
"->",
"has",
"(",
"'ezpublish.fieldType.ezobjectrelationlist'",
")",
")",
"{",
"$",
"container",
"->",
"findDefinition",
"(",
"'ezpublish.fieldType.ezobjectrelationlist'",
")",
"->",
"setClass",
"(",
"Type",
"::",
"class",
")",
";",
"}",
"if",
"(",
"$",
"container",
"->",
"has",
"(",
"'ezpublish.fieldType.ezobjectrelationlist.converter'",
")",
")",
"{",
"$",
"container",
"->",
"findDefinition",
"(",
"'ezpublish.fieldType.ezobjectrelationlist.converter'",
")",
"->",
"setClass",
"(",
"RelationListConverter",
"::",
"class",
")",
";",
"}",
"}"
] | Overrides ezrelationlist field type with own implementations. | [
"Overrides",
"ezrelationlist",
"field",
"type",
"with",
"own",
"implementations",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/DependencyInjection/Compiler/RelationListFieldTypePass.php#L17-L30 |
28,831 | spiral/router | src/Traits/VerbsTrait.php | VerbsTrait.withVerbs | public function withVerbs(string ...$verbs): RouteInterface
{
foreach ($verbs as &$verb) {
$verb = strtoupper($verb);
if (!in_array($verb, RouteInterface::VERBS)) {
throw new RouteException("Invalid HTTP verb `{$verb}`.");
}
unset($verb);
}
$route = clone $this;
$route->verbs = $verbs;
return $route;
} | php | public function withVerbs(string ...$verbs): RouteInterface
{
foreach ($verbs as &$verb) {
$verb = strtoupper($verb);
if (!in_array($verb, RouteInterface::VERBS)) {
throw new RouteException("Invalid HTTP verb `{$verb}`.");
}
unset($verb);
}
$route = clone $this;
$route->verbs = $verbs;
return $route;
} | [
"public",
"function",
"withVerbs",
"(",
"string",
"...",
"$",
"verbs",
")",
":",
"RouteInterface",
"{",
"foreach",
"(",
"$",
"verbs",
"as",
"&",
"$",
"verb",
")",
"{",
"$",
"verb",
"=",
"strtoupper",
"(",
"$",
"verb",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"verb",
",",
"RouteInterface",
"::",
"VERBS",
")",
")",
"{",
"throw",
"new",
"RouteException",
"(",
"\"Invalid HTTP verb `{$verb}`.\"",
")",
";",
"}",
"unset",
"(",
"$",
"verb",
")",
";",
"}",
"$",
"route",
"=",
"clone",
"$",
"this",
";",
"$",
"route",
"->",
"verbs",
"=",
"$",
"verbs",
";",
"return",
"$",
"route",
";",
"}"
] | Attach specific list of HTTP verbs to the route.
@param string ...$verbs
@return RouteInterface|$this
@throws RouteException | [
"Attach",
"specific",
"list",
"of",
"HTTP",
"verbs",
"to",
"the",
"route",
"."
] | 35721d06231d5650402eb93ac7f3ade00cd1b640 | https://github.com/spiral/router/blob/35721d06231d5650402eb93ac7f3ade00cd1b640/src/Traits/VerbsTrait.php#L29-L44 |
28,832 | Prezent/prezent-crud-bundle | src/Controller/CrudController.php | CrudController.editAction | public function editAction(Request $request, $id)
{
$configuration = $this->getConfiguration($request);
$dispatcher = $configuration->getEventDispatcher();
$om = $this->getObjectManager();
if (!$configuration->getFormType()) {
throw new \RuntimeException('You must set the formType on the CRUD configuration');
}
$object = $this->findObject($request, $id);
$form = $this->createForm($configuration->getFormType(), $object, $configuration->getFormOptions());
$event = new PreSubmitEvent($configuration, $request, $object, $form);
$dispatcher->dispatch(CrudEvents::PRE_SUBMIT, $event);
if ($event->hasResponse()) {
return $event->getResponse();
}
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->isValid()) {
$om->persist($object);
$event = new PreFlushEvent($configuration, $request, $object);
$dispatcher->dispatch(CrudEvents::PRE_FLUSH, $event);
if ($event->hasResponse()) {
return $event->getResponse();
}
$event = new PostFlushEvent($configuration, $request, $object);
try {
$om->flush();
$this->addFlash('success', sprintf('flash.%s.edit.success', $configuration->getName()));
} catch (\Exception $e) {
$event->setException($e);
$this->addFlash('error', sprintf('flash.%s.edit.error', $configuration->getName()));
}
$dispatcher->dispatch(CrudEvents::POST_FLUSH, $event);
if ($event->hasResponse()) {
return $event->getResponse();
}
return $this->redirectToRoute(
$configuration->getRoutePrefix() . 'index',
$configuration->getRouteParameters()
);
} else {
$event = new ValidationFailedEvent($configuration, $request, $object, $form);
$dispatcher->dispatch(CrudEvents::VALIDATION_FAILED, $event);
if ($event->hasResponse()) {
return $response;
}
}
}
return $this->render($this->getTemplate($request, 'edit'), array_merge([
'base_template' => $this->getTemplate($request, 'base'),
'config' => $configuration,
'form' => $form->createView(),
'object' => $object,
], $configuration->getTemplateVariables()));
} | php | public function editAction(Request $request, $id)
{
$configuration = $this->getConfiguration($request);
$dispatcher = $configuration->getEventDispatcher();
$om = $this->getObjectManager();
if (!$configuration->getFormType()) {
throw new \RuntimeException('You must set the formType on the CRUD configuration');
}
$object = $this->findObject($request, $id);
$form = $this->createForm($configuration->getFormType(), $object, $configuration->getFormOptions());
$event = new PreSubmitEvent($configuration, $request, $object, $form);
$dispatcher->dispatch(CrudEvents::PRE_SUBMIT, $event);
if ($event->hasResponse()) {
return $event->getResponse();
}
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->isValid()) {
$om->persist($object);
$event = new PreFlushEvent($configuration, $request, $object);
$dispatcher->dispatch(CrudEvents::PRE_FLUSH, $event);
if ($event->hasResponse()) {
return $event->getResponse();
}
$event = new PostFlushEvent($configuration, $request, $object);
try {
$om->flush();
$this->addFlash('success', sprintf('flash.%s.edit.success', $configuration->getName()));
} catch (\Exception $e) {
$event->setException($e);
$this->addFlash('error', sprintf('flash.%s.edit.error', $configuration->getName()));
}
$dispatcher->dispatch(CrudEvents::POST_FLUSH, $event);
if ($event->hasResponse()) {
return $event->getResponse();
}
return $this->redirectToRoute(
$configuration->getRoutePrefix() . 'index',
$configuration->getRouteParameters()
);
} else {
$event = new ValidationFailedEvent($configuration, $request, $object, $form);
$dispatcher->dispatch(CrudEvents::VALIDATION_FAILED, $event);
if ($event->hasResponse()) {
return $response;
}
}
}
return $this->render($this->getTemplate($request, 'edit'), array_merge([
'base_template' => $this->getTemplate($request, 'base'),
'config' => $configuration,
'form' => $form->createView(),
'object' => $object,
], $configuration->getTemplateVariables()));
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"configuration",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
"$",
"request",
")",
";",
"$",
"dispatcher",
"=",
"$",
"configuration",
"->",
"getEventDispatcher",
"(",
")",
";",
"$",
"om",
"=",
"$",
"this",
"->",
"getObjectManager",
"(",
")",
";",
"if",
"(",
"!",
"$",
"configuration",
"->",
"getFormType",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'You must set the formType on the CRUD configuration'",
")",
";",
"}",
"$",
"object",
"=",
"$",
"this",
"->",
"findObject",
"(",
"$",
"request",
",",
"$",
"id",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"configuration",
"->",
"getFormType",
"(",
")",
",",
"$",
"object",
",",
"$",
"configuration",
"->",
"getFormOptions",
"(",
")",
")",
";",
"$",
"event",
"=",
"new",
"PreSubmitEvent",
"(",
"$",
"configuration",
",",
"$",
"request",
",",
"$",
"object",
",",
"$",
"form",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"CrudEvents",
"::",
"PRE_SUBMIT",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"hasResponse",
"(",
")",
")",
"{",
"return",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"}",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isSubmitted",
"(",
")",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"om",
"->",
"persist",
"(",
"$",
"object",
")",
";",
"$",
"event",
"=",
"new",
"PreFlushEvent",
"(",
"$",
"configuration",
",",
"$",
"request",
",",
"$",
"object",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"CrudEvents",
"::",
"PRE_FLUSH",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"hasResponse",
"(",
")",
")",
"{",
"return",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"}",
"$",
"event",
"=",
"new",
"PostFlushEvent",
"(",
"$",
"configuration",
",",
"$",
"request",
",",
"$",
"object",
")",
";",
"try",
"{",
"$",
"om",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"addFlash",
"(",
"'success'",
",",
"sprintf",
"(",
"'flash.%s.edit.success'",
",",
"$",
"configuration",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"event",
"->",
"setException",
"(",
"$",
"e",
")",
";",
"$",
"this",
"->",
"addFlash",
"(",
"'error'",
",",
"sprintf",
"(",
"'flash.%s.edit.error'",
",",
"$",
"configuration",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"CrudEvents",
"::",
"POST_FLUSH",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"hasResponse",
"(",
")",
")",
"{",
"return",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"$",
"configuration",
"->",
"getRoutePrefix",
"(",
")",
".",
"'index'",
",",
"$",
"configuration",
"->",
"getRouteParameters",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"event",
"=",
"new",
"ValidationFailedEvent",
"(",
"$",
"configuration",
",",
"$",
"request",
",",
"$",
"object",
",",
"$",
"form",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"CrudEvents",
"::",
"VALIDATION_FAILED",
",",
"$",
"event",
")",
";",
"if",
"(",
"$",
"event",
"->",
"hasResponse",
"(",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"request",
",",
"'edit'",
")",
",",
"array_merge",
"(",
"[",
"'base_template'",
"=>",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"request",
",",
"'base'",
")",
",",
"'config'",
"=>",
"$",
"configuration",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'object'",
"=>",
"$",
"object",
",",
"]",
",",
"$",
"configuration",
"->",
"getTemplateVariables",
"(",
")",
")",
")",
";",
"}"
] | Edit an object
@Route("/edit/{id}")
@param Request $request
@param $id
@return RedirectResponse|Response | [
"Edit",
"an",
"object"
] | bb8bcf92cecc2acae08b8a672876b4972175ca24 | https://github.com/Prezent/prezent-crud-bundle/blob/bb8bcf92cecc2acae08b8a672876b4972175ca24/src/Controller/CrudController.php#L175-L244 |
28,833 | Prezent/prezent-crud-bundle | src/Controller/CrudController.php | CrudController.findObject | protected function findObject(Request $request, $id)
{
$configuration = $this->getConfiguration($request);
if (!($object = $this->getRepository()->find($id))) {
throw $this->createNotFoundException(
sprintf('Object %s(%s) not found', $configuration->getEntityClass(), $id)
);
}
return $object;
} | php | protected function findObject(Request $request, $id)
{
$configuration = $this->getConfiguration($request);
if (!($object = $this->getRepository()->find($id))) {
throw $this->createNotFoundException(
sprintf('Object %s(%s) not found', $configuration->getEntityClass(), $id)
);
}
return $object;
} | [
"protected",
"function",
"findObject",
"(",
"Request",
"$",
"request",
",",
"$",
"id",
")",
"{",
"$",
"configuration",
"=",
"$",
"this",
"->",
"getConfiguration",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"(",
"$",
"object",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"id",
")",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"sprintf",
"(",
"'Object %s(%s) not found'",
",",
"$",
"configuration",
"->",
"getEntityClass",
"(",
")",
",",
"$",
"id",
")",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | Find an object by ID
@param mixed $id
@return object
@throws NotFoundHttpException | [
"Find",
"an",
"object",
"by",
"ID"
] | bb8bcf92cecc2acae08b8a672876b4972175ca24 | https://github.com/Prezent/prezent-crud-bundle/blob/bb8bcf92cecc2acae08b8a672876b4972175ca24/src/Controller/CrudController.php#L340-L351 |
28,834 | Prezent/prezent-crud-bundle | src/Controller/CrudController.php | CrudController.getTemplate | protected function getTemplate(Request $request, $action)
{
$templates = $this->get('prezent_crud.template_guesser')->guessTemplateNames([$this, $action], $request);
foreach ($templates as $template) {
if ($this->get('twig')->getLoader()->exists($template)) {
return $template;
}
}
return array_shift($templates); // This ensures a proper error message about a missing template
} | php | protected function getTemplate(Request $request, $action)
{
$templates = $this->get('prezent_crud.template_guesser')->guessTemplateNames([$this, $action], $request);
foreach ($templates as $template) {
if ($this->get('twig')->getLoader()->exists($template)) {
return $template;
}
}
return array_shift($templates); // This ensures a proper error message about a missing template
} | [
"protected",
"function",
"getTemplate",
"(",
"Request",
"$",
"request",
",",
"$",
"action",
")",
"{",
"$",
"templates",
"=",
"$",
"this",
"->",
"get",
"(",
"'prezent_crud.template_guesser'",
")",
"->",
"guessTemplateNames",
"(",
"[",
"$",
"this",
",",
"$",
"action",
"]",
",",
"$",
"request",
")",
";",
"foreach",
"(",
"$",
"templates",
"as",
"$",
"template",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'twig'",
")",
"->",
"getLoader",
"(",
")",
"->",
"exists",
"(",
"$",
"template",
")",
")",
"{",
"return",
"$",
"template",
";",
"}",
"}",
"return",
"array_shift",
"(",
"$",
"templates",
")",
";",
"// This ensures a proper error message about a missing template",
"}"
] | Get the template for an action
@param Request $request
@param string $action
@return string | [
"Get",
"the",
"template",
"for",
"an",
"action"
] | bb8bcf92cecc2acae08b8a672876b4972175ca24 | https://github.com/Prezent/prezent-crud-bundle/blob/bb8bcf92cecc2acae08b8a672876b4972175ca24/src/Controller/CrudController.php#L371-L382 |
28,835 | smartboxgroup/integration-framework-bundle | Components/DB/DBConfigurableConsumer.php | DBConfigurableConsumer.readMessage | protected function readMessage(EndpointInterface $endpoint)
{
$options = $endpoint->getOptions();
$method = $options[NoSQLConfigurableProtocol::OPTION_METHOD];
$config = $this->methodsConfiguration[$method];
$steps = $config[ConfigurableConsumerInterface::CONFIG_QUERY_STEPS];
$context = $this->getConfHelper()->createContext($options);
try {
$this->configurableStepsProvider->executeSteps($steps, $options, $context);
$result = $this->getConfHelper()->resolve(
$config[ConfigurableConsumerInterface::CONFIG_QUERY_RESULT],
$context
);
} catch (NoResultsException $exception) {
$result = null;
if ($options[ConfigurableDbalProtocol::OPTION_STOP_ON_NO_RESULTS]) {
$this->stop();
}
}
if (null == $result) {
return null;
} elseif (is_array($result)) {
$result = new SerializableArray($result);
}
$context = new Context([
Context::FLOWS_VERSION => $this->getFlowsVersion(),
Context::TRANSACTION_ID => uniqid('', true),
Context::ORIGINAL_FROM => $endpoint->getURI(),
]);
return $this->smartesbHelper->getMessageFactory()->createMessage($result, [], $context);
} | php | protected function readMessage(EndpointInterface $endpoint)
{
$options = $endpoint->getOptions();
$method = $options[NoSQLConfigurableProtocol::OPTION_METHOD];
$config = $this->methodsConfiguration[$method];
$steps = $config[ConfigurableConsumerInterface::CONFIG_QUERY_STEPS];
$context = $this->getConfHelper()->createContext($options);
try {
$this->configurableStepsProvider->executeSteps($steps, $options, $context);
$result = $this->getConfHelper()->resolve(
$config[ConfigurableConsumerInterface::CONFIG_QUERY_RESULT],
$context
);
} catch (NoResultsException $exception) {
$result = null;
if ($options[ConfigurableDbalProtocol::OPTION_STOP_ON_NO_RESULTS]) {
$this->stop();
}
}
if (null == $result) {
return null;
} elseif (is_array($result)) {
$result = new SerializableArray($result);
}
$context = new Context([
Context::FLOWS_VERSION => $this->getFlowsVersion(),
Context::TRANSACTION_ID => uniqid('', true),
Context::ORIGINAL_FROM => $endpoint->getURI(),
]);
return $this->smartesbHelper->getMessageFactory()->createMessage($result, [], $context);
} | [
"protected",
"function",
"readMessage",
"(",
"EndpointInterface",
"$",
"endpoint",
")",
"{",
"$",
"options",
"=",
"$",
"endpoint",
"->",
"getOptions",
"(",
")",
";",
"$",
"method",
"=",
"$",
"options",
"[",
"NoSQLConfigurableProtocol",
"::",
"OPTION_METHOD",
"]",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"methodsConfiguration",
"[",
"$",
"method",
"]",
";",
"$",
"steps",
"=",
"$",
"config",
"[",
"ConfigurableConsumerInterface",
"::",
"CONFIG_QUERY_STEPS",
"]",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"getConfHelper",
"(",
")",
"->",
"createContext",
"(",
"$",
"options",
")",
";",
"try",
"{",
"$",
"this",
"->",
"configurableStepsProvider",
"->",
"executeSteps",
"(",
"$",
"steps",
",",
"$",
"options",
",",
"$",
"context",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"getConfHelper",
"(",
")",
"->",
"resolve",
"(",
"$",
"config",
"[",
"ConfigurableConsumerInterface",
"::",
"CONFIG_QUERY_RESULT",
"]",
",",
"$",
"context",
")",
";",
"}",
"catch",
"(",
"NoResultsException",
"$",
"exception",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"options",
"[",
"ConfigurableDbalProtocol",
"::",
"OPTION_STOP_ON_NO_RESULTS",
"]",
")",
"{",
"$",
"this",
"->",
"stop",
"(",
")",
";",
"}",
"}",
"if",
"(",
"null",
"==",
"$",
"result",
")",
"{",
"return",
"null",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"result",
")",
")",
"{",
"$",
"result",
"=",
"new",
"SerializableArray",
"(",
"$",
"result",
")",
";",
"}",
"$",
"context",
"=",
"new",
"Context",
"(",
"[",
"Context",
"::",
"FLOWS_VERSION",
"=>",
"$",
"this",
"->",
"getFlowsVersion",
"(",
")",
",",
"Context",
"::",
"TRANSACTION_ID",
"=>",
"uniqid",
"(",
"''",
",",
"true",
")",
",",
"Context",
"::",
"ORIGINAL_FROM",
"=>",
"$",
"endpoint",
"->",
"getURI",
"(",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"smartesbHelper",
"->",
"getMessageFactory",
"(",
")",
"->",
"createMessage",
"(",
"$",
"result",
",",
"[",
"]",
",",
"$",
"context",
")",
";",
"}"
] | Reads a message from the NoSQL database executing the configured steps.
@param EndpointInterface $endpoint
@return \Smartbox\Integration\FrameworkBundle\Core\Messages\Message | [
"Reads",
"a",
"message",
"from",
"the",
"NoSQL",
"database",
"executing",
"the",
"configured",
"steps",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/DB/DBConfigurableConsumer.php#L53-L89 |
28,836 | smartboxgroup/integration-framework-bundle | Components/DB/DBConfigurableConsumer.php | DBConfigurableConsumer.onConsume | protected function onConsume(EndpointInterface $endpoint, MessageInterface $message)
{
$options = $endpoint->getOptions();
$method = $options[NoSQLConfigurableProtocol::OPTION_METHOD];
$config = $this->methodsConfiguration[$method];
$steps = $config[ConfigurableConsumerInterface::CONFIG_ON_CONSUME];
$context = $this->getConfHelper()->createContext($options, $message);
$this->configurableStepsProvider->executeSteps($steps, $options, $context);
} | php | protected function onConsume(EndpointInterface $endpoint, MessageInterface $message)
{
$options = $endpoint->getOptions();
$method = $options[NoSQLConfigurableProtocol::OPTION_METHOD];
$config = $this->methodsConfiguration[$method];
$steps = $config[ConfigurableConsumerInterface::CONFIG_ON_CONSUME];
$context = $this->getConfHelper()->createContext($options, $message);
$this->configurableStepsProvider->executeSteps($steps, $options, $context);
} | [
"protected",
"function",
"onConsume",
"(",
"EndpointInterface",
"$",
"endpoint",
",",
"MessageInterface",
"$",
"message",
")",
"{",
"$",
"options",
"=",
"$",
"endpoint",
"->",
"getOptions",
"(",
")",
";",
"$",
"method",
"=",
"$",
"options",
"[",
"NoSQLConfigurableProtocol",
"::",
"OPTION_METHOD",
"]",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"methodsConfiguration",
"[",
"$",
"method",
"]",
";",
"$",
"steps",
"=",
"$",
"config",
"[",
"ConfigurableConsumerInterface",
"::",
"CONFIG_ON_CONSUME",
"]",
";",
"$",
"context",
"=",
"$",
"this",
"->",
"getConfHelper",
"(",
")",
"->",
"createContext",
"(",
"$",
"options",
",",
"$",
"message",
")",
";",
"$",
"this",
"->",
"configurableStepsProvider",
"->",
"executeSteps",
"(",
"$",
"steps",
",",
"$",
"options",
",",
"$",
"context",
")",
";",
"}"
] | Executes the necessary actions after the message has been consumed.
@param EndpointInterface $endpoint
@param MessageInterface $message | [
"Executes",
"the",
"necessary",
"actions",
"after",
"the",
"message",
"has",
"been",
"consumed",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/DB/DBConfigurableConsumer.php#L97-L107 |
28,837 | smartboxgroup/integration-framework-bundle | Tools/Evaluator/CustomExpressionLanguageProvider.php | CustomExpressionLanguageProvider.createNumberFormat | protected function createNumberFormat()
{
return new ExpressionFunction(
'numberFormat',
function ($number, $decimals = 0, $dec_point = '.', $thousands_sep = ',') {
return sprintf('( %1$s !== null ? number_format(%1$s, %2$s, %3$s, %4$s)) : null', $number, $decimals, $dec_point, $thousands_sep);
},
function ($arguments, $number, $decimals = 0, $dec_point = '.', $thousands_sep = ',') {
if (null === $number) {
return null;
}
return number_format($number, $decimals, $dec_point, $thousands_sep);
}
);
} | php | protected function createNumberFormat()
{
return new ExpressionFunction(
'numberFormat',
function ($number, $decimals = 0, $dec_point = '.', $thousands_sep = ',') {
return sprintf('( %1$s !== null ? number_format(%1$s, %2$s, %3$s, %4$s)) : null', $number, $decimals, $dec_point, $thousands_sep);
},
function ($arguments, $number, $decimals = 0, $dec_point = '.', $thousands_sep = ',') {
if (null === $number) {
return null;
}
return number_format($number, $decimals, $dec_point, $thousands_sep);
}
);
} | [
"protected",
"function",
"createNumberFormat",
"(",
")",
"{",
"return",
"new",
"ExpressionFunction",
"(",
"'numberFormat'",
",",
"function",
"(",
"$",
"number",
",",
"$",
"decimals",
"=",
"0",
",",
"$",
"dec_point",
"=",
"'.'",
",",
"$",
"thousands_sep",
"=",
"','",
")",
"{",
"return",
"sprintf",
"(",
"'( %1$s !== null ? number_format(%1$s, %2$s, %3$s, %4$s)) : null'",
",",
"$",
"number",
",",
"$",
"decimals",
",",
"$",
"dec_point",
",",
"$",
"thousands_sep",
")",
";",
"}",
",",
"function",
"(",
"$",
"arguments",
",",
"$",
"number",
",",
"$",
"decimals",
"=",
"0",
",",
"$",
"dec_point",
"=",
"'.'",
",",
"$",
"thousands_sep",
"=",
"','",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"number",
")",
"{",
"return",
"null",
";",
"}",
"return",
"number_format",
"(",
"$",
"number",
",",
"$",
"decimals",
",",
"$",
"dec_point",
",",
"$",
"thousands_sep",
")",
";",
"}",
")",
";",
"}"
] | Exposes php number_format.
string numberFormat ( float $number , int $decimals = 0 , string $dec_point = "." , string $thousands_sep = "," )
returns null if null passed
@return ExpressionFunction | [
"Exposes",
"php",
"number_format",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Tools/Evaluator/CustomExpressionLanguageProvider.php#L179-L194 |
28,838 | smartboxgroup/integration-framework-bundle | Tools/Evaluator/CustomExpressionLanguageProvider.php | CustomExpressionLanguageProvider.createSliceFunction | protected function createSliceFunction()
{
return new ExpressionFunction(
'slice',
function ($array, $start, $length = null, $preserveKeys = false) {
return sprintf('array_slice(%s, %s, %s, %s)', $array, $start, $length, $preserveKeys);
},
function ($arguments, $array, $start, $length = null, $preserveKeys = false) {
return array_slice($array, $start, $length, $preserveKeys);
}
);
} | php | protected function createSliceFunction()
{
return new ExpressionFunction(
'slice',
function ($array, $start, $length = null, $preserveKeys = false) {
return sprintf('array_slice(%s, %s, %s, %s)', $array, $start, $length, $preserveKeys);
},
function ($arguments, $array, $start, $length = null, $preserveKeys = false) {
return array_slice($array, $start, $length, $preserveKeys);
}
);
} | [
"protected",
"function",
"createSliceFunction",
"(",
")",
"{",
"return",
"new",
"ExpressionFunction",
"(",
"'slice'",
",",
"function",
"(",
"$",
"array",
",",
"$",
"start",
",",
"$",
"length",
"=",
"null",
",",
"$",
"preserveKeys",
"=",
"false",
")",
"{",
"return",
"sprintf",
"(",
"'array_slice(%s, %s, %s, %s)'",
",",
"$",
"array",
",",
"$",
"start",
",",
"$",
"length",
",",
"$",
"preserveKeys",
")",
";",
"}",
",",
"function",
"(",
"$",
"arguments",
",",
"$",
"array",
",",
"$",
"start",
",",
"$",
"length",
"=",
"null",
",",
"$",
"preserveKeys",
"=",
"false",
")",
"{",
"return",
"array_slice",
"(",
"$",
"array",
",",
"$",
"start",
",",
"$",
"length",
",",
"$",
"preserveKeys",
")",
";",
"}",
")",
";",
"}"
] | Returns the sequence of elements from an array based on start and length parameters.
@return ExpressionFunction | [
"Returns",
"the",
"sequence",
"of",
"elements",
"from",
"an",
"array",
"based",
"on",
"start",
"and",
"length",
"parameters",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Tools/Evaluator/CustomExpressionLanguageProvider.php#L235-L246 |
28,839 | smartboxgroup/integration-framework-bundle | Tools/Evaluator/CustomExpressionLanguageProvider.php | CustomExpressionLanguageProvider.createExplodeFunction | protected function createExplodeFunction()
{
return new ExpressionFunction(
'explode',
function ($delimiter, $string) {
return sprintf('explode(%s,%s)', $delimiter, $string);
},
function ($arguments, $delimiter, $string) {
return explode($delimiter, $string);
}
);
} | php | protected function createExplodeFunction()
{
return new ExpressionFunction(
'explode',
function ($delimiter, $string) {
return sprintf('explode(%s,%s)', $delimiter, $string);
},
function ($arguments, $delimiter, $string) {
return explode($delimiter, $string);
}
);
} | [
"protected",
"function",
"createExplodeFunction",
"(",
")",
"{",
"return",
"new",
"ExpressionFunction",
"(",
"'explode'",
",",
"function",
"(",
"$",
"delimiter",
",",
"$",
"string",
")",
"{",
"return",
"sprintf",
"(",
"'explode(%s,%s)'",
",",
"$",
"delimiter",
",",
"$",
"string",
")",
";",
"}",
",",
"function",
"(",
"$",
"arguments",
",",
"$",
"delimiter",
",",
"$",
"string",
")",
"{",
"return",
"explode",
"(",
"$",
"delimiter",
",",
"$",
"string",
")",
";",
"}",
")",
";",
"}"
] | Explode a string into an array.
@return ExpressionFunction | [
"Explode",
"a",
"string",
"into",
"an",
"array",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Tools/Evaluator/CustomExpressionLanguageProvider.php#L253-L264 |
28,840 | smartboxgroup/integration-framework-bundle | Tools/Evaluator/CustomExpressionLanguageProvider.php | CustomExpressionLanguageProvider.createImplodeFunction | protected function createImplodeFunction()
{
return new ExpressionFunction(
'implode',
function ($glue, $pieces) {
return sprintf('implode(%s,%s)', $glue, $pieces);
},
function ($arguments, $glue, $pieces) {
return implode($glue, $pieces);
}
);
} | php | protected function createImplodeFunction()
{
return new ExpressionFunction(
'implode',
function ($glue, $pieces) {
return sprintf('implode(%s,%s)', $glue, $pieces);
},
function ($arguments, $glue, $pieces) {
return implode($glue, $pieces);
}
);
} | [
"protected",
"function",
"createImplodeFunction",
"(",
")",
"{",
"return",
"new",
"ExpressionFunction",
"(",
"'implode'",
",",
"function",
"(",
"$",
"glue",
",",
"$",
"pieces",
")",
"{",
"return",
"sprintf",
"(",
"'implode(%s,%s)'",
",",
"$",
"glue",
",",
"$",
"pieces",
")",
";",
"}",
",",
"function",
"(",
"$",
"arguments",
",",
"$",
"glue",
",",
"$",
"pieces",
")",
"{",
"return",
"implode",
"(",
"$",
"glue",
",",
"$",
"pieces",
")",
";",
"}",
")",
";",
"}"
] | Implode an array to a string.
@return ExpressionFunction | [
"Implode",
"an",
"array",
"to",
"a",
"string",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Tools/Evaluator/CustomExpressionLanguageProvider.php#L271-L282 |
28,841 | cedx/coveralls.php | lib/GitData.php | GitData.fromJson | static function fromJson(object $map): self {
return new static(
isset($map->head) && is_object($map->head) ? GitCommit::fromJson($map->head) : null,
isset($map->branch) && is_string($map->branch) ? $map->branch : '',
isset($map->remotes) && is_array($map->remotes) ? array_map([GitRemote::class, 'fromJson'], $map->remotes) : []
);
} | php | static function fromJson(object $map): self {
return new static(
isset($map->head) && is_object($map->head) ? GitCommit::fromJson($map->head) : null,
isset($map->branch) && is_string($map->branch) ? $map->branch : '',
isset($map->remotes) && is_array($map->remotes) ? array_map([GitRemote::class, 'fromJson'], $map->remotes) : []
);
} | [
"static",
"function",
"fromJson",
"(",
"object",
"$",
"map",
")",
":",
"self",
"{",
"return",
"new",
"static",
"(",
"isset",
"(",
"$",
"map",
"->",
"head",
")",
"&&",
"is_object",
"(",
"$",
"map",
"->",
"head",
")",
"?",
"GitCommit",
"::",
"fromJson",
"(",
"$",
"map",
"->",
"head",
")",
":",
"null",
",",
"isset",
"(",
"$",
"map",
"->",
"branch",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"branch",
")",
"?",
"$",
"map",
"->",
"branch",
":",
"''",
",",
"isset",
"(",
"$",
"map",
"->",
"remotes",
")",
"&&",
"is_array",
"(",
"$",
"map",
"->",
"remotes",
")",
"?",
"array_map",
"(",
"[",
"GitRemote",
"::",
"class",
",",
"'fromJson'",
"]",
",",
"$",
"map",
"->",
"remotes",
")",
":",
"[",
"]",
")",
";",
"}"
] | Creates a new Git data from the specified JSON map.
@param object $map A JSON map representing a Git data.
@return static The instance corresponding to the specified JSON map. | [
"Creates",
"a",
"new",
"Git",
"data",
"from",
"the",
"specified",
"JSON",
"map",
"."
] | c196de0f92e06d5143ba90ebab18c8e384316cc0 | https://github.com/cedx/coveralls.php/blob/c196de0f92e06d5143ba90ebab18c8e384316cc0/lib/GitData.php#L33-L39 |
28,842 | cedx/coveralls.php | lib/GitData.php | GitData.fromRepository | static function fromRepository(string $path = ''): self {
$workingDir = getcwd() ?: '.';
if (!mb_strlen($path)) $path = $workingDir;
chdir($path);
$commands = (object) array_map(function($command) { return trim(`git $command`); }, [
'author_email' => 'log -1 --pretty=format:%ae',
'author_name' => 'log -1 --pretty=format:%aN',
'branch' => 'rev-parse --abbrev-ref HEAD',
'committer_email' => 'log -1 --pretty=format:%ce',
'committer_name' => 'log -1 --pretty=format:%cN',
'id' => 'log -1 --pretty=format:%H',
'message' => 'log -1 --pretty=format:%s',
'remotes' => 'remote -v'
]);
$remotes = [];
foreach (preg_split('/\r?\n/', $commands->remotes) ?: [] as $remote) {
$parts = explode(' ', (string) preg_replace('/\s+/', ' ', $remote));
if (!isset($remotes[$parts[0]])) $remotes[$parts[0]] = new GitRemote($parts[0], count($parts) > 1 ? $parts[1] : null);
}
chdir($workingDir);
return new static(GitCommit::fromJson($commands), $commands->branch, array_values($remotes));
} | php | static function fromRepository(string $path = ''): self {
$workingDir = getcwd() ?: '.';
if (!mb_strlen($path)) $path = $workingDir;
chdir($path);
$commands = (object) array_map(function($command) { return trim(`git $command`); }, [
'author_email' => 'log -1 --pretty=format:%ae',
'author_name' => 'log -1 --pretty=format:%aN',
'branch' => 'rev-parse --abbrev-ref HEAD',
'committer_email' => 'log -1 --pretty=format:%ce',
'committer_name' => 'log -1 --pretty=format:%cN',
'id' => 'log -1 --pretty=format:%H',
'message' => 'log -1 --pretty=format:%s',
'remotes' => 'remote -v'
]);
$remotes = [];
foreach (preg_split('/\r?\n/', $commands->remotes) ?: [] as $remote) {
$parts = explode(' ', (string) preg_replace('/\s+/', ' ', $remote));
if (!isset($remotes[$parts[0]])) $remotes[$parts[0]] = new GitRemote($parts[0], count($parts) > 1 ? $parts[1] : null);
}
chdir($workingDir);
return new static(GitCommit::fromJson($commands), $commands->branch, array_values($remotes));
} | [
"static",
"function",
"fromRepository",
"(",
"string",
"$",
"path",
"=",
"''",
")",
":",
"self",
"{",
"$",
"workingDir",
"=",
"getcwd",
"(",
")",
"?",
":",
"'.'",
";",
"if",
"(",
"!",
"mb_strlen",
"(",
"$",
"path",
")",
")",
"$",
"path",
"=",
"$",
"workingDir",
";",
"chdir",
"(",
"$",
"path",
")",
";",
"$",
"commands",
"=",
"(",
"object",
")",
"array_map",
"(",
"function",
"(",
"$",
"command",
")",
"{",
"return",
"trim",
"(",
"`git $command`",
")",
";",
"}",
",",
"[",
"'author_email'",
"=>",
"'log -1 --pretty=format:%ae'",
",",
"'author_name'",
"=>",
"'log -1 --pretty=format:%aN'",
",",
"'branch'",
"=>",
"'rev-parse --abbrev-ref HEAD'",
",",
"'committer_email'",
"=>",
"'log -1 --pretty=format:%ce'",
",",
"'committer_name'",
"=>",
"'log -1 --pretty=format:%cN'",
",",
"'id'",
"=>",
"'log -1 --pretty=format:%H'",
",",
"'message'",
"=>",
"'log -1 --pretty=format:%s'",
",",
"'remotes'",
"=>",
"'remote -v'",
"]",
")",
";",
"$",
"remotes",
"=",
"[",
"]",
";",
"foreach",
"(",
"preg_split",
"(",
"'/\\r?\\n/'",
",",
"$",
"commands",
"->",
"remotes",
")",
"?",
":",
"[",
"]",
"as",
"$",
"remote",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"remote",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"remotes",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
")",
")",
"$",
"remotes",
"[",
"$",
"parts",
"[",
"0",
"]",
"]",
"=",
"new",
"GitRemote",
"(",
"$",
"parts",
"[",
"0",
"]",
",",
"count",
"(",
"$",
"parts",
")",
">",
"1",
"?",
"$",
"parts",
"[",
"1",
"]",
":",
"null",
")",
";",
"}",
"chdir",
"(",
"$",
"workingDir",
")",
";",
"return",
"new",
"static",
"(",
"GitCommit",
"::",
"fromJson",
"(",
"$",
"commands",
")",
",",
"$",
"commands",
"->",
"branch",
",",
"array_values",
"(",
"$",
"remotes",
")",
")",
";",
"}"
] | Creates a new Git data from a local repository.
This method relies on the availability of the Git executable in the system path.
@param string $path The path to the repository folder. Defaults to the current working directory.
@return static The newly created Git data. | [
"Creates",
"a",
"new",
"Git",
"data",
"from",
"a",
"local",
"repository",
".",
"This",
"method",
"relies",
"on",
"the",
"availability",
"of",
"the",
"Git",
"executable",
"in",
"the",
"system",
"path",
"."
] | c196de0f92e06d5143ba90ebab18c8e384316cc0 | https://github.com/cedx/coveralls.php/blob/c196de0f92e06d5143ba90ebab18c8e384316cc0/lib/GitData.php#L47-L71 |
28,843 | Prezent/prezent-crud-bundle | src/Model/Configuration.php | Configuration.getDefaultName | private function getDefaultName(Request $request)
{
if (!preg_match('/Bundle\\\\Controller\\\\([\w\\\\]+)Controller:/', $request->attributes->get('_controller'), $match)) {
throw new \RuntimeException('Unable to determine controller name');
}
return strtolower(str_replace('\\', '_', $match[1]));
} | php | private function getDefaultName(Request $request)
{
if (!preg_match('/Bundle\\\\Controller\\\\([\w\\\\]+)Controller:/', $request->attributes->get('_controller'), $match)) {
throw new \RuntimeException('Unable to determine controller name');
}
return strtolower(str_replace('\\', '_', $match[1]));
} | [
"private",
"function",
"getDefaultName",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/Bundle\\\\\\\\Controller\\\\\\\\([\\w\\\\\\\\]+)Controller:/'",
",",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_controller'",
")",
",",
"$",
"match",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to determine controller name'",
")",
";",
"}",
"return",
"strtolower",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'_'",
",",
"$",
"match",
"[",
"1",
"]",
")",
")",
";",
"}"
] | Get the default controller name
@param Request $request
@return string | [
"Get",
"the",
"default",
"controller",
"name"
] | bb8bcf92cecc2acae08b8a672876b4972175ca24 | https://github.com/Prezent/prezent-crud-bundle/blob/bb8bcf92cecc2acae08b8a672876b4972175ca24/src/Model/Configuration.php#L519-L526 |
28,844 | Prezent/prezent-crud-bundle | src/Model/Configuration.php | Configuration.getDefaultAction | private function getDefaultAction(Request $request)
{
if (!preg_match('/(\w+)Action$/', $request->attributes->get('_controller'), $match)) {
throw new \RuntimeException('Unable to determine controller name');
}
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $match[1]));
} | php | private function getDefaultAction(Request $request)
{
if (!preg_match('/(\w+)Action$/', $request->attributes->get('_controller'), $match)) {
throw new \RuntimeException('Unable to determine controller name');
}
return strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $match[1]));
} | [
"private",
"function",
"getDefaultAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/(\\w+)Action$/'",
",",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_controller'",
")",
",",
"$",
"match",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Unable to determine controller name'",
")",
";",
"}",
"return",
"strtolower",
"(",
"preg_replace",
"(",
"'/(?<!^)[A-Z]/'",
",",
"'_$0'",
",",
"$",
"match",
"[",
"1",
"]",
")",
")",
";",
"}"
] | Get the default controller action
@param Request $request
@return string | [
"Get",
"the",
"default",
"controller",
"action"
] | bb8bcf92cecc2acae08b8a672876b4972175ca24 | https://github.com/Prezent/prezent-crud-bundle/blob/bb8bcf92cecc2acae08b8a672876b4972175ca24/src/Model/Configuration.php#L534-L541 |
28,845 | netgen/site-bundle | bundle/Controller/MenuController.php | MenuController.renderMenu | public function renderMenu(Request $request, string $menuName): Response
{
$menu = $this->menuProvider->get($menuName);
$menu->setChildrenAttribute('class', $request->attributes->get('ulClass') ?: 'nav navbar-nav');
$menuOptions = [
'firstClass' => $request->attributes->get('firstClass') ?: 'firstli',
'currentClass' => $request->attributes->get('currentClass') ?: 'active',
'lastClass' => $request->attributes->get('lastClass') ?: 'lastli',
'template' => $this->getConfigResolver()->getParameter('template.menu', 'ngsite'),
];
if ($request->attributes->has('template')) {
$menuOptions['template'] = $request->attributes->get('template');
}
$response = new Response();
$menuLocationId = $menu->getAttribute('location-id');
if (!empty($menuLocationId)) {
$this->tagHandler->addTags(['location-' . $menuLocationId]);
}
$this->processCacheSettings($request, $response);
$response->setContent($this->menuRenderer->get()->render($menu, $menuOptions));
return $response;
} | php | public function renderMenu(Request $request, string $menuName): Response
{
$menu = $this->menuProvider->get($menuName);
$menu->setChildrenAttribute('class', $request->attributes->get('ulClass') ?: 'nav navbar-nav');
$menuOptions = [
'firstClass' => $request->attributes->get('firstClass') ?: 'firstli',
'currentClass' => $request->attributes->get('currentClass') ?: 'active',
'lastClass' => $request->attributes->get('lastClass') ?: 'lastli',
'template' => $this->getConfigResolver()->getParameter('template.menu', 'ngsite'),
];
if ($request->attributes->has('template')) {
$menuOptions['template'] = $request->attributes->get('template');
}
$response = new Response();
$menuLocationId = $menu->getAttribute('location-id');
if (!empty($menuLocationId)) {
$this->tagHandler->addTags(['location-' . $menuLocationId]);
}
$this->processCacheSettings($request, $response);
$response->setContent($this->menuRenderer->get()->render($menu, $menuOptions));
return $response;
} | [
"public",
"function",
"renderMenu",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"menuName",
")",
":",
"Response",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"menuProvider",
"->",
"get",
"(",
"$",
"menuName",
")",
";",
"$",
"menu",
"->",
"setChildrenAttribute",
"(",
"'class'",
",",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'ulClass'",
")",
"?",
":",
"'nav navbar-nav'",
")",
";",
"$",
"menuOptions",
"=",
"[",
"'firstClass'",
"=>",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'firstClass'",
")",
"?",
":",
"'firstli'",
",",
"'currentClass'",
"=>",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'currentClass'",
")",
"?",
":",
"'active'",
",",
"'lastClass'",
"=>",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'lastClass'",
")",
"?",
":",
"'lastli'",
",",
"'template'",
"=>",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'template.menu'",
",",
"'ngsite'",
")",
",",
"]",
";",
"if",
"(",
"$",
"request",
"->",
"attributes",
"->",
"has",
"(",
"'template'",
")",
")",
"{",
"$",
"menuOptions",
"[",
"'template'",
"]",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'template'",
")",
";",
"}",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"menuLocationId",
"=",
"$",
"menu",
"->",
"getAttribute",
"(",
"'location-id'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"menuLocationId",
")",
")",
"{",
"$",
"this",
"->",
"tagHandler",
"->",
"addTags",
"(",
"[",
"'location-'",
".",
"$",
"menuLocationId",
"]",
")",
";",
"}",
"$",
"this",
"->",
"processCacheSettings",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"this",
"->",
"menuRenderer",
"->",
"get",
"(",
")",
"->",
"render",
"(",
"$",
"menu",
",",
"$",
"menuOptions",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Renders the menu with provided name. | [
"Renders",
"the",
"menu",
"with",
"provided",
"name",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/MenuController.php#L43-L71 |
28,846 | netgen/site-bundle | bundle/Controller/Controller.php | Controller.processCacheSettings | protected function processCacheSettings(Request $request, Response $response): void
{
$defaultSharedMaxAge = $this->getConfigResolver()->getParameter('view.shared_max_age', 'ngsite');
$cacheSettings = $request->attributes->get('cacheSettings');
if (!is_array($cacheSettings)) {
$cacheSettings = ['sharedMaxAge' => $defaultSharedMaxAge];
}
$public = true;
if (isset($cacheSettings['sharedMaxAge'])) {
$response->setSharedMaxAge($cacheSettings['sharedMaxAge']);
if (empty($cacheSettings['sharedMaxAge'])) {
$public = false;
}
} elseif (isset($cacheSettings['maxAge'])) {
$response->setMaxAge($cacheSettings['maxAge']);
if (empty($cacheSettings['maxAge'])) {
$public = false;
}
} else {
$response->setSharedMaxAge($defaultSharedMaxAge);
}
$public ? $response->setPublic() : $response->setPrivate();
} | php | protected function processCacheSettings(Request $request, Response $response): void
{
$defaultSharedMaxAge = $this->getConfigResolver()->getParameter('view.shared_max_age', 'ngsite');
$cacheSettings = $request->attributes->get('cacheSettings');
if (!is_array($cacheSettings)) {
$cacheSettings = ['sharedMaxAge' => $defaultSharedMaxAge];
}
$public = true;
if (isset($cacheSettings['sharedMaxAge'])) {
$response->setSharedMaxAge($cacheSettings['sharedMaxAge']);
if (empty($cacheSettings['sharedMaxAge'])) {
$public = false;
}
} elseif (isset($cacheSettings['maxAge'])) {
$response->setMaxAge($cacheSettings['maxAge']);
if (empty($cacheSettings['maxAge'])) {
$public = false;
}
} else {
$response->setSharedMaxAge($defaultSharedMaxAge);
}
$public ? $response->setPublic() : $response->setPrivate();
} | [
"protected",
"function",
"processCacheSettings",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
":",
"void",
"{",
"$",
"defaultSharedMaxAge",
"=",
"$",
"this",
"->",
"getConfigResolver",
"(",
")",
"->",
"getParameter",
"(",
"'view.shared_max_age'",
",",
"'ngsite'",
")",
";",
"$",
"cacheSettings",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'cacheSettings'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"cacheSettings",
")",
")",
"{",
"$",
"cacheSettings",
"=",
"[",
"'sharedMaxAge'",
"=>",
"$",
"defaultSharedMaxAge",
"]",
";",
"}",
"$",
"public",
"=",
"true",
";",
"if",
"(",
"isset",
"(",
"$",
"cacheSettings",
"[",
"'sharedMaxAge'",
"]",
")",
")",
"{",
"$",
"response",
"->",
"setSharedMaxAge",
"(",
"$",
"cacheSettings",
"[",
"'sharedMaxAge'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"cacheSettings",
"[",
"'sharedMaxAge'",
"]",
")",
")",
"{",
"$",
"public",
"=",
"false",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"cacheSettings",
"[",
"'maxAge'",
"]",
")",
")",
"{",
"$",
"response",
"->",
"setMaxAge",
"(",
"$",
"cacheSettings",
"[",
"'maxAge'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"cacheSettings",
"[",
"'maxAge'",
"]",
")",
")",
"{",
"$",
"public",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"response",
"->",
"setSharedMaxAge",
"(",
"$",
"defaultSharedMaxAge",
")",
";",
"}",
"$",
"public",
"?",
"$",
"response",
"->",
"setPublic",
"(",
")",
":",
"$",
"response",
"->",
"setPrivate",
"(",
")",
";",
"}"
] | Configures the response with provided cache settings. | [
"Configures",
"the",
"response",
"with",
"provided",
"cache",
"settings",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/Controller.php#L16-L42 |
28,847 | netgen/site-bundle | bundle/EventListener/User/PasswordResetRequestEventListener.php | PasswordResetRequestEventListener.onPasswordResetRequest | public function onPasswordResetRequest(PasswordResetRequestEvent $event): void
{
$user = $event->getUser();
$email = $event->getEmail();
if (!$user instanceof User) {
$this->mailHelper
->sendMail(
$email,
'ngsite.user.forgot_password.not_registered.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password_not_registered', 'ngsite')
);
return;
}
if (!$user->enabled) {
if ($this->ngUserSettingRepository->isUserActivated($user->id)) {
$this->mailHelper
->sendMail(
[$user->email => $this->getUserName($user)],
'ngsite.user.forgot_password.disabled.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password_disabled', 'ngsite'),
[
'user' => $user,
]
);
return;
}
$this->mailHelper
->sendMail(
[$user->email => $this->getUserName($user)],
'ngsite.user.forgot_password.not_active.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password_not_active', 'ngsite'),
[
'user' => $user,
]
);
return;
}
$accountKey = $this->ezUserAccountKeyRepository->create($user->id);
$this->mailHelper
->sendMail(
[$user->email => $this->getUserName($user)],
'ngsite.user.forgot_password.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password', 'ngsite'),
[
'user' => $user,
'hash' => $accountKey->getHash(),
]
);
} | php | public function onPasswordResetRequest(PasswordResetRequestEvent $event): void
{
$user = $event->getUser();
$email = $event->getEmail();
if (!$user instanceof User) {
$this->mailHelper
->sendMail(
$email,
'ngsite.user.forgot_password.not_registered.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password_not_registered', 'ngsite')
);
return;
}
if (!$user->enabled) {
if ($this->ngUserSettingRepository->isUserActivated($user->id)) {
$this->mailHelper
->sendMail(
[$user->email => $this->getUserName($user)],
'ngsite.user.forgot_password.disabled.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password_disabled', 'ngsite'),
[
'user' => $user,
]
);
return;
}
$this->mailHelper
->sendMail(
[$user->email => $this->getUserName($user)],
'ngsite.user.forgot_password.not_active.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password_not_active', 'ngsite'),
[
'user' => $user,
]
);
return;
}
$accountKey = $this->ezUserAccountKeyRepository->create($user->id);
$this->mailHelper
->sendMail(
[$user->email => $this->getUserName($user)],
'ngsite.user.forgot_password.subject',
$this->configResolver->getParameter('template.user.mail.forgot_password', 'ngsite'),
[
'user' => $user,
'hash' => $accountKey->getHash(),
]
);
} | [
"public",
"function",
"onPasswordResetRequest",
"(",
"PasswordResetRequestEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"user",
"=",
"$",
"event",
"->",
"getUser",
"(",
")",
";",
"$",
"email",
"=",
"$",
"event",
"->",
"getEmail",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
"instanceof",
"User",
")",
"{",
"$",
"this",
"->",
"mailHelper",
"->",
"sendMail",
"(",
"$",
"email",
",",
"'ngsite.user.forgot_password.not_registered.subject'",
",",
"$",
"this",
"->",
"configResolver",
"->",
"getParameter",
"(",
"'template.user.mail.forgot_password_not_registered'",
",",
"'ngsite'",
")",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"user",
"->",
"enabled",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"ngUserSettingRepository",
"->",
"isUserActivated",
"(",
"$",
"user",
"->",
"id",
")",
")",
"{",
"$",
"this",
"->",
"mailHelper",
"->",
"sendMail",
"(",
"[",
"$",
"user",
"->",
"email",
"=>",
"$",
"this",
"->",
"getUserName",
"(",
"$",
"user",
")",
"]",
",",
"'ngsite.user.forgot_password.disabled.subject'",
",",
"$",
"this",
"->",
"configResolver",
"->",
"getParameter",
"(",
"'template.user.mail.forgot_password_disabled'",
",",
"'ngsite'",
")",
",",
"[",
"'user'",
"=>",
"$",
"user",
",",
"]",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"mailHelper",
"->",
"sendMail",
"(",
"[",
"$",
"user",
"->",
"email",
"=>",
"$",
"this",
"->",
"getUserName",
"(",
"$",
"user",
")",
"]",
",",
"'ngsite.user.forgot_password.not_active.subject'",
",",
"$",
"this",
"->",
"configResolver",
"->",
"getParameter",
"(",
"'template.user.mail.forgot_password_not_active'",
",",
"'ngsite'",
")",
",",
"[",
"'user'",
"=>",
"$",
"user",
",",
"]",
")",
";",
"return",
";",
"}",
"$",
"accountKey",
"=",
"$",
"this",
"->",
"ezUserAccountKeyRepository",
"->",
"create",
"(",
"$",
"user",
"->",
"id",
")",
";",
"$",
"this",
"->",
"mailHelper",
"->",
"sendMail",
"(",
"[",
"$",
"user",
"->",
"email",
"=>",
"$",
"this",
"->",
"getUserName",
"(",
"$",
"user",
")",
"]",
",",
"'ngsite.user.forgot_password.subject'",
",",
"$",
"this",
"->",
"configResolver",
"->",
"getParameter",
"(",
"'template.user.mail.forgot_password'",
",",
"'ngsite'",
")",
",",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'hash'",
"=>",
"$",
"accountKey",
"->",
"getHash",
"(",
")",
",",
"]",
")",
";",
"}"
] | Listens for the start of forgot password procedure.
Event contains information about the submitted email and the user, if found. | [
"Listens",
"for",
"the",
"start",
"of",
"forgot",
"password",
"procedure",
".",
"Event",
"contains",
"information",
"about",
"the",
"submitted",
"email",
"and",
"the",
"user",
"if",
"found",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/EventListener/User/PasswordResetRequestEventListener.php#L31-L87 |
28,848 | netgen/site-bundle | bundle/Templating/Twig/Extension/SiteRuntime.php | SiteRuntime.getLanguageName | public function getLanguageName(string $languageCode): string
{
$posixLanguageCode = $this->localeConverter->convertToPOSIX($languageCode);
if ($posixLanguageCode === null) {
return '';
}
$posixLanguageCode = mb_substr($posixLanguageCode, 0, 2);
$languageName = Intl::getLanguageBundle()->getLanguageName($posixLanguageCode, null, $posixLanguageCode);
return ucwords($languageName);
} | php | public function getLanguageName(string $languageCode): string
{
$posixLanguageCode = $this->localeConverter->convertToPOSIX($languageCode);
if ($posixLanguageCode === null) {
return '';
}
$posixLanguageCode = mb_substr($posixLanguageCode, 0, 2);
$languageName = Intl::getLanguageBundle()->getLanguageName($posixLanguageCode, null, $posixLanguageCode);
return ucwords($languageName);
} | [
"public",
"function",
"getLanguageName",
"(",
"string",
"$",
"languageCode",
")",
":",
"string",
"{",
"$",
"posixLanguageCode",
"=",
"$",
"this",
"->",
"localeConverter",
"->",
"convertToPOSIX",
"(",
"$",
"languageCode",
")",
";",
"if",
"(",
"$",
"posixLanguageCode",
"===",
"null",
")",
"{",
"return",
"''",
";",
"}",
"$",
"posixLanguageCode",
"=",
"mb_substr",
"(",
"$",
"posixLanguageCode",
",",
"0",
",",
"2",
")",
";",
"$",
"languageName",
"=",
"Intl",
"::",
"getLanguageBundle",
"(",
")",
"->",
"getLanguageName",
"(",
"$",
"posixLanguageCode",
",",
"null",
",",
"$",
"posixLanguageCode",
")",
";",
"return",
"ucwords",
"(",
"$",
"languageName",
")",
";",
"}"
] | Returns the language name for specified language code. | [
"Returns",
"the",
"language",
"name",
"for",
"specified",
"language",
"code",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Templating/Twig/Extension/SiteRuntime.php#L52-L63 |
28,849 | cedx/coveralls.php | lib/Job.php | Job.fromJson | static function fromJson(object $map): self {
return (new static(isset($map->source_files) && is_array($map->source_files) ? array_map([SourceFile::class, 'fromJson'], $map->source_files) : []))
->setCommitSha(isset($map->commit_sha) && is_string($map->commit_sha) ? $map->commit_sha : '')
->setGit(isset($map->git) && is_object($map->git) ? GitData::fromJson($map->git) : null)
->setParallel(isset($map->parallel) && is_bool($map->parallel) ? $map->parallel : false)
->setRepoToken(isset($map->repo_token) && is_string($map->repo_token) ? $map->repo_token : '')
->setRunAt(isset($map->run_at) && is_string($map->run_at) ? new \DateTime($map->run_at) : null)
->setServiceJobId(isset($map->service_job_id) && is_string($map->service_job_id) ? $map->service_job_id : '')
->setServiceName(isset($map->service_name) && is_string($map->service_name) ? $map->service_name : '')
->setServiceNumber(isset($map->service_number) && is_string($map->service_number) ? $map->service_number : '')
->setServicePullRequest(isset($map->service_pull_request) && is_string($map->service_pull_request) ? $map->service_pull_request : '');
} | php | static function fromJson(object $map): self {
return (new static(isset($map->source_files) && is_array($map->source_files) ? array_map([SourceFile::class, 'fromJson'], $map->source_files) : []))
->setCommitSha(isset($map->commit_sha) && is_string($map->commit_sha) ? $map->commit_sha : '')
->setGit(isset($map->git) && is_object($map->git) ? GitData::fromJson($map->git) : null)
->setParallel(isset($map->parallel) && is_bool($map->parallel) ? $map->parallel : false)
->setRepoToken(isset($map->repo_token) && is_string($map->repo_token) ? $map->repo_token : '')
->setRunAt(isset($map->run_at) && is_string($map->run_at) ? new \DateTime($map->run_at) : null)
->setServiceJobId(isset($map->service_job_id) && is_string($map->service_job_id) ? $map->service_job_id : '')
->setServiceName(isset($map->service_name) && is_string($map->service_name) ? $map->service_name : '')
->setServiceNumber(isset($map->service_number) && is_string($map->service_number) ? $map->service_number : '')
->setServicePullRequest(isset($map->service_pull_request) && is_string($map->service_pull_request) ? $map->service_pull_request : '');
} | [
"static",
"function",
"fromJson",
"(",
"object",
"$",
"map",
")",
":",
"self",
"{",
"return",
"(",
"new",
"static",
"(",
"isset",
"(",
"$",
"map",
"->",
"source_files",
")",
"&&",
"is_array",
"(",
"$",
"map",
"->",
"source_files",
")",
"?",
"array_map",
"(",
"[",
"SourceFile",
"::",
"class",
",",
"'fromJson'",
"]",
",",
"$",
"map",
"->",
"source_files",
")",
":",
"[",
"]",
")",
")",
"->",
"setCommitSha",
"(",
"isset",
"(",
"$",
"map",
"->",
"commit_sha",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"commit_sha",
")",
"?",
"$",
"map",
"->",
"commit_sha",
":",
"''",
")",
"->",
"setGit",
"(",
"isset",
"(",
"$",
"map",
"->",
"git",
")",
"&&",
"is_object",
"(",
"$",
"map",
"->",
"git",
")",
"?",
"GitData",
"::",
"fromJson",
"(",
"$",
"map",
"->",
"git",
")",
":",
"null",
")",
"->",
"setParallel",
"(",
"isset",
"(",
"$",
"map",
"->",
"parallel",
")",
"&&",
"is_bool",
"(",
"$",
"map",
"->",
"parallel",
")",
"?",
"$",
"map",
"->",
"parallel",
":",
"false",
")",
"->",
"setRepoToken",
"(",
"isset",
"(",
"$",
"map",
"->",
"repo_token",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"repo_token",
")",
"?",
"$",
"map",
"->",
"repo_token",
":",
"''",
")",
"->",
"setRunAt",
"(",
"isset",
"(",
"$",
"map",
"->",
"run_at",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"run_at",
")",
"?",
"new",
"\\",
"DateTime",
"(",
"$",
"map",
"->",
"run_at",
")",
":",
"null",
")",
"->",
"setServiceJobId",
"(",
"isset",
"(",
"$",
"map",
"->",
"service_job_id",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"service_job_id",
")",
"?",
"$",
"map",
"->",
"service_job_id",
":",
"''",
")",
"->",
"setServiceName",
"(",
"isset",
"(",
"$",
"map",
"->",
"service_name",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"service_name",
")",
"?",
"$",
"map",
"->",
"service_name",
":",
"''",
")",
"->",
"setServiceNumber",
"(",
"isset",
"(",
"$",
"map",
"->",
"service_number",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"service_number",
")",
"?",
"$",
"map",
"->",
"service_number",
":",
"''",
")",
"->",
"setServicePullRequest",
"(",
"isset",
"(",
"$",
"map",
"->",
"service_pull_request",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"service_pull_request",
")",
"?",
"$",
"map",
"->",
"service_pull_request",
":",
"''",
")",
";",
"}"
] | Creates a new job from the specified JSON map.
@param object $map A JSON map representing a job.
@return static The instance corresponding to the specified JSON map. | [
"Creates",
"a",
"new",
"job",
"from",
"the",
"specified",
"JSON",
"map",
"."
] | c196de0f92e06d5143ba90ebab18c8e384316cc0 | https://github.com/cedx/coveralls.php/blob/c196de0f92e06d5143ba90ebab18c8e384316cc0/lib/Job.php#L50-L61 |
28,850 | netgen/site-bundle | bundle/Command/SymlinkProjectCommand.php | SymlinkProjectCommand.symlinkProjectFiles | protected function symlinkProjectFiles(string $projectFilesPath, InputInterface $input, OutputInterface $output): void
{
/** @var \DirectoryIterator[] $directories */
$directories = [];
$path = $projectFilesPath . '/root_' . $this->environment . '/';
if ($this->fileSystem->exists($path) && is_dir($path)) {
$directories[] = new DirectoryIterator($path);
}
$path = $projectFilesPath . '/root/';
if ($this->fileSystem->exists($path) && is_dir($path)) {
$directories[] = new DirectoryIterator($path);
}
foreach ($directories as $directory) {
foreach ($directory as $item) {
if ($item->isDot() || $item->isLink()) {
continue;
}
if ($item->isDir() || $item->isFile()) {
if (in_array($item->getBasename(), self::$blacklistedItems, true)) {
continue;
}
$webFolderName = $input->getOption('web-folder');
$webFolderName = !empty($webFolderName) ? $webFolderName : 'web';
$destination = $this->getContainer()->getParameter('kernel.project_dir') . '/' . $webFolderName . '/' . $item->getBasename();
if (!$this->fileSystem->exists(dirname($destination))) {
$output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment>. Folder does not exist!');
continue;
}
if ($item->isDir()) {
$this->verifyAndSymlinkDirectory(
$item->getPathname(),
$destination,
$output
);
} else {
$this->verifyAndSymlinkFile(
$item->getPathname(),
$destination,
$output
);
}
}
}
}
} | php | protected function symlinkProjectFiles(string $projectFilesPath, InputInterface $input, OutputInterface $output): void
{
/** @var \DirectoryIterator[] $directories */
$directories = [];
$path = $projectFilesPath . '/root_' . $this->environment . '/';
if ($this->fileSystem->exists($path) && is_dir($path)) {
$directories[] = new DirectoryIterator($path);
}
$path = $projectFilesPath . '/root/';
if ($this->fileSystem->exists($path) && is_dir($path)) {
$directories[] = new DirectoryIterator($path);
}
foreach ($directories as $directory) {
foreach ($directory as $item) {
if ($item->isDot() || $item->isLink()) {
continue;
}
if ($item->isDir() || $item->isFile()) {
if (in_array($item->getBasename(), self::$blacklistedItems, true)) {
continue;
}
$webFolderName = $input->getOption('web-folder');
$webFolderName = !empty($webFolderName) ? $webFolderName : 'web';
$destination = $this->getContainer()->getParameter('kernel.project_dir') . '/' . $webFolderName . '/' . $item->getBasename();
if (!$this->fileSystem->exists(dirname($destination))) {
$output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment>. Folder does not exist!');
continue;
}
if ($item->isDir()) {
$this->verifyAndSymlinkDirectory(
$item->getPathname(),
$destination,
$output
);
} else {
$this->verifyAndSymlinkFile(
$item->getPathname(),
$destination,
$output
);
}
}
}
}
} | [
"protected",
"function",
"symlinkProjectFiles",
"(",
"string",
"$",
"projectFilesPath",
",",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
":",
"void",
"{",
"/** @var \\DirectoryIterator[] $directories */",
"$",
"directories",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"projectFilesPath",
".",
"'/root_'",
".",
"$",
"this",
"->",
"environment",
".",
"'/'",
";",
"if",
"(",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"path",
")",
"&&",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"directories",
"[",
"]",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"}",
"$",
"path",
"=",
"$",
"projectFilesPath",
".",
"'/root/'",
";",
"if",
"(",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"$",
"path",
")",
"&&",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"directories",
"[",
"]",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"}",
"foreach",
"(",
"$",
"directories",
"as",
"$",
"directory",
")",
"{",
"foreach",
"(",
"$",
"directory",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"isDot",
"(",
")",
"||",
"$",
"item",
"->",
"isLink",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"isDir",
"(",
")",
"||",
"$",
"item",
"->",
"isFile",
"(",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"item",
"->",
"getBasename",
"(",
")",
",",
"self",
"::",
"$",
"blacklistedItems",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"$",
"webFolderName",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'web-folder'",
")",
";",
"$",
"webFolderName",
"=",
"!",
"empty",
"(",
"$",
"webFolderName",
")",
"?",
"$",
"webFolderName",
":",
"'web'",
";",
"$",
"destination",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kernel.project_dir'",
")",
".",
"'/'",
".",
"$",
"webFolderName",
".",
"'/'",
".",
"$",
"item",
"->",
"getBasename",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fileSystem",
"->",
"exists",
"(",
"dirname",
"(",
"$",
"destination",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'Skipped creating the symlink for <comment>'",
".",
"basename",
"(",
"$",
"destination",
")",
".",
"'</comment> in <comment>'",
".",
"dirname",
"(",
"$",
"destination",
")",
".",
"'/</comment>. Folder does not exist!'",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"this",
"->",
"verifyAndSymlinkDirectory",
"(",
"$",
"item",
"->",
"getPathname",
"(",
")",
",",
"$",
"destination",
",",
"$",
"output",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"verifyAndSymlinkFile",
"(",
"$",
"item",
"->",
"getPathname",
"(",
")",
",",
"$",
"destination",
",",
"$",
"output",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | Symlinks project files from a bundle. | [
"Symlinks",
"project",
"files",
"from",
"a",
"bundle",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Command/SymlinkProjectCommand.php#L60-L113 |
28,851 | IconoCoders/otp-simple-sdk | Source/SimpleIos.php | SimpleIos.runIos | public function runIos()
{
$this->debugMessage[] = 'IOS: START';
if ($this->merchantId == "" || $this->orderNumber == 'N/A') {
$this->errorMessage[] = 'IOS: MISSING DATA';
$this->debugMessage[] = 'IOS: END';
return false;
}
$iosArray = array(
'MERCHANT' => $this->merchantId,
'REFNOEXT' => $this->orderNumber,
'HASH' => $this->createHashString(array($this->merchantId, $this->orderNumber))
);
$this->logFunc("IOS", $iosArray, $this->orderNumber);
$iosCounter = 0;
while ($iosCounter < $this->maxRun) {
$result = $this->startRequest($this->iosOrderUrl, $iosArray, 'POST');
if ($result === false) {
$result = '<?xml version="1.0"?>
<Order>
<ORDER_DATE>' . @date("Y-m-d H:i:s", time()) . '</ORDER_DATE>
<REFNO>N/A</REFNO>
<REFNOEXT>N/A</REFNOEXT>
<ORDER_STATUS>EMPTY RESULT</ORDER_STATUS>
<PAYMETHOD>N/A</PAYMETHOD>
<HASH>N/A</HASH>
</Order>';
}
$resultArray = (array) simplexml_load_string($result);
foreach ($resultArray as $itemName => $itemValue) {
$this->status[$itemName] = $itemValue;
}
//Validation
$valid = false;
if (!isset($this->status['HASH'])) {
$this->debugMessage[] = 'IOS HASH: MISSING';
}
if ($this->createHashString($this->flatArray($this->status, array("HASH"))) == @$this->status['HASH']) {
$valid = true;
$this->debugMessage[] = 'IOS HASH: VALID';
}
if (!$valid) {
$iosCounter += $this->maxRun+10;
$this->debugMessage[] = 'IOS HASH: INVALID';
}
//state
switch ($this->status['ORDER_STATUS']) {
case 'NOT_FOUND':
$iosCounter++;
sleep(1);
break;
case 'CARD_NOTAUTHORIZED':
$iosCounter += 5;
sleep(1);
break;
default:
$iosCounter += $this->maxRun;
}
$this->debugMessage[] = 'IOS ORDER_STATUS: ' . $this->status['ORDER_STATUS'];
}
$this->debugMessage[] = 'IOS: END';
} | php | public function runIos()
{
$this->debugMessage[] = 'IOS: START';
if ($this->merchantId == "" || $this->orderNumber == 'N/A') {
$this->errorMessage[] = 'IOS: MISSING DATA';
$this->debugMessage[] = 'IOS: END';
return false;
}
$iosArray = array(
'MERCHANT' => $this->merchantId,
'REFNOEXT' => $this->orderNumber,
'HASH' => $this->createHashString(array($this->merchantId, $this->orderNumber))
);
$this->logFunc("IOS", $iosArray, $this->orderNumber);
$iosCounter = 0;
while ($iosCounter < $this->maxRun) {
$result = $this->startRequest($this->iosOrderUrl, $iosArray, 'POST');
if ($result === false) {
$result = '<?xml version="1.0"?>
<Order>
<ORDER_DATE>' . @date("Y-m-d H:i:s", time()) . '</ORDER_DATE>
<REFNO>N/A</REFNO>
<REFNOEXT>N/A</REFNOEXT>
<ORDER_STATUS>EMPTY RESULT</ORDER_STATUS>
<PAYMETHOD>N/A</PAYMETHOD>
<HASH>N/A</HASH>
</Order>';
}
$resultArray = (array) simplexml_load_string($result);
foreach ($resultArray as $itemName => $itemValue) {
$this->status[$itemName] = $itemValue;
}
//Validation
$valid = false;
if (!isset($this->status['HASH'])) {
$this->debugMessage[] = 'IOS HASH: MISSING';
}
if ($this->createHashString($this->flatArray($this->status, array("HASH"))) == @$this->status['HASH']) {
$valid = true;
$this->debugMessage[] = 'IOS HASH: VALID';
}
if (!$valid) {
$iosCounter += $this->maxRun+10;
$this->debugMessage[] = 'IOS HASH: INVALID';
}
//state
switch ($this->status['ORDER_STATUS']) {
case 'NOT_FOUND':
$iosCounter++;
sleep(1);
break;
case 'CARD_NOTAUTHORIZED':
$iosCounter += 5;
sleep(1);
break;
default:
$iosCounter += $this->maxRun;
}
$this->debugMessage[] = 'IOS ORDER_STATUS: ' . $this->status['ORDER_STATUS'];
}
$this->debugMessage[] = 'IOS: END';
} | [
"public",
"function",
"runIos",
"(",
")",
"{",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS: START'",
";",
"if",
"(",
"$",
"this",
"->",
"merchantId",
"==",
"\"\"",
"||",
"$",
"this",
"->",
"orderNumber",
"==",
"'N/A'",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'IOS: MISSING DATA'",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS: END'",
";",
"return",
"false",
";",
"}",
"$",
"iosArray",
"=",
"array",
"(",
"'MERCHANT'",
"=>",
"$",
"this",
"->",
"merchantId",
",",
"'REFNOEXT'",
"=>",
"$",
"this",
"->",
"orderNumber",
",",
"'HASH'",
"=>",
"$",
"this",
"->",
"createHashString",
"(",
"array",
"(",
"$",
"this",
"->",
"merchantId",
",",
"$",
"this",
"->",
"orderNumber",
")",
")",
")",
";",
"$",
"this",
"->",
"logFunc",
"(",
"\"IOS\"",
",",
"$",
"iosArray",
",",
"$",
"this",
"->",
"orderNumber",
")",
";",
"$",
"iosCounter",
"=",
"0",
";",
"while",
"(",
"$",
"iosCounter",
"<",
"$",
"this",
"->",
"maxRun",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"startRequest",
"(",
"$",
"this",
"->",
"iosOrderUrl",
",",
"$",
"iosArray",
",",
"'POST'",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"result",
"=",
"'<?xml version=\"1.0\"?>\n <Order>\n <ORDER_DATE>'",
".",
"@",
"date",
"(",
"\"Y-m-d H:i:s\"",
",",
"time",
"(",
")",
")",
".",
"'</ORDER_DATE>\n <REFNO>N/A</REFNO>\n <REFNOEXT>N/A</REFNOEXT>\n <ORDER_STATUS>EMPTY RESULT</ORDER_STATUS>\n <PAYMETHOD>N/A</PAYMETHOD>\n <HASH>N/A</HASH>\n </Order>'",
";",
"}",
"$",
"resultArray",
"=",
"(",
"array",
")",
"simplexml_load_string",
"(",
"$",
"result",
")",
";",
"foreach",
"(",
"$",
"resultArray",
"as",
"$",
"itemName",
"=>",
"$",
"itemValue",
")",
"{",
"$",
"this",
"->",
"status",
"[",
"$",
"itemName",
"]",
"=",
"$",
"itemValue",
";",
"}",
"//Validation",
"$",
"valid",
"=",
"false",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"status",
"[",
"'HASH'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS HASH: MISSING'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"createHashString",
"(",
"$",
"this",
"->",
"flatArray",
"(",
"$",
"this",
"->",
"status",
",",
"array",
"(",
"\"HASH\"",
")",
")",
")",
"==",
"@",
"$",
"this",
"->",
"status",
"[",
"'HASH'",
"]",
")",
"{",
"$",
"valid",
"=",
"true",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS HASH: VALID'",
";",
"}",
"if",
"(",
"!",
"$",
"valid",
")",
"{",
"$",
"iosCounter",
"+=",
"$",
"this",
"->",
"maxRun",
"+",
"10",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS HASH: INVALID'",
";",
"}",
"//state",
"switch",
"(",
"$",
"this",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
")",
"{",
"case",
"'NOT_FOUND'",
":",
"$",
"iosCounter",
"++",
";",
"sleep",
"(",
"1",
")",
";",
"break",
";",
"case",
"'CARD_NOTAUTHORIZED'",
":",
"$",
"iosCounter",
"+=",
"5",
";",
"sleep",
"(",
"1",
")",
";",
"break",
";",
"default",
":",
"$",
"iosCounter",
"+=",
"$",
"this",
"->",
"maxRun",
";",
"}",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS ORDER_STATUS: '",
".",
"$",
"this",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
";",
"}",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'IOS: END'",
";",
"}"
] | Starts IOS communication
@return void | [
"Starts",
"IOS",
"communication"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleIos.php#L87-L151 |
28,852 | alaxos/cakephp3-libs | src/View/Helper/AlaxosFormHelper.php | AlaxosFormHelper.antispam | public function antispam($form_dom_id)
{
$salt = isset($this->_View->viewVars['_alaxos_spam_filter_salt']) ? $this->_View->viewVars['_alaxos_spam_filter_salt'] : null;
$token = SecurityTool::get_today_token($salt);
/*
* Unlock hidden field added by JS to prevent blackholing of form
*/
$fieldname = SecurityTool::get_today_fieldname($salt);
$this->unlockField($fieldname);
return $this->AlaxosHtml->script(Router::url(['prefix' => false, 'plugin' => 'Alaxos', 'controller' => 'Javascripts', 'action' => 'antispam', '_ext' => 'js', '?' => ['fid' => $form_dom_id, 'token' => $token]], true), ['block' => true]);
} | php | public function antispam($form_dom_id)
{
$salt = isset($this->_View->viewVars['_alaxos_spam_filter_salt']) ? $this->_View->viewVars['_alaxos_spam_filter_salt'] : null;
$token = SecurityTool::get_today_token($salt);
/*
* Unlock hidden field added by JS to prevent blackholing of form
*/
$fieldname = SecurityTool::get_today_fieldname($salt);
$this->unlockField($fieldname);
return $this->AlaxosHtml->script(Router::url(['prefix' => false, 'plugin' => 'Alaxos', 'controller' => 'Javascripts', 'action' => 'antispam', '_ext' => 'js', '?' => ['fid' => $form_dom_id, 'token' => $token]], true), ['block' => true]);
} | [
"public",
"function",
"antispam",
"(",
"$",
"form_dom_id",
")",
"{",
"$",
"salt",
"=",
"isset",
"(",
"$",
"this",
"->",
"_View",
"->",
"viewVars",
"[",
"'_alaxos_spam_filter_salt'",
"]",
")",
"?",
"$",
"this",
"->",
"_View",
"->",
"viewVars",
"[",
"'_alaxos_spam_filter_salt'",
"]",
":",
"null",
";",
"$",
"token",
"=",
"SecurityTool",
"::",
"get_today_token",
"(",
"$",
"salt",
")",
";",
"/*\n * Unlock hidden field added by JS to prevent blackholing of form\n */",
"$",
"fieldname",
"=",
"SecurityTool",
"::",
"get_today_fieldname",
"(",
"$",
"salt",
")",
";",
"$",
"this",
"->",
"unlockField",
"(",
"$",
"fieldname",
")",
";",
"return",
"$",
"this",
"->",
"AlaxosHtml",
"->",
"script",
"(",
"Router",
"::",
"url",
"(",
"[",
"'prefix'",
"=>",
"false",
",",
"'plugin'",
"=>",
"'Alaxos'",
",",
"'controller'",
"=>",
"'Javascripts'",
",",
"'action'",
"=>",
"'antispam'",
",",
"'_ext'",
"=>",
"'js'",
",",
"'?'",
"=>",
"[",
"'fid'",
"=>",
"$",
"form_dom_id",
",",
"'token'",
"=>",
"$",
"token",
"]",
"]",
",",
"true",
")",
",",
"[",
"'block'",
"=>",
"true",
"]",
")",
";",
"}"
] | Add some JS code that add a hidden field
If the hidden field is not present in the POST, SpamFilterComponent considers the request as spam. | [
"Add",
"some",
"JS",
"code",
"that",
"add",
"a",
"hidden",
"field",
"If",
"the",
"hidden",
"field",
"is",
"not",
"present",
"in",
"the",
"POST",
"SpamFilterComponent",
"considers",
"the",
"request",
"as",
"spam",
"."
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/View/Helper/AlaxosFormHelper.php#L406-L418 |
28,853 | netgen/site-bundle | bundle/Core/MVC/Symfony/Matcher/ConfigResolverBased.php | ConfigResolverBased.doMatch | public function doMatch($value): bool
{
$config = $this->values[0];
$namespace = $this->values[1] ?? null;
if ($this->configResolver->hasParameter($config, $namespace)) {
$configValue = $this->configResolver->getParameter($config, $namespace);
$configValue = !is_array($configValue) ? [$configValue] : $configValue;
return in_array($value, $configValue, true);
}
return false;
} | php | public function doMatch($value): bool
{
$config = $this->values[0];
$namespace = $this->values[1] ?? null;
if ($this->configResolver->hasParameter($config, $namespace)) {
$configValue = $this->configResolver->getParameter($config, $namespace);
$configValue = !is_array($configValue) ? [$configValue] : $configValue;
return in_array($value, $configValue, true);
}
return false;
} | [
"public",
"function",
"doMatch",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"values",
"[",
"0",
"]",
";",
"$",
"namespace",
"=",
"$",
"this",
"->",
"values",
"[",
"1",
"]",
"??",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"configResolver",
"->",
"hasParameter",
"(",
"$",
"config",
",",
"$",
"namespace",
")",
")",
"{",
"$",
"configValue",
"=",
"$",
"this",
"->",
"configResolver",
"->",
"getParameter",
"(",
"$",
"config",
",",
"$",
"namespace",
")",
";",
"$",
"configValue",
"=",
"!",
"is_array",
"(",
"$",
"configValue",
")",
"?",
"[",
"$",
"configValue",
"]",
":",
"$",
"configValue",
";",
"return",
"in_array",
"(",
"$",
"value",
",",
"$",
"configValue",
",",
"true",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Performs the match against the provided value.
This works by comparing the value against the parameter from config resolver.
First element in the value array should be the name of the parameter and the
second should be the namespace.
@param mixed $value
@return bool | [
"Performs",
"the",
"match",
"against",
"the",
"provided",
"value",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Core/MVC/Symfony/Matcher/ConfigResolverBased.php#L33-L46 |
28,854 | smartboxgroup/integration-framework-bundle | Core/Producers/AbstractConfigurableProducer.php | AbstractConfigurableProducer.executeStep | public function executeStep($stepAction, &$stepActionParams, &$options, array &$context)
{
return $this->getConfHelper()->executeStep($stepAction, $stepActionParams, $options, $context);
} | php | public function executeStep($stepAction, &$stepActionParams, &$options, array &$context)
{
return $this->getConfHelper()->executeStep($stepAction, $stepActionParams, $options, $context);
} | [
"public",
"function",
"executeStep",
"(",
"$",
"stepAction",
",",
"&",
"$",
"stepActionParams",
",",
"&",
"$",
"options",
",",
"array",
"&",
"$",
"context",
")",
"{",
"return",
"$",
"this",
"->",
"getConfHelper",
"(",
")",
"->",
"executeStep",
"(",
"$",
"stepAction",
",",
"$",
"stepActionParams",
",",
"$",
"options",
",",
"$",
"context",
")",
";",
"}"
] | Returns true if the step was executed, false if the step was not recognized.
@param $stepAction
@param $stepActionParams
@param $options
@param array $context
@return bool | [
"Returns",
"true",
"if",
"the",
"step",
"was",
"executed",
"false",
"if",
"the",
"step",
"was",
"not",
"recognized",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Producers/AbstractConfigurableProducer.php#L91-L94 |
28,855 | netgen/ngsymfonytools | classes/ngsymfonytoolsrenderoperator.php | NgSymfonyToolsRenderOperator.renderUri | public static function renderUri( $uri, $options = array() )
{
$serviceContainer = ezpKernel::instance()->getServiceContainer();
$fragmentHandler = $serviceContainer->get( 'fragment.handler' );
$strategy = isset( $options['strategy'] ) ? $options['strategy'] : 'inline';
unset( $options['strategy'] );
try
{
return $fragmentHandler->render( $uri, $strategy, $options );
}
catch ( InvalidArgumentException $e )
{
throw new InvalidArgumentException( "The URI {$uri->controller} couldn't be rendered", 0, $e );
}
} | php | public static function renderUri( $uri, $options = array() )
{
$serviceContainer = ezpKernel::instance()->getServiceContainer();
$fragmentHandler = $serviceContainer->get( 'fragment.handler' );
$strategy = isset( $options['strategy'] ) ? $options['strategy'] : 'inline';
unset( $options['strategy'] );
try
{
return $fragmentHandler->render( $uri, $strategy, $options );
}
catch ( InvalidArgumentException $e )
{
throw new InvalidArgumentException( "The URI {$uri->controller} couldn't be rendered", 0, $e );
}
} | [
"public",
"static",
"function",
"renderUri",
"(",
"$",
"uri",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"serviceContainer",
"=",
"ezpKernel",
"::",
"instance",
"(",
")",
"->",
"getServiceContainer",
"(",
")",
";",
"$",
"fragmentHandler",
"=",
"$",
"serviceContainer",
"->",
"get",
"(",
"'fragment.handler'",
")",
";",
"$",
"strategy",
"=",
"isset",
"(",
"$",
"options",
"[",
"'strategy'",
"]",
")",
"?",
"$",
"options",
"[",
"'strategy'",
"]",
":",
"'inline'",
";",
"unset",
"(",
"$",
"options",
"[",
"'strategy'",
"]",
")",
";",
"try",
"{",
"return",
"$",
"fragmentHandler",
"->",
"render",
"(",
"$",
"uri",
",",
"$",
"strategy",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The URI {$uri->controller} couldn't be rendered\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Renders the given URI with Symfony stack
@param string|\Symfony\Component\HttpKernel\Controller\ControllerReference $uri
@param array $options
@return string | [
"Renders",
"the",
"given",
"URI",
"with",
"Symfony",
"stack"
] | 58abf97996ddd1d4f969d8c64ce6998b9d1a5c27 | https://github.com/netgen/ngsymfonytools/blob/58abf97996ddd1d4f969d8c64ce6998b9d1a5c27/classes/ngsymfonytoolsrenderoperator.php#L122-L138 |
28,856 | netgen/ngsymfonytools | classes/ngsymfonytoolsisgrantedoperator.php | NgSymfonyToolsIsGrantedOperator.isGranted | public static function isGranted( $role, $object = null, $field = null )
{
$serviceContainer = ezpKernel::instance()->getServiceContainer();
if ( $field !== null && class_exists( 'Symfony\Component\Security\Acl\Voter\FieldVote' ) )
{
$object = new FieldVote( $object, $field );
}
try
{
return $serviceContainer->get( 'security.authorization_checker' )->isGranted( $role, $object );
}
catch ( AuthenticationCredentialsNotFoundException $e )
{
return false;
}
} | php | public static function isGranted( $role, $object = null, $field = null )
{
$serviceContainer = ezpKernel::instance()->getServiceContainer();
if ( $field !== null && class_exists( 'Symfony\Component\Security\Acl\Voter\FieldVote' ) )
{
$object = new FieldVote( $object, $field );
}
try
{
return $serviceContainer->get( 'security.authorization_checker' )->isGranted( $role, $object );
}
catch ( AuthenticationCredentialsNotFoundException $e )
{
return false;
}
} | [
"public",
"static",
"function",
"isGranted",
"(",
"$",
"role",
",",
"$",
"object",
"=",
"null",
",",
"$",
"field",
"=",
"null",
")",
"{",
"$",
"serviceContainer",
"=",
"ezpKernel",
"::",
"instance",
"(",
")",
"->",
"getServiceContainer",
"(",
")",
";",
"if",
"(",
"$",
"field",
"!==",
"null",
"&&",
"class_exists",
"(",
"'Symfony\\Component\\Security\\Acl\\Voter\\FieldVote'",
")",
")",
"{",
"$",
"object",
"=",
"new",
"FieldVote",
"(",
"$",
"object",
",",
"$",
"field",
")",
";",
"}",
"try",
"{",
"return",
"$",
"serviceContainer",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
"->",
"isGranted",
"(",
"$",
"role",
",",
"$",
"object",
")",
";",
"}",
"catch",
"(",
"AuthenticationCredentialsNotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Returns if the current user has access to provided role.
@param mixed $role
@param mixed $object
@param mixed $field
@return bool | [
"Returns",
"if",
"the",
"current",
"user",
"has",
"access",
"to",
"provided",
"role",
"."
] | 58abf97996ddd1d4f969d8c64ce6998b9d1a5c27 | https://github.com/netgen/ngsymfonytools/blob/58abf97996ddd1d4f969d8c64ce6998b9d1a5c27/classes/ngsymfonytoolsisgrantedoperator.php#L82-L99 |
28,857 | nilportugues/php-api-transformer | src/Mapping/MappingFactory.php | MappingFactory.getClassProperties | protected static function getClassProperties(string $className) : array
{
if (empty(static::$classProperties[$className])) {
$ref = new ReflectionClass($className);
$properties = [];
foreach ($ref->getProperties() as $prop) {
$f = $prop->getName();
$properties[$f] = $prop;
}
if ($parentClass = $ref->getParentClass()) {
$parentPropsArr = static::getClassProperties($parentClass->getName());
if (\count($parentPropsArr) > 0) {
$properties = \array_merge($parentPropsArr, $properties);
}
}
static::$classProperties[$className] = \array_keys($properties);
}
return static::$classProperties[$className];
} | php | protected static function getClassProperties(string $className) : array
{
if (empty(static::$classProperties[$className])) {
$ref = new ReflectionClass($className);
$properties = [];
foreach ($ref->getProperties() as $prop) {
$f = $prop->getName();
$properties[$f] = $prop;
}
if ($parentClass = $ref->getParentClass()) {
$parentPropsArr = static::getClassProperties($parentClass->getName());
if (\count($parentPropsArr) > 0) {
$properties = \array_merge($parentPropsArr, $properties);
}
}
static::$classProperties[$className] = \array_keys($properties);
}
return static::$classProperties[$className];
} | [
"protected",
"static",
"function",
"getClassProperties",
"(",
"string",
"$",
"className",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"classProperties",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"ref",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"ref",
"->",
"getProperties",
"(",
")",
"as",
"$",
"prop",
")",
"{",
"$",
"f",
"=",
"$",
"prop",
"->",
"getName",
"(",
")",
";",
"$",
"properties",
"[",
"$",
"f",
"]",
"=",
"$",
"prop",
";",
"}",
"if",
"(",
"$",
"parentClass",
"=",
"$",
"ref",
"->",
"getParentClass",
"(",
")",
")",
"{",
"$",
"parentPropsArr",
"=",
"static",
"::",
"getClassProperties",
"(",
"$",
"parentClass",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"parentPropsArr",
")",
">",
"0",
")",
"{",
"$",
"properties",
"=",
"\\",
"array_merge",
"(",
"$",
"parentPropsArr",
",",
"$",
"properties",
")",
";",
"}",
"}",
"static",
"::",
"$",
"classProperties",
"[",
"$",
"className",
"]",
"=",
"\\",
"array_keys",
"(",
"$",
"properties",
")",
";",
"}",
"return",
"static",
"::",
"$",
"classProperties",
"[",
"$",
"className",
"]",
";",
"}"
] | Recursive function to get an associative array of class properties by
property name, including inherited ones from extended classes.
@param string $className Class name
@return array
@link http://php.net/manual/es/reflectionclass.getproperties.php#88405 | [
"Recursive",
"function",
"to",
"get",
"an",
"associative",
"array",
"of",
"class",
"properties",
"by",
"property",
"name",
"including",
"inherited",
"ones",
"from",
"extended",
"classes",
"."
] | a9f20fbe1580d98e3d462a0ebe13fb7595cbd683 | https://github.com/nilportugues/php-api-transformer/blob/a9f20fbe1580d98e3d462a0ebe13fb7595cbd683/src/Mapping/MappingFactory.php#L187-L207 |
28,858 | Atnic/laravel-generator | app/Console/Commands/ControllerMakeCommand.php | ControllerMakeCommand.getViewStub | protected function getViewStub($method = null, $name = null)
{
if (in_array($name, [ $this->qualifyClass('ModelController'), $this->qualifyClass('Model/ChildController') ])) {
if ($this->option('parent')) {
return __DIR__.'/stubs/view.nested.model.'.$method.'.stub';
} elseif ($this->option('model') || $this->option('resource')) {
return __DIR__.'/stubs/view.model.'.$method.'.stub';
}
}
if ($this->option('parent')) {
return __DIR__.'/stubs/view.nested.'.$method.'.stub';
} elseif ($this->option('model') || $this->option('resource')) {
return __DIR__.'/stubs/view.'.$method.'.stub';
}
return __DIR__.'/stubs/view.stub';
} | php | protected function getViewStub($method = null, $name = null)
{
if (in_array($name, [ $this->qualifyClass('ModelController'), $this->qualifyClass('Model/ChildController') ])) {
if ($this->option('parent')) {
return __DIR__.'/stubs/view.nested.model.'.$method.'.stub';
} elseif ($this->option('model') || $this->option('resource')) {
return __DIR__.'/stubs/view.model.'.$method.'.stub';
}
}
if ($this->option('parent')) {
return __DIR__.'/stubs/view.nested.'.$method.'.stub';
} elseif ($this->option('model') || $this->option('resource')) {
return __DIR__.'/stubs/view.'.$method.'.stub';
}
return __DIR__.'/stubs/view.stub';
} | [
"protected",
"function",
"getViewStub",
"(",
"$",
"method",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"[",
"$",
"this",
"->",
"qualifyClass",
"(",
"'ModelController'",
")",
",",
"$",
"this",
"->",
"qualifyClass",
"(",
"'Model/ChildController'",
")",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
")",
"{",
"return",
"__DIR__",
".",
"'/stubs/view.nested.model.'",
".",
"$",
"method",
".",
"'.stub'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'resource'",
")",
")",
"{",
"return",
"__DIR__",
".",
"'/stubs/view.model.'",
".",
"$",
"method",
".",
"'.stub'",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
")",
"{",
"return",
"__DIR__",
".",
"'/stubs/view.nested.'",
".",
"$",
"method",
".",
"'.stub'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'resource'",
")",
")",
"{",
"return",
"__DIR__",
".",
"'/stubs/view.'",
".",
"$",
"method",
".",
"'.stub'",
";",
"}",
"return",
"__DIR__",
".",
"'/stubs/view.stub'",
";",
"}"
] | Get the view stub file for the generator.
@param string|null $method
@param string|null $name
@return string | [
"Get",
"the",
"view",
"stub",
"file",
"for",
"the",
"generator",
"."
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ControllerMakeCommand.php#L49-L66 |
28,859 | Atnic/laravel-generator | app/Console/Commands/ControllerMakeCommand.php | ControllerMakeCommand.buildView | protected function buildView($name, $method = null)
{
$replace = [];
if ($this->option('parent')) {
$replace = $this->buildParentReplacements();
}
if ($this->option('model')) {
$replace = $this->buildModelReplacements($replace);
}
if ($this->option('parent')) {
$replace['parent_dummy_view'] = $this->getParentViewName($name);
$replace['parent_dummy_route'] = $this->getParentRouteName($name);
}
$replace['dummy_view'] = $this->getViewName($name);
$replace['dummy_route'] = $this->getRouteName($name);
return str_replace(array_keys($replace), array_values($replace), $this->files->get($this->getViewStub($method, $name)));
} | php | protected function buildView($name, $method = null)
{
$replace = [];
if ($this->option('parent')) {
$replace = $this->buildParentReplacements();
}
if ($this->option('model')) {
$replace = $this->buildModelReplacements($replace);
}
if ($this->option('parent')) {
$replace['parent_dummy_view'] = $this->getParentViewName($name);
$replace['parent_dummy_route'] = $this->getParentRouteName($name);
}
$replace['dummy_view'] = $this->getViewName($name);
$replace['dummy_route'] = $this->getRouteName($name);
return str_replace(array_keys($replace), array_values($replace), $this->files->get($this->getViewStub($method, $name)));
} | [
"protected",
"function",
"buildView",
"(",
"$",
"name",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"replace",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
")",
"{",
"$",
"replace",
"=",
"$",
"this",
"->",
"buildParentReplacements",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
")",
"{",
"$",
"replace",
"=",
"$",
"this",
"->",
"buildModelReplacements",
"(",
"$",
"replace",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
")",
"{",
"$",
"replace",
"[",
"'parent_dummy_view'",
"]",
"=",
"$",
"this",
"->",
"getParentViewName",
"(",
"$",
"name",
")",
";",
"$",
"replace",
"[",
"'parent_dummy_route'",
"]",
"=",
"$",
"this",
"->",
"getParentRouteName",
"(",
"$",
"name",
")",
";",
"}",
"$",
"replace",
"[",
"'dummy_view'",
"]",
"=",
"$",
"this",
"->",
"getViewName",
"(",
"$",
"name",
")",
";",
"$",
"replace",
"[",
"'dummy_route'",
"]",
"=",
"$",
"this",
"->",
"getRouteName",
"(",
"$",
"name",
")",
";",
"return",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replace",
")",
",",
"array_values",
"(",
"$",
"replace",
")",
",",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"this",
"->",
"getViewStub",
"(",
"$",
"method",
",",
"$",
"name",
")",
")",
")",
";",
"}"
] | Build the view with the given name.
@param string $name
@param string|null $method
@return string
@throws \Illuminate\Contracts\Filesystem\FileNotFoundException | [
"Build",
"the",
"view",
"with",
"the",
"given",
"name",
"."
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ControllerMakeCommand.php#L178-L198 |
28,860 | Atnic/laravel-generator | app/Console/Commands/ControllerMakeCommand.php | ControllerMakeCommand.generateView | protected function generateView()
{
if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
if ($this->option('parent')) {
$name = $this->qualifyClass('Model/ChildController');
} else {
$name = $this->qualifyClass('ModelController');
}
$path = $this->getViewPath($name);
if (!$this->files->exists(str_replace_last('.blade.php', '/index.blade.php', $path))) {
foreach ([ 'index', 'create', 'show', 'edit' ] as $key => $method) {
$this->makeDirectory(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path));
$this->files->put(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path), $this->buildView($name, $method));
}
}
}
$name = $this->qualifyClass($this->getNameInput());
$path = $this->getViewPath($name);
if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
foreach ([ 'index', 'create', 'show', 'edit' ] as $key => $method) {
$this->makeDirectory(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path));
$this->files->put(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path), $this->buildView($name, $method));
}
} else {
$this->makeDirectory($path);
$this->files->put($path, $this->buildView($name));
}
$this->info('View also generated successfully.');
} | php | protected function generateView()
{
if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
if ($this->option('parent')) {
$name = $this->qualifyClass('Model/ChildController');
} else {
$name = $this->qualifyClass('ModelController');
}
$path = $this->getViewPath($name);
if (!$this->files->exists(str_replace_last('.blade.php', '/index.blade.php', $path))) {
foreach ([ 'index', 'create', 'show', 'edit' ] as $key => $method) {
$this->makeDirectory(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path));
$this->files->put(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path), $this->buildView($name, $method));
}
}
}
$name = $this->qualifyClass($this->getNameInput());
$path = $this->getViewPath($name);
if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
foreach ([ 'index', 'create', 'show', 'edit' ] as $key => $method) {
$this->makeDirectory(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path));
$this->files->put(str_replace_last('.blade.php', '/' . $method . '.blade.php', $path), $this->buildView($name, $method));
}
} else {
$this->makeDirectory($path);
$this->files->put($path, $this->buildView($name));
}
$this->info('View also generated successfully.');
} | [
"protected",
"function",
"generateView",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'resource'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"'Model/ChildController'",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"'ModelController'",
")",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"getViewPath",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"str_replace_last",
"(",
"'.blade.php'",
",",
"'/index.blade.php'",
",",
"$",
"path",
")",
")",
")",
"{",
"foreach",
"(",
"[",
"'index'",
",",
"'create'",
",",
"'show'",
",",
"'edit'",
"]",
"as",
"$",
"key",
"=>",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"makeDirectory",
"(",
"str_replace_last",
"(",
"'.blade.php'",
",",
"'/'",
".",
"$",
"method",
".",
"'.blade.php'",
",",
"$",
"path",
")",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"str_replace_last",
"(",
"'.blade.php'",
",",
"'/'",
".",
"$",
"method",
".",
"'.blade.php'",
",",
"$",
"path",
")",
",",
"$",
"this",
"->",
"buildView",
"(",
"$",
"name",
",",
"$",
"method",
")",
")",
";",
"}",
"}",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getViewPath",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'resource'",
")",
")",
"{",
"foreach",
"(",
"[",
"'index'",
",",
"'create'",
",",
"'show'",
",",
"'edit'",
"]",
"as",
"$",
"key",
"=>",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"makeDirectory",
"(",
"str_replace_last",
"(",
"'.blade.php'",
",",
"'/'",
".",
"$",
"method",
".",
"'.blade.php'",
",",
"$",
"path",
")",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"str_replace_last",
"(",
"'.blade.php'",
",",
"'/'",
".",
"$",
"method",
".",
"'.blade.php'",
",",
"$",
"path",
")",
",",
"$",
"this",
"->",
"buildView",
"(",
"$",
"name",
",",
"$",
"method",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"makeDirectory",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"buildView",
"(",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"'View also generated successfully.'",
")",
";",
"}"
] | Generate View Files
@return void
@throws \Illuminate\Contracts\Filesystem\FileNotFoundException | [
"Generate",
"View",
"Files"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ControllerMakeCommand.php#L305-L337 |
28,861 | Atnic/laravel-generator | app/Console/Commands/ControllerMakeCommand.php | ControllerMakeCommand.appendRouteFile | protected function appendRouteFile()
{
$name = $this->qualifyClass($this->getNameInput());
$nameWithoutNamespace = str_replace($this->getDefaultNamespace(trim($this->rootNamespace(), '\\')).'\\', '', $name);
$file = $this->option('api') ? base_path('routes/api.php') : base_path('routes/web.php');
$routeName = $this->getRouteName($name);
$routePath = $this->getRoutePath($name);
$routeDefinition = 'Route::get(\''.$routePath.'\', \''.$nameWithoutNamespace.'\')->name(\''.$routeName.'\');'.PHP_EOL;
if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
$asExploded = explode('/', $routePath);
if (count($asExploded) > 1) {
array_pop($asExploded);
$as = implode('.', $asExploded);
if ($this->option('api'))
$routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \''.$as.'\' ]);'.PHP_EOL;
else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
} else {
if ($this->option('api'))
$routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \'api\' ]);'.PHP_EOL;
else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
}
}
file_put_contents($file, $routeDefinition, FILE_APPEND);
$this->warn($file.' modified.');
} | php | protected function appendRouteFile()
{
$name = $this->qualifyClass($this->getNameInput());
$nameWithoutNamespace = str_replace($this->getDefaultNamespace(trim($this->rootNamespace(), '\\')).'\\', '', $name);
$file = $this->option('api') ? base_path('routes/api.php') : base_path('routes/web.php');
$routeName = $this->getRouteName($name);
$routePath = $this->getRoutePath($name);
$routeDefinition = 'Route::get(\''.$routePath.'\', \''.$nameWithoutNamespace.'\')->name(\''.$routeName.'\');'.PHP_EOL;
if ($this->option('parent') || $this->option('model') || $this->option('resource')) {
$asExploded = explode('/', $routePath);
if (count($asExploded) > 1) {
array_pop($asExploded);
$as = implode('.', $asExploded);
if ($this->option('api'))
$routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \''.$as.'\' ]);'.PHP_EOL;
else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
} else {
if ($this->option('api'))
$routeDefinition = 'Route::apiResource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\', [ \'as\' => \'api\' ]);'.PHP_EOL;
else $routeDefinition = 'Route::resource(\''.$routePath.'\', \''.$nameWithoutNamespace.'\');'.PHP_EOL;
}
}
file_put_contents($file, $routeDefinition, FILE_APPEND);
$this->warn($file.' modified.');
} | [
"protected",
"function",
"appendRouteFile",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
";",
"$",
"nameWithoutNamespace",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"getDefaultNamespace",
"(",
"trim",
"(",
"$",
"this",
"->",
"rootNamespace",
"(",
")",
",",
"'\\\\'",
")",
")",
".",
"'\\\\'",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"option",
"(",
"'api'",
")",
"?",
"base_path",
"(",
"'routes/api.php'",
")",
":",
"base_path",
"(",
"'routes/web.php'",
")",
";",
"$",
"routeName",
"=",
"$",
"this",
"->",
"getRouteName",
"(",
"$",
"name",
")",
";",
"$",
"routePath",
"=",
"$",
"this",
"->",
"getRoutePath",
"(",
"$",
"name",
")",
";",
"$",
"routeDefinition",
"=",
"'Route::get(\\''",
".",
"$",
"routePath",
".",
"'\\', \\''",
".",
"$",
"nameWithoutNamespace",
".",
"'\\')->name(\\''",
".",
"$",
"routeName",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'model'",
")",
"||",
"$",
"this",
"->",
"option",
"(",
"'resource'",
")",
")",
"{",
"$",
"asExploded",
"=",
"explode",
"(",
"'/'",
",",
"$",
"routePath",
")",
";",
"if",
"(",
"count",
"(",
"$",
"asExploded",
")",
">",
"1",
")",
"{",
"array_pop",
"(",
"$",
"asExploded",
")",
";",
"$",
"as",
"=",
"implode",
"(",
"'.'",
",",
"$",
"asExploded",
")",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'api'",
")",
")",
"$",
"routeDefinition",
"=",
"'Route::apiResource(\\''",
".",
"$",
"routePath",
".",
"'\\', \\''",
".",
"$",
"nameWithoutNamespace",
".",
"'\\', [ \\'as\\' => \\''",
".",
"$",
"as",
".",
"'\\' ]);'",
".",
"PHP_EOL",
";",
"else",
"$",
"routeDefinition",
"=",
"'Route::resource(\\''",
".",
"$",
"routePath",
".",
"'\\', \\''",
".",
"$",
"nameWithoutNamespace",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'api'",
")",
")",
"$",
"routeDefinition",
"=",
"'Route::apiResource(\\''",
".",
"$",
"routePath",
".",
"'\\', \\''",
".",
"$",
"nameWithoutNamespace",
".",
"'\\', [ \\'as\\' => \\'api\\' ]);'",
".",
"PHP_EOL",
";",
"else",
"$",
"routeDefinition",
"=",
"'Route::resource(\\''",
".",
"$",
"routePath",
".",
"'\\', \\''",
".",
"$",
"nameWithoutNamespace",
".",
"'\\');'",
".",
"PHP_EOL",
";",
"}",
"}",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"routeDefinition",
",",
"FILE_APPEND",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"$",
"file",
".",
"' modified.'",
")",
";",
"}"
] | Append Route Files
@return void | [
"Append",
"Route",
"Files"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ControllerMakeCommand.php#L343-L372 |
28,862 | Atnic/laravel-generator | app/Console/Commands/ControllerMakeCommand.php | ControllerMakeCommand.getParentViewName | protected function getParentViewName($name)
{
$name = Str::replaceFirst($this->getDefaultNamespace(trim($this->rootNamespace(), '\\')).'\\', '', $name);
$name = Str::replaceLast('Controller', '', $name);
$names = explode('\\', $name);
foreach ($names as $key => $value) {
$names[$key] = snake_case($value);
}
if (count($names) >= 2) {
array_pop($names);
$parent = str_plural(array_pop($names));
array_push($names, $parent);
}
$name = implode('.', $names);
return str_replace('\\', '.', $name);
} | php | protected function getParentViewName($name)
{
$name = Str::replaceFirst($this->getDefaultNamespace(trim($this->rootNamespace(), '\\')).'\\', '', $name);
$name = Str::replaceLast('Controller', '', $name);
$names = explode('\\', $name);
foreach ($names as $key => $value) {
$names[$key] = snake_case($value);
}
if (count($names) >= 2) {
array_pop($names);
$parent = str_plural(array_pop($names));
array_push($names, $parent);
}
$name = implode('.', $names);
return str_replace('\\', '.', $name);
} | [
"protected",
"function",
"getParentViewName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"Str",
"::",
"replaceFirst",
"(",
"$",
"this",
"->",
"getDefaultNamespace",
"(",
"trim",
"(",
"$",
"this",
"->",
"rootNamespace",
"(",
")",
",",
"'\\\\'",
")",
")",
".",
"'\\\\'",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"Str",
"::",
"replaceLast",
"(",
"'Controller'",
",",
"''",
",",
"$",
"name",
")",
";",
"$",
"names",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"names",
"[",
"$",
"key",
"]",
"=",
"snake_case",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"names",
")",
">=",
"2",
")",
"{",
"array_pop",
"(",
"$",
"names",
")",
";",
"$",
"parent",
"=",
"str_plural",
"(",
"array_pop",
"(",
"$",
"names",
")",
")",
";",
"array_push",
"(",
"$",
"names",
",",
"$",
"parent",
")",
";",
"}",
"$",
"name",
"=",
"implode",
"(",
"'.'",
",",
"$",
"names",
")",
";",
"return",
"str_replace",
"(",
"'\\\\'",
",",
"'.'",
",",
"$",
"name",
")",
";",
"}"
] | Get the view name.
@param string $name
@return string | [
"Get",
"the",
"view",
"name",
"."
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ControllerMakeCommand.php#L407-L423 |
28,863 | alaxos/cakephp3-libs | src/Model/Behavior/AncestorBehavior.php | AncestorBehavior.getAncestorTable | public function getAncestorTable()
{
$ancestor_table = TableRegistry::get('Alaxos.Ancestors');
$table_name = $this->getConfig('ancestor_table_name');
$ancestor_table->setTable($table_name);
return $ancestor_table;
} | php | public function getAncestorTable()
{
$ancestor_table = TableRegistry::get('Alaxos.Ancestors');
$table_name = $this->getConfig('ancestor_table_name');
$ancestor_table->setTable($table_name);
return $ancestor_table;
} | [
"public",
"function",
"getAncestorTable",
"(",
")",
"{",
"$",
"ancestor_table",
"=",
"TableRegistry",
"::",
"get",
"(",
"'Alaxos.Ancestors'",
")",
";",
"$",
"table_name",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'ancestor_table_name'",
")",
";",
"$",
"ancestor_table",
"->",
"setTable",
"(",
"$",
"table_name",
")",
";",
"return",
"$",
"ancestor_table",
";",
"}"
] | Get the Table for the linked ancestors table
@return @return \Cake\ORM\Table | [
"Get",
"the",
"Table",
"for",
"the",
"linked",
"ancestors",
"table"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Model/Behavior/AncestorBehavior.php#L273-L281 |
28,864 | alaxos/cakephp3-libs | src/Model/Behavior/AncestorBehavior.php | AncestorBehavior.getMultilevelChildren | public function getMultilevelChildren($id, array $options = [])
{
$options['for'] = $id;
$options['direct'] = false;
$options['for'] = $id;
$options['direct'] = false;
$query = $this->_table->find();
$iterator = $this->findChildren($query, $options);
$primaryKey = $this->_table->getSchema()->primaryKey();
$primaryKey = count($primaryKey) == 1 ? $primaryKey[0] : $primaryKey;
$parent_id_fieldname = $this->getConfig('model_parent_id_fieldname');
$nodes_by_pk = [];
$root_nodes = [];
foreach($iterator as $node)
{
$nodes_by_pk[$node->{$primaryKey}] = $node;
if($node->{$parent_id_fieldname} == $id)
{
$root_nodes[] = $node;
}
if(isset($nodes_by_pk[$node->{$parent_id_fieldname}]))
{
if(!isset($nodes_by_pk[$node->{$parent_id_fieldname}]->children))
{
$nodes_by_pk[$node->{$parent_id_fieldname}]->children = [];
}
$nodes_by_pk[$node->{$parent_id_fieldname}]->children[] = $node;
}
}
unset($node);
return new \Cake\Collection\Collection($root_nodes);
} | php | public function getMultilevelChildren($id, array $options = [])
{
$options['for'] = $id;
$options['direct'] = false;
$options['for'] = $id;
$options['direct'] = false;
$query = $this->_table->find();
$iterator = $this->findChildren($query, $options);
$primaryKey = $this->_table->getSchema()->primaryKey();
$primaryKey = count($primaryKey) == 1 ? $primaryKey[0] : $primaryKey;
$parent_id_fieldname = $this->getConfig('model_parent_id_fieldname');
$nodes_by_pk = [];
$root_nodes = [];
foreach($iterator as $node)
{
$nodes_by_pk[$node->{$primaryKey}] = $node;
if($node->{$parent_id_fieldname} == $id)
{
$root_nodes[] = $node;
}
if(isset($nodes_by_pk[$node->{$parent_id_fieldname}]))
{
if(!isset($nodes_by_pk[$node->{$parent_id_fieldname}]->children))
{
$nodes_by_pk[$node->{$parent_id_fieldname}]->children = [];
}
$nodes_by_pk[$node->{$parent_id_fieldname}]->children[] = $node;
}
}
unset($node);
return new \Cake\Collection\Collection($root_nodes);
} | [
"public",
"function",
"getMultilevelChildren",
"(",
"$",
"id",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"[",
"'for'",
"]",
"=",
"$",
"id",
";",
"$",
"options",
"[",
"'direct'",
"]",
"=",
"false",
";",
"$",
"options",
"[",
"'for'",
"]",
"=",
"$",
"id",
";",
"$",
"options",
"[",
"'direct'",
"]",
"=",
"false",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"_table",
"->",
"find",
"(",
")",
";",
"$",
"iterator",
"=",
"$",
"this",
"->",
"findChildren",
"(",
"$",
"query",
",",
"$",
"options",
")",
";",
"$",
"primaryKey",
"=",
"$",
"this",
"->",
"_table",
"->",
"getSchema",
"(",
")",
"->",
"primaryKey",
"(",
")",
";",
"$",
"primaryKey",
"=",
"count",
"(",
"$",
"primaryKey",
")",
"==",
"1",
"?",
"$",
"primaryKey",
"[",
"0",
"]",
":",
"$",
"primaryKey",
";",
"$",
"parent_id_fieldname",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'model_parent_id_fieldname'",
")",
";",
"$",
"nodes_by_pk",
"=",
"[",
"]",
";",
"$",
"root_nodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"node",
")",
"{",
"$",
"nodes_by_pk",
"[",
"$",
"node",
"->",
"{",
"$",
"primaryKey",
"}",
"]",
"=",
"$",
"node",
";",
"if",
"(",
"$",
"node",
"->",
"{",
"$",
"parent_id_fieldname",
"}",
"==",
"$",
"id",
")",
"{",
"$",
"root_nodes",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"nodes_by_pk",
"[",
"$",
"node",
"->",
"{",
"$",
"parent_id_fieldname",
"}",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"nodes_by_pk",
"[",
"$",
"node",
"->",
"{",
"$",
"parent_id_fieldname",
"}",
"]",
"->",
"children",
")",
")",
"{",
"$",
"nodes_by_pk",
"[",
"$",
"node",
"->",
"{",
"$",
"parent_id_fieldname",
"}",
"]",
"->",
"children",
"=",
"[",
"]",
";",
"}",
"$",
"nodes_by_pk",
"[",
"$",
"node",
"->",
"{",
"$",
"parent_id_fieldname",
"}",
"]",
"->",
"children",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"}",
"unset",
"(",
"$",
"node",
")",
";",
"return",
"new",
"\\",
"Cake",
"\\",
"Collection",
"\\",
"Collection",
"(",
"$",
"root_nodes",
")",
";",
"}"
] | Return a multi-dimension array of child nodes
@param int $id
@param array $options
@return \Cake\Collection\Collection | [
"Return",
"a",
"multi",
"-",
"dimension",
"array",
"of",
"child",
"nodes"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Model/Behavior/AncestorBehavior.php#L627-L668 |
28,865 | alaxos/cakephp3-libs | src/Model/Behavior/AncestorBehavior.php | AncestorBehavior.moveNode | public function moveNode($id, $parent_id, $position = null)
{
$primaryKey = $this->_table->getSchema()->primaryKey();
$primaryKey = count($primaryKey) == 1 ? $primaryKey[0] : $primaryKey;
$parent_id_fieldname = $this->getConfig('model_parent_id_fieldname');
$sort_fieldname = $this->getConfig('model_sort_fieldname');
$connection = $this->_table->getConnection();
$connection->begin();
$result = true;
/*
* Get moved node
*/
$node = $this->_table->get($id);
/*
* Get current nodes positions of (new) siblings
*/
$current_children = $this->_table->query()->where([$parent_id_fieldname => $parent_id])->order([$sort_fieldname => 'asc']);
$new_sort_children = [];
foreach($current_children as $current_position => $current_child)
{
if($current_child->{$primaryKey} != $id)
{
$new_sort_children[] = $current_child;
}
}
/*
* Default position is after all siblings
*/
$position = isset($position) ? $position : $current_children->count();
$position = $position >= 0 ? $position : 0;
$position = $position <= count($new_sort_children) ? $position : count($new_sort_children);
/*
* Insert moved node at position
*/
array_splice($new_sort_children, $position, 0, array($node));
/*
* If node has a new parent -> save it
*/
if($node->{$parent_id_fieldname} != $parent_id)
{
$query = $this->_table->query()->update()->set([$parent_id_fieldname => $parent_id])->where([$primaryKey => $id]);
if(!$query->execute())
{
$result = false;
}
}
/*
* Update positions
*/
foreach($new_sort_children as $index => $new_sort_child)
{
$query = $this->_table->query()->update()->set([$sort_fieldname => ($index * 10)])->where([$primaryKey => $new_sort_child->{$primaryKey}]);
if(!$query->execute())
{
$result = false;
}
}
/***********/
if($result)
{
$connection->commit();
}
else
{
$connection->rollback();
}
return $result;
} | php | public function moveNode($id, $parent_id, $position = null)
{
$primaryKey = $this->_table->getSchema()->primaryKey();
$primaryKey = count($primaryKey) == 1 ? $primaryKey[0] : $primaryKey;
$parent_id_fieldname = $this->getConfig('model_parent_id_fieldname');
$sort_fieldname = $this->getConfig('model_sort_fieldname');
$connection = $this->_table->getConnection();
$connection->begin();
$result = true;
/*
* Get moved node
*/
$node = $this->_table->get($id);
/*
* Get current nodes positions of (new) siblings
*/
$current_children = $this->_table->query()->where([$parent_id_fieldname => $parent_id])->order([$sort_fieldname => 'asc']);
$new_sort_children = [];
foreach($current_children as $current_position => $current_child)
{
if($current_child->{$primaryKey} != $id)
{
$new_sort_children[] = $current_child;
}
}
/*
* Default position is after all siblings
*/
$position = isset($position) ? $position : $current_children->count();
$position = $position >= 0 ? $position : 0;
$position = $position <= count($new_sort_children) ? $position : count($new_sort_children);
/*
* Insert moved node at position
*/
array_splice($new_sort_children, $position, 0, array($node));
/*
* If node has a new parent -> save it
*/
if($node->{$parent_id_fieldname} != $parent_id)
{
$query = $this->_table->query()->update()->set([$parent_id_fieldname => $parent_id])->where([$primaryKey => $id]);
if(!$query->execute())
{
$result = false;
}
}
/*
* Update positions
*/
foreach($new_sort_children as $index => $new_sort_child)
{
$query = $this->_table->query()->update()->set([$sort_fieldname => ($index * 10)])->where([$primaryKey => $new_sort_child->{$primaryKey}]);
if(!$query->execute())
{
$result = false;
}
}
/***********/
if($result)
{
$connection->commit();
}
else
{
$connection->rollback();
}
return $result;
} | [
"public",
"function",
"moveNode",
"(",
"$",
"id",
",",
"$",
"parent_id",
",",
"$",
"position",
"=",
"null",
")",
"{",
"$",
"primaryKey",
"=",
"$",
"this",
"->",
"_table",
"->",
"getSchema",
"(",
")",
"->",
"primaryKey",
"(",
")",
";",
"$",
"primaryKey",
"=",
"count",
"(",
"$",
"primaryKey",
")",
"==",
"1",
"?",
"$",
"primaryKey",
"[",
"0",
"]",
":",
"$",
"primaryKey",
";",
"$",
"parent_id_fieldname",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'model_parent_id_fieldname'",
")",
";",
"$",
"sort_fieldname",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'model_sort_fieldname'",
")",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"_table",
"->",
"getConnection",
"(",
")",
";",
"$",
"connection",
"->",
"begin",
"(",
")",
";",
"$",
"result",
"=",
"true",
";",
"/*\n\t\t * Get moved node\n\t\t */",
"$",
"node",
"=",
"$",
"this",
"->",
"_table",
"->",
"get",
"(",
"$",
"id",
")",
";",
"/*\n\t\t * Get current nodes positions of (new) siblings\n\t\t */",
"$",
"current_children",
"=",
"$",
"this",
"->",
"_table",
"->",
"query",
"(",
")",
"->",
"where",
"(",
"[",
"$",
"parent_id_fieldname",
"=>",
"$",
"parent_id",
"]",
")",
"->",
"order",
"(",
"[",
"$",
"sort_fieldname",
"=>",
"'asc'",
"]",
")",
";",
"$",
"new_sort_children",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"current_children",
"as",
"$",
"current_position",
"=>",
"$",
"current_child",
")",
"{",
"if",
"(",
"$",
"current_child",
"->",
"{",
"$",
"primaryKey",
"}",
"!=",
"$",
"id",
")",
"{",
"$",
"new_sort_children",
"[",
"]",
"=",
"$",
"current_child",
";",
"}",
"}",
"/*\n\t\t * Default position is after all siblings\n\t\t */",
"$",
"position",
"=",
"isset",
"(",
"$",
"position",
")",
"?",
"$",
"position",
":",
"$",
"current_children",
"->",
"count",
"(",
")",
";",
"$",
"position",
"=",
"$",
"position",
">=",
"0",
"?",
"$",
"position",
":",
"0",
";",
"$",
"position",
"=",
"$",
"position",
"<=",
"count",
"(",
"$",
"new_sort_children",
")",
"?",
"$",
"position",
":",
"count",
"(",
"$",
"new_sort_children",
")",
";",
"/*\n\t\t * Insert moved node at position\n\t\t */",
"array_splice",
"(",
"$",
"new_sort_children",
",",
"$",
"position",
",",
"0",
",",
"array",
"(",
"$",
"node",
")",
")",
";",
"/*\n\t\t * If node has a new parent -> save it\n\t\t */",
"if",
"(",
"$",
"node",
"->",
"{",
"$",
"parent_id_fieldname",
"}",
"!=",
"$",
"parent_id",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_table",
"->",
"query",
"(",
")",
"->",
"update",
"(",
")",
"->",
"set",
"(",
"[",
"$",
"parent_id_fieldname",
"=>",
"$",
"parent_id",
"]",
")",
"->",
"where",
"(",
"[",
"$",
"primaryKey",
"=>",
"$",
"id",
"]",
")",
";",
"if",
"(",
"!",
"$",
"query",
"->",
"execute",
"(",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"}",
"/*\n\t\t * Update positions\n\t\t */",
"foreach",
"(",
"$",
"new_sort_children",
"as",
"$",
"index",
"=>",
"$",
"new_sort_child",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_table",
"->",
"query",
"(",
")",
"->",
"update",
"(",
")",
"->",
"set",
"(",
"[",
"$",
"sort_fieldname",
"=>",
"(",
"$",
"index",
"*",
"10",
")",
"]",
")",
"->",
"where",
"(",
"[",
"$",
"primaryKey",
"=>",
"$",
"new_sort_child",
"->",
"{",
"$",
"primaryKey",
"}",
"]",
")",
";",
"if",
"(",
"!",
"$",
"query",
"->",
"execute",
"(",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"}",
"/***********/",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"}",
"else",
"{",
"$",
"connection",
"->",
"rollback",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Move a node under the same parent node or under a new node.
New position of the node can be specified
@param int $id ID of the node to move
@param int $parent_id ID of the (new) parent node
@param int $position New position of the node. Position is zero based.
@return boolean | [
"Move",
"a",
"node",
"under",
"the",
"same",
"parent",
"node",
"or",
"under",
"a",
"new",
"node",
".",
"New",
"position",
"of",
"the",
"node",
"can",
"be",
"specified"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Model/Behavior/AncestorBehavior.php#L698-L779 |
28,866 | smartboxgroup/integration-framework-bundle | Core/Handlers/MessageHandler.php | MessageHandler.dispatchEvent | protected function dispatchEvent(Exchange $exchange, $eventName)
{
$event = new HandlerEvent($eventName);
$event->setTimestampToCurrent();
$event->setExchange($exchange);
$this->eventDispatcher->dispatch($eventName, $event);
} | php | protected function dispatchEvent(Exchange $exchange, $eventName)
{
$event = new HandlerEvent($eventName);
$event->setTimestampToCurrent();
$event->setExchange($exchange);
$this->eventDispatcher->dispatch($eventName, $event);
} | [
"protected",
"function",
"dispatchEvent",
"(",
"Exchange",
"$",
"exchange",
",",
"$",
"eventName",
")",
"{",
"$",
"event",
"=",
"new",
"HandlerEvent",
"(",
"$",
"eventName",
")",
";",
"$",
"event",
"->",
"setTimestampToCurrent",
"(",
")",
";",
"$",
"event",
"->",
"setExchange",
"(",
"$",
"exchange",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"$",
"eventName",
",",
"$",
"event",
")",
";",
"}"
] | Dispatch handler event depending on an event name
@param Exchange $exchange
@param $eventName | [
"Dispatch",
"handler",
"event",
"depending",
"on",
"an",
"event",
"name"
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Handlers/MessageHandler.php#L309-L315 |
28,867 | smartboxgroup/integration-framework-bundle | Core/Handlers/MessageHandler.php | MessageHandler.addCallbackHeadersToEnvelope | private function addCallbackHeadersToEnvelope(CallbackExchangeEnvelope $envelope, ProcessingException $exception, ProcessorInterface $processor)
{
$originalException = $exception->getOriginalException();
$errorDescription = $originalException ? $originalException->getMessage() : $exception->getMessage();
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_CREATED_AT, round(microtime(true) * 1000));
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_ERROR_MESSAGE, $errorDescription);
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_ERROR_PROCESSOR_ID, $processor->getId());
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_ERROR_PROCESSOR_DESCRIPTION, $processor->getDescription());
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_STATUS_CODE, $originalException->getCode());
} | php | private function addCallbackHeadersToEnvelope(CallbackExchangeEnvelope $envelope, ProcessingException $exception, ProcessorInterface $processor)
{
$originalException = $exception->getOriginalException();
$errorDescription = $originalException ? $originalException->getMessage() : $exception->getMessage();
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_CREATED_AT, round(microtime(true) * 1000));
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_ERROR_MESSAGE, $errorDescription);
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_ERROR_PROCESSOR_ID, $processor->getId());
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_ERROR_PROCESSOR_DESCRIPTION, $processor->getDescription());
$envelope->setHeader(CallbackExchangeEnvelope::HEADER_STATUS_CODE, $originalException->getCode());
} | [
"private",
"function",
"addCallbackHeadersToEnvelope",
"(",
"CallbackExchangeEnvelope",
"$",
"envelope",
",",
"ProcessingException",
"$",
"exception",
",",
"ProcessorInterface",
"$",
"processor",
")",
"{",
"$",
"originalException",
"=",
"$",
"exception",
"->",
"getOriginalException",
"(",
")",
";",
"$",
"errorDescription",
"=",
"$",
"originalException",
"?",
"$",
"originalException",
"->",
"getMessage",
"(",
")",
":",
"$",
"exception",
"->",
"getMessage",
"(",
")",
";",
"$",
"envelope",
"->",
"setHeader",
"(",
"CallbackExchangeEnvelope",
"::",
"HEADER_CREATED_AT",
",",
"round",
"(",
"microtime",
"(",
"true",
")",
"*",
"1000",
")",
")",
";",
"$",
"envelope",
"->",
"setHeader",
"(",
"CallbackExchangeEnvelope",
"::",
"HEADER_ERROR_MESSAGE",
",",
"$",
"errorDescription",
")",
";",
"$",
"envelope",
"->",
"setHeader",
"(",
"CallbackExchangeEnvelope",
"::",
"HEADER_ERROR_PROCESSOR_ID",
",",
"$",
"processor",
"->",
"getId",
"(",
")",
")",
";",
"$",
"envelope",
"->",
"setHeader",
"(",
"CallbackExchangeEnvelope",
"::",
"HEADER_ERROR_PROCESSOR_DESCRIPTION",
",",
"$",
"processor",
"->",
"getDescription",
"(",
")",
")",
";",
"$",
"envelope",
"->",
"setHeader",
"(",
"CallbackExchangeEnvelope",
"::",
"HEADER_STATUS_CODE",
",",
"$",
"originalException",
"->",
"getCode",
"(",
")",
")",
";",
"}"
] | This method adds headers to the Envelope that we put the Callback exchange into, this is so that the
consumer of the has information to do deal with it.
- add the last error message and the time the error happened
- add information about the processor that was being used when the event occurred
@param CallbackExchangeEnvelope $envelope
@param ProcessingException $exception
@param ProcessorInterface $processor | [
"This",
"method",
"adds",
"headers",
"to",
"the",
"Envelope",
"that",
"we",
"put",
"the",
"Callback",
"exchange",
"into",
"this",
"is",
"so",
"that",
"the",
"consumer",
"of",
"the",
"has",
"information",
"to",
"do",
"deal",
"with",
"it",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Handlers/MessageHandler.php#L506-L516 |
28,868 | smartboxgroup/integration-framework-bundle | Core/Handlers/MessageHandler.php | MessageHandler.handle | public function handle(MessageInterface $message, EndpointInterface $endpointFrom)
{
$retries = 0;
// If this is an exchange envelope, we extract the old exchange and prepare the new one
if ($message && $message instanceof ExchangeEnvelope) {
$oldExchange = $message->getBody();
$exchange = new Exchange($oldExchange->getIn(), $oldExchange->getItinerary(), $oldExchange->getHeaders());
if ($message instanceof RetryExchangeEnvelope) {
$retries = $message->getRetries();
$delaySinceLastRetry = round(microtime(true) * 1000) - $message->getHeader(RetryExchangeEnvelope::HEADER_LAST_RETRY_AT);
$retryDelay = $message->getHeader(RetryExchangeEnvelope::HEADER_RETRY_DELAY) * 1000;
$endpointURI = $message instanceof ThrottledExchangeEnvelope ? $this->throttleURI : $this->retryURI;
if ($delaySinceLastRetry < $retryDelay) {
$this->deferExchangeMessage($message, $endpointURI);
return;
}
}
}
// Otherwise create the exchange
else {
$exchange = $this->createExchangeForMessageFromURI($message, $endpointFrom->getURI());
}
$this->onHandleStart($exchange);
$result = $this->processExchange($exchange, $retries);
$this->onHandleSuccess($exchange);
return $result;
} | php | public function handle(MessageInterface $message, EndpointInterface $endpointFrom)
{
$retries = 0;
// If this is an exchange envelope, we extract the old exchange and prepare the new one
if ($message && $message instanceof ExchangeEnvelope) {
$oldExchange = $message->getBody();
$exchange = new Exchange($oldExchange->getIn(), $oldExchange->getItinerary(), $oldExchange->getHeaders());
if ($message instanceof RetryExchangeEnvelope) {
$retries = $message->getRetries();
$delaySinceLastRetry = round(microtime(true) * 1000) - $message->getHeader(RetryExchangeEnvelope::HEADER_LAST_RETRY_AT);
$retryDelay = $message->getHeader(RetryExchangeEnvelope::HEADER_RETRY_DELAY) * 1000;
$endpointURI = $message instanceof ThrottledExchangeEnvelope ? $this->throttleURI : $this->retryURI;
if ($delaySinceLastRetry < $retryDelay) {
$this->deferExchangeMessage($message, $endpointURI);
return;
}
}
}
// Otherwise create the exchange
else {
$exchange = $this->createExchangeForMessageFromURI($message, $endpointFrom->getURI());
}
$this->onHandleStart($exchange);
$result = $this->processExchange($exchange, $retries);
$this->onHandleSuccess($exchange);
return $result;
} | [
"public",
"function",
"handle",
"(",
"MessageInterface",
"$",
"message",
",",
"EndpointInterface",
"$",
"endpointFrom",
")",
"{",
"$",
"retries",
"=",
"0",
";",
"// If this is an exchange envelope, we extract the old exchange and prepare the new one",
"if",
"(",
"$",
"message",
"&&",
"$",
"message",
"instanceof",
"ExchangeEnvelope",
")",
"{",
"$",
"oldExchange",
"=",
"$",
"message",
"->",
"getBody",
"(",
")",
";",
"$",
"exchange",
"=",
"new",
"Exchange",
"(",
"$",
"oldExchange",
"->",
"getIn",
"(",
")",
",",
"$",
"oldExchange",
"->",
"getItinerary",
"(",
")",
",",
"$",
"oldExchange",
"->",
"getHeaders",
"(",
")",
")",
";",
"if",
"(",
"$",
"message",
"instanceof",
"RetryExchangeEnvelope",
")",
"{",
"$",
"retries",
"=",
"$",
"message",
"->",
"getRetries",
"(",
")",
";",
"$",
"delaySinceLastRetry",
"=",
"round",
"(",
"microtime",
"(",
"true",
")",
"*",
"1000",
")",
"-",
"$",
"message",
"->",
"getHeader",
"(",
"RetryExchangeEnvelope",
"::",
"HEADER_LAST_RETRY_AT",
")",
";",
"$",
"retryDelay",
"=",
"$",
"message",
"->",
"getHeader",
"(",
"RetryExchangeEnvelope",
"::",
"HEADER_RETRY_DELAY",
")",
"*",
"1000",
";",
"$",
"endpointURI",
"=",
"$",
"message",
"instanceof",
"ThrottledExchangeEnvelope",
"?",
"$",
"this",
"->",
"throttleURI",
":",
"$",
"this",
"->",
"retryURI",
";",
"if",
"(",
"$",
"delaySinceLastRetry",
"<",
"$",
"retryDelay",
")",
"{",
"$",
"this",
"->",
"deferExchangeMessage",
"(",
"$",
"message",
",",
"$",
"endpointURI",
")",
";",
"return",
";",
"}",
"}",
"}",
"// Otherwise create the exchange",
"else",
"{",
"$",
"exchange",
"=",
"$",
"this",
"->",
"createExchangeForMessageFromURI",
"(",
"$",
"message",
",",
"$",
"endpointFrom",
"->",
"getURI",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"onHandleStart",
"(",
"$",
"exchange",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"processExchange",
"(",
"$",
"exchange",
",",
"$",
"retries",
")",
";",
"$",
"this",
"->",
"onHandleSuccess",
"(",
"$",
"exchange",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Handle a message.
If the message is a retryable message and the message is not ready to be processed yet, we will re-defer the message.
Otherwise process the message by putting it as part of an exchange, and processing the exchange.
{@inheritdoc} | [
"Handle",
"a",
"message",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Handlers/MessageHandler.php#L526-L557 |
28,869 | smartboxgroup/integration-framework-bundle | Core/Handlers/MessageHandler.php | MessageHandler.deferExchangeMessage | public function deferExchangeMessage(ExchangeEnvelope $deferredExchange, $endpointURI = null)
{
$exchange = new Exchange($deferredExchange);
if (!$endpointURI) {
$oldExchange = $deferredExchange->getBody();
$endpointURI = $oldExchange->getHeader(Exchange::HEADER_FROM);
}
$endpoint = $this->getEndpointFactory()->createEndpoint($endpointURI, EndpointFactory::MODE_PRODUCE);
$endpoint->produce($exchange);
} | php | public function deferExchangeMessage(ExchangeEnvelope $deferredExchange, $endpointURI = null)
{
$exchange = new Exchange($deferredExchange);
if (!$endpointURI) {
$oldExchange = $deferredExchange->getBody();
$endpointURI = $oldExchange->getHeader(Exchange::HEADER_FROM);
}
$endpoint = $this->getEndpointFactory()->createEndpoint($endpointURI, EndpointFactory::MODE_PRODUCE);
$endpoint->produce($exchange);
} | [
"public",
"function",
"deferExchangeMessage",
"(",
"ExchangeEnvelope",
"$",
"deferredExchange",
",",
"$",
"endpointURI",
"=",
"null",
")",
"{",
"$",
"exchange",
"=",
"new",
"Exchange",
"(",
"$",
"deferredExchange",
")",
";",
"if",
"(",
"!",
"$",
"endpointURI",
")",
"{",
"$",
"oldExchange",
"=",
"$",
"deferredExchange",
"->",
"getBody",
"(",
")",
";",
"$",
"endpointURI",
"=",
"$",
"oldExchange",
"->",
"getHeader",
"(",
"Exchange",
"::",
"HEADER_FROM",
")",
";",
"}",
"$",
"endpoint",
"=",
"$",
"this",
"->",
"getEndpointFactory",
"(",
")",
"->",
"createEndpoint",
"(",
"$",
"endpointURI",
",",
"EndpointFactory",
"::",
"MODE_PRODUCE",
")",
";",
"$",
"endpoint",
"->",
"produce",
"(",
"$",
"exchange",
")",
";",
"}"
] | Defer and ExchangeEnvelope to an endpoint
If no endpoint is defined then look inside the envelope for the exchange and use original endpoint.
@param ExchangeEnvelope $deferredExchange
@param null $endpointURI | [
"Defer",
"and",
"ExchangeEnvelope",
"to",
"an",
"endpoint",
"If",
"no",
"endpoint",
"is",
"defined",
"then",
"look",
"inside",
"the",
"envelope",
"for",
"the",
"exchange",
"and",
"use",
"original",
"endpoint",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Handlers/MessageHandler.php#L656-L668 |
28,870 | netgen/site-bundle | bundle/Controller/FullViewController.php | FullViewController.viewNgCategory | public function viewNgCategory(Request $request, ContentView $view, array $params = [])
{
$content = $view->getSiteContent();
$location = $view->getSiteLocation();
if (!$location instanceof Location) {
$location = $content->mainLocation;
}
$response = $this->checkCategoryRedirect($location);
if ($response instanceof Response) {
return $response;
}
$criteria = [
new Criterion\Subtree($location->pathString),
new Criterion\Visibility(Criterion\Visibility::VISIBLE),
new Criterion\LogicalNot(new Criterion\LocationId($location->id)),
];
if (!$content->getField('fetch_subtree')->value->bool) {
$criteria[] = new Criterion\Location\Depth(Criterion\Operator::EQ, $location->depth + 1);
}
if (!$content->getField('children_class_filter_include')->isEmpty()) {
$contentTypeFilter = $content->getField('children_class_filter_include')->value;
$criteria[] = new Criterion\ContentTypeIdentifier(
array_map(
'trim',
explode(',', $contentTypeFilter->text)
)
);
}
$query = new LocationQuery();
$query->filter = new Criterion\LogicalAnd($criteria);
$query->sortClauses = $location->innerLocation->getSortClauses();
$pager = new Pagerfanta(
new FilterAdapter(
$query,
$this->getSite()->getFilterService()
)
);
$pager->setNormalizeOutOfRangePages(true);
/** @var \eZ\Publish\Core\FieldType\Integer\Value $pageLimitValue */
$pageLimitValue = $content->getField('page_limit')->value;
$defaultLimit = 12;
$childrenLimit = (int) ($params['childrenLimit'] ?? $defaultLimit);
$childrenLimit = $childrenLimit > 0 ? $childrenLimit : $defaultLimit;
$pager->setMaxPerPage($pageLimitValue->value > 0 ? (int) $pageLimitValue->value : $childrenLimit);
$currentPage = (int) $request->get('page', 1);
$pager->setCurrentPage($currentPage > 0 ? $currentPage : 1);
$view->addParameters([
'pager' => $pager,
]);
return $view;
} | php | public function viewNgCategory(Request $request, ContentView $view, array $params = [])
{
$content = $view->getSiteContent();
$location = $view->getSiteLocation();
if (!$location instanceof Location) {
$location = $content->mainLocation;
}
$response = $this->checkCategoryRedirect($location);
if ($response instanceof Response) {
return $response;
}
$criteria = [
new Criterion\Subtree($location->pathString),
new Criterion\Visibility(Criterion\Visibility::VISIBLE),
new Criterion\LogicalNot(new Criterion\LocationId($location->id)),
];
if (!$content->getField('fetch_subtree')->value->bool) {
$criteria[] = new Criterion\Location\Depth(Criterion\Operator::EQ, $location->depth + 1);
}
if (!$content->getField('children_class_filter_include')->isEmpty()) {
$contentTypeFilter = $content->getField('children_class_filter_include')->value;
$criteria[] = new Criterion\ContentTypeIdentifier(
array_map(
'trim',
explode(',', $contentTypeFilter->text)
)
);
}
$query = new LocationQuery();
$query->filter = new Criterion\LogicalAnd($criteria);
$query->sortClauses = $location->innerLocation->getSortClauses();
$pager = new Pagerfanta(
new FilterAdapter(
$query,
$this->getSite()->getFilterService()
)
);
$pager->setNormalizeOutOfRangePages(true);
/** @var \eZ\Publish\Core\FieldType\Integer\Value $pageLimitValue */
$pageLimitValue = $content->getField('page_limit')->value;
$defaultLimit = 12;
$childrenLimit = (int) ($params['childrenLimit'] ?? $defaultLimit);
$childrenLimit = $childrenLimit > 0 ? $childrenLimit : $defaultLimit;
$pager->setMaxPerPage($pageLimitValue->value > 0 ? (int) $pageLimitValue->value : $childrenLimit);
$currentPage = (int) $request->get('page', 1);
$pager->setCurrentPage($currentPage > 0 ? $currentPage : 1);
$view->addParameters([
'pager' => $pager,
]);
return $view;
} | [
"public",
"function",
"viewNgCategory",
"(",
"Request",
"$",
"request",
",",
"ContentView",
"$",
"view",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"content",
"=",
"$",
"view",
"->",
"getSiteContent",
"(",
")",
";",
"$",
"location",
"=",
"$",
"view",
"->",
"getSiteLocation",
"(",
")",
";",
"if",
"(",
"!",
"$",
"location",
"instanceof",
"Location",
")",
"{",
"$",
"location",
"=",
"$",
"content",
"->",
"mainLocation",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"checkCategoryRedirect",
"(",
"$",
"location",
")",
";",
"if",
"(",
"$",
"response",
"instanceof",
"Response",
")",
"{",
"return",
"$",
"response",
";",
"}",
"$",
"criteria",
"=",
"[",
"new",
"Criterion",
"\\",
"Subtree",
"(",
"$",
"location",
"->",
"pathString",
")",
",",
"new",
"Criterion",
"\\",
"Visibility",
"(",
"Criterion",
"\\",
"Visibility",
"::",
"VISIBLE",
")",
",",
"new",
"Criterion",
"\\",
"LogicalNot",
"(",
"new",
"Criterion",
"\\",
"LocationId",
"(",
"$",
"location",
"->",
"id",
")",
")",
",",
"]",
";",
"if",
"(",
"!",
"$",
"content",
"->",
"getField",
"(",
"'fetch_subtree'",
")",
"->",
"value",
"->",
"bool",
")",
"{",
"$",
"criteria",
"[",
"]",
"=",
"new",
"Criterion",
"\\",
"Location",
"\\",
"Depth",
"(",
"Criterion",
"\\",
"Operator",
"::",
"EQ",
",",
"$",
"location",
"->",
"depth",
"+",
"1",
")",
";",
"}",
"if",
"(",
"!",
"$",
"content",
"->",
"getField",
"(",
"'children_class_filter_include'",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"contentTypeFilter",
"=",
"$",
"content",
"->",
"getField",
"(",
"'children_class_filter_include'",
")",
"->",
"value",
";",
"$",
"criteria",
"[",
"]",
"=",
"new",
"Criterion",
"\\",
"ContentTypeIdentifier",
"(",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"','",
",",
"$",
"contentTypeFilter",
"->",
"text",
")",
")",
")",
";",
"}",
"$",
"query",
"=",
"new",
"LocationQuery",
"(",
")",
";",
"$",
"query",
"->",
"filter",
"=",
"new",
"Criterion",
"\\",
"LogicalAnd",
"(",
"$",
"criteria",
")",
";",
"$",
"query",
"->",
"sortClauses",
"=",
"$",
"location",
"->",
"innerLocation",
"->",
"getSortClauses",
"(",
")",
";",
"$",
"pager",
"=",
"new",
"Pagerfanta",
"(",
"new",
"FilterAdapter",
"(",
"$",
"query",
",",
"$",
"this",
"->",
"getSite",
"(",
")",
"->",
"getFilterService",
"(",
")",
")",
")",
";",
"$",
"pager",
"->",
"setNormalizeOutOfRangePages",
"(",
"true",
")",
";",
"/** @var \\eZ\\Publish\\Core\\FieldType\\Integer\\Value $pageLimitValue */",
"$",
"pageLimitValue",
"=",
"$",
"content",
"->",
"getField",
"(",
"'page_limit'",
")",
"->",
"value",
";",
"$",
"defaultLimit",
"=",
"12",
";",
"$",
"childrenLimit",
"=",
"(",
"int",
")",
"(",
"$",
"params",
"[",
"'childrenLimit'",
"]",
"??",
"$",
"defaultLimit",
")",
";",
"$",
"childrenLimit",
"=",
"$",
"childrenLimit",
">",
"0",
"?",
"$",
"childrenLimit",
":",
"$",
"defaultLimit",
";",
"$",
"pager",
"->",
"setMaxPerPage",
"(",
"$",
"pageLimitValue",
"->",
"value",
">",
"0",
"?",
"(",
"int",
")",
"$",
"pageLimitValue",
"->",
"value",
":",
"$",
"childrenLimit",
")",
";",
"$",
"currentPage",
"=",
"(",
"int",
")",
"$",
"request",
"->",
"get",
"(",
"'page'",
",",
"1",
")",
";",
"$",
"pager",
"->",
"setCurrentPage",
"(",
"$",
"currentPage",
">",
"0",
"?",
"$",
"currentPage",
":",
"1",
")",
";",
"$",
"view",
"->",
"addParameters",
"(",
"[",
"'pager'",
"=>",
"$",
"pager",
",",
"]",
")",
";",
"return",
"$",
"view",
";",
"}"
] | Action for viewing content with ng_category content type identifier.
@return \Symfony\Component\HttpFoundation\Response|\Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView | [
"Action",
"for",
"viewing",
"content",
"with",
"ng_category",
"content",
"type",
"identifier",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/FullViewController.php#L37-L101 |
28,871 | netgen/site-bundle | bundle/Controller/FullViewController.php | FullViewController.viewNgLandingPage | public function viewNgLandingPage(ContentView $view)
{
$location = $view->getSiteLocation();
if (!$location instanceof Location) {
$location = $view->getSiteContent()->mainLocation;
}
$response = $this->checkCategoryRedirect($location);
if ($response instanceof Response) {
return $response;
}
return $view;
} | php | public function viewNgLandingPage(ContentView $view)
{
$location = $view->getSiteLocation();
if (!$location instanceof Location) {
$location = $view->getSiteContent()->mainLocation;
}
$response = $this->checkCategoryRedirect($location);
if ($response instanceof Response) {
return $response;
}
return $view;
} | [
"public",
"function",
"viewNgLandingPage",
"(",
"ContentView",
"$",
"view",
")",
"{",
"$",
"location",
"=",
"$",
"view",
"->",
"getSiteLocation",
"(",
")",
";",
"if",
"(",
"!",
"$",
"location",
"instanceof",
"Location",
")",
"{",
"$",
"location",
"=",
"$",
"view",
"->",
"getSiteContent",
"(",
")",
"->",
"mainLocation",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"checkCategoryRedirect",
"(",
"$",
"location",
")",
";",
"if",
"(",
"$",
"response",
"instanceof",
"Response",
")",
"{",
"return",
"$",
"response",
";",
"}",
"return",
"$",
"view",
";",
"}"
] | Action for viewing content with ng_landing_page content type identifier.
@return \Symfony\Component\HttpFoundation\Response|\Netgen\Bundle\EzPlatformSiteApiBundle\View\ContentView | [
"Action",
"for",
"viewing",
"content",
"with",
"ng_landing_page",
"content",
"type",
"identifier",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/FullViewController.php#L108-L121 |
28,872 | netgen/site-bundle | bundle/Controller/FullViewController.php | FullViewController.checkCategoryRedirect | protected function checkCategoryRedirect(Location $location): ?RedirectResponse
{
$content = $location->content;
$internalRedirectContent = null;
if (!$content->getField('internal_redirect')->isEmpty()) {
$internalRedirectContent = $content->getFieldRelation('internal_redirect');
}
$externalRedirectValue = $content->getField('external_redirect')->value;
if ($internalRedirectContent instanceof Content) {
if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
return new RedirectResponse(
$this->router->generate($internalRedirectContent),
RedirectResponse::HTTP_MOVED_PERMANENTLY
);
}
} elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
}
return new RedirectResponse(
$this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
RedirectResponse::HTTP_MOVED_PERMANENTLY
);
}
return null;
} | php | protected function checkCategoryRedirect(Location $location): ?RedirectResponse
{
$content = $location->content;
$internalRedirectContent = null;
if (!$content->getField('internal_redirect')->isEmpty()) {
$internalRedirectContent = $content->getFieldRelation('internal_redirect');
}
$externalRedirectValue = $content->getField('external_redirect')->value;
if ($internalRedirectContent instanceof Content) {
if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
return new RedirectResponse(
$this->router->generate($internalRedirectContent),
RedirectResponse::HTTP_MOVED_PERMANENTLY
);
}
} elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
}
return new RedirectResponse(
$this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
RedirectResponse::HTTP_MOVED_PERMANENTLY
);
}
return null;
} | [
"protected",
"function",
"checkCategoryRedirect",
"(",
"Location",
"$",
"location",
")",
":",
"?",
"RedirectResponse",
"{",
"$",
"content",
"=",
"$",
"location",
"->",
"content",
";",
"$",
"internalRedirectContent",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"content",
"->",
"getField",
"(",
"'internal_redirect'",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"internalRedirectContent",
"=",
"$",
"content",
"->",
"getFieldRelation",
"(",
"'internal_redirect'",
")",
";",
"}",
"$",
"externalRedirectValue",
"=",
"$",
"content",
"->",
"getField",
"(",
"'external_redirect'",
")",
"->",
"value",
";",
"if",
"(",
"$",
"internalRedirectContent",
"instanceof",
"Content",
")",
"{",
"if",
"(",
"$",
"internalRedirectContent",
"->",
"contentInfo",
"->",
"mainLocationId",
"!==",
"$",
"location",
"->",
"id",
")",
"{",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"$",
"internalRedirectContent",
")",
",",
"RedirectResponse",
"::",
"HTTP_MOVED_PERMANENTLY",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"externalRedirectValue",
"instanceof",
"UrlValue",
"&&",
"!",
"$",
"content",
"->",
"getField",
"(",
"'external_redirect'",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"mb_stripos",
"(",
"$",
"externalRedirectValue",
"->",
"link",
",",
"'http'",
")",
"===",
"0",
")",
"{",
"return",
"new",
"RedirectResponse",
"(",
"$",
"externalRedirectValue",
"->",
"link",
",",
"RedirectResponse",
"::",
"HTTP_MOVED_PERMANENTLY",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"$",
"this",
"->",
"getRootLocation",
"(",
")",
")",
".",
"trim",
"(",
"$",
"externalRedirectValue",
"->",
"link",
",",
"'/'",
")",
",",
"RedirectResponse",
"::",
"HTTP_MOVED_PERMANENTLY",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Checks if content at location defined by it's ID contains
valid category redirect value and returns a redirect response if it does. | [
"Checks",
"if",
"content",
"at",
"location",
"defined",
"by",
"it",
"s",
"ID",
"contains",
"valid",
"category",
"redirect",
"value",
"and",
"returns",
"a",
"redirect",
"response",
"if",
"it",
"does",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Controller/FullViewController.php#L127-L157 |
28,873 | alaxos/cakephp3-libs | src/Controller/JavascriptsController.php | JavascriptsController.antispam | function antispam()
{
$this->layout = false;
$form_dom_id = $this->getRequest()->getQuery('fid');
$model_name = $this->getRequest()->getQuery('model_name');
$token = $this->getRequest()->getQuery('token');
$today_fieldname = $this->SpamFilter->get_today_fieldname();
$today_token = $this->SpamFilter->get_today_token();
$yesterday_token = $this->SpamFilter->get_yesterday_token();
if($token == $today_token || $token == $yesterday_token)
{
$this->set(compact('form_dom_id', 'model_name', 'today_fieldname'));
}
else
{
throw new NotFoundException();
}
} | php | function antispam()
{
$this->layout = false;
$form_dom_id = $this->getRequest()->getQuery('fid');
$model_name = $this->getRequest()->getQuery('model_name');
$token = $this->getRequest()->getQuery('token');
$today_fieldname = $this->SpamFilter->get_today_fieldname();
$today_token = $this->SpamFilter->get_today_token();
$yesterday_token = $this->SpamFilter->get_yesterday_token();
if($token == $today_token || $token == $yesterday_token)
{
$this->set(compact('form_dom_id', 'model_name', 'today_fieldname'));
}
else
{
throw new NotFoundException();
}
} | [
"function",
"antispam",
"(",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"false",
";",
"$",
"form_dom_id",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
"'fid'",
")",
";",
"$",
"model_name",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
"'model_name'",
")",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
"'token'",
")",
";",
"$",
"today_fieldname",
"=",
"$",
"this",
"->",
"SpamFilter",
"->",
"get_today_fieldname",
"(",
")",
";",
"$",
"today_token",
"=",
"$",
"this",
"->",
"SpamFilter",
"->",
"get_today_token",
"(",
")",
";",
"$",
"yesterday_token",
"=",
"$",
"this",
"->",
"SpamFilter",
"->",
"get_yesterday_token",
"(",
")",
";",
"if",
"(",
"$",
"token",
"==",
"$",
"today_token",
"||",
"$",
"token",
"==",
"$",
"yesterday_token",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'form_dom_id'",
",",
"'model_name'",
",",
"'today_fieldname'",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundException",
"(",
")",
";",
"}",
"}"
] | Return a JS that will complete an HTML form with a hidden field that changes every day | [
"Return",
"a",
"JS",
"that",
"will",
"complete",
"an",
"HTML",
"form",
"with",
"a",
"hidden",
"field",
"that",
"changes",
"every",
"day"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Controller/JavascriptsController.php#L25-L45 |
28,874 | smartboxgroup/integration-framework-bundle | Core/Processors/Processor.php | Processor.createProcessEvent | final protected function createProcessEvent(Exchange $exchange, SerializableArray $processingContext, $type)
{
$event = new ProcessEvent($type);
$event->setId(uniqid('', true));
$event->setTimestampToCurrent();
$event->setProcessor($this);
$event->setExchange($exchange);
$event->setProcessingContext($processingContext);
return $event;
} | php | final protected function createProcessEvent(Exchange $exchange, SerializableArray $processingContext, $type)
{
$event = new ProcessEvent($type);
$event->setId(uniqid('', true));
$event->setTimestampToCurrent();
$event->setProcessor($this);
$event->setExchange($exchange);
$event->setProcessingContext($processingContext);
return $event;
} | [
"final",
"protected",
"function",
"createProcessEvent",
"(",
"Exchange",
"$",
"exchange",
",",
"SerializableArray",
"$",
"processingContext",
",",
"$",
"type",
")",
"{",
"$",
"event",
"=",
"new",
"ProcessEvent",
"(",
"$",
"type",
")",
";",
"$",
"event",
"->",
"setId",
"(",
"uniqid",
"(",
"''",
",",
"true",
")",
")",
";",
"$",
"event",
"->",
"setTimestampToCurrent",
"(",
")",
";",
"$",
"event",
"->",
"setProcessor",
"(",
"$",
"this",
")",
";",
"$",
"event",
"->",
"setExchange",
"(",
"$",
"exchange",
")",
";",
"$",
"event",
"->",
"setProcessingContext",
"(",
"$",
"processingContext",
")",
";",
"return",
"$",
"event",
";",
"}"
] | Method to create a process event.
@param Exchange $exchange
@param SerializableArray $processingContext
@param string $type Event type
@return ProcessEvent | [
"Method",
"to",
"create",
"a",
"process",
"event",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Core/Processors/Processor.php#L98-L108 |
28,875 | Atnic/laravel-generator | app/Console/Commands/ControllerApiMakeCommand.php | ControllerApiMakeCommand.getRoutePath | protected function getRoutePath($name)
{
$routeName = str_replace_first('api.', '', $this->getRouteName($name));
$routeNameExploded = explode('.', $routeName);
$routePath = str_replace('.', '/', $routeName);
if ($this->option('parent') && count($routeNameExploded) >= 2) {
$routePath = str_replace_last('/', '.', $routePath);
}
return $routePath;
} | php | protected function getRoutePath($name)
{
$routeName = str_replace_first('api.', '', $this->getRouteName($name));
$routeNameExploded = explode('.', $routeName);
$routePath = str_replace('.', '/', $routeName);
if ($this->option('parent') && count($routeNameExploded) >= 2) {
$routePath = str_replace_last('/', '.', $routePath);
}
return $routePath;
} | [
"protected",
"function",
"getRoutePath",
"(",
"$",
"name",
")",
"{",
"$",
"routeName",
"=",
"str_replace_first",
"(",
"'api.'",
",",
"''",
",",
"$",
"this",
"->",
"getRouteName",
"(",
"$",
"name",
")",
")",
";",
"$",
"routeNameExploded",
"=",
"explode",
"(",
"'.'",
",",
"$",
"routeName",
")",
";",
"$",
"routePath",
"=",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"routeName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"option",
"(",
"'parent'",
")",
"&&",
"count",
"(",
"$",
"routeNameExploded",
")",
">=",
"2",
")",
"{",
"$",
"routePath",
"=",
"str_replace_last",
"(",
"'/'",
",",
"'.'",
",",
"$",
"routePath",
")",
";",
"}",
"return",
"$",
"routePath",
";",
"}"
] | Get the route path.
@param string $name
@return string | [
"Get",
"the",
"route",
"path",
"."
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ControllerApiMakeCommand.php#L316-L325 |
28,876 | netgen/site-bundle | bundle/DependencyInjection/Compiler/AsseticPass.php | AsseticPass.process | public function process(ContainerBuilder $container): void
{
if (!$container->has('assetic.twig_formula_loader.real')) {
return;
}
$container
->findDefinition('assetic.twig_formula_loader.real')
->replaceArgument(1, null);
} | php | public function process(ContainerBuilder $container): void
{
if (!$container->has('assetic.twig_formula_loader.real')) {
return;
}
$container
->findDefinition('assetic.twig_formula_loader.real')
->replaceArgument(1, null);
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"container",
"->",
"has",
"(",
"'assetic.twig_formula_loader.real'",
")",
")",
"{",
"return",
";",
"}",
"$",
"container",
"->",
"findDefinition",
"(",
"'assetic.twig_formula_loader.real'",
")",
"->",
"replaceArgument",
"(",
"1",
",",
"null",
")",
";",
"}"
] | Removes the logging of template errors to console stdout in Assetic. | [
"Removes",
"the",
"logging",
"of",
"template",
"errors",
"to",
"console",
"stdout",
"in",
"Assetic",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/DependencyInjection/Compiler/AsseticPass.php#L15-L24 |
28,877 | MacFJA/phpqa-extensions | src/ToolInstaller.php | ToolInstaller.install | public function install($class)
{
if (!in_array(ToolDefinition::class, class_implements($class), true)) {
throw new \InvalidArgumentException;
}
$this->runComposer(call_user_func([$class, 'getComposer']));
$this->updatePhpQaConfig(
call_user_func([$class, 'getCliName']),
$class,
call_user_func([$class, 'getReportName'])
);
} | php | public function install($class)
{
if (!in_array(ToolDefinition::class, class_implements($class), true)) {
throw new \InvalidArgumentException;
}
$this->runComposer(call_user_func([$class, 'getComposer']));
$this->updatePhpQaConfig(
call_user_func([$class, 'getCliName']),
$class,
call_user_func([$class, 'getReportName'])
);
} | [
"public",
"function",
"install",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"ToolDefinition",
"::",
"class",
",",
"class_implements",
"(",
"$",
"class",
")",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
";",
"}",
"$",
"this",
"->",
"runComposer",
"(",
"call_user_func",
"(",
"[",
"$",
"class",
",",
"'getComposer'",
"]",
")",
")",
";",
"$",
"this",
"->",
"updatePhpQaConfig",
"(",
"call_user_func",
"(",
"[",
"$",
"class",
",",
"'getCliName'",
"]",
")",
",",
"$",
"class",
",",
"call_user_func",
"(",
"[",
"$",
"class",
",",
"'getReportName'",
"]",
")",
")",
";",
"}"
] | Install a tool.
Read all needed information from the Tools\Analyser class and run composer
@param string $class The Tools\Analyser class name | [
"Install",
"a",
"tool",
"."
] | f2193aa80fb8e0025a261975be0d4c525180fc88 | https://github.com/MacFJA/phpqa-extensions/blob/f2193aa80fb8e0025a261975be0d4c525180fc88/src/ToolInstaller.php#L22-L34 |
28,878 | Atnic/laravel-generator | app/Console/Commands/ModelMakeCommand.php | ModelMakeCommand.createFilter | protected function createFilter()
{
$model = Str::studly(class_basename($this->argument('name')));
$this->call('make:filter', [
'name' => $model.'Filter',
]);
} | php | protected function createFilter()
{
$model = Str::studly(class_basename($this->argument('name')));
$this->call('make:filter', [
'name' => $model.'Filter',
]);
} | [
"protected",
"function",
"createFilter",
"(",
")",
"{",
"$",
"model",
"=",
"Str",
"::",
"studly",
"(",
"class_basename",
"(",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
")",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'make:filter'",
",",
"[",
"'name'",
"=>",
"$",
"model",
".",
"'Filter'",
",",
"]",
")",
";",
"}"
] | Create a filter for the model.
@return void | [
"Create",
"a",
"filter",
"for",
"the",
"model",
"."
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ModelMakeCommand.php#L34-L41 |
28,879 | Atnic/laravel-generator | app/Console/Commands/ModelMakeCommand.php | ModelMakeCommand.generateTranslation | protected function generateTranslation()
{
$name = $this->qualifyClass($this->getNameInput());
$path = $this->getTranslationPath($name);
$this->makeDirectory($path);
$this->files->put($path, $this->buildTranslation($name));
$this->info('Translation also generated successfully.');
$this->warn($path);
} | php | protected function generateTranslation()
{
$name = $this->qualifyClass($this->getNameInput());
$path = $this->getTranslationPath($name);
$this->makeDirectory($path);
$this->files->put($path, $this->buildTranslation($name));
$this->info('Translation also generated successfully.');
$this->warn($path);
} | [
"protected",
"function",
"generateTranslation",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"qualifyClass",
"(",
"$",
"this",
"->",
"getNameInput",
"(",
")",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getTranslationPath",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"makeDirectory",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"buildTranslation",
"(",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Translation also generated successfully.'",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"$",
"path",
")",
";",
"}"
] | Generate Translation File
@return void
@throws \Illuminate\Contracts\Filesystem\FileNotFoundException | [
"Generate",
"Translation",
"File"
] | 7bf53837a61af566b389255784dbbf1789020018 | https://github.com/Atnic/laravel-generator/blob/7bf53837a61af566b389255784dbbf1789020018/app/Console/Commands/ModelMakeCommand.php#L89-L99 |
28,880 | netgen/site-bundle | bundle/Routing/SiteContentUrlAliasRouter.php | SiteContentUrlAliasRouter.generate | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string
{
if (!$name instanceof Content && !$name instanceof ContentInfo) {
throw new RouteNotFoundException('Could not match route');
}
if (empty($name->mainLocationId)) {
throw new LogicException('Cannot generate an UrlAlias route for content without main location.');
}
return $this->generator->generate(
$name->mainLocation->innerLocation,
$parameters,
$referenceType
);
} | php | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string
{
if (!$name instanceof Content && !$name instanceof ContentInfo) {
throw new RouteNotFoundException('Could not match route');
}
if (empty($name->mainLocationId)) {
throw new LogicException('Cannot generate an UrlAlias route for content without main location.');
}
return $this->generator->generate(
$name->mainLocation->innerLocation,
$parameters,
$referenceType
);
} | [
"public",
"function",
"generate",
"(",
"$",
"name",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"referenceType",
"=",
"self",
"::",
"ABSOLUTE_PATH",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"name",
"instanceof",
"Content",
"&&",
"!",
"$",
"name",
"instanceof",
"ContentInfo",
")",
"{",
"throw",
"new",
"RouteNotFoundException",
"(",
"'Could not match route'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"name",
"->",
"mainLocationId",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Cannot generate an UrlAlias route for content without main location.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"generator",
"->",
"generate",
"(",
"$",
"name",
"->",
"mainLocation",
"->",
"innerLocation",
",",
"$",
"parameters",
",",
"$",
"referenceType",
")",
";",
"}"
] | Generates a URL for Site API Content object or ContentInfo object, from the given parameters.
@param mixed $name
@param mixed $parameters
@param mixed $referenceType | [
"Generates",
"a",
"URL",
"for",
"Site",
"API",
"Content",
"object",
"or",
"ContentInfo",
"object",
"from",
"the",
"given",
"parameters",
"."
] | 4198c8412ffdb6692b80d35e05c8ba331365b746 | https://github.com/netgen/site-bundle/blob/4198c8412ffdb6692b80d35e05c8ba331365b746/bundle/Routing/SiteContentUrlAliasRouter.php#L52-L67 |
28,881 | spiral/router | src/Route.php | Route.withContainer | public function withContainer(ContainerInterface $container): ContainerizedInterface
{
$route = clone $this;
$route->container = $container;
if ($route->target instanceof TargetInterface) {
$route->target = clone $route->target;
}
$route->pipeline = $route->makePipeline();
return $route;
} | php | public function withContainer(ContainerInterface $container): ContainerizedInterface
{
$route = clone $this;
$route->container = $container;
if ($route->target instanceof TargetInterface) {
$route->target = clone $route->target;
}
$route->pipeline = $route->makePipeline();
return $route;
} | [
"public",
"function",
"withContainer",
"(",
"ContainerInterface",
"$",
"container",
")",
":",
"ContainerizedInterface",
"{",
"$",
"route",
"=",
"clone",
"$",
"this",
";",
"$",
"route",
"->",
"container",
"=",
"$",
"container",
";",
"if",
"(",
"$",
"route",
"->",
"target",
"instanceof",
"TargetInterface",
")",
"{",
"$",
"route",
"->",
"target",
"=",
"clone",
"$",
"route",
"->",
"target",
";",
"}",
"$",
"route",
"->",
"pipeline",
"=",
"$",
"route",
"->",
"makePipeline",
"(",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Associated route with given container.
@param ContainerInterface $container
@return ContainerizedInterface|$this | [
"Associated",
"route",
"with",
"given",
"container",
"."
] | 35721d06231d5650402eb93ac7f3ade00cd1b640 | https://github.com/spiral/router/blob/35721d06231d5650402eb93ac7f3ade00cd1b640/src/Route.php#L76-L87 |
28,882 | nilportugues/php-api-transformer | src/Transformer/Helpers/RecursiveFilterHelper.php | RecursiveFilterHelper.deletePropertiesNotInFilter | public static function deletePropertiesNotInFilter(array &$mappings, array &$array, string $typeKey)
{
if (\array_key_exists(Serializer::CLASS_IDENTIFIER_KEY, $array)) {
$newArray = [];
$type = $array[Serializer::CLASS_IDENTIFIER_KEY];
self::deleteMatchedClassNotInFilterProperties($mappings, $array, $typeKey, $type, $newArray);
if (!empty($newArray)) {
$array = $newArray;
}
}
} | php | public static function deletePropertiesNotInFilter(array &$mappings, array &$array, string $typeKey)
{
if (\array_key_exists(Serializer::CLASS_IDENTIFIER_KEY, $array)) {
$newArray = [];
$type = $array[Serializer::CLASS_IDENTIFIER_KEY];
self::deleteMatchedClassNotInFilterProperties($mappings, $array, $typeKey, $type, $newArray);
if (!empty($newArray)) {
$array = $newArray;
}
}
} | [
"public",
"static",
"function",
"deletePropertiesNotInFilter",
"(",
"array",
"&",
"$",
"mappings",
",",
"array",
"&",
"$",
"array",
",",
"string",
"$",
"typeKey",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"Serializer",
"::",
"CLASS_IDENTIFIER_KEY",
",",
"$",
"array",
")",
")",
"{",
"$",
"newArray",
"=",
"[",
"]",
";",
"$",
"type",
"=",
"$",
"array",
"[",
"Serializer",
"::",
"CLASS_IDENTIFIER_KEY",
"]",
";",
"self",
"::",
"deleteMatchedClassNotInFilterProperties",
"(",
"$",
"mappings",
",",
"$",
"array",
",",
"$",
"typeKey",
",",
"$",
"type",
",",
"$",
"newArray",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"newArray",
")",
")",
"{",
"$",
"array",
"=",
"$",
"newArray",
";",
"}",
"}",
"}"
] | Delete all keys except the ones considered identifier keys or defined in the filter.
@param \NilPortugues\Api\Mapping\Mapping[] $mappings
@param array $array
@param string $typeKey | [
"Delete",
"all",
"keys",
"except",
"the",
"ones",
"considered",
"identifier",
"keys",
"or",
"defined",
"in",
"the",
"filter",
"."
] | a9f20fbe1580d98e3d462a0ebe13fb7595cbd683 | https://github.com/nilportugues/php-api-transformer/blob/a9f20fbe1580d98e3d462a0ebe13fb7595cbd683/src/Transformer/Helpers/RecursiveFilterHelper.php#L25-L37 |
28,883 | smartboxgroup/integration-framework-bundle | Components/DB/NoSQL/Drivers/MongoDB/MongoDBDateHandler.php | MongoDBDateHandler.convertFromMongoFormatToDateTime | public function convertFromMongoFormatToDateTime(VisitorInterface $visitor, $date, array $type, Context $context)
{
/**
* this $dateTime object is incorrect in case of using microseconds
* because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
* method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
* part after "." contains 9 digits but it should contain up to 6 digits
* so we have to reduce this part to 6 digits.
*
* @var \DateTime
*/
if (!is_string($date) && !$date instanceof UTCDatetime) {
throw new \InvalidArgumentException('The provided date must be a valid string or an instance of UTCDateTime');
}
if (is_string($date)) {
$dateTime = date_create($date);
if (false === $dateTime) {
throw new \InvalidArgumentException(sprintf('The provided date "%s" is not a valid date/time string', $date));
}
return $dateTime;
}
return self::convertMongoFormatToDateTime($date);
} | php | public function convertFromMongoFormatToDateTime(VisitorInterface $visitor, $date, array $type, Context $context)
{
/**
* this $dateTime object is incorrect in case of using microseconds
* because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
* method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
* part after "." contains 9 digits but it should contain up to 6 digits
* so we have to reduce this part to 6 digits.
*
* @var \DateTime
*/
if (!is_string($date) && !$date instanceof UTCDatetime) {
throw new \InvalidArgumentException('The provided date must be a valid string or an instance of UTCDateTime');
}
if (is_string($date)) {
$dateTime = date_create($date);
if (false === $dateTime) {
throw new \InvalidArgumentException(sprintf('The provided date "%s" is not a valid date/time string', $date));
}
return $dateTime;
}
return self::convertMongoFormatToDateTime($date);
} | [
"public",
"function",
"convertFromMongoFormatToDateTime",
"(",
"VisitorInterface",
"$",
"visitor",
",",
"$",
"date",
",",
"array",
"$",
"type",
",",
"Context",
"$",
"context",
")",
"{",
"/**\n * this $dateTime object is incorrect in case of using microseconds\n * because after conversion of \\MongoDB\\BSON\\UTCDateTime to \\DateTime\n * method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz\n * part after \".\" contains 9 digits but it should contain up to 6 digits\n * so we have to reduce this part to 6 digits.\n *\n * @var \\DateTime\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"date",
")",
"&&",
"!",
"$",
"date",
"instanceof",
"UTCDatetime",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The provided date must be a valid string or an instance of UTCDateTime'",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"date",
")",
")",
"{",
"$",
"dateTime",
"=",
"date_create",
"(",
"$",
"date",
")",
";",
"if",
"(",
"false",
"===",
"$",
"dateTime",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The provided date \"%s\" is not a valid date/time string'",
",",
"$",
"date",
")",
")",
";",
"}",
"return",
"$",
"dateTime",
";",
"}",
"return",
"self",
"::",
"convertMongoFormatToDateTime",
"(",
"$",
"date",
")",
";",
"}"
] | Method converts \MongoDB\BSON\UTCDateTime to \DateTime.
@param VisitorInterface $visitor
@param UTCDatetime $date
@param array $type
@param Context $context
@return \DateTime | [
"Method",
"converts",
"\\",
"MongoDB",
"\\",
"BSON",
"\\",
"UTCDateTime",
"to",
"\\",
"DateTime",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/DB/NoSQL/Drivers/MongoDB/MongoDBDateHandler.php#L58-L83 |
28,884 | smartboxgroup/integration-framework-bundle | Components/DB/NoSQL/Drivers/MongoDB/MongoDBDateHandler.php | MongoDBDateHandler.convertMongoFormatToDateTime | public static function convertMongoFormatToDateTime(UTCDatetime $date)
{
/**
* this $dateTime object is incorrect in case of using microseconds
* because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
* method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
* part after "." contains 9 digits but it should contain up to 6 digits
* so we have to reduce this part to 6 digits.
*
* @var \DateTime
*/
$dateTime = $date->toDateTime();
$seconds = $dateTime->format('U');
$microseconds = substr($dateTime->format('u'), 0, 5); // we allow max 6 digits
$fixedDateTime = DateTimeHelper::createDateTimeFromTimestampWithMilliseconds(sprintf('%s.%s', $seconds, $microseconds));
return $fixedDateTime;
} | php | public static function convertMongoFormatToDateTime(UTCDatetime $date)
{
/**
* this $dateTime object is incorrect in case of using microseconds
* because after conversion of \MongoDB\BSON\UTCDateTime to \DateTime
* method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz
* part after "." contains 9 digits but it should contain up to 6 digits
* so we have to reduce this part to 6 digits.
*
* @var \DateTime
*/
$dateTime = $date->toDateTime();
$seconds = $dateTime->format('U');
$microseconds = substr($dateTime->format('u'), 0, 5); // we allow max 6 digits
$fixedDateTime = DateTimeHelper::createDateTimeFromTimestampWithMilliseconds(sprintf('%s.%s', $seconds, $microseconds));
return $fixedDateTime;
} | [
"public",
"static",
"function",
"convertMongoFormatToDateTime",
"(",
"UTCDatetime",
"$",
"date",
")",
"{",
"/**\n * this $dateTime object is incorrect in case of using microseconds\n * because after conversion of \\MongoDB\\BSON\\UTCDateTime to \\DateTime\n * method $dateTime->format('U.u') returns invalid string xxxxxxxxx.zzzzzzzzz\n * part after \".\" contains 9 digits but it should contain up to 6 digits\n * so we have to reduce this part to 6 digits.\n *\n * @var \\DateTime\n */",
"$",
"dateTime",
"=",
"$",
"date",
"->",
"toDateTime",
"(",
")",
";",
"$",
"seconds",
"=",
"$",
"dateTime",
"->",
"format",
"(",
"'U'",
")",
";",
"$",
"microseconds",
"=",
"substr",
"(",
"$",
"dateTime",
"->",
"format",
"(",
"'u'",
")",
",",
"0",
",",
"5",
")",
";",
"// we allow max 6 digits",
"$",
"fixedDateTime",
"=",
"DateTimeHelper",
"::",
"createDateTimeFromTimestampWithMilliseconds",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"seconds",
",",
"$",
"microseconds",
")",
")",
";",
"return",
"$",
"fixedDateTime",
";",
"}"
] | Method converts \MongoDB\BSON\UTCDateTime to \DateTime preserving milliseconds.
@param UTCDatetime $date
@return \DateTime | [
"Method",
"converts",
"\\",
"MongoDB",
"\\",
"BSON",
"\\",
"UTCDateTime",
"to",
"\\",
"DateTime",
"preserving",
"milliseconds",
"."
] | 5f0bf8ff86337a51f6d208bd38df39017643b905 | https://github.com/smartboxgroup/integration-framework-bundle/blob/5f0bf8ff86337a51f6d208bd38df39017643b905/Components/DB/NoSQL/Drivers/MongoDB/MongoDBDateHandler.php#L92-L110 |
28,885 | cedx/coveralls.php | lib/GitRemote.php | GitRemote.fromJson | static function fromJson(object $map): self {
return new static(
isset($map->name) && is_string($map->name) ? $map->name : '',
isset($map->url) && is_string($map->url) ? $map->url : null
);
} | php | static function fromJson(object $map): self {
return new static(
isset($map->name) && is_string($map->name) ? $map->name : '',
isset($map->url) && is_string($map->url) ? $map->url : null
);
} | [
"static",
"function",
"fromJson",
"(",
"object",
"$",
"map",
")",
":",
"self",
"{",
"return",
"new",
"static",
"(",
"isset",
"(",
"$",
"map",
"->",
"name",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"name",
")",
"?",
"$",
"map",
"->",
"name",
":",
"''",
",",
"isset",
"(",
"$",
"map",
"->",
"url",
")",
"&&",
"is_string",
"(",
"$",
"map",
"->",
"url",
")",
"?",
"$",
"map",
"->",
"url",
":",
"null",
")",
";",
"}"
] | Creates a new remote repository from the specified JSON map.
@param object $map A JSON map representing a remote repository.
@return static The instance corresponding to the specified JSON map. | [
"Creates",
"a",
"new",
"remote",
"repository",
"from",
"the",
"specified",
"JSON",
"map",
"."
] | c196de0f92e06d5143ba90ebab18c8e384316cc0 | https://github.com/cedx/coveralls.php/blob/c196de0f92e06d5143ba90ebab18c8e384316cc0/lib/GitRemote.php#L32-L37 |
28,886 | IconoCoders/otp-simple-sdk | Source/SimpleBackRef.php | SimpleBackRef.createRequestUri | protected function createRequestUri()
{
if ($this->protocol == '') {
$this->protocol = "http";
}
$this->request = $this->protocol . '://' . $this->serverData['HTTP_HOST'] . $this->serverData['REQUEST_URI'];
$this->debugMessage[] = 'REQUEST: ' . $this->request;
} | php | protected function createRequestUri()
{
if ($this->protocol == '') {
$this->protocol = "http";
}
$this->request = $this->protocol . '://' . $this->serverData['HTTP_HOST'] . $this->serverData['REQUEST_URI'];
$this->debugMessage[] = 'REQUEST: ' . $this->request;
} | [
"protected",
"function",
"createRequestUri",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"protocol",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"protocol",
"=",
"\"http\"",
";",
"}",
"$",
"this",
"->",
"request",
"=",
"$",
"this",
"->",
"protocol",
".",
"'://'",
".",
"$",
"this",
"->",
"serverData",
"[",
"'HTTP_HOST'",
"]",
".",
"$",
"this",
"->",
"serverData",
"[",
"'REQUEST_URI'",
"]",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'REQUEST: '",
".",
"$",
"this",
"->",
"request",
";",
"}"
] | Creates request URI from HTTP SERVER VARS.
Handles http and https
@return void | [
"Creates",
"request",
"URI",
"from",
"HTTP",
"SERVER",
"VARS",
".",
"Handles",
"http",
"and",
"https"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleBackRef.php#L111-L118 |
28,887 | IconoCoders/otp-simple-sdk | Source/SimpleBackRef.php | SimpleBackRef.checkCtrl | protected function checkCtrl()
{
$requestURL = substr($this->request, 0, -38); //the last 38 characters are the CTRL param
$hashInput = strlen($requestURL) . $requestURL;
$this->debugMessage[] = 'REQUEST URL: ' . $requestURL;
$this->debugMessage[] = 'GET ctrl: ' . @$this->getData['ctrl'];
$this->debugMessage[] = 'Calculated ctrl: ' . $this->hmac($this->secretKey, $hashInput);
if (isset($this->getData['ctrl']) && $this->getData['ctrl'] == $this->hmac($this->secretKey, $hashInput)) {
return true;
}
$this->errorMessage[] = 'HASH: Calculated hash is not valid!';
$this->errorMessage[] = 'BACKREF ERROR: ' . @$this->getData['err'];
return false;
} | php | protected function checkCtrl()
{
$requestURL = substr($this->request, 0, -38); //the last 38 characters are the CTRL param
$hashInput = strlen($requestURL) . $requestURL;
$this->debugMessage[] = 'REQUEST URL: ' . $requestURL;
$this->debugMessage[] = 'GET ctrl: ' . @$this->getData['ctrl'];
$this->debugMessage[] = 'Calculated ctrl: ' . $this->hmac($this->secretKey, $hashInput);
if (isset($this->getData['ctrl']) && $this->getData['ctrl'] == $this->hmac($this->secretKey, $hashInput)) {
return true;
}
$this->errorMessage[] = 'HASH: Calculated hash is not valid!';
$this->errorMessage[] = 'BACKREF ERROR: ' . @$this->getData['err'];
return false;
} | [
"protected",
"function",
"checkCtrl",
"(",
")",
"{",
"$",
"requestURL",
"=",
"substr",
"(",
"$",
"this",
"->",
"request",
",",
"0",
",",
"-",
"38",
")",
";",
"//the last 38 characters are the CTRL param",
"$",
"hashInput",
"=",
"strlen",
"(",
"$",
"requestURL",
")",
".",
"$",
"requestURL",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'REQUEST URL: '",
".",
"$",
"requestURL",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'GET ctrl: '",
".",
"@",
"$",
"this",
"->",
"getData",
"[",
"'ctrl'",
"]",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'Calculated ctrl: '",
".",
"$",
"this",
"->",
"hmac",
"(",
"$",
"this",
"->",
"secretKey",
",",
"$",
"hashInput",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getData",
"[",
"'ctrl'",
"]",
")",
"&&",
"$",
"this",
"->",
"getData",
"[",
"'ctrl'",
"]",
"==",
"$",
"this",
"->",
"hmac",
"(",
"$",
"this",
"->",
"secretKey",
",",
"$",
"hashInput",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'HASH: Calculated hash is not valid!'",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'BACKREF ERROR: '",
".",
"@",
"$",
"this",
"->",
"getData",
"[",
"'err'",
"]",
";",
"return",
"false",
";",
"}"
] | Validates CTRL variable
@return boolean | [
"Validates",
"CTRL",
"variable"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleBackRef.php#L126-L139 |
28,888 | IconoCoders/otp-simple-sdk | Source/SimpleBackRef.php | SimpleBackRef.checkResponse | public function checkResponse()
{
if (!isset($this->order_ref)) {
$this->errorMessage[] = 'CHECK RESPONSE: Missing order_ref variable!';
return false;
}
$this->logFunc("BackRef", $this->getData, $this->order_ref);
if (!$this->checkCtrl()) {
$this->errorMessage[] = 'CHECK RESPONSE: INVALID CTRL!';
return false;
}
$ios = new SimpleIos($this->iosConfig, $this->getData['order_currency'], $this->order_ref);
foreach ($ios->errorMessage as $msg) {
$this->errorMessage[] = $msg;
}
foreach ($ios->debugMessage as $msg) {
$this->debugMessage[] = $msg;
}
if (is_object($ios)) {
$this->checkIOSStatus($ios);
}
$this->logFunc("BackRef_BackStatus", $this->backStatusArray, $this->order_ref);
if (!$this->checkRtVariable($ios)) {
return false;
}
if (!$this->backStatusArray['RESULT']) {
return false;
}
return true;
} | php | public function checkResponse()
{
if (!isset($this->order_ref)) {
$this->errorMessage[] = 'CHECK RESPONSE: Missing order_ref variable!';
return false;
}
$this->logFunc("BackRef", $this->getData, $this->order_ref);
if (!$this->checkCtrl()) {
$this->errorMessage[] = 'CHECK RESPONSE: INVALID CTRL!';
return false;
}
$ios = new SimpleIos($this->iosConfig, $this->getData['order_currency'], $this->order_ref);
foreach ($ios->errorMessage as $msg) {
$this->errorMessage[] = $msg;
}
foreach ($ios->debugMessage as $msg) {
$this->debugMessage[] = $msg;
}
if (is_object($ios)) {
$this->checkIOSStatus($ios);
}
$this->logFunc("BackRef_BackStatus", $this->backStatusArray, $this->order_ref);
if (!$this->checkRtVariable($ios)) {
return false;
}
if (!$this->backStatusArray['RESULT']) {
return false;
}
return true;
} | [
"public",
"function",
"checkResponse",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"order_ref",
")",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'CHECK RESPONSE: Missing order_ref variable!'",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"logFunc",
"(",
"\"BackRef\"",
",",
"$",
"this",
"->",
"getData",
",",
"$",
"this",
"->",
"order_ref",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"checkCtrl",
"(",
")",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'CHECK RESPONSE: INVALID CTRL!'",
";",
"return",
"false",
";",
"}",
"$",
"ios",
"=",
"new",
"SimpleIos",
"(",
"$",
"this",
"->",
"iosConfig",
",",
"$",
"this",
"->",
"getData",
"[",
"'order_currency'",
"]",
",",
"$",
"this",
"->",
"order_ref",
")",
";",
"foreach",
"(",
"$",
"ios",
"->",
"errorMessage",
"as",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"$",
"msg",
";",
"}",
"foreach",
"(",
"$",
"ios",
"->",
"debugMessage",
"as",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"$",
"msg",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"ios",
")",
")",
"{",
"$",
"this",
"->",
"checkIOSStatus",
"(",
"$",
"ios",
")",
";",
"}",
"$",
"this",
"->",
"logFunc",
"(",
"\"BackRef_BackStatus\"",
",",
"$",
"this",
"->",
"backStatusArray",
",",
"$",
"this",
"->",
"order_ref",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"checkRtVariable",
"(",
"$",
"ios",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check card authorization response
1. check ctrl
2. check RC & RT
3. check IOS status
@return boolean | [
"Check",
"card",
"authorization",
"response"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleBackRef.php#L151-L184 |
28,889 | IconoCoders/otp-simple-sdk | Source/SimpleBackRef.php | SimpleBackRef.checkIOSStatus | protected function checkIOSStatus($ios)
{
$this->backStatusArray['ORDER_STATUS'] = (isset($ios->status['ORDER_STATUS'])) ? $ios->status['ORDER_STATUS'] : 'IOS_ERROR';
$this->backStatusArray['PAYMETHOD'] = (isset($ios->status['PAYMETHOD'])) ? $ios->status['PAYMETHOD'] : 'N/A';
if (in_array(trim($ios->status['ORDER_STATUS']), $this->successfulStatus)) {
$this->backStatusArray['RESULT'] = true;
} elseif (in_array(trim($ios->status['ORDER_STATUS']), $this->unsuccessfulStatus)) {
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'IOS STATUS: UNSUCCESSFUL!';
}
} | php | protected function checkIOSStatus($ios)
{
$this->backStatusArray['ORDER_STATUS'] = (isset($ios->status['ORDER_STATUS'])) ? $ios->status['ORDER_STATUS'] : 'IOS_ERROR';
$this->backStatusArray['PAYMETHOD'] = (isset($ios->status['PAYMETHOD'])) ? $ios->status['PAYMETHOD'] : 'N/A';
if (in_array(trim($ios->status['ORDER_STATUS']), $this->successfulStatus)) {
$this->backStatusArray['RESULT'] = true;
} elseif (in_array(trim($ios->status['ORDER_STATUS']), $this->unsuccessfulStatus)) {
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'IOS STATUS: UNSUCCESSFUL!';
}
} | [
"protected",
"function",
"checkIOSStatus",
"(",
"$",
"ios",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'ORDER_STATUS'",
"]",
"=",
"(",
"isset",
"(",
"$",
"ios",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
")",
")",
"?",
"$",
"ios",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
":",
"'IOS_ERROR'",
";",
"$",
"this",
"->",
"backStatusArray",
"[",
"'PAYMETHOD'",
"]",
"=",
"(",
"isset",
"(",
"$",
"ios",
"->",
"status",
"[",
"'PAYMETHOD'",
"]",
")",
")",
"?",
"$",
"ios",
"->",
"status",
"[",
"'PAYMETHOD'",
"]",
":",
"'N/A'",
";",
"if",
"(",
"in_array",
"(",
"trim",
"(",
"$",
"ios",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
")",
",",
"$",
"this",
"->",
"successfulStatus",
")",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"true",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"trim",
"(",
"$",
"ios",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
")",
",",
"$",
"this",
"->",
"unsuccessfulStatus",
")",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'IOS STATUS: UNSUCCESSFUL!'",
";",
"}",
"}"
] | Check IOS result
@param obj $ios Result of IOS comunication
@return boolean | [
"Check",
"IOS",
"result"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleBackRef.php#L194-L204 |
28,890 | IconoCoders/otp-simple-sdk | Source/SimpleBackRef.php | SimpleBackRef.checkRtVariable | protected function checkRtVariable($ios)
{
$successCode = array("000", "001");
if (isset($this->getData['RT'])) {
$returnCode = substr($this->getData['RT'], 0, 3);
//000 and 001 are successful
if (in_array($returnCode, $successCode)) {
$this->backStatusArray['RESULT'] = true;
$this->debugMessage[] = 'Return code: ' . $returnCode;
return true;
//all other unsuccessful
} elseif ($this->getData['RT'] != "" && !in_array($returnCode, $successCode)) {
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'Return code: ' . $returnCode;
return false;
//in case of WIRE we have no bank return code and return text value, so RT has to be empty
} elseif ($this->getData['RT'] == "") {
//check IOS ORDER_STATUS
if (in_array(trim($ios->status['ORDER_STATUS']), $this->successfulStatus)) {
$this->backStatusArray['RESULT'] = true;
return true;
}
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'Empty RT and status is: ' . $ios->status['ORDER_STATUS'];
return false;
}
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'RT content: failure!';
return false;
} elseif (!isset($this->getData['RT'])) {
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'Missing variable: (RT)!';
return false;
}
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'checkRtVariable: general error!';
return false;
} | php | protected function checkRtVariable($ios)
{
$successCode = array("000", "001");
if (isset($this->getData['RT'])) {
$returnCode = substr($this->getData['RT'], 0, 3);
//000 and 001 are successful
if (in_array($returnCode, $successCode)) {
$this->backStatusArray['RESULT'] = true;
$this->debugMessage[] = 'Return code: ' . $returnCode;
return true;
//all other unsuccessful
} elseif ($this->getData['RT'] != "" && !in_array($returnCode, $successCode)) {
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'Return code: ' . $returnCode;
return false;
//in case of WIRE we have no bank return code and return text value, so RT has to be empty
} elseif ($this->getData['RT'] == "") {
//check IOS ORDER_STATUS
if (in_array(trim($ios->status['ORDER_STATUS']), $this->successfulStatus)) {
$this->backStatusArray['RESULT'] = true;
return true;
}
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'Empty RT and status is: ' . $ios->status['ORDER_STATUS'];
return false;
}
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'RT content: failure!';
return false;
} elseif (!isset($this->getData['RT'])) {
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'Missing variable: (RT)!';
return false;
}
$this->backStatusArray['RESULT'] = false;
$this->errorMessage[] = 'checkRtVariable: general error!';
return false;
} | [
"protected",
"function",
"checkRtVariable",
"(",
"$",
"ios",
")",
"{",
"$",
"successCode",
"=",
"array",
"(",
"\"000\"",
",",
"\"001\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getData",
"[",
"'RT'",
"]",
")",
")",
"{",
"$",
"returnCode",
"=",
"substr",
"(",
"$",
"this",
"->",
"getData",
"[",
"'RT'",
"]",
",",
"0",
",",
"3",
")",
";",
"//000 and 001 are successful",
"if",
"(",
"in_array",
"(",
"$",
"returnCode",
",",
"$",
"successCode",
")",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"debugMessage",
"[",
"]",
"=",
"'Return code: '",
".",
"$",
"returnCode",
";",
"return",
"true",
";",
"//all other unsuccessful",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getData",
"[",
"'RT'",
"]",
"!=",
"\"\"",
"&&",
"!",
"in_array",
"(",
"$",
"returnCode",
",",
"$",
"successCode",
")",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'Return code: '",
".",
"$",
"returnCode",
";",
"return",
"false",
";",
"//in case of WIRE we have no bank return code and return text value, so RT has to be empty",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getData",
"[",
"'RT'",
"]",
"==",
"\"\"",
")",
"{",
"//check IOS ORDER_STATUS",
"if",
"(",
"in_array",
"(",
"trim",
"(",
"$",
"ios",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
")",
",",
"$",
"this",
"->",
"successfulStatus",
")",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"true",
";",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'Empty RT and status is: '",
".",
"$",
"ios",
"->",
"status",
"[",
"'ORDER_STATUS'",
"]",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'RT content: failure!'",
";",
"return",
"false",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getData",
"[",
"'RT'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'Missing variable: (RT)!'",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"backStatusArray",
"[",
"'RESULT'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'checkRtVariable: general error!'",
";",
"return",
"false",
";",
"}"
] | Check RT variable
@param obj $ios Result of IOS comunication
@return boolean | [
"Check",
"RT",
"variable"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleBackRef.php#L214-L255 |
28,891 | alaxos/cakephp3-libs | src/Lib/XmlTool.php | XmlTool.getAttribute | public static function getAttribute($node, $attribute_name, $default_value = null)
{
$value = $node->getAttribute($attribute_name);
if (! isset($value) || strlen($value) == 0)
{
$value = $default_value;
}
return $value;
} | php | public static function getAttribute($node, $attribute_name, $default_value = null)
{
$value = $node->getAttribute($attribute_name);
if (! isset($value) || strlen($value) == 0)
{
$value = $default_value;
}
return $value;
} | [
"public",
"static",
"function",
"getAttribute",
"(",
"$",
"node",
",",
"$",
"attribute_name",
",",
"$",
"default_value",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"$",
"attribute_name",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
"||",
"strlen",
"(",
"$",
"value",
")",
"==",
"0",
")",
"{",
"$",
"value",
"=",
"$",
"default_value",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Get an attribute value, or the default value if the attribute is null or empty
@param DOMNode $node The node to search the attribute on
@param string $attribute_name The name of the attribute to get the value from
@param string $default_value A default value if the attribute doesn't exist or is empty | [
"Get",
"an",
"attribute",
"value",
"or",
"the",
"default",
"value",
"if",
"the",
"attribute",
"is",
"null",
"or",
"empty"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/XmlTool.php#L190-L200 |
28,892 | alaxos/cakephp3-libs | src/Lib/XmlTool.php | XmlTool.deleteElementsByXpath | public static function deleteElementsByXpath($node, $xpath_query, $namespaces = array())
{
if(is_a($node, 'DOMDocument'))
{
$xpath = new DOMXPath($node);
}
elseif(is_a($node, 'DOMNode'))
{
$xpath = new DOMXPath($node->ownerDocument);
}
else
{
return false;
}
foreach($namespaces as $prefix => $namespaceURI)
{
$xpath->registerNamespace($prefix, $namespaceURI);
}
$node_list = $xpath->query($xpath_query, $node);
if($node_list->length > 0)
{
foreach($node_list as $node_to_delete)
{
if(isset($node_to_delete->parentNode))
{
$node_to_delete->parentNode->removeChild($node_to_delete);
}
}
}
} | php | public static function deleteElementsByXpath($node, $xpath_query, $namespaces = array())
{
if(is_a($node, 'DOMDocument'))
{
$xpath = new DOMXPath($node);
}
elseif(is_a($node, 'DOMNode'))
{
$xpath = new DOMXPath($node->ownerDocument);
}
else
{
return false;
}
foreach($namespaces as $prefix => $namespaceURI)
{
$xpath->registerNamespace($prefix, $namespaceURI);
}
$node_list = $xpath->query($xpath_query, $node);
if($node_list->length > 0)
{
foreach($node_list as $node_to_delete)
{
if(isset($node_to_delete->parentNode))
{
$node_to_delete->parentNode->removeChild($node_to_delete);
}
}
}
} | [
"public",
"static",
"function",
"deleteElementsByXpath",
"(",
"$",
"node",
",",
"$",
"xpath_query",
",",
"$",
"namespaces",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"node",
",",
"'DOMDocument'",
")",
")",
"{",
"$",
"xpath",
"=",
"new",
"DOMXPath",
"(",
"$",
"node",
")",
";",
"}",
"elseif",
"(",
"is_a",
"(",
"$",
"node",
",",
"'DOMNode'",
")",
")",
"{",
"$",
"xpath",
"=",
"new",
"DOMXPath",
"(",
"$",
"node",
"->",
"ownerDocument",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"prefix",
"=>",
"$",
"namespaceURI",
")",
"{",
"$",
"xpath",
"->",
"registerNamespace",
"(",
"$",
"prefix",
",",
"$",
"namespaceURI",
")",
";",
"}",
"$",
"node_list",
"=",
"$",
"xpath",
"->",
"query",
"(",
"$",
"xpath_query",
",",
"$",
"node",
")",
";",
"if",
"(",
"$",
"node_list",
"->",
"length",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"node_list",
"as",
"$",
"node_to_delete",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node_to_delete",
"->",
"parentNode",
")",
")",
"{",
"$",
"node_to_delete",
"->",
"parentNode",
"->",
"removeChild",
"(",
"$",
"node_to_delete",
")",
";",
"}",
"}",
"}",
"}"
] | Delete all the nodes from a DOMDocument that are found with the given xpath query
@param DOMNode $node
@param string $xpath_query
@param array $namespaces
@return boolean | [
"Delete",
"all",
"the",
"nodes",
"from",
"a",
"DOMDocument",
"that",
"are",
"found",
"with",
"the",
"given",
"xpath",
"query"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/XmlTool.php#L210-L242 |
28,893 | alaxos/cakephp3-libs | src/Lib/XmlTool.php | XmlTool.setNodeText | public static function setNodeText($dom_document, $node, $text)
{
/*
* Clear existing child nodes
*/
foreach($node->childNodes as $child_node)
{
$node->removeChild($child_node);
}
/*
* Add a new child TextNode
*/
return $node->appendChild($dom_document->createTextNode($text));
} | php | public static function setNodeText($dom_document, $node, $text)
{
/*
* Clear existing child nodes
*/
foreach($node->childNodes as $child_node)
{
$node->removeChild($child_node);
}
/*
* Add a new child TextNode
*/
return $node->appendChild($dom_document->createTextNode($text));
} | [
"public",
"static",
"function",
"setNodeText",
"(",
"$",
"dom_document",
",",
"$",
"node",
",",
"$",
"text",
")",
"{",
"/*\n * Clear existing child nodes\n */",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"child_node",
")",
"{",
"$",
"node",
"->",
"removeChild",
"(",
"$",
"child_node",
")",
";",
"}",
"/*\n * Add a new child TextNode\n */",
"return",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"dom_document",
"->",
"createTextNode",
"(",
"$",
"text",
")",
")",
";",
"}"
] | Replace the content of a node by a TextNode containing the given text
Note:
compared to using $node->nodeValue, this method automatically encodes the text
to support characters such as ampersand
@param DOMDocument $dom_document
@param DOMNode $node
@param string $text
@return DOMNode the newly created TextNode | [
"Replace",
"the",
"content",
"of",
"a",
"node",
"by",
"a",
"TextNode",
"containing",
"the",
"given",
"text"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/XmlTool.php#L305-L319 |
28,894 | alaxos/cakephp3-libs | src/Controller/Component/FilterComponent.php | FilterComponent.prepareSearchEntity | public function prepareSearchEntity(array $options = array())
{
$alias = $options['alias'];
/**
* @var Entity $search_entity
*/
$search_entity = $this->controller->{$alias}->newEntity();
$search_entity->setAccess('*', true);
$this->controller->{$alias}->patchEntity($search_entity, $this->controller->request->getData());
$this->controller->set(compact('search_entity'));
} | php | public function prepareSearchEntity(array $options = array())
{
$alias = $options['alias'];
/**
* @var Entity $search_entity
*/
$search_entity = $this->controller->{$alias}->newEntity();
$search_entity->setAccess('*', true);
$this->controller->{$alias}->patchEntity($search_entity, $this->controller->request->getData());
$this->controller->set(compact('search_entity'));
} | [
"public",
"function",
"prepareSearchEntity",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"alias",
"=",
"$",
"options",
"[",
"'alias'",
"]",
";",
"/**\n * @var Entity $search_entity\n */",
"$",
"search_entity",
"=",
"$",
"this",
"->",
"controller",
"->",
"{",
"$",
"alias",
"}",
"->",
"newEntity",
"(",
")",
";",
"$",
"search_entity",
"->",
"setAccess",
"(",
"'*'",
",",
"true",
")",
";",
"$",
"this",
"->",
"controller",
"->",
"{",
"$",
"alias",
"}",
"->",
"patchEntity",
"(",
"$",
"search_entity",
",",
"$",
"this",
"->",
"controller",
"->",
"request",
"->",
"getData",
"(",
")",
")",
";",
"$",
"this",
"->",
"controller",
"->",
"set",
"(",
"compact",
"(",
"'search_entity'",
")",
")",
";",
"}"
] | Prepare Entity used to display search filters in the view
@param array $options
@return void | [
"Prepare",
"Entity",
"used",
"to",
"display",
"search",
"filters",
"in",
"the",
"view"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Controller/Component/FilterComponent.php#L370-L382 |
28,895 | alaxos/cakephp3-libs | src/Lib/DebugTool.php | DebugTool.init_microtime | public static function init_microtime($alert_threshold = null, $force_show_file = false)
{
if(DebugTool::$enabled)
{
DebugTool :: $start_microtime = microtime(true);
DebugTool :: $last_microtime = DebugTool :: $start_microtime;
DebugTool :: $alert_threshold = $alert_threshold;
DebugTool :: $force_show_file = $force_show_file;
}
} | php | public static function init_microtime($alert_threshold = null, $force_show_file = false)
{
if(DebugTool::$enabled)
{
DebugTool :: $start_microtime = microtime(true);
DebugTool :: $last_microtime = DebugTool :: $start_microtime;
DebugTool :: $alert_threshold = $alert_threshold;
DebugTool :: $force_show_file = $force_show_file;
}
} | [
"public",
"static",
"function",
"init_microtime",
"(",
"$",
"alert_threshold",
"=",
"null",
",",
"$",
"force_show_file",
"=",
"false",
")",
"{",
"if",
"(",
"DebugTool",
"::",
"$",
"enabled",
")",
"{",
"DebugTool",
"::",
"$",
"start_microtime",
"=",
"microtime",
"(",
"true",
")",
";",
"DebugTool",
"::",
"$",
"last_microtime",
"=",
"DebugTool",
"::",
"$",
"start_microtime",
";",
"DebugTool",
"::",
"$",
"alert_threshold",
"=",
"$",
"alert_threshold",
";",
"DebugTool",
"::",
"$",
"force_show_file",
"=",
"$",
"force_show_file",
";",
"}",
"}"
] | Init the start time to calculate steps time
@param float $alert_threshold Threshold in second above which the step time must be shown in red | [
"Init",
"the",
"start",
"time",
"to",
"calculate",
"steps",
"time"
] | 685e9f17a3fbe3550c59a03a65c4d75df763e804 | https://github.com/alaxos/cakephp3-libs/blob/685e9f17a3fbe3550c59a03a65c4d75df763e804/src/Lib/DebugTool.php#L118-L127 |
28,896 | spiral/router | src/Traits/PipelineTrait.php | PipelineTrait.withMiddleware | public function withMiddleware(...$middleware): RouteInterface
{
$route = clone $this;
// array fallback
if (count($middleware) == 1 && is_array($middleware[0])) {
$middleware = $middleware[0];
}
foreach ($middleware as $item) {
if (!is_string($item) && !$item instanceof MiddlewareInterface) {
if (is_object($item)) {
$name = get_class($item);
} else {
$name = gettype($item);
}
throw new RouteException("Invalid middleware `{$name}`.");
}
$route->middleware[] = $item;
}
if (!empty($route->pipeline)) {
$route->pipeline = $route->makePipeline();
}
return $route;
} | php | public function withMiddleware(...$middleware): RouteInterface
{
$route = clone $this;
// array fallback
if (count($middleware) == 1 && is_array($middleware[0])) {
$middleware = $middleware[0];
}
foreach ($middleware as $item) {
if (!is_string($item) && !$item instanceof MiddlewareInterface) {
if (is_object($item)) {
$name = get_class($item);
} else {
$name = gettype($item);
}
throw new RouteException("Invalid middleware `{$name}`.");
}
$route->middleware[] = $item;
}
if (!empty($route->pipeline)) {
$route->pipeline = $route->makePipeline();
}
return $route;
} | [
"public",
"function",
"withMiddleware",
"(",
"...",
"$",
"middleware",
")",
":",
"RouteInterface",
"{",
"$",
"route",
"=",
"clone",
"$",
"this",
";",
"// array fallback",
"if",
"(",
"count",
"(",
"$",
"middleware",
")",
"==",
"1",
"&&",
"is_array",
"(",
"$",
"middleware",
"[",
"0",
"]",
")",
")",
"{",
"$",
"middleware",
"=",
"$",
"middleware",
"[",
"0",
"]",
";",
"}",
"foreach",
"(",
"$",
"middleware",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"item",
")",
"&&",
"!",
"$",
"item",
"instanceof",
"MiddlewareInterface",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"$",
"name",
"=",
"get_class",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"gettype",
"(",
"$",
"item",
")",
";",
"}",
"throw",
"new",
"RouteException",
"(",
"\"Invalid middleware `{$name}`.\"",
")",
";",
"}",
"$",
"route",
"->",
"middleware",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"route",
"->",
"pipeline",
")",
")",
"{",
"$",
"route",
"->",
"pipeline",
"=",
"$",
"route",
"->",
"makePipeline",
"(",
")",
";",
"}",
"return",
"$",
"route",
";",
"}"
] | Associated middleware with route. New instance of route will be returned.
Example:
$route->withMiddleware(new CacheMiddleware(100));
$route->withMiddleware(ProxyMiddleware::class);
$route->withMiddleware(ProxyMiddleware::class, OtherMiddleware::class);
$route->withMiddleware([ProxyMiddleware::class, OtherMiddleware::class]);
@param MiddlewareInterface|string|array ...$middleware
@return RouteInterface|$this
@throws RouteException | [
"Associated",
"middleware",
"with",
"route",
".",
"New",
"instance",
"of",
"route",
"will",
"be",
"returned",
"."
] | 35721d06231d5650402eb93ac7f3ade00cd1b640 | https://github.com/spiral/router/blob/35721d06231d5650402eb93ac7f3ade00cd1b640/src/Traits/PipelineTrait.php#L42-L70 |
28,897 | spiral/router | src/Traits/PipelineTrait.php | PipelineTrait.makePipeline | protected function makePipeline(): Pipeline
{
try {
$this->pipeline = $this->container->get(Pipeline::class);
foreach ($this->middleware as $middleware) {
if ($middleware instanceof MiddlewareInterface) {
$this->pipeline->pushMiddleware($middleware);
} else {
// dynamically resolved
$this->pipeline->pushMiddleware($this->container->get($middleware));
}
}
} catch (ContainerExceptionInterface $e) {
throw new RouteException($e->getMessage(), $e->getCode(), $e);
}
return $this->pipeline;
} | php | protected function makePipeline(): Pipeline
{
try {
$this->pipeline = $this->container->get(Pipeline::class);
foreach ($this->middleware as $middleware) {
if ($middleware instanceof MiddlewareInterface) {
$this->pipeline->pushMiddleware($middleware);
} else {
// dynamically resolved
$this->pipeline->pushMiddleware($this->container->get($middleware));
}
}
} catch (ContainerExceptionInterface $e) {
throw new RouteException($e->getMessage(), $e->getCode(), $e);
}
return $this->pipeline;
} | [
"protected",
"function",
"makePipeline",
"(",
")",
":",
"Pipeline",
"{",
"try",
"{",
"$",
"this",
"->",
"pipeline",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"Pipeline",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"middleware",
"as",
"$",
"middleware",
")",
"{",
"if",
"(",
"$",
"middleware",
"instanceof",
"MiddlewareInterface",
")",
"{",
"$",
"this",
"->",
"pipeline",
"->",
"pushMiddleware",
"(",
"$",
"middleware",
")",
";",
"}",
"else",
"{",
"// dynamically resolved",
"$",
"this",
"->",
"pipeline",
"->",
"pushMiddleware",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"middleware",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"ContainerExceptionInterface",
"$",
"e",
")",
"{",
"throw",
"new",
"RouteException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pipeline",
";",
"}"
] | Get associated route pipeline.
@return Pipeline
@throws RouteException | [
"Get",
"associated",
"route",
"pipeline",
"."
] | 35721d06231d5650402eb93ac7f3ade00cd1b640 | https://github.com/spiral/router/blob/35721d06231d5650402eb93ac7f3ade00cd1b640/src/Traits/PipelineTrait.php#L79-L97 |
28,898 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.createHiddenField | public function createHiddenField($name = '', $value = '')
{
if ($name == '') {
$this->errorMessage[] = 'HTML HIDDEN: field name is empty';
return false;
}
$inputId = $name;
if (substr($name, -2, 2) == "[]") {
$inputId = substr($name, 0, -2);
}
return "\n<input type='hidden' name='" . $name . "' id='" . $inputId . "' value='" . $value . "' />";
} | php | public function createHiddenField($name = '', $value = '')
{
if ($name == '') {
$this->errorMessage[] = 'HTML HIDDEN: field name is empty';
return false;
}
$inputId = $name;
if (substr($name, -2, 2) == "[]") {
$inputId = substr($name, 0, -2);
}
return "\n<input type='hidden' name='" . $name . "' id='" . $inputId . "' value='" . $value . "' />";
} | [
"public",
"function",
"createHiddenField",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'HTML HIDDEN: field name is empty'",
";",
"return",
"false",
";",
"}",
"$",
"inputId",
"=",
"$",
"name",
";",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"-",
"2",
",",
"2",
")",
"==",
"\"[]\"",
")",
"{",
"$",
"inputId",
"=",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"-",
"2",
")",
";",
"}",
"return",
"\"\\n<input type='hidden' name='\"",
".",
"$",
"name",
".",
"\"' id='\"",
".",
"$",
"inputId",
".",
"\"' value='\"",
".",
"$",
"value",
".",
"\"' />\"",
";",
"}"
] | Creates hidden HTML field
@param string $name Name of the field. ID parameter will be generated without "[]"
@param string $value Value of the field
@return string HTML form element | [
"Creates",
"hidden",
"HTML",
"field"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L166-L177 |
28,899 | IconoCoders/otp-simple-sdk | Source/SimpleTransaction.php | SimpleTransaction.createPostArray | public function createPostArray($hashFieldName = "ORDER_HASH")
{
if (!$this->prepareFields($hashFieldName)) {
$this->errorMessage[] = 'POST ARRAY: Missing hash field name';
return false;
}
return $this->formData;
} | php | public function createPostArray($hashFieldName = "ORDER_HASH")
{
if (!$this->prepareFields($hashFieldName)) {
$this->errorMessage[] = 'POST ARRAY: Missing hash field name';
return false;
}
return $this->formData;
} | [
"public",
"function",
"createPostArray",
"(",
"$",
"hashFieldName",
"=",
"\"ORDER_HASH\"",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"prepareFields",
"(",
"$",
"hashFieldName",
")",
")",
"{",
"$",
"this",
"->",
"errorMessage",
"[",
"]",
"=",
"'POST ARRAY: Missing hash field name'",
";",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"formData",
";",
"}"
] | Generates raw data array with HMAC HASH code for custom processing
@param string $hashFieldName Index-name of the generated HASH field in the associative array
@return array Data content of form | [
"Generates",
"raw",
"data",
"array",
"with",
"HMAC",
"HASH",
"code",
"for",
"custom",
"processing"
] | d2808bf52e8d34be69414b444a00f1a9c8564930 | https://github.com/IconoCoders/otp-simple-sdk/blob/d2808bf52e8d34be69414b444a00f1a9c8564930/Source/SimpleTransaction.php#L187-L194 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.