repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
joomlatools/joomlatools-console
src/Joomlatools/Console/Command/Site/Configure.php
Configure.getDefaultPort
protected function getDefaultPort() { $driver = $this->mysql->driver; $key = $driver . '.default_port'; $port = ini_get($key); if ($port) { return $port; } return ini_get('mysqli.default_port'); }
php
protected function getDefaultPort() { $driver = $this->mysql->driver; $key = $driver . '.default_port'; $port = ini_get($key); if ($port) { return $port; } return ini_get('mysqli.default_port'); }
[ "protected", "function", "getDefaultPort", "(", ")", "{", "$", "driver", "=", "$", "this", "->", "mysql", "->", "driver", ";", "$", "key", "=", "$", "driver", ".", "'.default_port'", ";", "$", "port", "=", "ini_get", "(", "$", "key", ")", ";", "if", ...
Get default port for MySQL @return string
[ "Get", "default", "port", "for", "MySQL" ]
2911032c1dba27dcedc0b802717fe9ade6301239
https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Command/Site/Configure.php#L284-L295
train
dmkit/phalcon-jwt-auth
src/Phalcon/Auth/Adapter.php
Adapter.decode
protected function decode($token, $key) { try { if($this->leeway) { JWT::$leeway = $this->leeway; } $payload = (array) JWT::decode($token, $key, [$this->algo]); return $payload; } catch(\Exception $e) { $this->appendMessage($e->getMessage()); return false; } }
php
protected function decode($token, $key) { try { if($this->leeway) { JWT::$leeway = $this->leeway; } $payload = (array) JWT::decode($token, $key, [$this->algo]); return $payload; } catch(\Exception $e) { $this->appendMessage($e->getMessage()); return false; } }
[ "protected", "function", "decode", "(", "$", "token", ",", "$", "key", ")", "{", "try", "{", "if", "(", "$", "this", "->", "leeway", ")", "{", "JWT", "::", "$", "leeway", "=", "$", "this", "->", "leeway", ";", "}", "$", "payload", "=", "(", "ar...
Decodes JWT. @param string $token @param string $key @return array
[ "Decodes", "JWT", "." ]
1f4db19a7da8924832e482e4cc37471c5e61b8c2
https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/Adapter.php#L67-L83
train
dmkit/phalcon-jwt-auth
src/Phalcon/Auth/Adapter.php
Adapter.encode
protected function encode($payload, $key) { if( isset($payload['exp']) ) { $payload['exp'] = time() + $this->minToSec($payload['exp']); } return JWT::encode($payload, $key, $this->algo); }
php
protected function encode($payload, $key) { if( isset($payload['exp']) ) { $payload['exp'] = time() + $this->minToSec($payload['exp']); } return JWT::encode($payload, $key, $this->algo); }
[ "protected", "function", "encode", "(", "$", "payload", ",", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "payload", "[", "'exp'", "]", ")", ")", "{", "$", "payload", "[", "'exp'", "]", "=", "time", "(", ")", "+", "$", "this", "->", "min...
Encodes array into JWT. @param array $payload @param string $key @return string
[ "Encodes", "array", "into", "JWT", "." ]
1f4db19a7da8924832e482e4cc37471c5e61b8c2
https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/Adapter.php#L93-L99
train
joomlatools/joomlatools-console
src/Joomlatools/Console/Command/Site/CheckIn.php
CheckIn._getTables
protected function _getTables() { $prefix = \JFactory::getApplication()->get('dbprefix'); $dbo = \JFactory::getDbo(); $tables = array(); foreach (\JFactory::getDbo()->getTableList() as $table) { // Only check in tables with a prefix if (stripos($table, $prefix) === 0) { $columns = $dbo->getTableColumns($table); // Make sure that the table has the check in columns if (!isset($columns[$this->_user_column]) || !isset($columns[$this->_date_column])) { continue; } // Check the column's types. if (stripos($columns[$this->_user_column], 'int') !== 0 || stripos($columns[$this->_date_column], 'date') !== 0) { continue; } $query = $dbo->getQuery(true) ->select('COUNT(*)') ->from($dbo->quoteName($table)) ->where(sprintf('%s > 0', $this->_user_column)); $dbo->setQuery($query); // Only include tables that need to be checked in if (!$dbo->execute() || !$dbo->loadResult()) { continue; } $tables[] = str_replace($prefix, '', $table); } } return $tables; }
php
protected function _getTables() { $prefix = \JFactory::getApplication()->get('dbprefix'); $dbo = \JFactory::getDbo(); $tables = array(); foreach (\JFactory::getDbo()->getTableList() as $table) { // Only check in tables with a prefix if (stripos($table, $prefix) === 0) { $columns = $dbo->getTableColumns($table); // Make sure that the table has the check in columns if (!isset($columns[$this->_user_column]) || !isset($columns[$this->_date_column])) { continue; } // Check the column's types. if (stripos($columns[$this->_user_column], 'int') !== 0 || stripos($columns[$this->_date_column], 'date') !== 0) { continue; } $query = $dbo->getQuery(true) ->select('COUNT(*)') ->from($dbo->quoteName($table)) ->where(sprintf('%s > 0', $this->_user_column)); $dbo->setQuery($query); // Only include tables that need to be checked in if (!$dbo->execute() || !$dbo->loadResult()) { continue; } $tables[] = str_replace($prefix, '', $table); } } return $tables; }
[ "protected", "function", "_getTables", "(", ")", "{", "$", "prefix", "=", "\\", "JFactory", "::", "getApplication", "(", ")", "->", "get", "(", "'dbprefix'", ")", ";", "$", "dbo", "=", "\\", "JFactory", "::", "getDbo", "(", ")", ";", "$", "tables", "...
Check in tables getter. Only tables that need to be checked in will be returned. @return array An array containing the name of the tables to check in.
[ "Check", "in", "tables", "getter", "." ]
2911032c1dba27dcedc0b802717fe9ade6301239
https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Command/Site/CheckIn.php#L104-L144
train
dmkit/phalcon-jwt-auth
src/Phalcon/Auth/TokenGetter/TokenGetter.php
TokenGetter.parse
public function parse() : string { foreach($this->getters as $getter) { $token = $getter->parse(); if($token) { return $token; } } return ''; }
php
public function parse() : string { foreach($this->getters as $getter) { $token = $getter->parse(); if($token) { return $token; } } return ''; }
[ "public", "function", "parse", "(", ")", ":", "string", "{", "foreach", "(", "$", "this", "->", "getters", "as", "$", "getter", ")", "{", "$", "token", "=", "$", "getter", "->", "parse", "(", ")", ";", "if", "(", "$", "token", ")", "{", "return",...
Calls the getters parser and returns the token @return string
[ "Calls", "the", "getters", "parser", "and", "returns", "the", "token" ]
1f4db19a7da8924832e482e4cc37471c5e61b8c2
https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/TokenGetter/TokenGetter.php#L30-L40
train
joomlatools/joomlatools-console
src/Joomlatools/Console/Command/Site/AbstractSite.php
AbstractSite._ask
protected function _ask(InputInterface $input, OutputInterface $output, $label, $default = '', $required = false, $hidden = false) { $helper = $this->getHelper('question'); $text = $label; if (is_array($default)) { $defaultValue = $default[0]; } else $defaultValue = $default; if (!empty($defaultValue)) { $text .= ' [default: <info>' . $defaultValue . '</info>]'; } $text .= ': '; if (is_array($default)) { $question = new Question\ChoiceQuestion($text, $default, 0); } else $question = new Question\Question($text, $default); if ($hidden === true) { $question->setHidden(true); } $answer = $helper->ask($input, $output, $question); if ($required && empty($answer)) { return $this->_ask($input, $output, $label, $default, $hidden); } return $answer; }
php
protected function _ask(InputInterface $input, OutputInterface $output, $label, $default = '', $required = false, $hidden = false) { $helper = $this->getHelper('question'); $text = $label; if (is_array($default)) { $defaultValue = $default[0]; } else $defaultValue = $default; if (!empty($defaultValue)) { $text .= ' [default: <info>' . $defaultValue . '</info>]'; } $text .= ': '; if (is_array($default)) { $question = new Question\ChoiceQuestion($text, $default, 0); } else $question = new Question\Question($text, $default); if ($hidden === true) { $question->setHidden(true); } $answer = $helper->ask($input, $output, $question); if ($required && empty($answer)) { return $this->_ask($input, $output, $label, $default, $hidden); } return $answer; }
[ "protected", "function", "_ask", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "$", "label", ",", "$", "default", "=", "''", ",", "$", "required", "=", "false", ",", "$", "hidden", "=", "false", ")", "{", "$", "helper...
Prompt user to fill in a value @param InputInterface $input @param OutputInterface $output @param $label string The description of the value @param $default string|array The default value. If array given, question will be multiple-choice and the first item will be default. Can also be empty. @param bool $required @param bool $hidden Hide user input (useful for passwords) @return string Answer
[ "Prompt", "user", "to", "fill", "in", "a", "value" ]
2911032c1dba27dcedc0b802717fe9ade6301239
https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Command/Site/AbstractSite.php#L76-L108
train
joomlatools/joomlatools-console
src/Joomlatools/Console/Joomla/Bootstrapper.php
Bootstrapper.getApplication
public static function getApplication($base, $client_id = self::ADMIN) { $_SERVER['SERVER_PORT'] = 80; if (!self::$_application) { self::bootstrap($base); $options = array( 'root_user' => 'root', 'client_id' => $client_id ); self::$_application = new Application($options); $credentials = array( 'name' => 'root', 'username' => 'root', 'groups' => array(8), 'email' => 'root@localhost.home' ); self::$_application->authenticate($credentials); // If there are no marks in JProfiler debug plugin performs a division by zero using count($marks) \JProfiler::getInstance('Application')->mark('Hello world'); } return self::$_application; }
php
public static function getApplication($base, $client_id = self::ADMIN) { $_SERVER['SERVER_PORT'] = 80; if (!self::$_application) { self::bootstrap($base); $options = array( 'root_user' => 'root', 'client_id' => $client_id ); self::$_application = new Application($options); $credentials = array( 'name' => 'root', 'username' => 'root', 'groups' => array(8), 'email' => 'root@localhost.home' ); self::$_application->authenticate($credentials); // If there are no marks in JProfiler debug plugin performs a division by zero using count($marks) \JProfiler::getInstance('Application')->mark('Hello world'); } return self::$_application; }
[ "public", "static", "function", "getApplication", "(", "$", "base", ",", "$", "client_id", "=", "self", "::", "ADMIN", ")", "{", "$", "_SERVER", "[", "'SERVER_PORT'", "]", "=", "80", ";", "if", "(", "!", "self", "::", "$", "_application", ")", "{", "...
Returns a Joomla application with a root user logged in @param string $base Base path for the Joomla installation @param int $client_id Application client id to spoof. Defaults to admin. @return Application
[ "Returns", "a", "Joomla", "application", "with", "a", "root", "user", "logged", "in" ]
2911032c1dba27dcedc0b802717fe9ade6301239
https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Bootstrapper.php#L26-L55
train
joomlatools/joomlatools-console
src/Joomlatools/Console/Joomla/Bootstrapper.php
Bootstrapper.bootstrap
public static function bootstrap($base) { if (!class_exists('\\JApplicationCli')) { $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['HTTP_USER_AGENT'] = 'joomlatools-console/' . \Joomlatools\Console\Application::VERSION; if (!defined('_JEXEC')) { define('_JEXEC', 1); } if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (Util::isPlatform($base)) { define('JPATH_WEB' , $base.'/web'); define('JPATH_ROOT' , $base); define('JPATH_BASE' , JPATH_ROOT . '/app/administrator'); define('JPATH_CACHE' , JPATH_ROOT . '/cache/site'); define('JPATH_THEMES', __DIR__.'/templates'); require_once JPATH_ROOT . '/app/defines.php'; require_once JPATH_ROOT . '/app/bootstrap.php'; } else { define('JPATH_BASE', realpath($base)); require_once JPATH_BASE . '/includes/defines.php'; require_once JPATH_BASE . '/includes/framework.php'; } } }
php
public static function bootstrap($base) { if (!class_exists('\\JApplicationCli')) { $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['HTTP_USER_AGENT'] = 'joomlatools-console/' . \Joomlatools\Console\Application::VERSION; if (!defined('_JEXEC')) { define('_JEXEC', 1); } if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); } if (Util::isPlatform($base)) { define('JPATH_WEB' , $base.'/web'); define('JPATH_ROOT' , $base); define('JPATH_BASE' , JPATH_ROOT . '/app/administrator'); define('JPATH_CACHE' , JPATH_ROOT . '/cache/site'); define('JPATH_THEMES', __DIR__.'/templates'); require_once JPATH_ROOT . '/app/defines.php'; require_once JPATH_ROOT . '/app/bootstrap.php'; } else { define('JPATH_BASE', realpath($base)); require_once JPATH_BASE . '/includes/defines.php'; require_once JPATH_BASE . '/includes/framework.php'; } } }
[ "public", "static", "function", "bootstrap", "(", "$", "base", ")", "{", "if", "(", "!", "class_exists", "(", "'\\\\JApplicationCli'", ")", ")", "{", "$", "_SERVER", "[", "'HTTP_HOST'", "]", "=", "'localhost'", ";", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", ...
Load the Joomla application files @param $base
[ "Load", "the", "Joomla", "application", "files" ]
2911032c1dba27dcedc0b802717fe9ade6301239
https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Bootstrapper.php#L62-L96
train
stevenmaguire/yelp-php
src/v2/Client.php
Client.createDefaultHttpClient
public function createDefaultHttpClient() { $stack = HandlerStack::create(); $middleware = new Oauth1([ 'consumer_key' => $this->consumerKey, 'consumer_secret' => $this->consumerSecret, 'token' => $this->token, 'token_secret' => $this->tokenSecret ]); $stack->push($middleware); return new HttpClient([ 'handler' => $stack ]); }
php
public function createDefaultHttpClient() { $stack = HandlerStack::create(); $middleware = new Oauth1([ 'consumer_key' => $this->consumerKey, 'consumer_secret' => $this->consumerSecret, 'token' => $this->token, 'token_secret' => $this->tokenSecret ]); $stack->push($middleware); return new HttpClient([ 'handler' => $stack ]); }
[ "public", "function", "createDefaultHttpClient", "(", ")", "{", "$", "stack", "=", "HandlerStack", "::", "create", "(", ")", ";", "$", "middleware", "=", "new", "Oauth1", "(", "[", "'consumer_key'", "=>", "$", "this", "->", "consumerKey", ",", "'consumer_sec...
Creates default http client with appropriate authorization configuration. @return HttpClient
[ "Creates", "default", "http", "client", "with", "appropriate", "authorization", "configuration", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/v2/Client.php#L98-L114
train
stevenmaguire/yelp-php
src/v3/Client.php
Client.getAutocompleteResults
public function getAutocompleteResults($parameters = []) { $path = $this->appendParametersToUrl('/v3/autocomplete', $parameters); $request = $this->getRequest('GET', $path, $this->getDefaultHeaders()); return $this->processRequest($request); }
php
public function getAutocompleteResults($parameters = []) { $path = $this->appendParametersToUrl('/v3/autocomplete', $parameters); $request = $this->getRequest('GET', $path, $this->getDefaultHeaders()); return $this->processRequest($request); }
[ "public", "function", "getAutocompleteResults", "(", "$", "parameters", "=", "[", "]", ")", "{", "$", "path", "=", "$", "this", "->", "appendParametersToUrl", "(", "'/v3/autocomplete'", ",", "$", "parameters", ")", ";", "$", "request", "=", "$", "this", "-...
Fetches results from the Autocomplete API. @param array $parameters @return stdClass @throws Stevenmaguire\Yelp\Exception\HttpException @link https://www.yelp.com/developers/documentation/v3/autocomplete
[ "Fetches", "results", "from", "the", "Autocomplete", "API", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/v3/Client.php#L78-L84
train
stevenmaguire/yelp-php
src/v3/Client.php
Client.getBusiness
public function getBusiness($businessId, $parameters = []) { $path = $this->appendParametersToUrl('/v3/businesses/'.$businessId, $parameters); $request = $this->getRequest('GET', $path, $this->getDefaultHeaders()); return $this->processRequest($request); }
php
public function getBusiness($businessId, $parameters = []) { $path = $this->appendParametersToUrl('/v3/businesses/'.$businessId, $parameters); $request = $this->getRequest('GET', $path, $this->getDefaultHeaders()); return $this->processRequest($request); }
[ "public", "function", "getBusiness", "(", "$", "businessId", ",", "$", "parameters", "=", "[", "]", ")", "{", "$", "path", "=", "$", "this", "->", "appendParametersToUrl", "(", "'/v3/businesses/'", ".", "$", "businessId", ",", "$", "parameters", ")", ";", ...
Fetches a specific business by id. @param string $businessId @param array $parameters @return stdClass @throws Stevenmaguire\Yelp\Exception\HttpException @link https://www.yelp.com/developers/documentation/v3/business
[ "Fetches", "a", "specific", "business", "by", "id", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/v3/Client.php#L111-L117
train
stevenmaguire/yelp-php
src/v3/Client.php
Client.getTransactionsSearchResultsByType
public function getTransactionsSearchResultsByType($type, $parameters = []) { $path = $this->appendParametersToUrl('/v3/transactions/'.$type.'/search', $parameters); $request = $this->getRequest('GET', $path, $this->getDefaultHeaders()); return $this->processRequest($request); }
php
public function getTransactionsSearchResultsByType($type, $parameters = []) { $path = $this->appendParametersToUrl('/v3/transactions/'.$type.'/search', $parameters); $request = $this->getRequest('GET', $path, $this->getDefaultHeaders()); return $this->processRequest($request); }
[ "public", "function", "getTransactionsSearchResultsByType", "(", "$", "type", ",", "$", "parameters", "=", "[", "]", ")", "{", "$", "path", "=", "$", "this", "->", "appendParametersToUrl", "(", "'/v3/transactions/'", ".", "$", "type", ".", "'/search'", ",", ...
Fetches results from the Business Search API by Type. @param string $type @param array $parameters @return stdClass @throws Stevenmaguire\Yelp\Exception\HttpException @link https://www.yelp.com/developers/documentation/v3/transactions_search
[ "Fetches", "results", "from", "the", "Business", "Search", "API", "by", "Type", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/v3/Client.php#L213-L219
train
stevenmaguire/yelp-php
src/v3/Client.php
Client.handleResponse
protected function handleResponse(ResponseInterface $response) { $this->rateLimit = new RateLimit; $this->rateLimit->dailyLimit = (integer) $response->getHeaderLine('RateLimit-DailyLimit'); $this->rateLimit->remaining = (integer) $response->getHeaderLine('RateLimit-Remaining'); $this->rateLimit->resetTime = $response->getHeaderLine('RateLimit-ResetTime'); return $response; }
php
protected function handleResponse(ResponseInterface $response) { $this->rateLimit = new RateLimit; $this->rateLimit->dailyLimit = (integer) $response->getHeaderLine('RateLimit-DailyLimit'); $this->rateLimit->remaining = (integer) $response->getHeaderLine('RateLimit-Remaining'); $this->rateLimit->resetTime = $response->getHeaderLine('RateLimit-ResetTime'); return $response; }
[ "protected", "function", "handleResponse", "(", "ResponseInterface", "$", "response", ")", "{", "$", "this", "->", "rateLimit", "=", "new", "RateLimit", ";", "$", "this", "->", "rateLimit", "->", "dailyLimit", "=", "(", "integer", ")", "$", "response", "->",...
Provides a hook that handles the response before returning to the consumer. @param ResponseInterface $response @return ResponseInterface
[ "Provides", "a", "hook", "that", "handles", "the", "response", "before", "returning", "to", "the", "consumer", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/v3/Client.php#L228-L236
train
stevenmaguire/yelp-php
src/Tool/HttpTrait.php
HttpTrait.appendParametersToUrl
protected function appendParametersToUrl($url, array $parameters = array(), array $options = array()) { $url = rtrim($url, '?'); $queryString = $this->prepareQueryParams($parameters, $options); if ($queryString) { $uri = new Uri($url); $existingQuery = $uri->getQuery(); $updatedQuery = empty($existingQuery) ? $queryString : $existingQuery . '&' . $queryString; $url = (string) $uri->withQuery($updatedQuery); } return $url; }
php
protected function appendParametersToUrl($url, array $parameters = array(), array $options = array()) { $url = rtrim($url, '?'); $queryString = $this->prepareQueryParams($parameters, $options); if ($queryString) { $uri = new Uri($url); $existingQuery = $uri->getQuery(); $updatedQuery = empty($existingQuery) ? $queryString : $existingQuery . '&' . $queryString; $url = (string) $uri->withQuery($updatedQuery); } return $url; }
[ "protected", "function", "appendParametersToUrl", "(", "$", "url", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "url", "=", "rtrim", "(", "$", "url", ",", "'?'", ")", ...
Prepares and appends parameters, if provided, to the given url. @param string $url @param array $parameters @param string[] $options @return string
[ "Prepares", "and", "appends", "parameters", "if", "provided", "to", "the", "given", "url", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/Tool/HttpTrait.php#L47-L60
train
stevenmaguire/yelp-php
src/Tool/HttpTrait.php
HttpTrait.prepareQueryParams
protected function prepareQueryParams($params = [], $csvParams = []) { array_walk($params, function ($value, $key) use (&$params, $csvParams) { if (is_bool($value)) { $params[$key] = $this->getBoolString($value); } if (in_array($key, $csvParams)) { $params[$key] = $this->arrayToCsv($value); } }); return http_build_query($params); }
php
protected function prepareQueryParams($params = [], $csvParams = []) { array_walk($params, function ($value, $key) use (&$params, $csvParams) { if (is_bool($value)) { $params[$key] = $this->getBoolString($value); } if (in_array($key, $csvParams)) { $params[$key] = $this->arrayToCsv($value); } }); return http_build_query($params); }
[ "protected", "function", "prepareQueryParams", "(", "$", "params", "=", "[", "]", ",", "$", "csvParams", "=", "[", "]", ")", "{", "array_walk", "(", "$", "params", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "par...
Updates query params array to apply yelp specific formatting rules. @param array $params @param string[] $csvParams @return string
[ "Updates", "query", "params", "array", "to", "apply", "yelp", "specific", "formatting", "rules", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/Tool/HttpTrait.php#L169-L182
train
stevenmaguire/yelp-php
src/Tool/HttpTrait.php
HttpTrait.processRequest
protected function processRequest(RequestInterface $request) { $response = $this->handleResponse($this->getResponse($request)); return json_decode($response->getBody()); }
php
protected function processRequest(RequestInterface $request) { $response = $this->handleResponse($this->getResponse($request)); return json_decode($response->getBody()); }
[ "protected", "function", "processRequest", "(", "RequestInterface", "$", "request", ")", "{", "$", "response", "=", "$", "this", "->", "handleResponse", "(", "$", "this", "->", "getResponse", "(", "$", "request", ")", ")", ";", "return", "json_decode", "(", ...
Makes a request to the Yelp API and returns the response @param RequestInterface $request @return stdClass The JSON response from the request @throws Stevenmaguire\Yelp\Exception\ClientConfigurationException @throws Stevenmaguire\Yelp\Exception\HttpException
[ "Makes", "a", "request", "to", "the", "Yelp", "API", "and", "returns", "the", "response" ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/Tool/HttpTrait.php#L193-L198
train
stevenmaguire/yelp-php
src/Tool/ConfigurationTrait.php
ConfigurationTrait.mapConfiguration
protected function mapConfiguration(array $configuration) { array_walk($configuration, function ($value, $key) use (&$configuration) { $newKey = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))); $configuration[$newKey] = $value; }); return $configuration; }
php
protected function mapConfiguration(array $configuration) { array_walk($configuration, function ($value, $key) use (&$configuration) { $newKey = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))); $configuration[$newKey] = $value; }); return $configuration; }
[ "protected", "function", "mapConfiguration", "(", "array", "$", "configuration", ")", "{", "array_walk", "(", "$", "configuration", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "configuration", ")", "{", "$", "newKey", ...
Maps legacy configuration keys to updated keys. @param array $configuration @return array
[ "Maps", "legacy", "configuration", "keys", "to", "updated", "keys", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/Tool/ConfigurationTrait.php#L30-L38
train
stevenmaguire/yelp-php
src/Tool/ConfigurationTrait.php
ConfigurationTrait.parseConfiguration
protected function parseConfiguration($configuration = [], $defaults = []) { $configuration = array_merge($defaults, $this->mapConfiguration($configuration)); array_walk($configuration, [$this, 'setConfig']); return $this; }
php
protected function parseConfiguration($configuration = [], $defaults = []) { $configuration = array_merge($defaults, $this->mapConfiguration($configuration)); array_walk($configuration, [$this, 'setConfig']); return $this; }
[ "protected", "function", "parseConfiguration", "(", "$", "configuration", "=", "[", "]", ",", "$", "defaults", "=", "[", "]", ")", "{", "$", "configuration", "=", "array_merge", "(", "$", "defaults", ",", "$", "this", "->", "mapConfiguration", "(", "$", ...
Parse configuration using defaults @param array $configuration @param array $defaults @return mixed
[ "Parse", "configuration", "using", "defaults" ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/Tool/ConfigurationTrait.php#L48-L55
train
stevenmaguire/yelp-php
src/Tool/ConfigurationTrait.php
ConfigurationTrait.setConfig
protected function setConfig($value, $key) { $setter = 'set' . ucfirst($key); if (method_exists($this, $setter)) { $this->$setter($value); } elseif (property_exists($this, $key)) { $this->$key = $value; } return $this; }
php
protected function setConfig($value, $key) { $setter = 'set' . ucfirst($key); if (method_exists($this, $setter)) { $this->$setter($value); } elseif (property_exists($this, $key)) { $this->$key = $value; } return $this; }
[ "protected", "function", "setConfig", "(", "$", "value", ",", "$", "key", ")", "{", "$", "setter", "=", "'set'", ".", "ucfirst", "(", "$", "key", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "setter", ")", ")", "{", "$", "thi...
Attempts to set a given value. @param mixed $value @param string $key @return mixed
[ "Attempts", "to", "set", "a", "given", "value", "." ]
b96edaf0b620bceb68f0c597933f815171023562
https://github.com/stevenmaguire/yelp-php/blob/b96edaf0b620bceb68f0c597933f815171023562/src/Tool/ConfigurationTrait.php#L65-L76
train
CasperLaiTW/laravel-fb-messenger
src/Collections/ButtonCollection.php
ButtonCollection.addPostBackButton
public function addPostBackButton($text, $payload = '') { $this->add(new Button(Button::TYPE_POSTBACK, $text, $payload)); return $this; }
php
public function addPostBackButton($text, $payload = '') { $this->add(new Button(Button::TYPE_POSTBACK, $text, $payload)); return $this; }
[ "public", "function", "addPostBackButton", "(", "$", "text", ",", "$", "payload", "=", "''", ")", "{", "$", "this", "->", "add", "(", "new", "Button", "(", "Button", "::", "TYPE_POSTBACK", ",", "$", "text", ",", "$", "payload", ")", ")", ";", "return...
Add postback button @param $text @param $payload @return ButtonCollection
[ "Add", "postback", "button" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Collections/ButtonCollection.php#L39-L44
train
CasperLaiTW/laravel-fb-messenger
src/Collections/ButtonCollection.php
ButtonCollection.addWebButton
public function addWebButton($text, $url) { $this->add(new Button(Button::TYPE_WEB, $text, $url)); return $this; }
php
public function addWebButton($text, $url) { $this->add(new Button(Button::TYPE_WEB, $text, $url)); return $this; }
[ "public", "function", "addWebButton", "(", "$", "text", ",", "$", "url", ")", "{", "$", "this", "->", "add", "(", "new", "Button", "(", "Button", "::", "TYPE_WEB", ",", "$", "text", ",", "$", "url", ")", ")", ";", "return", "$", "this", ";", "}" ...
Add web url button @param $text @param $url @return ButtonCollection
[ "Add", "web", "url", "button" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Collections/ButtonCollection.php#L54-L59
train
CasperLaiTW/laravel-fb-messenger
src/Collections/ButtonCollection.php
ButtonCollection.addAccountLinkButton
public function addAccountLinkButton($url) { $this->add(new Button(Button::TYPE_ACCOUNT_LINK, null, $url)); return $this; }
php
public function addAccountLinkButton($url) { $this->add(new Button(Button::TYPE_ACCOUNT_LINK, null, $url)); return $this; }
[ "public", "function", "addAccountLinkButton", "(", "$", "url", ")", "{", "$", "this", "->", "add", "(", "new", "Button", "(", "Button", "::", "TYPE_ACCOUNT_LINK", ",", "null", ",", "$", "url", ")", ")", ";", "return", "$", "this", ";", "}" ]
Add account link button @param $url @return $this
[ "Add", "account", "link", "button" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Collections/ButtonCollection.php#L68-L73
train
CasperLaiTW/laravel-fb-messenger
src/Collections/ButtonCollection.php
ButtonCollection.addCallButton
public function addCallButton($title, $phone) { $this->add(new Button(Button::TYPE_CALL, $title, $phone)); return $this; }
php
public function addCallButton($title, $phone) { $this->add(new Button(Button::TYPE_CALL, $title, $phone)); return $this; }
[ "public", "function", "addCallButton", "(", "$", "title", ",", "$", "phone", ")", "{", "$", "this", "->", "add", "(", "new", "Button", "(", "Button", "::", "TYPE_CALL", ",", "$", "title", ",", "$", "phone", ")", ")", ";", "return", "$", "this", ";"...
Add phone call button @param $title @param $phone @return $this @throws \Casperlaitw\LaravelFbMessenger\Exceptions\OnlyUseByItselfException
[ "Add", "phone", "call", "button" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Collections/ButtonCollection.php#L84-L89
train
CasperLaiTW/laravel-fb-messenger
src/Collections/ButtonCollection.php
ButtonCollection.addShareButton
public function addShareButton($shareContent = null) { $button = new Button(Button::TYPE_SHARE, ''); if ($shareContent) { $button->setExtra($shareContent); } $this->add($button); return $this; }
php
public function addShareButton($shareContent = null) { $button = new Button(Button::TYPE_SHARE, ''); if ($shareContent) { $button->setExtra($shareContent); } $this->add($button); return $this; }
[ "public", "function", "addShareButton", "(", "$", "shareContent", "=", "null", ")", "{", "$", "button", "=", "new", "Button", "(", "Button", "::", "TYPE_SHARE", ",", "''", ")", ";", "if", "(", "$", "shareContent", ")", "{", "$", "button", "->", "setExt...
Add share button @return $this
[ "Add", "share", "button" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Collections/ButtonCollection.php#L96-L105
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/BaseHandler.php
BaseHandler.createBot
public function createBot($token, $secret = null) { $this->bot = new Bot($token); $this->bot->setSecret($secret); return $this; }
php
public function createBot($token, $secret = null) { $this->bot = new Bot($token); $this->bot->setSecret($secret); return $this; }
[ "public", "function", "createBot", "(", "$", "token", ",", "$", "secret", "=", "null", ")", "{", "$", "this", "->", "bot", "=", "new", "Bot", "(", "$", "token", ")", ";", "$", "this", "->", "bot", "->", "setSecret", "(", "$", "secret", ")", ";", ...
Create bot to send API @param $token @param $secret @return $this
[ "Create", "bot", "to", "send", "API" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/BaseHandler.php#L33-L39
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/BaseHandler.php
BaseHandler.send
public function send(Message $message) { if ($this->bot === null) { throw new NotCreateBotException; } $arguments = [$message]; if (in_array(RequestType::class, class_uses($message))) { $arguments[] = $message->getCurlType(); } return call_user_func_array([$this->bot, 'send'], $arguments); }
php
public function send(Message $message) { if ($this->bot === null) { throw new NotCreateBotException; } $arguments = [$message]; if (in_array(RequestType::class, class_uses($message))) { $arguments[] = $message->getCurlType(); } return call_user_func_array([$this->bot, 'send'], $arguments); }
[ "public", "function", "send", "(", "Message", "$", "message", ")", "{", "if", "(", "$", "this", "->", "bot", "===", "null", ")", "{", "throw", "new", "NotCreateBotException", ";", "}", "$", "arguments", "=", "[", "$", "message", "]", ";", "if", "(", ...
Send message to api @param Message $message @return HandleMessageResponse|array @throws \Casperlaitw\LaravelFbMessenger\Exceptions\NotCreateBotException
[ "Send", "message", "to", "api" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/BaseHandler.php#L60-L71
train
CasperLaiTW/laravel-fb-messenger
src/Collections/BaseCollection.php
BaseCollection.toData
public function toData() { $data = []; foreach ($this->elements as $element) { $data[] = $element->toData(); } return $data; }
php
public function toData() { $data = []; foreach ($this->elements as $element) { $data[] = $element->toData(); } return $data; }
[ "public", "function", "toData", "(", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "elements", "as", "$", "element", ")", "{", "$", "data", "[", "]", "=", "$", "element", "->", "toData", "(", ")", ";", "}", "retu...
Get all elements array data @return array
[ "Get", "all", "elements", "array", "data" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Collections/BaseCollection.php#L50-L58
train
mmoreram/GearmanBundle
Module/WorkerCollection.php
WorkerCollection.toArray
public function toArray() { $workersDumped = array(); foreach ($this->workerClasses as $worker) { $workersDumped[] = $worker->toArray(); } return $workersDumped; }
php
public function toArray() { $workersDumped = array(); foreach ($this->workerClasses as $worker) { $workersDumped[] = $worker->toArray(); } return $workersDumped; }
[ "public", "function", "toArray", "(", ")", "{", "$", "workersDumped", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "workerClasses", "as", "$", "worker", ")", "{", "$", "workersDumped", "[", "]", "=", "$", "worker", "->", "toArray", ...
Retrieve all workers loaded previously in cache format @return array
[ "Retrieve", "all", "workers", "loaded", "previously", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/WorkerCollection.php#L52-L61
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/HandleMessageResponse.php
HandleMessageResponse.getResponse
public function getResponse() { if (!empty($this->response['error'])) { return $this->handleError($this->response['error']); } return array_get($this->response, 'result', $this->response); }
php
public function getResponse() { if (!empty($this->response['error'])) { return $this->handleError($this->response['error']); } return array_get($this->response, 'result', $this->response); }
[ "public", "function", "getResponse", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "response", "[", "'error'", "]", ")", ")", "{", "return", "$", "this", "->", "handleError", "(", "$", "this", "->", "response", "[", "'error'", "]", ...
Get API response message @return string
[ "Get", "API", "response", "message" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/HandleMessageResponse.php#L35-L41
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/Debug/Debug.php
Debug.clear
public function clear() { $this->webhook = $this->request = $this->response = $this->status = $this->id = null; }
php
public function clear() { $this->webhook = $this->request = $this->response = $this->status = $this->id = null; }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "webhook", "=", "$", "this", "->", "request", "=", "$", "this", "->", "response", "=", "$", "this", "->", "status", "=", "$", "this", "->", "id", "=", "null", ";", "}" ]
Clear all.
[ "Clear", "all", "." ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Debug/Debug.php#L155-L158
train
CasperLaiTW/laravel-fb-messenger
src/Events/Broadcast.php
Broadcast.broadcastWith
public function broadcastWith() { return [ 'id' => $this->id, 'webhook' => $this->webhook, 'request' => $this->request, 'response' => $this->response, 'status' => $this->status, ]; }
php
public function broadcastWith() { return [ 'id' => $this->id, 'webhook' => $this->webhook, 'request' => $this->request, 'response' => $this->response, 'status' => $this->status, ]; }
[ "public", "function", "broadcastWith", "(", ")", "{", "return", "[", "'id'", "=>", "$", "this", "->", "id", ",", "'webhook'", "=>", "$", "this", "->", "webhook", ",", "'request'", "=>", "$", "this", "->", "request", ",", "'response'", "=>", "$", "this"...
Get the data to broadcast. @return array
[ "Get", "the", "data", "to", "broadcast", "." ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Events/Broadcast.php#L62-L71
train
CasperLaiTW/laravel-fb-messenger
src/Messages/Receiver.php
Receiver.boot
private function boot() { $messages = []; foreach ($this->messaging as $message) { $receiveMessage = new ReceiveMessage(Arr::get($message, 'recipient.id'), Arr::get($message, 'sender.id')); // is payload if (Arr::has($message, 'postback.payload') || Arr::has($message, 'message.quick_reply.payload')) { $receiveMessage ->setMessage(Arr::get($message, 'message.text')) ->setReferral(Arr::get($message, 'postback.referral', [])) ->setPostback(Arr::get( $message, 'postback.payload', Arr::get( $message, 'message.quick_reply.payload' ) )) ->setPayload(true); } else { $receiveMessage ->setMessage(Arr::get($message, 'message.text')) ->setReferral(Arr::get($message, 'referral', [])) ->setSkip( Arr::has($message, 'delivery') || Arr::has($message, 'message.is_echo') || (!Arr::has($message, 'message.text') && !Arr::has($message, 'message.attachments') && !Arr::has($message, 'referral')) ) ->setAttachments(Arr::get($message, 'message.attachments', [])) ->setNlp(Arr::get($message, 'message.nlp', [])); } $messages[] = $receiveMessage; } $this->collection = new ReceiveMessageCollection($messages); if ($this->filterSkip) { $this->collection = $this->collection->filterSkip(); } }
php
private function boot() { $messages = []; foreach ($this->messaging as $message) { $receiveMessage = new ReceiveMessage(Arr::get($message, 'recipient.id'), Arr::get($message, 'sender.id')); // is payload if (Arr::has($message, 'postback.payload') || Arr::has($message, 'message.quick_reply.payload')) { $receiveMessage ->setMessage(Arr::get($message, 'message.text')) ->setReferral(Arr::get($message, 'postback.referral', [])) ->setPostback(Arr::get( $message, 'postback.payload', Arr::get( $message, 'message.quick_reply.payload' ) )) ->setPayload(true); } else { $receiveMessage ->setMessage(Arr::get($message, 'message.text')) ->setReferral(Arr::get($message, 'referral', [])) ->setSkip( Arr::has($message, 'delivery') || Arr::has($message, 'message.is_echo') || (!Arr::has($message, 'message.text') && !Arr::has($message, 'message.attachments') && !Arr::has($message, 'referral')) ) ->setAttachments(Arr::get($message, 'message.attachments', [])) ->setNlp(Arr::get($message, 'message.nlp', [])); } $messages[] = $receiveMessage; } $this->collection = new ReceiveMessageCollection($messages); if ($this->filterSkip) { $this->collection = $this->collection->filterSkip(); } }
[ "private", "function", "boot", "(", ")", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "messaging", "as", "$", "message", ")", "{", "$", "receiveMessage", "=", "new", "ReceiveMessage", "(", "Arr", "::", "get", "(", "$",...
Boot to reorganize messages
[ "Boot", "to", "reorganize", "messages" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Messages/Receiver.php#L51-L91
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignTaskCallbacks
public function assignTaskCallbacks(\GearmanClient $gearmanClient) { $gearmanClient->setCompleteCallback(array( $this, 'assignCompleteCallback' )); $gearmanClient->setFailCallback(array( $this, 'assignFailCallback' )); $gearmanClient->setDataCallback(array( $this, 'assignDataCallback' )); $gearmanClient->setCreatedCallback(array( $this, 'assignCreatedCallback' )); $gearmanClient->setExceptionCallback(array( $this, 'assignExceptionCallback' )); $gearmanClient->setStatusCallback(array( $this, 'assignStatusCallback' )); $gearmanClient->setWarningCallback(array( $this, 'assignWarningCallback' )); $gearmanClient->setWorkloadCallback(array( $this, 'assignWorkloadCallback' )); }
php
public function assignTaskCallbacks(\GearmanClient $gearmanClient) { $gearmanClient->setCompleteCallback(array( $this, 'assignCompleteCallback' )); $gearmanClient->setFailCallback(array( $this, 'assignFailCallback' )); $gearmanClient->setDataCallback(array( $this, 'assignDataCallback' )); $gearmanClient->setCreatedCallback(array( $this, 'assignCreatedCallback' )); $gearmanClient->setExceptionCallback(array( $this, 'assignExceptionCallback' )); $gearmanClient->setStatusCallback(array( $this, 'assignStatusCallback' )); $gearmanClient->setWarningCallback(array( $this, 'assignWarningCallback' )); $gearmanClient->setWorkloadCallback(array( $this, 'assignWorkloadCallback' )); }
[ "public", "function", "assignTaskCallbacks", "(", "\\", "GearmanClient", "$", "gearmanClient", ")", "{", "$", "gearmanClient", "->", "setCompleteCallback", "(", "array", "(", "$", "this", ",", "'assignCompleteCallback'", ")", ")", ";", "$", "gearmanClient", "->", ...
Assign all GearmanClient callbacks as Symfony2 events @param \GearmanClient $gearmanClient Gearman client @return GearmanCallbacksDispatcher self Object
[ "Assign", "all", "GearmanClient", "callbacks", "as", "Symfony2", "events" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L43-L84
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignCompleteCallback
public function assignCompleteCallback(GearmanTask $gearmanTask, $contextReference = null) { $event = new GearmanClientCallbackCompleteEvent($gearmanTask); if (!is_null($contextReference)) { $event->setContext($contextReference); } $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_COMPLETE, $event ); }
php
public function assignCompleteCallback(GearmanTask $gearmanTask, $contextReference = null) { $event = new GearmanClientCallbackCompleteEvent($gearmanTask); if (!is_null($contextReference)) { $event->setContext($contextReference); } $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_COMPLETE, $event ); }
[ "public", "function", "assignCompleteCallback", "(", "GearmanTask", "$", "gearmanTask", ",", "$", "contextReference", "=", "null", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackCompleteEvent", "(", "$", "gearmanTask", ")", ";", "if", "(", "!", "is_nu...
Assigns CompleteCallback into GearmanTask @param GearmanTask $gearmanTask Gearman Task @see http://www.php.net/manual/en/gearmanclient.setcompletecallback.php
[ "Assigns", "CompleteCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L93-L103
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignFailCallback
public function assignFailCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackFailEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_FAIL, $event ); }
php
public function assignFailCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackFailEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_FAIL, $event ); }
[ "public", "function", "assignFailCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackFailEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "GearmanEvents...
Assigns FailCallback into GearmanTask @param GearmanTask $gearmanTask Gearman Task @see http://www.php.net/manual/en/gearmanclient.setfailcallback.php
[ "Assigns", "FailCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L112-L119
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignDataCallback
public function assignDataCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackDataEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_DATA, $event ); }
php
public function assignDataCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackDataEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_DATA, $event ); }
[ "public", "function", "assignDataCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackDataEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "GearmanEvents...
Assigns DataCallback into GearmanTask @param GearmanTask $gearmanTask Gearman Task @see http://www.php.net/manual/en/gearmanclient.setdatacallback.php
[ "Assigns", "DataCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L128-L135
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignCreatedCallback
public function assignCreatedCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackCreatedEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_CREATED, $event ); }
php
public function assignCreatedCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackCreatedEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_CREATED, $event ); }
[ "public", "function", "assignCreatedCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackCreatedEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "Gearman...
Assigns CreatedCallback into GearmanTask @param GearmanTask $gearmanTask Gearman task @see http://www.php.net/manual/en/gearmanclient.setcreatedcallback.php
[ "Assigns", "CreatedCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L144-L151
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignExceptionCallback
public function assignExceptionCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackExceptionEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_EXCEPTION, $event ); }
php
public function assignExceptionCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackExceptionEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_EXCEPTION, $event ); }
[ "public", "function", "assignExceptionCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackExceptionEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "Gea...
Assigns ExceptionCallback into GearmanTask @see http://www.php.net/manual/en/gearmanclient.setexceptioncallback.php
[ "Assigns", "ExceptionCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L158-L165
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignStatusCallback
public function assignStatusCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackStatusEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_STATUS, $event ); }
php
public function assignStatusCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackStatusEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_STATUS, $event ); }
[ "public", "function", "assignStatusCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackStatusEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "GearmanEv...
Assigns StatusCallback into GearmanTask @param GearmanTask $gearmanTask Gearman Task @see http://www.php.net/manual/en/gearmanclient.setstatuscallback.php
[ "Assigns", "StatusCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L174-L181
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignWarningCallback
public function assignWarningCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackWarningEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_WARNING, $event ); }
php
public function assignWarningCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackWarningEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_WARNING, $event ); }
[ "public", "function", "assignWarningCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackWarningEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "Gearman...
Assigns WarningCallback into GearmanTask @param GearmanTask $gearmanTask Gearman Task @see http://www.php.net/manual/en/gearmanclient.setwarningcallback.php
[ "Assigns", "WarningCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L190-L197
train
mmoreram/GearmanBundle
Dispatcher/GearmanCallbacksDispatcher.php
GearmanCallbacksDispatcher.assignWorkloadCallback
public function assignWorkloadCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackWorkloadEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_WORKLOAD, $event ); }
php
public function assignWorkloadCallback(GearmanTask $gearmanTask) { $event = new GearmanClientCallbackWorkloadEvent($gearmanTask); $this->eventDispatcher->dispatch( GearmanEvents::GEARMAN_CLIENT_CALLBACK_WORKLOAD, $event ); }
[ "public", "function", "assignWorkloadCallback", "(", "GearmanTask", "$", "gearmanTask", ")", "{", "$", "event", "=", "new", "GearmanClientCallbackWorkloadEvent", "(", "$", "gearmanTask", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "Gearm...
Assigns WorkloadCallback into GearmanTask @param GearmanTask $gearmanTask Gearman Task @see http://www.php.net/manual/en/gearmanclient.setworkloadcallback.php
[ "Assigns", "WorkloadCallback", "into", "GearmanTask" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Dispatcher/GearmanCallbacksDispatcher.php#L206-L213
train
mmoreram/GearmanBundle
Service/GearmanDescriber.php
GearmanDescriber.describeJob
public function describeJob(OutputInterface $output, array $worker) { /** * Commandline */ $script = $this->kernel->getRootDir() . '/console gearman:job:execute'; /** * A job descriptions contains its worker description */ $this->describeWorker($output, $worker); $job = $worker['job']; $output->writeln('<info>@job\methodName : ' . $job['methodName'] . '</info>'); $output->writeln('<info>@job\callableName : ' . $job['realCallableName'] . '</info>'); if ($job['jobPrefix']) { $output->writeln('<info>@job\jobPrefix : ' . $job['jobPrefix'] . '</info>'); } /** * Also a complete and clean execution path is given , for supervisord */ $output->writeln('<info>@job\supervisord : </info><comment>/usr/bin/php ' . $script.' ' . $job['realCallableName'] . ' --no-interaction</comment>'); $output->writeln('<info>@job\iterations : ' . $job['iterations'] . '</info>'); $output->writeln('<info>@job\defaultMethod : ' . $job['defaultMethod'] . '</info>'); /** * Printed every server is defined for current job */ $output->writeln(''); $output->writeln('<info>@job\servers :</info>'); $output->writeln(''); foreach ($job['servers'] as $name => $server) { $output->writeln('<comment> ' . $name . ' - ' . $server['host'] . ':' . $server['port'] . '</comment>'); } /** * Description */ $output->writeln(''); $output->writeln('<info>@job\description :</info>'); $output->writeln(''); $output->writeln('<comment> #' . $job['description'] . '</comment>'); $output->writeln(''); }
php
public function describeJob(OutputInterface $output, array $worker) { /** * Commandline */ $script = $this->kernel->getRootDir() . '/console gearman:job:execute'; /** * A job descriptions contains its worker description */ $this->describeWorker($output, $worker); $job = $worker['job']; $output->writeln('<info>@job\methodName : ' . $job['methodName'] . '</info>'); $output->writeln('<info>@job\callableName : ' . $job['realCallableName'] . '</info>'); if ($job['jobPrefix']) { $output->writeln('<info>@job\jobPrefix : ' . $job['jobPrefix'] . '</info>'); } /** * Also a complete and clean execution path is given , for supervisord */ $output->writeln('<info>@job\supervisord : </info><comment>/usr/bin/php ' . $script.' ' . $job['realCallableName'] . ' --no-interaction</comment>'); $output->writeln('<info>@job\iterations : ' . $job['iterations'] . '</info>'); $output->writeln('<info>@job\defaultMethod : ' . $job['defaultMethod'] . '</info>'); /** * Printed every server is defined for current job */ $output->writeln(''); $output->writeln('<info>@job\servers :</info>'); $output->writeln(''); foreach ($job['servers'] as $name => $server) { $output->writeln('<comment> ' . $name . ' - ' . $server['host'] . ':' . $server['port'] . '</comment>'); } /** * Description */ $output->writeln(''); $output->writeln('<info>@job\description :</info>'); $output->writeln(''); $output->writeln('<comment> #' . $job['description'] . '</comment>'); $output->writeln(''); }
[ "public", "function", "describeJob", "(", "OutputInterface", "$", "output", ",", "array", "$", "worker", ")", "{", "/**\n * Commandline\n */", "$", "script", "=", "$", "this", "->", "kernel", "->", "getRootDir", "(", ")", ".", "'/console gearman:jo...
Describe Job. Given a output object and a Job, dscribe it. @param OutputInterface $output Output object @param array $worker Worker array with Job to describe
[ "Describe", "Job", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanDescriber.php#L51-L96
train
mmoreram/GearmanBundle
Service/GearmanDescriber.php
GearmanDescriber.describeWorker
public function describeWorker(OutputInterface $output, array $worker, $tinyJobDescription = false) { /** * Commandline */ $script = $this->kernel->getRootDir() . '/console gearman:worker:execute'; $output->writeln(''); $output->writeln('<info>@Worker\className : ' . $worker['className'] . '</info>'); $output->writeln('<info>@Worker\fileName : ' . $worker['fileName'] . '</info>'); $output->writeln('<info>@Worker\nameSpace : ' . $worker['namespace'] . '</info>'); $output->writeln('<info>@Worker\callableName: ' . $worker['callableName'] . '</info>'); /** * Also a complete and clean execution path is given , for supervisord */ $output->writeln('<info>@Worker\supervisord : </info><comment>/usr/bin/php ' . $script.' ' . $worker['callableName'] . ' --no-interaction</comment>'); /** * Service value is only explained if defined. Not mandatory */ if (null !== $worker['service']) { $output->writeln('<info>@Worker\service : ' . $worker['service'] . '</info>'); } $output->writeln('<info>@worker\iterations : ' . $worker['iterations'] . '</info>'); $output->writeln('<info>@Worker\#jobs : ' . count($worker['jobs']) . '</info>'); if ($tinyJobDescription) { $output->writeln('<info>@Worker\jobs</info>'); $output->writeln(''); foreach ($worker['jobs'] as $job) { if ($job['jobPrefix']) { $output->writeln('<comment> # ' . $job['realCallableNameNoPrefix'] . ' with jobPrefix: ' . $job['jobPrefix'] . '</comment>'); } else { $output->writeln('<comment> # ' . $job['realCallableNameNoPrefix'] . ' </comment>'); } } } /** * Printed every server is defined for current job */ $output->writeln(''); $output->writeln('<info>@worker\servers :</info>'); $output->writeln(''); foreach ($worker['servers'] as $name => $server) { $output->writeln('<comment> #' . $name . ' - ' . $server['host'] . ':' . $server['port'] . '</comment>'); } /** * Description */ $output->writeln(''); $output->writeln('<info>@Worker\description :</info>'); $output->writeln(''); $output->writeln('<comment> ' . $worker['description'] . '</comment>'); $output->writeln(''); }
php
public function describeWorker(OutputInterface $output, array $worker, $tinyJobDescription = false) { /** * Commandline */ $script = $this->kernel->getRootDir() . '/console gearman:worker:execute'; $output->writeln(''); $output->writeln('<info>@Worker\className : ' . $worker['className'] . '</info>'); $output->writeln('<info>@Worker\fileName : ' . $worker['fileName'] . '</info>'); $output->writeln('<info>@Worker\nameSpace : ' . $worker['namespace'] . '</info>'); $output->writeln('<info>@Worker\callableName: ' . $worker['callableName'] . '</info>'); /** * Also a complete and clean execution path is given , for supervisord */ $output->writeln('<info>@Worker\supervisord : </info><comment>/usr/bin/php ' . $script.' ' . $worker['callableName'] . ' --no-interaction</comment>'); /** * Service value is only explained if defined. Not mandatory */ if (null !== $worker['service']) { $output->writeln('<info>@Worker\service : ' . $worker['service'] . '</info>'); } $output->writeln('<info>@worker\iterations : ' . $worker['iterations'] . '</info>'); $output->writeln('<info>@Worker\#jobs : ' . count($worker['jobs']) . '</info>'); if ($tinyJobDescription) { $output->writeln('<info>@Worker\jobs</info>'); $output->writeln(''); foreach ($worker['jobs'] as $job) { if ($job['jobPrefix']) { $output->writeln('<comment> # ' . $job['realCallableNameNoPrefix'] . ' with jobPrefix: ' . $job['jobPrefix'] . '</comment>'); } else { $output->writeln('<comment> # ' . $job['realCallableNameNoPrefix'] . ' </comment>'); } } } /** * Printed every server is defined for current job */ $output->writeln(''); $output->writeln('<info>@worker\servers :</info>'); $output->writeln(''); foreach ($worker['servers'] as $name => $server) { $output->writeln('<comment> #' . $name . ' - ' . $server['host'] . ':' . $server['port'] . '</comment>'); } /** * Description */ $output->writeln(''); $output->writeln('<info>@Worker\description :</info>'); $output->writeln(''); $output->writeln('<comment> ' . $worker['description'] . '</comment>'); $output->writeln(''); }
[ "public", "function", "describeWorker", "(", "OutputInterface", "$", "output", ",", "array", "$", "worker", ",", "$", "tinyJobDescription", "=", "false", ")", "{", "/**\n * Commandline\n */", "$", "script", "=", "$", "this", "->", "kernel", "->", ...
Describe Worker. Given a output object and a Worker, dscribe it. @param OutputInterface $output Output object @param array $worker Worker array with Job to describe @param Boolean $tinyJobDescription If true also print job list
[ "Describe", "Worker", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanDescriber.php#L107-L169
train
mmoreram/GearmanBundle
Service/GearmanExecute.php
GearmanExecute.executeJob
public function executeJob($jobName, array $options = array(), \GearmanWorker $gearmanWorker = null) { $worker = $this->getJob($jobName); if (false !== $worker) { $this->callJob($worker, $options, $gearmanWorker); } }
php
public function executeJob($jobName, array $options = array(), \GearmanWorker $gearmanWorker = null) { $worker = $this->getJob($jobName); if (false !== $worker) { $this->callJob($worker, $options, $gearmanWorker); } }
[ "public", "function", "executeJob", "(", "$", "jobName", ",", "array", "$", "options", "=", "array", "(", ")", ",", "\\", "GearmanWorker", "$", "gearmanWorker", "=", "null", ")", "{", "$", "worker", "=", "$", "this", "->", "getJob", "(", "$", "jobName"...
Executes a job given a jobName and given settings and annotations of job @param string $jobName Name of job to be executed @param array $options Array of options passed to the callback @param \GearmanWorker $gearmanWorker Worker instance to use
[ "Executes", "a", "job", "given", "a", "jobName", "and", "given", "settings", "and", "annotations", "of", "job" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanExecute.php#L169-L176
train
mmoreram/GearmanBundle
Service/GearmanExecute.php
GearmanExecute.callJob
private function callJob(Array $worker, array $options = array(), \GearmanWorker $gearmanWorker = null) { if(is_null($gearmanWorker)) { $gearmanWorker = new \GearmanWorker; } if (isset($worker['job'])) { $jobs = array($worker['job']); $iterations = $worker['job']['iterations']; $minimumExecutionTime = $worker['job']['minimumExecutionTime']; $timeout = $worker['job']['timeout']; $successes = $this->addServers($gearmanWorker, $worker['job']['servers']); } else { $jobs = $worker['jobs']; $iterations = $worker['iterations']; $minimumExecutionTime = $worker['minimumExecutionTime']; $timeout = $worker['timeout']; $successes = $this->addServers($gearmanWorker, $worker['servers']); } $options = $this->executeOptionsResolver->resolve($options); $iterations = $options['iterations'] ?: $iterations; $minimumExecutionTime = $options['minimum_execution_time'] ?: $minimumExecutionTime; $timeout = $options['timeout'] ?: $timeout; if (count($successes) < 1) { if ($minimumExecutionTime > 0) { sleep($minimumExecutionTime); } throw new ServerConnectionException('Worker was unable to connect to any server.'); } $objInstance = $this->createJob($worker); /** * Start the timer before running the worker. */ $time = time(); $this->runJob($gearmanWorker, $objInstance, $jobs, $iterations, $timeout); /** * If there is a minimum expected duration, wait out the remaining period if there is any. */ if ($minimumExecutionTime > 0) { $now = time(); $remaining = $minimumExecutionTime - ($now - $time); if ($remaining > 0) { sleep($remaining); } } return $this; }
php
private function callJob(Array $worker, array $options = array(), \GearmanWorker $gearmanWorker = null) { if(is_null($gearmanWorker)) { $gearmanWorker = new \GearmanWorker; } if (isset($worker['job'])) { $jobs = array($worker['job']); $iterations = $worker['job']['iterations']; $minimumExecutionTime = $worker['job']['minimumExecutionTime']; $timeout = $worker['job']['timeout']; $successes = $this->addServers($gearmanWorker, $worker['job']['servers']); } else { $jobs = $worker['jobs']; $iterations = $worker['iterations']; $minimumExecutionTime = $worker['minimumExecutionTime']; $timeout = $worker['timeout']; $successes = $this->addServers($gearmanWorker, $worker['servers']); } $options = $this->executeOptionsResolver->resolve($options); $iterations = $options['iterations'] ?: $iterations; $minimumExecutionTime = $options['minimum_execution_time'] ?: $minimumExecutionTime; $timeout = $options['timeout'] ?: $timeout; if (count($successes) < 1) { if ($minimumExecutionTime > 0) { sleep($minimumExecutionTime); } throw new ServerConnectionException('Worker was unable to connect to any server.'); } $objInstance = $this->createJob($worker); /** * Start the timer before running the worker. */ $time = time(); $this->runJob($gearmanWorker, $objInstance, $jobs, $iterations, $timeout); /** * If there is a minimum expected duration, wait out the remaining period if there is any. */ if ($minimumExecutionTime > 0) { $now = time(); $remaining = $minimumExecutionTime - ($now - $time); if ($remaining > 0) { sleep($remaining); } } return $this; }
[ "private", "function", "callJob", "(", "Array", "$", "worker", ",", "array", "$", "options", "=", "array", "(", ")", ",", "\\", "GearmanWorker", "$", "gearmanWorker", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "gearmanWorker", ")", ")", "{"...
Given a worker, execute GearmanWorker function defined by job. @param array $worker Worker definition @param array $options Array of options passed to the callback @param \GearmanWorker $gearmanWorker Worker instance to use @throws ServerConnectionException if a connection to a server was not possible. @return GearmanExecute self Object
[ "Given", "a", "worker", "execute", "GearmanWorker", "function", "defined", "by", "job", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanExecute.php#L189-L246
train
mmoreram/GearmanBundle
Service/GearmanExecute.php
GearmanExecute.createJob
private function createJob(array $worker) { /** * If service is defined, we must retrieve this class with dependency injection * * Otherwise we just create it with a simple new() */ if ($worker['service']) { $objInstance = $this->container->get($worker['service']); } else { $objInstance = new $worker['className']; /** * If instance of given object is instanceof * ContainerAwareInterface, we inject full container by calling * container setter. * * @see https://github.com/mmoreram/gearman-bundle/pull/12 */ if ($objInstance instanceof ContainerAwareInterface) { $objInstance->setContainer($this->container); } } return $objInstance; }
php
private function createJob(array $worker) { /** * If service is defined, we must retrieve this class with dependency injection * * Otherwise we just create it with a simple new() */ if ($worker['service']) { $objInstance = $this->container->get($worker['service']); } else { $objInstance = new $worker['className']; /** * If instance of given object is instanceof * ContainerAwareInterface, we inject full container by calling * container setter. * * @see https://github.com/mmoreram/gearman-bundle/pull/12 */ if ($objInstance instanceof ContainerAwareInterface) { $objInstance->setContainer($this->container); } } return $objInstance; }
[ "private", "function", "createJob", "(", "array", "$", "worker", ")", "{", "/**\n * If service is defined, we must retrieve this class with dependency injection\n *\n * Otherwise we just create it with a simple new()\n */", "if", "(", "$", "worker", "[", ...
Given a worker settings, return Job instance @param array $worker Worker settings @return Object Job instance
[ "Given", "a", "worker", "settings", "return", "Job", "instance" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanExecute.php#L255-L284
train
mmoreram/GearmanBundle
Service/GearmanExecute.php
GearmanExecute.runJob
private function runJob(\GearmanWorker $gearmanWorker, $objInstance, array $jobs, $iterations, $timeout = null) { /** * Set the output of this instance, this should allow workers to use the console output. */ if ($objInstance instanceof GearmanOutputAwareInterface) { $objInstance->setOutput($this->output ? : new NullOutput()); } /** * Every job defined in worker is added into GearmanWorker */ foreach ($jobs as $job) { /** * worker needs to have it's context into separated memory space; * if it's passed as a value, then garbage collector remove the target * what causes a segfault */ $this->workersBucket[$job['realCallableName']] = [ 'job_object_instance' => $objInstance, 'job_method' => $job['methodName'], 'jobs' => $jobs, ]; $gearmanWorker->addFunction( $job['realCallableName'], array($this, 'handleJob') ); } /** * If iterations value is 0, is like worker will never die */ $alive = (0 === $iterations); if ($timeout > 0) { $gearmanWorker->setTimeout($timeout * 1000); } /** * Executes GearmanWorker with all jobs defined */ while (false === $this->stopWorkSignalReceived && $gearmanWorker->work()) { $iterations--; $event = new GearmanWorkExecutedEvent($jobs, $iterations, $gearmanWorker->returnCode()); $this->eventDispatcher->dispatch(GearmanEvents::GEARMAN_WORK_EXECUTED, $event); if ($gearmanWorker->returnCode() != GEARMAN_SUCCESS) { break; } /** * Only finishes its execution if alive is false and iterations * arrives to 0 */ if (!$alive && $iterations <= 0) { break; } } }
php
private function runJob(\GearmanWorker $gearmanWorker, $objInstance, array $jobs, $iterations, $timeout = null) { /** * Set the output of this instance, this should allow workers to use the console output. */ if ($objInstance instanceof GearmanOutputAwareInterface) { $objInstance->setOutput($this->output ? : new NullOutput()); } /** * Every job defined in worker is added into GearmanWorker */ foreach ($jobs as $job) { /** * worker needs to have it's context into separated memory space; * if it's passed as a value, then garbage collector remove the target * what causes a segfault */ $this->workersBucket[$job['realCallableName']] = [ 'job_object_instance' => $objInstance, 'job_method' => $job['methodName'], 'jobs' => $jobs, ]; $gearmanWorker->addFunction( $job['realCallableName'], array($this, 'handleJob') ); } /** * If iterations value is 0, is like worker will never die */ $alive = (0 === $iterations); if ($timeout > 0) { $gearmanWorker->setTimeout($timeout * 1000); } /** * Executes GearmanWorker with all jobs defined */ while (false === $this->stopWorkSignalReceived && $gearmanWorker->work()) { $iterations--; $event = new GearmanWorkExecutedEvent($jobs, $iterations, $gearmanWorker->returnCode()); $this->eventDispatcher->dispatch(GearmanEvents::GEARMAN_WORK_EXECUTED, $event); if ($gearmanWorker->returnCode() != GEARMAN_SUCCESS) { break; } /** * Only finishes its execution if alive is false and iterations * arrives to 0 */ if (!$alive && $iterations <= 0) { break; } } }
[ "private", "function", "runJob", "(", "\\", "GearmanWorker", "$", "gearmanWorker", ",", "$", "objInstance", ",", "array", "$", "jobs", ",", "$", "iterations", ",", "$", "timeout", "=", "null", ")", "{", "/**\n * Set the output of this instance, this should a...
Given a GearmanWorker and an instance of Job, run it @param \GearmanWorker $gearmanWorker Gearman Worker @param Object $objInstance Job instance @param array $jobs Array of jobs to subscribe @param integer $iterations Number of iterations @param integer $timeout Timeout @return GearmanExecute self Object
[ "Given", "a", "GearmanWorker", "and", "an", "instance", "of", "Job", "run", "it" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanExecute.php#L297-L360
train
mmoreram/GearmanBundle
Service/GearmanExecute.php
GearmanExecute.addServers
private function addServers(\GearmanWorker $gmworker, array $servers) { $successes = array(); if (!empty($servers)) { foreach ($servers as $server) { if (@$gmworker->addServer($server['host'], $server['port'])) { $successes[] = $server; } } } else { if (@$gmworker->addServer()) { $successes[] = array('127.0.0.1', 4730); } } return $successes; }
php
private function addServers(\GearmanWorker $gmworker, array $servers) { $successes = array(); if (!empty($servers)) { foreach ($servers as $server) { if (@$gmworker->addServer($server['host'], $server['port'])) { $successes[] = $server; } } } else { if (@$gmworker->addServer()) { $successes[] = array('127.0.0.1', 4730); } } return $successes; }
[ "private", "function", "addServers", "(", "\\", "GearmanWorker", "$", "gmworker", ",", "array", "$", "servers", ")", "{", "$", "successes", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "servers", ")", ")", "{", "foreach", "(", "$",...
Adds into worker all defined Servers. If any is defined, performs default method @param \GearmanWorker $gmworker Worker to perform configuration @param array $servers Servers array @throws ServerConnectionException if a connection to a server was not possible. @return array Successfully added servers
[ "Adds", "into", "worker", "all", "defined", "Servers", ".", "If", "any", "is", "defined", "performs", "default", "method" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanExecute.php#L373-L391
train
mmoreram/GearmanBundle
Service/GearmanExecute.php
GearmanExecute.executeWorker
public function executeWorker($workerName, array $options = array()) { $worker = $this->getWorker($workerName); if (false !== $worker) { $this->callJob($worker, $options); } }
php
public function executeWorker($workerName, array $options = array()) { $worker = $this->getWorker($workerName); if (false !== $worker) { $this->callJob($worker, $options); } }
[ "public", "function", "executeWorker", "(", "$", "workerName", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "worker", "=", "$", "this", "->", "getWorker", "(", "$", "workerName", ")", ";", "if", "(", "false", "!==", "$", "work...
Executes a worker given a workerName subscribing all his jobs inside and given settings and annotations of worker and jobs @param string $workerName Name of worker to be executed
[ "Executes", "a", "worker", "given", "a", "workerName", "subscribing", "all", "his", "jobs", "inside", "and", "given", "settings", "and", "annotations", "of", "worker", "and", "jobs" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanExecute.php#L399-L407
train
CasperLaiTW/laravel-fb-messenger
src/Controllers/WebhookController.php
WebhookController.receive
public function receive(Request $request) { $receive = new Receiver($request); $webhook = new WebhookHandler($receive->getMessages(), $this->config, $this->debug); $webhook->handle(); }
php
public function receive(Request $request) { $receive = new Receiver($request); $webhook = new WebhookHandler($receive->getMessages(), $this->config, $this->debug); $webhook->handle(); }
[ "public", "function", "receive", "(", "Request", "$", "request", ")", "{", "$", "receive", "=", "new", "Receiver", "(", "$", "request", ")", ";", "$", "webhook", "=", "new", "WebhookHandler", "(", "$", "receive", "->", "getMessages", "(", ")", ",", "$"...
Receive the webhook request @param Request $request
[ "Receive", "the", "webhook", "request" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Controllers/WebhookController.php#L74-L79
train
mmoreram/GearmanBundle
GearmanBundle.php
GearmanBundle.boot
public function boot() { $kernel = $this->container->get('kernel'); AnnotationRegistry::registerFile($kernel ->locateResource("@GearmanBundle/Driver/Gearman/Work.php") ); AnnotationRegistry::registerFile($kernel ->locateResource("@GearmanBundle/Driver/Gearman/Job.php") ); }
php
public function boot() { $kernel = $this->container->get('kernel'); AnnotationRegistry::registerFile($kernel ->locateResource("@GearmanBundle/Driver/Gearman/Work.php") ); AnnotationRegistry::registerFile($kernel ->locateResource("@GearmanBundle/Driver/Gearman/Job.php") ); }
[ "public", "function", "boot", "(", ")", "{", "$", "kernel", "=", "$", "this", "->", "container", "->", "get", "(", "'kernel'", ")", ";", "AnnotationRegistry", "::", "registerFile", "(", "$", "kernel", "->", "locateResource", "(", "\"@GearmanBundle/Driver/Gearm...
Boots the Bundle.
[ "Boots", "the", "Bundle", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/GearmanBundle.php#L29-L40
train
CasperLaiTW/laravel-fb-messenger
src/Messages/Button.php
Button.makePayload
private function makePayload() { $payload = []; switch ($this->type) { case self::TYPE_POSTBACK: case self::TYPE_CALL: $payload = ['payload' => $this->payload]; break; case self::TYPE_WEB: $payload = ['url' => $this->payload]; break; default: throw new UnknownTypeException; } return array_merge($payload, $this->extra); }
php
private function makePayload() { $payload = []; switch ($this->type) { case self::TYPE_POSTBACK: case self::TYPE_CALL: $payload = ['payload' => $this->payload]; break; case self::TYPE_WEB: $payload = ['url' => $this->payload]; break; default: throw new UnknownTypeException; } return array_merge($payload, $this->extra); }
[ "private", "function", "makePayload", "(", ")", "{", "$", "payload", "=", "[", "]", ";", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "self", "::", "TYPE_POSTBACK", ":", "case", "self", "::", "TYPE_CALL", ":", "$", "payload", "=", "[",...
Make payload by type @return array @throws \Casperlaitw\LaravelFbMessenger\Exceptions\UnknownTypeException
[ "Make", "payload", "by", "type" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Messages/Button.php#L114-L130
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.enqueue
protected function enqueue($jobName, $params, $method, $unique) { $worker = $this->getJob($jobName); $unique = $this ->uniqueJobIdentifierGenerator ->generateUniqueKey($jobName, $params, $unique, $method); return $worker ? $this->doEnqueue($worker, $params, $method, $unique) : false; }
php
protected function enqueue($jobName, $params, $method, $unique) { $worker = $this->getJob($jobName); $unique = $this ->uniqueJobIdentifierGenerator ->generateUniqueKey($jobName, $params, $unique, $method); return $worker ? $this->doEnqueue($worker, $params, $method, $unique) : false; }
[ "protected", "function", "enqueue", "(", "$", "jobName", ",", "$", "params", ",", "$", "method", ",", "$", "unique", ")", "{", "$", "worker", "=", "$", "this", "->", "getJob", "(", "$", "jobName", ")", ";", "$", "unique", "=", "$", "this", "->", ...
Get real worker from job name and enqueues the action given one method. @param string $jobName A GearmanBundle registered function the worker is to execute @param string $params Parameters to send to job as string @param string $method Method to execute @param string $unique A unique ID used to identify a particular task @return mixed Return result of the call. If worker is not valid, return false
[ "Get", "real", "worker", "from", "job", "name", "and", "enqueues", "the", "action", "given", "one", "method", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L221-L232
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.doEnqueue
protected function doEnqueue(array $worker, $params, $method, $unique) { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); $result = $gearmanClient->$method($worker['job']['realCallableName'], $params, $unique); $this->returnCode = $gearmanClient->returnCode(); $this->gearmanClient = null; return $result; }
php
protected function doEnqueue(array $worker, $params, $method, $unique) { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); $result = $gearmanClient->$method($worker['job']['realCallableName'], $params, $unique); $this->returnCode = $gearmanClient->returnCode(); $this->gearmanClient = null; return $result; }
[ "protected", "function", "doEnqueue", "(", "array", "$", "worker", ",", "$", "params", ",", "$", "method", ",", "$", "unique", ")", "{", "$", "gearmanClient", "=", "$", "this", "->", "getNativeClient", "(", ")", ";", "$", "this", "->", "assignServers", ...
Execute a GearmanClient call given a worker, params and a method. If he GarmanClient call is asyncronous, result value will be a handler. Otherwise, will return job result. @param array $worker Worker definition @param string $params Parameters to send to job as string @param string $method Method to execute @param string $unique A unique ID used to identify a particular task @return mixed Return result of the GearmanClient call
[ "Execute", "a", "GearmanClient", "call", "given", "a", "worker", "params", "and", "a", "method", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L247-L258
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.assignServers
protected function assignServers(\GearmanClient $gearmanClient) { $servers = $this->defaultServers; if (!empty($this->servers)) { $servers = $this->servers; } /** * We include each server into gearman client */ foreach ($servers as $server) { $gearmanClient->addServer($server['host'], $server['port']); } return $this; }
php
protected function assignServers(\GearmanClient $gearmanClient) { $servers = $this->defaultServers; if (!empty($this->servers)) { $servers = $this->servers; } /** * We include each server into gearman client */ foreach ($servers as $server) { $gearmanClient->addServer($server['host'], $server['port']); } return $this; }
[ "protected", "function", "assignServers", "(", "\\", "GearmanClient", "$", "gearmanClient", ")", "{", "$", "servers", "=", "$", "this", "->", "defaultServers", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "servers", ")", ")", "{", "$", "servers"...
Given a GearmanClient, set all included servers @param \GearmanClient $gearmanClient Object to include servers @return GearmanClient Returns self object
[ "Given", "a", "GearmanClient", "set", "all", "included", "servers" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L267-L285
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.callJob
public function callJob($name, $params = '', $unique = null) { $worker = $this->getJob($name); $methodCallable = $worker['job']['defaultMethod']; return $this->enqueue($name, $params, $methodCallable, $unique); }
php
public function callJob($name, $params = '', $unique = null) { $worker = $this->getJob($name); $methodCallable = $worker['job']['defaultMethod']; return $this->enqueue($name, $params, $methodCallable, $unique); }
[ "public", "function", "callJob", "(", "$", "name", ",", "$", "params", "=", "''", ",", "$", "unique", "=", "null", ")", "{", "$", "worker", "=", "$", "this", "->", "getJob", "(", "$", "name", ")", ";", "$", "methodCallable", "=", "$", "worker", "...
Runs a single task and returns some result, depending of method called. Method called depends of default callable method setted on gearman settings or overwritted on work or job annotations @param string $name A GearmanBundle registered function the worker is to execute @param string $params Parameters to send to job as string @param string $unique A unique ID used to identify a particular task @return mixed result depending of method called.
[ "Runs", "a", "single", "task", "and", "returns", "some", "result", "depending", "of", "method", "called", ".", "Method", "called", "depends", "of", "default", "callable", "method", "setted", "on", "gearman", "settings", "or", "overwritted", "on", "work", "or",...
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L302-L308
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.doJob
public function doJob($name, $params = '', $unique = null) { return $this->enqueue($name, $params, GearmanMethods::GEARMAN_METHOD_DONORMAL, $unique); }
php
public function doJob($name, $params = '', $unique = null) { return $this->enqueue($name, $params, GearmanMethods::GEARMAN_METHOD_DONORMAL, $unique); }
[ "public", "function", "doJob", "(", "$", "name", ",", "$", "params", "=", "''", ",", "$", "unique", "=", "null", ")", "{", "return", "$", "this", "->", "enqueue", "(", "$", "name", ",", "$", "params", ",", "GearmanMethods", "::", "GEARMAN_METHOD_DONORM...
Runs a single task and returns a string representation of the result. It is up to the GearmanClient and GearmanWorker to agree on the format of the result. The GearmanClient::do() method is deprecated as of pecl/gearman 1.0.0. Use GearmanClient::doNormal(). @param string $name A GearmanBundle registered function the worker is to execute @param string $params Parameters to send to job as string @param string $unique A unique ID used to identify a particular task @return string A string representing the results of running a task. @deprecated
[ "Runs", "a", "single", "task", "and", "returns", "a", "string", "representation", "of", "the", "result", ".", "It", "is", "up", "to", "the", "GearmanClient", "and", "GearmanWorker", "to", "agree", "on", "the", "format", "of", "the", "result", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L325-L328
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.doHighBackgroundJob
public function doHighBackgroundJob($name, $params = '', $unique = null) { return $this->enqueue($name, $params, GearmanMethods::GEARMAN_METHOD_DOHIGHBACKGROUND, $unique); }
php
public function doHighBackgroundJob($name, $params = '', $unique = null) { return $this->enqueue($name, $params, GearmanMethods::GEARMAN_METHOD_DOHIGHBACKGROUND, $unique); }
[ "public", "function", "doHighBackgroundJob", "(", "$", "name", ",", "$", "params", "=", "''", ",", "$", "unique", "=", "null", ")", "{", "return", "$", "this", "->", "enqueue", "(", "$", "name", ",", "$", "params", ",", "GearmanMethods", "::", "GEARMAN...
Runs a high priority task in the background, returning a job handle which can be used to get the status of the running task. High priority tasks take precedence over normal and low priority tasks in the job queue. @param string $name A GearmanBundle registered function the worker is to execute @param string $params Parameters to send to job as string @param string $unique A unique ID used to identify a particular task @return string The job handle for the submitted task.
[ "Runs", "a", "high", "priority", "task", "in", "the", "background", "returning", "a", "job", "handle", "which", "can", "be", "used", "to", "get", "the", "status", "of", "the", "running", "task", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L395-L398
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.doLowBackgroundJob
public function doLowBackgroundJob($name, $params = '', $unique = null) { return $this->enqueue($name, $params, GearmanMethods::GEARMAN_METHOD_DOLOWBACKGROUND, $unique); }
php
public function doLowBackgroundJob($name, $params = '', $unique = null) { return $this->enqueue($name, $params, GearmanMethods::GEARMAN_METHOD_DOLOWBACKGROUND, $unique); }
[ "public", "function", "doLowBackgroundJob", "(", "$", "name", ",", "$", "params", "=", "''", ",", "$", "unique", "=", "null", ")", "{", "return", "$", "this", "->", "enqueue", "(", "$", "name", ",", "$", "params", ",", "GearmanMethods", "::", "GEARMAN_...
Runs a low priority task in the background, returning a job handle which can be used to get the status of the running task. Normal and high priority tasks will get precedence over low priority tasks in the job queue. @param string $name A GearmanBundle registered function the worker is to execute @param string $params Parameters to send to job as string @param string $unique A unique ID used to identify a particular task @return string The job handle for the submitted task.
[ "Runs", "a", "low", "priority", "task", "in", "the", "background", "returning", "a", "job", "handle", "which", "can", "be", "used", "to", "get", "the", "status", "of", "the", "running", "task", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L434-L437
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.getJobStatus
public function getJobStatus($idJob) { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); $statusData = $gearmanClient->jobStatus($idJob); $jobStatus = new JobStatus($statusData); $this->gearmanClient = null; return $jobStatus; }
php
public function getJobStatus($idJob) { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); $statusData = $gearmanClient->jobStatus($idJob); $jobStatus = new JobStatus($statusData); $this->gearmanClient = null; return $jobStatus; }
[ "public", "function", "getJobStatus", "(", "$", "idJob", ")", "{", "$", "gearmanClient", "=", "$", "this", "->", "getNativeClient", "(", ")", ";", "$", "this", "->", "assignServers", "(", "$", "gearmanClient", ")", ";", "$", "statusData", "=", "$", "gear...
Fetches the Status of a special Background Job. @param string $idJob The job handle string @return JobStatus Job status
[ "Fetches", "the", "Status", "of", "a", "special", "Background", "Job", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L446-L457
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.addTaskHighBackground
public function addTaskHighBackground($name, $params = '', &$context = null, $unique = null) { $this->enqueueTask($name, $params, $context, $unique, GearmanMethods::GEARMAN_METHOD_ADDTASKHIGHBACKGROUND); return $this; }
php
public function addTaskHighBackground($name, $params = '', &$context = null, $unique = null) { $this->enqueueTask($name, $params, $context, $unique, GearmanMethods::GEARMAN_METHOD_ADDTASKHIGHBACKGROUND); return $this; }
[ "public", "function", "addTaskHighBackground", "(", "$", "name", ",", "$", "params", "=", "''", ",", "&", "$", "context", "=", "null", ",", "$", "unique", "=", "null", ")", "{", "$", "this", "->", "enqueueTask", "(", "$", "name", ",", "$", "params", ...
Adds a high priority background task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks() to perform the work. Tasks with a high priority will be selected from the queue before those of normal or low priority. @param string $name A GermanBundle registered function to be executed @param string $params Parameters to send to task as string @param Mixed &$context Application context to associate with a task @param string $unique A unique ID used to identify a particular task @return GearmanClient Return this object
[ "Adds", "a", "high", "priority", "background", "task", "to", "be", "run", "in", "parallel", "with", "other", "tasks", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L577-L582
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.enqueueTask
protected function enqueueTask($name, $params, &$context, $unique, $method) { $contextReference = array('context' => &$context); $task = array( 'name' => $name, 'params' => $params, 'context' => $contextReference, 'unique' => $this->uniqueJobIdentifierGenerator->generateUniqueKey($name, $params, $unique, $method), 'method' => $method, ); $this->addTaskToStructure($task); return $this; }
php
protected function enqueueTask($name, $params, &$context, $unique, $method) { $contextReference = array('context' => &$context); $task = array( 'name' => $name, 'params' => $params, 'context' => $contextReference, 'unique' => $this->uniqueJobIdentifierGenerator->generateUniqueKey($name, $params, $unique, $method), 'method' => $method, ); $this->addTaskToStructure($task); return $this; }
[ "protected", "function", "enqueueTask", "(", "$", "name", ",", "$", "params", ",", "&", "$", "context", ",", "$", "unique", ",", "$", "method", ")", "{", "$", "contextReference", "=", "array", "(", "'context'", "=>", "&", "$", "context", ")", ";", "$...
Adds a task into the structure of tasks with included type of call @param string $name A GermanBundle registered function to be executed @param string $params Parameters to send to task as string @param Mixed $context Application context to associate with a task @param string $unique A unique ID used to identify a particular task @param string $method Method to perform @return GearmanClient Return this object
[ "Adds", "a", "task", "into", "the", "structure", "of", "tasks", "with", "included", "type", "of", "call" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L619-L633
train
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.runTasks
public function runTasks() { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); if ($this->settings['callbacks']) { $this->gearmanCallbacksDispatcher->assignTaskCallbacks($gearmanClient); } foreach ($this->taskStructure as $task) { $type = $task['method']; $jobName = $task['name']; $worker = $this->getJob($jobName); if (false !== $worker) { $gearmanClient->$type( $worker['job']['realCallableName'], $task['params'], $task['context'], $task['unique'] ); } } $this->initTaskStructure(); $this->gearmanClient = null; return $gearmanClient->runTasks(); }
php
public function runTasks() { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); if ($this->settings['callbacks']) { $this->gearmanCallbacksDispatcher->assignTaskCallbacks($gearmanClient); } foreach ($this->taskStructure as $task) { $type = $task['method']; $jobName = $task['name']; $worker = $this->getJob($jobName); if (false !== $worker) { $gearmanClient->$type( $worker['job']['realCallableName'], $task['params'], $task['context'], $task['unique'] ); } } $this->initTaskStructure(); $this->gearmanClient = null; return $gearmanClient->runTasks(); }
[ "public", "function", "runTasks", "(", ")", "{", "$", "gearmanClient", "=", "$", "this", "->", "getNativeClient", "(", ")", ";", "$", "this", "->", "assignServers", "(", "$", "gearmanClient", ")", ";", "if", "(", "$", "this", "->", "settings", "[", "'c...
For a set of tasks previously added with GearmanClient::addTask(), GearmanClient::addTaskHigh(), GearmanClient::addTaskLow(), GearmanClient::addTaskBackground(), GearmanClient::addTaskHighBackground(), GearmanClient::addTaskLowBackground(), this call starts running the tasks in parallel. Note that enough workers need to be available for the tasks to all run in parallel @return boolean run tasks result
[ "For", "a", "set", "of", "tasks", "previously", "added", "with" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L664-L696
train
mmoreram/GearmanBundle
Service/GearmanCacheWrapper.php
GearmanCacheWrapper.load
public function load(Cache $cache, $cacheId) { if ($cache->contains($cacheId)) { /** * Cache contains gearman structure */ $this->workerCollection = $cache->fetch($cacheId); } else { /** * Cache is empty. * * Full structure must be generated and cached */ $this->workerCollection = $this ->getGearmanParser() ->load() ->toArray(); $cache->save($cacheId, $this->workerCollection); } return $this; }
php
public function load(Cache $cache, $cacheId) { if ($cache->contains($cacheId)) { /** * Cache contains gearman structure */ $this->workerCollection = $cache->fetch($cacheId); } else { /** * Cache is empty. * * Full structure must be generated and cached */ $this->workerCollection = $this ->getGearmanParser() ->load() ->toArray(); $cache->save($cacheId, $this->workerCollection); } return $this; }
[ "public", "function", "load", "(", "Cache", "$", "cache", ",", "$", "cacheId", ")", "{", "if", "(", "$", "cache", "->", "contains", "(", "$", "cacheId", ")", ")", "{", "/**\n * Cache contains gearman structure\n */", "$", "this", "->", ...
loads Gearman cache, only if is not loaded yet @param Cache $cache Cache instance @param string $cacheId Cache id @return GearmanCacheWrapper self Object
[ "loads", "Gearman", "cache", "only", "if", "is", "not", "loaded", "yet" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanCacheWrapper.php#L126-L151
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/AutoTypingHandler.php
AutoTypingHandler.handle
public function handle(ReceiveMessage $message) { $typing = new Typing($message->getSender()); $this->send($typing); }
php
public function handle(ReceiveMessage $message) { $typing = new Typing($message->getSender()); $this->send($typing); }
[ "public", "function", "handle", "(", "ReceiveMessage", "$", "message", ")", "{", "$", "typing", "=", "new", "Typing", "(", "$", "message", "->", "getSender", "(", ")", ")", ";", "$", "this", "->", "send", "(", "$", "typing", ")", ";", "}" ]
Handle the chatbot message @param ReceiveMessage $message @return mixed @throws \Casperlaitw\LaravelFbMessenger\Exceptions\NotCreateBotException
[ "Handle", "the", "chatbot", "message" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/AutoTypingHandler.php#L27-L31
train
mmoreram/GearmanBundle
Module/WorkerClass.php
WorkerClass.createJobCollection
private function createJobCollection(ReflectionClass $reflectionClass, Reader $reader) { $jobCollection = new JobCollection; /** * For each defined method, we parse it */ foreach ($reflectionClass->getMethods() as $reflectionMethod) { $methodAnnotations = $reader->getMethodAnnotations($reflectionMethod); /** * Every annotation found is parsed */ foreach ($methodAnnotations as $methodAnnotation) { /** * Annotation is only loaded if is typeof JobAnnotation */ if ($methodAnnotation instanceof JobAnnotation) { /** * Creates new Job */ $job = new Job($methodAnnotation, $reflectionMethod, $this->callableName, $this->servers, array( 'jobPrefix' => $this->jobPrefix, 'iterations' => $this->iterations, 'method' => $this->defaultMethod, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, )); $jobCollection->add($job); } } } return $jobCollection; }
php
private function createJobCollection(ReflectionClass $reflectionClass, Reader $reader) { $jobCollection = new JobCollection; /** * For each defined method, we parse it */ foreach ($reflectionClass->getMethods() as $reflectionMethod) { $methodAnnotations = $reader->getMethodAnnotations($reflectionMethod); /** * Every annotation found is parsed */ foreach ($methodAnnotations as $methodAnnotation) { /** * Annotation is only loaded if is typeof JobAnnotation */ if ($methodAnnotation instanceof JobAnnotation) { /** * Creates new Job */ $job = new Job($methodAnnotation, $reflectionMethod, $this->callableName, $this->servers, array( 'jobPrefix' => $this->jobPrefix, 'iterations' => $this->iterations, 'method' => $this->defaultMethod, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, )); $jobCollection->add($job); } } } return $jobCollection; }
[ "private", "function", "createJobCollection", "(", "ReflectionClass", "$", "reflectionClass", ",", "Reader", "$", "reader", ")", "{", "$", "jobCollection", "=", "new", "JobCollection", ";", "/**\n * For each defined method, we parse it\n */", "foreach", "(",...
Creates job collection of worker @param ReflectionClass $reflectionClass Reflexion class @param Reader $reader ReaderAnnotation class @return WorkerClass self Object
[ "Creates", "job", "collection", "of", "worker" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/WorkerClass.php#L296-L333
train
mmoreram/GearmanBundle
Module/WorkerClass.php
WorkerClass.toArray
public function toArray() { return array( 'namespace' => $this->namespace, 'className' => $this->className, 'fileName' => $this->fileName, 'callableName' => $this->callableName, 'description' => $this->description, 'service' => $this->service, 'servers' => $this->servers, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'jobs' => $this->jobCollection->toArray(), ); }
php
public function toArray() { return array( 'namespace' => $this->namespace, 'className' => $this->className, 'fileName' => $this->fileName, 'callableName' => $this->callableName, 'description' => $this->description, 'service' => $this->service, 'servers' => $this->servers, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'jobs' => $this->jobCollection->toArray(), ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'namespace'", "=>", "$", "this", "->", "namespace", ",", "'className'", "=>", "$", "this", "->", "className", ",", "'fileName'", "=>", "$", "this", "->", "fileName", ",", "'callableNa...
Retrieve all Worker data in cache format @return array
[ "Retrieve", "all", "Worker", "data", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/WorkerClass.php#L340-L356
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/WebhookHandler.php
WebhookHandler.autoTypeHandle
private function autoTypeHandle($message) { $autoTyping = $this->config->get('fb-messenger.auto_typing'); if ($autoTyping) { $handler = $this->createBot($this->app->make(AutoTypingHandler::class)); $handler->handle($message); } }
php
private function autoTypeHandle($message) { $autoTyping = $this->config->get('fb-messenger.auto_typing'); if ($autoTyping) { $handler = $this->createBot($this->app->make(AutoTypingHandler::class)); $handler->handle($message); } }
[ "private", "function", "autoTypeHandle", "(", "$", "message", ")", "{", "$", "autoTyping", "=", "$", "this", "->", "config", "->", "get", "(", "'fb-messenger.auto_typing'", ")", ";", "if", "(", "$", "autoTyping", ")", "{", "$", "handler", "=", "$", "this...
Handle auto type
[ "Handle", "auto", "type" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/WebhookHandler.php#L118-L125
train
CasperLaiTW/laravel-fb-messenger
src/Messages/PersistentMenuMessage.php
PersistentMenuMessage.toData
public function toData() { if ($this->type === Bot::TYPE_DELETE) { return [ 'fields' => [ 'persistent_menu', ], ]; } if ($this->type === Bot::TYPE_GET) { return [ 'fields' => 'persistent_menu', ]; } return [ 'persistent_menu' => $this->menus, ]; }
php
public function toData() { if ($this->type === Bot::TYPE_DELETE) { return [ 'fields' => [ 'persistent_menu', ], ]; } if ($this->type === Bot::TYPE_GET) { return [ 'fields' => 'persistent_menu', ]; } return [ 'persistent_menu' => $this->menus, ]; }
[ "public", "function", "toData", "(", ")", "{", "if", "(", "$", "this", "->", "type", "===", "Bot", "::", "TYPE_DELETE", ")", "{", "return", "[", "'fields'", "=>", "[", "'persistent_menu'", ",", "]", ",", "]", ";", "}", "if", "(", "$", "this", "->",...
Message to send @return array
[ "Message", "to", "send" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Messages/PersistentMenuMessage.php#L43-L62
train
mmoreram/GearmanBundle
Module/JobCollection.php
JobCollection.toArray
public function toArray() { $jobs = array(); foreach ($this->workerJobs as $job) { $jobs[] = $job->toArray(); } return $jobs; }
php
public function toArray() { $jobs = array(); foreach ($this->workerJobs as $job) { $jobs[] = $job->toArray(); } return $jobs; }
[ "public", "function", "toArray", "(", ")", "{", "$", "jobs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "workerJobs", "as", "$", "job", ")", "{", "$", "jobs", "[", "]", "=", "$", "job", "->", "toArray", "(", ")", ";", "}", ...
Retrieve all jobs loaded previously in cache format @return array
[ "Retrieve", "all", "jobs", "loaded", "previously", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/JobCollection.php#L62-L72
train
CasperLaiTW/laravel-fb-messenger
src/Providers/RouteServiceProvider.php
RouteServiceProvider.boot
public function boot(Router $router) { if (!$this->app->routesAreCached()) { $router->group([ 'namespace' => $this->namespace, ], function (Router $router) { require __DIR__.'/../routes/web.php'; }); } }
php
public function boot(Router $router) { if (!$this->app->routesAreCached()) { $router->group([ 'namespace' => $this->namespace, ], function (Router $router) { require __DIR__.'/../routes/web.php'; }); } }
[ "public", "function", "boot", "(", "Router", "$", "router", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "$", "router", "->", "group", "(", "[", "'namespace'", "=>", "$", "this", "->", "namespace", ...
Register the webhook to router @param Router $router
[ "Register", "the", "webhook", "to", "router" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Providers/RouteServiceProvider.php#L29-L38
train
mmoreram/GearmanBundle
Module/JobStatus.php
JobStatus.getCompletionPercent
public function getCompletionPercent() { $percent = 0; if (($this->completed > 0) && ($this->completionTotal > 0)) { $percent = $this->completed / $this->completionTotal; } return $percent; }
php
public function getCompletionPercent() { $percent = 0; if (($this->completed > 0) && ($this->completionTotal > 0)) { $percent = $this->completed / $this->completionTotal; } return $percent; }
[ "public", "function", "getCompletionPercent", "(", ")", "{", "$", "percent", "=", "0", ";", "if", "(", "(", "$", "this", "->", "completed", ">", "0", ")", "&&", "(", "$", "this", "->", "completionTotal", ">", "0", ")", ")", "{", "$", "percent", "="...
Return percent completed. 0 is not started or not known 1 is finished Between 0 and 1 is in process. Value is a float @return float Percent completed
[ "Return", "percent", "completed", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/JobStatus.php#L119-L129
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/Bot.php
Bot.send
public function send($message, $type = self::TYPE_POST) { if ($message instanceof ProfileInterface) { return $this->sendProfile($message->toData(), $type); } if ($message instanceof UserInterface) { return $this->sendUserApi($message); } if ($message instanceof CodeInterface) { return $this->sendMessengerCode($message->toData()); } return $this->sendMessage($message->toData()); }
php
public function send($message, $type = self::TYPE_POST) { if ($message instanceof ProfileInterface) { return $this->sendProfile($message->toData(), $type); } if ($message instanceof UserInterface) { return $this->sendUserApi($message); } if ($message instanceof CodeInterface) { return $this->sendMessengerCode($message->toData()); } return $this->sendMessage($message->toData()); }
[ "public", "function", "send", "(", "$", "message", ",", "$", "type", "=", "self", "::", "TYPE_POST", ")", "{", "if", "(", "$", "message", "instanceof", "ProfileInterface", ")", "{", "return", "$", "this", "->", "sendProfile", "(", "$", "message", "->", ...
Send message to API If instance of ProfileInterface, auto turn to thread_settings endpoint @param Message $message @param string $type @return HandleMessageResponse|array @throws \RuntimeException
[ "Send", "message", "to", "API" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Bot.php#L155-L170
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/Bot.php
Bot.sendProfile
protected function sendProfile($message, $type = self::TYPE_POST) { return new HandleMessageResponse($this->call('me/messenger_profile', $message, $type)); }
php
protected function sendProfile($message, $type = self::TYPE_POST) { return new HandleMessageResponse($this->call('me/messenger_profile', $message, $type)); }
[ "protected", "function", "sendProfile", "(", "$", "message", ",", "$", "type", "=", "self", "::", "TYPE_POST", ")", "{", "return", "new", "HandleMessageResponse", "(", "$", "this", "->", "call", "(", "'me/messenger_profile'", ",", "$", "message", ",", "$", ...
Send messenger profile endpoint @param array $message @param string $type @return HandleMessageResponse @throws \RuntimeException
[ "Send", "messenger", "profile", "endpoint" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Bot.php#L191-L194
train
mmoreram/GearmanBundle
Generator/UniqueJobIdentifierGenerator.php
UniqueJobIdentifierGenerator.generateUniqueKey
public function generateUniqueKey($name, $params, $unique, $method) { $unique = !$unique && $this->generateUniqueKey ? md5($name . $params) : $unique; if (strlen($name . $unique) > 114) { throw new WorkerNameTooLongException; } return $unique; }
php
public function generateUniqueKey($name, $params, $unique, $method) { $unique = !$unique && $this->generateUniqueKey ? md5($name . $params) : $unique; if (strlen($name . $unique) > 114) { throw new WorkerNameTooLongException; } return $unique; }
[ "public", "function", "generateUniqueKey", "(", "$", "name", ",", "$", "params", ",", "$", "unique", ",", "$", "method", ")", "{", "$", "unique", "=", "!", "$", "unique", "&&", "$", "this", "->", "generateUniqueKey", "?", "md5", "(", "$", "name", "."...
Generate unique key if generateUniqueKey is enabled Even some parameters are not used, are passed to allow user overwrite method Also, if name and unique value exceeds 114 bytes, an exception is thrown @param string $name A GermanBundle registered function to be executed @param string $params Parameters to send to task as string @param string $unique unique ID used to identify a particular task @param string $method Method to perform @return string Generated Unique Key @throws WorkerNameTooLongException If name is too large @api
[ "Generate", "unique", "key", "if", "generateUniqueKey", "is", "enabled" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Generator/UniqueJobIdentifierGenerator.php#L63-L75
train
mmoreram/GearmanBundle
Module/JobClass.php
JobClass.toArray
public function toArray() { return array( 'callableName' => $this->callableName, 'methodName' => $this->methodName, 'realCallableName' => $this->realCallableName, 'jobPrefix' => $this->jobPrefix, 'realCallableNameNoPrefix' => $this->realCallableNameNoPrefix, 'description' => $this->description, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'servers' => $this->servers, 'defaultMethod' => $this->defaultMethod, ); }
php
public function toArray() { return array( 'callableName' => $this->callableName, 'methodName' => $this->methodName, 'realCallableName' => $this->realCallableName, 'jobPrefix' => $this->jobPrefix, 'realCallableNameNoPrefix' => $this->realCallableNameNoPrefix, 'description' => $this->description, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'servers' => $this->servers, 'defaultMethod' => $this->defaultMethod, ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'callableName'", "=>", "$", "this", "->", "callableName", ",", "'methodName'", "=>", "$", "this", "->", "methodName", ",", "'realCallableName'", "=>", "$", "this", "->", "realCallableName...
Retrieve all Job data in cache format @return array
[ "Retrieve", "all", "Job", "data", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/JobClass.php#L269-L285
train
CasperLaiTW/laravel-fb-messenger
src/PersistentMenu/Menu.php
Menu.postback
public function postback($text, $payload = '') { $this->createMenu([ 'call_to_actions' => [ (new Button(Button::TYPE_POSTBACK, $text, $payload))->toData(), ], ]); }
php
public function postback($text, $payload = '') { $this->createMenu([ 'call_to_actions' => [ (new Button(Button::TYPE_POSTBACK, $text, $payload))->toData(), ], ]); }
[ "public", "function", "postback", "(", "$", "text", ",", "$", "payload", "=", "''", ")", "{", "$", "this", "->", "createMenu", "(", "[", "'call_to_actions'", "=>", "[", "(", "new", "Button", "(", "Button", "::", "TYPE_POSTBACK", ",", "$", "text", ",", ...
Create postback menu @param $text @param string $payload @throws \Casperlaitw\LaravelFbMessenger\Exceptions\UnknownTypeException
[ "Create", "postback", "menu" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/PersistentMenu/Menu.php#L60-L67
train
CasperLaiTW/laravel-fb-messenger
src/PersistentMenu/Menu.php
Menu.locale
public function locale($locale, $menus) { $this->stack[] = [ 'locale' => $locale, ]; $this->loadMenus($menus); $this->menus[] = array_pop($this->stack); }
php
public function locale($locale, $menus) { $this->stack[] = [ 'locale' => $locale, ]; $this->loadMenus($menus); $this->menus[] = array_pop($this->stack); }
[ "public", "function", "locale", "(", "$", "locale", ",", "$", "menus", ")", "{", "$", "this", "->", "stack", "[", "]", "=", "[", "'locale'", "=>", "$", "locale", ",", "]", ";", "$", "this", "->", "loadMenus", "(", "$", "menus", ")", ";", "$", "...
Set locale menu @param $locale @param $menus
[ "Set", "locale", "menu" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/PersistentMenu/Menu.php#L114-L123
train
CasperLaiTW/laravel-fb-messenger
src/PersistentMenu/Menu.php
Menu.mergeWithLastStack
protected function mergeWithLastStack($menu) { $stack = array_pop($this->stack); $this->stack[] = array_merge_recursive($stack, $menu); }
php
protected function mergeWithLastStack($menu) { $stack = array_pop($this->stack); $this->stack[] = array_merge_recursive($stack, $menu); }
[ "protected", "function", "mergeWithLastStack", "(", "$", "menu", ")", "{", "$", "stack", "=", "array_pop", "(", "$", "this", "->", "stack", ")", ";", "$", "this", "->", "stack", "[", "]", "=", "array_merge_recursive", "(", "$", "stack", ",", "$", "menu...
Merge menus to last menu stack @param $menu
[ "Merge", "menus", "to", "last", "menu", "stack" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/PersistentMenu/Menu.php#L152-L156
train
CasperLaiTW/laravel-fb-messenger
src/Contracts/Messages/Attachment.php
Attachment.setAttachmentId
public function setAttachmentId($id) { $this->payload['attachment_id'] = $id; unset($this->payload['url'], $this->payload['is_reusable']); return $this; }
php
public function setAttachmentId($id) { $this->payload['attachment_id'] = $id; unset($this->payload['url'], $this->payload['is_reusable']); return $this; }
[ "public", "function", "setAttachmentId", "(", "$", "id", ")", "{", "$", "this", "->", "payload", "[", "'attachment_id'", "]", "=", "$", "id", ";", "unset", "(", "$", "this", "->", "payload", "[", "'url'", "]", ",", "$", "this", "->", "payload", "[", ...
Set attachment id @param $id @return $this
[ "Set", "attachment", "id" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Messages/Attachment.php#L124-L130
train
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.load
public function load() { list($paths, $excludedPaths) = $this->loadBundleNamespaceMap($this->kernelBundles, $this->bundles); $paths = array_merge($paths, $this->loadResourceNamespaceMap($this->rootDir, $this->resources)); return $this->parseNamespaceMap($this->finder, $this->reader, $paths, $excludedPaths); }
php
public function load() { list($paths, $excludedPaths) = $this->loadBundleNamespaceMap($this->kernelBundles, $this->bundles); $paths = array_merge($paths, $this->loadResourceNamespaceMap($this->rootDir, $this->resources)); return $this->parseNamespaceMap($this->finder, $this->reader, $paths, $excludedPaths); }
[ "public", "function", "load", "(", ")", "{", "list", "(", "$", "paths", ",", "$", "excludedPaths", ")", "=", "$", "this", "->", "loadBundleNamespaceMap", "(", "$", "this", "->", "kernelBundles", ",", "$", "this", "->", "bundles", ")", ";", "$", "paths"...
Loads Worker Collection from parsed files @return WorkerCollection collection of all info
[ "Loads", "Worker", "Collection", "from", "parsed", "files" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L136-L142
train
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.loadResourceNamespaceMap
public function loadResourceNamespaceMap($rootDir, array $resources) { return array_map(function($resource) use ($rootDir) { return $rootDir . '/' . trim($resource, '/') . '/'; }, $resources); }
php
public function loadResourceNamespaceMap($rootDir, array $resources) { return array_map(function($resource) use ($rootDir) { return $rootDir . '/' . trim($resource, '/') . '/'; }, $resources); }
[ "public", "function", "loadResourceNamespaceMap", "(", "$", "rootDir", ",", "array", "$", "resources", ")", "{", "return", "array_map", "(", "function", "(", "$", "resource", ")", "use", "(", "$", "rootDir", ")", "{", "return", "$", "rootDir", ".", "'/'", ...
Get resource paths @param string $rootDir @param array $resources @return array
[ "Get", "resource", "paths" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L205-L210
train
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.parseNamespaceMap
public function parseNamespaceMap( Finder $finder, Reader $reader, array $paths, array $excludedPaths ) { $workerCollection = new WorkerCollection; if (!empty($paths)) { $finder ->files() ->followLinks() ->exclude($excludedPaths) ->in($paths) ->name('*.php'); $this->parseFiles($finder, $reader, $workerCollection); } return $workerCollection; }
php
public function parseNamespaceMap( Finder $finder, Reader $reader, array $paths, array $excludedPaths ) { $workerCollection = new WorkerCollection; if (!empty($paths)) { $finder ->files() ->followLinks() ->exclude($excludedPaths) ->in($paths) ->name('*.php'); $this->parseFiles($finder, $reader, $workerCollection); } return $workerCollection; }
[ "public", "function", "parseNamespaceMap", "(", "Finder", "$", "finder", ",", "Reader", "$", "reader", ",", "array", "$", "paths", ",", "array", "$", "excludedPaths", ")", "{", "$", "workerCollection", "=", "new", "WorkerCollection", ";", "if", "(", "!", "...
Perform a parsing inside all namespace map Creates an empty worker collection and, if exist some parseable files parse them, filling this object @param Finder $finder Finder @param Reader $reader Reader @param array $paths Paths where to look for @param array $excludedPaths Paths to ignore @return WorkerCollection collection of all info
[ "Perform", "a", "parsing", "inside", "all", "namespace", "map" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L225-L247
train
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.parseFiles
public function parseFiles( Finder $finder, Reader $reader, WorkerCollection $workerCollection ) { /** * Every file found is parsed */ foreach ($finder as $file) { /** * File is accepted to be parsed */ $classNamespace = $this->getFileClassNamespace($file->getRealpath()); $reflectionClass = new ReflectionClass($classNamespace); $classAnnotations = $reader->getClassAnnotations($reflectionClass); /** * Every annotation found is parsed */ foreach ($classAnnotations as $annotation) { /** * Annotation is only laoded if is typeof WorkAnnotation */ if ($annotation instanceof WorkAnnotation) { /** * Creates new Worker element with all its Job data */ $worker = new Worker($annotation, $reflectionClass, $reader, $this->servers, $this->defaultSettings); $workerCollection->add($worker); } } } return $this; }
php
public function parseFiles( Finder $finder, Reader $reader, WorkerCollection $workerCollection ) { /** * Every file found is parsed */ foreach ($finder as $file) { /** * File is accepted to be parsed */ $classNamespace = $this->getFileClassNamespace($file->getRealpath()); $reflectionClass = new ReflectionClass($classNamespace); $classAnnotations = $reader->getClassAnnotations($reflectionClass); /** * Every annotation found is parsed */ foreach ($classAnnotations as $annotation) { /** * Annotation is only laoded if is typeof WorkAnnotation */ if ($annotation instanceof WorkAnnotation) { /** * Creates new Worker element with all its Job data */ $worker = new Worker($annotation, $reflectionClass, $reader, $this->servers, $this->defaultSettings); $workerCollection->add($worker); } } } return $this; }
[ "public", "function", "parseFiles", "(", "Finder", "$", "finder", ",", "Reader", "$", "reader", ",", "WorkerCollection", "$", "workerCollection", ")", "{", "/**\n * Every file found is parsed\n */", "foreach", "(", "$", "finder", "as", "$", "file", "...
Load all workers with their jobs @param Finder $finder Finder @param Reader $reader Reader @param WorkerCollection $workerCollection Worker collection @return GearmanParser self Object
[ "Load", "all", "workers", "with", "their", "jobs" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L258-L297
train
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.getFileClassNamespace
public function getFileClassNamespace($file) { $filenameBlock = explode(DIRECTORY_SEPARATOR, $file); $filename = explode('.', end($filenameBlock), 2); $filename = reset($filename); preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match); return is_array($match) && isset($match[1]) ? $match[1] . '\\' . $filename : false; }
php
public function getFileClassNamespace($file) { $filenameBlock = explode(DIRECTORY_SEPARATOR, $file); $filename = explode('.', end($filenameBlock), 2); $filename = reset($filename); preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match); return is_array($match) && isset($match[1]) ? $match[1] . '\\' . $filename : false; }
[ "public", "function", "getFileClassNamespace", "(", "$", "file", ")", "{", "$", "filenameBlock", "=", "explode", "(", "DIRECTORY_SEPARATOR", ",", "$", "file", ")", ";", "$", "filename", "=", "explode", "(", "'.'", ",", "end", "(", "$", "filenameBlock", ")"...
Returns file class namespace, if exists @param string $file A PHP file path @return string|false Full class namespace if found, false otherwise
[ "Returns", "file", "class", "namespace", "if", "exists" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L306-L317
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedQuery
protected function mappedQuery(Builder $query, $method, ArgumentBag $args) { $mapping = $this->getMappingForAttribute($args->get('column')); if ($this->relationMapping($mapping)) { return $this->mappedRelationQuery($query, $method, $args, $mapping); } $args->set('column', $mapping); return $query->callParent($method, $args->all()); }
php
protected function mappedQuery(Builder $query, $method, ArgumentBag $args) { $mapping = $this->getMappingForAttribute($args->get('column')); if ($this->relationMapping($mapping)) { return $this->mappedRelationQuery($query, $method, $args, $mapping); } $args->set('column', $mapping); return $query->callParent($method, $args->all()); }
[ "protected", "function", "mappedQuery", "(", "Builder", "$", "query", ",", "$", "method", ",", "ArgumentBag", "$", "args", ")", "{", "$", "mapping", "=", "$", "this", "->", "getMappingForAttribute", "(", "$", "args", "->", "get", "(", "'column'", ")", ")...
Custom query handler for querying mapped attributes. @param \Sofa\Eloquence\Builder $query @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @return mixed
[ "Custom", "query", "handler", "for", "querying", "mapped", "attributes", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L67-L78
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedSelect
protected function mappedSelect(Builder $query, ArgumentBag $args) { $columns = $args->get('columns'); foreach ($columns as $key => $column) { list($column, $as) = $this->extractColumnAlias($column); // Each mapped column will be selected appropriately. If it's alias // then prefix it with current table and use original field name // otherwise join required mapped tables and select the field. if ($this->hasMapping($column)) { $mapping = $this->getMappingForAttribute($column); if ($this->relationMapping($mapping)) { list($target, $mapped) = $this->parseMappedColumn($mapping); $table = $this->joinMapped($query, $target); } else { list($table, $mapped) = [$this->getTable(), $mapping]; } $columns[$key] = "{$table}.{$mapped}"; if ($as !== $column) { $columns[$key] .= " as {$as}"; } // For non mapped columns present on this table we will simply // add the prefix, in order to avoid any column collisions, // that are likely to happen when we are joining tables. } elseif ($this->hasColumn($column)) { $columns[$key] = "{$this->getTable()}.{$column}"; } } $args->set('columns', $columns); }
php
protected function mappedSelect(Builder $query, ArgumentBag $args) { $columns = $args->get('columns'); foreach ($columns as $key => $column) { list($column, $as) = $this->extractColumnAlias($column); // Each mapped column will be selected appropriately. If it's alias // then prefix it with current table and use original field name // otherwise join required mapped tables and select the field. if ($this->hasMapping($column)) { $mapping = $this->getMappingForAttribute($column); if ($this->relationMapping($mapping)) { list($target, $mapped) = $this->parseMappedColumn($mapping); $table = $this->joinMapped($query, $target); } else { list($table, $mapped) = [$this->getTable(), $mapping]; } $columns[$key] = "{$table}.{$mapped}"; if ($as !== $column) { $columns[$key] .= " as {$as}"; } // For non mapped columns present on this table we will simply // add the prefix, in order to avoid any column collisions, // that are likely to happen when we are joining tables. } elseif ($this->hasColumn($column)) { $columns[$key] = "{$this->getTable()}.{$column}"; } } $args->set('columns', $columns); }
[ "protected", "function", "mappedSelect", "(", "Builder", "$", "query", ",", "ArgumentBag", "$", "args", ")", "{", "$", "columns", "=", "$", "args", "->", "get", "(", "'columns'", ")", ";", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", ...
Adjust mapped columns for select statement. @param \Sofa\Eloquence\Builder $query @param \Sofa\Hookable\Contracts\ArgumentBag $args @return void
[ "Adjust", "mapped", "columns", "for", "select", "statement", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L87-L123
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedRelationQuery
protected function mappedRelationQuery($query, $method, ArgumentBag $args, $mapping) { list($target, $column) = $this->parseMappedColumn($mapping); if (in_array($method, ['pluck', 'value', 'aggregate', 'orderBy', 'lists'])) { return $this->mappedJoinQuery($query, $method, $args, $target, $column); } return $this->mappedHasQuery($query, $method, $args, $target, $column); }
php
protected function mappedRelationQuery($query, $method, ArgumentBag $args, $mapping) { list($target, $column) = $this->parseMappedColumn($mapping); if (in_array($method, ['pluck', 'value', 'aggregate', 'orderBy', 'lists'])) { return $this->mappedJoinQuery($query, $method, $args, $target, $column); } return $this->mappedHasQuery($query, $method, $args, $target, $column); }
[ "protected", "function", "mappedRelationQuery", "(", "$", "query", ",", "$", "method", ",", "ArgumentBag", "$", "args", ",", "$", "mapping", ")", "{", "list", "(", "$", "target", ",", "$", "column", ")", "=", "$", "this", "->", "parseMappedColumn", "(", ...
Handle querying relational mappings. @param \Sofa\Eloquence\Builder $query @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $mapping @return mixed
[ "Handle", "querying", "relational", "mappings", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L134-L143
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.orderByMapped
protected function orderByMapped(Builder $query, ArgumentBag $args, $table, $column, $target) { $query->with($target)->getQuery()->orderBy("{$table}.{$column}", $args->get('direction')); return $query; }
php
protected function orderByMapped(Builder $query, ArgumentBag $args, $table, $column, $target) { $query->with($target)->getQuery()->orderBy("{$table}.{$column}", $args->get('direction')); return $query; }
[ "protected", "function", "orderByMapped", "(", "Builder", "$", "query", ",", "ArgumentBag", "$", "args", ",", "$", "table", ",", "$", "column", ",", "$", "target", ")", "{", "$", "query", "->", "with", "(", "$", "target", ")", "->", "getQuery", "(", ...
Order query by mapped attribute. @param \Sofa\Eloquence\Builder $query @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $table @param string $column @param string $target @return \Sofa\Eloquence\Builder
[ "Order", "query", "by", "mapped", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L178-L183
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.pluckMapped
protected function pluckMapped(Builder $query, ArgumentBag $args, $table, $column) { $query->select("{$table}.{$column}"); if (!is_null($args->get('key'))) { $this->mappedSelectListsKey($query, $args->get('key')); } $args->set('column', $column); return $query->callParent('pluck', $args->all()); }
php
protected function pluckMapped(Builder $query, ArgumentBag $args, $table, $column) { $query->select("{$table}.{$column}"); if (!is_null($args->get('key'))) { $this->mappedSelectListsKey($query, $args->get('key')); } $args->set('column', $column); return $query->callParent('pluck', $args->all()); }
[ "protected", "function", "pluckMapped", "(", "Builder", "$", "query", ",", "ArgumentBag", "$", "args", ",", "$", "table", ",", "$", "column", ")", "{", "$", "query", "->", "select", "(", "\"{$table}.{$column}\"", ")", ";", "if", "(", "!", "is_null", "(",...
Get an array with the values of given mapped attribute. @param \Sofa\Eloquence\Builder $query @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $table @param string $column @return array
[ "Get", "an", "array", "with", "the", "values", "of", "given", "mapped", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L207-L218
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedSelectListsKey
protected function mappedSelectListsKey(Builder $query, $key) { if ($this->hasColumn($key)) { return $query->addSelect($this->getTable() . '.' . $key); } return $query->addSelect($key); }
php
protected function mappedSelectListsKey(Builder $query, $key) { if ($this->hasColumn($key)) { return $query->addSelect($this->getTable() . '.' . $key); } return $query->addSelect($key); }
[ "protected", "function", "mappedSelectListsKey", "(", "Builder", "$", "query", ",", "$", "key", ")", "{", "if", "(", "$", "this", "->", "hasColumn", "(", "$", "key", ")", ")", "{", "return", "$", "query", "->", "addSelect", "(", "$", "this", "->", "g...
Add select clause for key of the list array. @param \Sofa\Eloquence\Builder $query @param string $key @return \Sofa\Eloquence\Builder
[ "Add", "select", "clause", "for", "key", "of", "the", "list", "array", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L227-L234
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.alreadyJoined
protected function alreadyJoined(Builder $query, $table) { $joined = Arr::pluck((array) $query->getQuery()->joins, 'table'); return in_array($table, $joined); }
php
protected function alreadyJoined(Builder $query, $table) { $joined = Arr::pluck((array) $query->getQuery()->joins, 'table'); return in_array($table, $joined); }
[ "protected", "function", "alreadyJoined", "(", "Builder", "$", "query", ",", "$", "table", ")", "{", "$", "joined", "=", "Arr", "::", "pluck", "(", "(", "array", ")", "$", "query", "->", "getQuery", "(", ")", "->", "joins", ",", "'table'", ")", ";", ...
Determine whether given table has been already joined. @param \Sofa\Eloquence\Builder $query @param string $table @return boolean
[ "Determine", "whether", "given", "table", "has", "been", "already", "joined", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L299-L304
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getJoinKeys
protected function getJoinKeys(Relation $relation) { if ($relation instanceof HasOne || $relation instanceof MorphOne) { return [$relation->getQualifiedForeignKeyName(), $relation->getQualifiedParentKeyName()]; } if ($relation instanceof BelongsTo && !$relation instanceof MorphTo) { return [$relation->getQualifiedForeignKey(), $relation->getQualifiedOwnerKeyName()]; } $class = get_class($relation); throw new LogicException( "Only HasOne, MorphOne and BelongsTo mappings can be queried. {$class} given." ); }
php
protected function getJoinKeys(Relation $relation) { if ($relation instanceof HasOne || $relation instanceof MorphOne) { return [$relation->getQualifiedForeignKeyName(), $relation->getQualifiedParentKeyName()]; } if ($relation instanceof BelongsTo && !$relation instanceof MorphTo) { return [$relation->getQualifiedForeignKey(), $relation->getQualifiedOwnerKeyName()]; } $class = get_class($relation); throw new LogicException( "Only HasOne, MorphOne and BelongsTo mappings can be queried. {$class} given." ); }
[ "protected", "function", "getJoinKeys", "(", "Relation", "$", "relation", ")", "{", "if", "(", "$", "relation", "instanceof", "HasOne", "||", "$", "relation", "instanceof", "MorphOne", ")", "{", "return", "[", "$", "relation", "->", "getQualifiedForeignKeyName",...
Get the keys from relation in order to join the table. @param \Illuminate\Database\Eloquent\Relations\Relation $relation @return array @throws \LogicException
[ "Get", "the", "keys", "from", "relation", "in", "order", "to", "join", "the", "table", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L314-L329
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedHasQuery
protected function mappedHasQuery(Builder $query, $method, ArgumentBag $args, $target, $column) { $boolean = $this->getMappedBoolean($args); $operator = $this->getMappedOperator($method, $args); $args->set('column', $column); return $query ->has($target, $operator, 1, $boolean, $this->getMappedWhereConstraint($method, $args)) ->with($target); }
php
protected function mappedHasQuery(Builder $query, $method, ArgumentBag $args, $target, $column) { $boolean = $this->getMappedBoolean($args); $operator = $this->getMappedOperator($method, $args); $args->set('column', $column); return $query ->has($target, $operator, 1, $boolean, $this->getMappedWhereConstraint($method, $args)) ->with($target); }
[ "protected", "function", "mappedHasQuery", "(", "Builder", "$", "query", ",", "$", "method", ",", "ArgumentBag", "$", "args", ",", "$", "target", ",", "$", "column", ")", "{", "$", "boolean", "=", "$", "this", "->", "getMappedBoolean", "(", "$", "args", ...
Add whereHas subquery on the mapped attribute relation. @param \Sofa\Eloquence\Builder $query @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $target @param string $column @return \Sofa\Eloquence\Builder
[ "Add", "whereHas", "subquery", "on", "the", "mapped", "attribute", "relation", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L354-L365
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getMappedWhereConstraint
protected function getMappedWhereConstraint($method, ArgumentBag $args) { return function ($query) use ($method, $args) { call_user_func_array([$query, $method], $args->all()); }; }
php
protected function getMappedWhereConstraint($method, ArgumentBag $args) { return function ($query) use ($method, $args) { call_user_func_array([$query, $method], $args->all()); }; }
[ "protected", "function", "getMappedWhereConstraint", "(", "$", "method", ",", "ArgumentBag", "$", "args", ")", "{", "return", "function", "(", "$", "query", ")", "use", "(", "$", "method", ",", "$", "args", ")", "{", "call_user_func_array", "(", "[", "$", ...
Get the relation constraint closure. @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @return \Closure
[ "Get", "the", "relation", "constraint", "closure", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L374-L379
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getMappedOperator
protected function getMappedOperator($method, ArgumentBag $args) { if ($not = $args->get('not')) { $args->set('not', false); } if ($null = $this->isWhereNull($method, $args)) { $args->set('not', true); } return ($not ^ $null) ? '<' : '>='; }
php
protected function getMappedOperator($method, ArgumentBag $args) { if ($not = $args->get('not')) { $args->set('not', false); } if ($null = $this->isWhereNull($method, $args)) { $args->set('not', true); } return ($not ^ $null) ? '<' : '>='; }
[ "protected", "function", "getMappedOperator", "(", "$", "method", ",", "ArgumentBag", "$", "args", ")", "{", "if", "(", "$", "not", "=", "$", "args", "->", "get", "(", "'not'", ")", ")", "{", "$", "args", "->", "set", "(", "'not'", ",", "false", ")...
Determine the operator for count relation query and set 'not' appropriately. @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @return string
[ "Determine", "the", "operator", "for", "count", "relation", "query", "and", "set", "not", "appropriately", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L403-L414
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.hasMapping
public function hasMapping($key) { if (is_null($this->mappedAttributes)) { $this->parseMappings(); } return array_key_exists((string) $key, $this->mappedAttributes); }
php
public function hasMapping($key) { if (is_null($this->mappedAttributes)) { $this->parseMappings(); } return array_key_exists((string) $key, $this->mappedAttributes); }
[ "public", "function", "hasMapping", "(", "$", "key", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "mappedAttributes", ")", ")", "{", "$", "this", "->", "parseMappings", "(", ")", ";", "}", "return", "array_key_exists", "(", "(", "string", ")...
Determine whether a mapping exists for an attribute. @param string $key @return boolean
[ "Determine", "whether", "a", "mapping", "exists", "for", "an", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L446-L453
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.parseMappings
protected function parseMappings() { $this->mappedAttributes = []; foreach ($this->getMaps() as $attribute => $mapping) { if (is_array($mapping)) { $this->parseImplicitMapping($mapping, $attribute); } else { $this->mappedAttributes[$attribute] = $mapping; } } }
php
protected function parseMappings() { $this->mappedAttributes = []; foreach ($this->getMaps() as $attribute => $mapping) { if (is_array($mapping)) { $this->parseImplicitMapping($mapping, $attribute); } else { $this->mappedAttributes[$attribute] = $mapping; } } }
[ "protected", "function", "parseMappings", "(", ")", "{", "$", "this", "->", "mappedAttributes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getMaps", "(", ")", "as", "$", "attribute", "=>", "$", "mapping", ")", "{", "if", "(", "is_array", ...
Parse defined mappings into flat array. @return void
[ "Parse", "defined", "mappings", "into", "flat", "array", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L460-L471
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mapAttribute
protected function mapAttribute($key) { $segments = explode('.', $this->getMappingForAttribute($key)); return $this->getTarget($this, $segments); }
php
protected function mapAttribute($key) { $segments = explode('.', $this->getMappingForAttribute($key)); return $this->getTarget($this, $segments); }
[ "protected", "function", "mapAttribute", "(", "$", "key", ")", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "this", "->", "getMappingForAttribute", "(", "$", "key", ")", ")", ";", "return", "$", "this", "->", "getTarget", "(", "$", "this...
Map an attribute to a value. @param string $key @return mixed
[ "Map", "an", "attribute", "to", "a", "value", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L493-L498
train
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getTarget
protected function getTarget($target, array $segments) { foreach ($segments as $segment) { if (!$target) { return; } $target = $target->{$segment}; } return $target; }
php
protected function getTarget($target, array $segments) { foreach ($segments as $segment) { if (!$target) { return; } $target = $target->{$segment}; } return $target; }
[ "protected", "function", "getTarget", "(", "$", "target", ",", "array", "$", "segments", ")", "{", "foreach", "(", "$", "segments", "as", "$", "segment", ")", "{", "if", "(", "!", "$", "target", ")", "{", "return", ";", "}", "$", "target", "=", "$"...
Get mapped value. @param \Illuminate\Database\Eloquent\Model $target @param array $segments @return mixed
[ "Get", "mapped", "value", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L507-L518
train