repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.initialise | public function initialise($options = array())
{
// Set the language in the class.
$config = JFactory::getConfig();
// Check that we were given a language in the array (since by default may be blank).
if (isset($options['language']))
{
$config->set('language', $options['language']);
}
// Set user specific editor.
$user = JFactory::getUser();
$editor = $user->getParam('editor', $this->getCfg('editor'));
if (!JPluginHelper::isEnabled('editors', $editor))
{
$editor = $this->getCfg('editor');
if (!JPluginHelper::isEnabled('editors', $editor))
{
$editor = 'none';
}
}
$config->set('editor', $editor);
// Trigger the onAfterInitialise event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterInitialise');
} | php | public function initialise($options = array())
{
// Set the language in the class.
$config = JFactory::getConfig();
// Check that we were given a language in the array (since by default may be blank).
if (isset($options['language']))
{
$config->set('language', $options['language']);
}
// Set user specific editor.
$user = JFactory::getUser();
$editor = $user->getParam('editor', $this->getCfg('editor'));
if (!JPluginHelper::isEnabled('editors', $editor))
{
$editor = $this->getCfg('editor');
if (!JPluginHelper::isEnabled('editors', $editor))
{
$editor = 'none';
}
}
$config->set('editor', $editor);
// Trigger the onAfterInitialise event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterInitialise');
} | [
"public",
"function",
"initialise",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"// Set the language in the class.",
"$",
"config",
"=",
"JFactory",
"::",
"getConfig",
"(",
")",
";",
"// Check that we were given a language in the array (since by default may be blank).",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'language'",
"]",
")",
")",
"{",
"$",
"config",
"->",
"set",
"(",
"'language'",
",",
"$",
"options",
"[",
"'language'",
"]",
")",
";",
"}",
"// Set user specific editor.",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"$",
"editor",
"=",
"$",
"user",
"->",
"getParam",
"(",
"'editor'",
",",
"$",
"this",
"->",
"getCfg",
"(",
"'editor'",
")",
")",
";",
"if",
"(",
"!",
"JPluginHelper",
"::",
"isEnabled",
"(",
"'editors'",
",",
"$",
"editor",
")",
")",
"{",
"$",
"editor",
"=",
"$",
"this",
"->",
"getCfg",
"(",
"'editor'",
")",
";",
"if",
"(",
"!",
"JPluginHelper",
"::",
"isEnabled",
"(",
"'editors'",
",",
"$",
"editor",
")",
")",
"{",
"$",
"editor",
"=",
"'none'",
";",
"}",
"}",
"$",
"config",
"->",
"set",
"(",
"'editor'",
",",
"$",
"editor",
")",
";",
"// Trigger the onAfterInitialise event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterInitialise'",
")",
";",
"}"
] | Initialise the application.
@param array $options An optional associative array of configuration settings.
@return void
@since 11.1
@deprecated 4.0 | [
"Initialise",
"the",
"application",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L194-L224 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.route | public function route()
{
// Get the full request URI.
$uri = clone JUri::getInstance();
$router = $this->getRouter();
$result = $router->parse($uri);
foreach ($result as $key => $value)
{
$this->input->def($key, $value);
}
// Trigger the onAfterRoute event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterRoute');
} | php | public function route()
{
// Get the full request URI.
$uri = clone JUri::getInstance();
$router = $this->getRouter();
$result = $router->parse($uri);
foreach ($result as $key => $value)
{
$this->input->def($key, $value);
}
// Trigger the onAfterRoute event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterRoute');
} | [
"public",
"function",
"route",
"(",
")",
"{",
"// Get the full request URI.",
"$",
"uri",
"=",
"clone",
"JUri",
"::",
"getInstance",
"(",
")",
";",
"$",
"router",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
";",
"$",
"result",
"=",
"$",
"router",
"->",
"parse",
"(",
"$",
"uri",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"input",
"->",
"def",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"// Trigger the onAfterRoute event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterRoute'",
")",
";",
"}"
] | Route the application.
Routing is the process of examining the request environment to determine which
component should receive the request. The component optional parameters
are then set in the request object to be processed when the application is being
dispatched.
@return void
@since 11.1
@deprecated 4.0 | [
"Route",
"the",
"application",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L239-L255 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.dispatch | public function dispatch($component = null)
{
$document = JFactory::getDocument();
$contents = JComponentHelper::renderComponent($component);
$document->setBuffer($contents, 'component');
// Trigger the onAfterDispatch event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterDispatch');
} | php | public function dispatch($component = null)
{
$document = JFactory::getDocument();
$contents = JComponentHelper::renderComponent($component);
$document->setBuffer($contents, 'component');
// Trigger the onAfterDispatch event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterDispatch');
} | [
"public",
"function",
"dispatch",
"(",
"$",
"component",
"=",
"null",
")",
"{",
"$",
"document",
"=",
"JFactory",
"::",
"getDocument",
"(",
")",
";",
"$",
"contents",
"=",
"JComponentHelper",
"::",
"renderComponent",
"(",
"$",
"component",
")",
";",
"$",
"document",
"->",
"setBuffer",
"(",
"$",
"contents",
",",
"'component'",
")",
";",
"// Trigger the onAfterDispatch event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterDispatch'",
")",
";",
"}"
] | Dispatch the application.
Dispatching is the process of pulling the option from the request object and
mapping them to a component. If the component does not exist, it handles
determining a default component to dispatch.
@param string $component The component to dispatch.
@return void
@since 11.1
@deprecated 4.0 | [
"Dispatch",
"the",
"application",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L271-L281 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.render | public function render()
{
$template = $this->getTemplate(true);
$params = array('template' => $template->template, 'file' => 'index.php', 'directory' => JPATH_THEMES, 'params' => $template->params);
// Parse the document.
$document = JFactory::getDocument();
$document->parse($params);
// Trigger the onBeforeRender event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onBeforeRender');
// Render the document.
$caching = ($this->getCfg('caching') >= 2) ? true : false;
JResponse::setBody($document->render($caching, $params));
// Trigger the onAfterRender event.
$this->triggerEvent('onAfterRender');
} | php | public function render()
{
$template = $this->getTemplate(true);
$params = array('template' => $template->template, 'file' => 'index.php', 'directory' => JPATH_THEMES, 'params' => $template->params);
// Parse the document.
$document = JFactory::getDocument();
$document->parse($params);
// Trigger the onBeforeRender event.
JPluginHelper::importPlugin('system');
$this->triggerEvent('onBeforeRender');
// Render the document.
$caching = ($this->getCfg('caching') >= 2) ? true : false;
JResponse::setBody($document->render($caching, $params));
// Trigger the onAfterRender event.
$this->triggerEvent('onAfterRender');
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"true",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'template'",
"=>",
"$",
"template",
"->",
"template",
",",
"'file'",
"=>",
"'index.php'",
",",
"'directory'",
"=>",
"JPATH_THEMES",
",",
"'params'",
"=>",
"$",
"template",
"->",
"params",
")",
";",
"// Parse the document.",
"$",
"document",
"=",
"JFactory",
"::",
"getDocument",
"(",
")",
";",
"$",
"document",
"->",
"parse",
"(",
"$",
"params",
")",
";",
"// Trigger the onBeforeRender event.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'system'",
")",
";",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onBeforeRender'",
")",
";",
"// Render the document.",
"$",
"caching",
"=",
"(",
"$",
"this",
"->",
"getCfg",
"(",
"'caching'",
")",
">=",
"2",
")",
"?",
"true",
":",
"false",
";",
"JResponse",
"::",
"setBody",
"(",
"$",
"document",
"->",
"render",
"(",
"$",
"caching",
",",
"$",
"params",
")",
")",
";",
"// Trigger the onAfterRender event.",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onAfterRender'",
")",
";",
"}"
] | Render the application.
Rendering is the process of pushing the document buffers into the template
placeholders, retrieving data from the document and pushing it into
the JResponse buffer.
@return void
@since 11.1
@deprecated 4.0 | [
"Render",
"the",
"application",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L295-L315 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.redirect | public function redirect($url, $msg = '', $msgType = 'message', $moved = false)
{
// Check for relative internal links.
if (preg_match('#^index2?\.php#', $url))
{
$url = JUri::base() . $url;
}
// Strip out any line breaks.
$url = preg_split("/[\r\n]/", $url);
$url = $url[0];
/*
* If we don't start with a http we need to fix this before we proceed.
* We could validly start with something else (e.g. ftp), though this would
* be unlikely and isn't supported by this API.
*/
if (!preg_match('#^http#i', $url))
{
$uri = JUri::getInstance();
$prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
if ($url[0] == '/')
{
// We just need the prefix since we have a path relative to the root.
$url = $prefix . $url;
}
else
{
// It's relative to where we are now, so lets add that.
$parts = explode('/', $uri->toString(array('path')));
array_pop($parts);
$path = implode('/', $parts) . '/';
$url = $prefix . $path . $url;
}
}
// If the message exists, enqueue it.
if (trim($msg))
{
$this->enqueueMessage($msg, $msgType);
}
// Persist messages if they exist.
if (count($this->_messageQueue))
{
$session = JFactory::getSession();
$session->set('application.queue', $this->_messageQueue);
}
// If the headers have been sent, then we cannot send an additional location header
// so we will output a javascript redirect statement.
if (headers_sent())
{
echo "<script>document.location.href='" . str_replace("'", "'", $url) . "';</script>\n";
}
else
{
$document = JFactory::getDocument();
if (($this->client->engine == JApplicationWebClient::TRIDENT) && !StringHelper::is_ascii($url))
{
// MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />'
. '<script>document.location.href=\'' . str_replace("'", "'", $url) . '\';</script></head></html>';
}
else
{
// All other browsers, use the more efficient HTTP header method
header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
header('Location: ' . $url);
header('Content-Type: text/html; charset=' . $document->getCharset());
}
}
$this->close();
} | php | public function redirect($url, $msg = '', $msgType = 'message', $moved = false)
{
// Check for relative internal links.
if (preg_match('#^index2?\.php#', $url))
{
$url = JUri::base() . $url;
}
// Strip out any line breaks.
$url = preg_split("/[\r\n]/", $url);
$url = $url[0];
/*
* If we don't start with a http we need to fix this before we proceed.
* We could validly start with something else (e.g. ftp), though this would
* be unlikely and isn't supported by this API.
*/
if (!preg_match('#^http#i', $url))
{
$uri = JUri::getInstance();
$prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
if ($url[0] == '/')
{
// We just need the prefix since we have a path relative to the root.
$url = $prefix . $url;
}
else
{
// It's relative to where we are now, so lets add that.
$parts = explode('/', $uri->toString(array('path')));
array_pop($parts);
$path = implode('/', $parts) . '/';
$url = $prefix . $path . $url;
}
}
// If the message exists, enqueue it.
if (trim($msg))
{
$this->enqueueMessage($msg, $msgType);
}
// Persist messages if they exist.
if (count($this->_messageQueue))
{
$session = JFactory::getSession();
$session->set('application.queue', $this->_messageQueue);
}
// If the headers have been sent, then we cannot send an additional location header
// so we will output a javascript redirect statement.
if (headers_sent())
{
echo "<script>document.location.href='" . str_replace("'", "'", $url) . "';</script>\n";
}
else
{
$document = JFactory::getDocument();
if (($this->client->engine == JApplicationWebClient::TRIDENT) && !StringHelper::is_ascii($url))
{
// MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />'
. '<script>document.location.href=\'' . str_replace("'", "'", $url) . '\';</script></head></html>';
}
else
{
// All other browsers, use the more efficient HTTP header method
header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
header('Location: ' . $url);
header('Content-Type: text/html; charset=' . $document->getCharset());
}
}
$this->close();
} | [
"public",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"msg",
"=",
"''",
",",
"$",
"msgType",
"=",
"'message'",
",",
"$",
"moved",
"=",
"false",
")",
"{",
"// Check for relative internal links.",
"if",
"(",
"preg_match",
"(",
"'#^index2?\\.php#'",
",",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"JUri",
"::",
"base",
"(",
")",
".",
"$",
"url",
";",
"}",
"// Strip out any line breaks.",
"$",
"url",
"=",
"preg_split",
"(",
"\"/[\\r\\n]/\"",
",",
"$",
"url",
")",
";",
"$",
"url",
"=",
"$",
"url",
"[",
"0",
"]",
";",
"/*\n\t\t * If we don't start with a http we need to fix this before we proceed.\n\t\t * We could validly start with something else (e.g. ftp), though this would\n\t\t * be unlikely and isn't supported by this API.\n\t\t */",
"if",
"(",
"!",
"preg_match",
"(",
"'#^http#i'",
",",
"$",
"url",
")",
")",
"{",
"$",
"uri",
"=",
"JUri",
"::",
"getInstance",
"(",
")",
";",
"$",
"prefix",
"=",
"$",
"uri",
"->",
"toString",
"(",
"array",
"(",
"'scheme'",
",",
"'user'",
",",
"'pass'",
",",
"'host'",
",",
"'port'",
")",
")",
";",
"if",
"(",
"$",
"url",
"[",
"0",
"]",
"==",
"'/'",
")",
"{",
"// We just need the prefix since we have a path relative to the root.",
"$",
"url",
"=",
"$",
"prefix",
".",
"$",
"url",
";",
"}",
"else",
"{",
"// It's relative to where we are now, so lets add that.",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"uri",
"->",
"toString",
"(",
"array",
"(",
"'path'",
")",
")",
")",
";",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"path",
"=",
"implode",
"(",
"'/'",
",",
"$",
"parts",
")",
".",
"'/'",
";",
"$",
"url",
"=",
"$",
"prefix",
".",
"$",
"path",
".",
"$",
"url",
";",
"}",
"}",
"// If the message exists, enqueue it.",
"if",
"(",
"trim",
"(",
"$",
"msg",
")",
")",
"{",
"$",
"this",
"->",
"enqueueMessage",
"(",
"$",
"msg",
",",
"$",
"msgType",
")",
";",
"}",
"// Persist messages if they exist.",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_messageQueue",
")",
")",
"{",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'application.queue'",
",",
"$",
"this",
"->",
"_messageQueue",
")",
";",
"}",
"// If the headers have been sent, then we cannot send an additional location header",
"// so we will output a javascript redirect statement.",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"echo",
"\"<script>document.location.href='\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"'\"",
",",
"$",
"url",
")",
".",
"\"';</script>\\n\"",
";",
"}",
"else",
"{",
"$",
"document",
"=",
"JFactory",
"::",
"getDocument",
"(",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"client",
"->",
"engine",
"==",
"JApplicationWebClient",
"::",
"TRIDENT",
")",
"&&",
"!",
"StringHelper",
"::",
"is_ascii",
"(",
"$",
"url",
")",
")",
"{",
"// MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method",
"echo",
"'<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset='",
".",
"$",
"document",
"->",
"getCharset",
"(",
")",
".",
"'\" />'",
".",
"'<script>document.location.href=\\''",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"'\"",
",",
"$",
"url",
")",
".",
"'\\';</script></head></html>'",
";",
"}",
"else",
"{",
"// All other browsers, use the more efficient HTTP header method",
"header",
"(",
"$",
"moved",
"?",
"'HTTP/1.1 301 Moved Permanently'",
":",
"'HTTP/1.1 303 See other'",
")",
";",
"header",
"(",
"'Location: '",
".",
"$",
"url",
")",
";",
"header",
"(",
"'Content-Type: text/html; charset='",
".",
"$",
"document",
"->",
"getCharset",
"(",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"close",
"(",
")",
";",
"}"
] | Redirect to another URL.
Optionally enqueues a message in the system message queue (which will be displayed
the next time a page is loaded) using the enqueueMessage method. If the headers have
not been sent the redirect will be accomplished using a "301 Moved Permanently"
code in the header pointing to the new location. If the headers have already been
sent this will be accomplished using a JavaScript statement.
@param string $url The URL to redirect to. Can only be http/https URL
@param string $msg An optional message to display on redirect.
@param string $msgType An optional message type. Defaults to message.
@param boolean $moved True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed.
@return void Calls exit().
@since 11.1
@deprecated 4.0
@see JApplication::enqueueMessage() | [
"Redirect",
"to",
"another",
"URL",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L338-L414 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.enqueueMessage | public function enqueueMessage($msg, $type = 'message')
{
// For empty queue, if messages exists in the session, enqueue them first.
if (!count($this->_messageQueue))
{
$session = JFactory::getSession();
$sessionQueue = $session->get('application.queue');
if (count($sessionQueue))
{
$this->_messageQueue = $sessionQueue;
$session->set('application.queue', null);
}
}
// Enqueue the message.
$this->_messageQueue[] = array('message' => $msg, 'type' => strtolower($type));
} | php | public function enqueueMessage($msg, $type = 'message')
{
// For empty queue, if messages exists in the session, enqueue them first.
if (!count($this->_messageQueue))
{
$session = JFactory::getSession();
$sessionQueue = $session->get('application.queue');
if (count($sessionQueue))
{
$this->_messageQueue = $sessionQueue;
$session->set('application.queue', null);
}
}
// Enqueue the message.
$this->_messageQueue[] = array('message' => $msg, 'type' => strtolower($type));
} | [
"public",
"function",
"enqueueMessage",
"(",
"$",
"msg",
",",
"$",
"type",
"=",
"'message'",
")",
"{",
"// For empty queue, if messages exists in the session, enqueue them first.",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"_messageQueue",
")",
")",
"{",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"$",
"sessionQueue",
"=",
"$",
"session",
"->",
"get",
"(",
"'application.queue'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"sessionQueue",
")",
")",
"{",
"$",
"this",
"->",
"_messageQueue",
"=",
"$",
"sessionQueue",
";",
"$",
"session",
"->",
"set",
"(",
"'application.queue'",
",",
"null",
")",
";",
"}",
"}",
"// Enqueue the message.",
"$",
"this",
"->",
"_messageQueue",
"[",
"]",
"=",
"array",
"(",
"'message'",
"=>",
"$",
"msg",
",",
"'type'",
"=>",
"strtolower",
"(",
"$",
"type",
")",
")",
";",
"}"
] | Enqueue a system message.
@param string $msg The message to enqueue.
@param string $type The message type. Default is message.
@return void
@since 11.1
@deprecated 4.0 | [
"Enqueue",
"a",
"system",
"message",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L427-L444 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.getMessageQueue | public function getMessageQueue()
{
// For empty queue, if messages exists in the session, enqueue them.
if (!count($this->_messageQueue))
{
$session = JFactory::getSession();
$sessionQueue = $session->get('application.queue');
if (count($sessionQueue))
{
$this->_messageQueue = $sessionQueue;
$session->set('application.queue', null);
}
}
return $this->_messageQueue;
} | php | public function getMessageQueue()
{
// For empty queue, if messages exists in the session, enqueue them.
if (!count($this->_messageQueue))
{
$session = JFactory::getSession();
$sessionQueue = $session->get('application.queue');
if (count($sessionQueue))
{
$this->_messageQueue = $sessionQueue;
$session->set('application.queue', null);
}
}
return $this->_messageQueue;
} | [
"public",
"function",
"getMessageQueue",
"(",
")",
"{",
"// For empty queue, if messages exists in the session, enqueue them.",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"_messageQueue",
")",
")",
"{",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"$",
"sessionQueue",
"=",
"$",
"session",
"->",
"get",
"(",
"'application.queue'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"sessionQueue",
")",
")",
"{",
"$",
"this",
"->",
"_messageQueue",
"=",
"$",
"sessionQueue",
";",
"$",
"session",
"->",
"set",
"(",
"'application.queue'",
",",
"null",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_messageQueue",
";",
"}"
] | Get the system message queue.
@return array The system message queue.
@since 11.1
@deprecated 4.0 | [
"Get",
"the",
"system",
"message",
"queue",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L454-L470 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.getName | public function getName()
{
$name = $this->_name;
if (empty($name))
{
$r = null;
if (!preg_match('/J(.*)/i', get_class($this), $r))
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME'), JLog::WARNING, 'jerror');
}
$name = strtolower($r[1]);
}
return $name;
} | php | public function getName()
{
$name = $this->_name;
if (empty($name))
{
$r = null;
if (!preg_match('/J(.*)/i', get_class($this), $r))
{
JLog::add(JText::_('JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME'), JLog::WARNING, 'jerror');
}
$name = strtolower($r[1]);
}
return $name;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_name",
";",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"r",
"=",
"null",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/J(.*)/i'",
",",
"get_class",
"(",
"$",
"this",
")",
",",
"$",
"r",
")",
")",
"{",
"JLog",
"::",
"add",
"(",
"JText",
"::",
"_",
"(",
"'JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME'",
")",
",",
"JLog",
"::",
"WARNING",
",",
"'jerror'",
")",
";",
"}",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"r",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Method to get the application name.
The dispatcher name is by default parsed using the classname, or it can be set
by passing a $config['name'] in the class constructor.
@return string The name of the dispatcher.
@since 11.1
@deprecated 4.0 | [
"Method",
"to",
"get",
"the",
"application",
"name",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L503-L520 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.getUserStateFromRequest | public function getUserStateFromRequest($key, $request, $default = null, $type = 'none')
{
$cur_state = $this->getUserState($key, $default);
$new_state = $this->input->get($request, null, $type);
// Save the new value only if it was set in this request.
if ($new_state !== null)
{
$this->setUserState($key, $new_state);
}
else
{
$new_state = $cur_state;
}
return $new_state;
} | php | public function getUserStateFromRequest($key, $request, $default = null, $type = 'none')
{
$cur_state = $this->getUserState($key, $default);
$new_state = $this->input->get($request, null, $type);
// Save the new value only if it was set in this request.
if ($new_state !== null)
{
$this->setUserState($key, $new_state);
}
else
{
$new_state = $cur_state;
}
return $new_state;
} | [
"public",
"function",
"getUserStateFromRequest",
"(",
"$",
"key",
",",
"$",
"request",
",",
"$",
"default",
"=",
"null",
",",
"$",
"type",
"=",
"'none'",
")",
"{",
"$",
"cur_state",
"=",
"$",
"this",
"->",
"getUserState",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"$",
"new_state",
"=",
"$",
"this",
"->",
"input",
"->",
"get",
"(",
"$",
"request",
",",
"null",
",",
"$",
"type",
")",
";",
"// Save the new value only if it was set in this request.",
"if",
"(",
"$",
"new_state",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setUserState",
"(",
"$",
"key",
",",
"$",
"new_state",
")",
";",
"}",
"else",
"{",
"$",
"new_state",
"=",
"$",
"cur_state",
";",
"}",
"return",
"$",
"new_state",
";",
"}"
] | Gets the value of a user state variable.
@param string $key The key of the user state variable.
@param string $request The name of the variable passed in a request.
@param string $default The default value for the variable if not found. Optional.
@param string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional.
@return The request user state.
@since 11.1
@deprecated 4.0 | [
"Gets",
"the",
"value",
"of",
"a",
"user",
"state",
"variable",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L583-L599 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.login | public function login($credentials, $options = array())
{
// Get the global JAuthentication object.
jimport('joomla.user.authentication');
JPluginHelper::importPlugin('user');
$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($credentials, $options);
if ($response->status === JAuthentication::STATUS_SUCCESS)
{
// Validate that the user should be able to login (different to being authenticated).
// This permits authentication plugins blocking the user
$authorisations = $authenticate->authorise($response, $options);
foreach ($authorisations as $authorisation)
{
$denied_states = array(JAuthentication::STATUS_EXPIRED, JAuthentication::STATUS_DENIED);
if (in_array($authorisation->status, $denied_states))
{
// Trigger onUserAuthorisationFailure Event.
$this->triggerEvent('onUserAuthorisationFailure', array((array) $authorisation));
// If silent is set, just return false.
if (isset($options['silent']) && $options['silent'])
{
return false;
}
// Return the error.
switch ($authorisation->status)
{
case JAuthentication::STATUS_EXPIRED:
return JError::raiseWarning('102002', JText::_('JLIB_LOGIN_EXPIRED'));
break;
case JAuthentication::STATUS_DENIED:
return JError::raiseWarning('102003', JText::_('JLIB_LOGIN_DENIED'));
break;
default:
return JError::raiseWarning('102004', JText::_('JLIB_LOGIN_AUTHORISATION'));
break;
}
}
}
// Import the user plugin group.
JPluginHelper::importPlugin('user');
// OK, the credentials are authenticated and user is authorised. Let's fire the onLogin event.
$results = $this->triggerEvent('onUserLogin', array((array) $response, $options));
/*
* If any of the user plugins did not successfully complete the login routine
* then the whole method fails.
*
* Any errors raised should be done in the plugin as this provides the ability
* to provide much more information about why the routine may have failed.
*/
$user = JFactory::getUser();
if ($response->type == 'Cookie')
{
$user->set('cookieLogin', true);
}
if (in_array(false, $results, true) == false)
{
$options['user'] = $user;
$options['responseType'] = $response->type;
if (isset($response->length) && isset($response->secure) && isset($response->lifetime))
{
$options['length'] = $response->length;
$options['secure'] = $response->secure;
$options['lifetime'] = $response->lifetime;
}
// The user is successfully logged in. Run the after login events
$this->triggerEvent('onUserAfterLogin', array($options));
}
return true;
}
// Trigger onUserLoginFailure Event.
$this->triggerEvent('onUserLoginFailure', array((array) $response));
// If silent is set, just return false.
if (isset($options['silent']) && $options['silent'])
{
return false;
}
// If status is success, any error will have been raised by the user plugin
if ($response->status !== JAuthentication::STATUS_SUCCESS)
{
JLog::add($response->error_message, JLog::WARNING, 'jerror');
}
return false;
} | php | public function login($credentials, $options = array())
{
// Get the global JAuthentication object.
jimport('joomla.user.authentication');
JPluginHelper::importPlugin('user');
$authenticate = JAuthentication::getInstance();
$response = $authenticate->authenticate($credentials, $options);
if ($response->status === JAuthentication::STATUS_SUCCESS)
{
// Validate that the user should be able to login (different to being authenticated).
// This permits authentication plugins blocking the user
$authorisations = $authenticate->authorise($response, $options);
foreach ($authorisations as $authorisation)
{
$denied_states = array(JAuthentication::STATUS_EXPIRED, JAuthentication::STATUS_DENIED);
if (in_array($authorisation->status, $denied_states))
{
// Trigger onUserAuthorisationFailure Event.
$this->triggerEvent('onUserAuthorisationFailure', array((array) $authorisation));
// If silent is set, just return false.
if (isset($options['silent']) && $options['silent'])
{
return false;
}
// Return the error.
switch ($authorisation->status)
{
case JAuthentication::STATUS_EXPIRED:
return JError::raiseWarning('102002', JText::_('JLIB_LOGIN_EXPIRED'));
break;
case JAuthentication::STATUS_DENIED:
return JError::raiseWarning('102003', JText::_('JLIB_LOGIN_DENIED'));
break;
default:
return JError::raiseWarning('102004', JText::_('JLIB_LOGIN_AUTHORISATION'));
break;
}
}
}
// Import the user plugin group.
JPluginHelper::importPlugin('user');
// OK, the credentials are authenticated and user is authorised. Let's fire the onLogin event.
$results = $this->triggerEvent('onUserLogin', array((array) $response, $options));
/*
* If any of the user plugins did not successfully complete the login routine
* then the whole method fails.
*
* Any errors raised should be done in the plugin as this provides the ability
* to provide much more information about why the routine may have failed.
*/
$user = JFactory::getUser();
if ($response->type == 'Cookie')
{
$user->set('cookieLogin', true);
}
if (in_array(false, $results, true) == false)
{
$options['user'] = $user;
$options['responseType'] = $response->type;
if (isset($response->length) && isset($response->secure) && isset($response->lifetime))
{
$options['length'] = $response->length;
$options['secure'] = $response->secure;
$options['lifetime'] = $response->lifetime;
}
// The user is successfully logged in. Run the after login events
$this->triggerEvent('onUserAfterLogin', array($options));
}
return true;
}
// Trigger onUserLoginFailure Event.
$this->triggerEvent('onUserLoginFailure', array((array) $response));
// If silent is set, just return false.
if (isset($options['silent']) && $options['silent'])
{
return false;
}
// If status is success, any error will have been raised by the user plugin
if ($response->status !== JAuthentication::STATUS_SUCCESS)
{
JLog::add($response->error_message, JLog::WARNING, 'jerror');
}
return false;
} | [
"public",
"function",
"login",
"(",
"$",
"credentials",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"// Get the global JAuthentication object.",
"jimport",
"(",
"'joomla.user.authentication'",
")",
";",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'user'",
")",
";",
"$",
"authenticate",
"=",
"JAuthentication",
"::",
"getInstance",
"(",
")",
";",
"$",
"response",
"=",
"$",
"authenticate",
"->",
"authenticate",
"(",
"$",
"credentials",
",",
"$",
"options",
")",
";",
"if",
"(",
"$",
"response",
"->",
"status",
"===",
"JAuthentication",
"::",
"STATUS_SUCCESS",
")",
"{",
"// Validate that the user should be able to login (different to being authenticated).",
"// This permits authentication plugins blocking the user",
"$",
"authorisations",
"=",
"$",
"authenticate",
"->",
"authorise",
"(",
"$",
"response",
",",
"$",
"options",
")",
";",
"foreach",
"(",
"$",
"authorisations",
"as",
"$",
"authorisation",
")",
"{",
"$",
"denied_states",
"=",
"array",
"(",
"JAuthentication",
"::",
"STATUS_EXPIRED",
",",
"JAuthentication",
"::",
"STATUS_DENIED",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"authorisation",
"->",
"status",
",",
"$",
"denied_states",
")",
")",
"{",
"// Trigger onUserAuthorisationFailure Event.",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserAuthorisationFailure'",
",",
"array",
"(",
"(",
"array",
")",
"$",
"authorisation",
")",
")",
";",
"// If silent is set, just return false.",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'silent'",
"]",
")",
"&&",
"$",
"options",
"[",
"'silent'",
"]",
")",
"{",
"return",
"false",
";",
"}",
"// Return the error.",
"switch",
"(",
"$",
"authorisation",
"->",
"status",
")",
"{",
"case",
"JAuthentication",
"::",
"STATUS_EXPIRED",
":",
"return",
"JError",
"::",
"raiseWarning",
"(",
"'102002'",
",",
"JText",
"::",
"_",
"(",
"'JLIB_LOGIN_EXPIRED'",
")",
")",
";",
"break",
";",
"case",
"JAuthentication",
"::",
"STATUS_DENIED",
":",
"return",
"JError",
"::",
"raiseWarning",
"(",
"'102003'",
",",
"JText",
"::",
"_",
"(",
"'JLIB_LOGIN_DENIED'",
")",
")",
";",
"break",
";",
"default",
":",
"return",
"JError",
"::",
"raiseWarning",
"(",
"'102004'",
",",
"JText",
"::",
"_",
"(",
"'JLIB_LOGIN_AUTHORISATION'",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"// Import the user plugin group.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'user'",
")",
";",
"// OK, the credentials are authenticated and user is authorised. Let's fire the onLogin event.",
"$",
"results",
"=",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserLogin'",
",",
"array",
"(",
"(",
"array",
")",
"$",
"response",
",",
"$",
"options",
")",
")",
";",
"/*\n\t\t\t * If any of the user plugins did not successfully complete the login routine\n\t\t\t * then the whole method fails.\n\t\t\t *\n\t\t\t * Any errors raised should be done in the plugin as this provides the ability\n\t\t\t * to provide much more information about why the routine may have failed.\n\t\t\t */",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"if",
"(",
"$",
"response",
"->",
"type",
"==",
"'Cookie'",
")",
"{",
"$",
"user",
"->",
"set",
"(",
"'cookieLogin'",
",",
"true",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"false",
",",
"$",
"results",
",",
"true",
")",
"==",
"false",
")",
"{",
"$",
"options",
"[",
"'user'",
"]",
"=",
"$",
"user",
";",
"$",
"options",
"[",
"'responseType'",
"]",
"=",
"$",
"response",
"->",
"type",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"length",
")",
"&&",
"isset",
"(",
"$",
"response",
"->",
"secure",
")",
"&&",
"isset",
"(",
"$",
"response",
"->",
"lifetime",
")",
")",
"{",
"$",
"options",
"[",
"'length'",
"]",
"=",
"$",
"response",
"->",
"length",
";",
"$",
"options",
"[",
"'secure'",
"]",
"=",
"$",
"response",
"->",
"secure",
";",
"$",
"options",
"[",
"'lifetime'",
"]",
"=",
"$",
"response",
"->",
"lifetime",
";",
"}",
"// The user is successfully logged in. Run the after login events",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserAfterLogin'",
",",
"array",
"(",
"$",
"options",
")",
")",
";",
"}",
"return",
"true",
";",
"}",
"// Trigger onUserLoginFailure Event.",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserLoginFailure'",
",",
"array",
"(",
"(",
"array",
")",
"$",
"response",
")",
")",
";",
"// If silent is set, just return false.",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'silent'",
"]",
")",
"&&",
"$",
"options",
"[",
"'silent'",
"]",
")",
"{",
"return",
"false",
";",
"}",
"// If status is success, any error will have been raised by the user plugin",
"if",
"(",
"$",
"response",
"->",
"status",
"!==",
"JAuthentication",
"::",
"STATUS_SUCCESS",
")",
"{",
"JLog",
"::",
"add",
"(",
"$",
"response",
"->",
"error_message",
",",
"JLog",
"::",
"WARNING",
",",
"'jerror'",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Login authentication function.
Username and encoded password are passed the onUserLogin event which
is responsible for the user validation. A successful validation updates
the current session record with the user's details.
Username and encoded password are sent as credentials (along with other
possibilities) to each observer (authentication plugin) for user
validation. Successful validation will update the current session with
the user details.
@param array $credentials Array('username' => string, 'password' => string)
@param array $options Array('remember' => boolean)
@return boolean|JException True on success, false if failed or silent handling is configured, or a JException object on authentication error.
@since 11.1
@deprecated 4.0 | [
"Login",
"authentication",
"function",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L621-L725 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.logout | public function logout($userid = null, $options = array())
{
// Get a user object from the JApplication.
$user = JFactory::getUser($userid);
// Build the credentials array.
$parameters['username'] = $user->get('username');
$parameters['id'] = $user->get('id');
// Set clientid in the options array if it hasn't been set already.
if (!isset($options['clientid']))
{
$options['clientid'] = $this->getClientId();
}
// Import the user plugin group.
JPluginHelper::importPlugin('user');
// OK, the credentials are built. Lets fire the onLogout event.
$results = $this->triggerEvent('onUserLogout', array($parameters, $options));
if (!in_array(false, $results, true))
{
$options['username'] = $user->get('username');
$results = $this->triggerEvent('onUserAfterLogout', array($options));
return true;
}
// Trigger onUserLoginFailure Event.
$this->triggerEvent('onUserLogoutFailure', array($parameters));
return false;
} | php | public function logout($userid = null, $options = array())
{
// Get a user object from the JApplication.
$user = JFactory::getUser($userid);
// Build the credentials array.
$parameters['username'] = $user->get('username');
$parameters['id'] = $user->get('id');
// Set clientid in the options array if it hasn't been set already.
if (!isset($options['clientid']))
{
$options['clientid'] = $this->getClientId();
}
// Import the user plugin group.
JPluginHelper::importPlugin('user');
// OK, the credentials are built. Lets fire the onLogout event.
$results = $this->triggerEvent('onUserLogout', array($parameters, $options));
if (!in_array(false, $results, true))
{
$options['username'] = $user->get('username');
$results = $this->triggerEvent('onUserAfterLogout', array($options));
return true;
}
// Trigger onUserLoginFailure Event.
$this->triggerEvent('onUserLogoutFailure', array($parameters));
return false;
} | [
"public",
"function",
"logout",
"(",
"$",
"userid",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"// Get a user object from the JApplication.",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
"$",
"userid",
")",
";",
"// Build the credentials array.",
"$",
"parameters",
"[",
"'username'",
"]",
"=",
"$",
"user",
"->",
"get",
"(",
"'username'",
")",
";",
"$",
"parameters",
"[",
"'id'",
"]",
"=",
"$",
"user",
"->",
"get",
"(",
"'id'",
")",
";",
"// Set clientid in the options array if it hasn't been set already.",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'clientid'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'clientid'",
"]",
"=",
"$",
"this",
"->",
"getClientId",
"(",
")",
";",
"}",
"// Import the user plugin group.",
"JPluginHelper",
"::",
"importPlugin",
"(",
"'user'",
")",
";",
"// OK, the credentials are built. Lets fire the onLogout event.",
"$",
"results",
"=",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserLogout'",
",",
"array",
"(",
"$",
"parameters",
",",
"$",
"options",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"false",
",",
"$",
"results",
",",
"true",
")",
")",
"{",
"$",
"options",
"[",
"'username'",
"]",
"=",
"$",
"user",
"->",
"get",
"(",
"'username'",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserAfterLogout'",
",",
"array",
"(",
"$",
"options",
")",
")",
";",
"return",
"true",
";",
"}",
"// Trigger onUserLoginFailure Event.",
"$",
"this",
"->",
"triggerEvent",
"(",
"'onUserLogoutFailure'",
",",
"array",
"(",
"$",
"parameters",
")",
")",
";",
"return",
"false",
";",
"}"
] | Logout authentication function.
Passed the current user information to the onUserLogout event and reverts the current
session record back to 'anonymous' parameters.
If any of the authentication plugins did not successfully complete
the logout routine then the whole method fails. Any errors raised
should be done in the plugin as this provides the ability to give
much more information about why the routine may have failed.
@param integer $userid The user to load - Can be an integer or string - If string, it is converted to ID automatically
@param array $options Array('clientid' => array of client id's)
@return boolean True on success
@since 11.1
@deprecated 4.0 | [
"Logout",
"authentication",
"function",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L745-L778 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.getTemplate | public function getTemplate($params = false)
{
$template = new stdClass;
$template->template = 'system';
$template->params = new Registry;
if ($params)
{
return $template;
}
return $template->template;
} | php | public function getTemplate($params = false)
{
$template = new stdClass;
$template->template = 'system';
$template->params = new Registry;
if ($params)
{
return $template;
}
return $template->template;
} | [
"public",
"function",
"getTemplate",
"(",
"$",
"params",
"=",
"false",
")",
"{",
"$",
"template",
"=",
"new",
"stdClass",
";",
"$",
"template",
"->",
"template",
"=",
"'system'",
";",
"$",
"template",
"->",
"params",
"=",
"new",
"Registry",
";",
"if",
"(",
"$",
"params",
")",
"{",
"return",
"$",
"template",
";",
"}",
"return",
"$",
"template",
"->",
"template",
";",
"}"
] | Gets the name of the current template.
@param boolean $params An optional associative array of configuration settings
@return mixed System is the fallback.
@since 11.1
@deprecated 4.0 | [
"Gets",
"the",
"name",
"of",
"the",
"current",
"template",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L790-L803 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.getPathway | public function getPathway($name = null, $options = array())
{
if (!isset($name))
{
$name = $this->_name;
}
try
{
$pathway = JPathway::getInstance($name, $options);
}
catch (Exception $e)
{
return;
}
return $pathway;
} | php | public function getPathway($name = null, $options = array())
{
if (!isset($name))
{
$name = $this->_name;
}
try
{
$pathway = JPathway::getInstance($name, $options);
}
catch (Exception $e)
{
return;
}
return $pathway;
} | [
"public",
"function",
"getPathway",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_name",
";",
"}",
"try",
"{",
"$",
"pathway",
"=",
"JPathway",
"::",
"getInstance",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
";",
"}",
"return",
"$",
"pathway",
";",
"}"
] | Returns the application JPathway object.
@param string $name The name of the application.
@param array $options An optional associative array of configuration settings.
@return JPathway|null A JPathway object
@since 11.1
@deprecated 4.0 | [
"Returns",
"the",
"application",
"JPathway",
"object",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L864-L881 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.getMenu | public function getMenu($name = null, $options = array())
{
if (!isset($name))
{
$name = $this->_name;
}
try
{
$menu = JMenu::getInstance($name, $options);
}
catch (Exception $e)
{
return;
}
return $menu;
} | php | public function getMenu($name = null, $options = array())
{
if (!isset($name))
{
$name = $this->_name;
}
try
{
$menu = JMenu::getInstance($name, $options);
}
catch (Exception $e)
{
return;
}
return $menu;
} | [
"public",
"function",
"getMenu",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"_name",
";",
"}",
"try",
"{",
"$",
"menu",
"=",
"JMenu",
"::",
"getInstance",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
";",
"}",
"return",
"$",
"menu",
";",
"}"
] | Returns the application JPathway object.
@param string $name The name of the application/client.
@param array $options An optional associative array of configuration settings.
@return JMenu|null JMenu object.
@since 11.1
@deprecated 4.0 | [
"Returns",
"the",
"application",
"JPathway",
"object",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L894-L911 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication._createConfiguration | protected function _createConfiguration($file)
{
JLoader::register('JConfig', $file);
// Create the JConfig object.
$config = new JConfig;
// Get the global configuration object.
$registry = JFactory::getConfig();
// Load the configuration values into the registry.
$registry->loadObject($config);
return $config;
} | php | protected function _createConfiguration($file)
{
JLoader::register('JConfig', $file);
// Create the JConfig object.
$config = new JConfig;
// Get the global configuration object.
$registry = JFactory::getConfig();
// Load the configuration values into the registry.
$registry->loadObject($config);
return $config;
} | [
"protected",
"function",
"_createConfiguration",
"(",
"$",
"file",
")",
"{",
"JLoader",
"::",
"register",
"(",
"'JConfig'",
",",
"$",
"file",
")",
";",
"// Create the JConfig object.",
"$",
"config",
"=",
"new",
"JConfig",
";",
"// Get the global configuration object.",
"$",
"registry",
"=",
"JFactory",
"::",
"getConfig",
"(",
")",
";",
"// Load the configuration values into the registry.",
"$",
"registry",
"->",
"loadObject",
"(",
"$",
"config",
")",
";",
"return",
"$",
"config",
";",
"}"
] | Create the configuration registry.
@param string $file The path to the configuration file
@return JConfig A JConfig object
@since 11.1
@deprecated 4.0 | [
"Create",
"the",
"configuration",
"registry",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L938-L952 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication._createSession | protected function _createSession($name, $auto_start = true)
{
$options = array();
$options['name'] = $name;
switch ($this->_clientId)
{
case 0:
if ($this->getCfg('force_ssl') == 2)
{
$options['force_ssl'] = true;
}
break;
case 1:
if ($this->getCfg('force_ssl') >= 1)
{
$options['force_ssl'] = true;
}
break;
}
$this->registerEvent('onAfterSessionStart', array($this, 'afterSessionStart'));
$session = JFactory::getSession($options);
$session->initialise($this->input, $this->dispatcher);
if($session->getState() != 'active')
{
if ($auto_start || JRequest::getCmd($session->getName(), null, 'cookie')) {
$session->start();
}
}
// Only update the session table if the session is active
if($session->getState() == 'active')
{
// TODO: At some point we need to get away from having session data always in the db.
$db = JFactory::getDbo();
// Remove expired sessions from the database.
$time = time();
if ($time % 2)
{
// The modulus introduces a little entropy, making the flushing less accurate
// but fires the query less than half the time.
$query = $db->getQuery(true)
->delete($db->quoteName('#__users_sessions'))
->where($db->quoteName('time') . ' < ' . $db->quote((int) ($time - $session->getExpire())));
$db->setQuery($query);
$db->execute();
}
// Check to see the the session already exists.
$handler = $this->getCfg('session_handler');
if (($handler != 'database' && ($time % 2 || $session->isNew()))
|| ($handler == 'database' && $session->isNew()))
{
$this->checkSession();
}
}
else
{
$session->set('registry', new JRegistry('session'));
$session->set('user', new JUser());
}
return $session;
} | php | protected function _createSession($name, $auto_start = true)
{
$options = array();
$options['name'] = $name;
switch ($this->_clientId)
{
case 0:
if ($this->getCfg('force_ssl') == 2)
{
$options['force_ssl'] = true;
}
break;
case 1:
if ($this->getCfg('force_ssl') >= 1)
{
$options['force_ssl'] = true;
}
break;
}
$this->registerEvent('onAfterSessionStart', array($this, 'afterSessionStart'));
$session = JFactory::getSession($options);
$session->initialise($this->input, $this->dispatcher);
if($session->getState() != 'active')
{
if ($auto_start || JRequest::getCmd($session->getName(), null, 'cookie')) {
$session->start();
}
}
// Only update the session table if the session is active
if($session->getState() == 'active')
{
// TODO: At some point we need to get away from having session data always in the db.
$db = JFactory::getDbo();
// Remove expired sessions from the database.
$time = time();
if ($time % 2)
{
// The modulus introduces a little entropy, making the flushing less accurate
// but fires the query less than half the time.
$query = $db->getQuery(true)
->delete($db->quoteName('#__users_sessions'))
->where($db->quoteName('time') . ' < ' . $db->quote((int) ($time - $session->getExpire())));
$db->setQuery($query);
$db->execute();
}
// Check to see the the session already exists.
$handler = $this->getCfg('session_handler');
if (($handler != 'database' && ($time % 2 || $session->isNew()))
|| ($handler == 'database' && $session->isNew()))
{
$this->checkSession();
}
}
else
{
$session->set('registry', new JRegistry('session'));
$session->set('user', new JUser());
}
return $session;
} | [
"protected",
"function",
"_createSession",
"(",
"$",
"name",
",",
"$",
"auto_start",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"$",
"options",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"switch",
"(",
"$",
"this",
"->",
"_clientId",
")",
"{",
"case",
"0",
":",
"if",
"(",
"$",
"this",
"->",
"getCfg",
"(",
"'force_ssl'",
")",
"==",
"2",
")",
"{",
"$",
"options",
"[",
"'force_ssl'",
"]",
"=",
"true",
";",
"}",
"break",
";",
"case",
"1",
":",
"if",
"(",
"$",
"this",
"->",
"getCfg",
"(",
"'force_ssl'",
")",
">=",
"1",
")",
"{",
"$",
"options",
"[",
"'force_ssl'",
"]",
"=",
"true",
";",
"}",
"break",
";",
"}",
"$",
"this",
"->",
"registerEvent",
"(",
"'onAfterSessionStart'",
",",
"array",
"(",
"$",
"this",
",",
"'afterSessionStart'",
")",
")",
";",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
"$",
"options",
")",
";",
"$",
"session",
"->",
"initialise",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"dispatcher",
")",
";",
"if",
"(",
"$",
"session",
"->",
"getState",
"(",
")",
"!=",
"'active'",
")",
"{",
"if",
"(",
"$",
"auto_start",
"||",
"JRequest",
"::",
"getCmd",
"(",
"$",
"session",
"->",
"getName",
"(",
")",
",",
"null",
",",
"'cookie'",
")",
")",
"{",
"$",
"session",
"->",
"start",
"(",
")",
";",
"}",
"}",
"// Only update the session table if the session is active",
"if",
"(",
"$",
"session",
"->",
"getState",
"(",
")",
"==",
"'active'",
")",
"{",
"// TODO: At some point we need to get away from having session data always in the db.",
"$",
"db",
"=",
"JFactory",
"::",
"getDbo",
"(",
")",
";",
"// Remove expired sessions from the database.",
"$",
"time",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"time",
"%",
"2",
")",
"{",
"// The modulus introduces a little entropy, making the flushing less accurate",
"// but fires the query less than half the time.",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"delete",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"where",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'time'",
")",
".",
"' < '",
".",
"$",
"db",
"->",
"quote",
"(",
"(",
"int",
")",
"(",
"$",
"time",
"-",
"$",
"session",
"->",
"getExpire",
"(",
")",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"// Check to see the the session already exists.",
"$",
"handler",
"=",
"$",
"this",
"->",
"getCfg",
"(",
"'session_handler'",
")",
";",
"if",
"(",
"(",
"$",
"handler",
"!=",
"'database'",
"&&",
"(",
"$",
"time",
"%",
"2",
"||",
"$",
"session",
"->",
"isNew",
"(",
")",
")",
")",
"||",
"(",
"$",
"handler",
"==",
"'database'",
"&&",
"$",
"session",
"->",
"isNew",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"checkSession",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"session",
"->",
"set",
"(",
"'registry'",
",",
"new",
"JRegistry",
"(",
"'session'",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'user'",
",",
"new",
"JUser",
"(",
")",
")",
";",
"}",
"return",
"$",
"session",
";",
"}"
] | Create the user session.
Old sessions are flushed based on the configuration value for the cookie
lifetime. If an existing session, then the last access time is updated.
If a new session, a session id is generated and a record is created in
the #__users_sessions table.
@param string $name The sessions name.
@return JSession JSession on success. May call exit() on database error.
@since 11.1
@deprecated 4.0 | [
"Create",
"the",
"user",
"session",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L969-L1040 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.checkSession | public function checkSession()
{
$db = JFactory::getDbo();
$session = JFactory::getSession();
$user = JFactory::getUser();
$query = $db->getQuery(true)
->select($db->quoteName('session_id'))
->from($db->quoteName('#__users_sessions'))
->where($db->quoteName('session_id') . ' = ' . $db->quote($session->getId()));
$db->setQuery($query, 0, 1);
$exists = $db->loadResult();
// If the session record doesn't exist initialise it.
if (!$exists)
{
$query->clear();
if ($session->isNew())
{
$query->insert($db->quoteName('#__users_sessions'))
->columns($db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('time'))
->values($db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . $db->quote((int) time()));
$db->setQuery($query);
}
else
{
$query->insert($db->quoteName('#__users_sessions'))
->columns(
$db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('guest') . ', ' .
$db->quoteName('time') . ', ' . $db->quoteName('userid') . ', ' . $db->quoteName('username')
)
->values(
$db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' .
$db->quote((int) $session->get('session.timer.start')) . ', ' . (int) $user->get('id') . ', ' . $db->quote($user->get('username'))
);
$db->setQuery($query);
}
// If the insert failed, exit the application.
try
{
$db->execute();
}
catch (RuntimeException $e)
{
jexit($e->getMessage());
}
}
} | php | public function checkSession()
{
$db = JFactory::getDbo();
$session = JFactory::getSession();
$user = JFactory::getUser();
$query = $db->getQuery(true)
->select($db->quoteName('session_id'))
->from($db->quoteName('#__users_sessions'))
->where($db->quoteName('session_id') . ' = ' . $db->quote($session->getId()));
$db->setQuery($query, 0, 1);
$exists = $db->loadResult();
// If the session record doesn't exist initialise it.
if (!$exists)
{
$query->clear();
if ($session->isNew())
{
$query->insert($db->quoteName('#__users_sessions'))
->columns($db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('time'))
->values($db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . $db->quote((int) time()));
$db->setQuery($query);
}
else
{
$query->insert($db->quoteName('#__users_sessions'))
->columns(
$db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('guest') . ', ' .
$db->quoteName('time') . ', ' . $db->quoteName('userid') . ', ' . $db->quoteName('username')
)
->values(
$db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' .
$db->quote((int) $session->get('session.timer.start')) . ', ' . (int) $user->get('id') . ', ' . $db->quote($user->get('username'))
);
$db->setQuery($query);
}
// If the insert failed, exit the application.
try
{
$db->execute();
}
catch (RuntimeException $e)
{
jexit($e->getMessage());
}
}
} | [
"public",
"function",
"checkSession",
"(",
")",
"{",
"$",
"db",
"=",
"JFactory",
"::",
"getDbo",
"(",
")",
";",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"$",
"user",
"=",
"JFactory",
"::",
"getUser",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
")",
"->",
"from",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"where",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
".",
"' = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
",",
"0",
",",
"1",
")",
";",
"$",
"exists",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"// If the session record doesn't exist initialise it.",
"if",
"(",
"!",
"$",
"exists",
")",
"{",
"$",
"query",
"->",
"clear",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"query",
"->",
"insert",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"columns",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'client_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'time'",
")",
")",
"->",
"values",
"(",
"$",
"db",
"->",
"quote",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"this",
"->",
"getClientId",
"(",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quote",
"(",
"(",
"int",
")",
"time",
"(",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"insert",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'#__users_sessions'",
")",
")",
"->",
"columns",
"(",
"$",
"db",
"->",
"quoteName",
"(",
"'session_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'client_id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'guest'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'time'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'userid'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quoteName",
"(",
"'username'",
")",
")",
"->",
"values",
"(",
"$",
"db",
"->",
"quote",
"(",
"$",
"session",
"->",
"getId",
"(",
")",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"this",
"->",
"getClientId",
"(",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"user",
"->",
"get",
"(",
"'guest'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quote",
"(",
"(",
"int",
")",
"$",
"session",
"->",
"get",
"(",
"'session.timer.start'",
")",
")",
".",
"', '",
".",
"(",
"int",
")",
"$",
"user",
"->",
"get",
"(",
"'id'",
")",
".",
"', '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"user",
"->",
"get",
"(",
"'username'",
")",
")",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"}",
"// If the insert failed, exit the application.",
"try",
"{",
"$",
"db",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"jexit",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Checks the user session.
If the session record doesn't exist, initialise it.
If session is new, create session variables
@return void
@since 11.1
@deprecated 4.0 | [
"Checks",
"the",
"user",
"session",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L1053-L1104 |
joomlatools/joomlatools-platform-legacy | code/application/application.php | JApplication.afterSessionStart | public function afterSessionStart()
{
$session = JFactory::getSession();
if ($session->isNew())
{
$session->set('registry', new Registry('session'));
$session->set('user', new JUser);
}
} | php | public function afterSessionStart()
{
$session = JFactory::getSession();
if ($session->isNew())
{
$session->set('registry', new Registry('session'));
$session->set('user', new JUser);
}
} | [
"public",
"function",
"afterSessionStart",
"(",
")",
"{",
"$",
"session",
"=",
"JFactory",
"::",
"getSession",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"session",
"->",
"set",
"(",
"'registry'",
",",
"new",
"Registry",
"(",
"'session'",
")",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'user'",
",",
"new",
"JUser",
")",
";",
"}",
"}"
] | After the session has been started we need to populate it with some default values.
@return void
@since 12.2
@deprecated 4.0 | [
"After",
"the",
"session",
"has",
"been",
"started",
"we",
"need",
"to",
"populate",
"it",
"with",
"some",
"default",
"values",
"."
] | train | https://github.com/joomlatools/joomlatools-platform-legacy/blob/3a76944e2f2c415faa6504754c75321a3b478c06/code/application/application.php#L1114-L1123 |
mremi/Flowdock | src/Mremi/Flowdock/Command/SendTeamInboxMessageCommand.php | SendTeamInboxMessageCommand.configure | protected function configure()
{
$this
->setName('send-team-inbox-message')
->setDescription('Sends a mail-like message to the team inbox of a flow')
->addArgument('flow-api-token', InputArgument::REQUIRED, 'The flow API token')
->addArgument('source', InputArgument::REQUIRED, 'The human readable identifier of the application that uses the Flowdock Push API')
->addArgument('from-address', InputArgument::REQUIRED, 'The email address of the message sender')
->addArgument('subject', InputArgument::REQUIRED, 'The subject line of the message')
->addArgument('content', InputArgument::REQUIRED, 'The content of the message')
->addOption('from-name', null, InputOption::VALUE_REQUIRED, 'The name of the message sender')
->addOption('reply-to', null, InputOption::VALUE_REQUIRED, 'The email address for replies')
->addOption('project', null, InputOption::VALUE_REQUIRED, 'The human readable identifier for more detailed message categorization')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The format of the message content')
->addOption('link', null, InputOption::VALUE_REQUIRED, 'The link associated with the message')
->addOption('tags', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'The message tags')
->addOption('options', null, InputOption::VALUE_REQUIRED, 'An array of options used by request');
} | php | protected function configure()
{
$this
->setName('send-team-inbox-message')
->setDescription('Sends a mail-like message to the team inbox of a flow')
->addArgument('flow-api-token', InputArgument::REQUIRED, 'The flow API token')
->addArgument('source', InputArgument::REQUIRED, 'The human readable identifier of the application that uses the Flowdock Push API')
->addArgument('from-address', InputArgument::REQUIRED, 'The email address of the message sender')
->addArgument('subject', InputArgument::REQUIRED, 'The subject line of the message')
->addArgument('content', InputArgument::REQUIRED, 'The content of the message')
->addOption('from-name', null, InputOption::VALUE_REQUIRED, 'The name of the message sender')
->addOption('reply-to', null, InputOption::VALUE_REQUIRED, 'The email address for replies')
->addOption('project', null, InputOption::VALUE_REQUIRED, 'The human readable identifier for more detailed message categorization')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The format of the message content')
->addOption('link', null, InputOption::VALUE_REQUIRED, 'The link associated with the message')
->addOption('tags', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'The message tags')
->addOption('options', null, InputOption::VALUE_REQUIRED, 'An array of options used by request');
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"'send-team-inbox-message'",
")",
"->",
"setDescription",
"(",
"'Sends a mail-like message to the team inbox of a flow'",
")",
"->",
"addArgument",
"(",
"'flow-api-token'",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"'The flow API token'",
")",
"->",
"addArgument",
"(",
"'source'",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"'The human readable identifier of the application that uses the Flowdock Push API'",
")",
"->",
"addArgument",
"(",
"'from-address'",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"'The email address of the message sender'",
")",
"->",
"addArgument",
"(",
"'subject'",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"'The subject line of the message'",
")",
"->",
"addArgument",
"(",
"'content'",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"'The content of the message'",
")",
"->",
"addOption",
"(",
"'from-name'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'The name of the message sender'",
")",
"->",
"addOption",
"(",
"'reply-to'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'The email address for replies'",
")",
"->",
"addOption",
"(",
"'project'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'The human readable identifier for more detailed message categorization'",
")",
"->",
"addOption",
"(",
"'format'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'The format of the message content'",
")",
"->",
"addOption",
"(",
"'link'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'The link associated with the message'",
")",
"->",
"addOption",
"(",
"'tags'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
"|",
"InputOption",
"::",
"VALUE_IS_ARRAY",
",",
"'The message tags'",
")",
"->",
"addOption",
"(",
"'options'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'An array of options used by request'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mremi/Flowdock/blob/287bfdcef17529055f803f2316e3ad31826e79eb/src/Mremi/Flowdock/Command/SendTeamInboxMessageCommand.php#L33-L52 |
mremi/Flowdock | src/Mremi/Flowdock/Command/SendTeamInboxMessageCommand.php | SendTeamInboxMessageCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$push = new Push($input->getArgument('flow-api-token'));
$message = TeamInboxMessage::create()
->setSource($input->getArgument('source'))
->setFromAddress($input->getArgument('from-address'))
->setSubject($input->getArgument('subject'))
->setContent($input->getArgument('content'))
->setFromName($input->getOption('from-name'))
->setReplyTo($input->getOption('reply-to'))
->setProject($input->getOption('project'))
->setFormat($input->getOption('format'))
->setLink($input->getOption('link'))
->setTags($input->getOption('tags'));
$options = $input->getOption('options') ? json_decode($input->getOption('options'), true) : array();
if ($push->sendTeamInboxMessage($message, $options)) {
$output->writeln('<info>Success:</info> the message has been sent');
return;
}
$output->writeln(sprintf('<error>Failure:</error> %s', $message->getResponseMessage()));
$output->writeln(var_export($message->getResponseErrors(), true));
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$push = new Push($input->getArgument('flow-api-token'));
$message = TeamInboxMessage::create()
->setSource($input->getArgument('source'))
->setFromAddress($input->getArgument('from-address'))
->setSubject($input->getArgument('subject'))
->setContent($input->getArgument('content'))
->setFromName($input->getOption('from-name'))
->setReplyTo($input->getOption('reply-to'))
->setProject($input->getOption('project'))
->setFormat($input->getOption('format'))
->setLink($input->getOption('link'))
->setTags($input->getOption('tags'));
$options = $input->getOption('options') ? json_decode($input->getOption('options'), true) : array();
if ($push->sendTeamInboxMessage($message, $options)) {
$output->writeln('<info>Success:</info> the message has been sent');
return;
}
$output->writeln(sprintf('<error>Failure:</error> %s', $message->getResponseMessage()));
$output->writeln(var_export($message->getResponseErrors(), true));
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"push",
"=",
"new",
"Push",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'flow-api-token'",
")",
")",
";",
"$",
"message",
"=",
"TeamInboxMessage",
"::",
"create",
"(",
")",
"->",
"setSource",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'source'",
")",
")",
"->",
"setFromAddress",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'from-address'",
")",
")",
"->",
"setSubject",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'subject'",
")",
")",
"->",
"setContent",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'content'",
")",
")",
"->",
"setFromName",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'from-name'",
")",
")",
"->",
"setReplyTo",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'reply-to'",
")",
")",
"->",
"setProject",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'project'",
")",
")",
"->",
"setFormat",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'format'",
")",
")",
"->",
"setLink",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'link'",
")",
")",
"->",
"setTags",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'tags'",
")",
")",
";",
"$",
"options",
"=",
"$",
"input",
"->",
"getOption",
"(",
"'options'",
")",
"?",
"json_decode",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'options'",
")",
",",
"true",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"$",
"push",
"->",
"sendTeamInboxMessage",
"(",
"$",
"message",
",",
"$",
"options",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<info>Success:</info> the message has been sent'",
")",
";",
"return",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'<error>Failure:</error> %s'",
",",
"$",
"message",
"->",
"getResponseMessage",
"(",
")",
")",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"var_export",
"(",
"$",
"message",
"->",
"getResponseErrors",
"(",
")",
",",
"true",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/mremi/Flowdock/blob/287bfdcef17529055f803f2316e3ad31826e79eb/src/Mremi/Flowdock/Command/SendTeamInboxMessageCommand.php#L57-L83 |
qcubed/orm | src/Codegen/SqlTable.php | SqlTable.getColumnByName | public function getColumnByName($strColumnName) {
if ($this->objColumnArray) {
foreach ($this->objColumnArray as $objColumn){
if ($objColumn->Name == $strColumnName)
return $objColumn;
}
}
return null;
} | php | public function getColumnByName($strColumnName) {
if ($this->objColumnArray) {
foreach ($this->objColumnArray as $objColumn){
if ($objColumn->Name == $strColumnName)
return $objColumn;
}
}
return null;
} | [
"public",
"function",
"getColumnByName",
"(",
"$",
"strColumnName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"objColumnArray",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"objColumnArray",
"as",
"$",
"objColumn",
")",
"{",
"if",
"(",
"$",
"objColumn",
"->",
"Name",
"==",
"$",
"strColumnName",
")",
"return",
"$",
"objColumn",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | return the SqlColumn object related to that column name
@param string $strColumnName Name of the column
@return SqlColumn | [
"return",
"the",
"SqlColumn",
"object",
"related",
"to",
"that",
"column",
"name"
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/SqlTable.php#L115-L123 |
qcubed/orm | src/Codegen/SqlTable.php | SqlTable.lookupColumnPropertyName | public function lookupColumnPropertyName($strColumnName){
$objColumn = $this->getColumnByName($strColumnName);
if ($objColumn)
return $objColumn->PropertyName;
else
return null;
} | php | public function lookupColumnPropertyName($strColumnName){
$objColumn = $this->getColumnByName($strColumnName);
if ($objColumn)
return $objColumn->PropertyName;
else
return null;
} | [
"public",
"function",
"lookupColumnPropertyName",
"(",
"$",
"strColumnName",
")",
"{",
"$",
"objColumn",
"=",
"$",
"this",
"->",
"getColumnByName",
"(",
"$",
"strColumnName",
")",
";",
"if",
"(",
"$",
"objColumn",
")",
"return",
"$",
"objColumn",
"->",
"PropertyName",
";",
"else",
"return",
"null",
";",
"}"
] | Return the property name for a given column name (false if it doesn't exists)
@param string $strColumnName name of the column
@return string | [
"Return",
"the",
"property",
"name",
"for",
"a",
"given",
"column",
"name",
"(",
"false",
"if",
"it",
"doesn",
"t",
"exists",
")"
] | train | https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Codegen/SqlTable.php#L139-L145 |
4devs/ElfinderPhpConnector | Response.php | Response.toArray | public function toArray()
{
$data = array(
'added' => $this->getAdded(true),
'api' => $this->getApi(),
'cwd' => $this->getCwd(true),
'debug' => $this->getDebug(),
'files' => $this->getFiles(true),
'list' => $this->getList(),
'netDrivers' => $this->getNetDrivers(),
'options' => $this->getOptions(),
'removed' => $this->getRemoved(true),
'tree' => $this->getTree(true),
'uplMaxSize' => $this->getUplMaxSize(),
'content' => $this->getContent(),
'size' => $this->getSize(),
'error' => $this->getError(),
'dim' => $this->getDim(),
);
return array_filter(
$data,
function ($var) {
return !is_null($var);
}
);
} | php | public function toArray()
{
$data = array(
'added' => $this->getAdded(true),
'api' => $this->getApi(),
'cwd' => $this->getCwd(true),
'debug' => $this->getDebug(),
'files' => $this->getFiles(true),
'list' => $this->getList(),
'netDrivers' => $this->getNetDrivers(),
'options' => $this->getOptions(),
'removed' => $this->getRemoved(true),
'tree' => $this->getTree(true),
'uplMaxSize' => $this->getUplMaxSize(),
'content' => $this->getContent(),
'size' => $this->getSize(),
'error' => $this->getError(),
'dim' => $this->getDim(),
);
return array_filter(
$data,
function ($var) {
return !is_null($var);
}
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'added'",
"=>",
"$",
"this",
"->",
"getAdded",
"(",
"true",
")",
",",
"'api'",
"=>",
"$",
"this",
"->",
"getApi",
"(",
")",
",",
"'cwd'",
"=>",
"$",
"this",
"->",
"getCwd",
"(",
"true",
")",
",",
"'debug'",
"=>",
"$",
"this",
"->",
"getDebug",
"(",
")",
",",
"'files'",
"=>",
"$",
"this",
"->",
"getFiles",
"(",
"true",
")",
",",
"'list'",
"=>",
"$",
"this",
"->",
"getList",
"(",
")",
",",
"'netDrivers'",
"=>",
"$",
"this",
"->",
"getNetDrivers",
"(",
")",
",",
"'options'",
"=>",
"$",
"this",
"->",
"getOptions",
"(",
")",
",",
"'removed'",
"=>",
"$",
"this",
"->",
"getRemoved",
"(",
"true",
")",
",",
"'tree'",
"=>",
"$",
"this",
"->",
"getTree",
"(",
"true",
")",
",",
"'uplMaxSize'",
"=>",
"$",
"this",
"->",
"getUplMaxSize",
"(",
")",
",",
"'content'",
"=>",
"$",
"this",
"->",
"getContent",
"(",
")",
",",
"'size'",
"=>",
"$",
"this",
"->",
"getSize",
"(",
")",
",",
"'error'",
"=>",
"$",
"this",
"->",
"getError",
"(",
")",
",",
"'dim'",
"=>",
"$",
"this",
"->",
"getDim",
"(",
")",
",",
")",
";",
"return",
"array_filter",
"(",
"$",
"data",
",",
"function",
"(",
"$",
"var",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"var",
")",
";",
"}",
")",
";",
"}"
] | get response as array.
@return array | [
"get",
"response",
"as",
"array",
"."
] | train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L80-L106 |
4devs/ElfinderPhpConnector | Response.php | Response.getAdded | public function getAdded($asArray = true)
{
$return = array();
if ($asArray && $this->added) {
foreach ($this->added as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->added;
} | php | public function getAdded($asArray = true)
{
$return = array();
if ($asArray && $this->added) {
foreach ($this->added as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->added;
} | [
"public",
"function",
"getAdded",
"(",
"$",
"asArray",
"=",
"true",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"asArray",
"&&",
"$",
"this",
"->",
"added",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"added",
"as",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"file",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"return",
"$",
"asArray",
"?",
"$",
"return",
":",
"$",
"this",
"->",
"added",
";",
"}"
] | get Added.
@param bool $asArray
@return array|FileInfo[] | [
"get",
"Added",
"."
] | train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L223-L233 |
4devs/ElfinderPhpConnector | Response.php | Response.getCwd | public function getCwd($asArray = false)
{
return $this->cwd && $asArray ? $this->cwd->toArray() : $this->cwd;
} | php | public function getCwd($asArray = false)
{
return $this->cwd && $asArray ? $this->cwd->toArray() : $this->cwd;
} | [
"public",
"function",
"getCwd",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"cwd",
"&&",
"$",
"asArray",
"?",
"$",
"this",
"->",
"cwd",
"->",
"toArray",
"(",
")",
":",
"$",
"this",
"->",
"cwd",
";",
"}"
] | get Current Working Directory.
@param bool $asArray
@return array|FileInfo | [
"get",
"Current",
"Working",
"Directory",
"."
] | train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L272-L275 |
4devs/ElfinderPhpConnector | Response.php | Response.getFiles | public function getFiles($asArray = false)
{
$return = array();
if ($asArray && $this->files) {
foreach ($this->files as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->files;
} | php | public function getFiles($asArray = false)
{
$return = array();
if ($asArray && $this->files) {
foreach ($this->files as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->files;
} | [
"public",
"function",
"getFiles",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"asArray",
"&&",
"$",
"this",
"->",
"files",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"file",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"return",
"$",
"asArray",
"?",
"$",
"return",
":",
"$",
"this",
"->",
"files",
";",
"}"
] | get Files.
@param bool $asArray
@return array|FileInfo[] | [
"get",
"Files",
"."
] | train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L355-L365 |
4devs/ElfinderPhpConnector | Response.php | Response.getTree | public function getTree($asArray = false)
{
$return = array();
if ($asArray && $this->tree) {
foreach ($this->tree as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->tree;
} | php | public function getTree($asArray = false)
{
$return = array();
if ($asArray && $this->tree) {
foreach ($this->tree as $file) {
$return[] = $file->toArray();
}
}
return $asArray ? $return : $this->tree;
} | [
"public",
"function",
"getTree",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"asArray",
"&&",
"$",
"this",
"->",
"tree",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"tree",
"as",
"$",
"file",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"file",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"return",
"$",
"asArray",
"?",
"$",
"return",
":",
"$",
"this",
"->",
"tree",
";",
"}"
] | get Tree.
@param bool $asArray
@return array|FileInfo[] | [
"get",
"Tree",
"."
] | train | https://github.com/4devs/ElfinderPhpConnector/blob/510e295dcafeaa0f796986ad87b3ed5f6b0d9338/Response.php#L503-L513 |
webforge-labs/psc-cms | lib/Psc/JS/JS.php | JS.register | public static function register($jsFile, $alias = NULL, Array $dependencies = array()) {
return self::getManager()->register($jsFile, $alias, $dependencies);
} | php | public static function register($jsFile, $alias = NULL, Array $dependencies = array()) {
return self::getManager()->register($jsFile, $alias, $dependencies);
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"jsFile",
",",
"$",
"alias",
"=",
"NULL",
",",
"Array",
"$",
"dependencies",
"=",
"array",
"(",
")",
")",
"{",
"return",
"self",
"::",
"getManager",
"(",
")",
"->",
"register",
"(",
"$",
"jsFile",
",",
"$",
"alias",
",",
"$",
"dependencies",
")",
";",
"}"
] | Macht dem Standard JS Manager eine JS Datei bekannt | [
"Macht",
"dem",
"Standard",
"JS",
"Manager",
"eine",
"JS",
"Datei",
"bekannt"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/JS/JS.php#L20-L22 |
picamator/CacheManager | src/Cache/CacheItemFactory.php | CacheItemFactory.create | public function create(string $key, array $value) : CacheItemInterface
{
/** @var \Cache\Adapter\Common\CacheItem $cacheItem */
$cacheItem = $this->objectManager->create($this->className, [$key])
->set($value);
return $cacheItem;
} | php | public function create(string $key, array $value) : CacheItemInterface
{
/** @var \Cache\Adapter\Common\CacheItem $cacheItem */
$cacheItem = $this->objectManager->create($this->className, [$key])
->set($value);
return $cacheItem;
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"value",
")",
":",
"CacheItemInterface",
"{",
"/** @var \\Cache\\Adapter\\Common\\CacheItem $cacheItem */",
"$",
"cacheItem",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"create",
"(",
"$",
"this",
"->",
"className",
",",
"[",
"$",
"key",
"]",
")",
"->",
"set",
"(",
"$",
"value",
")",
";",
"return",
"$",
"cacheItem",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/Cache/CacheItemFactory.php#L41-L48 |
maniaplanet/maniaplanet-ws-sdk | libraries/Maniaplanet/WebServices/ManiaConnect/Player.php | Player.getPlayer | function getPlayer()
{
$player = self::$persistance->getVariable('player');
if(!$player)
{
if($this->getAccessToken())
{
$player = $this->executeOAuth2('GET', '/player/');
self::$persistance->setVariable('player', $player);
}
}
return $player;
} | php | function getPlayer()
{
$player = self::$persistance->getVariable('player');
if(!$player)
{
if($this->getAccessToken())
{
$player = $this->executeOAuth2('GET', '/player/');
self::$persistance->setVariable('player', $player);
}
}
return $player;
} | [
"function",
"getPlayer",
"(",
")",
"{",
"$",
"player",
"=",
"self",
"::",
"$",
"persistance",
"->",
"getVariable",
"(",
"'player'",
")",
";",
"if",
"(",
"!",
"$",
"player",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getAccessToken",
"(",
")",
")",
"{",
"$",
"player",
"=",
"$",
"this",
"->",
"executeOAuth2",
"(",
"'GET'",
",",
"'/player/'",
")",
";",
"self",
"::",
"$",
"persistance",
"->",
"setVariable",
"(",
"'player'",
",",
"$",
"player",
")",
";",
"}",
"}",
"return",
"$",
"player",
";",
"}"
] | This is the first method to call when you have an authorization code.
It will retrieve an access token if possible and then call the service to
retrieve a basic object about the authentified player.
You do not need any special scope to call this service, as long as you
have an access token.
If an access token is not found, it will return false
@return object A player object or false if no access token is found | [
"This",
"is",
"the",
"first",
"method",
"to",
"call",
"when",
"you",
"have",
"an",
"authorization",
"code",
".",
"It",
"will",
"retrieve",
"an",
"access",
"token",
"if",
"possible",
"and",
"then",
"call",
"the",
"service",
"to",
"retrieve",
"a",
"basic",
"object",
"about",
"the",
"authentified",
"player",
"."
] | train | https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaConnect/Player.php#L33-L45 |
webforge-labs/psc-cms | lib/PHPWord/PHPWord/Shared/File.php | PHPWord_Shared_File.realpath | public static function realpath($pFilename) {
// Returnvalue
$returnValue = '';
// Try using realpath()
$returnValue = realpath($pFilename);
// Found something?
if ($returnValue == '' || is_null($returnValue)) {
$pathArray = split('/' , $pFilename);
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
for ($i = 0; $i < count($pathArray); ++$i) {
if ($pathArray[$i] == '..' && $i > 0) {
unset($pathArray[$i]);
unset($pathArray[$i - 1]);
break;
}
}
}
$returnValue = implode('/', $pathArray);
}
// Return
return $returnValue;
} | php | public static function realpath($pFilename) {
// Returnvalue
$returnValue = '';
// Try using realpath()
$returnValue = realpath($pFilename);
// Found something?
if ($returnValue == '' || is_null($returnValue)) {
$pathArray = split('/' , $pFilename);
while(in_array('..', $pathArray) && $pathArray[0] != '..') {
for ($i = 0; $i < count($pathArray); ++$i) {
if ($pathArray[$i] == '..' && $i > 0) {
unset($pathArray[$i]);
unset($pathArray[$i - 1]);
break;
}
}
}
$returnValue = implode('/', $pathArray);
}
// Return
return $returnValue;
} | [
"public",
"static",
"function",
"realpath",
"(",
"$",
"pFilename",
")",
"{",
"// Returnvalue",
"$",
"returnValue",
"=",
"''",
";",
"// Try using realpath()",
"$",
"returnValue",
"=",
"realpath",
"(",
"$",
"pFilename",
")",
";",
"// Found something?",
"if",
"(",
"$",
"returnValue",
"==",
"''",
"||",
"is_null",
"(",
"$",
"returnValue",
")",
")",
"{",
"$",
"pathArray",
"=",
"split",
"(",
"'/'",
",",
"$",
"pFilename",
")",
";",
"while",
"(",
"in_array",
"(",
"'..'",
",",
"$",
"pathArray",
")",
"&&",
"$",
"pathArray",
"[",
"0",
"]",
"!=",
"'..'",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"pathArray",
")",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"pathArray",
"[",
"$",
"i",
"]",
"==",
"'..'",
"&&",
"$",
"i",
">",
"0",
")",
"{",
"unset",
"(",
"$",
"pathArray",
"[",
"$",
"i",
"]",
")",
";",
"unset",
"(",
"$",
"pathArray",
"[",
"$",
"i",
"-",
"1",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"$",
"returnValue",
"=",
"implode",
"(",
"'/'",
",",
"$",
"pathArray",
")",
";",
"}",
"// Return",
"return",
"$",
"returnValue",
";",
"}"
] | Returns canonicalized absolute pathname, also for ZIP archives
@param string $pFilename
@return string | [
"Returns",
"canonicalized",
"absolute",
"pathname",
"also",
"for",
"ZIP",
"archives"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Shared/File.php#L66-L90 |
2amigos/yiifoundation | widgets/Alert.php | Alert.init | public function init()
{
if (is_string($this->config)) {
throw new InvalidConfigException('"config" must be of type array.');
}
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.alerts.js' : 'foundation.min.js'
);
if (!isset($this->config)) {
$this->config = array(
Enum::COLOR_REGULAR => array(),
Enum::COLOR_ALERT => array(),
Enum::COLOR_SECONDARY => array(),
Enum::COLOR_SUCCESS => array(),
);
}
$this->htmlOptions = ArrayHelper::defaultValue('id', $this->getId(), $this->htmlOptions);
parent::init();
} | php | public function init()
{
if (is_string($this->config)) {
throw new InvalidConfigException('"config" must be of type array.');
}
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.alerts.js' : 'foundation.min.js'
);
if (!isset($this->config)) {
$this->config = array(
Enum::COLOR_REGULAR => array(),
Enum::COLOR_ALERT => array(),
Enum::COLOR_SECONDARY => array(),
Enum::COLOR_SUCCESS => array(),
);
}
$this->htmlOptions = ArrayHelper::defaultValue('id', $this->getId(), $this->htmlOptions);
parent::init();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"config",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'\"config\" must be of type array.'",
")",
";",
"}",
"$",
"this",
"->",
"assets",
"=",
"array",
"(",
"'js'",
"=>",
"YII_DEBUG",
"?",
"'foundation/foundation.alerts.js'",
":",
"'foundation.min.js'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
")",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"array",
"(",
"Enum",
"::",
"COLOR_REGULAR",
"=>",
"array",
"(",
")",
",",
"Enum",
"::",
"COLOR_ALERT",
"=>",
"array",
"(",
")",
",",
"Enum",
"::",
"COLOR_SECONDARY",
"=>",
"array",
"(",
")",
",",
"Enum",
"::",
"COLOR_SUCCESS",
"=>",
"array",
"(",
")",
",",
")",
";",
"}",
"$",
"this",
"->",
"htmlOptions",
"=",
"ArrayHelper",
"::",
"defaultValue",
"(",
"'id'",
",",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"this",
"->",
"htmlOptions",
")",
";",
"parent",
"::",
"init",
"(",
")",
";",
"}"
] | Initializes the widget
@throws \foundation\exception\InvalidConfigException | [
"Initializes",
"the",
"widget"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Alert.php#L44-L63 |
2amigos/yiifoundation | widgets/Alert.php | Alert.renderAlert | public function renderAlert()
{
$user = \Yii::app()->user;
if (count($user->getFlashes(false)) == 0) {
return;
}
$alerts = array();
foreach ($this->config as $style => $config) {
if ($user->hasFlash($style)) {
$options = ArrayHelper::getValue($config, 'htmlOptions', array());
Html::addCssClass($options, $style);
$close = ArrayHelper::getValue($config, 'close', '×');
$alerts[] = \foundation\helpers\Alert::alert($user->getFlash($style), $options, $close);
}
}
$this->registerEvents("#{$this->htmlOptions['id']} > .alert-box", $this->events);
return \CHtml::tag('div', $this->htmlOptions, implode("\n", $alerts));
} | php | public function renderAlert()
{
$user = \Yii::app()->user;
if (count($user->getFlashes(false)) == 0) {
return;
}
$alerts = array();
foreach ($this->config as $style => $config) {
if ($user->hasFlash($style)) {
$options = ArrayHelper::getValue($config, 'htmlOptions', array());
Html::addCssClass($options, $style);
$close = ArrayHelper::getValue($config, 'close', '×');
$alerts[] = \foundation\helpers\Alert::alert($user->getFlash($style), $options, $close);
}
}
$this->registerEvents("#{$this->htmlOptions['id']} > .alert-box", $this->events);
return \CHtml::tag('div', $this->htmlOptions, implode("\n", $alerts));
} | [
"public",
"function",
"renderAlert",
"(",
")",
"{",
"$",
"user",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"user",
";",
"if",
"(",
"count",
"(",
"$",
"user",
"->",
"getFlashes",
"(",
"false",
")",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"alerts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"as",
"$",
"style",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"hasFlash",
"(",
"$",
"style",
")",
")",
"{",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"config",
",",
"'htmlOptions'",
",",
"array",
"(",
")",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"options",
",",
"$",
"style",
")",
";",
"$",
"close",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"config",
",",
"'close'",
",",
"'×'",
")",
";",
"$",
"alerts",
"[",
"]",
"=",
"\\",
"foundation",
"\\",
"helpers",
"\\",
"Alert",
"::",
"alert",
"(",
"$",
"user",
"->",
"getFlash",
"(",
"$",
"style",
")",
",",
"$",
"options",
",",
"$",
"close",
")",
";",
"}",
"}",
"$",
"this",
"->",
"registerEvents",
"(",
"\"#{$this->htmlOptions['id']} > .alert-box\"",
",",
"$",
"this",
"->",
"events",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'div'",
",",
"$",
"this",
"->",
"htmlOptions",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"alerts",
")",
")",
";",
"}"
] | Renders the alert
@return string the rendering result | [
"Renders",
"the",
"alert"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Alert.php#L77-L95 |
nyeholt/silverstripe-external-content | thirdparty/Zend/Validate/Sitemap/Loc.php | Zend_Validate_Sitemap_Loc.isValid | public function isValid($value)
{
$this->_setValue($value);
if (!is_string($value)) {
return false;
}
return Zend_Uri::check($value);
} | php | public function isValid($value)
{
$this->_setValue($value);
if (!is_string($value)) {
return false;
}
return Zend_Uri::check($value);
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Zend_Uri",
"::",
"check",
"(",
"$",
"value",
")",
";",
"}"
] | Validates if a string is valid as a sitemap location
@link http://www.sitemaps.org/protocol.php#locdef <loc>
@param string $value value to validate
@return boolean | [
"Validates",
"if",
"a",
"string",
"is",
"valid",
"as",
"a",
"sitemap",
"location"
] | train | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Sitemap/Loc.php#L68-L77 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.setWsConfig | public function setWsConfig($wsConfig = array())
{
$this->wsConfig = $wsConfig;
$this->logger->debug(__FUNCTION__, 'Web Service Config => ' . json_encode($this->wsConfig));
return $this;
} | php | public function setWsConfig($wsConfig = array())
{
$this->wsConfig = $wsConfig;
$this->logger->debug(__FUNCTION__, 'Web Service Config => ' . json_encode($this->wsConfig));
return $this;
} | [
"public",
"function",
"setWsConfig",
"(",
"$",
"wsConfig",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"wsConfig",
"=",
"$",
"wsConfig",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Web Service Config => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function setWsConfig
@author: 713uk13m <[email protected]>
@time : 11/22/18 15:30
@param array $wsConfig
@return $this | [
"Function",
"setWsConfig"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L168-L174 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.setInputData | public function setInputData($inputData = array())
{
$this->inputData = $inputData;
$this->logger->debug(__FUNCTION__, 'Input Data => ' . json_encode($this->inputData));
return $this;
} | php | public function setInputData($inputData = array())
{
$this->inputData = $inputData;
$this->logger->debug(__FUNCTION__, 'Input Data => ' . json_encode($this->inputData));
return $this;
} | [
"public",
"function",
"setInputData",
"(",
"$",
"inputData",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"inputData",
"=",
"$",
"inputData",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function setInputData
@author: 713uk13m <[email protected]>
@time : 11/22/18 15:20
@param array $inputData
@return $this | [
"Function",
"setInputData"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L216-L222 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToWebService | public function sendSmsToWebService()
{
$getConfig = $this->getConfigData();
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To Web Service => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$mo = $this->inputData['mo'];
$note = $this->inputData['note'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$note = trim($note);
$url = $this->wsConfig['url'];
$method = empty($this->wsConfig['method']) ? $getConfig[self::CONFIG_KEY_WEB_SERVICE]['method'] : $this->wsConfig['method'];
$method = strtoupper($method);
$validStr = $phone_number . $this->wsConfig['prefix'] . $msg . $this->wsConfig['prefix'] . $this->wsConfig['token'];
$params = array(
'msisdn' => $phone_number,
'mo' => $mo,
'mt' => $msg,
'note' => $note . self::NOTE_PREFIX . $phone_number . self::NOTE_PREFIX . date('Y-m-d') . self::NOTE_PREFIX . $this->wsConfig['short_code'],
'signature' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To Webservice');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
if ($method == 'JSON') {
$requestSms = $this->requests->jsonRequest($url, $params);
} elseif ($method == 'XML') {
$requestSms = $this->requests->xmlRequest($url, $params);
} elseif ($method == 'POST') {
$requestSms = $this->requests->sendRequest($url, $params, 'POST');
} else {
$requestSms = $this->requests->sendRequest($url, $params);
}
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$responseSms = json_decode(trim($requestSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['mt'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (isset($responseSms->ec) && $responseSms->ec == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['mt'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['mt'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToWebService()
{
$getConfig = $this->getConfigData();
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To Web Service => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$mo = $this->inputData['mo'];
$note = $this->inputData['note'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$note = trim($note);
$url = $this->wsConfig['url'];
$method = empty($this->wsConfig['method']) ? $getConfig[self::CONFIG_KEY_WEB_SERVICE]['method'] : $this->wsConfig['method'];
$method = strtoupper($method);
$validStr = $phone_number . $this->wsConfig['prefix'] . $msg . $this->wsConfig['prefix'] . $this->wsConfig['token'];
$params = array(
'msisdn' => $phone_number,
'mo' => $mo,
'mt' => $msg,
'note' => $note . self::NOTE_PREFIX . $phone_number . self::NOTE_PREFIX . date('Y-m-d') . self::NOTE_PREFIX . $this->wsConfig['short_code'],
'signature' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To Webservice');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
if ($method == 'JSON') {
$requestSms = $this->requests->jsonRequest($url, $params);
} elseif ($method == 'XML') {
$requestSms = $this->requests->xmlRequest($url, $params);
} elseif ($method == 'POST') {
$requestSms = $this->requests->sendRequest($url, $params, 'POST');
} else {
$requestSms = $this->requests->sendRequest($url, $params);
}
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$responseSms = json_decode(trim($requestSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['mt'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (isset($responseSms->ec) && $responseSms->ec == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['mt'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['mt'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToWebService",
"(",
")",
"{",
"$",
"getConfig",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS To Web Service => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"mo",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
";",
"$",
"note",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"note",
"=",
"trim",
"(",
"$",
"note",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"empty",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
")",
"?",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_WEB_SERVICE",
"]",
"[",
"'method'",
"]",
":",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"$",
"validStr",
"=",
"$",
"phone_number",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
".",
"$",
"msg",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
";",
"$",
"params",
"=",
"array",
"(",
"'msisdn'",
"=>",
"$",
"phone_number",
",",
"'mo'",
"=>",
"$",
"mo",
",",
"'mt'",
"=>",
"$",
"msg",
",",
"'note'",
"=>",
"$",
"note",
".",
"self",
"::",
"NOTE_PREFIX",
".",
"$",
"phone_number",
".",
"self",
"::",
"NOTE_PREFIX",
".",
"date",
"(",
"'Y-m-d'",
")",
".",
"self",
"::",
"NOTE_PREFIX",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'short_code'",
"]",
",",
"'signature'",
"=>",
"md5",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To Webservice'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Method: '",
".",
"json_encode",
"(",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms String to Valid: '",
".",
"json_encode",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Token: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Prefix: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
")",
")",
";",
"if",
"(",
"$",
"method",
"==",
"'JSON'",
")",
"{",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"jsonRequest",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'XML'",
")",
"{",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"xmlRequest",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'POST'",
")",
"{",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"'POST'",
")",
";",
"}",
"else",
"{",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"$",
"responseSms",
"=",
"json_decode",
"(",
"trim",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"$",
"responseSms",
"===",
"NULL",
"||",
"empty",
"(",
"$",
"responseSms",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"API_ERROR_CODE",
",",
"'description'",
"=>",
"'Error'",
",",
"'data'",
"=>",
"array",
"(",
"'msg'",
"=>",
"'Không gửi được MT. Response từ API về không hợp lệ',",
"",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'mt'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"responseSms",
"->",
"ec",
")",
"&&",
"$",
"responseSms",
"->",
"ec",
"==",
"self",
"::",
"SEND_SMS_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'description'",
"=>",
"'Success'",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'mt'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'description'",
"=>",
"'Failed'",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'mt'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToWebService
@author: 713uk13m <[email protected]>
@time : 11/22/18 15:28
@return $this | [
"Function",
"sendSmsToWebService"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L260-L361 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToSmppVersion2 | public function sendSmsToSmppVersion2()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to SMPP Version 2 => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$callbackParams = isset($this->inputData['callbackParams']) ? $this->inputData['callbackParams'] : NULL;
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$callBack = (!empty($this->wsConfig['callbackUrl'])) ? trim($this->wsConfig['callbackUrl']) . trim(base64_encode($callbackParams), '=') : NULL;
$params = array(
'service' => $this->wsConfig['short_code'],
'msisdn' => $phone_number,
'msg' => $msg,
'callbackUrl' => $callBack
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMPP Version 2');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$responseSms = json_decode(trim($requestSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'service' => $params['service'],
'phone_number' => $params['msisdn'],
'msg' => $params['msg'],
'callbackUrl' => $params['callbackUrl'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (isset($responseSms->ec) && $responseSms->ec == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'service' => $params['service'],
'phone_number' => $params['msisdn'],
'msg' => $params['msg'],
'callbackUrl' => $params['callbackUrl'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'service' => $params['service'],
'phone_number' => $params['msisdn'],
'msg' => $params['msg'],
'callbackUrl' => $params['callbackUrl'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToSmppVersion2()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to SMPP Version 2 => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$callbackParams = isset($this->inputData['callbackParams']) ? $this->inputData['callbackParams'] : NULL;
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$callBack = (!empty($this->wsConfig['callbackUrl'])) ? trim($this->wsConfig['callbackUrl']) . trim(base64_encode($callbackParams), '=') : NULL;
$params = array(
'service' => $this->wsConfig['short_code'],
'msisdn' => $phone_number,
'msg' => $msg,
'callbackUrl' => $callBack
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMPP Version 2');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$responseSms = json_decode(trim($requestSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'service' => $params['service'],
'phone_number' => $params['msisdn'],
'msg' => $params['msg'],
'callbackUrl' => $params['callbackUrl'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (isset($responseSms->ec) && $responseSms->ec == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'service' => $params['service'],
'phone_number' => $params['msisdn'],
'msg' => $params['msg'],
'callbackUrl' => $params['callbackUrl'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'service' => $params['service'],
'phone_number' => $params['msisdn'],
'msg' => $params['msg'],
'callbackUrl' => $params['callbackUrl'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToSmppVersion2",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS to SMPP Version 2 => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"callbackParams",
"=",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'callbackParams'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'callbackParams'",
"]",
":",
"NULL",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"callBack",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'callbackUrl'",
"]",
")",
")",
"?",
"trim",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'callbackUrl'",
"]",
")",
".",
"trim",
"(",
"base64_encode",
"(",
"$",
"callbackParams",
")",
",",
"'='",
")",
":",
"NULL",
";",
"$",
"params",
"=",
"array",
"(",
"'service'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'short_code'",
"]",
",",
"'msisdn'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'callbackUrl'",
"=>",
"$",
"callBack",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To SMPP Version 2'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Method: '",
".",
"json_encode",
"(",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"method",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"$",
"responseSms",
"=",
"json_decode",
"(",
"trim",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"$",
"responseSms",
"===",
"NULL",
"||",
"empty",
"(",
"$",
"responseSms",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"API_ERROR_CODE",
",",
"'description'",
"=>",
"'Error'",
",",
"'data'",
"=>",
"array",
"(",
"'msg'",
"=>",
"'Không gửi được MT. Response từ API về không hợp lệ',",
"",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'service'",
"=>",
"$",
"params",
"[",
"'service'",
"]",
",",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'msg'",
"]",
",",
"'callbackUrl'",
"=>",
"$",
"params",
"[",
"'callbackUrl'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"responseSms",
"->",
"ec",
")",
"&&",
"$",
"responseSms",
"->",
"ec",
"==",
"self",
"::",
"SEND_SMS_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'description'",
"=>",
"'Success'",
",",
"'data'",
"=>",
"array",
"(",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'service'",
"=>",
"$",
"params",
"[",
"'service'",
"]",
",",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'msg'",
"]",
",",
"'callbackUrl'",
"=>",
"$",
"params",
"[",
"'callbackUrl'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'description'",
"=>",
"'Failed'",
",",
"'data'",
"=>",
"array",
"(",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'service'",
"=>",
"$",
"params",
"[",
"'service'",
"]",
",",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'msg'",
"]",
",",
"'callbackUrl'",
"=>",
"$",
"params",
"[",
"'callbackUrl'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToSmppVersion2
@author: 713uk13m <[email protected]>
@time : 11/22/18 15:48
@return $this | [
"Function",
"sendSmsToSmppVersion2"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L371-L464 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToSmppVersion1 | public function sendSmsToSmppVersion1()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to SMPP Version 1 => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$params = array(
'username' => $this->wsConfig['username'],
'password' => $this->wsConfig['password'],
'to' => $phone_number,
'text' => $msg
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMPP Version 1');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$responseSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($responseSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $responseSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['to'],
'msg' => $params['text'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if ($responseSms == self::SMPP_VER_1_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'data' => array('requestResult' => $responseSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['to'],
'msg' => $params['text'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'data' => array('requestResult' => $responseSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['to'],
'msg' => $params['text'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToSmppVersion1()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to SMPP Version 1 => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$params = array(
'username' => $this->wsConfig['username'],
'password' => $this->wsConfig['password'],
'to' => $phone_number,
'text' => $msg
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMPP Version 1');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$responseSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($responseSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $responseSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['to'],
'msg' => $params['text'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if ($responseSms == self::SMPP_VER_1_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'data' => array('requestResult' => $responseSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['to'],
'msg' => $params['text'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'data' => array('requestResult' => $responseSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['to'],
'msg' => $params['text'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToSmppVersion1",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS to SMPP Version 1 => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"params",
"=",
"array",
"(",
"'username'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'username'",
"]",
",",
"'password'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'password'",
"]",
",",
"'to'",
"=>",
"$",
"phone_number",
",",
"'text'",
"=>",
"$",
"msg",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To SMPP Version 1'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Method: '",
".",
"json_encode",
"(",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"responseSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"method",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"responseSms",
")",
")",
";",
"if",
"(",
"$",
"responseSms",
"===",
"NULL",
"||",
"empty",
"(",
"$",
"responseSms",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"API_ERROR_CODE",
",",
"'description'",
"=>",
"'Error'",
",",
"'data'",
"=>",
"array",
"(",
"'msg'",
"=>",
"'Không gửi được MT. Response từ API về không hợp lệ',",
"",
"'requestResult'",
"=>",
"$",
"responseSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'to'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'text'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"responseSms",
"==",
"self",
"::",
"SMPP_VER_1_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'description'",
"=>",
"'Success'",
",",
"'data'",
"=>",
"array",
"(",
"'requestResult'",
"=>",
"$",
"responseSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'to'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'text'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'description'",
"=>",
"'Failed'",
",",
"'data'",
"=>",
"array",
"(",
"'requestResult'",
"=>",
"$",
"responseSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'to'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'text'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToSmppVersion1
@author: 713uk13m <[email protected]>
@time : 11/22/18 15:49
@return $this | [
"Function",
"sendSmsToSmppVersion1"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L474-L559 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToGatewayWithoutMo | public function sendSmsToGatewayWithoutMo()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To SMS Gateway without MO => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$short_code = $this->inputData['short_code'];
// Kết nối theo mẫu tài liệu kết nối gửi MT chủ động
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$validStr = $this->wsConfig['pnId'] . $phone_number . $msg . $this->wsConfig['token'];
$params = array(
// Tham số API
'api' => $this->wsConfig['api'],
// Số điện thoại cần gửi
'phone' => $phone_number,
// Nội dung tin nhắn
'message' => $msg,
// Đầu số gửi tin nhắn
'service' => $short_code,
// Tham số định danh đối tác
'pnid' => $this->wsConfig['pnId'],
// Chữ ký xác thực
'signature' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMS Gateway Without MO');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if (array_key_exists($requestSms, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITHOUT_MO]['responseMap'])) {
$result = array(
'status' => $requestSms,
'desc' => $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITHOUT_MO]['responseMap'][$requestSms],
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['phone'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_ERROR,
'desc' => 'Gửi tin thất bại',
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['phone'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToGatewayWithoutMo()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To SMS Gateway without MO => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$short_code = $this->inputData['short_code'];
// Kết nối theo mẫu tài liệu kết nối gửi MT chủ động
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$validStr = $this->wsConfig['pnId'] . $phone_number . $msg . $this->wsConfig['token'];
$params = array(
// Tham số API
'api' => $this->wsConfig['api'],
// Số điện thoại cần gửi
'phone' => $phone_number,
// Nội dung tin nhắn
'message' => $msg,
// Đầu số gửi tin nhắn
'service' => $short_code,
// Tham số định danh đối tác
'pnid' => $this->wsConfig['pnId'],
// Chữ ký xác thực
'signature' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMS Gateway Without MO');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if (array_key_exists($requestSms, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITHOUT_MO]['responseMap'])) {
$result = array(
'status' => $requestSms,
'desc' => $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITHOUT_MO]['responseMap'][$requestSms],
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['phone'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_ERROR,
'desc' => 'Gửi tin thất bại',
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['phone'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToGatewayWithoutMo",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS To SMS Gateway without MO => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"getConfig",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"short_code",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'short_code'",
"]",
";",
"// Kết nối theo mẫu tài liệu kết nối gửi MT chủ động",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"validStr",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'pnId'",
"]",
".",
"$",
"phone_number",
".",
"$",
"msg",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
";",
"$",
"params",
"=",
"array",
"(",
"// Tham số API",
"'api'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'api'",
"]",
",",
"// Số điện thoại cần gửi",
"'phone'",
"=>",
"$",
"phone_number",
",",
"// Nội dung tin nhắn",
"'message'",
"=>",
"$",
"msg",
",",
"// Đầu số gửi tin nhắn",
"'service'",
"=>",
"$",
"short_code",
",",
"// Tham số định danh đối tác",
"'pnid'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'pnId'",
"]",
",",
"// Chữ ký xác thực",
"'signature'",
"=>",
"md5",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To SMS Gateway Without MO'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Method: '",
".",
"json_encode",
"(",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms String to Valid: '",
".",
"json_encode",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Token: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Prefix: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
")",
")",
";",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"method",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"requestSms",
",",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_WITHOUT_MO",
"]",
"[",
"'responseMap'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"$",
"requestSms",
",",
"'desc'",
"=>",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_WITHOUT_MO",
"]",
"[",
"'responseMap'",
"]",
"[",
"$",
"requestSms",
"]",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'phone'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'message'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'desc'",
"=>",
"'Gửi tin thất bại',",
"",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'phone'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'message'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToGatewayWithoutMo
@author: 713uk13m <[email protected]>
@time : 11/22/18 15:54
@return $this | [
"Function",
"sendSmsToGatewayWithoutMo"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L569-L646 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToGatewayWithMo | public function sendSmsToGatewayWithMo()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To SMS Gateway with MO => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$moId = $this->inputData['moId'];
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$msgIndex = $this->inputData['msgIndex'];
$totalMt = $this->inputData['totalMt'];
// Kết nối theo mẫu tài liệu kết nối gửi MT chủ động
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$telco_id = $this->phoneNumber->detect_carrier($phone_number, TRUE);
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$validStr = $moId . $this->wsConfig['prefix'] . $this->wsConfig['token'];
$params = array(
// Tham số API
'pnid' => $this->wsConfig['pnId'],
'npid' => $this->wsConfig['npId'],
'moid' => $moId,
'receiver' => $phone_number,
'type' => $this->wsConfig['type'],
'message' => $msg,
'cpid' => $telco_id,
'msgindex' => (empty($msgIndex)) ? $msgIndex : $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['msgindex'],
'totalMT' => (empty($totalMt)) ? $totalMt : $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['totalMT'],
'signal' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMS Gateway With MoId');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if (array_key_exists($requestSms, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['responseMap'])) {
$result = array(
'status' => $requestSms,
'desc' => $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['responseMap'][$requestSms],
'request_data' => ['url' => $url, 'params' => $params, 'method' => $method],
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['receiver'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_ERROR,
'desc' => 'Gửi tin thất bại',
'request_data' => ['url' => $url, 'params' => $params, 'method' => $method],
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['receiver'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToGatewayWithMo()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To SMS Gateway with MO => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$moId = $this->inputData['moId'];
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$msgIndex = $this->inputData['msgIndex'];
$totalMt = $this->inputData['totalMt'];
// Kết nối theo mẫu tài liệu kết nối gửi MT chủ động
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$telco_id = $this->phoneNumber->detect_carrier($phone_number, TRUE);
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$validStr = $moId . $this->wsConfig['prefix'] . $this->wsConfig['token'];
$params = array(
// Tham số API
'pnid' => $this->wsConfig['pnId'],
'npid' => $this->wsConfig['npId'],
'moid' => $moId,
'receiver' => $phone_number,
'type' => $this->wsConfig['type'],
'message' => $msg,
'cpid' => $telco_id,
'msgindex' => (empty($msgIndex)) ? $msgIndex : $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['msgindex'],
'totalMT' => (empty($totalMt)) ? $totalMt : $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['totalMT'],
'signal' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To SMS Gateway With MoId');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if (array_key_exists($requestSms, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['responseMap'])) {
$result = array(
'status' => $requestSms,
'desc' => $getConfig[self::CONFIG_KEY_SMS_GATEWAY_WITH_MO]['responseMap'][$requestSms],
'request_data' => ['url' => $url, 'params' => $params, 'method' => $method],
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['receiver'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_ERROR,
'desc' => 'Gửi tin thất bại',
'request_data' => ['url' => $url, 'params' => $params, 'method' => $method],
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $params['receiver'],
'msg' => $params['message'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToGatewayWithMo",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS To SMS Gateway with MO => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"getConfig",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
")",
";",
"$",
"moId",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'moId'",
"]",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"msgIndex",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msgIndex'",
"]",
";",
"$",
"totalMt",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'totalMt'",
"]",
";",
"// Kết nối theo mẫu tài liệu kết nối gửi MT chủ động",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"telco_id",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"detect_carrier",
"(",
"$",
"phone_number",
",",
"TRUE",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"validStr",
"=",
"$",
"moId",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
".",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
";",
"$",
"params",
"=",
"array",
"(",
"// Tham số API",
"'pnid'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'pnId'",
"]",
",",
"'npid'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'npId'",
"]",
",",
"'moid'",
"=>",
"$",
"moId",
",",
"'receiver'",
"=>",
"$",
"phone_number",
",",
"'type'",
"=>",
"$",
"this",
"->",
"wsConfig",
"[",
"'type'",
"]",
",",
"'message'",
"=>",
"$",
"msg",
",",
"'cpid'",
"=>",
"$",
"telco_id",
",",
"'msgindex'",
"=>",
"(",
"empty",
"(",
"$",
"msgIndex",
")",
")",
"?",
"$",
"msgIndex",
":",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_WITH_MO",
"]",
"[",
"'msgindex'",
"]",
",",
"'totalMT'",
"=>",
"(",
"empty",
"(",
"$",
"totalMt",
")",
")",
"?",
"$",
"totalMt",
":",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_WITH_MO",
"]",
"[",
"'totalMT'",
"]",
",",
"'signal'",
"=>",
"md5",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To SMS Gateway With MoId'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Method: '",
".",
"json_encode",
"(",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms String to Valid: '",
".",
"json_encode",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Token: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Prefix: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
")",
")",
";",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"method",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"requestSms",
",",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_WITH_MO",
"]",
"[",
"'responseMap'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"$",
"requestSms",
",",
"'desc'",
"=>",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_WITH_MO",
"]",
"[",
"'responseMap'",
"]",
"[",
"$",
"requestSms",
"]",
",",
"'request_data'",
"=>",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
"]",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'receiver'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'message'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'desc'",
"=>",
"'Gửi tin thất bại',",
"",
"'request_data'",
"=>",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
"]",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'receiver'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'message'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToGatewayWithMo
@author: 713uk13m <[email protected]>
@time : 11/22/18 16:01
@return $this | [
"Function",
"sendSmsToGatewayWithMo"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L656-L735 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToVasCloudGatewayVina | public function sendSmsToVasCloudGatewayVina()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To VinaPhone VasCloud Gateway => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$phone_number = $this->inputData['phone_number'];
$mo = $this->inputData['mo'];
$msg = $this->inputData['msg'];
$send_method = $this->inputData['send_method'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$mo = trim($mo);
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
// Send SMS to VasCloud
$transaction_id = ceil(microtime(TRUE) * 1000);
$default_moid = $this->wsConfig['default_moid'];
$source_address = $this->wsConfig['shortcode'];
$sms_brandname = $this->wsConfig['brandname'];
$sms_service_code = $this->wsConfig['service_code'];
$sms_content_type = $this->wsConfig['content_type'];
$sms_user_name = $this->wsConfig['username_cp'];
$authenticate = $this->wsConfig['authenticate'];
$acount_send_sms = $this->wsConfig['account'];
$sms_cp_code = $this->wsConfig['cp_code'];
$sms_cp_charge = $this->wsConfig['cp_charge'];
$price = $this->wsConfig['default_price'];
$input_package_code = $this->wsConfig['default_package'];
$sms_authenticate = md5(md5($transaction_id . $sms_user_name) . md5($acount_send_sms . $phone_number) . $authenticate);
// Data XML gui len SMSGW Vascloud
$config = DataRepository::getData('configSendSmsToVasCloudGatewayVina');
$content_xml = "<MODULE>SMSGW</MODULE><MESSAGE_TYPE>REQUEST</MESSAGE_TYPE><COMMAND><transaction_id>$transaction_id</transaction_id>" . "<mo_id>" . $default_moid . "</mo_id><destination_address>" . $phone_number . "</destination_address><source_address>" . $source_address . "</source_address>" . "<brandname>" . $sms_brandname . "</brandname><content_type>" . $sms_content_type . "</content_type><user_name>" . $sms_user_name . "</user_name>" . "<authenticate>" . $sms_authenticate . "</authenticate><info>" . $msg . "</info><command_code>" . $mo . "</command_code>" . "<cp_code>" . $sms_cp_code . "</cp_code><cp_charge>" . $sms_cp_charge . "</cp_charge><service_code>" . $sms_service_code . "</service_code>" . "<package_code>$input_package_code</package_code><package_price>$price</package_price></COMMAND>";
$data_xml = $config['open_request'] . $content_xml . $config['end_request'];
$this->logger->info(__FUNCTION__, 'Send Request ' . $method . ' to URL ' . $url);
$this->logger->info('Send Request Data ' . $data_xml);
$requestSms = (($send_method !== NULL) && ($send_method == 'Msg_Log')) ? $getConfig[self::CONFIG_KEY_SMS_GATEWAY_VINA_VAS_CLOUD]['responseIsSuccess'] : $this->requests->xmlRequest($url, $data_xml, $this->wsConfig['timeout']);
$this->logger->info(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if (empty($requestSms)) {
$result = array(
'status' => self::EXIT_ERROR,
'msg' => 'Parse Request is Error',
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$errorId = $this->requests->xmlGetValue($requestSms, "<error_id>", "</error_id>");
$errorDesc = $this->requests->xmlGetValue($requestSms, "<error_desc>", "</error_desc>");
if ($errorId == self::SEND_SMS_SUCCESS) {
$result = array(
'status' => self::EXIT_SUCCESS,
'msg' => 'Gửi tin nhắn thành công',
'data' => array('error_id' => $errorId, 'error_desc' => $errorDesc),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_ERROR,
'msg' => 'Gửi tin nhắn thất bại',
'data' => array('error_id' => $errorId, 'error_desc' => $errorDesc),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToVasCloudGatewayVina()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS To VinaPhone VasCloud Gateway => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$phone_number = $this->inputData['phone_number'];
$mo = $this->inputData['mo'];
$msg = $this->inputData['msg'];
$send_method = $this->inputData['send_method'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$mo = trim($mo);
$msg = trim($msg);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
// Send SMS to VasCloud
$transaction_id = ceil(microtime(TRUE) * 1000);
$default_moid = $this->wsConfig['default_moid'];
$source_address = $this->wsConfig['shortcode'];
$sms_brandname = $this->wsConfig['brandname'];
$sms_service_code = $this->wsConfig['service_code'];
$sms_content_type = $this->wsConfig['content_type'];
$sms_user_name = $this->wsConfig['username_cp'];
$authenticate = $this->wsConfig['authenticate'];
$acount_send_sms = $this->wsConfig['account'];
$sms_cp_code = $this->wsConfig['cp_code'];
$sms_cp_charge = $this->wsConfig['cp_charge'];
$price = $this->wsConfig['default_price'];
$input_package_code = $this->wsConfig['default_package'];
$sms_authenticate = md5(md5($transaction_id . $sms_user_name) . md5($acount_send_sms . $phone_number) . $authenticate);
// Data XML gui len SMSGW Vascloud
$config = DataRepository::getData('configSendSmsToVasCloudGatewayVina');
$content_xml = "<MODULE>SMSGW</MODULE><MESSAGE_TYPE>REQUEST</MESSAGE_TYPE><COMMAND><transaction_id>$transaction_id</transaction_id>" . "<mo_id>" . $default_moid . "</mo_id><destination_address>" . $phone_number . "</destination_address><source_address>" . $source_address . "</source_address>" . "<brandname>" . $sms_brandname . "</brandname><content_type>" . $sms_content_type . "</content_type><user_name>" . $sms_user_name . "</user_name>" . "<authenticate>" . $sms_authenticate . "</authenticate><info>" . $msg . "</info><command_code>" . $mo . "</command_code>" . "<cp_code>" . $sms_cp_code . "</cp_code><cp_charge>" . $sms_cp_charge . "</cp_charge><service_code>" . $sms_service_code . "</service_code>" . "<package_code>$input_package_code</package_code><package_price>$price</package_price></COMMAND>";
$data_xml = $config['open_request'] . $content_xml . $config['end_request'];
$this->logger->info(__FUNCTION__, 'Send Request ' . $method . ' to URL ' . $url);
$this->logger->info('Send Request Data ' . $data_xml);
$requestSms = (($send_method !== NULL) && ($send_method == 'Msg_Log')) ? $getConfig[self::CONFIG_KEY_SMS_GATEWAY_VINA_VAS_CLOUD]['responseIsSuccess'] : $this->requests->xmlRequest($url, $data_xml, $this->wsConfig['timeout']);
$this->logger->info(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if (empty($requestSms)) {
$result = array(
'status' => self::EXIT_ERROR,
'msg' => 'Parse Request is Error',
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$errorId = $this->requests->xmlGetValue($requestSms, "<error_id>", "</error_id>");
$errorDesc = $this->requests->xmlGetValue($requestSms, "<error_desc>", "</error_desc>");
if ($errorId == self::SEND_SMS_SUCCESS) {
$result = array(
'status' => self::EXIT_SUCCESS,
'msg' => 'Gửi tin nhắn thành công',
'data' => array('error_id' => $errorId, 'error_desc' => $errorDesc),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_ERROR,
'msg' => 'Gửi tin nhắn thất bại',
'data' => array('error_id' => $errorId, 'error_desc' => $errorDesc),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => $method),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToVasCloudGatewayVina",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS To VinaPhone VasCloud Gateway => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"getConfig",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"mo",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"send_method",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'send_method'",
"]",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"mo",
"=",
"trim",
"(",
"$",
"mo",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"// Send SMS to VasCloud",
"$",
"transaction_id",
"=",
"ceil",
"(",
"microtime",
"(",
"TRUE",
")",
"*",
"1000",
")",
";",
"$",
"default_moid",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'default_moid'",
"]",
";",
"$",
"source_address",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'shortcode'",
"]",
";",
"$",
"sms_brandname",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'brandname'",
"]",
";",
"$",
"sms_service_code",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'service_code'",
"]",
";",
"$",
"sms_content_type",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'content_type'",
"]",
";",
"$",
"sms_user_name",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'username_cp'",
"]",
";",
"$",
"authenticate",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'authenticate'",
"]",
";",
"$",
"acount_send_sms",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'account'",
"]",
";",
"$",
"sms_cp_code",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'cp_code'",
"]",
";",
"$",
"sms_cp_charge",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'cp_charge'",
"]",
";",
"$",
"price",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'default_price'",
"]",
";",
"$",
"input_package_code",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'default_package'",
"]",
";",
"$",
"sms_authenticate",
"=",
"md5",
"(",
"md5",
"(",
"$",
"transaction_id",
".",
"$",
"sms_user_name",
")",
".",
"md5",
"(",
"$",
"acount_send_sms",
".",
"$",
"phone_number",
")",
".",
"$",
"authenticate",
")",
";",
"// Data XML gui len SMSGW Vascloud",
"$",
"config",
"=",
"DataRepository",
"::",
"getData",
"(",
"'configSendSmsToVasCloudGatewayVina'",
")",
";",
"$",
"content_xml",
"=",
"\"<MODULE>SMSGW</MODULE><MESSAGE_TYPE>REQUEST</MESSAGE_TYPE><COMMAND><transaction_id>$transaction_id</transaction_id>\"",
".",
"\"<mo_id>\"",
".",
"$",
"default_moid",
".",
"\"</mo_id><destination_address>\"",
".",
"$",
"phone_number",
".",
"\"</destination_address><source_address>\"",
".",
"$",
"source_address",
".",
"\"</source_address>\"",
".",
"\"<brandname>\"",
".",
"$",
"sms_brandname",
".",
"\"</brandname><content_type>\"",
".",
"$",
"sms_content_type",
".",
"\"</content_type><user_name>\"",
".",
"$",
"sms_user_name",
".",
"\"</user_name>\"",
".",
"\"<authenticate>\"",
".",
"$",
"sms_authenticate",
".",
"\"</authenticate><info>\"",
".",
"$",
"msg",
".",
"\"</info><command_code>\"",
".",
"$",
"mo",
".",
"\"</command_code>\"",
".",
"\"<cp_code>\"",
".",
"$",
"sms_cp_code",
".",
"\"</cp_code><cp_charge>\"",
".",
"$",
"sms_cp_charge",
".",
"\"</cp_charge><service_code>\"",
".",
"$",
"sms_service_code",
".",
"\"</service_code>\"",
".",
"\"<package_code>$input_package_code</package_code><package_price>$price</package_price></COMMAND>\"",
";",
"$",
"data_xml",
"=",
"$",
"config",
"[",
"'open_request'",
"]",
".",
"$",
"content_xml",
".",
"$",
"config",
"[",
"'end_request'",
"]",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send Request '",
".",
"$",
"method",
".",
"' to URL '",
".",
"$",
"url",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Send Request Data '",
".",
"$",
"data_xml",
")",
";",
"$",
"requestSms",
"=",
"(",
"(",
"$",
"send_method",
"!==",
"NULL",
")",
"&&",
"(",
"$",
"send_method",
"==",
"'Msg_Log'",
")",
")",
"?",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_VINA_VAS_CLOUD",
"]",
"[",
"'responseIsSuccess'",
"]",
":",
"$",
"this",
"->",
"requests",
"->",
"xmlRequest",
"(",
"$",
"url",
",",
"$",
"data_xml",
",",
"$",
"this",
"->",
"wsConfig",
"[",
"'timeout'",
"]",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"requestSms",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'msg'",
"=>",
"'Parse Request is Error'",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"data_xml",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"errorId",
"=",
"$",
"this",
"->",
"requests",
"->",
"xmlGetValue",
"(",
"$",
"requestSms",
",",
"\"<error_id>\"",
",",
"\"</error_id>\"",
")",
";",
"$",
"errorDesc",
"=",
"$",
"this",
"->",
"requests",
"->",
"xmlGetValue",
"(",
"$",
"requestSms",
",",
"\"<error_desc>\"",
",",
"\"</error_desc>\"",
")",
";",
"if",
"(",
"$",
"errorId",
"==",
"self",
"::",
"SEND_SMS_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'msg'",
"=>",
"'Gửi tin nhắn thành công',",
"",
"'data'",
"=>",
"array",
"(",
"'error_id'",
"=>",
"$",
"errorId",
",",
"'error_desc'",
"=>",
"$",
"errorDesc",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"data_xml",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'msg'",
"=>",
"'Gửi tin nhắn thất bại',",
"",
"'data'",
"=>",
"array",
"(",
"'error_id'",
"=>",
"$",
"errorId",
",",
"'error_desc'",
"=>",
"$",
"errorDesc",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"data_xml",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToVasCloudGatewayVina
@author: 713uk13m <[email protected]>
@time : 2018-12-06 23:17
@return $this | [
"Function",
"sendSmsToVasCloudGatewayVina"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L745-L838 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToViettelWithMPSGateway | public function sendSmsToViettelWithMPSGateway()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to Viettel MPS Gateway => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$alias = $this->inputData['alias'];
$params = $this->inputData['params'];
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$content = trim($msg);
$url = $this->wsConfig['api_link'];
$username = $this->wsConfig['username'];
$password = $this->wsConfig['password'];
$shortcode = $this->wsConfig['shortcode'];
$timeout = $this->wsConfig['timeout'];
// Request Data với XML thuần
$data_xml = '<?xml version="1.0"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://smsws/xsd"><soapenv:Header/><soapenv:Body><xsd:smsRequest><xsd:username>' . $username . '</xsd:username><xsd:password>' . $password . '</xsd:password><xsd:msisdn>' . $phone_number . '</xsd:msisdn><xsd:content>' . $content . '</xsd:content><xsd:shortcode>' . $shortcode . '</xsd:shortcode><xsd:alias>' . $alias . '</xsd:alias><xsd:params>' . $params . '</xsd:params></xsd:smsRequest></soapenv:Body></soapenv:Envelope>';
$this->logger->info(__FUNCTION__, 'Send Request to URL ' . $url);
$this->logger->info('Send Request Data ' . $data_xml);
$requestSms = $this->requests->xmlRequest($url, $data_xml, $timeout); // Gửi Request SMS
$this->logger->info(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$returnResult = $this->requests->xmlGetValue($requestSms, "<return>", "</return>"); // Display the result
if ($returnResult == self::SEND_SMS_SUCCESS) {
$result = array(
'status' => self::EXIT_SUCCESS,
'msg' => 'Gửi tin nhắn thành công',
'data' => array('returnResult' => $returnResult, 'requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (array_key_exists($returnResult, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_VIETTEL]['responseMap'])) {
$result = array(
'status' => self::EXIT_ERROR,
'msg' => 'Gửi tin nhắn thất bại',
'data' => array(
'returnResult' => $returnResult,
'returnResultDesc' => Utils::strToEn($getConfig['responseMap'][$returnResult]),
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_CONFIG,
'msg' => 'Lỗi hệ thống',
'data' => array('returnResult' => $returnResult, 'requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToViettelWithMPSGateway()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to Viettel MPS Gateway => ' . json_encode($this->inputData));
$getConfig = $this->getConfigData();
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$alias = $this->inputData['alias'];
$params = $this->inputData['params'];
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$content = trim($msg);
$url = $this->wsConfig['api_link'];
$username = $this->wsConfig['username'];
$password = $this->wsConfig['password'];
$shortcode = $this->wsConfig['shortcode'];
$timeout = $this->wsConfig['timeout'];
// Request Data với XML thuần
$data_xml = '<?xml version="1.0"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://smsws/xsd"><soapenv:Header/><soapenv:Body><xsd:smsRequest><xsd:username>' . $username . '</xsd:username><xsd:password>' . $password . '</xsd:password><xsd:msisdn>' . $phone_number . '</xsd:msisdn><xsd:content>' . $content . '</xsd:content><xsd:shortcode>' . $shortcode . '</xsd:shortcode><xsd:alias>' . $alias . '</xsd:alias><xsd:params>' . $params . '</xsd:params></xsd:smsRequest></soapenv:Body></soapenv:Envelope>';
$this->logger->info(__FUNCTION__, 'Send Request to URL ' . $url);
$this->logger->info('Send Request Data ' . $data_xml);
$requestSms = $this->requests->xmlRequest($url, $data_xml, $timeout); // Gửi Request SMS
$this->logger->info(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$returnResult = $this->requests->xmlGetValue($requestSms, "<return>", "</return>"); // Display the result
if ($returnResult == self::SEND_SMS_SUCCESS) {
$result = array(
'status' => self::EXIT_SUCCESS,
'msg' => 'Gửi tin nhắn thành công',
'data' => array('returnResult' => $returnResult, 'requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (array_key_exists($returnResult, $getConfig[self::CONFIG_KEY_SMS_GATEWAY_VIETTEL]['responseMap'])) {
$result = array(
'status' => self::EXIT_ERROR,
'msg' => 'Gửi tin nhắn thất bại',
'data' => array(
'returnResult' => $returnResult,
'returnResultDesc' => Utils::strToEn($getConfig['responseMap'][$returnResult]),
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'status' => self::EXIT_CONFIG,
'msg' => 'Lỗi hệ thống',
'data' => array('returnResult' => $returnResult, 'requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $data_xml, 'method' => 'POST'),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToViettelWithMPSGateway",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS to Viettel MPS Gateway => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"getConfig",
"=",
"$",
"this",
"->",
"getConfigData",
"(",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"alias",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'alias'",
"]",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'params'",
"]",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"content",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'api_link'",
"]",
";",
"$",
"username",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'username'",
"]",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'password'",
"]",
";",
"$",
"shortcode",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'shortcode'",
"]",
";",
"$",
"timeout",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'timeout'",
"]",
";",
"// Request Data với XML thuần",
"$",
"data_xml",
"=",
"'<?xml version=\"1.0\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://smsws/xsd\"><soapenv:Header/><soapenv:Body><xsd:smsRequest><xsd:username>'",
".",
"$",
"username",
".",
"'</xsd:username><xsd:password>'",
".",
"$",
"password",
".",
"'</xsd:password><xsd:msisdn>'",
".",
"$",
"phone_number",
".",
"'</xsd:msisdn><xsd:content>'",
".",
"$",
"content",
".",
"'</xsd:content><xsd:shortcode>'",
".",
"$",
"shortcode",
".",
"'</xsd:shortcode><xsd:alias>'",
".",
"$",
"alias",
".",
"'</xsd:alias><xsd:params>'",
".",
"$",
"params",
".",
"'</xsd:params></xsd:smsRequest></soapenv:Body></soapenv:Envelope>'",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send Request to URL '",
".",
"$",
"url",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Send Request Data '",
".",
"$",
"data_xml",
")",
";",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"xmlRequest",
"(",
"$",
"url",
",",
"$",
"data_xml",
",",
"$",
"timeout",
")",
";",
"// Gửi Request SMS",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"$",
"returnResult",
"=",
"$",
"this",
"->",
"requests",
"->",
"xmlGetValue",
"(",
"$",
"requestSms",
",",
"\"<return>\"",
",",
"\"</return>\"",
")",
";",
"// Display the result",
"if",
"(",
"$",
"returnResult",
"==",
"self",
"::",
"SEND_SMS_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'msg'",
"=>",
"'Gửi tin nhắn thành công',",
"",
"'data'",
"=>",
"array",
"(",
"'returnResult'",
"=>",
"$",
"returnResult",
",",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"data_xml",
",",
"'method'",
"=>",
"'POST'",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"returnResult",
",",
"$",
"getConfig",
"[",
"self",
"::",
"CONFIG_KEY_SMS_GATEWAY_VIETTEL",
"]",
"[",
"'responseMap'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'msg'",
"=>",
"'Gửi tin nhắn thất bại',",
"",
"'data'",
"=>",
"array",
"(",
"'returnResult'",
"=>",
"$",
"returnResult",
",",
"'returnResultDesc'",
"=>",
"Utils",
"::",
"strToEn",
"(",
"$",
"getConfig",
"[",
"'responseMap'",
"]",
"[",
"$",
"returnResult",
"]",
")",
",",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"data_xml",
",",
"'method'",
"=>",
"'POST'",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"self",
"::",
"EXIT_CONFIG",
",",
"'msg'",
"=>",
"'Lỗi hệ thống',",
"",
"'data'",
"=>",
"array",
"(",
"'returnResult'",
"=>",
"$",
"returnResult",
",",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"data_xml",
",",
"'method'",
"=>",
"'POST'",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToViettelWithMPSGateway
@author: 713uk13m <[email protected]>
@time : 11/22/18 16:19
@return $this | [
"Function",
"sendSmsToViettelWithMPSGateway"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L848-L930 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToViettelWithWebService | public function sendSmsToViettelWithWebService()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to Viettel Web Service => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$alias = $this->inputData['alias'];
$params = $this->inputData['params'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$content = trim($msg);
$url = $this->wsConfig['api_link'];
$token = $this->wsConfig['token'];
$prefix = $this->wsConfig['prefix'];
$method = $this->wsConfig['method'];
$validStr = $phone_number . $prefix . $content . $prefix . $params . $prefix . $token;
// Request Data với XML thuần
$params = array(
'msisdn' => $phone_number,
'content' => $content,
'alias' => $alias,
'type' => $params,
'signature' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To Webservice');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$responseSms = json_decode(trim($requestSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['content'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (isset($responseSms->Result) && $responseSms->Result == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['content'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['content'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToViettelWithWebService()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to Viettel Web Service => ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$alias = $this->inputData['alias'];
$params = $this->inputData['params'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$content = trim($msg);
$url = $this->wsConfig['api_link'];
$token = $this->wsConfig['token'];
$prefix = $this->wsConfig['prefix'];
$method = $this->wsConfig['method'];
$validStr = $phone_number . $prefix . $content . $prefix . $params . $prefix . $token;
// Request Data với XML thuần
$params = array(
'msisdn' => $phone_number,
'content' => $content,
'alias' => $alias,
'type' => $params,
'signature' => md5($validStr)
);
$this->logger->debug(__FUNCTION__, 'SendSms To Webservice');
$this->logger->debug(__FUNCTION__, 'SendSms Method: ' . json_encode($method));
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$this->logger->debug(__FUNCTION__, 'SendSms String to Valid: ' . json_encode($validStr));
$this->logger->debug(__FUNCTION__, 'SendSms Token: ' . json_encode($this->wsConfig['token']));
$this->logger->debug(__FUNCTION__, 'SendSms Prefix: ' . json_encode($this->wsConfig['prefix']));
$requestSms = $this->requests->sendRequest($url, $params, $method);
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
$responseSms = json_decode(trim($requestSms));
if ($responseSms === NULL || empty($responseSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['content'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
if (isset($responseSms->Result) && $responseSms->Result == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['content'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'data' => array('requestResult' => $requestSms),
'request_data' => array('url' => $url, 'params' => $params, 'method' => $method),
'response_data' => $responseSms,
'content_data' => array(
'phone_number' => $params['msisdn'],
'msg' => $params['content'],
'mo' => isset($this->inputData['mo']) ? $this->inputData['mo'] : NULL,
'note' => isset($this->inputData['note']) ? $this->inputData['note'] : NULL,
'subCode' => isset($this->inputData['subCode']) ? $this->inputData['subCode'] : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToViettelWithWebService",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS to Viettel Web Service => '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"alias",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'alias'",
"]",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'params'",
"]",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"content",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'api_link'",
"]",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
";",
"$",
"prefix",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"validStr",
"=",
"$",
"phone_number",
".",
"$",
"prefix",
".",
"$",
"content",
".",
"$",
"prefix",
".",
"$",
"params",
".",
"$",
"prefix",
".",
"$",
"token",
";",
"// Request Data với XML thuần",
"$",
"params",
"=",
"array",
"(",
"'msisdn'",
"=>",
"$",
"phone_number",
",",
"'content'",
"=>",
"$",
"content",
",",
"'alias'",
"=>",
"$",
"alias",
",",
"'type'",
"=>",
"$",
"params",
",",
"'signature'",
"=>",
"md5",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To Webservice'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Method: '",
".",
"json_encode",
"(",
"$",
"method",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms String to Valid: '",
".",
"json_encode",
"(",
"$",
"validStr",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Token: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'token'",
"]",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Prefix: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"wsConfig",
"[",
"'prefix'",
"]",
")",
")",
";",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"requests",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"method",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"$",
"responseSms",
"=",
"json_decode",
"(",
"trim",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"$",
"responseSms",
"===",
"NULL",
"||",
"empty",
"(",
"$",
"responseSms",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"API_ERROR_CODE",
",",
"'description'",
"=>",
"'Error'",
",",
"'data'",
"=>",
"array",
"(",
"'msg'",
"=>",
"'Không gửi được MT. Response từ API về không hợp lệ',",
"",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'content'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"responseSms",
"->",
"Result",
")",
"&&",
"$",
"responseSms",
"->",
"Result",
"==",
"self",
"::",
"SEND_SMS_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'description'",
"=>",
"'Success'",
",",
"'data'",
"=>",
"array",
"(",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'content'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'description'",
"=>",
"'Failed'",
",",
"'data'",
"=>",
"array",
"(",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
",",
"'method'",
"=>",
"$",
"method",
")",
",",
"'response_data'",
"=>",
"$",
"responseSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"params",
"[",
"'msisdn'",
"]",
",",
"'msg'",
"=>",
"$",
"params",
"[",
"'content'",
"]",
",",
"'mo'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
":",
"NULL",
",",
"'note'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
":",
"NULL",
",",
"'subCode'",
"=>",
"isset",
"(",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
")",
"?",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToViettelWithWebService
@author: 713uk13m <[email protected]>
@time : 11/22/18 16:20
@return $this | [
"Function",
"sendSmsToViettelWithWebService"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L940-L1035 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToMobiFoneWithCSPSendMessage | public function sendSmsToMobiFoneWithCSPSendMessage()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to MobiFone CSP=> ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$mo = $this->inputData['mo'];
$note = $this->inputData['note'];
$subCode = $this->inputData['subCode'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$note = trim($note);
$subCode = trim($subCode);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$serviceCode = $this->wsConfig['ServiceCode'];
$useBrandName = $this->wsConfig['UseBrandName'];
$username = $this->wsConfig['username'];
$password = $this->wsConfig['password'];
$params = array(
'ServiceCode' => $serviceCode,
'ISDN' => $phone_number,
'Content' => $msg,
'UseBrandname' => $useBrandName,
'User' => $username,
'Pass' => $password
);
$this->logger->debug(__FUNCTION__, 'SendSms To Webservice');
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$requestSms = $this->soapRequests->setEndpoint($url)->setData($params)->setCallFunction('sendMessage')->setFieldResult('ResultCode')->clientRequestSOAP();
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if ($requestSms === NULL || empty($requestSms) || !is_array($requestSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => !empty($mo) ? $mo : NULL,
'note' => !empty($note) ? $note : NULL,
'subCode' => !empty($subCode) ? $subCode : NULL
)
);
} else {
if (isset($requestSms['status']) && $requestSms['status'] == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'request_data' => array('url' => $url, 'params' => $params),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => !empty($mo) ? $mo : NULL,
'note' => !empty($note) ? $note : NULL,
'subCode' => !empty($subCode) ? $subCode : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'request_data' => array('url' => $url, 'params' => $params),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => !empty($mo) ? $mo : NULL,
'note' => !empty($note) ? $note : NULL,
'subCode' => !empty($subCode) ? $subCode : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToMobiFoneWithCSPSendMessage()
{
$this->logger->debug(__FUNCTION__, 'Input Data Send SMS to MobiFone CSP=> ' . json_encode($this->inputData));
$phone_number = $this->inputData['phone_number'];
$msg = $this->inputData['msg'];
$mo = $this->inputData['mo'];
$note = $this->inputData['note'];
$subCode = $this->inputData['subCode'];
$phone_number = $this->phoneNumber->vn_convert_phone_number($phone_number, 'new');
$msg = trim($msg);
$note = trim($note);
$subCode = trim($subCode);
$url = $this->wsConfig['url'];
$method = $this->wsConfig['method'];
$serviceCode = $this->wsConfig['ServiceCode'];
$useBrandName = $this->wsConfig['UseBrandName'];
$username = $this->wsConfig['username'];
$password = $this->wsConfig['password'];
$params = array(
'ServiceCode' => $serviceCode,
'ISDN' => $phone_number,
'Content' => $msg,
'UseBrandname' => $useBrandName,
'User' => $username,
'Pass' => $password
);
$this->logger->debug(__FUNCTION__, 'SendSms To Webservice');
$this->logger->debug(__FUNCTION__, 'MT Message Length: ' . $this->lengthMtMessage($msg));
if (strtoupper($method) == 'GET') {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url . '?' . http_build_query($params)));
} else {
$this->logger->debug(__FUNCTION__, 'SendSms Url: ' . json_encode($url));
$this->logger->debug(__FUNCTION__, 'SendSms Params: ' . json_encode($params));
}
$requestSms = $this->soapRequests->setEndpoint($url)->setData($params)->setCallFunction('sendMessage')->setFieldResult('ResultCode')->clientRequestSOAP();
$this->logger->debug(__FUNCTION__, 'SendSms Result: ' . json_encode($requestSms));
if ($requestSms === NULL || empty($requestSms) || !is_array($requestSms)) {
$result = array(
'code' => self::API_ERROR_CODE,
'description' => 'Error',
'data' => array(
'msg' => 'Không gửi được MT. Response từ API về không hợp lệ',
'requestResult' => $requestSms
),
'request_data' => array('url' => $url, 'params' => $params),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => !empty($mo) ? $mo : NULL,
'note' => !empty($note) ? $note : NULL,
'subCode' => !empty($subCode) ? $subCode : NULL
)
);
} else {
if (isset($requestSms['status']) && $requestSms['status'] == self::SEND_SMS_SUCCESS) {
$result = array(
'code' => self::EXIT_SUCCESS,
'description' => 'Success',
'request_data' => array('url' => $url, 'params' => $params),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => !empty($mo) ? $mo : NULL,
'note' => !empty($note) ? $note : NULL,
'subCode' => !empty($subCode) ? $subCode : NULL
)
);
} else {
$result = array(
'code' => self::EXIT_ERROR,
'description' => 'Failed',
'request_data' => array('url' => $url, 'params' => $params),
'response_data' => $requestSms,
'content_data' => array(
'phone_number' => $phone_number,
'msg' => $msg,
'mo' => !empty($mo) ? $mo : NULL,
'note' => !empty($note) ? $note : NULL,
'subCode' => !empty($subCode) ? $subCode : NULL
)
);
}
}
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToMobiFoneWithCSPSendMessage",
"(",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'Input Data Send SMS to MobiFone CSP=> '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"inputData",
")",
")",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'phone_number'",
"]",
";",
"$",
"msg",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'msg'",
"]",
";",
"$",
"mo",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'mo'",
"]",
";",
"$",
"note",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'note'",
"]",
";",
"$",
"subCode",
"=",
"$",
"this",
"->",
"inputData",
"[",
"'subCode'",
"]",
";",
"$",
"phone_number",
"=",
"$",
"this",
"->",
"phoneNumber",
"->",
"vn_convert_phone_number",
"(",
"$",
"phone_number",
",",
"'new'",
")",
";",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"$",
"note",
"=",
"trim",
"(",
"$",
"note",
")",
";",
"$",
"subCode",
"=",
"trim",
"(",
"$",
"subCode",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'url'",
"]",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'method'",
"]",
";",
"$",
"serviceCode",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'ServiceCode'",
"]",
";",
"$",
"useBrandName",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'UseBrandName'",
"]",
";",
"$",
"username",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'username'",
"]",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"wsConfig",
"[",
"'password'",
"]",
";",
"$",
"params",
"=",
"array",
"(",
"'ServiceCode'",
"=>",
"$",
"serviceCode",
",",
"'ISDN'",
"=>",
"$",
"phone_number",
",",
"'Content'",
"=>",
"$",
"msg",
",",
"'UseBrandname'",
"=>",
"$",
"useBrandName",
",",
"'User'",
"=>",
"$",
"username",
",",
"'Pass'",
"=>",
"$",
"password",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms To Webservice'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'MT Message Length: '",
".",
"$",
"this",
"->",
"lengthMtMessage",
"(",
"$",
"msg",
")",
")",
";",
"if",
"(",
"strtoupper",
"(",
"$",
"method",
")",
"==",
"'GET'",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"params",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Url: '",
".",
"json_encode",
"(",
"$",
"url",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Params: '",
".",
"json_encode",
"(",
"$",
"params",
")",
")",
";",
"}",
"$",
"requestSms",
"=",
"$",
"this",
"->",
"soapRequests",
"->",
"setEndpoint",
"(",
"$",
"url",
")",
"->",
"setData",
"(",
"$",
"params",
")",
"->",
"setCallFunction",
"(",
"'sendMessage'",
")",
"->",
"setFieldResult",
"(",
"'ResultCode'",
")",
"->",
"clientRequestSOAP",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"__FUNCTION__",
",",
"'SendSms Result: '",
".",
"json_encode",
"(",
"$",
"requestSms",
")",
")",
";",
"if",
"(",
"$",
"requestSms",
"===",
"NULL",
"||",
"empty",
"(",
"$",
"requestSms",
")",
"||",
"!",
"is_array",
"(",
"$",
"requestSms",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"API_ERROR_CODE",
",",
"'description'",
"=>",
"'Error'",
",",
"'data'",
"=>",
"array",
"(",
"'msg'",
"=>",
"'Không gửi được MT. Response từ API về không hợp lệ',",
"",
"'requestResult'",
"=>",
"$",
"requestSms",
")",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"!",
"empty",
"(",
"$",
"mo",
")",
"?",
"$",
"mo",
":",
"NULL",
",",
"'note'",
"=>",
"!",
"empty",
"(",
"$",
"note",
")",
"?",
"$",
"note",
":",
"NULL",
",",
"'subCode'",
"=>",
"!",
"empty",
"(",
"$",
"subCode",
")",
"?",
"$",
"subCode",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"requestSms",
"[",
"'status'",
"]",
")",
"&&",
"$",
"requestSms",
"[",
"'status'",
"]",
"==",
"self",
"::",
"SEND_SMS_SUCCESS",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_SUCCESS",
",",
"'description'",
"=>",
"'Success'",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"!",
"empty",
"(",
"$",
"mo",
")",
"?",
"$",
"mo",
":",
"NULL",
",",
"'note'",
"=>",
"!",
"empty",
"(",
"$",
"note",
")",
"?",
"$",
"note",
":",
"NULL",
",",
"'subCode'",
"=>",
"!",
"empty",
"(",
"$",
"subCode",
")",
"?",
"$",
"subCode",
":",
"NULL",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"array",
"(",
"'code'",
"=>",
"self",
"::",
"EXIT_ERROR",
",",
"'description'",
"=>",
"'Failed'",
",",
"'request_data'",
"=>",
"array",
"(",
"'url'",
"=>",
"$",
"url",
",",
"'params'",
"=>",
"$",
"params",
")",
",",
"'response_data'",
"=>",
"$",
"requestSms",
",",
"'content_data'",
"=>",
"array",
"(",
"'phone_number'",
"=>",
"$",
"phone_number",
",",
"'msg'",
"=>",
"$",
"msg",
",",
"'mo'",
"=>",
"!",
"empty",
"(",
"$",
"mo",
")",
"?",
"$",
"mo",
":",
"NULL",
",",
"'note'",
"=>",
"!",
"empty",
"(",
"$",
"note",
")",
"?",
"$",
"note",
":",
"NULL",
",",
"'subCode'",
"=>",
"!",
"empty",
"(",
"$",
"subCode",
")",
"?",
"$",
"subCode",
":",
"NULL",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToMobiFoneWithCSPSendMessage
@author: 713uk13m <[email protected]>
@time : 2018-12-27 09:43
@return $this | [
"Function",
"sendSmsToMobiFoneWithCSPSendMessage"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L1045-L1137 |
nguyenanhung/td-send-sms | src/SendSMS/SendSms.php | SendSms.sendSmsToVnmSDPWithSOAP | public function sendSmsToVnmSDPWithSOAP()
{
$result = array();
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | php | public function sendSmsToVnmSDPWithSOAP()
{
$result = array();
if ($this->responseIsObject) {
$result = Utils::arrayToObject($result);
}
$this->sendSmsResult = $result;
$this->logger->info(__FUNCTION__, 'Send SMS Result: ' . json_encode($this->sendSmsResult));
return $this;
} | [
"public",
"function",
"sendSmsToVnmSDPWithSOAP",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"responseIsObject",
")",
"{",
"$",
"result",
"=",
"Utils",
"::",
"arrayToObject",
"(",
"$",
"result",
")",
";",
"}",
"$",
"this",
"->",
"sendSmsResult",
"=",
"$",
"result",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"__FUNCTION__",
",",
"'Send SMS Result: '",
".",
"json_encode",
"(",
"$",
"this",
"->",
"sendSmsResult",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Function sendSmsToVnmSDPWithSOAP
@author: 713uk13m <[email protected]>
@time : 11/22/18 16:22
@return $this | [
"Function",
"sendSmsToVnmSDPWithSOAP"
] | train | https://github.com/nguyenanhung/td-send-sms/blob/ed7b413aa09918e0dab3354cbc1d0c4565d39463/src/SendSMS/SendSms.php#L1187-L1197 |
arsengoian/viper-framework | src/Viper/Support/Libs/Util.php | Util.match | public static function match(string $switch, array $fields, callable $default = NULL): bool {
foreach ($fields as $key => $call) {
if (self::contains($switch, $key)){
return $call();
}
}
if ($default)
$default();
return FALSE;
} | php | public static function match(string $switch, array $fields, callable $default = NULL): bool {
foreach ($fields as $key => $call) {
if (self::contains($switch, $key)){
return $call();
}
}
if ($default)
$default();
return FALSE;
} | [
"public",
"static",
"function",
"match",
"(",
"string",
"$",
"switch",
",",
"array",
"$",
"fields",
",",
"callable",
"$",
"default",
"=",
"NULL",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"$",
"call",
")",
"{",
"if",
"(",
"self",
"::",
"contains",
"(",
"$",
"switch",
",",
"$",
"key",
")",
")",
"{",
"return",
"$",
"call",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"default",
")",
"$",
"default",
"(",
")",
";",
"return",
"FALSE",
";",
"}"
] | String functions | [
"String",
"functions"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Support/Libs/Util.php#L17-L26 |
arsengoian/viper-framework | src/Viper/Support/Libs/Util.php | Util.recursiveMkdir | public static function recursiveMkdir(string $dir, int $loops = 0) {
if ($loops > 20)
throw new UtilException('No more than 20 directories in a row');
if(!file_exists($newdir = dirname($dir)))
self::recursiveMkdir($newdir);
@mkdir($dir);
@chmod($dir, 0777);
} | php | public static function recursiveMkdir(string $dir, int $loops = 0) {
if ($loops > 20)
throw new UtilException('No more than 20 directories in a row');
if(!file_exists($newdir = dirname($dir)))
self::recursiveMkdir($newdir);
@mkdir($dir);
@chmod($dir, 0777);
} | [
"public",
"static",
"function",
"recursiveMkdir",
"(",
"string",
"$",
"dir",
",",
"int",
"$",
"loops",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"loops",
">",
"20",
")",
"throw",
"new",
"UtilException",
"(",
"'No more than 20 directories in a row'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"newdir",
"=",
"dirname",
"(",
"$",
"dir",
")",
")",
")",
"self",
"::",
"recursiveMkdir",
"(",
"$",
"newdir",
")",
";",
"@",
"mkdir",
"(",
"$",
"dir",
")",
";",
"@",
"chmod",
"(",
"$",
"dir",
",",
"0777",
")",
";",
"}"
] | Warning! Ignoring warnings | [
"Warning!",
"Ignoring",
"warnings"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Support/Libs/Util.php#L84-L91 |
PortaText/php-sdk | src/PortaText/Command/Api/Destinations.php | Destinations.getEndpoint | protected function getEndpoint($method)
{
$endpoint = "destinations";
$queryString = array();
$page = $this->getArgument("page");
$sortBy = $this->getArgument("sortBy");
$order = $this->getArgument("order");
if (!is_null($page)) {
$queryString['page'] = $page;
$this->delArgument("page");
}
if (!is_null($sortBy)) {
$queryString['sort_by'] = $sortBy;
$this->delArgument("sortBy");
}
if (!is_null($order)) {
$queryString['order'] = $order;
$this->delArgument("order");
}
if (!empty($queryString)) {
$queryString = http_build_query($queryString);
$endpoint .= "?$queryString";
}
return $endpoint;
} | php | protected function getEndpoint($method)
{
$endpoint = "destinations";
$queryString = array();
$page = $this->getArgument("page");
$sortBy = $this->getArgument("sortBy");
$order = $this->getArgument("order");
if (!is_null($page)) {
$queryString['page'] = $page;
$this->delArgument("page");
}
if (!is_null($sortBy)) {
$queryString['sort_by'] = $sortBy;
$this->delArgument("sortBy");
}
if (!is_null($order)) {
$queryString['order'] = $order;
$this->delArgument("order");
}
if (!empty($queryString)) {
$queryString = http_build_query($queryString);
$endpoint .= "?$queryString";
}
return $endpoint;
} | [
"protected",
"function",
"getEndpoint",
"(",
"$",
"method",
")",
"{",
"$",
"endpoint",
"=",
"\"destinations\"",
";",
"$",
"queryString",
"=",
"array",
"(",
")",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"page\"",
")",
";",
"$",
"sortBy",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"sortBy\"",
")",
";",
"$",
"order",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"order\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"page",
")",
")",
"{",
"$",
"queryString",
"[",
"'page'",
"]",
"=",
"$",
"page",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"page\"",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"sortBy",
")",
")",
"{",
"$",
"queryString",
"[",
"'sort_by'",
"]",
"=",
"$",
"sortBy",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"sortBy\"",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"order",
")",
")",
"{",
"$",
"queryString",
"[",
"'order'",
"]",
"=",
"$",
"order",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"order\"",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"queryString",
")",
")",
"{",
"$",
"queryString",
"=",
"http_build_query",
"(",
"$",
"queryString",
")",
";",
"$",
"endpoint",
".=",
"\"?$queryString\"",
";",
"}",
"return",
"$",
"endpoint",
";",
"}"
] | Returns a string with the endpoint for the given command.
@param string $method Method for this command.
@return string | [
"Returns",
"a",
"string",
"with",
"the",
"endpoint",
"for",
"the",
"given",
"command",
"."
] | train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Destinations.php#L64-L88 |
PortaText/php-sdk | src/PortaText/Command/Api/EmailVerify.php | EmailVerify.getEndpoint | protected function getEndpoint($method)
{
$endpoint = "me/email_verify";
$nonce = $this->getArgument("nonce");
if (!is_null($nonce)) {
$endpoint .= "/$nonce";
$this->delArgument("nonce");
}
return $endpoint;
} | php | protected function getEndpoint($method)
{
$endpoint = "me/email_verify";
$nonce = $this->getArgument("nonce");
if (!is_null($nonce)) {
$endpoint .= "/$nonce";
$this->delArgument("nonce");
}
return $endpoint;
} | [
"protected",
"function",
"getEndpoint",
"(",
"$",
"method",
")",
"{",
"$",
"endpoint",
"=",
"\"me/email_verify\"",
";",
"$",
"nonce",
"=",
"$",
"this",
"->",
"getArgument",
"(",
"\"nonce\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"nonce",
")",
")",
"{",
"$",
"endpoint",
".=",
"\"/$nonce\"",
";",
"$",
"this",
"->",
"delArgument",
"(",
"\"nonce\"",
")",
";",
"}",
"return",
"$",
"endpoint",
";",
"}"
] | Returns a string with the endpoint for the given command.
@param string $method Method for this command.
@return string | [
"Returns",
"a",
"string",
"with",
"the",
"endpoint",
"for",
"the",
"given",
"command",
"."
] | train | https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/EmailVerify.php#L38-L47 |
webforge-labs/psc-cms | lib/Psc/Code/Build/Phar.php | Phar.addFile | public function addFile(File $file, File $fileInPhar) {
if (!$fileInPhar->getDirectory()->isRelative()) {
throw new \Psc\Exception('fileInPhar muss ein relatives Verzeichnis haben');
}
$this->additionalFiles[(string) $fileInPhar] = array($file, $fileInPhar);
return $this;
} | php | public function addFile(File $file, File $fileInPhar) {
if (!$fileInPhar->getDirectory()->isRelative()) {
throw new \Psc\Exception('fileInPhar muss ein relatives Verzeichnis haben');
}
$this->additionalFiles[(string) $fileInPhar] = array($file, $fileInPhar);
return $this;
} | [
"public",
"function",
"addFile",
"(",
"File",
"$",
"file",
",",
"File",
"$",
"fileInPhar",
")",
"{",
"if",
"(",
"!",
"$",
"fileInPhar",
"->",
"getDirectory",
"(",
")",
"->",
"isRelative",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Psc",
"\\",
"Exception",
"(",
"'fileInPhar muss ein relatives Verzeichnis haben'",
")",
";",
"}",
"$",
"this",
"->",
"additionalFiles",
"[",
"(",
"string",
")",
"$",
"fileInPhar",
"]",
"=",
"array",
"(",
"$",
"file",
",",
"$",
"fileInPhar",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Fügt eine beliebige Datei zum Phar hinzu
Achtung: wenn dies eine PHP-Datei ist mit einer Klasse drin, wird diese nicht "indiziert", sondern einfach nur dump eingefügt
Dies ist also nur für andere PHARs oder andere Dateien ohne PHP-Klassen darin
@param File $fileInPhar ist eine RELATIVE Datei => d. h. das Verzeichnis ist relativ und bestimmt den Namen und Ort der Datei im Phar | [
"Fügt",
"eine",
"beliebige",
"Datei",
"zum",
"Phar",
"hinzu"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Build/Phar.php#L160-L167 |
webforge-labs/psc-cms | lib/Psc/Code/Build/Phar.php | Phar.inferClassName | protected function inferClassName(File $file) {
return Code::mapFileToClass($file, $this->classPath->up(), $this->underscoreStyle ? '_' : '\\');
} | php | protected function inferClassName(File $file) {
return Code::mapFileToClass($file, $this->classPath->up(), $this->underscoreStyle ? '_' : '\\');
} | [
"protected",
"function",
"inferClassName",
"(",
"File",
"$",
"file",
")",
"{",
"return",
"Code",
"::",
"mapFileToClass",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"classPath",
"->",
"up",
"(",
")",
",",
"$",
"this",
"->",
"underscoreStyle",
"?",
"'_'",
":",
"'\\\\'",
")",
";",
"}"
] | Gibt zu einer Datei im Phar die Klasse zurück
dies funktioniert im Moment nur mit der Konvention, dass jedes Verzeichnis ein unter-namespace von $this->namespace ist | [
"Gibt",
"zu",
"einer",
"Datei",
"im",
"Phar",
"die",
"Klasse",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Build/Phar.php#L207-L209 |
yuncms/framework | src/base/Snowflake.php | Snowflake.next | public function next():int
{
$timestamp = $this->milliTime();
if ($timestamp < $this->_lastTimestamp) {
throw new Exception(sprintf("Clock moved backwards. Refusing to generate id for %d milliseconds", $this->_lastTimestamp - $timestamp));
}
if ($this->_lastTimestamp == $timestamp) {
$this->_sequence = ($this->_sequence + 1) & self::SEQUENCE_MASK;
if ($this->_sequence == 0) {
$timestamp = $this->waitNextMilli($this->_lastTimestamp);
}
} else {
$this->_sequence = 0;
}
$this->_lastTimestamp = $timestamp;
return (($timestamp - $this->epoch) << self::TIMESTAMP_LEFT_SHIFT)
| ($this->dataCenterId << self::DATA_CENTER_ID_SHIFT)
| ($this->workerId << self::WORKER_ID_SHIFT)
| $this->_sequence;
} | php | public function next():int
{
$timestamp = $this->milliTime();
if ($timestamp < $this->_lastTimestamp) {
throw new Exception(sprintf("Clock moved backwards. Refusing to generate id for %d milliseconds", $this->_lastTimestamp - $timestamp));
}
if ($this->_lastTimestamp == $timestamp) {
$this->_sequence = ($this->_sequence + 1) & self::SEQUENCE_MASK;
if ($this->_sequence == 0) {
$timestamp = $this->waitNextMilli($this->_lastTimestamp);
}
} else {
$this->_sequence = 0;
}
$this->_lastTimestamp = $timestamp;
return (($timestamp - $this->epoch) << self::TIMESTAMP_LEFT_SHIFT)
| ($this->dataCenterId << self::DATA_CENTER_ID_SHIFT)
| ($this->workerId << self::WORKER_ID_SHIFT)
| $this->_sequence;
} | [
"public",
"function",
"next",
"(",
")",
":",
"int",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"milliTime",
"(",
")",
";",
"if",
"(",
"$",
"timestamp",
"<",
"$",
"this",
"->",
"_lastTimestamp",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"\"Clock moved backwards. Refusing to generate id for %d milliseconds\"",
",",
"$",
"this",
"->",
"_lastTimestamp",
"-",
"$",
"timestamp",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_lastTimestamp",
"==",
"$",
"timestamp",
")",
"{",
"$",
"this",
"->",
"_sequence",
"=",
"(",
"$",
"this",
"->",
"_sequence",
"+",
"1",
")",
"&",
"self",
"::",
"SEQUENCE_MASK",
";",
"if",
"(",
"$",
"this",
"->",
"_sequence",
"==",
"0",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"waitNextMilli",
"(",
"$",
"this",
"->",
"_lastTimestamp",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_sequence",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"_lastTimestamp",
"=",
"$",
"timestamp",
";",
"return",
"(",
"(",
"$",
"timestamp",
"-",
"$",
"this",
"->",
"epoch",
")",
"<<",
"self",
"::",
"TIMESTAMP_LEFT_SHIFT",
")",
"|",
"(",
"$",
"this",
"->",
"dataCenterId",
"<<",
"self",
"::",
"DATA_CENTER_ID_SHIFT",
")",
"|",
"(",
"$",
"this",
"->",
"workerId",
"<<",
"self",
"::",
"WORKER_ID_SHIFT",
")",
"|",
"$",
"this",
"->",
"_sequence",
";",
"}"
] | 获得下一个ID (该方法是线程安全的)
@return int
@throws Exception | [
"获得下一个ID",
"(",
"该方法是线程安全的",
")"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/base/Snowflake.php#L76-L95 |
yuncms/framework | src/base/Snowflake.php | Snowflake.waitNextMilli | protected function waitNextMilli($lastTimestamp):int
{
$timestamp = $this->milliTime();
while ($timestamp <= $lastTimestamp) {
$timestamp = $this->milliTime();
}
return $timestamp;
} | php | protected function waitNextMilli($lastTimestamp):int
{
$timestamp = $this->milliTime();
while ($timestamp <= $lastTimestamp) {
$timestamp = $this->milliTime();
}
return $timestamp;
} | [
"protected",
"function",
"waitNextMilli",
"(",
"$",
"lastTimestamp",
")",
":",
"int",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"milliTime",
"(",
")",
";",
"while",
"(",
"$",
"timestamp",
"<=",
"$",
"lastTimestamp",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"milliTime",
"(",
")",
";",
"}",
"return",
"$",
"timestamp",
";",
"}"
] | 阻塞到下一个毫秒,直到获得新的时间戳
@param int $lastTimestamp 上次生成ID的时间截
@return int 当前时间戳 | [
"阻塞到下一个毫秒,直到获得新的时间戳"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/base/Snowflake.php#L102-L109 |
yuncms/framework | src/base/Snowflake.php | Snowflake.milliTime | protected function milliTime(): int
{
$microTime = microtime();
$comps = explode(' ', $microTime);
// Note: Using a string here to prevent loss of precision
// in case of "overflow" (PHP converts it to a double)
return (int)sprintf('%d%03d', $comps[1], $comps[0] * 1000);
} | php | protected function milliTime(): int
{
$microTime = microtime();
$comps = explode(' ', $microTime);
// Note: Using a string here to prevent loss of precision
// in case of "overflow" (PHP converts it to a double)
return (int)sprintf('%d%03d', $comps[1], $comps[0] * 1000);
} | [
"protected",
"function",
"milliTime",
"(",
")",
":",
"int",
"{",
"$",
"microTime",
"=",
"microtime",
"(",
")",
";",
"$",
"comps",
"=",
"explode",
"(",
"' '",
",",
"$",
"microTime",
")",
";",
"// Note: Using a string here to prevent loss of precision",
"// in case of \"overflow\" (PHP converts it to a double)",
"return",
"(",
"int",
")",
"sprintf",
"(",
"'%d%03d'",
",",
"$",
"comps",
"[",
"1",
"]",
",",
"$",
"comps",
"[",
"0",
"]",
"*",
"1000",
")",
";",
"}"
] | 返回以毫秒为单位的当前时间
@return int 当前时间(毫秒) | [
"返回以毫秒为单位的当前时间"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/base/Snowflake.php#L115-L122 |
webforge-labs/psc-cms | lib/Psc/CMS/ComponentsForm.php | ComponentsForm.sortComponents | public function sortComponents($sorting) {
if (is_array($sorting)) {
$order = array_flip($sorting); // $name => $position
// wir erstellen unseren name => componenten index
$components = \Psc\Doctrine\Helper::reindex($this->components->toArray(),'getFormName');
// wir fügen alle Komponenten hinzu, die nicht in dem Index drin sind (hängen sie nach hinten an)
foreach($components as $name => $component) {
if (!array_key_exists($name, $order)) {
$order[$name] = count($order);
}
}
$sorting = function ($c1, $c2) use ($order) {
// @TODO formName kann auch ein array sein?
if (($n1 = $c1->getFormName()) === ($n2 = $c2->getFormName())) {
return 0;
}
return $order[$n1] > $order[$n2] ? 1 : -1;
};
}
if (!($sorting instanceof \Closure)) {
throw new \InvalidArgumentException('sortComponents muss eine Closure als Parameter haben (oder ein Array)');
}
$this->components->sortBy($sorting);
return $this;
} | php | public function sortComponents($sorting) {
if (is_array($sorting)) {
$order = array_flip($sorting); // $name => $position
// wir erstellen unseren name => componenten index
$components = \Psc\Doctrine\Helper::reindex($this->components->toArray(),'getFormName');
// wir fügen alle Komponenten hinzu, die nicht in dem Index drin sind (hängen sie nach hinten an)
foreach($components as $name => $component) {
if (!array_key_exists($name, $order)) {
$order[$name] = count($order);
}
}
$sorting = function ($c1, $c2) use ($order) {
// @TODO formName kann auch ein array sein?
if (($n1 = $c1->getFormName()) === ($n2 = $c2->getFormName())) {
return 0;
}
return $order[$n1] > $order[$n2] ? 1 : -1;
};
}
if (!($sorting instanceof \Closure)) {
throw new \InvalidArgumentException('sortComponents muss eine Closure als Parameter haben (oder ein Array)');
}
$this->components->sortBy($sorting);
return $this;
} | [
"public",
"function",
"sortComponents",
"(",
"$",
"sorting",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"sorting",
")",
")",
"{",
"$",
"order",
"=",
"array_flip",
"(",
"$",
"sorting",
")",
";",
"// $name => $position",
"// wir erstellen unseren name => componenten index",
"$",
"components",
"=",
"\\",
"Psc",
"\\",
"Doctrine",
"\\",
"Helper",
"::",
"reindex",
"(",
"$",
"this",
"->",
"components",
"->",
"toArray",
"(",
")",
",",
"'getFormName'",
")",
";",
"// wir fügen alle Komponenten hinzu, die nicht in dem Index drin sind (hängen sie nach hinten an)",
"foreach",
"(",
"$",
"components",
"as",
"$",
"name",
"=>",
"$",
"component",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"order",
")",
")",
"{",
"$",
"order",
"[",
"$",
"name",
"]",
"=",
"count",
"(",
"$",
"order",
")",
";",
"}",
"}",
"$",
"sorting",
"=",
"function",
"(",
"$",
"c1",
",",
"$",
"c2",
")",
"use",
"(",
"$",
"order",
")",
"{",
"// @TODO formName kann auch ein array sein?",
"if",
"(",
"(",
"$",
"n1",
"=",
"$",
"c1",
"->",
"getFormName",
"(",
")",
")",
"===",
"(",
"$",
"n2",
"=",
"$",
"c2",
"->",
"getFormName",
"(",
")",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"order",
"[",
"$",
"n1",
"]",
">",
"$",
"order",
"[",
"$",
"n2",
"]",
"?",
"1",
":",
"-",
"1",
";",
"}",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"sorting",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'sortComponents muss eine Closure als Parameter haben (oder ein Array)'",
")",
";",
"}",
"$",
"this",
"->",
"components",
"->",
"sortBy",
"(",
"$",
"sorting",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Verändert die aktuelle Reihenfolge der Componenten
$sorting kann entweder ein Closure sein welches als Parameter 2 Komponenten bekommt und dann entscheidet welche weiter vorne stehen soll.
oder ein array von property Names. Diese werden dann in der Reihenfolge wie im Array gesetzt, alle restlichen (nicht im array angegebenen) Componenten werden ans Ende gehängt
@param Closure|array $sorting kann ein Array von property-Names sein oder eine Closure die 2 Parameter erhält und eine Sortierfunktion ist returns: -1|0|1 | [
"Verändert",
"die",
"aktuelle",
"Reihenfolge",
"der",
"Componenten"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/ComponentsForm.php#L127-L156 |
teneleven/GeolocatorBundle | Controller/GeolocatorController.php | GeolocatorController.locate | public function locate($entity, Request $request, $template = null)
{
if (!$template) {
$template = 'TenelevenGeolocatorBundle::results.html.twig';
}
$provider = $this->getLocationProvider($entity);
$form = $this->get('form.factory')->createNamed('', $provider->getFilterFormType(), null, array(
'method' => 'GET',
'csrf_protection' => false,
'allow_extra_fields' => true,
));
foreach ($request->query->all() as $key => $value) {
if ($form->has($key)) {
continue;
}
$form->add($key, HiddenType::class, [
'data' => $value,
]);
}
try {
$form->handleRequest($request);
} catch (QuotaExceeded $e) {
$this->get('logger')->error($e->getMessage());
$this->get('session')->getFlashBag()->add('error', 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.');
}
if (!$form->isValid()) {
return $this->render($template, array(
'map' => $map = $this->getMap(),
'form' => $form->createView()
));
}
$result = $provider->findLocations($form);
$map = $this->buildMap($template, $result);
return $this->render($template, array(
'form' => $form->createView(),
'result' => $result,
'map' => $map
));
} | php | public function locate($entity, Request $request, $template = null)
{
if (!$template) {
$template = 'TenelevenGeolocatorBundle::results.html.twig';
}
$provider = $this->getLocationProvider($entity);
$form = $this->get('form.factory')->createNamed('', $provider->getFilterFormType(), null, array(
'method' => 'GET',
'csrf_protection' => false,
'allow_extra_fields' => true,
));
foreach ($request->query->all() as $key => $value) {
if ($form->has($key)) {
continue;
}
$form->add($key, HiddenType::class, [
'data' => $value,
]);
}
try {
$form->handleRequest($request);
} catch (QuotaExceeded $e) {
$this->get('logger')->error($e->getMessage());
$this->get('session')->getFlashBag()->add('error', 'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.');
}
if (!$form->isValid()) {
return $this->render($template, array(
'map' => $map = $this->getMap(),
'form' => $form->createView()
));
}
$result = $provider->findLocations($form);
$map = $this->buildMap($template, $result);
return $this->render($template, array(
'form' => $form->createView(),
'result' => $result,
'map' => $map
));
} | [
"public",
"function",
"locate",
"(",
"$",
"entity",
",",
"Request",
"$",
"request",
",",
"$",
"template",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"'TenelevenGeolocatorBundle::results.html.twig'",
";",
"}",
"$",
"provider",
"=",
"$",
"this",
"->",
"getLocationProvider",
"(",
"$",
"entity",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"createNamed",
"(",
"''",
",",
"$",
"provider",
"->",
"getFilterFormType",
"(",
")",
",",
"null",
",",
"array",
"(",
"'method'",
"=>",
"'GET'",
",",
"'csrf_protection'",
"=>",
"false",
",",
"'allow_extra_fields'",
"=>",
"true",
",",
")",
")",
";",
"foreach",
"(",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"continue",
";",
"}",
"$",
"form",
"->",
"add",
"(",
"$",
"key",
",",
"HiddenType",
"::",
"class",
",",
"[",
"'data'",
"=>",
"$",
"value",
",",
"]",
")",
";",
"}",
"try",
"{",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"}",
"catch",
"(",
"QuotaExceeded",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'logger'",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'error'",
",",
"'Sorry, this locator has exceeded the quota for location look-ups. Please try again at a later time.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"array",
"(",
"'map'",
"=>",
"$",
"map",
"=",
"$",
"this",
"->",
"getMap",
"(",
")",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
")",
")",
";",
"}",
"$",
"result",
"=",
"$",
"provider",
"->",
"findLocations",
"(",
"$",
"form",
")",
";",
"$",
"map",
"=",
"$",
"this",
"->",
"buildMap",
"(",
"$",
"template",
",",
"$",
"result",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'result'",
"=>",
"$",
"result",
",",
"'map'",
"=>",
"$",
"map",
")",
")",
";",
"}"
] | Displays a geo-locator screen with map, form, and locations
@param string $entity The entity key that the provider is registered under
@param Request $request
@param string $template The template to render
@return Response | [
"Displays",
"a",
"geo",
"-",
"locator",
"screen",
"with",
"map",
"form",
"and",
"locations"
] | train | https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Controller/GeolocatorController.php#L44-L89 |
teneleven/GeolocatorBundle | Controller/GeolocatorController.php | GeolocatorController.buildMap | protected function buildMap($template, Search $result)
{
$map = $this->getMap();
if (!$result->hasResults()) { //in case of no result we center on the searched location
$map->setCenter(
new Coordinate(
$result->getCenter()->getLatitude(),
$result->getCenter()->getLongitude()
)
);
return $map;
}
$twigTemplate = $this->get('twig')->loadTemplate($template);
$map->setAutoZoom(true); //this is important to set before adding markers
foreach ($result->getResults() as $result) { /* @var $result Result */
$location = $result->location;
if (!$location instanceof GeolocatableInterface) {
continue;
}
$marker = new Marker(
new Coordinate(
$location->getLatitude(),
$location->getLongitude()
)
);
if ($twigTemplate->hasBlock('teneleven_geolocator_item_window', [])) {
$infoWindow = new InfoWindow($twigTemplate->renderBlock(
'teneleven_geolocator_item_window',
array('result' => $result)
));
$marker->setInfoWindow($infoWindow);
$result->mapWindowId = $infoWindow->getVariable();
}
$result->mapMarkerId = $marker->getVariable();
$map->getOverlayManager()->addMarker($marker);
}
return $map;
} | php | protected function buildMap($template, Search $result)
{
$map = $this->getMap();
if (!$result->hasResults()) { //in case of no result we center on the searched location
$map->setCenter(
new Coordinate(
$result->getCenter()->getLatitude(),
$result->getCenter()->getLongitude()
)
);
return $map;
}
$twigTemplate = $this->get('twig')->loadTemplate($template);
$map->setAutoZoom(true); //this is important to set before adding markers
foreach ($result->getResults() as $result) { /* @var $result Result */
$location = $result->location;
if (!$location instanceof GeolocatableInterface) {
continue;
}
$marker = new Marker(
new Coordinate(
$location->getLatitude(),
$location->getLongitude()
)
);
if ($twigTemplate->hasBlock('teneleven_geolocator_item_window', [])) {
$infoWindow = new InfoWindow($twigTemplate->renderBlock(
'teneleven_geolocator_item_window',
array('result' => $result)
));
$marker->setInfoWindow($infoWindow);
$result->mapWindowId = $infoWindow->getVariable();
}
$result->mapMarkerId = $marker->getVariable();
$map->getOverlayManager()->addMarker($marker);
}
return $map;
} | [
"protected",
"function",
"buildMap",
"(",
"$",
"template",
",",
"Search",
"$",
"result",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"getMap",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"hasResults",
"(",
")",
")",
"{",
"//in case of no result we center on the searched location",
"$",
"map",
"->",
"setCenter",
"(",
"new",
"Coordinate",
"(",
"$",
"result",
"->",
"getCenter",
"(",
")",
"->",
"getLatitude",
"(",
")",
",",
"$",
"result",
"->",
"getCenter",
"(",
")",
"->",
"getLongitude",
"(",
")",
")",
")",
";",
"return",
"$",
"map",
";",
"}",
"$",
"twigTemplate",
"=",
"$",
"this",
"->",
"get",
"(",
"'twig'",
")",
"->",
"loadTemplate",
"(",
"$",
"template",
")",
";",
"$",
"map",
"->",
"setAutoZoom",
"(",
"true",
")",
";",
"//this is important to set before adding markers",
"foreach",
"(",
"$",
"result",
"->",
"getResults",
"(",
")",
"as",
"$",
"result",
")",
"{",
"/* @var $result Result */",
"$",
"location",
"=",
"$",
"result",
"->",
"location",
";",
"if",
"(",
"!",
"$",
"location",
"instanceof",
"GeolocatableInterface",
")",
"{",
"continue",
";",
"}",
"$",
"marker",
"=",
"new",
"Marker",
"(",
"new",
"Coordinate",
"(",
"$",
"location",
"->",
"getLatitude",
"(",
")",
",",
"$",
"location",
"->",
"getLongitude",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"twigTemplate",
"->",
"hasBlock",
"(",
"'teneleven_geolocator_item_window'",
",",
"[",
"]",
")",
")",
"{",
"$",
"infoWindow",
"=",
"new",
"InfoWindow",
"(",
"$",
"twigTemplate",
"->",
"renderBlock",
"(",
"'teneleven_geolocator_item_window'",
",",
"array",
"(",
"'result'",
"=>",
"$",
"result",
")",
")",
")",
";",
"$",
"marker",
"->",
"setInfoWindow",
"(",
"$",
"infoWindow",
")",
";",
"$",
"result",
"->",
"mapWindowId",
"=",
"$",
"infoWindow",
"->",
"getVariable",
"(",
")",
";",
"}",
"$",
"result",
"->",
"mapMarkerId",
"=",
"$",
"marker",
"->",
"getVariable",
"(",
")",
";",
"$",
"map",
"->",
"getOverlayManager",
"(",
")",
"->",
"addMarker",
"(",
"$",
"marker",
")",
";",
"}",
"return",
"$",
"map",
";",
"}"
] | Builds a map of locations
@param string $template
@param Search $result
@return \Ivory\GoogleMap\Map | [
"Builds",
"a",
"map",
"of",
"locations"
] | train | https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Controller/GeolocatorController.php#L108-L157 |
arsengoian/viper-framework | src/Viper/Core/Model/DB/MySQL/Types/StringType.php | StringType.validate | public function validate ($value): void
{
switch ($this -> sqlType) {
case 'ENUM':
case 'SET':
// Not implemented;
break;
default:
$common = self::TYPES[$this -> sqlType];
if (!$this -> size)
$this -> size = $common;
else $this -> size = min($this -> size, $common);
$this -> getValidator()::apply('strlen', $value, $this -> size);
}
} | php | public function validate ($value): void
{
switch ($this -> sqlType) {
case 'ENUM':
case 'SET':
// Not implemented;
break;
default:
$common = self::TYPES[$this -> sqlType];
if (!$this -> size)
$this -> size = $common;
else $this -> size = min($this -> size, $common);
$this -> getValidator()::apply('strlen', $value, $this -> size);
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
":",
"void",
"{",
"switch",
"(",
"$",
"this",
"->",
"sqlType",
")",
"{",
"case",
"'ENUM'",
":",
"case",
"'SET'",
":",
"// Not implemented;",
"break",
";",
"default",
":",
"$",
"common",
"=",
"self",
"::",
"TYPES",
"[",
"$",
"this",
"->",
"sqlType",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"size",
")",
"$",
"this",
"->",
"size",
"=",
"$",
"common",
";",
"else",
"$",
"this",
"->",
"size",
"=",
"min",
"(",
"$",
"this",
"->",
"size",
",",
"$",
"common",
")",
";",
"$",
"this",
"->",
"getValidator",
"(",
")",
"::",
"apply",
"(",
"'strlen'",
",",
"$",
"value",
",",
"$",
"this",
"->",
"size",
")",
";",
"}",
"}"
] | Checks if the type is correspondent | [
"Checks",
"if",
"the",
"type",
"is",
"correspondent"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Core/Model/DB/MySQL/Types/StringType.php#L36-L51 |
redaigbaria/oauth2 | src/TokenType/AbstractTokenType.php | AbstractTokenType.getParam | public function getParam($key)
{
return isset($this->response[$key]) ? $this->response[$key] : null;
} | php | public function getParam($key)
{
return isset($this->response[$key]) ? $this->response[$key] : null;
} | [
"public",
"function",
"getParam",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"response",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"response",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/TokenType/AbstractTokenType.php#L71-L74 |
krzysztofmazur/php-object-mapper | src/KrzysztofMazur/ObjectMapper/ObjectMapper.php | ObjectMapper.map | public function map($source, $targetClass, $mapId = null)
{
$object = $this->instantiator->instantiate($targetClass);
$this->mapToObject($source, $object, $mapId);
return $object;
} | php | public function map($source, $targetClass, $mapId = null)
{
$object = $this->instantiator->instantiate($targetClass);
$this->mapToObject($source, $object, $mapId);
return $object;
} | [
"public",
"function",
"map",
"(",
"$",
"source",
",",
"$",
"targetClass",
",",
"$",
"mapId",
"=",
"null",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"instantiator",
"->",
"instantiate",
"(",
"$",
"targetClass",
")",
";",
"$",
"this",
"->",
"mapToObject",
"(",
"$",
"source",
",",
"$",
"object",
",",
"$",
"mapId",
")",
";",
"return",
"$",
"object",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/ObjectMapper.php#L42-L48 |
krzysztofmazur/php-object-mapper | src/KrzysztofMazur/ObjectMapper/ObjectMapper.php | ObjectMapper.mapToObject | public function mapToObject($source, $target, $mapId = null)
{
$this->repository->getMapping(get_class($source), get_class($target), $mapId)->map($source, $target);
return $target;
} | php | public function mapToObject($source, $target, $mapId = null)
{
$this->repository->getMapping(get_class($source), get_class($target), $mapId)->map($source, $target);
return $target;
} | [
"public",
"function",
"mapToObject",
"(",
"$",
"source",
",",
"$",
"target",
",",
"$",
"mapId",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"repository",
"->",
"getMapping",
"(",
"get_class",
"(",
"$",
"source",
")",
",",
"get_class",
"(",
"$",
"target",
")",
",",
"$",
"mapId",
")",
"->",
"map",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"return",
"$",
"target",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/ObjectMapper.php#L53-L58 |
2amigos/yiifoundation | widgets/TopBar.php | TopBar.init | public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.topbar.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::NAV_TOPBAR);
if ($this->fixed) {
Html::addCssClass($this->htmlOptions, Enum::NAV_FIXED);
}
if ($this->sticky) {
Html::addCssClass($this->htmlOptions, Enum::NAV_STICKY);
}
if ($this->containToGrid) {
Html::addCssClass($this->htmlOptions, Enum::NAV_CONTAINED);
}
parent::init();
} | php | public function init()
{
$this->assets = array(
'js' => YII_DEBUG ? 'foundation/foundation.topbar.js' : 'foundation.min.js'
);
Html::addCssClass($this->htmlOptions, Enum::NAV_TOPBAR);
if ($this->fixed) {
Html::addCssClass($this->htmlOptions, Enum::NAV_FIXED);
}
if ($this->sticky) {
Html::addCssClass($this->htmlOptions, Enum::NAV_STICKY);
}
if ($this->containToGrid) {
Html::addCssClass($this->htmlOptions, Enum::NAV_CONTAINED);
}
parent::init();
} | [
"public",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"assets",
"=",
"array",
"(",
"'js'",
"=>",
"YII_DEBUG",
"?",
"'foundation/foundation.topbar.js'",
":",
"'foundation.min.js'",
")",
";",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"NAV_TOPBAR",
")",
";",
"if",
"(",
"$",
"this",
"->",
"fixed",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"NAV_FIXED",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"sticky",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"NAV_STICKY",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"containToGrid",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"this",
"->",
"htmlOptions",
",",
"Enum",
"::",
"NAV_CONTAINED",
")",
";",
"}",
"parent",
"::",
"init",
"(",
")",
";",
"}"
] | Initializes the widget | [
"Initializes",
"the",
"widget"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L137-L155 |
2amigos/yiifoundation | widgets/TopBar.php | TopBar.renderNavigation | protected function renderNavigation()
{
$nav = array();
if (!empty($this->wrapperOptions)) {
$nav[] = \CHtml::openTag('div', $this->wrapperOptions);
}
$nav[] = \CHtml::openTag('nav', $this->htmlOptions);
$nav[] = $this->renderTitle();
$nav[] = $this->renderItems();
$nav[] = \CHtml::closeTag('nav');
if (!empty($this->wrapperOptions)) {
$nav[] = \CHtml::closeTag('div');
}
return implode("\n", $nav);
} | php | protected function renderNavigation()
{
$nav = array();
if (!empty($this->wrapperOptions)) {
$nav[] = \CHtml::openTag('div', $this->wrapperOptions);
}
$nav[] = \CHtml::openTag('nav', $this->htmlOptions);
$nav[] = $this->renderTitle();
$nav[] = $this->renderItems();
$nav[] = \CHtml::closeTag('nav');
if (!empty($this->wrapperOptions)) {
$nav[] = \CHtml::closeTag('div');
}
return implode("\n", $nav);
} | [
"protected",
"function",
"renderNavigation",
"(",
")",
"{",
"$",
"nav",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"wrapperOptions",
")",
")",
"{",
"$",
"nav",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'div'",
",",
"$",
"this",
"->",
"wrapperOptions",
")",
";",
"}",
"$",
"nav",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'nav'",
",",
"$",
"this",
"->",
"htmlOptions",
")",
";",
"$",
"nav",
"[",
"]",
"=",
"$",
"this",
"->",
"renderTitle",
"(",
")",
";",
"$",
"nav",
"[",
"]",
"=",
"$",
"this",
"->",
"renderItems",
"(",
")",
";",
"$",
"nav",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'nav'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"wrapperOptions",
")",
")",
"{",
"$",
"nav",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'div'",
")",
";",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"nav",
")",
";",
"}"
] | Renders the navigation | [
"Renders",
"the",
"navigation"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L168-L183 |
2amigos/yiifoundation | widgets/TopBar.php | TopBar.renderTitle | protected function renderTitle()
{
$items = array();
$title = \CHtml::tag('h1', array(), \CHtml::link($this->title, $this->titleUrl, $this->titleOptions));
$items[] = \CHtml::tag('li', array('class' => 'name'), $title);
$items[] = \CHtml::tag(
'li',
array('class' => 'toggle-topbar menu-icon'),
\CHtml::link('<span>Menu</span>', '#')
);
return \CHtml::tag('ul', array('class' => 'title-area'), implode("\n", $items));
} | php | protected function renderTitle()
{
$items = array();
$title = \CHtml::tag('h1', array(), \CHtml::link($this->title, $this->titleUrl, $this->titleOptions));
$items[] = \CHtml::tag('li', array('class' => 'name'), $title);
$items[] = \CHtml::tag(
'li',
array('class' => 'toggle-topbar menu-icon'),
\CHtml::link('<span>Menu</span>', '#')
);
return \CHtml::tag('ul', array('class' => 'title-area'), implode("\n", $items));
} | [
"protected",
"function",
"renderTitle",
"(",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"$",
"title",
"=",
"\\",
"CHtml",
"::",
"tag",
"(",
"'h1'",
",",
"array",
"(",
")",
",",
"\\",
"CHtml",
"::",
"link",
"(",
"$",
"this",
"->",
"title",
",",
"$",
"this",
"->",
"titleUrl",
",",
"$",
"this",
"->",
"titleOptions",
")",
")",
";",
"$",
"items",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"array",
"(",
"'class'",
"=>",
"'name'",
")",
",",
"$",
"title",
")",
";",
"$",
"items",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"array",
"(",
"'class'",
"=>",
"'toggle-topbar menu-icon'",
")",
",",
"\\",
"CHtml",
"::",
"link",
"(",
"'<span>Menu</span>'",
",",
"'#'",
")",
")",
";",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'ul'",
",",
"array",
"(",
"'class'",
"=>",
"'title-area'",
")",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"items",
")",
")",
";",
"}"
] | Renders the title of navigation
@return string | [
"Renders",
"the",
"title",
"of",
"navigation"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L189-L200 |
2amigos/yiifoundation | widgets/TopBar.php | TopBar.renderItems | protected function renderItems()
{
$items = array();
if (!empty($this->leftItems)) {
$tItems = array();
foreach ($this->leftItems as $item) {
$tItems[] = $this->renderItem($item);
}
$items[] = \CHtml::openTag('ul', array('class' => Enum::POS_LEFT)) . implode(
"\n",
$tItems
) . \CHtml::closeTag(
'ul'
);
}
if (!empty($this->rightItems)) {
$tItems = array();
foreach ($this->rightItems as $item) {
$tItems[] = $this->renderItem($item);
}
$items[] = \CHtml::openTag('ul', array('class' => Enum::POS_RIGHT)) . implode(
"\n",
$tItems
) . \CHtml::closeTag(
'ul'
);
}
return \CHtml::tag('section', array('class' => 'top-bar-section'), implode("\n", $items), true);
} | php | protected function renderItems()
{
$items = array();
if (!empty($this->leftItems)) {
$tItems = array();
foreach ($this->leftItems as $item) {
$tItems[] = $this->renderItem($item);
}
$items[] = \CHtml::openTag('ul', array('class' => Enum::POS_LEFT)) . implode(
"\n",
$tItems
) . \CHtml::closeTag(
'ul'
);
}
if (!empty($this->rightItems)) {
$tItems = array();
foreach ($this->rightItems as $item) {
$tItems[] = $this->renderItem($item);
}
$items[] = \CHtml::openTag('ul', array('class' => Enum::POS_RIGHT)) . implode(
"\n",
$tItems
) . \CHtml::closeTag(
'ul'
);
}
return \CHtml::tag('section', array('class' => 'top-bar-section'), implode("\n", $items), true);
} | [
"protected",
"function",
"renderItems",
"(",
")",
"{",
"$",
"items",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"leftItems",
")",
")",
"{",
"$",
"tItems",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"leftItems",
"as",
"$",
"item",
")",
"{",
"$",
"tItems",
"[",
"]",
"=",
"$",
"this",
"->",
"renderItem",
"(",
"$",
"item",
")",
";",
"}",
"$",
"items",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'ul'",
",",
"array",
"(",
"'class'",
"=>",
"Enum",
"::",
"POS_LEFT",
")",
")",
".",
"implode",
"(",
"\"\\n\"",
",",
"$",
"tItems",
")",
".",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'ul'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"rightItems",
")",
")",
"{",
"$",
"tItems",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rightItems",
"as",
"$",
"item",
")",
"{",
"$",
"tItems",
"[",
"]",
"=",
"$",
"this",
"->",
"renderItem",
"(",
"$",
"item",
")",
";",
"}",
"$",
"items",
"[",
"]",
"=",
"\\",
"CHtml",
"::",
"openTag",
"(",
"'ul'",
",",
"array",
"(",
"'class'",
"=>",
"Enum",
"::",
"POS_RIGHT",
")",
")",
".",
"implode",
"(",
"\"\\n\"",
",",
"$",
"tItems",
")",
".",
"\\",
"CHtml",
"::",
"closeTag",
"(",
"'ul'",
")",
";",
"}",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'section'",
",",
"array",
"(",
"'class'",
"=>",
"'top-bar-section'",
")",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"items",
")",
",",
"true",
")",
";",
"}"
] | Renders widget's items.
@return string | [
"Renders",
"widget",
"s",
"items",
"."
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L206-L235 |
2amigos/yiifoundation | widgets/TopBar.php | TopBar.renderItem | protected function renderItem($item)
{
if (is_string($item)) {
return $item;
}
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
$label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array());
$items = ArrayHelper::getValue($item, 'items');
$url = \CHtml::normalizeUrl(ArrayHelper::getValue($item, 'url', '#'));
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
if (ArrayHelper::getValue($item, Enum::STATE_ACTIVE)) {
ArrayHelper::addValue('class', Enum::STATE_ACTIVE, $options);
}
if ($items !== null) {
Html::addCssClass($options, Enum::DROPDOWN_HAS);
if (is_array($items)) {
$items = Nav::dropdown($items, $this->encodeLabels);
}
}
return \CHtml::tag('li', $options, \CHtml::link($label, $url, $linkOptions) . $items);
} | php | protected function renderItem($item)
{
if (is_string($item)) {
return $item;
}
if (!isset($item['label'])) {
throw new InvalidConfigException("The 'label' option is required.");
}
$label = $this->encodeLabels ? \CHtml::encode($item['label']) : $item['label'];
$options = ArrayHelper::getValue($item, 'options', array());
$items = ArrayHelper::getValue($item, 'items');
$url = \CHtml::normalizeUrl(ArrayHelper::getValue($item, 'url', '#'));
$linkOptions = ArrayHelper::getValue($item, 'linkOptions', array());
if (ArrayHelper::getValue($item, Enum::STATE_ACTIVE)) {
ArrayHelper::addValue('class', Enum::STATE_ACTIVE, $options);
}
if ($items !== null) {
Html::addCssClass($options, Enum::DROPDOWN_HAS);
if (is_array($items)) {
$items = Nav::dropdown($items, $this->encodeLabels);
}
}
return \CHtml::tag('li', $options, \CHtml::link($label, $url, $linkOptions) . $items);
} | [
"protected",
"function",
"renderItem",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"item",
")",
")",
"{",
"return",
"$",
"item",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"item",
"[",
"'label'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"\"The 'label' option is required.\"",
")",
";",
"}",
"$",
"label",
"=",
"$",
"this",
"->",
"encodeLabels",
"?",
"\\",
"CHtml",
"::",
"encode",
"(",
"$",
"item",
"[",
"'label'",
"]",
")",
":",
"$",
"item",
"[",
"'label'",
"]",
";",
"$",
"options",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'options'",
",",
"array",
"(",
")",
")",
";",
"$",
"items",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'items'",
")",
";",
"$",
"url",
"=",
"\\",
"CHtml",
"::",
"normalizeUrl",
"(",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'url'",
",",
"'#'",
")",
")",
";",
"$",
"linkOptions",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"'linkOptions'",
",",
"array",
"(",
")",
")",
";",
"if",
"(",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"item",
",",
"Enum",
"::",
"STATE_ACTIVE",
")",
")",
"{",
"ArrayHelper",
"::",
"addValue",
"(",
"'class'",
",",
"Enum",
"::",
"STATE_ACTIVE",
",",
"$",
"options",
")",
";",
"}",
"if",
"(",
"$",
"items",
"!==",
"null",
")",
"{",
"Html",
"::",
"addCssClass",
"(",
"$",
"options",
",",
"Enum",
"::",
"DROPDOWN_HAS",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"items",
")",
")",
"{",
"$",
"items",
"=",
"Nav",
"::",
"dropdown",
"(",
"$",
"items",
",",
"$",
"this",
"->",
"encodeLabels",
")",
";",
"}",
"}",
"return",
"\\",
"CHtml",
"::",
"tag",
"(",
"'li'",
",",
"$",
"options",
",",
"\\",
"CHtml",
"::",
"link",
"(",
"$",
"label",
",",
"$",
"url",
",",
"$",
"linkOptions",
")",
".",
"$",
"items",
")",
";",
"}"
] | Renders a widget's item
@param mixed $item the item to render
@return string the rendering result.
@throws InvalidConfigException | [
"Renders",
"a",
"widget",
"s",
"item"
] | train | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/TopBar.php#L243-L269 |
afrittella/back-project | src/app/Http/ViewComposers/AdminMenuComposer.php | AdminMenuComposer.menu | function menu($menus)
{
// Retrieve current user (for permissions)
$user = Auth::user();
$templates = [
"menu" => '
<ul class="sidebar-menu" data-widget="tree">
%s
</ul>
',
"menu_row" => '
<li class="%s">
%s
</li>
', // class, link . submenu
"menu_caret" => '
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>',
"menu_subrow" => '
<ul class="treeview-menu">
%s
</ul>
',
"menu_link" => '
<a href="%s"><i class="%s text-red"></i><span>%s</span>%s</a>
' // url, icon, title
];
$traverse = function ($rows) use (&$traverse, $templates, $user) {
$menuString = "";
$hasActive = false;
foreach ($rows as $menu) {
if (!empty($menu->permission) and !$user->hasPermission($menu->permission)) {
continue;
}
$hasActive = false;
$submenu = "";
$authorized = true;
if ($menu->children->count() > 0) {
list($submenuString, $hasActive) = $traverse($menu->children);
$submenu = "";
if (!empty($submenuString)) {
$submenu = sprintf($templates['menu_subrow'], $submenuString);
} else {
$authorized = false;
}
}
$menu_caret = (!empty($submenu) ? $templates['menu_caret'] : '');
$link = sprintf($templates['menu_link'],
(!empty($menu->route) ? url($menu->route) : '#'),
(!empty($menu->icon) ? $menu->icon : 'fa fa-circle-o'),
//trans('back-project::base.dashboard')
\Lang::has('back-project::menu.' . $menu->title) ? __('back-project::menu.' . $menu->title) : $menu->title,
$menu_caret
);
$class = (!empty($submenu) ? 'treeview' : '');
$current_url = \Route::current()->uri();
if ($authorized) {
$menuString .= sprintf($templates['menu_row'], $class, $link . $submenu);
}
}
return [
$menuString,
$hasActive
];
};
list($menu, $hasActive) = $traverse($menus);
return sprintf($templates['menu'], $menu);
} | php | function menu($menus)
{
// Retrieve current user (for permissions)
$user = Auth::user();
$templates = [
"menu" => '
<ul class="sidebar-menu" data-widget="tree">
%s
</ul>
',
"menu_row" => '
<li class="%s">
%s
</li>
', // class, link . submenu
"menu_caret" => '
<span class="pull-right-container">
<i class="fa fa-angle-left pull-right"></i>
</span>',
"menu_subrow" => '
<ul class="treeview-menu">
%s
</ul>
',
"menu_link" => '
<a href="%s"><i class="%s text-red"></i><span>%s</span>%s</a>
' // url, icon, title
];
$traverse = function ($rows) use (&$traverse, $templates, $user) {
$menuString = "";
$hasActive = false;
foreach ($rows as $menu) {
if (!empty($menu->permission) and !$user->hasPermission($menu->permission)) {
continue;
}
$hasActive = false;
$submenu = "";
$authorized = true;
if ($menu->children->count() > 0) {
list($submenuString, $hasActive) = $traverse($menu->children);
$submenu = "";
if (!empty($submenuString)) {
$submenu = sprintf($templates['menu_subrow'], $submenuString);
} else {
$authorized = false;
}
}
$menu_caret = (!empty($submenu) ? $templates['menu_caret'] : '');
$link = sprintf($templates['menu_link'],
(!empty($menu->route) ? url($menu->route) : '#'),
(!empty($menu->icon) ? $menu->icon : 'fa fa-circle-o'),
//trans('back-project::base.dashboard')
\Lang::has('back-project::menu.' . $menu->title) ? __('back-project::menu.' . $menu->title) : $menu->title,
$menu_caret
);
$class = (!empty($submenu) ? 'treeview' : '');
$current_url = \Route::current()->uri();
if ($authorized) {
$menuString .= sprintf($templates['menu_row'], $class, $link . $submenu);
}
}
return [
$menuString,
$hasActive
];
};
list($menu, $hasActive) = $traverse($menus);
return sprintf($templates['menu'], $menu);
} | [
"function",
"menu",
"(",
"$",
"menus",
")",
"{",
"// Retrieve current user (for permissions)",
"$",
"user",
"=",
"Auth",
"::",
"user",
"(",
")",
";",
"$",
"templates",
"=",
"[",
"\"menu\"",
"=>",
"'\n <ul class=\"sidebar-menu\" data-widget=\"tree\">\n %s\n </ul>\n '",
",",
"\"menu_row\"",
"=>",
"'\n <li class=\"%s\">\n %s\n </li>\n '",
",",
"// class, link . submenu",
"\"menu_caret\"",
"=>",
"'\n <span class=\"pull-right-container\">\n <i class=\"fa fa-angle-left pull-right\"></i>\n </span>'",
",",
"\"menu_subrow\"",
"=>",
"'\n <ul class=\"treeview-menu\">\n %s\n </ul>\n '",
",",
"\"menu_link\"",
"=>",
"'\n <a href=\"%s\"><i class=\"%s text-red\"></i><span>%s</span>%s</a>\n '",
"// url, icon, title",
"]",
";",
"$",
"traverse",
"=",
"function",
"(",
"$",
"rows",
")",
"use",
"(",
"&",
"$",
"traverse",
",",
"$",
"templates",
",",
"$",
"user",
")",
"{",
"$",
"menuString",
"=",
"\"\"",
";",
"$",
"hasActive",
"=",
"false",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"menu",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"menu",
"->",
"permission",
")",
"and",
"!",
"$",
"user",
"->",
"hasPermission",
"(",
"$",
"menu",
"->",
"permission",
")",
")",
"{",
"continue",
";",
"}",
"$",
"hasActive",
"=",
"false",
";",
"$",
"submenu",
"=",
"\"\"",
";",
"$",
"authorized",
"=",
"true",
";",
"if",
"(",
"$",
"menu",
"->",
"children",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"list",
"(",
"$",
"submenuString",
",",
"$",
"hasActive",
")",
"=",
"$",
"traverse",
"(",
"$",
"menu",
"->",
"children",
")",
";",
"$",
"submenu",
"=",
"\"\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"submenuString",
")",
")",
"{",
"$",
"submenu",
"=",
"sprintf",
"(",
"$",
"templates",
"[",
"'menu_subrow'",
"]",
",",
"$",
"submenuString",
")",
";",
"}",
"else",
"{",
"$",
"authorized",
"=",
"false",
";",
"}",
"}",
"$",
"menu_caret",
"=",
"(",
"!",
"empty",
"(",
"$",
"submenu",
")",
"?",
"$",
"templates",
"[",
"'menu_caret'",
"]",
":",
"''",
")",
";",
"$",
"link",
"=",
"sprintf",
"(",
"$",
"templates",
"[",
"'menu_link'",
"]",
",",
"(",
"!",
"empty",
"(",
"$",
"menu",
"->",
"route",
")",
"?",
"url",
"(",
"$",
"menu",
"->",
"route",
")",
":",
"'#'",
")",
",",
"(",
"!",
"empty",
"(",
"$",
"menu",
"->",
"icon",
")",
"?",
"$",
"menu",
"->",
"icon",
":",
"'fa fa-circle-o'",
")",
",",
"//trans('back-project::base.dashboard')",
"\\",
"Lang",
"::",
"has",
"(",
"'back-project::menu.'",
".",
"$",
"menu",
"->",
"title",
")",
"?",
"__",
"(",
"'back-project::menu.'",
".",
"$",
"menu",
"->",
"title",
")",
":",
"$",
"menu",
"->",
"title",
",",
"$",
"menu_caret",
")",
";",
"$",
"class",
"=",
"(",
"!",
"empty",
"(",
"$",
"submenu",
")",
"?",
"'treeview'",
":",
"''",
")",
";",
"$",
"current_url",
"=",
"\\",
"Route",
"::",
"current",
"(",
")",
"->",
"uri",
"(",
")",
";",
"if",
"(",
"$",
"authorized",
")",
"{",
"$",
"menuString",
".=",
"sprintf",
"(",
"$",
"templates",
"[",
"'menu_row'",
"]",
",",
"$",
"class",
",",
"$",
"link",
".",
"$",
"submenu",
")",
";",
"}",
"}",
"return",
"[",
"$",
"menuString",
",",
"$",
"hasActive",
"]",
";",
"}",
";",
"list",
"(",
"$",
"menu",
",",
"$",
"hasActive",
")",
"=",
"$",
"traverse",
"(",
"$",
"menus",
")",
";",
"return",
"sprintf",
"(",
"$",
"templates",
"[",
"'menu'",
"]",
",",
"$",
"menu",
")",
";",
"}"
] | Format an AdminLTE Menu
$menus must be formatted in this way:
Menu
children
children
@param array $menus
@return string | [
"Format",
"an",
"AdminLTE",
"Menu"
] | train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Http/ViewComposers/AdminMenuComposer.php#L39-L119 |
ruvents/ruwork-upload-bundle | Manager/UploadManager.php | UploadManager.register | public function register($object, $source): void
{
$resolvedSource = $this->sourceResolver->resolve($source);
$this->accessor->setPath($object, $resolvedSource->getPath());
$this->accessor->setAttributes($object, $resolvedSource->getAttributes());
$this->resolvedSources->attach($object, $resolvedSource);
} | php | public function register($object, $source): void
{
$resolvedSource = $this->sourceResolver->resolve($source);
$this->accessor->setPath($object, $resolvedSource->getPath());
$this->accessor->setAttributes($object, $resolvedSource->getAttributes());
$this->resolvedSources->attach($object, $resolvedSource);
} | [
"public",
"function",
"register",
"(",
"$",
"object",
",",
"$",
"source",
")",
":",
"void",
"{",
"$",
"resolvedSource",
"=",
"$",
"this",
"->",
"sourceResolver",
"->",
"resolve",
"(",
"$",
"source",
")",
";",
"$",
"this",
"->",
"accessor",
"->",
"setPath",
"(",
"$",
"object",
",",
"$",
"resolvedSource",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"this",
"->",
"accessor",
"->",
"setAttributes",
"(",
"$",
"object",
",",
"$",
"resolvedSource",
"->",
"getAttributes",
"(",
")",
")",
";",
"$",
"this",
"->",
"resolvedSources",
"->",
"attach",
"(",
"$",
"object",
",",
"$",
"resolvedSource",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Manager/UploadManager.php#L38-L44 |
ruvents/ruwork-upload-bundle | Manager/UploadManager.php | UploadManager.getResolvedSource | public function getResolvedSource($object): ResolvedSource
{
if (!$this->resolvedSources->contains($object)) {
throw new NotRegisteredException('Object is not registered.');
}
return $this->resolvedSources[$object];
} | php | public function getResolvedSource($object): ResolvedSource
{
if (!$this->resolvedSources->contains($object)) {
throw new NotRegisteredException('Object is not registered.');
}
return $this->resolvedSources[$object];
} | [
"public",
"function",
"getResolvedSource",
"(",
"$",
"object",
")",
":",
"ResolvedSource",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"resolvedSources",
"->",
"contains",
"(",
"$",
"object",
")",
")",
"{",
"throw",
"new",
"NotRegisteredException",
"(",
"'Object is not registered.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolvedSources",
"[",
"$",
"object",
"]",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Manager/UploadManager.php#L49-L56 |
ruvents/ruwork-upload-bundle | Manager/UploadManager.php | UploadManager.save | public function save($object): void
{
$this->getResolvedSource($object)->save();
$this->detach($object);
} | php | public function save($object): void
{
$this->getResolvedSource($object)->save();
$this->detach($object);
} | [
"public",
"function",
"save",
"(",
"$",
"object",
")",
":",
"void",
"{",
"$",
"this",
"->",
"getResolvedSource",
"(",
"$",
"object",
")",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"detach",
"(",
"$",
"object",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Manager/UploadManager.php#L61-L65 |
ruvents/ruwork-upload-bundle | Manager/UploadManager.php | UploadManager.locate | public function locate($object): string
{
$path = $this->getPath($object);
return $this->pathLocator->locatePath($path);
} | php | public function locate($object): string
{
$path = $this->getPath($object);
return $this->pathLocator->locatePath($path);
} | [
"public",
"function",
"locate",
"(",
"$",
"object",
")",
":",
"string",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"object",
")",
";",
"return",
"$",
"this",
"->",
"pathLocator",
"->",
"locatePath",
"(",
"$",
"path",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Manager/UploadManager.php#L94-L99 |
xinix-technology/norm | src/Norm/Cursor/OCICursor.php | OCICursor.count | public function count($foundOnly = false)
{
$wheres = array();
$data = array();
$matchOrs = array();
$criteria = $this->translateCriteria($this->criteria);
if (is_null($this->match)) {
$criteria = $this->translateCriteria($this->criteria);
if ($criteria) {
foreach ($criteria as $key => $value) {
$wheres[] = $this->dialect->grammarExpression($key, $value,$this->collection, $data);
}
}
} else {
$schema = $this->collection->schema();
$i = 0;
foreach ($schema as $key => $value) {
if ($value instanceof Reference) {
$foreign = $value['foreign'];
$foreignLabel = $value['foreignLabel'];
$foreignKey = $value['foreignKey'];
$matchOrs[] = $this->getQueryReference($key, $foreign, $foreignLabel, $foreignKey, $i);
} else {
$matchOrs[] = $key.' LIKE :f'.$i;
$i++;
}
}
$wheres[] = '('.implode(' OR ', $matchOrs).')';
}
$query = "SELECT count(ROWNUM) r FROM " . $this->collection->getName();
if (!empty($wheres)) {
$query .= ' WHERE '.implode(' AND ', $wheres);
}
$statement = oci_parse($this->raw, $query);
foreach ($data as $key => $value) {
oci_bind_by_name($statement, ':'.$key, $data[$key]);
}
if ($foundOnly) {
if ($matchOrs) {
$match = '%'.$this->match.'%';
foreach ($matchOrs as $key => $value) {
oci_bind_by_name($statement, ':f'.$key, $match);
}
}
}
oci_execute($statement);
$result = array();
while ($row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
$result[] = $row;
}
oci_free_statement($statement);
$r = reset($result);
$r = $r['R'];
return (int) $r;
} | php | public function count($foundOnly = false)
{
$wheres = array();
$data = array();
$matchOrs = array();
$criteria = $this->translateCriteria($this->criteria);
if (is_null($this->match)) {
$criteria = $this->translateCriteria($this->criteria);
if ($criteria) {
foreach ($criteria as $key => $value) {
$wheres[] = $this->dialect->grammarExpression($key, $value,$this->collection, $data);
}
}
} else {
$schema = $this->collection->schema();
$i = 0;
foreach ($schema as $key => $value) {
if ($value instanceof Reference) {
$foreign = $value['foreign'];
$foreignLabel = $value['foreignLabel'];
$foreignKey = $value['foreignKey'];
$matchOrs[] = $this->getQueryReference($key, $foreign, $foreignLabel, $foreignKey, $i);
} else {
$matchOrs[] = $key.' LIKE :f'.$i;
$i++;
}
}
$wheres[] = '('.implode(' OR ', $matchOrs).')';
}
$query = "SELECT count(ROWNUM) r FROM " . $this->collection->getName();
if (!empty($wheres)) {
$query .= ' WHERE '.implode(' AND ', $wheres);
}
$statement = oci_parse($this->raw, $query);
foreach ($data as $key => $value) {
oci_bind_by_name($statement, ':'.$key, $data[$key]);
}
if ($foundOnly) {
if ($matchOrs) {
$match = '%'.$this->match.'%';
foreach ($matchOrs as $key => $value) {
oci_bind_by_name($statement, ':f'.$key, $match);
}
}
}
oci_execute($statement);
$result = array();
while ($row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
$result[] = $row;
}
oci_free_statement($statement);
$r = reset($result);
$r = $r['R'];
return (int) $r;
} | [
"public",
"function",
"count",
"(",
"$",
"foundOnly",
"=",
"false",
")",
"{",
"$",
"wheres",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"matchOrs",
"=",
"array",
"(",
")",
";",
"$",
"criteria",
"=",
"$",
"this",
"->",
"translateCriteria",
"(",
"$",
"this",
"->",
"criteria",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"match",
")",
")",
"{",
"$",
"criteria",
"=",
"$",
"this",
"->",
"translateCriteria",
"(",
"$",
"this",
"->",
"criteria",
")",
";",
"if",
"(",
"$",
"criteria",
")",
"{",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"wheres",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"->",
"grammarExpression",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"this",
"->",
"collection",
",",
"$",
"data",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"collection",
"->",
"schema",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"Reference",
")",
"{",
"$",
"foreign",
"=",
"$",
"value",
"[",
"'foreign'",
"]",
";",
"$",
"foreignLabel",
"=",
"$",
"value",
"[",
"'foreignLabel'",
"]",
";",
"$",
"foreignKey",
"=",
"$",
"value",
"[",
"'foreignKey'",
"]",
";",
"$",
"matchOrs",
"[",
"]",
"=",
"$",
"this",
"->",
"getQueryReference",
"(",
"$",
"key",
",",
"$",
"foreign",
",",
"$",
"foreignLabel",
",",
"$",
"foreignKey",
",",
"$",
"i",
")",
";",
"}",
"else",
"{",
"$",
"matchOrs",
"[",
"]",
"=",
"$",
"key",
".",
"' LIKE :f'",
".",
"$",
"i",
";",
"$",
"i",
"++",
";",
"}",
"}",
"$",
"wheres",
"[",
"]",
"=",
"'('",
".",
"implode",
"(",
"' OR '",
",",
"$",
"matchOrs",
")",
".",
"')'",
";",
"}",
"$",
"query",
"=",
"\"SELECT count(ROWNUM) r FROM \"",
".",
"$",
"this",
"->",
"collection",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"wheres",
")",
")",
"{",
"$",
"query",
".=",
"' WHERE '",
".",
"implode",
"(",
"' AND '",
",",
"$",
"wheres",
")",
";",
"}",
"$",
"statement",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"oci_bind_by_name",
"(",
"$",
"statement",
",",
"':'",
".",
"$",
"key",
",",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"$",
"foundOnly",
")",
"{",
"if",
"(",
"$",
"matchOrs",
")",
"{",
"$",
"match",
"=",
"'%'",
".",
"$",
"this",
"->",
"match",
".",
"'%'",
";",
"foreach",
"(",
"$",
"matchOrs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"oci_bind_by_name",
"(",
"$",
"statement",
",",
"':f'",
".",
"$",
"key",
",",
"$",
"match",
")",
";",
"}",
"}",
"}",
"oci_execute",
"(",
"$",
"statement",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"row",
"=",
"oci_fetch_array",
"(",
"$",
"statement",
",",
"OCI_ASSOC",
"+",
"OCI_RETURN_LOBS",
"+",
"OCI_RETURN_NULLS",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"oci_free_statement",
"(",
"$",
"statement",
")",
";",
"$",
"r",
"=",
"reset",
"(",
"$",
"result",
")",
";",
"$",
"r",
"=",
"$",
"r",
"[",
"'R'",
"]",
";",
"return",
"(",
"int",
")",
"$",
"r",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L155-L227 |
xinix-technology/norm | src/Norm/Cursor/OCICursor.php | OCICursor.prepareCriteria | public function prepareCriteria($criteria)
{
if (is_null($criteria)) {
$criteria = array();
}
if (array_key_exists('$id', $criteria)) {
$criteria['id'] = $criteria['$id'];
unset($criteria['$id']);
}
return $criteria ? : array();
} | php | public function prepareCriteria($criteria)
{
if (is_null($criteria)) {
$criteria = array();
}
if (array_key_exists('$id', $criteria)) {
$criteria['id'] = $criteria['$id'];
unset($criteria['$id']);
}
return $criteria ? : array();
} | [
"public",
"function",
"prepareCriteria",
"(",
"$",
"criteria",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"criteria",
")",
")",
"{",
"$",
"criteria",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'$id'",
",",
"$",
"criteria",
")",
")",
"{",
"$",
"criteria",
"[",
"'id'",
"]",
"=",
"$",
"criteria",
"[",
"'$id'",
"]",
";",
"unset",
"(",
"$",
"criteria",
"[",
"'$id'",
"]",
")",
";",
"}",
"return",
"$",
"criteria",
"?",
":",
"array",
"(",
")",
";",
"}"
] | comment for other criteria | [
"comment",
"for",
"other",
"criteria"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L244-L256 |
xinix-technology/norm | src/Norm/Cursor/OCICursor.php | OCICursor.getStatement | public function getStatement($type = null)
{
$data = array();
$wheres = array();
$matchOrs = array();
if (is_null($this->match)) {
$criteria = $this->translateCriteria($this->criteria);
if ($criteria) {
foreach ($criteria as $key => $value) {
$wheres[] = $this->dialect->grammarExpression($key, $value,$this->collection, $data);
}
}
} else {
$schema = $this->collection->schema();
$i = 0;
foreach ($schema as $key => $value) {
if ($value instanceof \Norm\Schema\Reference) {
$foreign = $value['foreign'];
$foreignLabel = $value['foreignLabel'];
$foreignKey = $value['foreignKey'];
$matchOrs[] = $this->getQueryReference($key, $foreign, $foreignLabel, $foreignKey, $i);
} else {
$matchOrs[] = $key.' LIKE :f'.$i;
$i++;
}
}
$wheres[] = '('.implode(' OR ', $matchOrs).')';
}
$select = '';
if ($this->skip > 0 or $this->limit > 0) {
$select .= 'rownum r, ';
}
$select .= $this->collection->getName().'.*';
$query = 'SELECT '.$select.' FROM '.$this->collection->getName();
$order = '';
if ($this->sortBy) {
foreach ($this->sortBy as $key => $value) {
if ($value == 1) {
$op = ' ASC';
} else {
$op = ' DESC';
}
$order[] = $key . $op;
}
if (!empty($order)) {
$order = ' ORDER BY '.implode(',', $order);
}
}
if (!empty($wheres)) {
$query .= ' WHERE '.implode(' AND ', $wheres);
}
$limit = '';
if ($this->skip > 0) {
$limit = 'r > '.($this->skip).' AND ROWNUM <= (SELECT COUNT(ROWNUM) FROM ('.$query.'))';
if ($this->limit > 0) {
$limit = 'r > '.($this->skip).' AND ROWNUM <= ' . $this->limit;
}
} elseif ($this->limit > 0) {
$limit = 'r <= ' . $this->limit;
}
$query .= $order;
if ($limit !== '') {
$query = 'SELECT * FROM ('.$query.') WHERE '.$limit;
}
$statement = oci_parse($this->raw, $query);
foreach ($data as $key => $value) {
oci_bind_by_name($statement, ':'.$key, $data[$key]);
}
if ($matchOrs) {
$match = '%'.$this->match.'%';
foreach ($matchOrs as $key => $value) {
oci_bind_by_name($statement, ':f'.$key, $match);
}
}
oci_execute($statement);
$result = array();
while ($row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
$result[] = $row;
}
$this->rows = $result;
oci_free_statement($statement);
$this->index = -1;
} | php | public function getStatement($type = null)
{
$data = array();
$wheres = array();
$matchOrs = array();
if (is_null($this->match)) {
$criteria = $this->translateCriteria($this->criteria);
if ($criteria) {
foreach ($criteria as $key => $value) {
$wheres[] = $this->dialect->grammarExpression($key, $value,$this->collection, $data);
}
}
} else {
$schema = $this->collection->schema();
$i = 0;
foreach ($schema as $key => $value) {
if ($value instanceof \Norm\Schema\Reference) {
$foreign = $value['foreign'];
$foreignLabel = $value['foreignLabel'];
$foreignKey = $value['foreignKey'];
$matchOrs[] = $this->getQueryReference($key, $foreign, $foreignLabel, $foreignKey, $i);
} else {
$matchOrs[] = $key.' LIKE :f'.$i;
$i++;
}
}
$wheres[] = '('.implode(' OR ', $matchOrs).')';
}
$select = '';
if ($this->skip > 0 or $this->limit > 0) {
$select .= 'rownum r, ';
}
$select .= $this->collection->getName().'.*';
$query = 'SELECT '.$select.' FROM '.$this->collection->getName();
$order = '';
if ($this->sortBy) {
foreach ($this->sortBy as $key => $value) {
if ($value == 1) {
$op = ' ASC';
} else {
$op = ' DESC';
}
$order[] = $key . $op;
}
if (!empty($order)) {
$order = ' ORDER BY '.implode(',', $order);
}
}
if (!empty($wheres)) {
$query .= ' WHERE '.implode(' AND ', $wheres);
}
$limit = '';
if ($this->skip > 0) {
$limit = 'r > '.($this->skip).' AND ROWNUM <= (SELECT COUNT(ROWNUM) FROM ('.$query.'))';
if ($this->limit > 0) {
$limit = 'r > '.($this->skip).' AND ROWNUM <= ' . $this->limit;
}
} elseif ($this->limit > 0) {
$limit = 'r <= ' . $this->limit;
}
$query .= $order;
if ($limit !== '') {
$query = 'SELECT * FROM ('.$query.') WHERE '.$limit;
}
$statement = oci_parse($this->raw, $query);
foreach ($data as $key => $value) {
oci_bind_by_name($statement, ':'.$key, $data[$key]);
}
if ($matchOrs) {
$match = '%'.$this->match.'%';
foreach ($matchOrs as $key => $value) {
oci_bind_by_name($statement, ':f'.$key, $match);
}
}
oci_execute($statement);
$result = array();
while ($row = oci_fetch_array($statement, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
$result[] = $row;
}
$this->rows = $result;
oci_free_statement($statement);
$this->index = -1;
} | [
"public",
"function",
"getStatement",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"wheres",
"=",
"array",
"(",
")",
";",
"$",
"matchOrs",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"match",
")",
")",
"{",
"$",
"criteria",
"=",
"$",
"this",
"->",
"translateCriteria",
"(",
"$",
"this",
"->",
"criteria",
")",
";",
"if",
"(",
"$",
"criteria",
")",
"{",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"wheres",
"[",
"]",
"=",
"$",
"this",
"->",
"dialect",
"->",
"grammarExpression",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"this",
"->",
"collection",
",",
"$",
"data",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"collection",
"->",
"schema",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Norm",
"\\",
"Schema",
"\\",
"Reference",
")",
"{",
"$",
"foreign",
"=",
"$",
"value",
"[",
"'foreign'",
"]",
";",
"$",
"foreignLabel",
"=",
"$",
"value",
"[",
"'foreignLabel'",
"]",
";",
"$",
"foreignKey",
"=",
"$",
"value",
"[",
"'foreignKey'",
"]",
";",
"$",
"matchOrs",
"[",
"]",
"=",
"$",
"this",
"->",
"getQueryReference",
"(",
"$",
"key",
",",
"$",
"foreign",
",",
"$",
"foreignLabel",
",",
"$",
"foreignKey",
",",
"$",
"i",
")",
";",
"}",
"else",
"{",
"$",
"matchOrs",
"[",
"]",
"=",
"$",
"key",
".",
"' LIKE :f'",
".",
"$",
"i",
";",
"$",
"i",
"++",
";",
"}",
"}",
"$",
"wheres",
"[",
"]",
"=",
"'('",
".",
"implode",
"(",
"' OR '",
",",
"$",
"matchOrs",
")",
".",
"')'",
";",
"}",
"$",
"select",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"skip",
">",
"0",
"or",
"$",
"this",
"->",
"limit",
">",
"0",
")",
"{",
"$",
"select",
".=",
"'rownum r, '",
";",
"}",
"$",
"select",
".=",
"$",
"this",
"->",
"collection",
"->",
"getName",
"(",
")",
".",
"'.*'",
";",
"$",
"query",
"=",
"'SELECT '",
".",
"$",
"select",
".",
"' FROM '",
".",
"$",
"this",
"->",
"collection",
"->",
"getName",
"(",
")",
";",
"$",
"order",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"sortBy",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"sortBy",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"1",
")",
"{",
"$",
"op",
"=",
"' ASC'",
";",
"}",
"else",
"{",
"$",
"op",
"=",
"' DESC'",
";",
"}",
"$",
"order",
"[",
"]",
"=",
"$",
"key",
".",
"$",
"op",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"order",
")",
")",
"{",
"$",
"order",
"=",
"' ORDER BY '",
".",
"implode",
"(",
"','",
",",
"$",
"order",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"wheres",
")",
")",
"{",
"$",
"query",
".=",
"' WHERE '",
".",
"implode",
"(",
"' AND '",
",",
"$",
"wheres",
")",
";",
"}",
"$",
"limit",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"skip",
">",
"0",
")",
"{",
"$",
"limit",
"=",
"'r > '",
".",
"(",
"$",
"this",
"->",
"skip",
")",
".",
"' AND ROWNUM <= (SELECT COUNT(ROWNUM) FROM ('",
".",
"$",
"query",
".",
"'))'",
";",
"if",
"(",
"$",
"this",
"->",
"limit",
">",
"0",
")",
"{",
"$",
"limit",
"=",
"'r > '",
".",
"(",
"$",
"this",
"->",
"skip",
")",
".",
"' AND ROWNUM <= '",
".",
"$",
"this",
"->",
"limit",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"limit",
">",
"0",
")",
"{",
"$",
"limit",
"=",
"'r <= '",
".",
"$",
"this",
"->",
"limit",
";",
"}",
"$",
"query",
".=",
"$",
"order",
";",
"if",
"(",
"$",
"limit",
"!==",
"''",
")",
"{",
"$",
"query",
"=",
"'SELECT * FROM ('",
".",
"$",
"query",
".",
"') WHERE '",
".",
"$",
"limit",
";",
"}",
"$",
"statement",
"=",
"oci_parse",
"(",
"$",
"this",
"->",
"raw",
",",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"oci_bind_by_name",
"(",
"$",
"statement",
",",
"':'",
".",
"$",
"key",
",",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"$",
"matchOrs",
")",
"{",
"$",
"match",
"=",
"'%'",
".",
"$",
"this",
"->",
"match",
".",
"'%'",
";",
"foreach",
"(",
"$",
"matchOrs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"oci_bind_by_name",
"(",
"$",
"statement",
",",
"':f'",
".",
"$",
"key",
",",
"$",
"match",
")",
";",
"}",
"}",
"oci_execute",
"(",
"$",
"statement",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"row",
"=",
"oci_fetch_array",
"(",
"$",
"statement",
",",
"OCI_ASSOC",
"+",
"OCI_RETURN_LOBS",
"+",
"OCI_RETURN_NULLS",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"this",
"->",
"rows",
"=",
"$",
"result",
";",
"oci_free_statement",
"(",
"$",
"statement",
")",
";",
"$",
"this",
"->",
"index",
"=",
"-",
"1",
";",
"}"
] | Execute a query.
@return int | [
"Execute",
"a",
"query",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L280-L391 |
xinix-technology/norm | src/Norm/Cursor/OCICursor.php | OCICursor.sort | public function sort(array $sorts = array())
{
if (func_num_args() === 0) {
return $this->sorts;
}
$this->sorts = array();
foreach ($sorts as $key => $value) {
if ($key[0] === '$') {
$key = 'h_' . substr($key, 1);
}
$this->sorts[$key] = $value;
}
$this->sortBy = $this->sorts;
return $this;
} | php | public function sort(array $sorts = array())
{
if (func_num_args() === 0) {
return $this->sorts;
}
$this->sorts = array();
foreach ($sorts as $key => $value) {
if ($key[0] === '$') {
$key = 'h_' . substr($key, 1);
}
$this->sorts[$key] = $value;
}
$this->sortBy = $this->sorts;
return $this;
} | [
"public",
"function",
"sort",
"(",
"array",
"$",
"sorts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"sorts",
";",
"}",
"$",
"this",
"->",
"sorts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"sorts",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"[",
"0",
"]",
"===",
"'$'",
")",
"{",
"$",
"key",
"=",
"'h_'",
".",
"substr",
"(",
"$",
"key",
",",
"1",
")",
";",
"}",
"$",
"this",
"->",
"sorts",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"this",
"->",
"sortBy",
"=",
"$",
"this",
"->",
"sorts",
";",
"return",
"$",
"this",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L397-L417 |
xinix-technology/norm | src/Norm/Cursor/OCICursor.php | OCICursor.getQueryReference | public function getQueryReference($key = '', $foreign = '', $foreignLabel = '', $foreignKey = '', &$i)
{
$model = Norm::factory($foreign);
$refSchemes = $model->schema();
$foreignKey = $foreignKey ?: 'id';
if ($foreignKey == '$id') {
$foreignKey = 'id';
}
$query = $key . ' IN (SELECT '.$foreignKey.' FROM '.strtolower($foreign).' WHERE '.$foreignLabel.' LIKE :f'.$i.') ';
$i++;
return $query;
} | php | public function getQueryReference($key = '', $foreign = '', $foreignLabel = '', $foreignKey = '', &$i)
{
$model = Norm::factory($foreign);
$refSchemes = $model->schema();
$foreignKey = $foreignKey ?: 'id';
if ($foreignKey == '$id') {
$foreignKey = 'id';
}
$query = $key . ' IN (SELECT '.$foreignKey.' FROM '.strtolower($foreign).' WHERE '.$foreignLabel.' LIKE :f'.$i.') ';
$i++;
return $query;
} | [
"public",
"function",
"getQueryReference",
"(",
"$",
"key",
"=",
"''",
",",
"$",
"foreign",
"=",
"''",
",",
"$",
"foreignLabel",
"=",
"''",
",",
"$",
"foreignKey",
"=",
"''",
",",
"&",
"$",
"i",
")",
"{",
"$",
"model",
"=",
"Norm",
"::",
"factory",
"(",
"$",
"foreign",
")",
";",
"$",
"refSchemes",
"=",
"$",
"model",
"->",
"schema",
"(",
")",
";",
"$",
"foreignKey",
"=",
"$",
"foreignKey",
"?",
":",
"'id'",
";",
"if",
"(",
"$",
"foreignKey",
"==",
"'$id'",
")",
"{",
"$",
"foreignKey",
"=",
"'id'",
";",
"}",
"$",
"query",
"=",
"$",
"key",
".",
"' IN (SELECT '",
".",
"$",
"foreignKey",
".",
"' FROM '",
".",
"strtolower",
"(",
"$",
"foreign",
")",
".",
"' WHERE '",
".",
"$",
"foreignLabel",
".",
"' LIKE :f'",
".",
"$",
"i",
".",
"') '",
";",
"$",
"i",
"++",
";",
"return",
"$",
"query",
";",
"}"
] | Find reference of a foreign key.
@param string $key
@param string $foreign
@param string $foreignLabel
@param string $foreignKey
@param int &$i
@return string | [
"Find",
"reference",
"of",
"a",
"foreign",
"key",
"."
] | train | https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Cursor/OCICursor.php#L450-L464 |
dms-org/package.blog | src/Domain/Services/Loader/BlogAuthorLoader.php | BlogAuthorLoader.loadFromSlug | public function loadFromSlug(string $slug) : BlogAuthor
{
$categories = $this->blogAuthorRepo->matching(
$this->blogAuthorRepo->criteria()
->where(BlogAuthor::SLUG, '=', $slug)
);
if (!$categories) {
throw new EntityNotFoundException(BlogAuthor::class, $slug, BlogAuthor::SLUG);
}
return reset($categories);
} | php | public function loadFromSlug(string $slug) : BlogAuthor
{
$categories = $this->blogAuthorRepo->matching(
$this->blogAuthorRepo->criteria()
->where(BlogAuthor::SLUG, '=', $slug)
);
if (!$categories) {
throw new EntityNotFoundException(BlogAuthor::class, $slug, BlogAuthor::SLUG);
}
return reset($categories);
} | [
"public",
"function",
"loadFromSlug",
"(",
"string",
"$",
"slug",
")",
":",
"BlogAuthor",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"blogAuthorRepo",
"->",
"matching",
"(",
"$",
"this",
"->",
"blogAuthorRepo",
"->",
"criteria",
"(",
")",
"->",
"where",
"(",
"BlogAuthor",
"::",
"SLUG",
",",
"'='",
",",
"$",
"slug",
")",
")",
";",
"if",
"(",
"!",
"$",
"categories",
")",
"{",
"throw",
"new",
"EntityNotFoundException",
"(",
"BlogAuthor",
"::",
"class",
",",
"$",
"slug",
",",
"BlogAuthor",
"::",
"SLUG",
")",
";",
"}",
"return",
"reset",
"(",
"$",
"categories",
")",
";",
"}"
] | @param string $slug
@return BlogAuthor
@throws EntityNotFoundException | [
"@param",
"string",
"$slug"
] | train | https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Domain/Services/Loader/BlogAuthorLoader.php#L46-L58 |
webforge-labs/psc-cms | lib/Psc/System/File.php | File.replaceContents | public function replaceContents(Array $replacements) {
$this->writeContents(
str_replace(
array_keys($replacements),
array_values($replacements),
$this->getContents()
)
);
return $this;
} | php | public function replaceContents(Array $replacements) {
$this->writeContents(
str_replace(
array_keys($replacements),
array_values($replacements),
$this->getContents()
)
);
return $this;
} | [
"public",
"function",
"replaceContents",
"(",
"Array",
"$",
"replacements",
")",
"{",
"$",
"this",
"->",
"writeContents",
"(",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replacements",
")",
",",
"array_values",
"(",
"$",
"replacements",
")",
",",
"$",
"this",
"->",
"getContents",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Replaces the contents of the file
@deprecated | [
"Replaces",
"the",
"contents",
"of",
"the",
"file"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/File.php#L11-L20 |
anime-db/app-bundle | src/DQL/Datetime.php | Datetime.getSql | public function getSql(SqlWalker $sqlWalker)
{
return sprintf(
'DATETIME(%s, %s)',
$this->firstDateExpression->dispatch($sqlWalker),
$this->secondDateExpression->dispatch($sqlWalker)
);
} | php | public function getSql(SqlWalker $sqlWalker)
{
return sprintf(
'DATETIME(%s, %s)',
$this->firstDateExpression->dispatch($sqlWalker),
$this->secondDateExpression->dispatch($sqlWalker)
);
} | [
"public",
"function",
"getSql",
"(",
"SqlWalker",
"$",
"sqlWalker",
")",
"{",
"return",
"sprintf",
"(",
"'DATETIME(%s, %s)'",
",",
"$",
"this",
"->",
"firstDateExpression",
"->",
"dispatch",
"(",
"$",
"sqlWalker",
")",
",",
"$",
"this",
"->",
"secondDateExpression",
"->",
"dispatch",
"(",
"$",
"sqlWalker",
")",
")",
";",
"}"
] | @param SqlWalker $sqlWalker
@return string | [
"@param",
"SqlWalker",
"$sqlWalker"
] | train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/DQL/Datetime.php#L56-L63 |
askupasoftware/amarkal | Extensions/WordPress/Widget/Widget.php | Widget.set_field_names | private function set_field_names()
{
foreach ( $this->config->fields as $field )
{
$field->init_name = $field->name;
}
} | php | private function set_field_names()
{
foreach ( $this->config->fields as $field )
{
$field->init_name = $field->name;
}
} | [
"private",
"function",
"set_field_names",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"init_name",
"=",
"$",
"field",
"->",
"name",
";",
"}",
"}"
] | Since the widget's form sets custom names and ids to each field,
the original field name must be stored seperately using this function. | [
"Since",
"the",
"widget",
"s",
"form",
"sets",
"custom",
"names",
"and",
"ids",
"to",
"each",
"field",
"the",
"original",
"field",
"name",
"must",
"be",
"stored",
"seperately",
"using",
"this",
"function",
"."
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Widget/Widget.php#L85-L91 |
askupasoftware/amarkal | Extensions/WordPress/Widget/Widget.php | Widget.form | public function form( $instance )
{
// Reset the names so that the form's update function works properly
foreach ( $this->config->fields as $field )
{
$field->name = $field->init_name;
}
// Update values
$this->form->updater->set_new_instance( $instance );
$this->form->updater->update();
// Set the widget specific field names and ids
foreach ( $this->config->fields as $field )
{
$field->id = $this->get_field_id( $field->init_name );
$field->name = $this->get_field_name( $field->init_name );
}
// Print the form
$this->form->render(true);
} | php | public function form( $instance )
{
// Reset the names so that the form's update function works properly
foreach ( $this->config->fields as $field )
{
$field->name = $field->init_name;
}
// Update values
$this->form->updater->set_new_instance( $instance );
$this->form->updater->update();
// Set the widget specific field names and ids
foreach ( $this->config->fields as $field )
{
$field->id = $this->get_field_id( $field->init_name );
$field->name = $this->get_field_name( $field->init_name );
}
// Print the form
$this->form->render(true);
} | [
"public",
"function",
"form",
"(",
"$",
"instance",
")",
"{",
"// Reset the names so that the form's update function works properly",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"name",
"=",
"$",
"field",
"->",
"init_name",
";",
"}",
"// Update values",
"$",
"this",
"->",
"form",
"->",
"updater",
"->",
"set_new_instance",
"(",
"$",
"instance",
")",
";",
"$",
"this",
"->",
"form",
"->",
"updater",
"->",
"update",
"(",
")",
";",
"// Set the widget specific field names and ids",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"field",
"->",
"id",
"=",
"$",
"this",
"->",
"get_field_id",
"(",
"$",
"field",
"->",
"init_name",
")",
";",
"$",
"field",
"->",
"name",
"=",
"$",
"this",
"->",
"get_field_name",
"(",
"$",
"field",
"->",
"init_name",
")",
";",
"}",
"// Print the form",
"$",
"this",
"->",
"form",
"->",
"render",
"(",
"true",
")",
";",
"}"
] | Generates the administration form for the widget
@param array $instance The array of keys and
values for the widget | [
"Generates",
"the",
"administration",
"form",
"for",
"the",
"widget"
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Widget/Widget.php#L99-L119 |
askupasoftware/amarkal | Extensions/WordPress/Widget/Widget.php | Widget.update | public function update( $new_instance, $old_instance )
{
$this->form->updater->set_new_instance( $new_instance );
return $this->form->updater->update( $old_instance );
} | php | public function update( $new_instance, $old_instance )
{
$this->form->updater->set_new_instance( $new_instance );
return $this->form->updater->update( $old_instance );
} | [
"public",
"function",
"update",
"(",
"$",
"new_instance",
",",
"$",
"old_instance",
")",
"{",
"$",
"this",
"->",
"form",
"->",
"updater",
"->",
"set_new_instance",
"(",
"$",
"new_instance",
")",
";",
"return",
"$",
"this",
"->",
"form",
"->",
"updater",
"->",
"update",
"(",
"$",
"old_instance",
")",
";",
"}"
] | Processes the widget's options to be saved.
@param array new_instance The previous instance
of values before the update.
@param array old_instance The new instance of
values to be generated via the update. | [
"Processes",
"the",
"widget",
"s",
"options",
"to",
"be",
"saved",
"."
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Widget/Widget.php#L129-L133 |
djgadd/themosis-illuminate | src/Filesystem/StorageFacade.php | StorageFacade.fake | public static function fake($disk)
{
(new Filesystem)->cleanDirectory(
$root = storage_path('framework/testing/disks/'.$disk)
);
static::set($disk, self::createLocalDriver(['root' => $root]));
} | php | public static function fake($disk)
{
(new Filesystem)->cleanDirectory(
$root = storage_path('framework/testing/disks/'.$disk)
);
static::set($disk, self::createLocalDriver(['root' => $root]));
} | [
"public",
"static",
"function",
"fake",
"(",
"$",
"disk",
")",
"{",
"(",
"new",
"Filesystem",
")",
"->",
"cleanDirectory",
"(",
"$",
"root",
"=",
"storage_path",
"(",
"'framework/testing/disks/'",
".",
"$",
"disk",
")",
")",
";",
"static",
"::",
"set",
"(",
"$",
"disk",
",",
"self",
"::",
"createLocalDriver",
"(",
"[",
"'root'",
"=>",
"$",
"root",
"]",
")",
")",
";",
"}"
] | Replace the given disk with a local, testing disk.
@param string $disk
@return void | [
"Replace",
"the",
"given",
"disk",
"with",
"a",
"local",
"testing",
"disk",
"."
] | train | https://github.com/djgadd/themosis-illuminate/blob/13ee4c3413cddd85a2f262ac361f35c81da0c53c/src/Filesystem/StorageFacade.php#L19-L26 |
askupasoftware/amarkal | Form/Form.php | Form.validate_components | private function validate_components( $components )
{
foreach( $components as $component )
{
if( ! $component instanceof UI\AbstractComponent )
{
throw new WrongTypeException( \gettype( $component ) );
}
if( $component instanceof UI\Components\Composite )
{
$this->validate_components( $component->components );
continue;
}
if( $component instanceof UI\ValueComponentInterface && in_array( $component->name, $this->names ) )
{
throw new DuplicateNameException( $component->name );
}
$this->names[] = $component->name;
}
} | php | private function validate_components( $components )
{
foreach( $components as $component )
{
if( ! $component instanceof UI\AbstractComponent )
{
throw new WrongTypeException( \gettype( $component ) );
}
if( $component instanceof UI\Components\Composite )
{
$this->validate_components( $component->components );
continue;
}
if( $component instanceof UI\ValueComponentInterface && in_array( $component->name, $this->names ) )
{
throw new DuplicateNameException( $component->name );
}
$this->names[] = $component->name;
}
} | [
"private",
"function",
"validate_components",
"(",
"$",
"components",
")",
"{",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"!",
"$",
"component",
"instanceof",
"UI",
"\\",
"AbstractComponent",
")",
"{",
"throw",
"new",
"WrongTypeException",
"(",
"\\",
"gettype",
"(",
"$",
"component",
")",
")",
";",
"}",
"if",
"(",
"$",
"component",
"instanceof",
"UI",
"\\",
"Components",
"\\",
"Composite",
")",
"{",
"$",
"this",
"->",
"validate_components",
"(",
"$",
"component",
"->",
"components",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"component",
"instanceof",
"UI",
"\\",
"ValueComponentInterface",
"&&",
"in_array",
"(",
"$",
"component",
"->",
"name",
",",
"$",
"this",
"->",
"names",
")",
")",
"{",
"throw",
"new",
"DuplicateNameException",
"(",
"$",
"component",
"->",
"name",
")",
";",
"}",
"$",
"this",
"->",
"names",
"[",
"]",
"=",
"$",
"component",
"->",
"name",
";",
"}",
"}"
] | Internally used to validate each form component.
@param \Amarkal\UI\AbstractComponent[] $components
@throws \Amarkal\Form\DuplicateNameException | [
"Internally",
"used",
"to",
"validate",
"each",
"form",
"component",
"."
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Form/Form.php#L42-L64 |
ClanCats/Core | src/bundles/Mail/Transporter/Smtp.php | Transporter_Smtp.setup_driver | protected function setup_driver( &$driver )
{
$driver->IsSMTP();
$driver->Host = $this->config->host;
// smtp auth?
if ( $this->config->auth === true )
{
$driver->SMTPAuth = true;
$driver->Username = $this->config->user;
$driver->Password = $this->config->pass;
}
$driver->SMTPSecure = $this->config->encryption;
$driver->Port = $this->config->port;
} | php | protected function setup_driver( &$driver )
{
$driver->IsSMTP();
$driver->Host = $this->config->host;
// smtp auth?
if ( $this->config->auth === true )
{
$driver->SMTPAuth = true;
$driver->Username = $this->config->user;
$driver->Password = $this->config->pass;
}
$driver->SMTPSecure = $this->config->encryption;
$driver->Port = $this->config->port;
} | [
"protected",
"function",
"setup_driver",
"(",
"&",
"$",
"driver",
")",
"{",
"$",
"driver",
"->",
"IsSMTP",
"(",
")",
";",
"$",
"driver",
"->",
"Host",
"=",
"$",
"this",
"->",
"config",
"->",
"host",
";",
"// smtp auth?",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"auth",
"===",
"true",
")",
"{",
"$",
"driver",
"->",
"SMTPAuth",
"=",
"true",
";",
"$",
"driver",
"->",
"Username",
"=",
"$",
"this",
"->",
"config",
"->",
"user",
";",
"$",
"driver",
"->",
"Password",
"=",
"$",
"this",
"->",
"config",
"->",
"pass",
";",
"}",
"$",
"driver",
"->",
"SMTPSecure",
"=",
"$",
"this",
"->",
"config",
"->",
"encryption",
";",
"$",
"driver",
"->",
"Port",
"=",
"$",
"this",
"->",
"config",
"->",
"port",
";",
"}"
] | Set the driver settings ( smtp / sendmail )
@param PHPMailer $driver
@return void | [
"Set",
"the",
"driver",
"settings",
"(",
"smtp",
"/",
"sendmail",
")"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/Transporter/Smtp.php#L20-L35 |
digitalkaoz/versioneye-php | src/Console/CommandFactory.php | CommandFactory.generateCommands | public function generateCommands(array $classes = [])
{
$classes = $this->readApis($classes);
$token = $this->token->read();
$commands = [];
foreach ($classes as $class) {
$api = new \ReflectionClass($class);
foreach ($api->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (0 !== strpos($method->getName(), '__')) { //skip magics
$command = $this->generateCommand($api->getShortName(), $method, $token);
$commands[$command->getName()] = $command;
}
}
}
return $commands;
} | php | public function generateCommands(array $classes = [])
{
$classes = $this->readApis($classes);
$token = $this->token->read();
$commands = [];
foreach ($classes as $class) {
$api = new \ReflectionClass($class);
foreach ($api->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (0 !== strpos($method->getName(), '__')) { //skip magics
$command = $this->generateCommand($api->getShortName(), $method, $token);
$commands[$command->getName()] = $command;
}
}
}
return $commands;
} | [
"public",
"function",
"generateCommands",
"(",
"array",
"$",
"classes",
"=",
"[",
"]",
")",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"readApis",
"(",
"$",
"classes",
")",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"token",
"->",
"read",
"(",
")",
";",
"$",
"commands",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"api",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"api",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"0",
"!==",
"strpos",
"(",
"$",
"method",
"->",
"getName",
"(",
")",
",",
"'__'",
")",
")",
"{",
"//skip magics",
"$",
"command",
"=",
"$",
"this",
"->",
"generateCommand",
"(",
"$",
"api",
"->",
"getShortName",
"(",
")",
",",
"$",
"method",
",",
"$",
"token",
")",
";",
"$",
"commands",
"[",
"$",
"command",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"command",
";",
"}",
"}",
"}",
"return",
"$",
"commands",
";",
"}"
] | generates Commands from all Api Methods.
@param array $classes
@return Command[] | [
"generates",
"Commands",
"from",
"all",
"Api",
"Methods",
"."
] | train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Console/CommandFactory.php#L48-L66 |
digitalkaoz/versioneye-php | src/Console/CommandFactory.php | CommandFactory.buildDefinition | private function buildDefinition(\ReflectionMethod $method, $token = null)
{
$definition = new InputDefinition();
foreach ($method->getParameters() as $parameter) {
if ($parameter->isDefaultValueAvailable()) {
//option
$definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, null, $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null));
} else {
//argument
$definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, null, null));
}
}
$definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'the auth token to use', $token));
$definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'display raw response'));
return $definition;
} | php | private function buildDefinition(\ReflectionMethod $method, $token = null)
{
$definition = new InputDefinition();
foreach ($method->getParameters() as $parameter) {
if ($parameter->isDefaultValueAvailable()) {
//option
$definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, null, $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null));
} else {
//argument
$definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, null, null));
}
}
$definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'the auth token to use', $token));
$definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'display raw response'));
return $definition;
} | [
"private",
"function",
"buildDefinition",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
",",
"$",
"token",
"=",
"null",
")",
"{",
"$",
"definition",
"=",
"new",
"InputDefinition",
"(",
")",
";",
"foreach",
"(",
"$",
"method",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"parameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"//option",
"$",
"definition",
"->",
"addOption",
"(",
"new",
"InputOption",
"(",
"$",
"parameter",
"->",
"getName",
"(",
")",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"null",
",",
"$",
"parameter",
"->",
"isDefaultValueAvailable",
"(",
")",
"?",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
":",
"null",
")",
")",
";",
"}",
"else",
"{",
"//argument",
"$",
"definition",
"->",
"addArgument",
"(",
"new",
"InputArgument",
"(",
"$",
"parameter",
"->",
"getName",
"(",
")",
",",
"InputArgument",
"::",
"REQUIRED",
",",
"null",
",",
"null",
")",
")",
";",
"}",
"}",
"$",
"definition",
"->",
"addOption",
"(",
"new",
"InputOption",
"(",
"'token'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_REQUIRED",
",",
"'the auth token to use'",
",",
"$",
"token",
")",
")",
";",
"$",
"definition",
"->",
"addOption",
"(",
"new",
"InputOption",
"(",
"'debug'",
",",
"null",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"'display raw response'",
")",
")",
";",
"return",
"$",
"definition",
";",
"}"
] | builds the Input Definition based upon Api Method Parameters.
@param \ReflectionMethod $method
@param string $token
@return InputDefinition | [
"builds",
"the",
"Input",
"Definition",
"based",
"upon",
"Api",
"Method",
"Parameters",
"."
] | train | https://github.com/digitalkaoz/versioneye-php/blob/7b8eb9cdc83e01138dda0e709c07e3beb6aad136/src/Console/CommandFactory.php#L99-L117 |
ClanCats/Core | src/bundles/UI/Builder.php | Builder._init | public static function _init()
{
// select the current builder
$builder_class = \ClanCats::$config->get( 'ui.builder', "\\UI\\Builder_Bootstrap" );
static::$builder = new $builder_class;
// load the ui configuration
static::$config = \CCConfig::create( 'ui' );
} | php | public static function _init()
{
// select the current builder
$builder_class = \ClanCats::$config->get( 'ui.builder', "\\UI\\Builder_Bootstrap" );
static::$builder = new $builder_class;
// load the ui configuration
static::$config = \CCConfig::create( 'ui' );
} | [
"public",
"static",
"function",
"_init",
"(",
")",
"{",
"// select the current builder",
"$",
"builder_class",
"=",
"\\",
"ClanCats",
"::",
"$",
"config",
"->",
"get",
"(",
"'ui.builder'",
",",
"\"\\\\UI\\\\Builder_Bootstrap\"",
")",
";",
"static",
"::",
"$",
"builder",
"=",
"new",
"$",
"builder_class",
";",
"// load the ui configuration",
"static",
"::",
"$",
"config",
"=",
"\\",
"CCConfig",
"::",
"create",
"(",
"'ui'",
")",
";",
"}"
] | Static init
@return void | [
"Static",
"init"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Builder.php#L32-L40 |
ClanCats/Core | src/bundles/UI/Builder.php | Builder.handle | public static function handle()
{
$args = func_get_args();
$key = array_shift( $args );
return call_user_func_array( array( static::$builder, 'build_'.$key ), $args );
} | php | public static function handle()
{
$args = func_get_args();
$key = array_shift( $args );
return call_user_func_array( array( static::$builder, 'build_'.$key ), $args );
} | [
"public",
"static",
"function",
"handle",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"return",
"call_user_func_array",
"(",
"array",
"(",
"static",
"::",
"$",
"builder",
",",
"'build_'",
".",
"$",
"key",
")",
",",
"$",
"args",
")",
";",
"}"
] | Handle a build request
@param string $key
@param mixed ... | [
"Handle",
"a",
"build",
"request"
] | train | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Builder.php#L48-L54 |
anime-db/app-bundle | src/Service/TwigExtension.php | TwigExtension.favicon | public function favicon($url)
{
return $url ? $this->router->generate('media_favicon', ['host' => parse_url($url, PHP_URL_HOST)]) : false;
} | php | public function favicon($url)
{
return $url ? $this->router->generate('media_favicon', ['host' => parse_url($url, PHP_URL_HOST)]) : false;
} | [
"public",
"function",
"favicon",
"(",
"$",
"url",
")",
"{",
"return",
"$",
"url",
"?",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'media_favicon'",
",",
"[",
"'host'",
"=>",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_HOST",
")",
"]",
")",
":",
"false",
";",
"}"
] | @param string $url
@return string|false | [
"@param",
"string",
"$url"
] | train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/TwigExtension.php#L69-L72 |
anime-db/app-bundle | src/Service/TwigExtension.php | TwigExtension.widgets | public function widgets($place, array $attributes = [], array $options = [])
{
$result = '';
foreach ($this->widgets->getWidgetsForPlace($place) as $controller) {
$result .= $this->handler->render(
new ControllerReference($controller, $attributes, []),
'hinclude',
$options
);
}
return $result;
} | php | public function widgets($place, array $attributes = [], array $options = [])
{
$result = '';
foreach ($this->widgets->getWidgetsForPlace($place) as $controller) {
$result .= $this->handler->render(
new ControllerReference($controller, $attributes, []),
'hinclude',
$options
);
}
return $result;
} | [
"public",
"function",
"widgets",
"(",
"$",
"place",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"widgets",
"->",
"getWidgetsForPlace",
"(",
"$",
"place",
")",
"as",
"$",
"controller",
")",
"{",
"$",
"result",
".=",
"$",
"this",
"->",
"handler",
"->",
"render",
"(",
"new",
"ControllerReference",
"(",
"$",
"controller",
",",
"$",
"attributes",
",",
"[",
"]",
")",
",",
"'hinclude'",
",",
"$",
"options",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | @param string $place
@param array $attributes
@param array $options
@return string | [
"@param",
"string",
"$place",
"@param",
"array",
"$attributes",
"@param",
"array",
"$options"
] | train | https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Service/TwigExtension.php#L81-L93 |
dms-org/package.blog | src/Domain/Entities/BlogArticleComment.php | BlogArticleComment.defineEntity | protected function defineEntity(ClassDefinition $class)
{
$class->property($this->article)->asObject(BlogArticle::class);
$class->property($this->authorName)->asString();
$class->property($this->authorEmail)->asObject(EmailAddress::class);
$class->property($this->content)->asString();
$class->property($this->postedAt)->asObject(DateTime::class);
$this->defineMetadata($class);
} | php | protected function defineEntity(ClassDefinition $class)
{
$class->property($this->article)->asObject(BlogArticle::class);
$class->property($this->authorName)->asString();
$class->property($this->authorEmail)->asObject(EmailAddress::class);
$class->property($this->content)->asString();
$class->property($this->postedAt)->asObject(DateTime::class);
$this->defineMetadata($class);
} | [
"protected",
"function",
"defineEntity",
"(",
"ClassDefinition",
"$",
"class",
")",
"{",
"$",
"class",
"->",
"property",
"(",
"$",
"this",
"->",
"article",
")",
"->",
"asObject",
"(",
"BlogArticle",
"::",
"class",
")",
";",
"$",
"class",
"->",
"property",
"(",
"$",
"this",
"->",
"authorName",
")",
"->",
"asString",
"(",
")",
";",
"$",
"class",
"->",
"property",
"(",
"$",
"this",
"->",
"authorEmail",
")",
"->",
"asObject",
"(",
"EmailAddress",
"::",
"class",
")",
";",
"$",
"class",
"->",
"property",
"(",
"$",
"this",
"->",
"content",
")",
"->",
"asString",
"(",
")",
";",
"$",
"class",
"->",
"property",
"(",
"$",
"this",
"->",
"postedAt",
")",
"->",
"asObject",
"(",
"DateTime",
"::",
"class",
")",
";",
"$",
"this",
"->",
"defineMetadata",
"(",
"$",
"class",
")",
";",
"}"
] | Defines the structure of this entity.
@param ClassDefinition $class | [
"Defines",
"the",
"structure",
"of",
"this",
"entity",
"."
] | train | https://github.com/dms-org/package.blog/blob/1500f6fad20d81289a0dfa617fc1c54699f01e16/src/Domain/Entities/BlogArticleComment.php#L80-L93 |
yuncms/framework | src/web/XmlParser.php | XmlParser.parse | public function parse($rawBody, $contentType)
{
try {
$parameters = simplexml_load_string($rawBody, 'SimpleXMLElement', LIBXML_NOCDATA);
$parameters = $this->asArray ? (array)$parameters : $parameters;
return $parameters === null ? [] : $parameters;
} catch (InvalidArgumentException $e) {
if ($this->throwException) {
throw new BadRequestHttpException('Invalid XML data in request body: ' . $e->getMessage());
}
return [];
}
} | php | public function parse($rawBody, $contentType)
{
try {
$parameters = simplexml_load_string($rawBody, 'SimpleXMLElement', LIBXML_NOCDATA);
$parameters = $this->asArray ? (array)$parameters : $parameters;
return $parameters === null ? [] : $parameters;
} catch (InvalidArgumentException $e) {
if ($this->throwException) {
throw new BadRequestHttpException('Invalid XML data in request body: ' . $e->getMessage());
}
return [];
}
} | [
"public",
"function",
"parse",
"(",
"$",
"rawBody",
",",
"$",
"contentType",
")",
"{",
"try",
"{",
"$",
"parameters",
"=",
"simplexml_load_string",
"(",
"$",
"rawBody",
",",
"'SimpleXMLElement'",
",",
"LIBXML_NOCDATA",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"asArray",
"?",
"(",
"array",
")",
"$",
"parameters",
":",
"$",
"parameters",
";",
"return",
"$",
"parameters",
"===",
"null",
"?",
"[",
"]",
":",
"$",
"parameters",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"throwException",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
"'Invalid XML data in request body: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"[",
"]",
";",
"}",
"}"
] | Parses a HTTP request body.
@param string $rawBody the raw HTTP request body.
@param string $contentType the content type specified for the request body.
@return array parameters parsed from the request body
@throws BadRequestHttpException if the body contains invalid json and [[throwException]] is `true`. | [
"Parses",
"a",
"HTTP",
"request",
"body",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/web/XmlParser.php#L48-L60 |
yuncms/framework | src/rest/controllers/NotificationController.php | NotificationController.actionIndex | public function actionIndex()
{
$user = $this->findModel(Yii::$app->user->id);
$query = $user->getNotifications()->orderBy(new Expression("IF(ISNULL(read_at),0,1) asc"))->addOrderBy(['created_at' => SORT_DESC]);
$requestParams = Yii::$app->getRequest()->getBodyParams();
if (empty($requestParams)) {
$requestParams = Yii::$app->getRequest()->getQueryParams();
}
$filter = null;
$dataFilter = Yii::createObject([
'class' => ActiveDataFilter::class,
'searchModel' => function () {
return (new DynamicModel(['verb' => null]))
->addRule('verb', 'string');
},
]);
if ($dataFilter->load($requestParams)) {
$filter = $dataFilter->build();
if ($filter === false) {
return $dataFilter;
}
}
if ($filter) {
$query->andWhere($filter);
}
return Yii::createObject([
'class' => ActiveDataProvider::class,
'query' => $query,
'pagination' => [
'params' => $requestParams
],
'sort' => [
'params' => $requestParams
],
]);
} | php | public function actionIndex()
{
$user = $this->findModel(Yii::$app->user->id);
$query = $user->getNotifications()->orderBy(new Expression("IF(ISNULL(read_at),0,1) asc"))->addOrderBy(['created_at' => SORT_DESC]);
$requestParams = Yii::$app->getRequest()->getBodyParams();
if (empty($requestParams)) {
$requestParams = Yii::$app->getRequest()->getQueryParams();
}
$filter = null;
$dataFilter = Yii::createObject([
'class' => ActiveDataFilter::class,
'searchModel' => function () {
return (new DynamicModel(['verb' => null]))
->addRule('verb', 'string');
},
]);
if ($dataFilter->load($requestParams)) {
$filter = $dataFilter->build();
if ($filter === false) {
return $dataFilter;
}
}
if ($filter) {
$query->andWhere($filter);
}
return Yii::createObject([
'class' => ActiveDataProvider::class,
'query' => $query,
'pagination' => [
'params' => $requestParams
],
'sort' => [
'params' => $requestParams
],
]);
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"findModel",
"(",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"id",
")",
";",
"$",
"query",
"=",
"$",
"user",
"->",
"getNotifications",
"(",
")",
"->",
"orderBy",
"(",
"new",
"Expression",
"(",
"\"IF(ISNULL(read_at),0,1) asc\"",
")",
")",
"->",
"addOrderBy",
"(",
"[",
"'created_at'",
"=>",
"SORT_DESC",
"]",
")",
";",
"$",
"requestParams",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getBodyParams",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"requestParams",
")",
")",
"{",
"$",
"requestParams",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
"->",
"getQueryParams",
"(",
")",
";",
"}",
"$",
"filter",
"=",
"null",
";",
"$",
"dataFilter",
"=",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"ActiveDataFilter",
"::",
"class",
",",
"'searchModel'",
"=>",
"function",
"(",
")",
"{",
"return",
"(",
"new",
"DynamicModel",
"(",
"[",
"'verb'",
"=>",
"null",
"]",
")",
")",
"->",
"addRule",
"(",
"'verb'",
",",
"'string'",
")",
";",
"}",
",",
"]",
")",
";",
"if",
"(",
"$",
"dataFilter",
"->",
"load",
"(",
"$",
"requestParams",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"dataFilter",
"->",
"build",
"(",
")",
";",
"if",
"(",
"$",
"filter",
"===",
"false",
")",
"{",
"return",
"$",
"dataFilter",
";",
"}",
"}",
"if",
"(",
"$",
"filter",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"$",
"filter",
")",
";",
"}",
"return",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"ActiveDataProvider",
"::",
"class",
",",
"'query'",
"=>",
"$",
"query",
",",
"'pagination'",
"=>",
"[",
"'params'",
"=>",
"$",
"requestParams",
"]",
",",
"'sort'",
"=>",
"[",
"'params'",
"=>",
"$",
"requestParams",
"]",
",",
"]",
")",
";",
"}"
] | 跟用户相关的通知列表
@return ActiveDataProvider|ActiveDataFilter
@throws NotFoundHttpException
@throws \yii\base\InvalidConfigException | [
"跟用户相关的通知列表"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/NotificationController.php#L62-L97 |
yuncms/framework | src/rest/controllers/NotificationController.php | NotificationController.actionView | public function actionView($id)
{
$user = $this->findModel(Yii::$app->user->id);
/** @var DatabaseNotification $notification */
if (($notification = $user->getNotifications()->andWhere(['id' => $id])->one()) != null) {
$notification->setRead();
return $notification;
} else {
throw new NotFoundHttpException("Notification not found: $id");
}
} | php | public function actionView($id)
{
$user = $this->findModel(Yii::$app->user->id);
/** @var DatabaseNotification $notification */
if (($notification = $user->getNotifications()->andWhere(['id' => $id])->one()) != null) {
$notification->setRead();
return $notification;
} else {
throw new NotFoundHttpException("Notification not found: $id");
}
} | [
"public",
"function",
"actionView",
"(",
"$",
"id",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"findModel",
"(",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"id",
")",
";",
"/** @var DatabaseNotification $notification */",
"if",
"(",
"(",
"$",
"notification",
"=",
"$",
"user",
"->",
"getNotifications",
"(",
")",
"->",
"andWhere",
"(",
"[",
"'id'",
"=>",
"$",
"id",
"]",
")",
"->",
"one",
"(",
")",
")",
"!=",
"null",
")",
"{",
"$",
"notification",
"->",
"setRead",
"(",
")",
";",
"return",
"$",
"notification",
";",
"}",
"else",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"\"Notification not found: $id\"",
")",
";",
"}",
"}"
] | 查看通知详情
@param string $id
@return DatabaseNotification
@throws NotFoundHttpException | [
"查看通知详情"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/NotificationController.php#L105-L115 |
yuncms/framework | src/rest/controllers/NotificationController.php | NotificationController.actionBatchMarkRead | public function actionBatchMarkRead()
{
if (($ids = Yii::$app->request->post('ids', null)) != null) {
foreach ($ids as $id) {
DatabaseNotification::updateAll(['read_at' => time()], ['id' => $id, 'notifiable_id' => Yii::$app->user->id, 'notifiable_class' => \yuncms\user\models\User::class]);
}
}
Yii::$app->getResponse()->setStatusCode(200);
} | php | public function actionBatchMarkRead()
{
if (($ids = Yii::$app->request->post('ids', null)) != null) {
foreach ($ids as $id) {
DatabaseNotification::updateAll(['read_at' => time()], ['id' => $id, 'notifiable_id' => Yii::$app->user->id, 'notifiable_class' => \yuncms\user\models\User::class]);
}
}
Yii::$app->getResponse()->setStatusCode(200);
} | [
"public",
"function",
"actionBatchMarkRead",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"ids",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
"'ids'",
",",
"null",
")",
")",
"!=",
"null",
")",
"{",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"id",
")",
"{",
"DatabaseNotification",
"::",
"updateAll",
"(",
"[",
"'read_at'",
"=>",
"time",
"(",
")",
"]",
",",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'notifiable_id'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"id",
",",
"'notifiable_class'",
"=>",
"\\",
"yuncms",
"\\",
"user",
"\\",
"models",
"\\",
"User",
"::",
"class",
"]",
")",
";",
"}",
"}",
"Yii",
"::",
"$",
"app",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"200",
")",
";",
"}"
] | 标记指定通知为已读 | [
"标记指定通知为已读"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/NotificationController.php#L120-L129 |
yuncms/framework | src/rest/controllers/NotificationController.php | NotificationController.actionMarkRead | public function actionMarkRead()
{
DatabaseNotification::updateAll(['read_at' => time()], ['notifiable_id' => Yii::$app->user->id, 'notifiable_class' => \yuncms\user\models\User::class]);
Yii::$app->getResponse()->setStatusCode(200);
} | php | public function actionMarkRead()
{
DatabaseNotification::updateAll(['read_at' => time()], ['notifiable_id' => Yii::$app->user->id, 'notifiable_class' => \yuncms\user\models\User::class]);
Yii::$app->getResponse()->setStatusCode(200);
} | [
"public",
"function",
"actionMarkRead",
"(",
")",
"{",
"DatabaseNotification",
"::",
"updateAll",
"(",
"[",
"'read_at'",
"=>",
"time",
"(",
")",
"]",
",",
"[",
"'notifiable_id'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"id",
",",
"'notifiable_class'",
"=>",
"\\",
"yuncms",
"\\",
"user",
"\\",
"models",
"\\",
"User",
"::",
"class",
"]",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"200",
")",
";",
"}"
] | 标记所有通知为已读 | [
"标记所有通知为已读"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/controllers/NotificationController.php#L134-L138 |
simple-php-mvc/simple-php-mvc | src/MVC/Server/Route.php | Route.getInstance | static function getInstance($methods, $patternUri, $action, $name = null)
{
if (!self::$instance) {
self::$instance = new self($methods, $patternUri, $action, $name);
}
return self::$instance;
} | php | static function getInstance($methods, $patternUri, $action, $name = null)
{
if (!self::$instance) {
self::$instance = new self($methods, $patternUri, $action, $name);
}
return self::$instance;
} | [
"static",
"function",
"getInstance",
"(",
"$",
"methods",
",",
"$",
"patternUri",
",",
"$",
"action",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"instance",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
"(",
"$",
"methods",
",",
"$",
"patternUri",
",",
"$",
"action",
",",
"$",
"name",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] | Get Route instance
@param string|array $methods
@param string $patternUri
@param string|\callable $action
@param string $name
@return Route | [
"Get",
"Route",
"instance"
] | train | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/Route.php#L88-L95 |
simple-php-mvc/simple-php-mvc | src/MVC/Server/Route.php | Route.setAction | public function setAction($action)
{
if (!is_string($action) && !is_callable($action)) {
throw new \LogicException(sprintf('Route action given "%s" is invalid. String or Callable expected.', gettype($action)));
}
$this->action = $action;
return $this;
} | php | public function setAction($action)
{
if (!is_string($action) && !is_callable($action)) {
throw new \LogicException(sprintf('Route action given "%s" is invalid. String or Callable expected.', gettype($action)));
}
$this->action = $action;
return $this;
} | [
"public",
"function",
"setAction",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"action",
")",
"&&",
"!",
"is_callable",
"(",
"$",
"action",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Route action given \"%s\" is invalid. String or Callable expected.'",
",",
"gettype",
"(",
"$",
"action",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"action",
"=",
"$",
"action",
";",
"return",
"$",
"this",
";",
"}"
] | Set action callback
@param string|\callable $action
@return Route
@throws \LogicException | [
"Set",
"action",
"callback"
] | train | https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Server/Route.php#L144-L152 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.