id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
41,200 | imbo/behat-api-extension | features/bootstrap/FeatureContext.php | FeatureContext.assertCommandOutputMatches | public function assertCommandOutputMatches(PyStringNode $content) {
Assertion::contains(
$this->getOutput(),
str_replace("'''", '"""', (string) $content),
sprintf('Command output does not match. Actual output: %s', $this->getOutput())
);
} | php | public function assertCommandOutputMatches(PyStringNode $content) {
Assertion::contains(
$this->getOutput(),
str_replace("'''", '"""', (string) $content),
sprintf('Command output does not match. Actual output: %s', $this->getOutput())
);
} | [
"public",
"function",
"assertCommandOutputMatches",
"(",
"PyStringNode",
"$",
"content",
")",
"{",
"Assertion",
"::",
"contains",
"(",
"$",
"this",
"->",
"getOutput",
"(",
")",
",",
"str_replace",
"(",
"\"'''\"",
",",
"'\"\"\"'",
",",
"(",
"string",
")",
"$"... | Assert command output contains a string
@param PyStringNode $output
@Then the output should contain: | [
"Assert",
"command",
"output",
"contains",
"a",
"string"
] | f1607cc88fd352a73a87ebf69214b5e2e505fb34 | https://github.com/imbo/behat-api-extension/blob/f1607cc88fd352a73a87ebf69214b5e2e505fb34/features/bootstrap/FeatureContext.php#L158-L164 |
41,201 | imbo/behat-api-extension | features/bootstrap/FeatureContext.php | FeatureContext.assertCommandResult | public function assertCommandResult($result) {
$exitCode = $this->getExitCode();
// Escape % as the callback will pass this value to sprintf() if the assertion fails, and
// sprintf might complain about too few arguments as the output might contain stuff like %s
// or %d.
$output = str_replace('%', '%%', $this->getOutput());
if ($result === 'fail') {
$callback = 'notEq';
$errorMessage = sprintf(
'Invalid exit code, did not expect 0. Command output: %s',
$output
);
} else {
$callback = 'eq';
$errorMessage = sprintf(
'Expected exit code 0, got %d. Command output: %s',
$exitCode,
$output
);
}
Assertion::$callback(0, $exitCode, $errorMessage);
} | php | public function assertCommandResult($result) {
$exitCode = $this->getExitCode();
// Escape % as the callback will pass this value to sprintf() if the assertion fails, and
// sprintf might complain about too few arguments as the output might contain stuff like %s
// or %d.
$output = str_replace('%', '%%', $this->getOutput());
if ($result === 'fail') {
$callback = 'notEq';
$errorMessage = sprintf(
'Invalid exit code, did not expect 0. Command output: %s',
$output
);
} else {
$callback = 'eq';
$errorMessage = sprintf(
'Expected exit code 0, got %d. Command output: %s',
$exitCode,
$output
);
}
Assertion::$callback(0, $exitCode, $errorMessage);
} | [
"public",
"function",
"assertCommandResult",
"(",
"$",
"result",
")",
"{",
"$",
"exitCode",
"=",
"$",
"this",
"->",
"getExitCode",
"(",
")",
";",
"// Escape % as the callback will pass this value to sprintf() if the assertion fails, and",
"// sprintf might complain about too fe... | Checks whether the command failed or passed
@param string $result
@Then /^it should (fail|pass)$/ | [
"Checks",
"whether",
"the",
"command",
"failed",
"or",
"passed"
] | f1607cc88fd352a73a87ebf69214b5e2e505fb34 | https://github.com/imbo/behat-api-extension/blob/f1607cc88fd352a73a87ebf69214b5e2e505fb34/features/bootstrap/FeatureContext.php#L172-L196 |
41,202 | imbo/behat-api-extension | features/bootstrap/FeatureContext.php | FeatureContext.getOutput | private function getOutput() {
$output = $this->process->getErrorOutput() . $this->process->getOutput();
return trim(preg_replace('/ +$/m', '', $output));
} | php | private function getOutput() {
$output = $this->process->getErrorOutput() . $this->process->getOutput();
return trim(preg_replace('/ +$/m', '', $output));
} | [
"private",
"function",
"getOutput",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"process",
"->",
"getErrorOutput",
"(",
")",
".",
"$",
"this",
"->",
"process",
"->",
"getOutput",
"(",
")",
";",
"return",
"trim",
"(",
"preg_replace",
"(",
"'/ ... | Get output from the process
@return string | [
"Get",
"output",
"from",
"the",
"process"
] | f1607cc88fd352a73a87ebf69214b5e2e505fb34 | https://github.com/imbo/behat-api-extension/blob/f1607cc88fd352a73a87ebf69214b5e2e505fb34/features/bootstrap/FeatureContext.php#L212-L216 |
41,203 | imbo/behat-api-extension | features/bootstrap/FeatureContext.php | FeatureContext.rmdir | private static function rmdir($path) {
foreach (glob($path . '/*') as $file) {
if (is_dir($file)) {
self::rmdir($file);
} else {
unlink($file);
}
}
// Remove the remaining directory
rmdir($path);
} | php | private static function rmdir($path) {
foreach (glob($path . '/*') as $file) {
if (is_dir($file)) {
self::rmdir($file);
} else {
unlink($file);
}
}
// Remove the remaining directory
rmdir($path);
} | [
"private",
"static",
"function",
"rmdir",
"(",
"$",
"path",
")",
"{",
"foreach",
"(",
"glob",
"(",
"$",
"path",
".",
"'/*'",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"file",
")",
")",
"{",
"self",
"::",
"rmdir",
"(",
"$"... | Recursively delete a directory
@param string $path Path to a file or a directory | [
"Recursively",
"delete",
"a",
"directory"
] | f1607cc88fd352a73a87ebf69214b5e2e505fb34 | https://github.com/imbo/behat-api-extension/blob/f1607cc88fd352a73a87ebf69214b5e2e505fb34/features/bootstrap/FeatureContext.php#L223-L234 |
41,204 | imbo/behat-api-extension | src/ArrayContainsComparator/Matcher/JWT.php | JWT.addToken | public function addToken($name, array $payload, $secret) {
$this->jwtTokens[$name] = [
'payload' => $payload,
'secret' => $secret,
];
return $this;
} | php | public function addToken($name, array $payload, $secret) {
$this->jwtTokens[$name] = [
'payload' => $payload,
'secret' => $secret,
];
return $this;
} | [
"public",
"function",
"addToken",
"(",
"$",
"name",
",",
"array",
"$",
"payload",
",",
"$",
"secret",
")",
"{",
"$",
"this",
"->",
"jwtTokens",
"[",
"$",
"name",
"]",
"=",
"[",
"'payload'",
"=>",
"$",
"payload",
",",
"'secret'",
"=>",
"$",
"secret",
... | Add a JWT token that can be matched
@param string $name String identifying the token
@param array $payload The payload
@param string $secret The secret used to sign the token
@return self | [
"Add",
"a",
"JWT",
"token",
"that",
"can",
"be",
"matched"
] | f1607cc88fd352a73a87ebf69214b5e2e505fb34 | https://github.com/imbo/behat-api-extension/blob/f1607cc88fd352a73a87ebf69214b5e2e505fb34/src/ArrayContainsComparator/Matcher/JWT.php#L56-L63 |
41,205 | wordplate/framework | src/PluginLoader.php | PluginLoader.load | public function load(): void
{
// Load WordPress's action and filter helper functions.
require_once ABSPATH.'wp-includes/plugin.php';
add_filter('pre_option_active_plugins', [$this, 'preOptionActivePlugins']);
add_filter('show_advanced_plugins', [$this, 'showAdvancedPlugins'], 0, 2);
add_filter('option_active_plugins', [$this, 'optionActivePlugins'], PHP_INT_MAX);
add_filter('pre_update_option_active_plugins', [$this, 'preUpdateOptionActivePlugins']);
} | php | public function load(): void
{
// Load WordPress's action and filter helper functions.
require_once ABSPATH.'wp-includes/plugin.php';
add_filter('pre_option_active_plugins', [$this, 'preOptionActivePlugins']);
add_filter('show_advanced_plugins', [$this, 'showAdvancedPlugins'], 0, 2);
add_filter('option_active_plugins', [$this, 'optionActivePlugins'], PHP_INT_MAX);
add_filter('pre_update_option_active_plugins', [$this, 'preUpdateOptionActivePlugins']);
} | [
"public",
"function",
"load",
"(",
")",
":",
"void",
"{",
"// Load WordPress's action and filter helper functions.",
"require_once",
"ABSPATH",
".",
"'wp-includes/plugin.php'",
";",
"add_filter",
"(",
"'pre_option_active_plugins'",
",",
"[",
"$",
"this",
",",
"'preOptionA... | Run the plugin loader.
@return void | [
"Run",
"the",
"plugin",
"loader",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L48-L57 |
41,206 | wordplate/framework | src/PluginLoader.php | PluginLoader.showAdvancedPlugins | public function showAdvancedPlugins(bool $show, string $type)
{
if (!$this->isPluginsScreen() || $type !== 'mustuse' || !current_user_can('activate_plugins')) {
return $show;
}
$GLOBALS['plugins']['mustuse'] = $this->getPlugins();
} | php | public function showAdvancedPlugins(bool $show, string $type)
{
if (!$this->isPluginsScreen() || $type !== 'mustuse' || !current_user_can('activate_plugins')) {
return $show;
}
$GLOBALS['plugins']['mustuse'] = $this->getPlugins();
} | [
"public",
"function",
"showAdvancedPlugins",
"(",
"bool",
"$",
"show",
",",
"string",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPluginsScreen",
"(",
")",
"||",
"$",
"type",
"!==",
"'mustuse'",
"||",
"!",
"current_user_can",
"(",
"'acti... | Show must-use plugins on the plugins page.
@param bool $show
@param string $type
@return void | [
"Show",
"must",
"-",
"use",
"plugins",
"on",
"the",
"plugins",
"page",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L67-L74 |
41,207 | wordplate/framework | src/PluginLoader.php | PluginLoader.preOptionActivePlugins | public function preOptionActivePlugins($plugins)
{
remove_filter('pre_option_active_plugins', [$this, 'preOptionActivePlugins']);
if (
!defined('WP_PLUGIN_DIR') ||
!defined('WPMU_PLUGIN_DIR') ||
!is_blog_installed()
) {
return false;
}
$this->validatePlugins();
$haveUnactivatedPlugins = false;
foreach (array_keys($this->getPlugins()) as $plugin) {
if ($this->isPluginActive($plugin)) {
require_once WPMU_PLUGIN_DIR.'/'.$plugin;
} else {
$haveUnactivatedPlugins = true;
}
}
if ($haveUnactivatedPlugins) {
add_action('wp_loaded', [$this, 'activatePlugins']);
}
return $plugins;
} | php | public function preOptionActivePlugins($plugins)
{
remove_filter('pre_option_active_plugins', [$this, 'preOptionActivePlugins']);
if (
!defined('WP_PLUGIN_DIR') ||
!defined('WPMU_PLUGIN_DIR') ||
!is_blog_installed()
) {
return false;
}
$this->validatePlugins();
$haveUnactivatedPlugins = false;
foreach (array_keys($this->getPlugins()) as $plugin) {
if ($this->isPluginActive($plugin)) {
require_once WPMU_PLUGIN_DIR.'/'.$plugin;
} else {
$haveUnactivatedPlugins = true;
}
}
if ($haveUnactivatedPlugins) {
add_action('wp_loaded', [$this, 'activatePlugins']);
}
return $plugins;
} | [
"public",
"function",
"preOptionActivePlugins",
"(",
"$",
"plugins",
")",
"{",
"remove_filter",
"(",
"'pre_option_active_plugins'",
",",
"[",
"$",
"this",
",",
"'preOptionActivePlugins'",
"]",
")",
";",
"if",
"(",
"!",
"defined",
"(",
"'WP_PLUGIN_DIR'",
")",
"||... | Active plugins including must-use plugins.
@param mixed $plugins
@return mixed | [
"Active",
"plugins",
"including",
"must",
"-",
"use",
"plugins",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L83-L111 |
41,208 | wordplate/framework | src/PluginLoader.php | PluginLoader.optionActivePlugins | public function optionActivePlugins($plugins): array
{
if ($this->isPluginsScreen()) {
return $plugins;
}
foreach (array_keys($this->getPlugins()) as $plugin) {
$plugins = array_diff($plugins, [$plugin]);
if ($this->isPluginActive($plugin)) {
// Remove plugin from array, if exists
$plugins = array_diff($plugins, [$plugin]);
// Add plugin with relative url to WPMU_PLUGIN_DIR
$plugins[] = $this->getRelativePath().$plugin;
}
}
return array_unique($plugins);
} | php | public function optionActivePlugins($plugins): array
{
if ($this->isPluginsScreen()) {
return $plugins;
}
foreach (array_keys($this->getPlugins()) as $plugin) {
$plugins = array_diff($plugins, [$plugin]);
if ($this->isPluginActive($plugin)) {
// Remove plugin from array, if exists
$plugins = array_diff($plugins, [$plugin]);
// Add plugin with relative url to WPMU_PLUGIN_DIR
$plugins[] = $this->getRelativePath().$plugin;
}
}
return array_unique($plugins);
} | [
"public",
"function",
"optionActivePlugins",
"(",
"$",
"plugins",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"isPluginsScreen",
"(",
")",
")",
"{",
"return",
"$",
"plugins",
";",
"}",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"ge... | Add plugins to active plugins, this makes is_plugin_active work.
@param array $plugins
@return array | [
"Add",
"plugins",
"to",
"active",
"plugins",
"this",
"makes",
"is_plugin_active",
"work",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L120-L138 |
41,209 | wordplate/framework | src/PluginLoader.php | PluginLoader.activatePlugins | public function activatePlugins(): void
{
foreach (array_keys($this->getPlugins()) as $plugin) {
if (!$this->isPluginActive($plugin)) {
$this->activatePlugin($plugin);
}
}
} | php | public function activatePlugins(): void
{
foreach (array_keys($this->getPlugins()) as $plugin) {
if (!$this->isPluginActive($plugin)) {
$this->activatePlugin($plugin);
}
}
} | [
"public",
"function",
"activatePlugins",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"getPlugins",
"(",
")",
")",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isPluginActive",
"(",
"$",
"plu... | Active plugins not activated.
@return void | [
"Active",
"plugins",
"not",
"activated",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L159-L166 |
41,210 | wordplate/framework | src/PluginLoader.php | PluginLoader.getPlugins | protected function getPlugins(): array
{
if ($this->plugins) {
return $this->plugins;
}
// Load WordPress's plugin helper functions.
require_once ABSPATH.'wp-admin/includes/plugin.php';
$plugins = array_diff_key(
get_plugins('/'.$this->getRelativePath()),
get_mu_plugins()
);
$this->plugins = array_unique($plugins, SORT_REGULAR);
return $this->plugins;
} | php | protected function getPlugins(): array
{
if ($this->plugins) {
return $this->plugins;
}
// Load WordPress's plugin helper functions.
require_once ABSPATH.'wp-admin/includes/plugin.php';
$plugins = array_diff_key(
get_plugins('/'.$this->getRelativePath()),
get_mu_plugins()
);
$this->plugins = array_unique($plugins, SORT_REGULAR);
return $this->plugins;
} | [
"protected",
"function",
"getPlugins",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"plugins",
")",
"{",
"return",
"$",
"this",
"->",
"plugins",
";",
"}",
"// Load WordPress's plugin helper functions.",
"require_once",
"ABSPATH",
".",
"'wp-admin/in... | Get the plugins and must-use plugins.
@return array | [
"Get",
"the",
"plugins",
"and",
"must",
"-",
"use",
"plugins",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L173-L190 |
41,211 | wordplate/framework | src/PluginLoader.php | PluginLoader.getActivePlugins | protected function getActivePlugins(): array
{
if ($this->activePlugins) {
return $this->activePlugins;
}
$this->activePlugins = (array) get_option('active_mu_plugins', []);
return $this->activePlugins;
} | php | protected function getActivePlugins(): array
{
if ($this->activePlugins) {
return $this->activePlugins;
}
$this->activePlugins = (array) get_option('active_mu_plugins', []);
return $this->activePlugins;
} | [
"protected",
"function",
"getActivePlugins",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"activePlugins",
")",
"{",
"return",
"$",
"this",
"->",
"activePlugins",
";",
"}",
"$",
"this",
"->",
"activePlugins",
"=",
"(",
"array",
")",
"get_op... | Get the active must-use plugins.
@return array | [
"Get",
"the",
"active",
"must",
"-",
"use",
"plugins",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L197-L206 |
41,212 | wordplate/framework | src/PluginLoader.php | PluginLoader.setActivePlugins | protected function setActivePlugins(array $plugins): void
{
$plugins = array_unique($plugins, SORT_REGULAR);
update_option('active_mu_plugins', $plugins);
$this->activePlugins = $plugins;
} | php | protected function setActivePlugins(array $plugins): void
{
$plugins = array_unique($plugins, SORT_REGULAR);
update_option('active_mu_plugins', $plugins);
$this->activePlugins = $plugins;
} | [
"protected",
"function",
"setActivePlugins",
"(",
"array",
"$",
"plugins",
")",
":",
"void",
"{",
"$",
"plugins",
"=",
"array_unique",
"(",
"$",
"plugins",
",",
"SORT_REGULAR",
")",
";",
"update_option",
"(",
"'active_mu_plugins'",
",",
"$",
"plugins",
")",
... | Set the active must-use plugins.
@param array $plugins
@return void | [
"Set",
"the",
"active",
"must",
"-",
"use",
"plugins",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L215-L222 |
41,213 | wordplate/framework | src/PluginLoader.php | PluginLoader.activatePlugin | protected function activatePlugin(string $plugin): void
{
require_once WPMU_PLUGIN_DIR.'/'.$plugin;
do_action('activate_'.$plugin);
$plugins = $this->getActivePlugins();
$plugins[] = $plugin;
$this->setActivePlugins($plugins);
} | php | protected function activatePlugin(string $plugin): void
{
require_once WPMU_PLUGIN_DIR.'/'.$plugin;
do_action('activate_'.$plugin);
$plugins = $this->getActivePlugins();
$plugins[] = $plugin;
$this->setActivePlugins($plugins);
} | [
"protected",
"function",
"activatePlugin",
"(",
"string",
"$",
"plugin",
")",
":",
"void",
"{",
"require_once",
"WPMU_PLUGIN_DIR",
".",
"'/'",
".",
"$",
"plugin",
";",
"do_action",
"(",
"'activate_'",
".",
"$",
"plugin",
")",
";",
"$",
"plugins",
"=",
"$",... | Activate plugin by their name.
@param string $plugin
@return void | [
"Activate",
"plugin",
"by",
"their",
"name",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L243-L253 |
41,214 | wordplate/framework | src/PluginLoader.php | PluginLoader.validatePlugins | protected function validatePlugins(): void
{
$plugins = array_filter($this->getActivePlugins(), function ($plugin) {
return file_exists(WPMU_PLUGIN_DIR.'/'.$plugin);
});
if (array_diff($plugins, $this->getActivePlugins())) {
$this->setActivePlugins($plugins);
}
} | php | protected function validatePlugins(): void
{
$plugins = array_filter($this->getActivePlugins(), function ($plugin) {
return file_exists(WPMU_PLUGIN_DIR.'/'.$plugin);
});
if (array_diff($plugins, $this->getActivePlugins())) {
$this->setActivePlugins($plugins);
}
} | [
"protected",
"function",
"validatePlugins",
"(",
")",
":",
"void",
"{",
"$",
"plugins",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"getActivePlugins",
"(",
")",
",",
"function",
"(",
"$",
"plugin",
")",
"{",
"return",
"file_exists",
"(",
"WPMU_PLUGIN_DIR",... | Validate active plugins and deactivate invalid plugins.
@return void | [
"Validate",
"active",
"plugins",
"and",
"deactivate",
"invalid",
"plugins",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/PluginLoader.php#L260-L269 |
41,215 | wordplate/framework | src/Application.php | Application.run | public function run()
{
// For developers: WordPress debugging mode.
$debug = env('WP_DEBUG', false);
define('WP_DEBUG', $debug);
define('WP_DEBUG_LOG', env('WP_DEBUG_LOG', false));
define('WP_DEBUG_DISPLAY', env('WP_DEBUG_DISPLAY', $debug));
define('SCRIPT_DEBUG', env('SCRIPT_DEBUG', $debug));
// The database configuration with database name, username, password,
// hostname charset and database collae type.
define('DB_NAME', env('DB_NAME'));
define('DB_USER', env('DB_USER'));
define('DB_PASSWORD', env('DB_PASSWORD'));
define('DB_HOST', env('DB_HOST'));
define('DB_CHARSET', env('DB_CHARSET', 'utf8mb4'));
define('DB_COLLATE', env('DB_COLLATE', 'utf8mb4_unicode_ci'));
// Set the unique authentication keys and salts.
define('AUTH_KEY', env('AUTH_KEY'));
define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY'));
define('LOGGED_IN_KEY', env('LOGGED_IN_KEY'));
define('NONCE_KEY', env('NONCE_KEY'));
define('AUTH_SALT', env('AUTH_SALT'));
define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT'));
define('LOGGED_IN_SALT', env('LOGGED_IN_SALT'));
define('NONCE_SALT', env('NONCE_SALT'));
// Set the home url to the current domain.
$request = Request::createFromGlobals();
define('WP_HOME', env('WP_URL', $request->getSchemeAndHttpHost()));
// Set the WordPress directory path.
define('WP_SITEURL', env('WP_SITEURL', sprintf('%s/%s', WP_HOME, env('WP_DIR', 'wordpress'))));
// Set the WordPress content directory path.
define('WP_CONTENT_DIR', env('WP_CONTENT_DIR', $this->getPublicPath()));
define('WP_CONTENT_URL', env('WP_CONTENT_URL', WP_HOME));
// Set the trash to less days to optimize WordPress.
define('EMPTY_TRASH_DAYS', env('EMPTY_TRASH_DAYS', 7));
// Set the default WordPress theme.
define('WP_DEFAULT_THEME', env('WP_THEME', 'wordplate'));
// Constant to configure core updates.
define('WP_AUTO_UPDATE_CORE', env('WP_AUTO_UPDATE_CORE', 'minor'));
// Specify the number of post revisions.
define('WP_POST_REVISIONS', env('WP_POST_REVISIONS', 2));
// Cleanup WordPress image edits.
define('IMAGE_EDIT_OVERWRITE', env('IMAGE_EDIT_OVERWRITE', true));
// Prevent file edititing from the dashboard.
define('DISALLOW_FILE_EDIT', env('DISALLOW_FILE_EDIT', true));
// Set the absolute path to the WordPress directory.
if (!defined('ABSPATH')) {
define('ABSPATH', sprintf('%s/%s/', $this->getPublicPath(), env('WP_DIR', 'wordpress')));
}
// Load the must-use plugins.
$pluginLoader = new PluginLoader();
$pluginLoader->load();
} | php | public function run()
{
// For developers: WordPress debugging mode.
$debug = env('WP_DEBUG', false);
define('WP_DEBUG', $debug);
define('WP_DEBUG_LOG', env('WP_DEBUG_LOG', false));
define('WP_DEBUG_DISPLAY', env('WP_DEBUG_DISPLAY', $debug));
define('SCRIPT_DEBUG', env('SCRIPT_DEBUG', $debug));
// The database configuration with database name, username, password,
// hostname charset and database collae type.
define('DB_NAME', env('DB_NAME'));
define('DB_USER', env('DB_USER'));
define('DB_PASSWORD', env('DB_PASSWORD'));
define('DB_HOST', env('DB_HOST'));
define('DB_CHARSET', env('DB_CHARSET', 'utf8mb4'));
define('DB_COLLATE', env('DB_COLLATE', 'utf8mb4_unicode_ci'));
// Set the unique authentication keys and salts.
define('AUTH_KEY', env('AUTH_KEY'));
define('SECURE_AUTH_KEY', env('SECURE_AUTH_KEY'));
define('LOGGED_IN_KEY', env('LOGGED_IN_KEY'));
define('NONCE_KEY', env('NONCE_KEY'));
define('AUTH_SALT', env('AUTH_SALT'));
define('SECURE_AUTH_SALT', env('SECURE_AUTH_SALT'));
define('LOGGED_IN_SALT', env('LOGGED_IN_SALT'));
define('NONCE_SALT', env('NONCE_SALT'));
// Set the home url to the current domain.
$request = Request::createFromGlobals();
define('WP_HOME', env('WP_URL', $request->getSchemeAndHttpHost()));
// Set the WordPress directory path.
define('WP_SITEURL', env('WP_SITEURL', sprintf('%s/%s', WP_HOME, env('WP_DIR', 'wordpress'))));
// Set the WordPress content directory path.
define('WP_CONTENT_DIR', env('WP_CONTENT_DIR', $this->getPublicPath()));
define('WP_CONTENT_URL', env('WP_CONTENT_URL', WP_HOME));
// Set the trash to less days to optimize WordPress.
define('EMPTY_TRASH_DAYS', env('EMPTY_TRASH_DAYS', 7));
// Set the default WordPress theme.
define('WP_DEFAULT_THEME', env('WP_THEME', 'wordplate'));
// Constant to configure core updates.
define('WP_AUTO_UPDATE_CORE', env('WP_AUTO_UPDATE_CORE', 'minor'));
// Specify the number of post revisions.
define('WP_POST_REVISIONS', env('WP_POST_REVISIONS', 2));
// Cleanup WordPress image edits.
define('IMAGE_EDIT_OVERWRITE', env('IMAGE_EDIT_OVERWRITE', true));
// Prevent file edititing from the dashboard.
define('DISALLOW_FILE_EDIT', env('DISALLOW_FILE_EDIT', true));
// Set the absolute path to the WordPress directory.
if (!defined('ABSPATH')) {
define('ABSPATH', sprintf('%s/%s/', $this->getPublicPath(), env('WP_DIR', 'wordpress')));
}
// Load the must-use plugins.
$pluginLoader = new PluginLoader();
$pluginLoader->load();
} | [
"public",
"function",
"run",
"(",
")",
"{",
"// For developers: WordPress debugging mode.",
"$",
"debug",
"=",
"env",
"(",
"'WP_DEBUG'",
",",
"false",
")",
";",
"define",
"(",
"'WP_DEBUG'",
",",
"$",
"debug",
")",
";",
"define",
"(",
"'WP_DEBUG_LOG'",
",",
"... | Star the application engine.
@return void | [
"Star",
"the",
"application",
"engine",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/Application.php#L61-L126 |
41,216 | wordplate/framework | src/Application.php | Application.getPublicPath | public function getPublicPath(): string
{
if (is_null($this->publicPath)) {
return $this->basePath.DIRECTORY_SEPARATOR.'public';
}
return $this->publicPath;
} | php | public function getPublicPath(): string
{
if (is_null($this->publicPath)) {
return $this->basePath.DIRECTORY_SEPARATOR.'public';
}
return $this->publicPath;
} | [
"public",
"function",
"getPublicPath",
"(",
")",
":",
"string",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"publicPath",
")",
")",
"{",
"return",
"$",
"this",
"->",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"'public'",
";",
"}",
"return",
"$",... | Get the public web directory path.
@return string | [
"Get",
"the",
"public",
"web",
"directory",
"path",
"."
] | 2760174306e74fa728551a1ce0938e3d75ccbf90 | https://github.com/wordplate/framework/blob/2760174306e74fa728551a1ce0938e3d75ccbf90/src/Application.php#L143-L150 |
41,217 | Artem-Schander/L5Modular | src/Console/ModuleMakeCommand.php | ModuleMakeCommand.handle | public function handle()
{
$app = app();
$this->version = (int) str_replace('.', '', $app->version());
// check if module exists
if ($this->files->exists(app_path().'/Modules/'.studly_case($this->getNameInput()))) {
return $this->error($this->type.' already exists!');
}
// Create Controller
$this->generate('controller');
// Create Model
$this->generate('model');
// Create Views folder
$this->generate('view');
//Flag for no translation
if (! $this->option('no-translation')) { // Create Translations folder
$this->generate('translation');
}
if ($this->version < 530) {
// Create Routes file
$this->generate('routes');
} else {
// Create WEB Routes file
$this->generate('web');
// Create API Routes file
$this->generate('api');
}
// Create Helper file
$this->generate('helper');
if (! $this->option('no-migration')) {
// without hacky studly_case function
// foo-bar results in foo-bar and not in foo_bar
$table = str_plural(snake_case(studly_case($this->getNameInput())));
$this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
}
$this->info($this->type.' created successfully.');
} | php | public function handle()
{
$app = app();
$this->version = (int) str_replace('.', '', $app->version());
// check if module exists
if ($this->files->exists(app_path().'/Modules/'.studly_case($this->getNameInput()))) {
return $this->error($this->type.' already exists!');
}
// Create Controller
$this->generate('controller');
// Create Model
$this->generate('model');
// Create Views folder
$this->generate('view');
//Flag for no translation
if (! $this->option('no-translation')) { // Create Translations folder
$this->generate('translation');
}
if ($this->version < 530) {
// Create Routes file
$this->generate('routes');
} else {
// Create WEB Routes file
$this->generate('web');
// Create API Routes file
$this->generate('api');
}
// Create Helper file
$this->generate('helper');
if (! $this->option('no-migration')) {
// without hacky studly_case function
// foo-bar results in foo-bar and not in foo_bar
$table = str_plural(snake_case(studly_case($this->getNameInput())));
$this->call('make:migration', ['name' => "create_{$table}_table", '--create' => $table]);
}
$this->info($this->type.' created successfully.');
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"app",
"=",
"app",
"(",
")",
";",
"$",
"this",
"->",
"version",
"=",
"(",
"int",
")",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"$",
"app",
"->",
"version",
"(",
")",
")",
";",
"// check if mod... | Execute the console command >= L5.5.
@return void | [
"Execute",
"the",
"console",
"command",
">",
"=",
"L5",
".",
"5",
"."
] | 5cf09c427e392131a730533d0a600b6ffbf8dc4e | https://github.com/Artem-Schander/L5Modular/blob/5cf09c427e392131a730533d0a600b6ffbf8dc4e/src/Console/ModuleMakeCommand.php#L53-L104 |
41,218 | Artem-Schander/L5Modular | src/Console/ModuleMakeCommand.php | ModuleMakeCommand.replaceName | protected function replaceName(&$stub, $name)
{
$stub = str_replace('DummyTitle', $name, $stub);
$stub = str_replace('DummyUCtitle', ucfirst(studly_case($name)), $stub);
return $this;
} | php | protected function replaceName(&$stub, $name)
{
$stub = str_replace('DummyTitle', $name, $stub);
$stub = str_replace('DummyUCtitle', ucfirst(studly_case($name)), $stub);
return $this;
} | [
"protected",
"function",
"replaceName",
"(",
"&",
"$",
"stub",
",",
"$",
"name",
")",
"{",
"$",
"stub",
"=",
"str_replace",
"(",
"'DummyTitle'",
",",
"$",
"name",
",",
"$",
"stub",
")",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"'DummyUCtitle'",
",",
... | Replace the name for the given stub.
@param string $stub
@param string $name
@return string | [
"Replace",
"the",
"name",
"for",
"the",
"given",
"stub",
"."
] | 5cf09c427e392131a730533d0a600b6ffbf8dc4e | https://github.com/Artem-Schander/L5Modular/blob/5cf09c427e392131a730533d0a600b6ffbf8dc4e/src/Console/ModuleMakeCommand.php#L198-L203 |
41,219 | mikestecker/craft-videoembedder | src/services/VideoEmbedderService.php | VideoEmbedderService.getVideoId | public function getVideoId($url)
{
// looks like there are, now let's only do this for YouTube and Vimeo
if($this->getInfo($url)->type == 'video' && ($this->isYouTube($url) || $this->isVimeo($url)))
{
if ($this->isYouTube($url))
{
return $this->getYouTubeId($url);
}
else if ($this->isVimeo($url))
{
return $this->getVimeoId($url);
}
}
else
{
// return empty string
return '';
}
} | php | public function getVideoId($url)
{
// looks like there are, now let's only do this for YouTube and Vimeo
if($this->getInfo($url)->type == 'video' && ($this->isYouTube($url) || $this->isVimeo($url)))
{
if ($this->isYouTube($url))
{
return $this->getYouTubeId($url);
}
else if ($this->isVimeo($url))
{
return $this->getVimeoId($url);
}
}
else
{
// return empty string
return '';
}
} | [
"public",
"function",
"getVideoId",
"(",
"$",
"url",
")",
"{",
"// looks like there are, now let's only do this for YouTube and Vimeo",
"if",
"(",
"$",
"this",
"->",
"getInfo",
"(",
"$",
"url",
")",
"->",
"type",
"==",
"'video'",
"&&",
"(",
"$",
"this",
"->",
... | Take a url and returns only the video ID
@param string $url
@return string | [
"Take",
"a",
"url",
"and",
"returns",
"only",
"the",
"video",
"ID"
] | 03045545633952647190ed07b5b115e645931d57 | https://github.com/mikestecker/craft-videoembedder/blob/03045545633952647190ed07b5b115e645931d57/src/services/VideoEmbedderService.php#L261-L280 |
41,220 | pcrov/JsonReader | src/Parser/Lexer.php | Lexer.scanCodepoint | private function scanCodepoint(): string
{
$buffer = &$this->buffer;
$offset = &$this->offset;
$codepoint = $buffer[$offset++];
$ord = \ord($codepoint);
if (!($ord >> 7)) {
return $codepoint;
}
if (!(($ord >> 5) ^ 0b110)) {
$expect = 1;
} elseif (!(($ord >> 4) ^ 0b1110)) {
$expect = 2;
} elseif (!(($ord >> 3) ^ 0b11110)) {
$expect = 3;
} else {
$expect = 0; // This'll throw in just a moment.
}
$continuationBytes = "";
do {
$temp = \substr($buffer, $offset, $expect);
$deltaLength = \strlen($temp);
$expect -= $deltaLength;
$continuationBytes .= $temp;
} while ($expect > 0 && $this->refillBuffer());
$offset += $deltaLength;
for (
$i = 0, $continuationBytesLength = \strlen($continuationBytes);
$i < $continuationBytesLength;
$i++
) {
$byte = $continuationBytes[$i];
if ((\ord($byte) >> 6) ^ 0b10) {
break;
}
$codepoint .= $byte;
}
$chr = \IntlChar::chr($codepoint);
if ($chr === null) {
throw new ParseException($this->getIllFormedUtf8ExceptionMessage($codepoint));
}
return $chr;
} | php | private function scanCodepoint(): string
{
$buffer = &$this->buffer;
$offset = &$this->offset;
$codepoint = $buffer[$offset++];
$ord = \ord($codepoint);
if (!($ord >> 7)) {
return $codepoint;
}
if (!(($ord >> 5) ^ 0b110)) {
$expect = 1;
} elseif (!(($ord >> 4) ^ 0b1110)) {
$expect = 2;
} elseif (!(($ord >> 3) ^ 0b11110)) {
$expect = 3;
} else {
$expect = 0; // This'll throw in just a moment.
}
$continuationBytes = "";
do {
$temp = \substr($buffer, $offset, $expect);
$deltaLength = \strlen($temp);
$expect -= $deltaLength;
$continuationBytes .= $temp;
} while ($expect > 0 && $this->refillBuffer());
$offset += $deltaLength;
for (
$i = 0, $continuationBytesLength = \strlen($continuationBytes);
$i < $continuationBytesLength;
$i++
) {
$byte = $continuationBytes[$i];
if ((\ord($byte) >> 6) ^ 0b10) {
break;
}
$codepoint .= $byte;
}
$chr = \IntlChar::chr($codepoint);
if ($chr === null) {
throw new ParseException($this->getIllFormedUtf8ExceptionMessage($codepoint));
}
return $chr;
} | [
"private",
"function",
"scanCodepoint",
"(",
")",
":",
"string",
"{",
"$",
"buffer",
"=",
"&",
"$",
"this",
"->",
"buffer",
";",
"$",
"offset",
"=",
"&",
"$",
"this",
"->",
"offset",
";",
"$",
"codepoint",
"=",
"$",
"buffer",
"[",
"$",
"offset",
"+... | Scans a single UTF-8 encoded Unicode codepoint, which can be up to four
bytes long.
0xxx xxxx Single-byte codepoint.
110x xxxx First of a two-byte codepoint.
1110 xxxx First of three.
1111 0xxx First of four.
10xx xxxx A continuation of any of the three preceding.
@see https://en.wikipedia.org/wiki/UTF-8#Description
@see http://www.unicode.org/versions/Unicode9.0.0/ch03.pdf#page=54
@throws ParseException on ill-formed UTF-8. | [
"Scans",
"a",
"single",
"UTF",
"-",
"8",
"encoded",
"Unicode",
"codepoint",
"which",
"can",
"be",
"up",
"to",
"four",
"bytes",
"long",
"."
] | 83ff905fbea18c74bd438c6aa85cb3500763bfdb | https://github.com/pcrov/JsonReader/blob/83ff905fbea18c74bd438c6aa85cb3500763bfdb/src/Parser/Lexer.php#L367-L420 |
41,221 | pcrov/JsonReader | src/Parser/Lexer.php | Lexer.scanEscapedUnicodeSequence | private function scanEscapedUnicodeSequence(): string
{
static $hexChars = "0123456789ABCDEFabcdef";
static $length = 4;
$sequence = $this->scanWhile($hexChars, $length);
if (\strlen($sequence) < $length) {
throw new ParseException($this->getExceptionMessage());
}
return $sequence;
} | php | private function scanEscapedUnicodeSequence(): string
{
static $hexChars = "0123456789ABCDEFabcdef";
static $length = 4;
$sequence = $this->scanWhile($hexChars, $length);
if (\strlen($sequence) < $length) {
throw new ParseException($this->getExceptionMessage());
}
return $sequence;
} | [
"private",
"function",
"scanEscapedUnicodeSequence",
"(",
")",
":",
"string",
"{",
"static",
"$",
"hexChars",
"=",
"\"0123456789ABCDEFabcdef\"",
";",
"static",
"$",
"length",
"=",
"4",
";",
"$",
"sequence",
"=",
"$",
"this",
"->",
"scanWhile",
"(",
"$",
"hex... | Scans four hexadecimal characters.
@throws ParseException | [
"Scans",
"four",
"hexadecimal",
"characters",
"."
] | 83ff905fbea18c74bd438c6aa85cb3500763bfdb | https://github.com/pcrov/JsonReader/blob/83ff905fbea18c74bd438c6aa85cb3500763bfdb/src/Parser/Lexer.php#L466-L478 |
41,222 | damirka/yii2-jwt | src/UserTrait.php | UserTrait.getJWT | public function getJWT()
{
// Collect all the data
$secret = static::getSecretKey();
$currentTime = time();
$request = Yii::$app->request;
$hostInfo = '';
// There is also a \yii\console\Request that doesn't have this property
if ($request instanceof WebRequest) {
$hostInfo = $request->hostInfo;
}
// Merge token with presets not to miss any params in custom
// configuration
$token = array_merge([
'iss' => $hostInfo,
'aud' => $hostInfo,
'iat' => $currentTime,
'nbf' => $currentTime
], static::getHeaderToken());
// Set up id
$token['jti'] = $this->getJTI();
return JWT::encode($token, $secret, static::getAlgo());
} | php | public function getJWT()
{
// Collect all the data
$secret = static::getSecretKey();
$currentTime = time();
$request = Yii::$app->request;
$hostInfo = '';
// There is also a \yii\console\Request that doesn't have this property
if ($request instanceof WebRequest) {
$hostInfo = $request->hostInfo;
}
// Merge token with presets not to miss any params in custom
// configuration
$token = array_merge([
'iss' => $hostInfo,
'aud' => $hostInfo,
'iat' => $currentTime,
'nbf' => $currentTime
], static::getHeaderToken());
// Set up id
$token['jti'] = $this->getJTI();
return JWT::encode($token, $secret, static::getAlgo());
} | [
"public",
"function",
"getJWT",
"(",
")",
"{",
"// Collect all the data",
"$",
"secret",
"=",
"static",
"::",
"getSecretKey",
"(",
")",
";",
"$",
"currentTime",
"=",
"time",
"(",
")",
";",
"$",
"request",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
... | Encodes model data to create custom JWT with model.id set in it
@return string encoded JWT | [
"Encodes",
"model",
"data",
"to",
"create",
"custom",
"JWT",
"with",
"model",
".",
"id",
"set",
"in",
"it"
] | 3598863189aaec7cb93329fd11104fdfe2a6baa1 | https://github.com/damirka/yii2-jwt/blob/3598863189aaec7cb93329fd11104fdfe2a6baa1/src/UserTrait.php#L110-L136 |
41,223 | Superbalist/php-pubsub | src/Utils.php | Utils.unserializeMessagePayload | public static function unserializeMessagePayload($payload)
{
$message = json_decode($payload, true);
if (json_last_error() === JSON_ERROR_NONE) {
return $message;
}
return $payload;
} | php | public static function unserializeMessagePayload($payload)
{
$message = json_decode($payload, true);
if (json_last_error() === JSON_ERROR_NONE) {
return $message;
}
return $payload;
} | [
"public",
"static",
"function",
"unserializeMessagePayload",
"(",
"$",
"payload",
")",
"{",
"$",
"message",
"=",
"json_decode",
"(",
"$",
"payload",
",",
"true",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"===",
"JSON_ERROR_NONE",
")",
"{",
"return",
... | Unserialize the message payload.
@param string $payload
@return mixed | [
"Unserialize",
"the",
"message",
"payload",
"."
] | b2dcae00364c505266650eefb2a1374683e59cb3 | https://github.com/Superbalist/php-pubsub/blob/b2dcae00364c505266650eefb2a1374683e59cb3/src/Utils.php#L26-L34 |
41,224 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Util.php | Util.getJoomlaVersion | public static function getJoomlaVersion($base)
{
$key = md5($base);
if (!isset(self::$_versions[$key]))
{
$canonical = function($version) {
if (isset($version->RELEASE)) {
return 'v' . $version->RELEASE . '.' . $version->DEV_LEVEL;
}
// Joomla 3.5 and up uses constants instead of properties in JVersion
$className = get_class($version);
if (defined("$className::RELEASE")) {
return $version::RELEASE . '.' . $version::DEV_LEVEL;
}
return 'unknown';
};
$files = array(
'joomla-cms' => '/libraries/cms/version/version.php',
'joomla-cms-new' => '/libraries/src/Version.php', // 3.8+
'joomlatools-platform' => '/lib/libraries/cms/version/version.php',
'joomla-1.5' => '/libraries/joomla/version.php'
);
$code = false;
$application = false;
foreach ($files as $type => $file)
{
$path = $base . $file;
if (file_exists($path))
{
$code = $path;
$application = $type;
break;
}
}
if ($code !== false)
{
if (!defined('JPATH_PLATFORM')) {
define('JPATH_PLATFORM', self::buildTargetPath('/libraries', $base));
}
if (!defined('_JEXEC')) {
define('_JEXEC', 1);
}
$identifier = uniqid();
$source = file_get_contents($code);
$source = preg_replace('/<\?php/', '', $source, 1);
$pattern = $application == 'joomla-cms-new' ? '/class Version/i' : '/class JVersion/i';
$replacement = $application == 'joomla-cms-new' ? 'class Version' . $identifier : 'class JVersion' . $identifier;
$source = preg_replace($pattern, $replacement, $source);
eval($source);
$class = $application == 'joomla-cms-new' ? '\\Joomla\\CMS\\Version'.$identifier : 'JVersion'.$identifier;
$version = new $class();
self::$_versions[$key] = (object) array('release' => $canonical($version), 'type' => $application);
}
else self::$_versions[$key] = false;
}
if (!self::$_versions[$key] && self::isKodekitPlatform($base)) {
self::$_versions[$key] = (object) array('type' => 'kodekit-platform', 'release' => 'n/a');
}
return self::$_versions[$key];
} | php | public static function getJoomlaVersion($base)
{
$key = md5($base);
if (!isset(self::$_versions[$key]))
{
$canonical = function($version) {
if (isset($version->RELEASE)) {
return 'v' . $version->RELEASE . '.' . $version->DEV_LEVEL;
}
// Joomla 3.5 and up uses constants instead of properties in JVersion
$className = get_class($version);
if (defined("$className::RELEASE")) {
return $version::RELEASE . '.' . $version::DEV_LEVEL;
}
return 'unknown';
};
$files = array(
'joomla-cms' => '/libraries/cms/version/version.php',
'joomla-cms-new' => '/libraries/src/Version.php', // 3.8+
'joomlatools-platform' => '/lib/libraries/cms/version/version.php',
'joomla-1.5' => '/libraries/joomla/version.php'
);
$code = false;
$application = false;
foreach ($files as $type => $file)
{
$path = $base . $file;
if (file_exists($path))
{
$code = $path;
$application = $type;
break;
}
}
if ($code !== false)
{
if (!defined('JPATH_PLATFORM')) {
define('JPATH_PLATFORM', self::buildTargetPath('/libraries', $base));
}
if (!defined('_JEXEC')) {
define('_JEXEC', 1);
}
$identifier = uniqid();
$source = file_get_contents($code);
$source = preg_replace('/<\?php/', '', $source, 1);
$pattern = $application == 'joomla-cms-new' ? '/class Version/i' : '/class JVersion/i';
$replacement = $application == 'joomla-cms-new' ? 'class Version' . $identifier : 'class JVersion' . $identifier;
$source = preg_replace($pattern, $replacement, $source);
eval($source);
$class = $application == 'joomla-cms-new' ? '\\Joomla\\CMS\\Version'.$identifier : 'JVersion'.$identifier;
$version = new $class();
self::$_versions[$key] = (object) array('release' => $canonical($version), 'type' => $application);
}
else self::$_versions[$key] = false;
}
if (!self::$_versions[$key] && self::isKodekitPlatform($base)) {
self::$_versions[$key] = (object) array('type' => 'kodekit-platform', 'release' => 'n/a');
}
return self::$_versions[$key];
} | [
"public",
"static",
"function",
"getJoomlaVersion",
"(",
"$",
"base",
")",
"{",
"$",
"key",
"=",
"md5",
"(",
"$",
"base",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_versions",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"canonical... | Retrieve the Joomla version.
Returns an object with properties type and release.
Returns FALSE if unable to find correct version.
@param string $base Base path for the Joomla installation
@return stdclass|boolean | [
"Retrieve",
"the",
"Joomla",
"version",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Util.php#L23-L100 |
41,225 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Util.php | Util.buildTargetPath | public static function buildTargetPath($path, $base = '')
{
if (!empty($base) && substr($base, -1) == '/') {
$base = substr($base, 0, -1);
}
$path = str_replace($base, '', $path);
if (substr($path, 0, 1) != '/') {
$path = '/'.$path;
}
if (self::isPlatform($base))
{
$paths = array(
'/administrator/manifests' => '/config/manifests/',
'/administrator' => '/app/administrator',
'/components' => '/app/site/components',
'/modules' => '/app/site/modules',
'/language' => '/app/site/language',
'/media' => '/web/media',
'/plugins' => '/lib/plugins',
'/libraries' => '/lib/libraries',
'/images' => '/web/images',
'/configuration.php' => '/config/configuration.php'
);
foreach ($paths as $original => $replacement)
{
if (substr($path, 0, strlen($original)) == $original)
{
$path = $replacement . substr($path, strlen($original));
break;
}
}
}
return $base.$path;
} | php | public static function buildTargetPath($path, $base = '')
{
if (!empty($base) && substr($base, -1) == '/') {
$base = substr($base, 0, -1);
}
$path = str_replace($base, '', $path);
if (substr($path, 0, 1) != '/') {
$path = '/'.$path;
}
if (self::isPlatform($base))
{
$paths = array(
'/administrator/manifests' => '/config/manifests/',
'/administrator' => '/app/administrator',
'/components' => '/app/site/components',
'/modules' => '/app/site/modules',
'/language' => '/app/site/language',
'/media' => '/web/media',
'/plugins' => '/lib/plugins',
'/libraries' => '/lib/libraries',
'/images' => '/web/images',
'/configuration.php' => '/config/configuration.php'
);
foreach ($paths as $original => $replacement)
{
if (substr($path, 0, strlen($original)) == $original)
{
$path = $replacement . substr($path, strlen($original));
break;
}
}
}
return $base.$path;
} | [
"public",
"static",
"function",
"buildTargetPath",
"(",
"$",
"path",
",",
"$",
"base",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"base",
")",
"&&",
"substr",
"(",
"$",
"base",
",",
"-",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"base"... | Builds the full path for a given path inside a Joomla project.
If base is a Joomla Platform installation, the path will be
translated into the correct path in platform.
Example: /administrator/components/com_xyz becomes /app/administrator/components/com_xyz in platform.
@param string $path The original relative path to the file/directory
@param string $base The root directory of the Joomla installation
@return string Target path | [
"Builds",
"the",
"full",
"path",
"for",
"a",
"given",
"path",
"inside",
"a",
"Joomla",
"project",
".",
"If",
"base",
"is",
"a",
"Joomla",
"Platform",
"installation",
"the",
"path",
"will",
"be",
"translated",
"into",
"the",
"correct",
"path",
"in",
"platfo... | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Util.php#L159-L197 |
41,226 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Util.php | Util.isJoomlatoolsBox | public static function isJoomlatoolsBox()
{
if (php_uname('n') === 'joomlatools') {
return true;
}
// Support boxes that do not have the correct hostname set
$user = exec('whoami');
if (trim($user) == 'vagrant' && file_exists('/home/vagrant/scripts/dashboard/index.php'))
{
if (file_exists('/etc/varnish/default.vcl')) {
return true;
}
}
return false;
} | php | public static function isJoomlatoolsBox()
{
if (php_uname('n') === 'joomlatools') {
return true;
}
// Support boxes that do not have the correct hostname set
$user = exec('whoami');
if (trim($user) == 'vagrant' && file_exists('/home/vagrant/scripts/dashboard/index.php'))
{
if (file_exists('/etc/varnish/default.vcl')) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"isJoomlatoolsBox",
"(",
")",
"{",
"if",
"(",
"php_uname",
"(",
"'n'",
")",
"===",
"'joomlatools'",
")",
"{",
"return",
"true",
";",
"}",
"// Support boxes that do not have the correct hostname set",
"$",
"user",
"=",
"exec",
"(",
... | Determine if we are running from inside the Joomlatools Box environment.
Only boxes >= 1.4.0 can be recognized.
@return boolean true|false | [
"Determine",
"if",
"we",
"are",
"running",
"from",
"inside",
"the",
"Joomlatools",
"Box",
"environment",
".",
"Only",
"boxes",
">",
"=",
"1",
".",
"4",
".",
"0",
"can",
"be",
"recognized",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Util.php#L205-L221 |
41,227 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Util.php | Util.getTemplatePath | public static function getTemplatePath()
{
$path = \Phar::running();
if (!empty($path)) {
return $path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . '.files';
}
$root = dirname(dirname(dirname(dirname(__DIR__))));
return realpath($root .DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . '.files');
} | php | public static function getTemplatePath()
{
$path = \Phar::running();
if (!empty($path)) {
return $path . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . '.files';
}
$root = dirname(dirname(dirname(dirname(__DIR__))));
return realpath($root .DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . '.files');
} | [
"public",
"static",
"function",
"getTemplatePath",
"(",
")",
"{",
"$",
"path",
"=",
"\\",
"Phar",
"::",
"running",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"'bin'... | Get template directory path
@return string | [
"Get",
"template",
"directory",
"path"
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Util.php#L244-L255 |
41,228 | dmkit/phalcon-jwt-auth | src/Phalcon/Auth/Middleware/Micro.php | Micro.setEventChecker | protected function setEventChecker()
{
$diName = self::$diName;
$eventsManager = $this->app->getEventsManager() ?? new EventsManager();
$eventsManager->attach(
"micro:beforeExecuteRoute",
function (Event $event, $app) use($diName) {
$auth = $app[$diName];
// check if it has CORS support
if ($auth->isIgnoreOptionsMethod() && $app['request']->getMethod() == 'OPTIONS') {
return true;
}
if($auth->isIgnoreUri()) {
/**
* Let's try to parse if there's a token
* but we don't want to get an invalid token
*/
if( !$auth->check() && $this->getMessages()[0] != 'missing token')
{
return $auth->unauthorized();
}
return true;
}
if($auth->check()) {
return true;
}
return $auth->unauthorized();
}
);
$this->app->setEventsManager($eventsManager);
} | php | protected function setEventChecker()
{
$diName = self::$diName;
$eventsManager = $this->app->getEventsManager() ?? new EventsManager();
$eventsManager->attach(
"micro:beforeExecuteRoute",
function (Event $event, $app) use($diName) {
$auth = $app[$diName];
// check if it has CORS support
if ($auth->isIgnoreOptionsMethod() && $app['request']->getMethod() == 'OPTIONS') {
return true;
}
if($auth->isIgnoreUri()) {
/**
* Let's try to parse if there's a token
* but we don't want to get an invalid token
*/
if( !$auth->check() && $this->getMessages()[0] != 'missing token')
{
return $auth->unauthorized();
}
return true;
}
if($auth->check()) {
return true;
}
return $auth->unauthorized();
}
);
$this->app->setEventsManager($eventsManager);
} | [
"protected",
"function",
"setEventChecker",
"(",
")",
"{",
"$",
"diName",
"=",
"self",
"::",
"$",
"diName",
";",
"$",
"eventsManager",
"=",
"$",
"this",
"->",
"app",
"->",
"getEventsManager",
"(",
")",
"??",
"new",
"EventsManager",
"(",
")",
";",
"$",
... | Sets event authentication. | [
"Sets",
"event",
"authentication",
"."
] | 1f4db19a7da8924832e482e4cc37471c5e61b8c2 | https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/Middleware/Micro.php#L136-L173 |
41,229 | dmkit/phalcon-jwt-auth | src/Phalcon/Auth/Middleware/Micro.php | Micro.isIgnoreUri | public function isIgnoreUri()
{
if(!$this->ignoreUri) {
return false;
}
// access request object
$request = $this->app['request'];
// url
$uri = $request->getURI();
// http method
$method = $request->getMethod();
return $this->hasMatchIgnoreUri($uri, $method);
} | php | public function isIgnoreUri()
{
if(!$this->ignoreUri) {
return false;
}
// access request object
$request = $this->app['request'];
// url
$uri = $request->getURI();
// http method
$method = $request->getMethod();
return $this->hasMatchIgnoreUri($uri, $method);
} | [
"public",
"function",
"isIgnoreUri",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ignoreUri",
")",
"{",
"return",
"false",
";",
"}",
"// access request object",
"$",
"request",
"=",
"$",
"this",
"->",
"app",
"[",
"'request'",
"]",
";",
"// url",
... | Checks if the URI and HTTP METHOD can bypass the authentication.
@return bool | [
"Checks",
"if",
"the",
"URI",
"and",
"HTTP",
"METHOD",
"can",
"bypass",
"the",
"authentication",
"."
] | 1f4db19a7da8924832e482e4cc37471c5e61b8c2 | https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/Middleware/Micro.php#L210-L226 |
41,230 | joomlatools/joomlatools-console | src/Joomlatools/Console/Application.php | Application.getPluginPath | public function getPluginPath()
{
if (empty($this->_plugin_path)) {
$this->_plugin_path = $this->getConsoleHome() . '/plugins';
}
return $this->_plugin_path;
} | php | public function getPluginPath()
{
if (empty($this->_plugin_path)) {
$this->_plugin_path = $this->getConsoleHome() . '/plugins';
}
return $this->_plugin_path;
} | [
"public",
"function",
"getPluginPath",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_plugin_path",
")",
")",
"{",
"$",
"this",
"->",
"_plugin_path",
"=",
"$",
"this",
"->",
"getConsoleHome",
"(",
")",
".",
"'/plugins'",
";",
"}",
"return... | Get the plugin path
@return string Path to the plugins directory | [
"Get",
"the",
"plugin",
"path"
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Application.php#L100-L107 |
41,231 | joomlatools/joomlatools-console | src/Joomlatools/Console/Application.php | Application.getPlugins | public function getPlugins()
{
if (!$this->_plugins) {
$manifest = $this->getPluginPath() . '/composer.json';
if (!file_exists($manifest)) {
return array();
}
$contents = file_get_contents($manifest);
if ($contents === false) {
return array();
}
$data = json_decode($contents);
if (!isset($data->require)) {
return array();
}
$this->_plugins = array();
foreach ($data->require as $package => $version)
{
$file = $this->getPluginPath() . '/vendor/' . $package . '/composer.json';
if (file_exists($file))
{
$json = file_get_contents($file);
$manifest = json_decode($json);
if (is_null($manifest)) {
continue;
}
if (isset($manifest->type) && $manifest->type == 'joomlatools-console-plugin') {
$this->_plugins[$package] = $version;
}
}
}
}
return $this->_plugins;
} | php | public function getPlugins()
{
if (!$this->_plugins) {
$manifest = $this->getPluginPath() . '/composer.json';
if (!file_exists($manifest)) {
return array();
}
$contents = file_get_contents($manifest);
if ($contents === false) {
return array();
}
$data = json_decode($contents);
if (!isset($data->require)) {
return array();
}
$this->_plugins = array();
foreach ($data->require as $package => $version)
{
$file = $this->getPluginPath() . '/vendor/' . $package . '/composer.json';
if (file_exists($file))
{
$json = file_get_contents($file);
$manifest = json_decode($json);
if (is_null($manifest)) {
continue;
}
if (isset($manifest->type) && $manifest->type == 'joomlatools-console-plugin') {
$this->_plugins[$package] = $version;
}
}
}
}
return $this->_plugins;
} | [
"public",
"function",
"getPlugins",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_plugins",
")",
"{",
"$",
"manifest",
"=",
"$",
"this",
"->",
"getPluginPath",
"(",
")",
".",
"'/composer.json'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"ma... | Get the list of installed plugin packages.
@return array Array of package names as key and their version as value | [
"Get",
"the",
"list",
"of",
"installed",
"plugin",
"packages",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Application.php#L165-L210 |
41,232 | joomlatools/joomlatools-console | src/Joomlatools/Console/Application.php | Application._loadPlugins | protected function _loadPlugins()
{
$autoloader = $this->getPluginPath() . '/vendor/autoload.php';
if (file_exists($autoloader)) {
require_once $autoloader;
}
$plugins = $this->getPlugins();
$classes = array();
foreach ($plugins as $package => $version)
{
$path = $this->getPluginPath() . '/vendor/' . $package;
$directories = glob($path.'/*/Console/Command', GLOB_ONLYDIR);
foreach ($directories as $directory)
{
$vendor = substr($directory, strlen($path) + 1, strlen('/Console/Command') * -1);
$iterator = new \DirectoryIterator($directory);
foreach ($iterator as $file)
{
if ($file->getExtension() == 'php') {
$classes[] = sprintf('%s\Console\Command\%s', $vendor, $file->getBasename('.php'));
}
}
}
}
foreach ($classes as $class)
{
if (class_exists($class))
{
$command = new $class();
if (!$command instanceof \Symfony\Component\Console\Command\Command) {
continue;
}
$name = $command->getName();
if(!$this->has($name)) {
$this->add($command);
}
else $this->_output->writeln("<fg=yellow;options=bold>Notice:</fg=yellow;options=bold> The '$class' command wants to register the '$name' command but it already exists, ignoring.");
}
}
} | php | protected function _loadPlugins()
{
$autoloader = $this->getPluginPath() . '/vendor/autoload.php';
if (file_exists($autoloader)) {
require_once $autoloader;
}
$plugins = $this->getPlugins();
$classes = array();
foreach ($plugins as $package => $version)
{
$path = $this->getPluginPath() . '/vendor/' . $package;
$directories = glob($path.'/*/Console/Command', GLOB_ONLYDIR);
foreach ($directories as $directory)
{
$vendor = substr($directory, strlen($path) + 1, strlen('/Console/Command') * -1);
$iterator = new \DirectoryIterator($directory);
foreach ($iterator as $file)
{
if ($file->getExtension() == 'php') {
$classes[] = sprintf('%s\Console\Command\%s', $vendor, $file->getBasename('.php'));
}
}
}
}
foreach ($classes as $class)
{
if (class_exists($class))
{
$command = new $class();
if (!$command instanceof \Symfony\Component\Console\Command\Command) {
continue;
}
$name = $command->getName();
if(!$this->has($name)) {
$this->add($command);
}
else $this->_output->writeln("<fg=yellow;options=bold>Notice:</fg=yellow;options=bold> The '$class' command wants to register the '$name' command but it already exists, ignoring.");
}
}
} | [
"protected",
"function",
"_loadPlugins",
"(",
")",
"{",
"$",
"autoloader",
"=",
"$",
"this",
"->",
"getPluginPath",
"(",
")",
".",
"'/vendor/autoload.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"autoloader",
")",
")",
"{",
"require_once",
"$",
"autoloade... | Loads plugins into the application. | [
"Loads",
"plugins",
"into",
"the",
"application",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Application.php#L244-L292 |
41,233 | dmkit/phalcon-jwt-auth | src/Phalcon/Auth/Auth.php | Auth.check | public function check(TokenGetter $parser, string $key) : bool
{
$token = $parser->parse();
if(!$token) {
$this->appendMessage('missing token');
return false;
}
$payload = $this->decode($token, $key);
if(!$payload || empty($payload)) {
return false;
}
$this->payload = $payload;
// if any of the callback return false, this will immediately return false
foreach($this->_onCheckCb as $callback) {
if( $callback($this) === false ) {
return false;
}
}
return true;
} | php | public function check(TokenGetter $parser, string $key) : bool
{
$token = $parser->parse();
if(!$token) {
$this->appendMessage('missing token');
return false;
}
$payload = $this->decode($token, $key);
if(!$payload || empty($payload)) {
return false;
}
$this->payload = $payload;
// if any of the callback return false, this will immediately return false
foreach($this->_onCheckCb as $callback) {
if( $callback($this) === false ) {
return false;
}
}
return true;
} | [
"public",
"function",
"check",
"(",
"TokenGetter",
"$",
"parser",
",",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"$",
"token",
"=",
"$",
"parser",
"->",
"parse",
"(",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"append... | Checks and validates JWT.
Calls the oncheck callbacks and pass self as parameter.
@param Dmkit\Phalcon\Auth\TokenGetter\AdapterInterface $parser
@param string $key
@return bool | [
"Checks",
"and",
"validates",
"JWT",
".",
"Calls",
"the",
"oncheck",
"callbacks",
"and",
"pass",
"self",
"as",
"parameter",
"."
] | 1f4db19a7da8924832e482e4cc37471c5e61b8c2 | https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/Auth.php#L50-L74 |
41,234 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Application.php | Application.hasExtension | public function hasExtension($element, $type = 'component')
{
$db = JFactory::getDbo();
$sql = "SELECT `extension_id`, `state` FROM `#__extensions`"
." WHERE `element` = ".$db->quote($element)." AND `type` = ".$db->quote($type);
$extension = $db->setQuery($sql)->loadObject();
return ($extension && $extension->state != -1);
} | php | public function hasExtension($element, $type = 'component')
{
$db = JFactory::getDbo();
$sql = "SELECT `extension_id`, `state` FROM `#__extensions`"
." WHERE `element` = ".$db->quote($element)." AND `type` = ".$db->quote($type);
$extension = $db->setQuery($sql)->loadObject();
return ($extension && $extension->state != -1);
} | [
"public",
"function",
"hasExtension",
"(",
"$",
"element",
",",
"$",
"type",
"=",
"'component'",
")",
"{",
"$",
"db",
"=",
"JFactory",
"::",
"getDbo",
"(",
")",
";",
"$",
"sql",
"=",
"\"SELECT `extension_id`, `state` FROM `#__extensions`\"",
".",
"\" WHERE `elem... | Checks if this Joomla installation has a certain element installed.
@param string $element The name of the element
@param string $type The type of extension
@return bool | [
"Checks",
"if",
"this",
"Joomla",
"installation",
"has",
"a",
"certain",
"element",
"installed",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Application.php#L138-L147 |
41,235 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Application.php | Application.getName | public function getName()
{
$name = '';
switch ($this->_clientId)
{
case Bootstrapper::SITE:
$name = 'site';
break;
case Bootstrapper::ADMIN:
$name = 'administrator';
break;
default:
$name = 'cli';
break;
}
return $name;
} | php | public function getName()
{
$name = '';
switch ($this->_clientId)
{
case Bootstrapper::SITE:
$name = 'site';
break;
case Bootstrapper::ADMIN:
$name = 'administrator';
break;
default:
$name = 'cli';
break;
}
return $name;
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"$",
"name",
"=",
"''",
";",
"switch",
"(",
"$",
"this",
"->",
"_clientId",
")",
"{",
"case",
"Bootstrapper",
"::",
"SITE",
":",
"$",
"name",
"=",
"'site'",
";",
"break",
";",
"case",
"Bootstrapper",
":... | Get the current application name.
@return string | [
"Get",
"the",
"current",
"application",
"name",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Application.php#L257-L275 |
41,236 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Application.php | Application.fetchConfigurationData | protected function fetchConfigurationData($file = '', $class = 'JConfig')
{
$config = parent::fetchConfigurationData($file, $class);
// Inject the root user configuration
if(isset($this->_options['root_user']))
{
$root_user = isset($this->_options['root_user']) ? $this->_options['root_user'] : 'root';
if (is_array($config)) {
$config['root_user'] = $root_user;
}
elseif (is_object($config)) {
$config->root_user = $root_user;
}
}
return $config;
} | php | protected function fetchConfigurationData($file = '', $class = 'JConfig')
{
$config = parent::fetchConfigurationData($file, $class);
// Inject the root user configuration
if(isset($this->_options['root_user']))
{
$root_user = isset($this->_options['root_user']) ? $this->_options['root_user'] : 'root';
if (is_array($config)) {
$config['root_user'] = $root_user;
}
elseif (is_object($config)) {
$config->root_user = $root_user;
}
}
return $config;
} | [
"protected",
"function",
"fetchConfigurationData",
"(",
"$",
"file",
"=",
"''",
",",
"$",
"class",
"=",
"'JConfig'",
")",
"{",
"$",
"config",
"=",
"parent",
"::",
"fetchConfigurationData",
"(",
"$",
"file",
",",
"$",
"class",
")",
";",
"// Inject the root us... | Method to load a PHP configuration class file based on convention and return the instantiated data object. You
will extend this method in child classes to provide configuration data from whatever data source is relevant
for your specific application.
Additionally injects the root_user into the configuration.
@param string $file The path and filename of the configuration file. If not provided, configuration.php
in JPATH_BASE will be used.
@param string $class The class name to instantiate.
@return mixed Either an array or object to be loaded into the configuration object.
@since 11.1 | [
"Method",
"to",
"load",
"a",
"PHP",
"configuration",
"class",
"file",
"based",
"on",
"convention",
"and",
"return",
"the",
"instantiated",
"data",
"object",
".",
"You",
"will",
"extend",
"this",
"method",
"in",
"child",
"classes",
"to",
"provide",
"configurati... | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Application.php#L365-L383 |
41,237 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Application.php | Application._startSession | protected function _startSession()
{
$name = md5($this->getCfg('secret') . get_class($this));
$lifetime = $this->getCfg('lifetime') * 60 ;
$handler = $this->getCfg('session_handler', 'none');
$options = array(
'name' => $name,
'expire' => $lifetime
);
$session = JSession::getInstance($handler, $options);
$session->initialise($this->input, $this->dispatcher);
if ($session->getState() == 'expired') {
$session->restart();
} else {
$session->start();
}
return $session;
} | php | protected function _startSession()
{
$name = md5($this->getCfg('secret') . get_class($this));
$lifetime = $this->getCfg('lifetime') * 60 ;
$handler = $this->getCfg('session_handler', 'none');
$options = array(
'name' => $name,
'expire' => $lifetime
);
$session = JSession::getInstance($handler, $options);
$session->initialise($this->input, $this->dispatcher);
if ($session->getState() == 'expired') {
$session->restart();
} else {
$session->start();
}
return $session;
} | [
"protected",
"function",
"_startSession",
"(",
")",
"{",
"$",
"name",
"=",
"md5",
"(",
"$",
"this",
"->",
"getCfg",
"(",
"'secret'",
")",
".",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"lifetime",
"=",
"$",
"this",
"->",
"getCfg",
"(",
"'l... | Creates a new Joomla session.
@return JSession | [
"Creates",
"a",
"new",
"Joomla",
"session",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Application.php#L390-L411 |
41,238 | joomlatools/joomlatools-console | src/Joomlatools/Console/Joomla/Application.php | Application.getMenu | public function getMenu($name = null, $options = array())
{
if (!isset($name))
{
$app = JFactory::getApplication();
$name = $app->getName();
}
try
{
if (!class_exists('JMenu' . ucfirst($name))) {
jimport('cms.menu.'.strtolower($name));
}
$menu = JMenu::getInstance($name, $options);
}
catch (Exception $e) {
return null;
}
return $menu;
} | php | public function getMenu($name = null, $options = array())
{
if (!isset($name))
{
$app = JFactory::getApplication();
$name = $app->getName();
}
try
{
if (!class_exists('JMenu' . ucfirst($name))) {
jimport('cms.menu.'.strtolower($name));
}
$menu = JMenu::getInstance($name, $options);
}
catch (Exception $e) {
return null;
}
return $menu;
} | [
"public",
"function",
"getMenu",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"$",
"app",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
";",
... | Returns the application JMenu object.
@param string $name The name of the application/client.
@param array $options An optional associative array of configuration settings.
@return JMenu | [
"Returns",
"the",
"application",
"JMenu",
"object",
"."
] | 2911032c1dba27dcedc0b802717fe9ade6301239 | https://github.com/joomlatools/joomlatools-console/blob/2911032c1dba27dcedc0b802717fe9ade6301239/src/Joomlatools/Console/Joomla/Application.php#L534-L555 |
41,239 | dmkit/phalcon-jwt-auth | src/Phalcon/Auth/TokenGetter/Handler/Header.php | Header.parse | public function parse() : string
{
$raw_token = $this->_Request->getHeader($this->key);
if(!$raw_token) {
return '';
}
return trim( str_ireplace($this->prefix, '', $raw_token));
} | php | public function parse() : string
{
$raw_token = $this->_Request->getHeader($this->key);
if(!$raw_token) {
return '';
}
return trim( str_ireplace($this->prefix, '', $raw_token));
} | [
"public",
"function",
"parse",
"(",
")",
":",
"string",
"{",
"$",
"raw_token",
"=",
"$",
"this",
"->",
"_Request",
"->",
"getHeader",
"(",
"$",
"this",
"->",
"key",
")",
";",
"if",
"(",
"!",
"$",
"raw_token",
")",
"{",
"return",
"''",
";",
"}",
"... | Gets the token from the headers
@return string | [
"Gets",
"the",
"token",
"from",
"the",
"headers"
] | 1f4db19a7da8924832e482e4cc37471c5e61b8c2 | https://github.com/dmkit/phalcon-jwt-auth/blob/1f4db19a7da8924832e482e4cc37471c5e61b8c2/src/Phalcon/Auth/TokenGetter/Handler/Header.php#L24-L33 |
41,240 | 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 |
41,241 | 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 |
41,242 | 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 |
41,243 | 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 |
41,244 | 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 |
41,245 | 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 |
41,246 | 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 |
41,247 | 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 |
41,248 | 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 |
41,249 | 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 |
41,250 | 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 |
41,251 | 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 |
41,252 | 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 |
41,253 | 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 |
41,254 | 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 |
41,255 | 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 |
41,256 | 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 |
41,257 | 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 |
41,258 | 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 |
41,259 | 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 |
41,260 | 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 |
41,261 | 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 |
41,262 | 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 |
41,263 | 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 |
41,264 | 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 |
41,265 | 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 |
41,266 | 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 |
41,267 | 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 |
41,268 | 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 |
41,269 | 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 |
41,270 | 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 |
41,271 | 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 |
41,272 | 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 |
41,273 | 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 |
41,274 | 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 |
41,275 | 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 |
41,276 | 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 |
41,277 | 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 |
41,278 | 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 |
41,279 | 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 |
41,280 | 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 |
41,281 | 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 |
41,282 | 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 |
41,283 | 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 |
41,284 | 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 |
41,285 | 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 |
41,286 | 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 |
41,287 | 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 |
41,288 | 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 |
41,289 | 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 |
41,290 | 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 |
41,291 | 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 |
41,292 | 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 |
41,293 | 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 |
41,294 | 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 |
41,295 | 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 |
41,296 | 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 |
41,297 | 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 |
41,298 | 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 |
41,299 | 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 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.