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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
1,500 | wasabi-cms/core | src/Controller/GroupPermissionsController.php | GroupPermissionsController.sync | public function sync()
{
$actionMap = $this->Guardian->getActionMap();
// check existance of all permission entries for each individual group
/** @var Query $groups */
$groups = $this->GroupPermissions->Groups->find('all')
->where(['Groups.id <>' => 1]);// ignore Administrator group
/** @var Connection $connection */
$connection = $this->GroupPermissions->connection();
$connection->begin();
// delete guest actions
$this->GroupPermissions->deleteAll([
'path IN' => $this->Guardian->getGuestActions()
]);
foreach ($groups as $group) {
try {
$this->GroupPermissions->createMissingPermissions($group->id, $actionMap);
$this->GroupPermissions->deleteOrphans($group->id, $actionMap);
} catch (Exception $e) {
$connection->rollback();
}
}
if ($connection->inTransaction()) {
$connection->commit();
}
// delete guardian path cache
$this->eventManager()->dispatch(new Event('Guardian.GroupPermissions.afterSync'));
$this->Flash->success(__d('wasabi_core', 'All permissions have been synchronized.'));
$this->redirect(['action' => 'index']);
//@codingStandardIgnoreStart
return;
//@codingStandardIgnoreEnd
} | php | public function sync()
{
$actionMap = $this->Guardian->getActionMap();
// check existance of all permission entries for each individual group
/** @var Query $groups */
$groups = $this->GroupPermissions->Groups->find('all')
->where(['Groups.id <>' => 1]);// ignore Administrator group
/** @var Connection $connection */
$connection = $this->GroupPermissions->connection();
$connection->begin();
// delete guest actions
$this->GroupPermissions->deleteAll([
'path IN' => $this->Guardian->getGuestActions()
]);
foreach ($groups as $group) {
try {
$this->GroupPermissions->createMissingPermissions($group->id, $actionMap);
$this->GroupPermissions->deleteOrphans($group->id, $actionMap);
} catch (Exception $e) {
$connection->rollback();
}
}
if ($connection->inTransaction()) {
$connection->commit();
}
// delete guardian path cache
$this->eventManager()->dispatch(new Event('Guardian.GroupPermissions.afterSync'));
$this->Flash->success(__d('wasabi_core', 'All permissions have been synchronized.'));
$this->redirect(['action' => 'index']);
//@codingStandardIgnoreStart
return;
//@codingStandardIgnoreEnd
} | [
"public",
"function",
"sync",
"(",
")",
"{",
"$",
"actionMap",
"=",
"$",
"this",
"->",
"Guardian",
"->",
"getActionMap",
"(",
")",
";",
"// check existance of all permission entries for each individual group",
"/** @var Query $groups */",
"$",
"groups",
"=",
"$",
"this",
"->",
"GroupPermissions",
"->",
"Groups",
"->",
"find",
"(",
"'all'",
")",
"->",
"where",
"(",
"[",
"'Groups.id <>'",
"=>",
"1",
"]",
")",
";",
"// ignore Administrator group",
"/** @var Connection $connection */",
"$",
"connection",
"=",
"$",
"this",
"->",
"GroupPermissions",
"->",
"connection",
"(",
")",
";",
"$",
"connection",
"->",
"begin",
"(",
")",
";",
"// delete guest actions",
"$",
"this",
"->",
"GroupPermissions",
"->",
"deleteAll",
"(",
"[",
"'path IN'",
"=>",
"$",
"this",
"->",
"Guardian",
"->",
"getGuestActions",
"(",
")",
"]",
")",
";",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"GroupPermissions",
"->",
"createMissingPermissions",
"(",
"$",
"group",
"->",
"id",
",",
"$",
"actionMap",
")",
";",
"$",
"this",
"->",
"GroupPermissions",
"->",
"deleteOrphans",
"(",
"$",
"group",
"->",
"id",
",",
"$",
"actionMap",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"connection",
"->",
"rollback",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"connection",
"->",
"inTransaction",
"(",
")",
")",
"{",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"}",
"// delete guardian path cache",
"$",
"this",
"->",
"eventManager",
"(",
")",
"->",
"dispatch",
"(",
"new",
"Event",
"(",
"'Guardian.GroupPermissions.afterSync'",
")",
")",
";",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"__d",
"(",
"'wasabi_core'",
",",
"'All permissions have been synchronized.'",
")",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'index'",
"]",
")",
";",
"//@codingStandardIgnoreStart",
"return",
";",
"//@codingStandardIgnoreEnd",
"}"
] | Sync action
GET
@return void | [
"Sync",
"action",
"GET"
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/GroupPermissionsController.php#L84-L122 |
1,501 | wasabi-cms/core | src/Controller/GroupPermissionsController.php | GroupPermissionsController.update | public function update()
{
if (!$this->request->is('post')) {
if ($this->request->is('ajax')) {
throw new MethodNotAllowedException();
} else {
$this->Flash->error($this->invalidRequestMessage);
$this->redirect(['action' => 'index']);
return;
}
}
if (empty($this->request->data) && !$this->request->is('ajax')) {
$this->Flash->warning(__d('wasabi_core', 'There are no permissions to update yet.'));
$this->redirect(['action' => 'index']);
return;
}
// save the new language positions
$permissions = $this->GroupPermissions->patchEntities(
$this->GroupPermissions->find('all'),
$this->request->data
);
/** @var Connection $connection */
$connection = $this->GroupPermissions->connection();
$connection->begin();
foreach ($permissions as $permission) {
if (!$this->GroupPermissions->save($permission)) {
$connection->rollback();
break;
}
}
if ($connection->inTransaction()) {
$connection->commit();
Cache::clear(false, 'wasabi/core/group_permissions');
if ($this->request->is('ajax')) {
$status = 'success';
$this->set(compact('status'));
$this->set('_serialize', ['status']);
} else {
$this->Flash->success(__d('wasabi_core', 'All permissions have been saved.'));
$this->redirect(['action' => 'index']);
return;
}
} else {
$this->Flash->error($this->dbErrorMessage);
}
} | php | public function update()
{
if (!$this->request->is('post')) {
if ($this->request->is('ajax')) {
throw new MethodNotAllowedException();
} else {
$this->Flash->error($this->invalidRequestMessage);
$this->redirect(['action' => 'index']);
return;
}
}
if (empty($this->request->data) && !$this->request->is('ajax')) {
$this->Flash->warning(__d('wasabi_core', 'There are no permissions to update yet.'));
$this->redirect(['action' => 'index']);
return;
}
// save the new language positions
$permissions = $this->GroupPermissions->patchEntities(
$this->GroupPermissions->find('all'),
$this->request->data
);
/** @var Connection $connection */
$connection = $this->GroupPermissions->connection();
$connection->begin();
foreach ($permissions as $permission) {
if (!$this->GroupPermissions->save($permission)) {
$connection->rollback();
break;
}
}
if ($connection->inTransaction()) {
$connection->commit();
Cache::clear(false, 'wasabi/core/group_permissions');
if ($this->request->is('ajax')) {
$status = 'success';
$this->set(compact('status'));
$this->set('_serialize', ['status']);
} else {
$this->Flash->success(__d('wasabi_core', 'All permissions have been saved.'));
$this->redirect(['action' => 'index']);
return;
}
} else {
$this->Flash->error($this->dbErrorMessage);
}
} | [
"public",
"function",
"update",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'post'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
")",
"{",
"throw",
"new",
"MethodNotAllowedException",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"invalidRequestMessage",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'index'",
"]",
")",
";",
"return",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"data",
")",
"&&",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
")",
"{",
"$",
"this",
"->",
"Flash",
"->",
"warning",
"(",
"__d",
"(",
"'wasabi_core'",
",",
"'There are no permissions to update yet.'",
")",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'index'",
"]",
")",
";",
"return",
";",
"}",
"// save the new language positions",
"$",
"permissions",
"=",
"$",
"this",
"->",
"GroupPermissions",
"->",
"patchEntities",
"(",
"$",
"this",
"->",
"GroupPermissions",
"->",
"find",
"(",
"'all'",
")",
",",
"$",
"this",
"->",
"request",
"->",
"data",
")",
";",
"/** @var Connection $connection */",
"$",
"connection",
"=",
"$",
"this",
"->",
"GroupPermissions",
"->",
"connection",
"(",
")",
";",
"$",
"connection",
"->",
"begin",
"(",
")",
";",
"foreach",
"(",
"$",
"permissions",
"as",
"$",
"permission",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"GroupPermissions",
"->",
"save",
"(",
"$",
"permission",
")",
")",
"{",
"$",
"connection",
"->",
"rollback",
"(",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"connection",
"->",
"inTransaction",
"(",
")",
")",
"{",
"$",
"connection",
"->",
"commit",
"(",
")",
";",
"Cache",
"::",
"clear",
"(",
"false",
",",
"'wasabi/core/group_permissions'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
")",
"{",
"$",
"status",
"=",
"'success'",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'status'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"[",
"'status'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"success",
"(",
"__d",
"(",
"'wasabi_core'",
",",
"'All permissions have been saved.'",
")",
")",
";",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'action'",
"=>",
"'index'",
"]",
")",
";",
"return",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"Flash",
"->",
"error",
"(",
"$",
"this",
"->",
"dbErrorMessage",
")",
";",
"}",
"}"
] | Update action
POST | AJAX
@return void | [
"Update",
"action",
"POST",
"|",
"AJAX"
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/GroupPermissionsController.php#L130-L179 |
1,502 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/tasks/simple2orm.php | Simple2orm.run | public static function run()
{
// fetch the commandline options
$run_migration = \Cli::option('migrate', \Cli::option('m', false));
$run_validation = $run_migration ? true : \Cli::option('validate', \Cli::option('v', false));
// if no run options are present, show the help
if ( ! $run_migration and ! $run_validation )
{
return static::help();
}
// step 1: run validation
$validated = true;
if ($run_validation)
{
$validated = static::run_validation();
}
// step 2: run migration
if ($run_migration)
{
if ($validated)
{
$migrated = static::run_migration();
if ($migrated)
{
\Cli::write('Migration succesfully finished', 'light_green');
}
else
{
\Cli::write("\n".'Migration failed. Skipping the remainder of the migration. Please correct the errors and run again.', 'light_red');
}
}
else
{
\Cli::write("\n".'Validation failed. Skipping the actual migration. Please correct the errors.', 'light_red');
}
}
} | php | public static function run()
{
// fetch the commandline options
$run_migration = \Cli::option('migrate', \Cli::option('m', false));
$run_validation = $run_migration ? true : \Cli::option('validate', \Cli::option('v', false));
// if no run options are present, show the help
if ( ! $run_migration and ! $run_validation )
{
return static::help();
}
// step 1: run validation
$validated = true;
if ($run_validation)
{
$validated = static::run_validation();
}
// step 2: run migration
if ($run_migration)
{
if ($validated)
{
$migrated = static::run_migration();
if ($migrated)
{
\Cli::write('Migration succesfully finished', 'light_green');
}
else
{
\Cli::write("\n".'Migration failed. Skipping the remainder of the migration. Please correct the errors and run again.', 'light_red');
}
}
else
{
\Cli::write("\n".'Validation failed. Skipping the actual migration. Please correct the errors.', 'light_red');
}
}
} | [
"public",
"static",
"function",
"run",
"(",
")",
"{",
"// fetch the commandline options",
"$",
"run_migration",
"=",
"\\",
"Cli",
"::",
"option",
"(",
"'migrate'",
",",
"\\",
"Cli",
"::",
"option",
"(",
"'m'",
",",
"false",
")",
")",
";",
"$",
"run_validation",
"=",
"$",
"run_migration",
"?",
"true",
":",
"\\",
"Cli",
"::",
"option",
"(",
"'validate'",
",",
"\\",
"Cli",
"::",
"option",
"(",
"'v'",
",",
"false",
")",
")",
";",
"// if no run options are present, show the help",
"if",
"(",
"!",
"$",
"run_migration",
"and",
"!",
"$",
"run_validation",
")",
"{",
"return",
"static",
"::",
"help",
"(",
")",
";",
"}",
"// step 1: run validation",
"$",
"validated",
"=",
"true",
";",
"if",
"(",
"$",
"run_validation",
")",
"{",
"$",
"validated",
"=",
"static",
"::",
"run_validation",
"(",
")",
";",
"}",
"// step 2: run migration",
"if",
"(",
"$",
"run_migration",
")",
"{",
"if",
"(",
"$",
"validated",
")",
"{",
"$",
"migrated",
"=",
"static",
"::",
"run_migration",
"(",
")",
";",
"if",
"(",
"$",
"migrated",
")",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"'Migration succesfully finished'",
",",
"'light_green'",
")",
";",
"}",
"else",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"\"\\n\"",
".",
"'Migration failed. Skipping the remainder of the migration. Please correct the errors and run again.'",
",",
"'light_red'",
")",
";",
"}",
"}",
"else",
"{",
"\\",
"Cli",
"::",
"write",
"(",
"\"\\n\"",
".",
"'Validation failed. Skipping the actual migration. Please correct the errors.'",
",",
"'light_red'",
")",
";",
"}",
"}",
"}"
] | Show help.
Usage (from command line):
php oil refine simple2orm | [
"Show",
"help",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/tasks/simple2orm.php#L34-L73 |
1,503 | emaphp/eMapper | lib/eMapper/Statement/Configuration/StatementConfiguration.php | StatementConfiguration.type | public function type($mapping_type) {
$args = func_get_args();
$mapping_type = array_shift($args);
//check if mapping arguments are defined
if (empty($args))
return $this->merge(['map.type' => $mapping_type]);
return $this->merge(['map.type' => $mapping_type, 'map.params' => $args]);
} | php | public function type($mapping_type) {
$args = func_get_args();
$mapping_type = array_shift($args);
//check if mapping arguments are defined
if (empty($args))
return $this->merge(['map.type' => $mapping_type]);
return $this->merge(['map.type' => $mapping_type, 'map.params' => $args]);
} | [
"public",
"function",
"type",
"(",
"$",
"mapping_type",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"mapping_type",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"//check if mapping arguments are defined",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"return",
"$",
"this",
"->",
"merge",
"(",
"[",
"'map.type'",
"=>",
"$",
"mapping_type",
"]",
")",
";",
"return",
"$",
"this",
"->",
"merge",
"(",
"[",
"'map.type'",
"=>",
"$",
"mapping_type",
",",
"'map.params'",
"=>",
"$",
"args",
"]",
")",
";",
"}"
] | Sets result mapping options
@param string $mapping_type
@return \eMapper\Statement\Configuration\StatementConfiguration | [
"Sets",
"result",
"mapping",
"options"
] | df7100e601d2a1363d07028a786b6ceb22271829 | https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Statement/Configuration/StatementConfiguration.php#L16-L25 |
1,504 | emaphp/eMapper | lib/eMapper/Statement/Configuration/StatementConfiguration.php | StatementConfiguration.resultMap | public function resultMap($result_map) {
if (!is_string($result_map)) {
if (is_object($result_map))
$result_map = get_class($result_map);
else
throw new \InvalidArgumentException("Method 'resultMap' expects a string or valid a result map instance.");
}
return $this->merge(['map.result' => $result_map]);
} | php | public function resultMap($result_map) {
if (!is_string($result_map)) {
if (is_object($result_map))
$result_map = get_class($result_map);
else
throw new \InvalidArgumentException("Method 'resultMap' expects a string or valid a result map instance.");
}
return $this->merge(['map.result' => $result_map]);
} | [
"public",
"function",
"resultMap",
"(",
"$",
"result_map",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"result_map",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"result_map",
")",
")",
"$",
"result_map",
"=",
"get_class",
"(",
"$",
"result_map",
")",
";",
"else",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Method 'resultMap' expects a string or valid a result map instance.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"merge",
"(",
"[",
"'map.result'",
"=>",
"$",
"result_map",
"]",
")",
";",
"}"
] | Sets the result map class to apply to obtained result
@param mixed $result_map
@throws \InvalidArgumentException
@return \eMapper\Statement\Configuration\StatementConfiguration | [
"Sets",
"the",
"result",
"map",
"class",
"to",
"apply",
"to",
"obtained",
"result"
] | df7100e601d2a1363d07028a786b6ceb22271829 | https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Statement/Configuration/StatementConfiguration.php#L33-L42 |
1,505 | emaphp/eMapper | lib/eMapper/Statement/Configuration/StatementConfiguration.php | StatementConfiguration.cache | public function cache($cache_key, $cache_ttl = 0) {
if (!is_string($cache_key) || empty($cache_key))
throw new \InvalidArgumentException("Cache key is not a valid string.");
if (!is_integer($cache_ttl) || $cache_ttl < 0)
throw new \InvalidArgumentException("Cache TTL is not a valid integer.");
return $this->merge(['cache.key' => $cache_key, 'cache.ttl' => $cache_ttl]);
} | php | public function cache($cache_key, $cache_ttl = 0) {
if (!is_string($cache_key) || empty($cache_key))
throw new \InvalidArgumentException("Cache key is not a valid string.");
if (!is_integer($cache_ttl) || $cache_ttl < 0)
throw new \InvalidArgumentException("Cache TTL is not a valid integer.");
return $this->merge(['cache.key' => $cache_key, 'cache.ttl' => $cache_ttl]);
} | [
"public",
"function",
"cache",
"(",
"$",
"cache_key",
",",
"$",
"cache_ttl",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"cache_key",
")",
"||",
"empty",
"(",
"$",
"cache_key",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Cache key is not a valid string.\"",
")",
";",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"cache_ttl",
")",
"||",
"$",
"cache_ttl",
"<",
"0",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Cache TTL is not a valid integer.\"",
")",
";",
"return",
"$",
"this",
"->",
"merge",
"(",
"[",
"'cache.key'",
"=>",
"$",
"cache_key",
",",
"'cache.ttl'",
"=>",
"$",
"cache_ttl",
"]",
")",
";",
"}"
] | Sets cache key and ttl
@param string $cache_key
@param integer $cache_ttl
@throws \InvalidArgumentException
@return \eMapper\Statement\Configuration\StatementConfiguration | [
"Sets",
"cache",
"key",
"and",
"ttl"
] | df7100e601d2a1363d07028a786b6ceb22271829 | https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Statement/Configuration/StatementConfiguration.php#L103-L111 |
1,506 | tigron/skeleton-i18n | lib/Skeleton/I18n/Language.php | Language.get_by_name_short | public static function get_by_name_short($name) {
$db = Database::Get();
$id = $db->get_one('SELECT id FROM language WHERE name_short=?', [$name]);
if ($id === null) {
throw new \Exception('No such language');
}
$language = self::get_by_id($id);
return $language;
} | php | public static function get_by_name_short($name) {
$db = Database::Get();
$id = $db->get_one('SELECT id FROM language WHERE name_short=?', [$name]);
if ($id === null) {
throw new \Exception('No such language');
}
$language = self::get_by_id($id);
return $language;
} | [
"public",
"static",
"function",
"get_by_name_short",
"(",
"$",
"name",
")",
"{",
"$",
"db",
"=",
"Database",
"::",
"Get",
"(",
")",
";",
"$",
"id",
"=",
"$",
"db",
"->",
"get_one",
"(",
"'SELECT id FROM language WHERE name_short=?'",
",",
"[",
"$",
"name",
"]",
")",
";",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No such language'",
")",
";",
"}",
"$",
"language",
"=",
"self",
"::",
"get_by_id",
"(",
"$",
"id",
")",
";",
"return",
"$",
"language",
";",
"}"
] | Get by name_short
@access public
@return Language
@param string $name_short | [
"Get",
"by",
"name_short"
] | b1523e69ec8674b9d9359045ff0ee4dfde66f9e6 | https://github.com/tigron/skeleton-i18n/blob/b1523e69ec8674b9d9359045ff0ee4dfde66f9e6/lib/Skeleton/I18n/Language.php#L35-L45 |
1,507 | tmquang6805/phalex | library/Phalex/Loader/Autoloader.php | Autoloader.registerClassMap | protected function registerClassMap(array $classMap)
{
foreach ($classMap as $file) {
$arrClasses = require $file;
if (!ArrayUtils::isHashTable($arrClasses, true)) {
throw new Exception\RuntimeException('Config autoload for classmap is invalid');
}
if (!empty($arrClasses)) {
$this->loader->registerClasses($arrClasses);
}
}
} | php | protected function registerClassMap(array $classMap)
{
foreach ($classMap as $file) {
$arrClasses = require $file;
if (!ArrayUtils::isHashTable($arrClasses, true)) {
throw new Exception\RuntimeException('Config autoload for classmap is invalid');
}
if (!empty($arrClasses)) {
$this->loader->registerClasses($arrClasses);
}
}
} | [
"protected",
"function",
"registerClassMap",
"(",
"array",
"$",
"classMap",
")",
"{",
"foreach",
"(",
"$",
"classMap",
"as",
"$",
"file",
")",
"{",
"$",
"arrClasses",
"=",
"require",
"$",
"file",
";",
"if",
"(",
"!",
"ArrayUtils",
"::",
"isHashTable",
"(",
"$",
"arrClasses",
",",
"true",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Config autoload for classmap is invalid'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"arrClasses",
")",
")",
"{",
"$",
"this",
"->",
"loader",
"->",
"registerClasses",
"(",
"$",
"arrClasses",
")",
";",
"}",
"}",
"}"
] | Register class map
@param array $classMap
@throws Exception\RuntimeException
@todo Should cache multi include file into one | [
"Register",
"class",
"map"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Loader/Autoloader.php#L58-L70 |
1,508 | tmquang6805/phalex | library/Phalex/Loader/Autoloader.php | Autoloader.register | public function register()
{
$moduleHandler = $this->diFactory->get('moduleHandler');
$autoloadConf = $moduleHandler->getModulesAutoloadConfig();
if (isset($autoloadConf['namespaces'])) {
if (!ArrayUtils::isHashTable($autoloadConf['namespaces'])) {
throw new Exception\RuntimeException('Config autoload for namespace is invalid');
}
$this->loader->registerNamespaces($autoloadConf['namespaces']);
}
if (isset($autoloadConf['classmap'])) {
$this->registerClassMap($autoloadConf['classmap']);
}
$this->loader->register();
return $this;
} | php | public function register()
{
$moduleHandler = $this->diFactory->get('moduleHandler');
$autoloadConf = $moduleHandler->getModulesAutoloadConfig();
if (isset($autoloadConf['namespaces'])) {
if (!ArrayUtils::isHashTable($autoloadConf['namespaces'])) {
throw new Exception\RuntimeException('Config autoload for namespace is invalid');
}
$this->loader->registerNamespaces($autoloadConf['namespaces']);
}
if (isset($autoloadConf['classmap'])) {
$this->registerClassMap($autoloadConf['classmap']);
}
$this->loader->register();
return $this;
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"moduleHandler",
"=",
"$",
"this",
"->",
"diFactory",
"->",
"get",
"(",
"'moduleHandler'",
")",
";",
"$",
"autoloadConf",
"=",
"$",
"moduleHandler",
"->",
"getModulesAutoloadConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"autoloadConf",
"[",
"'namespaces'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"ArrayUtils",
"::",
"isHashTable",
"(",
"$",
"autoloadConf",
"[",
"'namespaces'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Config autoload for namespace is invalid'",
")",
";",
"}",
"$",
"this",
"->",
"loader",
"->",
"registerNamespaces",
"(",
"$",
"autoloadConf",
"[",
"'namespaces'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"autoloadConf",
"[",
"'classmap'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"registerClassMap",
"(",
"$",
"autoloadConf",
"[",
"'classmap'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"loader",
"->",
"register",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Auto register namespace and class map
@throws Exception\RuntimeException
@todo Should cache register classmap | [
"Auto",
"register",
"namespace",
"and",
"class",
"map"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Loader/Autoloader.php#L77-L94 |
1,509 | fabsgc/framework | Core/Http/Response/Response.php | Response.header | public function header($header = null) {
if ($this->_status != null) {
array_push($this->_headers, $header);
return true;
}
else {
return $this->_headers;
}
} | php | public function header($header = null) {
if ($this->_status != null) {
array_push($this->_headers, $header);
return true;
}
else {
return $this->_headers;
}
} | [
"public",
"function",
"header",
"(",
"$",
"header",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_status",
"!=",
"null",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"_headers",
",",
"$",
"header",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_headers",
";",
"}",
"}"
] | add header to the stack
get headers
@access public
@param $header string
@return mixed
@since 3.0
@package Gcs\Framework\Http\Core\Response | [
"add",
"header",
"to",
"the",
"stack",
"get",
"headers"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Http/Response/Response.php#L193-L201 |
1,510 | fabsgc/framework | Core/Http/Response/Response.php | Response.status | public function status($status = null) {
if ($status != null) {
if (array_key_exists($status, $this->_statusCode)) {
$this->_status = $status;
}
return true;
}
else {
return $this->_status;
}
} | php | public function status($status = null) {
if ($status != null) {
if (array_key_exists($status, $this->_statusCode)) {
$this->_status = $status;
}
return true;
}
else {
return $this->_status;
}
} | [
"public",
"function",
"status",
"(",
"$",
"status",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"status",
"!=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"status",
",",
"$",
"this",
"->",
"_statusCode",
")",
")",
"{",
"$",
"this",
"->",
"_status",
"=",
"$",
"status",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_status",
";",
"}",
"}"
] | set the status code. If you use 404, 403 or 500, the framework will display an error page
get the status code
@access public
@param $status string
@return mixed
@since 3.0
@package Gcs\Framework\Http\Core\Response | [
"set",
"the",
"status",
"code",
".",
"If",
"you",
"use",
"404",
"403",
"or",
"500",
"the",
"framework",
"will",
"display",
"an",
"error",
"page",
"get",
"the",
"status",
"code"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Http/Response/Response.php#L213-L224 |
1,511 | fabsgc/framework | Core/Http/Response/Response.php | Response.contentType | public function contentType($contentType = null) {
if ($contentType != null) {
$this->_contentType = $contentType;
return true;
}
else {
return $this->_contentType;
}
} | php | public function contentType($contentType = null) {
if ($contentType != null) {
$this->_contentType = $contentType;
return true;
}
else {
return $this->_contentType;
}
} | [
"public",
"function",
"contentType",
"(",
"$",
"contentType",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"contentType",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_contentType",
"=",
"$",
"contentType",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_contentType",
";",
"}",
"}"
] | set Content-Type without Content-Type
get Content-Type
@access public
@param $contentType string
@return mixed
@since 3.0
@package Gcs\Framework\Http\Core\Response | [
"set",
"Content",
"-",
"Type",
"without",
"Content",
"-",
"Type",
"get",
"Content",
"-",
"Type"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Http/Response/Response.php#L236-L244 |
1,512 | fabsgc/framework | Core/Http/Response/Response.php | Response.run | public function run() {
header('Content-Type: ' . $this->_contentType);
if ($this->_status != 200) {
http_response_code($this->_status);
}
if (array_key_exists($this->_status, $this->_statusErrorPage)) {
$tpl = new Template($this->_statusErrorPage[$this->_status], $this->_status, '0', Request::instance()->lang);
$tpl->assign([
'code' => $this->_status,
'description' => $this->_statusCode[$this->_status]
]);
$this->_page = $tpl->show();
}
else {
foreach ($this->_headers as $value) {
header($value);
}
}
} | php | public function run() {
header('Content-Type: ' . $this->_contentType);
if ($this->_status != 200) {
http_response_code($this->_status);
}
if (array_key_exists($this->_status, $this->_statusErrorPage)) {
$tpl = new Template($this->_statusErrorPage[$this->_status], $this->_status, '0', Request::instance()->lang);
$tpl->assign([
'code' => $this->_status,
'description' => $this->_statusCode[$this->_status]
]);
$this->_page = $tpl->show();
}
else {
foreach ($this->_headers as $value) {
header($value);
}
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"header",
"(",
"'Content-Type: '",
".",
"$",
"this",
"->",
"_contentType",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_status",
"!=",
"200",
")",
"{",
"http_response_code",
"(",
"$",
"this",
"->",
"_status",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"_status",
",",
"$",
"this",
"->",
"_statusErrorPage",
")",
")",
"{",
"$",
"tpl",
"=",
"new",
"Template",
"(",
"$",
"this",
"->",
"_statusErrorPage",
"[",
"$",
"this",
"->",
"_status",
"]",
",",
"$",
"this",
"->",
"_status",
",",
"'0'",
",",
"Request",
"::",
"instance",
"(",
")",
"->",
"lang",
")",
";",
"$",
"tpl",
"->",
"assign",
"(",
"[",
"'code'",
"=>",
"$",
"this",
"->",
"_status",
",",
"'description'",
"=>",
"$",
"this",
"->",
"_statusCode",
"[",
"$",
"this",
"->",
"_status",
"]",
"]",
")",
";",
"$",
"this",
"->",
"_page",
"=",
"$",
"tpl",
"->",
"show",
"(",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_headers",
"as",
"$",
"value",
")",
"{",
"header",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | execute all the headers
@access public
@return void
@since 3.0
@package Gcs\Framework\Http\Core\Response | [
"execute",
"all",
"the",
"headers"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Http/Response/Response.php#L254-L276 |
1,513 | fabsgc/framework | Core/Http/Response/Response.php | Response.page | public function page($page = null) {
if ($page != null) {
$this->_page = $page;
return true;
}
else {
return $this->_page;
}
} | php | public function page($page = null) {
if ($page != null) {
$this->_page = $page;
return true;
}
else {
return $this->_page;
}
} | [
"public",
"function",
"page",
"(",
"$",
"page",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"page",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_page",
"=",
"$",
"page",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_page",
";",
"}",
"}"
] | return the page content
@access public
@param $page string
@return mixed
@since 3.0
@package Gcs\Framework\Http\Core\Response | [
"return",
"the",
"page",
"content"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Http/Response/Response.php#L287-L295 |
1,514 | Innmind/neo4j-onm | src/EntityFactory/Resolver.php | Resolver.register | private function register(EntityFactoryInterface $factory): self
{
$this->mapping = $this->mapping->put(
get_class($factory),
$factory
);
return $this;
} | php | private function register(EntityFactoryInterface $factory): self
{
$this->mapping = $this->mapping->put(
get_class($factory),
$factory
);
return $this;
} | [
"private",
"function",
"register",
"(",
"EntityFactoryInterface",
"$",
"factory",
")",
":",
"self",
"{",
"$",
"this",
"->",
"mapping",
"=",
"$",
"this",
"->",
"mapping",
"->",
"put",
"(",
"get_class",
"(",
"$",
"factory",
")",
",",
"$",
"factory",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Register the given entity factory instance | [
"Register",
"the",
"given",
"entity",
"factory",
"instance"
] | 816216802a9716bb5f20cc38336313b043bf764c | https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/EntityFactory/Resolver.php#L45-L53 |
1,515 | UpMembership/upmembership-project | scripts/ScriptHandler.php | ScriptHandler.checkComposerVersion | public static function checkComposerVersion(Event $event) {
$composer = $event->getComposer();
$io = $event->getIO();
$version = $composer::VERSION;
// If Composer is installed through git we have no easy way to determine if
// it is new enough, just display a warning.
if ($version === '@package_version@') {
$io->writeError('<warning>You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.</warning>');
}
elseif (Comparator::lessThan($version, '1.0.0')) {
$io->writeError('<error>UpMembership requires Composer version 1.0.0 or higher. Please update your Composer before continuing</error>.');
exit(1);
}
} | php | public static function checkComposerVersion(Event $event) {
$composer = $event->getComposer();
$io = $event->getIO();
$version = $composer::VERSION;
// If Composer is installed through git we have no easy way to determine if
// it is new enough, just display a warning.
if ($version === '@package_version@') {
$io->writeError('<warning>You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.</warning>');
}
elseif (Comparator::lessThan($version, '1.0.0')) {
$io->writeError('<error>UpMembership requires Composer version 1.0.0 or higher. Please update your Composer before continuing</error>.');
exit(1);
}
} | [
"public",
"static",
"function",
"checkComposerVersion",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"composer",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
";",
"$",
"io",
"=",
"$",
"event",
"->",
"getIO",
"(",
")",
";",
"$",
"version",
"=",
"$",
"composer",
"::",
"VERSION",
";",
"// If Composer is installed through git we have no easy way to determine if",
"// it is new enough, just display a warning.",
"if",
"(",
"$",
"version",
"===",
"'@package_version@'",
")",
"{",
"$",
"io",
"->",
"writeError",
"(",
"'<warning>You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.</warning>'",
")",
";",
"}",
"elseif",
"(",
"Comparator",
"::",
"lessThan",
"(",
"$",
"version",
",",
"'1.0.0'",
")",
")",
"{",
"$",
"io",
"->",
"writeError",
"(",
"'<error>UpMembership requires Composer version 1.0.0 or higher. Please update your Composer before continuing</error>.'",
")",
";",
"exit",
"(",
"1",
")",
";",
"}",
"}"
] | Checks if the installed version of Composer is compatible.
Composer 1.0.0 and higher consider a `composer install` without having a
lock file present as equal to `composer update`. We do not ship with a lock
file to avoid merge conflicts downstream, meaning that if a project is
installed with an older version of Composer the scaffolding of Drupal will
not be triggered. We check this here instead of in drupal-scaffold to be
able to give immediate feedback to the end user, rather than failing the
installation after going through the lengthy process of compiling and
downloading the Composer dependencies.
@see https://github.com/composer/composer/pull/5035 | [
"Checks",
"if",
"the",
"installed",
"version",
"of",
"Composer",
"is",
"compatible",
"."
] | 4a7e13323f142f42bb45ee488cb28f2ce11a0620 | https://github.com/UpMembership/upmembership-project/blob/4a7e13323f142f42bb45ee488cb28f2ce11a0620/scripts/ScriptHandler.php#L75-L90 |
1,516 | mariusbalcytis/oauth-commerce-lib-base | src/Maba/OAuthCommerceClient/Entity/UserCredentials/CreditCard.php | CreditCard.toPrivateArray | public function toPrivateArray()
{
return array(
'number' => $this->getNumber(),
'holder_name' => $this->getHolderName(),
'expiration_year' => $this->getExpirationYear(),
'expiration_month' => $this->getExpirationMonth(),
'security_code' => $this->getSecurityCode(),
);
} | php | public function toPrivateArray()
{
return array(
'number' => $this->getNumber(),
'holder_name' => $this->getHolderName(),
'expiration_year' => $this->getExpirationYear(),
'expiration_month' => $this->getExpirationMonth(),
'security_code' => $this->getSecurityCode(),
);
} | [
"public",
"function",
"toPrivateArray",
"(",
")",
"{",
"return",
"array",
"(",
"'number'",
"=>",
"$",
"this",
"->",
"getNumber",
"(",
")",
",",
"'holder_name'",
"=>",
"$",
"this",
"->",
"getHolderName",
"(",
")",
",",
"'expiration_year'",
"=>",
"$",
"this",
"->",
"getExpirationYear",
"(",
")",
",",
"'expiration_month'",
"=>",
"$",
"this",
"->",
"getExpirationMonth",
"(",
")",
",",
"'security_code'",
"=>",
"$",
"this",
"->",
"getSecurityCode",
"(",
")",
",",
")",
";",
"}"
] | Returns only private properties that must be encrypted before sending
@return array | [
"Returns",
"only",
"private",
"properties",
"that",
"must",
"be",
"encrypted",
"before",
"sending"
] | 996fc2ba0933a5a11384d537d32073c014ef4819 | https://github.com/mariusbalcytis/oauth-commerce-lib-base/blob/996fc2ba0933a5a11384d537d32073c014ef4819/src/Maba/OAuthCommerceClient/Entity/UserCredentials/CreditCard.php#L191-L200 |
1,517 | slickframework/orm | src/Event/EmittersMap.php | EmittersMap.set | public function set($key, $value)
{
if (! $value instanceof EmitterInterface) {
throw new InvalidArgumentException(
"Only EmitterInterface object can be putted in a ".
"EmittersMap."
);
}
return parent::set($key, $value);
} | php | public function set($key, $value)
{
if (! $value instanceof EmitterInterface) {
throw new InvalidArgumentException(
"Only EmitterInterface object can be putted in a ".
"EmittersMap."
);
}
return parent::set($key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"EmitterInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Only EmitterInterface object can be putted in a \"",
".",
"\"EmittersMap.\"",
")",
";",
"}",
"return",
"parent",
"::",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Puts a new emitter in the map.
@param mixed $key
@param EmitterInterface $value
@return $this|self|MapInterface | [
"Puts",
"a",
"new",
"emitter",
"in",
"the",
"map",
"."
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/src/Event/EmittersMap.php#L34-L43 |
1,518 | wudimeicom/WudimeiPHP | Session.php | Session.loadConfig | public function loadConfig( $file ){
if( file_exists( $file ) ){
$config = include $file;
$driver = $config['driver'];
if( $driver == 'file'){
$session = new \Wudimei\Session\File($config);
}
$this->session = $session;
}
else{
throw new \Exception('sesstion config file "' . $file . '" does not exists');
}
} | php | public function loadConfig( $file ){
if( file_exists( $file ) ){
$config = include $file;
$driver = $config['driver'];
if( $driver == 'file'){
$session = new \Wudimei\Session\File($config);
}
$this->session = $session;
}
else{
throw new \Exception('sesstion config file "' . $file . '" does not exists');
}
} | [
"public",
"function",
"loadConfig",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"config",
"=",
"include",
"$",
"file",
";",
"$",
"driver",
"=",
"$",
"config",
"[",
"'driver'",
"]",
";",
"if",
"(",
"$",
"driver",
"==",
"'file'",
")",
"{",
"$",
"session",
"=",
"new",
"\\",
"Wudimei",
"\\",
"Session",
"\\",
"File",
"(",
"$",
"config",
")",
";",
"}",
"$",
"this",
"->",
"session",
"=",
"$",
"session",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'sesstion config file \"'",
".",
"$",
"file",
".",
"'\" does not exists'",
")",
";",
"}",
"}"
] | load config array from file
@param string $file
@throws \Exception
@return void | [
"load",
"config",
"array",
"from",
"file"
] | ea7267d449cea06dc057919efa498599bd8ee4b9 | https://github.com/wudimeicom/WudimeiPHP/blob/ea7267d449cea06dc057919efa498599bd8ee4b9/Session.php#L17-L31 |
1,519 | tenside/core | src/Task/CompositeTaskFactory.php | CompositeTaskFactory.getFactoryForType | private function getFactoryForType($taskType)
{
foreach ($this->factories as $factory) {
if ($factory->isTypeSupported($taskType)) {
return $factory;
}
}
return null;
} | php | private function getFactoryForType($taskType)
{
foreach ($this->factories as $factory) {
if ($factory->isTypeSupported($taskType)) {
return $factory;
}
}
return null;
} | [
"private",
"function",
"getFactoryForType",
"(",
"$",
"taskType",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"factories",
"as",
"$",
"factory",
")",
"{",
"if",
"(",
"$",
"factory",
"->",
"isTypeSupported",
"(",
"$",
"taskType",
")",
")",
"{",
"return",
"$",
"factory",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Search the factory that can handle the type.
@param string $taskType The task type to search.
@return null|TaskFactoryInterface | [
"Search",
"the",
"factory",
"that",
"can",
"handle",
"the",
"type",
"."
] | 56422fa8cdecf03cb431bb6654c2942ade39bf7b | https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Task/CompositeTaskFactory.php#L94-L103 |
1,520 | Cosmicist/mongol | src/Flatline/Auth/MongolUserProvider.php | MongolUserProvider.retrieveByID | public function retrieveByID($identifier)
{
$user = $this->conn->{$this->table}->findOne(array('_id' => new \MongoId($identifier)));
if ( ! is_null($user))
{
return new MongolUser((array) $user);
}
} | php | public function retrieveByID($identifier)
{
$user = $this->conn->{$this->table}->findOne(array('_id' => new \MongoId($identifier)));
if ( ! is_null($user))
{
return new MongolUser((array) $user);
}
} | [
"public",
"function",
"retrieveByID",
"(",
"$",
"identifier",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"conn",
"->",
"{",
"$",
"this",
"->",
"table",
"}",
"->",
"findOne",
"(",
"array",
"(",
"'_id'",
"=>",
"new",
"\\",
"MongoId",
"(",
"$",
"identifier",
")",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"user",
")",
")",
"{",
"return",
"new",
"MongolUser",
"(",
"(",
"array",
")",
"$",
"user",
")",
";",
"}",
"}"
] | Retrieve a user by their unique idenetifier.
@param mixed $identifier
@return Illuminate\Auth\UserInterface|null | [
"Retrieve",
"a",
"user",
"by",
"their",
"unique",
"idenetifier",
"."
] | 6f35ee2f3687af355ff175391e9d9e46075beadc | https://github.com/Cosmicist/mongol/blob/6f35ee2f3687af355ff175391e9d9e46075beadc/src/Flatline/Auth/MongolUserProvider.php#L52-L60 |
1,521 | nano7/Http | src/Routing/ApiController.php | ApiController.model | protected function model($class = false)
{
if ($class !== false) {
return app($class);
}
// Verificar se já foi criado
if (! is_null($this->model)) {
return $this->model;
}
return $this->model = app($this->modelName);
} | php | protected function model($class = false)
{
if ($class !== false) {
return app($class);
}
// Verificar se já foi criado
if (! is_null($this->model)) {
return $this->model;
}
return $this->model = app($this->modelName);
} | [
"protected",
"function",
"model",
"(",
"$",
"class",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"class",
"!==",
"false",
")",
"{",
"return",
"app",
"(",
"$",
"class",
")",
";",
"}",
"// Verificar se já foi criado",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"model",
")",
")",
"{",
"return",
"$",
"this",
"->",
"model",
";",
"}",
"return",
"$",
"this",
"->",
"model",
"=",
"app",
"(",
"$",
"this",
"->",
"modelName",
")",
";",
"}"
] | Create model.
@return Model | [
"Create",
"model",
"."
] | 9af795646ceb3cf1364160a71e339cb79d63773f | https://github.com/nano7/Http/blob/9af795646ceb3cf1364160a71e339cb79d63773f/src/Routing/ApiController.php#L162-L174 |
1,522 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.fetch | public function fetch($url)
{
$SHDObject = $this->getSHDWrapper($url);
$urls = $this->getPageUrls($SHDObject);
$titles = $this->getPageTitles($SHDObject);
$snippets = $this->getPageSnippets($SHDObject);
return array('urls' => $urls,
'titles' => $titles,
'snippets' => $snippets);
} | php | public function fetch($url)
{
$SHDObject = $this->getSHDWrapper($url);
$urls = $this->getPageUrls($SHDObject);
$titles = $this->getPageTitles($SHDObject);
$snippets = $this->getPageSnippets($SHDObject);
return array('urls' => $urls,
'titles' => $titles,
'snippets' => $snippets);
} | [
"public",
"function",
"fetch",
"(",
"$",
"url",
")",
"{",
"$",
"SHDObject",
"=",
"$",
"this",
"->",
"getSHDWrapper",
"(",
"$",
"url",
")",
";",
"$",
"urls",
"=",
"$",
"this",
"->",
"getPageUrls",
"(",
"$",
"SHDObject",
")",
";",
"$",
"titles",
"=",
"$",
"this",
"->",
"getPageTitles",
"(",
"$",
"SHDObject",
")",
";",
"$",
"snippets",
"=",
"$",
"this",
"->",
"getPageSnippets",
"(",
"$",
"SHDObject",
")",
";",
"return",
"array",
"(",
"'urls'",
"=>",
"$",
"urls",
",",
"'titles'",
"=>",
"$",
"titles",
",",
"'snippets'",
"=>",
"$",
"snippets",
")",
";",
"}"
] | Get a multidimensional array with urls, titles and snippets for a given
SERP url.
@param string $url
@return array | [
"Get",
"a",
"multidimensional",
"array",
"with",
"urls",
"titles",
"and",
"snippets",
"for",
"a",
"given",
"SERP",
"url",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L105-L114 |
1,523 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.cacheHit | public function cacheHit($url) {
$file = FileSystemHelper::getCachedEntry($url, $this->getCacheDir());
return $this->isCaching() && FileSystemHelper::cacheEntryExists($file)
&& FileSystemHelper::validateCache($file, $this->getCacheTTL(),
$this->isCachingForever());
} | php | public function cacheHit($url) {
$file = FileSystemHelper::getCachedEntry($url, $this->getCacheDir());
return $this->isCaching() && FileSystemHelper::cacheEntryExists($file)
&& FileSystemHelper::validateCache($file, $this->getCacheTTL(),
$this->isCachingForever());
} | [
"public",
"function",
"cacheHit",
"(",
"$",
"url",
")",
"{",
"$",
"file",
"=",
"FileSystemHelper",
"::",
"getCachedEntry",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"getCacheDir",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"isCaching",
"(",
")",
"&&",
"FileSystemHelper",
"::",
"cacheEntryExists",
"(",
"$",
"file",
")",
"&&",
"FileSystemHelper",
"::",
"validateCache",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"getCacheTTL",
"(",
")",
",",
"$",
"this",
"->",
"isCachingForever",
"(",
")",
")",
";",
"}"
] | Check if cache should be hit for a given url request.
@param string $url
@return bool | [
"Check",
"if",
"cache",
"should",
"be",
"hit",
"for",
"a",
"given",
"url",
"request",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L121-L126 |
1,524 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.setCacheDir | public function setCacheDir($dir)
{
if (GenericValidator::validateDirName($dir)) {
$this->cacheDir = $dir;
FileSystemHelper::setUpDir($dir);
return true;
}
return false;
} | php | public function setCacheDir($dir)
{
if (GenericValidator::validateDirName($dir)) {
$this->cacheDir = $dir;
FileSystemHelper::setUpDir($dir);
return true;
}
return false;
} | [
"public",
"function",
"setCacheDir",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"GenericValidator",
"::",
"validateDirName",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"this",
"->",
"cacheDir",
"=",
"$",
"dir",
";",
"FileSystemHelper",
"::",
"setUpDir",
"(",
"$",
"dir",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Set the path to the cache folder.
@param string $dir
@return bool | [
"Set",
"the",
"path",
"to",
"the",
"cache",
"folder",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L163-L171 |
1,525 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.setCacheTTL | public function setCacheTTL($hours)
{
if (GenericValidator::validateExpirationTime($hours)) {
$this->cacheTTL = $hours;
return true;
}
return false;
} | php | public function setCacheTTL($hours)
{
if (GenericValidator::validateExpirationTime($hours)) {
$this->cacheTTL = $hours;
return true;
}
return false;
} | [
"public",
"function",
"setCacheTTL",
"(",
"$",
"hours",
")",
"{",
"if",
"(",
"GenericValidator",
"::",
"validateExpirationTime",
"(",
"$",
"hours",
")",
")",
"{",
"$",
"this",
"->",
"cacheTTL",
"=",
"$",
"hours",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Set the cache duration expressed in hours.
@param int $hours
@return bool | [
"Set",
"the",
"cache",
"duration",
"expressed",
"in",
"hours",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L187-L194 |
1,526 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.enableCaching | public function enableCaching()
{
if (FileSystemHelper::folderExists($this->getCacheDir())) {
$this->caching = true;
return true;
}
return false;
} | php | public function enableCaching()
{
if (FileSystemHelper::folderExists($this->getCacheDir())) {
$this->caching = true;
return true;
}
return false;
} | [
"public",
"function",
"enableCaching",
"(",
")",
"{",
"if",
"(",
"FileSystemHelper",
"::",
"folderExists",
"(",
"$",
"this",
"->",
"getCacheDir",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"caching",
"=",
"true",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Turn caching on.
Prevent turning caching on if the cache folder hasn't been yet created.
@return bool | [
"Turn",
"caching",
"on",
".",
"Prevent",
"turning",
"caching",
"on",
"if",
"the",
"cache",
"folder",
"hasn",
"t",
"been",
"yet",
"created",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L210-L217 |
1,527 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.setCharset | public function setCharset($charset)
{
if (GenericValidator::validateCharset($charset)) {
$this->charset = $charset;
return true;
}
return false;
} | php | public function setCharset($charset)
{
if (GenericValidator::validateCharset($charset)) {
$this->charset = $charset;
return true;
}
return false;
} | [
"public",
"function",
"setCharset",
"(",
"$",
"charset",
")",
"{",
"if",
"(",
"GenericValidator",
"::",
"validateCharset",
"(",
"$",
"charset",
")",
")",
"{",
"$",
"this",
"->",
"charset",
"=",
"$",
"charset",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Set the charset used by the SimpleHtmlDom object.
@param string $charset
@return bool | [
"Set",
"the",
"charset",
"used",
"by",
"the",
"SimpleHtmlDom",
"object",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L273-L280 |
1,528 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.cleanText | protected function cleanText($text)
{
$strippedText = strip_tags($text);
$strippedText = htmlentities($strippedText, ENT_QUOTES, $this->getCharset(), FALSE);
return html_entity_decode($strippedText, ENT_QUOTES, $this->getCharset());
} | php | protected function cleanText($text)
{
$strippedText = strip_tags($text);
$strippedText = htmlentities($strippedText, ENT_QUOTES, $this->getCharset(), FALSE);
return html_entity_decode($strippedText, ENT_QUOTES, $this->getCharset());
} | [
"protected",
"function",
"cleanText",
"(",
"$",
"text",
")",
"{",
"$",
"strippedText",
"=",
"strip_tags",
"(",
"$",
"text",
")",
";",
"$",
"strippedText",
"=",
"htmlentities",
"(",
"$",
"strippedText",
",",
"ENT_QUOTES",
",",
"$",
"this",
"->",
"getCharset",
"(",
")",
",",
"FALSE",
")",
";",
"return",
"html_entity_decode",
"(",
"$",
"strippedText",
",",
"ENT_QUOTES",
",",
"$",
"this",
"->",
"getCharset",
"(",
")",
")",
";",
"}"
] | Extract textual data from fetched raw html text.
@param string $text
@return string | [
"Extract",
"textual",
"data",
"from",
"fetched",
"raw",
"html",
"text",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L299-L304 |
1,529 | franzip/serp-fetcher | src/Fetchers/SerpFetcher.php | SerpFetcher.normalizeResult | protected function normalizeResult($resultArray)
{
$countArr = count($resultArray);
if ($countArr > 10) {
$resultArray = array_slice($resultArray, 0, 10);
}
else if ($countArr < 10) {
for ($i = $countArr; $i < self::DEFAULT_RESULT_NUMBER; $i++)
$resultArray[$i] = self::DEFAULT_PAD_ENTRY;
}
return $resultArray;
} | php | protected function normalizeResult($resultArray)
{
$countArr = count($resultArray);
if ($countArr > 10) {
$resultArray = array_slice($resultArray, 0, 10);
}
else if ($countArr < 10) {
for ($i = $countArr; $i < self::DEFAULT_RESULT_NUMBER; $i++)
$resultArray[$i] = self::DEFAULT_PAD_ENTRY;
}
return $resultArray;
} | [
"protected",
"function",
"normalizeResult",
"(",
"$",
"resultArray",
")",
"{",
"$",
"countArr",
"=",
"count",
"(",
"$",
"resultArray",
")",
";",
"if",
"(",
"$",
"countArr",
">",
"10",
")",
"{",
"$",
"resultArray",
"=",
"array_slice",
"(",
"$",
"resultArray",
",",
"0",
",",
"10",
")",
";",
"}",
"else",
"if",
"(",
"$",
"countArr",
"<",
"10",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"$",
"countArr",
";",
"$",
"i",
"<",
"self",
"::",
"DEFAULT_RESULT_NUMBER",
";",
"$",
"i",
"++",
")",
"$",
"resultArray",
"[",
"$",
"i",
"]",
"=",
"self",
"::",
"DEFAULT_PAD_ENTRY",
";",
"}",
"return",
"$",
"resultArray",
";",
"}"
] | Normalize result array by slicing it or by adding padding.
@param array $resultArray
@return array | [
"Normalize",
"result",
"array",
"by",
"slicing",
"it",
"or",
"by",
"adding",
"padding",
"."
] | 0554b682a8e4aec6e5d615866087b34e731e0d88 | https://github.com/franzip/serp-fetcher/blob/0554b682a8e4aec6e5d615866087b34e731e0d88/src/Fetchers/SerpFetcher.php#L367-L378 |
1,530 | wasabi-cms/core | src/View/Helper/GuardianHelper.php | GuardianHelper.protectedLink | public function protectedLink($title, $url, $options = [], $displayLinkTextIfUnauthorized = false)
{
$url = $this->_getUrl($url);
if (!guardian()->hasAccess($url)) {
if ($displayLinkTextIfUnauthorized) {
return $title;
}
return '';
}
return $this->link($title, $url, $options);
} | php | public function protectedLink($title, $url, $options = [], $displayLinkTextIfUnauthorized = false)
{
$url = $this->_getUrl($url);
if (!guardian()->hasAccess($url)) {
if ($displayLinkTextIfUnauthorized) {
return $title;
}
return '';
}
return $this->link($title, $url, $options);
} | [
"public",
"function",
"protectedLink",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"displayLinkTextIfUnauthorized",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_getUrl",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"guardian",
"(",
")",
"->",
"hasAccess",
"(",
"$",
"url",
")",
")",
"{",
"if",
"(",
"$",
"displayLinkTextIfUnauthorized",
")",
"{",
"return",
"$",
"title",
";",
"}",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"link",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"}"
] | Create a properly prefixed backend link.
automatically prepends the backend url prefix to the desired $url
@param string $title The link title.
@param array|string $url The url to link to.
@param array $options Options passed to the html link helper method.
@param bool $displayLinkTextIfUnauthorized Whether to display the link title if the user is
not authorized to access the link.
@return string | [
"Create",
"a",
"properly",
"prefixed",
"backend",
"link",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/GuardianHelper.php#L40-L50 |
1,531 | wasabi-cms/core | src/View/Helper/GuardianHelper.php | GuardianHelper.unprotectedLink | public function unprotectedLink($title, $url, $options = [])
{
$url = $this->_getUrl($url);
return $this->link($title, $url, $options);
} | php | public function unprotectedLink($title, $url, $options = [])
{
$url = $this->_getUrl($url);
return $this->link($title, $url, $options);
} | [
"public",
"function",
"unprotectedLink",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_getUrl",
"(",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"link",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"}"
] | Create a properly prefixed backend link and
don't check permissions.
@param string $title The link title.
@param array|string $url The url to link to.
@param array $options Options passed to the html link helper method.
@return string | [
"Create",
"a",
"properly",
"prefixed",
"backend",
"link",
"and",
"don",
"t",
"check",
"permissions",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/GuardianHelper.php#L61-L65 |
1,532 | wasabi-cms/core | src/View/Helper/GuardianHelper.php | GuardianHelper.protectedConfirmationLink | public function protectedConfirmationLink($title, $url, $options, $displayLinkTextIfUnauthorized = false)
{
if (!isset($options['confirm-message'])) {
user_error('\'confirm-message\' option is not set on protectedConfirmationLink.');
$options['confirm-message'] = '';
}
if (!isset($options['confirm-title'])) {
user_error('\'confirm-title\' option is not set on protectedConfirmationLink.');
$options['confirm-title'] = '';
}
$url = $this->_getUrl($url);
if (!guardian()->hasAccess($url)) {
if ($displayLinkTextIfUnauthorized) {
return $title;
}
return '';
}
$linkOptions = [
'data-modal-header' => $options['confirm-title'],
'data-modal-body' => '<p>' . $options['confirm-message'] . '</p>',
'data-method' => 'post',
'data-toggle' => 'confirm'
];
unset($options['confirm-title'], $options['confirm-message']);
if (isset($options['ajax']) && $options['ajax'] === true) {
$linkOptions['data-modal-ajax'] = 1;
unset($options['ajax']);
if (isset($options['notify'])) {
$linkOptions['data-modal-notify'] = $options['notify'];
unset($options['notify']);
}
if (isset($options['event'])) {
$linkOptions['data-modal-event'] = $options['event'];
unset($options['event']);
}
}
if (isset($options['void']) && $options['void'] === true) {
$linkOptions['data-modal-action'] = Router::url($url);
$url = 'javascript:void(0)';
}
$linkOptions = Hash::merge($linkOptions, $options);
return $this->link($title, $url, $linkOptions);
} | php | public function protectedConfirmationLink($title, $url, $options, $displayLinkTextIfUnauthorized = false)
{
if (!isset($options['confirm-message'])) {
user_error('\'confirm-message\' option is not set on protectedConfirmationLink.');
$options['confirm-message'] = '';
}
if (!isset($options['confirm-title'])) {
user_error('\'confirm-title\' option is not set on protectedConfirmationLink.');
$options['confirm-title'] = '';
}
$url = $this->_getUrl($url);
if (!guardian()->hasAccess($url)) {
if ($displayLinkTextIfUnauthorized) {
return $title;
}
return '';
}
$linkOptions = [
'data-modal-header' => $options['confirm-title'],
'data-modal-body' => '<p>' . $options['confirm-message'] . '</p>',
'data-method' => 'post',
'data-toggle' => 'confirm'
];
unset($options['confirm-title'], $options['confirm-message']);
if (isset($options['ajax']) && $options['ajax'] === true) {
$linkOptions['data-modal-ajax'] = 1;
unset($options['ajax']);
if (isset($options['notify'])) {
$linkOptions['data-modal-notify'] = $options['notify'];
unset($options['notify']);
}
if (isset($options['event'])) {
$linkOptions['data-modal-event'] = $options['event'];
unset($options['event']);
}
}
if (isset($options['void']) && $options['void'] === true) {
$linkOptions['data-modal-action'] = Router::url($url);
$url = 'javascript:void(0)';
}
$linkOptions = Hash::merge($linkOptions, $options);
return $this->link($title, $url, $linkOptions);
} | [
"public",
"function",
"protectedConfirmationLink",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"options",
",",
"$",
"displayLinkTextIfUnauthorized",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'confirm-message'",
"]",
")",
")",
"{",
"user_error",
"(",
"'\\'confirm-message\\' option is not set on protectedConfirmationLink.'",
")",
";",
"$",
"options",
"[",
"'confirm-message'",
"]",
"=",
"''",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'confirm-title'",
"]",
")",
")",
"{",
"user_error",
"(",
"'\\'confirm-title\\' option is not set on protectedConfirmationLink.'",
")",
";",
"$",
"options",
"[",
"'confirm-title'",
"]",
"=",
"''",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"_getUrl",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"guardian",
"(",
")",
"->",
"hasAccess",
"(",
"$",
"url",
")",
")",
"{",
"if",
"(",
"$",
"displayLinkTextIfUnauthorized",
")",
"{",
"return",
"$",
"title",
";",
"}",
"return",
"''",
";",
"}",
"$",
"linkOptions",
"=",
"[",
"'data-modal-header'",
"=>",
"$",
"options",
"[",
"'confirm-title'",
"]",
",",
"'data-modal-body'",
"=>",
"'<p>'",
".",
"$",
"options",
"[",
"'confirm-message'",
"]",
".",
"'</p>'",
",",
"'data-method'",
"=>",
"'post'",
",",
"'data-toggle'",
"=>",
"'confirm'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'confirm-title'",
"]",
",",
"$",
"options",
"[",
"'confirm-message'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'ajax'",
"]",
")",
"&&",
"$",
"options",
"[",
"'ajax'",
"]",
"===",
"true",
")",
"{",
"$",
"linkOptions",
"[",
"'data-modal-ajax'",
"]",
"=",
"1",
";",
"unset",
"(",
"$",
"options",
"[",
"'ajax'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'notify'",
"]",
")",
")",
"{",
"$",
"linkOptions",
"[",
"'data-modal-notify'",
"]",
"=",
"$",
"options",
"[",
"'notify'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'notify'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'event'",
"]",
")",
")",
"{",
"$",
"linkOptions",
"[",
"'data-modal-event'",
"]",
"=",
"$",
"options",
"[",
"'event'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'event'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'void'",
"]",
")",
"&&",
"$",
"options",
"[",
"'void'",
"]",
"===",
"true",
")",
"{",
"$",
"linkOptions",
"[",
"'data-modal-action'",
"]",
"=",
"Router",
"::",
"url",
"(",
"$",
"url",
")",
";",
"$",
"url",
"=",
"'javascript:void(0)'",
";",
"}",
"$",
"linkOptions",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"linkOptions",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"link",
"(",
"$",
"title",
",",
"$",
"url",
",",
"$",
"linkOptions",
")",
";",
"}"
] | Create a backend confirmation link.
@param string $title The link title.
@param array|string $url The url to link to.
@param array $options Options passed to the html link helper method.
@param bool $displayLinkTextIfUnauthorized Whether to display the link title if the user is
not authorized to access the link.
@return string | [
"Create",
"a",
"backend",
"confirmation",
"link",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/View/Helper/GuardianHelper.php#L77-L125 |
1,533 | codger-php/generate | src/Language.php | Language.convert | public static function convert(string $input, int $to) : string
{
$string = self::normalize($input);
$parts = explode(' ', $string);
array_walk($parts, function (&$part) {
$part = ucfirst($part);
});
switch ($to) {
case self::TYPE_NAMESPACE:
return implode('\\', $parts);
case self::TYPE_TABLE:
return strtolower(implode('_', $parts));
case self::TYPE_VARIABLE:
case self::TYPE_ANGULAR_COMPONENT:
return lcfirst(implode('', $parts));
case self::TYPE_PATH:
return implode('/', $parts);
case self::TYPE_URL:
return strtolower(implode('/', $parts));
case self::TYPE_CSS_IDENTIFIER:
case self::TYPE_ANGULAR_TAG:
return strtolower(implode('-', $parts));
case self::TYPE_ANGULAR_MODULE:
return strtolower(implode('.', $parts));
default:
throw new DomainException("Please use one of the `TYPE_` constants on the `Codger\Generate\Language` class as 2nd parameter.");
}
} | php | public static function convert(string $input, int $to) : string
{
$string = self::normalize($input);
$parts = explode(' ', $string);
array_walk($parts, function (&$part) {
$part = ucfirst($part);
});
switch ($to) {
case self::TYPE_NAMESPACE:
return implode('\\', $parts);
case self::TYPE_TABLE:
return strtolower(implode('_', $parts));
case self::TYPE_VARIABLE:
case self::TYPE_ANGULAR_COMPONENT:
return lcfirst(implode('', $parts));
case self::TYPE_PATH:
return implode('/', $parts);
case self::TYPE_URL:
return strtolower(implode('/', $parts));
case self::TYPE_CSS_IDENTIFIER:
case self::TYPE_ANGULAR_TAG:
return strtolower(implode('-', $parts));
case self::TYPE_ANGULAR_MODULE:
return strtolower(implode('.', $parts));
default:
throw new DomainException("Please use one of the `TYPE_` constants on the `Codger\Generate\Language` class as 2nd parameter.");
}
} | [
"public",
"static",
"function",
"convert",
"(",
"string",
"$",
"input",
",",
"int",
"$",
"to",
")",
":",
"string",
"{",
"$",
"string",
"=",
"self",
"::",
"normalize",
"(",
"$",
"input",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"' '",
",",
"$",
"string",
")",
";",
"array_walk",
"(",
"$",
"parts",
",",
"function",
"(",
"&",
"$",
"part",
")",
"{",
"$",
"part",
"=",
"ucfirst",
"(",
"$",
"part",
")",
";",
"}",
")",
";",
"switch",
"(",
"$",
"to",
")",
"{",
"case",
"self",
"::",
"TYPE_NAMESPACE",
":",
"return",
"implode",
"(",
"'\\\\'",
",",
"$",
"parts",
")",
";",
"case",
"self",
"::",
"TYPE_TABLE",
":",
"return",
"strtolower",
"(",
"implode",
"(",
"'_'",
",",
"$",
"parts",
")",
")",
";",
"case",
"self",
"::",
"TYPE_VARIABLE",
":",
"case",
"self",
"::",
"TYPE_ANGULAR_COMPONENT",
":",
"return",
"lcfirst",
"(",
"implode",
"(",
"''",
",",
"$",
"parts",
")",
")",
";",
"case",
"self",
"::",
"TYPE_PATH",
":",
"return",
"implode",
"(",
"'/'",
",",
"$",
"parts",
")",
";",
"case",
"self",
"::",
"TYPE_URL",
":",
"return",
"strtolower",
"(",
"implode",
"(",
"'/'",
",",
"$",
"parts",
")",
")",
";",
"case",
"self",
"::",
"TYPE_CSS_IDENTIFIER",
":",
"case",
"self",
"::",
"TYPE_ANGULAR_TAG",
":",
"return",
"strtolower",
"(",
"implode",
"(",
"'-'",
",",
"$",
"parts",
")",
")",
";",
"case",
"self",
"::",
"TYPE_ANGULAR_MODULE",
":",
"return",
"strtolower",
"(",
"implode",
"(",
"'.'",
",",
"$",
"parts",
")",
")",
";",
"default",
":",
"throw",
"new",
"DomainException",
"(",
"\"Please use one of the `TYPE_` constants on the `Codger\\Generate\\Language` class as 2nd parameter.\"",
")",
";",
"}",
"}"
] | Convert input string to a different "format".
@param string $input
@param int $to Use one of the `TYPE_` constants defined on
`Codger\Php\Language`.
@return string | [
"Convert",
"input",
"string",
"to",
"a",
"different",
"format",
"."
] | 89dd3bd074cef53cf85b1470c0b96b4167825416 | https://github.com/codger-php/generate/blob/89dd3bd074cef53cf85b1470c0b96b4167825416/src/Language.php#L55-L82 |
1,534 | easy-system/es-error | src/TemplateRenderer/TemplateResolver.php | TemplateResolver.setTemplate | public function setTemplate($name, $path)
{
if (! isset($this->templates[$name])) {
throw new UnexpectedValueException(sprintf(
'Unexpected template name "%s" provided.',
is_string($name) ? $name : gettype($name)
));
}
$finfo = new SplFileInfo($path);
$realPath = $finfo->getRealPath();
if (! $realPath) {
throw new InvalidArgumentException(sprintf(
'Invalid path "%s" of template "%s" provided.',
$path,
$name
));
}
$extension = $finfo->getExtension();
if ('phtml' !== $extension) {
throw new InvalidArgumentException(sprintf(
'Invalid file extension "%s" of template "%s"; the extension '
. 'of template file must be "phtml".',
$extension,
$name
));
}
$this->templates[$name] = $realPath;
} | php | public function setTemplate($name, $path)
{
if (! isset($this->templates[$name])) {
throw new UnexpectedValueException(sprintf(
'Unexpected template name "%s" provided.',
is_string($name) ? $name : gettype($name)
));
}
$finfo = new SplFileInfo($path);
$realPath = $finfo->getRealPath();
if (! $realPath) {
throw new InvalidArgumentException(sprintf(
'Invalid path "%s" of template "%s" provided.',
$path,
$name
));
}
$extension = $finfo->getExtension();
if ('phtml' !== $extension) {
throw new InvalidArgumentException(sprintf(
'Invalid file extension "%s" of template "%s"; the extension '
. 'of template file must be "phtml".',
$extension,
$name
));
}
$this->templates[$name] = $realPath;
} | [
"public",
"function",
"setTemplate",
"(",
"$",
"name",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"templates",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'Unexpected template name \"%s\" provided.'",
",",
"is_string",
"(",
"$",
"name",
")",
"?",
"$",
"name",
":",
"gettype",
"(",
"$",
"name",
")",
")",
")",
";",
"}",
"$",
"finfo",
"=",
"new",
"SplFileInfo",
"(",
"$",
"path",
")",
";",
"$",
"realPath",
"=",
"$",
"finfo",
"->",
"getRealPath",
"(",
")",
";",
"if",
"(",
"!",
"$",
"realPath",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid path \"%s\" of template \"%s\" provided.'",
",",
"$",
"path",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"extension",
"=",
"$",
"finfo",
"->",
"getExtension",
"(",
")",
";",
"if",
"(",
"'phtml'",
"!==",
"$",
"extension",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid file extension \"%s\" of template \"%s\"; the extension '",
".",
"'of template file must be \"phtml\".'",
",",
"$",
"extension",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"templates",
"[",
"$",
"name",
"]",
"=",
"$",
"realPath",
";",
"}"
] | Sets template.
@param string $name The name of template
@param string $path The path to template
@throws \UnexpectedValueException If non-standart template name specified
@throws \InvalidArgumentException
- If specified template file not exists
- If the extension of template file is not "phtml" | [
"Sets",
"template",
"."
] | 5248c52f2992acc9ddf3542092ad7bbbb440e621 | https://github.com/easy-system/es-error/blob/5248c52f2992acc9ddf3542092ad7bbbb440e621/src/TemplateRenderer/TemplateResolver.php#L44-L72 |
1,535 | frogsystem/spawn | src/frogsystem/spawn/Container.php | Container.get | public function get($abstract, $args = [])
{
// element in container
if ($this->has($abstract)) {
// retrieve the entry
return $this->retrieve($this->container, $abstract, $args);
}
throw new Exceptions\NotFoundException("Abstract '{$abstract}' not found.");
} | php | public function get($abstract, $args = [])
{
// element in container
if ($this->has($abstract)) {
// retrieve the entry
return $this->retrieve($this->container, $abstract, $args);
}
throw new Exceptions\NotFoundException("Abstract '{$abstract}' not found.");
} | [
"public",
"function",
"get",
"(",
"$",
"abstract",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// element in container",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"abstract",
")",
")",
"{",
"// retrieve the entry",
"return",
"$",
"this",
"->",
"retrieve",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"abstract",
",",
"$",
"args",
")",
";",
"}",
"throw",
"new",
"Exceptions",
"\\",
"NotFoundException",
"(",
"\"Abstract '{$abstract}' not found.\"",
")",
";",
"}"
] | Invokes the registered entry for an abstract and returns the result.
@param string $abstract The abstract to store in the container.
@param array $args Array of arguments passed to a possible callable
@return mixed No entry was found for this identifier.
@throws NotFoundException | [
"Invokes",
"the",
"registered",
"entry",
"for",
"an",
"abstract",
"and",
"returns",
"the",
"result",
"."
] | fede7dcf09d276a4f0143783cd48c802fe1daad4 | https://github.com/frogsystem/spawn/blob/fede7dcf09d276a4f0143783cd48c802fe1daad4/src/frogsystem/spawn/Container.php#L127-L136 |
1,536 | frogsystem/spawn | src/frogsystem/spawn/Container.php | Container.retrieve | private function retrieve(&$from, $abstract, $args = [])
{
// get the entry
$entry = $from[$abstract];
// Closures will be invoked with DI and the result returned
if (is_object($entry) && ($entry instanceof \Closure)) {
return $this->invoke($entry, $args);
}
// return the unchanged value
return $entry;
} | php | private function retrieve(&$from, $abstract, $args = [])
{
// get the entry
$entry = $from[$abstract];
// Closures will be invoked with DI and the result returned
if (is_object($entry) && ($entry instanceof \Closure)) {
return $this->invoke($entry, $args);
}
// return the unchanged value
return $entry;
} | [
"private",
"function",
"retrieve",
"(",
"&",
"$",
"from",
",",
"$",
"abstract",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// get the entry",
"$",
"entry",
"=",
"$",
"from",
"[",
"$",
"abstract",
"]",
";",
"// Closures will be invoked with DI and the result returned",
"if",
"(",
"is_object",
"(",
"$",
"entry",
")",
"&&",
"(",
"$",
"entry",
"instanceof",
"\\",
"Closure",
")",
")",
"{",
"return",
"$",
"this",
"->",
"invoke",
"(",
"$",
"entry",
",",
"$",
"args",
")",
";",
"}",
"// return the unchanged value",
"return",
"$",
"entry",
";",
"}"
] | Helper method to retrieve an existing entry from a given library array.
You have to find sure, that the entry exists in the library.
@param $from
@param string $abstract The abstract to get.
@param array $args
@return mixed The entry.
@internal param $ &array $from The specified library. | [
"Helper",
"method",
"to",
"retrieve",
"an",
"existing",
"entry",
"from",
"a",
"given",
"library",
"array",
".",
"You",
"have",
"to",
"find",
"sure",
"that",
"the",
"entry",
"exists",
"in",
"the",
"library",
"."
] | fede7dcf09d276a4f0143783cd48c802fe1daad4 | https://github.com/frogsystem/spawn/blob/fede7dcf09d276a4f0143783cd48c802fe1daad4/src/frogsystem/spawn/Container.php#L147-L159 |
1,537 | frogsystem/spawn | src/frogsystem/spawn/Container.php | Container.make | public function make($concrete, array $args = [])
{
// build only from strings
if (!is_object($concrete) && !is_scalar($concrete) && !is_null($concrete)) {
throw new Exceptions\InvalidArgumentException();
}
// get reflection and parameters
$reflection = new \ReflectionClass($concrete);
$constructor = $reflection->getConstructor();
// Return new instance
$arguments = $constructor ? $this->inject($constructor, $args) : [];
return $reflection->newInstanceArgs($arguments);
} | php | public function make($concrete, array $args = [])
{
// build only from strings
if (!is_object($concrete) && !is_scalar($concrete) && !is_null($concrete)) {
throw new Exceptions\InvalidArgumentException();
}
// get reflection and parameters
$reflection = new \ReflectionClass($concrete);
$constructor = $reflection->getConstructor();
// Return new instance
$arguments = $constructor ? $this->inject($constructor, $args) : [];
return $reflection->newInstanceArgs($arguments);
} | [
"public",
"function",
"make",
"(",
"$",
"concrete",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// build only from strings",
"if",
"(",
"!",
"is_object",
"(",
"$",
"concrete",
")",
"&&",
"!",
"is_scalar",
"(",
"$",
"concrete",
")",
"&&",
"!",
"is_null",
"(",
"$",
"concrete",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidArgumentException",
"(",
")",
";",
"}",
"// get reflection and parameters",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"concrete",
")",
";",
"$",
"constructor",
"=",
"$",
"reflection",
"->",
"getConstructor",
"(",
")",
";",
"// Return new instance",
"$",
"arguments",
"=",
"$",
"constructor",
"?",
"$",
"this",
"->",
"inject",
"(",
"$",
"constructor",
",",
"$",
"args",
")",
":",
"[",
"]",
";",
"return",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"arguments",
")",
";",
"}"
] | Make a new instance of a concrete using Dependency Injection.
@param $concrete
@param array $args
@return mixed
@throws Exceptions\InvalidArgumentException | [
"Make",
"a",
"new",
"instance",
"of",
"a",
"concrete",
"using",
"Dependency",
"Injection",
"."
] | fede7dcf09d276a4f0143783cd48c802fe1daad4 | https://github.com/frogsystem/spawn/blob/fede7dcf09d276a4f0143783cd48c802fe1daad4/src/frogsystem/spawn/Container.php#L180-L194 |
1,538 | frogsystem/spawn | src/frogsystem/spawn/Container.php | Container.invoke | public function invoke(Callable $callable, array $args = [])
{
// object/class method
if (is_string($callable) && false !== strpos($callable, '::')) {
$callable = explode('::', $callable);
}
if (is_array($callable)) {
$reflection = new \ReflectionMethod($callable[0], $callable[1]);
}
// closures, functions and any other callable
if (!isset($reflection)) {
$reflection = new \ReflectionFunction($callable);
}
// inject arguments
$arguments = $this->inject($reflection, $args);
return $callable(...$arguments);
} | php | public function invoke(Callable $callable, array $args = [])
{
// object/class method
if (is_string($callable) && false !== strpos($callable, '::')) {
$callable = explode('::', $callable);
}
if (is_array($callable)) {
$reflection = new \ReflectionMethod($callable[0], $callable[1]);
}
// closures, functions and any other callable
if (!isset($reflection)) {
$reflection = new \ReflectionFunction($callable);
}
// inject arguments
$arguments = $this->inject($reflection, $args);
return $callable(...$arguments);
} | [
"public",
"function",
"invoke",
"(",
"Callable",
"$",
"callable",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// object/class method",
"if",
"(",
"is_string",
"(",
"$",
"callable",
")",
"&&",
"false",
"!==",
"strpos",
"(",
"$",
"callable",
",",
"'::'",
")",
")",
"{",
"$",
"callable",
"=",
"explode",
"(",
"'::'",
",",
"$",
"callable",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"callable",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"callable",
"[",
"0",
"]",
",",
"$",
"callable",
"[",
"1",
"]",
")",
";",
"}",
"// closures, functions and any other callable",
"if",
"(",
"!",
"isset",
"(",
"$",
"reflection",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"callable",
")",
";",
"}",
"// inject arguments",
"$",
"arguments",
"=",
"$",
"this",
"->",
"inject",
"(",
"$",
"reflection",
",",
"$",
"args",
")",
";",
"return",
"$",
"callable",
"(",
"...",
"$",
"arguments",
")",
";",
"}"
] | Invoke the given Closure with DI.
@param callable $callable
@param array $args
@return mixed
@throws Exceptions\ContainerException | [
"Invoke",
"the",
"given",
"Closure",
"with",
"DI",
"."
] | fede7dcf09d276a4f0143783cd48c802fe1daad4 | https://github.com/frogsystem/spawn/blob/fede7dcf09d276a4f0143783cd48c802fe1daad4/src/frogsystem/spawn/Container.php#L203-L221 |
1,539 | frogsystem/spawn | src/frogsystem/spawn/Container.php | Container.inject | protected function inject(\ReflectionFunctionAbstract $reflection, array $args = [])
{
// get parameters
$parameters = $reflection->getParameters();
// Build argument list
$arguments = [];
foreach ($parameters as $parameter) {
// Get class
$class = $parameter->getClass();
// From argument array (class or parameter name)
$key = $class && isset($args[$class->name]) ? $class->name : $parameter->name;
if (array_key_exists($key, $args)) {
$arguments[] = $args[$key];
unset($args[$key]);
continue;
}
// Delegated Lookup
if ($class && $this->delegate->has($class->name)) {
$arguments[] = $this->delegate->get($class->name);
continue;
}
// Real class
if ($class && class_exists($class->name)) {
$arguments[] = $this->make($class->name);
continue;
}
// Skip optional parameter with default value
if ($parameter->isDefaultValueAvailable()) {
$arguments[] = $parameter->getDefaultValue();
continue;
}
// Couldn't resolve the dependency
throw new Exceptions\ParameterResolutionException($reflection, $parameter);
}
return $arguments;
} | php | protected function inject(\ReflectionFunctionAbstract $reflection, array $args = [])
{
// get parameters
$parameters = $reflection->getParameters();
// Build argument list
$arguments = [];
foreach ($parameters as $parameter) {
// Get class
$class = $parameter->getClass();
// From argument array (class or parameter name)
$key = $class && isset($args[$class->name]) ? $class->name : $parameter->name;
if (array_key_exists($key, $args)) {
$arguments[] = $args[$key];
unset($args[$key]);
continue;
}
// Delegated Lookup
if ($class && $this->delegate->has($class->name)) {
$arguments[] = $this->delegate->get($class->name);
continue;
}
// Real class
if ($class && class_exists($class->name)) {
$arguments[] = $this->make($class->name);
continue;
}
// Skip optional parameter with default value
if ($parameter->isDefaultValueAvailable()) {
$arguments[] = $parameter->getDefaultValue();
continue;
}
// Couldn't resolve the dependency
throw new Exceptions\ParameterResolutionException($reflection, $parameter);
}
return $arguments;
} | [
"protected",
"function",
"inject",
"(",
"\\",
"ReflectionFunctionAbstract",
"$",
"reflection",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// get parameters",
"$",
"parameters",
"=",
"$",
"reflection",
"->",
"getParameters",
"(",
")",
";",
"// Build argument list",
"$",
"arguments",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
")",
"{",
"// Get class",
"$",
"class",
"=",
"$",
"parameter",
"->",
"getClass",
"(",
")",
";",
"// From argument array (class or parameter name)",
"$",
"key",
"=",
"$",
"class",
"&&",
"isset",
"(",
"$",
"args",
"[",
"$",
"class",
"->",
"name",
"]",
")",
"?",
"$",
"class",
"->",
"name",
":",
"$",
"parameter",
"->",
"name",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"args",
")",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"$",
"args",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"continue",
";",
"}",
"// Delegated Lookup",
"if",
"(",
"$",
"class",
"&&",
"$",
"this",
"->",
"delegate",
"->",
"has",
"(",
"$",
"class",
"->",
"name",
")",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"$",
"this",
"->",
"delegate",
"->",
"get",
"(",
"$",
"class",
"->",
"name",
")",
";",
"continue",
";",
"}",
"// Real class",
"if",
"(",
"$",
"class",
"&&",
"class_exists",
"(",
"$",
"class",
"->",
"name",
")",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"class",
"->",
"name",
")",
";",
"continue",
";",
"}",
"// Skip optional parameter with default value",
"if",
"(",
"$",
"parameter",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"arguments",
"[",
"]",
"=",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
";",
"continue",
";",
"}",
"// Couldn't resolve the dependency",
"throw",
"new",
"Exceptions",
"\\",
"ParameterResolutionException",
"(",
"$",
"reflection",
",",
"$",
"parameter",
")",
";",
"}",
"return",
"$",
"arguments",
";",
"}"
] | Performs the actual injection of dependencies from a reflection
@param \ReflectionFunctionAbstract $reflection
@param array $args
@return array The list of reflected arguments.
@throws Exceptions\ContainerException | [
"Performs",
"the",
"actual",
"injection",
"of",
"dependencies",
"from",
"a",
"reflection"
] | fede7dcf09d276a4f0143783cd48c802fe1daad4 | https://github.com/frogsystem/spawn/blob/fede7dcf09d276a4f0143783cd48c802fe1daad4/src/frogsystem/spawn/Container.php#L230-L272 |
1,540 | kherge-abandoned/Wisdom | src/lib/KevinGH/Wisdom/Silex/Provider.php | Provider.createService | public static function createService(Application $app, $serviceName, $pathName, $optionsName)
{
$app[$optionsName] = array();
$app[$serviceName] = $app->share(
function () use (
$app,
$serviceName,
$pathName,
$optionsName
) {
$app[$optionsName] = array_merge(
array(
'cache_path' => '',
'debug' => $app['debug'],
'prefix' => $app['debug'] ? 'dev.' : 'prod.'
),
$app[$optionsName]
);
if (false === isset($app[$optionsName]['loaders'])) {
$options = $app[$optionsName];
$options['loaders'] = array(
'KevinGH\Wisdom\Loader\INI',
'KevinGH\Wisdom\Loader\JSON'
);
if (class_exists('Symfony\Component\Yaml\Yaml')) {
$options['loaders'][] = 'KevinGH\Wisdom\Loader\YAML';
}
$app[$optionsName] = $options;
}
$wisdom = new Wisdom ($app[$pathName]);
$wisdom->setCache($app[$optionsName]['cache_path']);
$wisdom->setDebug($app[$optionsName]['debug']);
$wisdom->setPrefix($app[$optionsName]['prefix']);
$wisdom->setValues($app);
foreach ((array) $app[$optionsName]['loaders'] as $class) {
$wisdom->addLoader(new $class);
}
return $wisdom;
}
);
} | php | public static function createService(Application $app, $serviceName, $pathName, $optionsName)
{
$app[$optionsName] = array();
$app[$serviceName] = $app->share(
function () use (
$app,
$serviceName,
$pathName,
$optionsName
) {
$app[$optionsName] = array_merge(
array(
'cache_path' => '',
'debug' => $app['debug'],
'prefix' => $app['debug'] ? 'dev.' : 'prod.'
),
$app[$optionsName]
);
if (false === isset($app[$optionsName]['loaders'])) {
$options = $app[$optionsName];
$options['loaders'] = array(
'KevinGH\Wisdom\Loader\INI',
'KevinGH\Wisdom\Loader\JSON'
);
if (class_exists('Symfony\Component\Yaml\Yaml')) {
$options['loaders'][] = 'KevinGH\Wisdom\Loader\YAML';
}
$app[$optionsName] = $options;
}
$wisdom = new Wisdom ($app[$pathName]);
$wisdom->setCache($app[$optionsName]['cache_path']);
$wisdom->setDebug($app[$optionsName]['debug']);
$wisdom->setPrefix($app[$optionsName]['prefix']);
$wisdom->setValues($app);
foreach ((array) $app[$optionsName]['loaders'] as $class) {
$wisdom->addLoader(new $class);
}
return $wisdom;
}
);
} | [
"public",
"static",
"function",
"createService",
"(",
"Application",
"$",
"app",
",",
"$",
"serviceName",
",",
"$",
"pathName",
",",
"$",
"optionsName",
")",
"{",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"=",
"array",
"(",
")",
";",
"$",
"app",
"[",
"$",
"serviceName",
"]",
"=",
"$",
"app",
"->",
"share",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"app",
",",
"$",
"serviceName",
",",
"$",
"pathName",
",",
"$",
"optionsName",
")",
"{",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"=",
"array_merge",
"(",
"array",
"(",
"'cache_path'",
"=>",
"''",
",",
"'debug'",
"=>",
"$",
"app",
"[",
"'debug'",
"]",
",",
"'prefix'",
"=>",
"$",
"app",
"[",
"'debug'",
"]",
"?",
"'dev.'",
":",
"'prod.'",
")",
",",
"$",
"app",
"[",
"$",
"optionsName",
"]",
")",
";",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"[",
"'loaders'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"$",
"app",
"[",
"$",
"optionsName",
"]",
";",
"$",
"options",
"[",
"'loaders'",
"]",
"=",
"array",
"(",
"'KevinGH\\Wisdom\\Loader\\INI'",
",",
"'KevinGH\\Wisdom\\Loader\\JSON'",
")",
";",
"if",
"(",
"class_exists",
"(",
"'Symfony\\Component\\Yaml\\Yaml'",
")",
")",
"{",
"$",
"options",
"[",
"'loaders'",
"]",
"[",
"]",
"=",
"'KevinGH\\Wisdom\\Loader\\YAML'",
";",
"}",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"=",
"$",
"options",
";",
"}",
"$",
"wisdom",
"=",
"new",
"Wisdom",
"(",
"$",
"app",
"[",
"$",
"pathName",
"]",
")",
";",
"$",
"wisdom",
"->",
"setCache",
"(",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"[",
"'cache_path'",
"]",
")",
";",
"$",
"wisdom",
"->",
"setDebug",
"(",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"[",
"'debug'",
"]",
")",
";",
"$",
"wisdom",
"->",
"setPrefix",
"(",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"[",
"'prefix'",
"]",
")",
";",
"$",
"wisdom",
"->",
"setValues",
"(",
"$",
"app",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"app",
"[",
"$",
"optionsName",
"]",
"[",
"'loaders'",
"]",
"as",
"$",
"class",
")",
"{",
"$",
"wisdom",
"->",
"addLoader",
"(",
"new",
"$",
"class",
")",
";",
"}",
"return",
"$",
"wisdom",
";",
"}",
")",
";",
"}"
] | Creates a Wisdom service provider.
@param Application $app The Silex application.
@param string $serviceName The new service name.
@param string $pathName The new path parameter name.
@param string $optionsName The new options parameter name. | [
"Creates",
"a",
"Wisdom",
"service",
"provider",
"."
] | eb5b1dadde0729f2ccd1b241c2cecebc778e22f3 | https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Silex/Provider.php#L38-L86 |
1,541 | bazzline/php_component_process_pipe | source/Pipe.php | Pipe.pipe | public function pipe(ExecutableInterface $process, $_ = null)
{
foreach (func_get_args() as $index => $process) {
if ($process instanceof ExecutableInterface) {
$this->processes[] = $process;
} else {
$message = 'Argument ' . $index . ' passed to ' . __METHOD__ .
'() must implement interface ' .
'Net\Bazzline\Component\ProcessPipe\ExecutableInterface' .
', instance of ' . get_class($process) . ' given';
throw new InvalidArgumentException($message);
}
}
return $this;
} | php | public function pipe(ExecutableInterface $process, $_ = null)
{
foreach (func_get_args() as $index => $process) {
if ($process instanceof ExecutableInterface) {
$this->processes[] = $process;
} else {
$message = 'Argument ' . $index . ' passed to ' . __METHOD__ .
'() must implement interface ' .
'Net\Bazzline\Component\ProcessPipe\ExecutableInterface' .
', instance of ' . get_class($process) . ' given';
throw new InvalidArgumentException($message);
}
}
return $this;
} | [
"public",
"function",
"pipe",
"(",
"ExecutableInterface",
"$",
"process",
",",
"$",
"_",
"=",
"null",
")",
"{",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"index",
"=>",
"$",
"process",
")",
"{",
"if",
"(",
"$",
"process",
"instanceof",
"ExecutableInterface",
")",
"{",
"$",
"this",
"->",
"processes",
"[",
"]",
"=",
"$",
"process",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"'Argument '",
".",
"$",
"index",
".",
"' passed to '",
".",
"__METHOD__",
".",
"'() must implement interface '",
".",
"'Net\\Bazzline\\Component\\ProcessPipe\\ExecutableInterface'",
".",
"', instance of '",
".",
"get_class",
"(",
"$",
"process",
")",
".",
"' given'",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds one or more process to the pipe
@param ExecutableInterface $process - or more
@param ExecutableInterface $_ [optional]
@throws InvalidArgumentException
@return $this | [
"Adds",
"one",
"or",
"more",
"process",
"to",
"the",
"pipe"
] | 572a72398ed751ce26a202c3741599933e88925f | https://github.com/bazzline/php_component_process_pipe/blob/572a72398ed751ce26a202c3741599933e88925f/source/Pipe.php#L56-L71 |
1,542 | dronemill/phphelpers | src/Arrays.php | Arrays.make_assoc | public static function make_assoc($columns, $array)
{
/* init the array */
$assoc = array();
/* set the cursor to */
$cursor = 0;
/* itterate over the data, and combine the data */
foreach ($array as $record)
{
foreach ($record as $key => $value)
{
$assoc[$cursor][$columns[$key]] = $value;
}
$cursor++;
}
return $assoc;
} | php | public static function make_assoc($columns, $array)
{
/* init the array */
$assoc = array();
/* set the cursor to */
$cursor = 0;
/* itterate over the data, and combine the data */
foreach ($array as $record)
{
foreach ($record as $key => $value)
{
$assoc[$cursor][$columns[$key]] = $value;
}
$cursor++;
}
return $assoc;
} | [
"public",
"static",
"function",
"make_assoc",
"(",
"$",
"columns",
",",
"$",
"array",
")",
"{",
"/* init the array */",
"$",
"assoc",
"=",
"array",
"(",
")",
";",
"/* set the cursor to */",
"$",
"cursor",
"=",
"0",
";",
"/* itterate over the data, and combine the data */",
"foreach",
"(",
"$",
"array",
"as",
"$",
"record",
")",
"{",
"foreach",
"(",
"$",
"record",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"assoc",
"[",
"$",
"cursor",
"]",
"[",
"$",
"columns",
"[",
"$",
"key",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"cursor",
"++",
";",
"}",
"return",
"$",
"assoc",
";",
"}"
] | Convert an array into an associative array
@param array $columns the columns to match indexes on
@param array $array the data array to process | [
"Convert",
"an",
"array",
"into",
"an",
"associative",
"array"
] | 09531fc8cdbb757146cd068b6366d28951cdb433 | https://github.com/dronemill/phphelpers/blob/09531fc8cdbb757146cd068b6366d28951cdb433/src/Arrays.php#L56-L75 |
1,543 | dronemill/phphelpers | src/Arrays.php | Arrays.group_concat | public static function group_concat($data, $column, $strings = false, $quotes = '\'')
{
if (is_string($column))
{
$column = array($column);
}
/* init the return array */
$return = array();
foreach ($column as $col)
{
$return[$col] = ($strings ? $quotes : '');
}
/* itterate over the data */
foreach ($data as $row)
{
foreach ($column as $col)
{
$return[$col] .= $row[$col] . ($strings ? ($quotes . ',' . $quotes) : ',');
}
}
/* clean up the trailing comma */
foreach ($return as $column => $ret)
{
/* if the string is empty, continue on */
if (($length = strlen($ret)) < 1) continue;
/* the length to trim off */
$trim = 1;
if ($strings)
{
$trim = strlen($quotes) + 1;
}
$return[$column] = substr($ret, 0, $length - $trim);
}
/* return the values */
return $return;
} | php | public static function group_concat($data, $column, $strings = false, $quotes = '\'')
{
if (is_string($column))
{
$column = array($column);
}
/* init the return array */
$return = array();
foreach ($column as $col)
{
$return[$col] = ($strings ? $quotes : '');
}
/* itterate over the data */
foreach ($data as $row)
{
foreach ($column as $col)
{
$return[$col] .= $row[$col] . ($strings ? ($quotes . ',' . $quotes) : ',');
}
}
/* clean up the trailing comma */
foreach ($return as $column => $ret)
{
/* if the string is empty, continue on */
if (($length = strlen($ret)) < 1) continue;
/* the length to trim off */
$trim = 1;
if ($strings)
{
$trim = strlen($quotes) + 1;
}
$return[$column] = substr($ret, 0, $length - $trim);
}
/* return the values */
return $return;
} | [
"public",
"static",
"function",
"group_concat",
"(",
"$",
"data",
",",
"$",
"column",
",",
"$",
"strings",
"=",
"false",
",",
"$",
"quotes",
"=",
"'\\''",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"column",
")",
")",
"{",
"$",
"column",
"=",
"array",
"(",
"$",
"column",
")",
";",
"}",
"/* init the return array */",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"column",
"as",
"$",
"col",
")",
"{",
"$",
"return",
"[",
"$",
"col",
"]",
"=",
"(",
"$",
"strings",
"?",
"$",
"quotes",
":",
"''",
")",
";",
"}",
"/* itterate over the data */",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"column",
"as",
"$",
"col",
")",
"{",
"$",
"return",
"[",
"$",
"col",
"]",
".=",
"$",
"row",
"[",
"$",
"col",
"]",
".",
"(",
"$",
"strings",
"?",
"(",
"$",
"quotes",
".",
"','",
".",
"$",
"quotes",
")",
":",
"','",
")",
";",
"}",
"}",
"/* clean up the trailing comma */",
"foreach",
"(",
"$",
"return",
"as",
"$",
"column",
"=>",
"$",
"ret",
")",
"{",
"/* if the string is empty, continue on */",
"if",
"(",
"(",
"$",
"length",
"=",
"strlen",
"(",
"$",
"ret",
")",
")",
"<",
"1",
")",
"continue",
";",
"/* the length to trim off */",
"$",
"trim",
"=",
"1",
";",
"if",
"(",
"$",
"strings",
")",
"{",
"$",
"trim",
"=",
"strlen",
"(",
"$",
"quotes",
")",
"+",
"1",
";",
"}",
"$",
"return",
"[",
"$",
"column",
"]",
"=",
"substr",
"(",
"$",
"ret",
",",
"0",
",",
"$",
"length",
"-",
"$",
"trim",
")",
";",
"}",
"/* return the values */",
"return",
"$",
"return",
";",
"}"
] | emulate the MySql group concat function for a result set
@param array $data the data array to process
@param string|array $column the column to concat
@param boolean $strings treat the values as strings
@param string $quotes the quotes to use when handeling strings
@return array('column']=>'concated_string',...) | [
"emulate",
"the",
"MySql",
"group",
"concat",
"function",
"for",
"a",
"result",
"set"
] | 09531fc8cdbb757146cd068b6366d28951cdb433 | https://github.com/dronemill/phphelpers/blob/09531fc8cdbb757146cd068b6366d28951cdb433/src/Arrays.php#L87-L128 |
1,544 | dronemill/phphelpers | src/Arrays.php | Arrays.value_to_key | public static function value_to_key($data, $column)
{
/* init the return array */
$return = array();
/* itterate over all the elements */
foreach ($data as $key => $val)
{
if (is_object($val))
{
$return[$val->$column] = $val;
}
else
{
$return[$val[$column]] = $val;
}
}
/* return the array */
return $return;
} | php | public static function value_to_key($data, $column)
{
/* init the return array */
$return = array();
/* itterate over all the elements */
foreach ($data as $key => $val)
{
if (is_object($val))
{
$return[$val->$column] = $val;
}
else
{
$return[$val[$column]] = $val;
}
}
/* return the array */
return $return;
} | [
"public",
"static",
"function",
"value_to_key",
"(",
"$",
"data",
",",
"$",
"column",
")",
"{",
"/* init the return array */",
"$",
"return",
"=",
"array",
"(",
")",
";",
"/* itterate over all the elements */",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"val",
")",
")",
"{",
"$",
"return",
"[",
"$",
"val",
"->",
"$",
"column",
"]",
"=",
"$",
"val",
";",
"}",
"else",
"{",
"$",
"return",
"[",
"$",
"val",
"[",
"$",
"column",
"]",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"/* return the array */",
"return",
"$",
"return",
";",
"}"
] | column of array to key
@param array $data the data to process
@param mixed the column to store as the array key
@return the processed array | [
"column",
"of",
"array",
"to",
"key"
] | 09531fc8cdbb757146cd068b6366d28951cdb433 | https://github.com/dronemill/phphelpers/blob/09531fc8cdbb757146cd068b6366d28951cdb433/src/Arrays.php#L138-L158 |
1,545 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/UriNormalize.php | UriNormalize.filter | public function filter($value)
{
if (!is_scalar($value)) {
return $value;
}
$value = (string) $value;
$defaultScheme = $this->defaultScheme ?: $this->enforcedScheme;
// Reset default scheme if it is not a known scheme
if (!UriFactory::getRegisteredSchemeClass($defaultScheme)) {
$defaultScheme = null;
}
try {
$uri = UriFactory::factory($value, $defaultScheme);
if ($this->enforcedScheme && (!$uri->getScheme())) {
$this->enforceScheme($uri);
}
} catch (UriException $ex) {
// We are unable to parse / enfore scheme with the given config and input
return $value;
}
$uri->normalize();
if (!$uri->isValid()) {
return $value;
}
return $uri->toString();
} | php | public function filter($value)
{
if (!is_scalar($value)) {
return $value;
}
$value = (string) $value;
$defaultScheme = $this->defaultScheme ?: $this->enforcedScheme;
// Reset default scheme if it is not a known scheme
if (!UriFactory::getRegisteredSchemeClass($defaultScheme)) {
$defaultScheme = null;
}
try {
$uri = UriFactory::factory($value, $defaultScheme);
if ($this->enforcedScheme && (!$uri->getScheme())) {
$this->enforceScheme($uri);
}
} catch (UriException $ex) {
// We are unable to parse / enfore scheme with the given config and input
return $value;
}
$uri->normalize();
if (!$uri->isValid()) {
return $value;
}
return $uri->toString();
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"$",
"defaultScheme",
"=",
"$",
"this",
"->",
"defaultScheme",
"?",
":",
"$",
"this",
"->",
"enforcedScheme",
";",
"// Reset default scheme if it is not a known scheme",
"if",
"(",
"!",
"UriFactory",
"::",
"getRegisteredSchemeClass",
"(",
"$",
"defaultScheme",
")",
")",
"{",
"$",
"defaultScheme",
"=",
"null",
";",
"}",
"try",
"{",
"$",
"uri",
"=",
"UriFactory",
"::",
"factory",
"(",
"$",
"value",
",",
"$",
"defaultScheme",
")",
";",
"if",
"(",
"$",
"this",
"->",
"enforcedScheme",
"&&",
"(",
"!",
"$",
"uri",
"->",
"getScheme",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"enforceScheme",
"(",
"$",
"uri",
")",
";",
"}",
"}",
"catch",
"(",
"UriException",
"$",
"ex",
")",
"{",
"// We are unable to parse / enfore scheme with the given config and input",
"return",
"$",
"value",
";",
"}",
"$",
"uri",
"->",
"normalize",
"(",
")",
";",
"if",
"(",
"!",
"$",
"uri",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"$",
"uri",
"->",
"toString",
"(",
")",
";",
"}"
] | Filter the URL by normalizing it and applying a default scheme if set
@param string $value
@return string | [
"Filter",
"the",
"URL",
"by",
"normalizing",
"it",
"and",
"applying",
"a",
"default",
"scheme",
"if",
"set"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/UriNormalize.php#L85-L116 |
1,546 | anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/UriNormalize.php | UriNormalize.enforceScheme | protected function enforceScheme(Uri $uri)
{
$path = $uri->getPath();
if (strpos($path, '/') !== false) {
list($host, $path) = explode('/', $path, 2);
$path = '/' . $path;
} else {
$host = $path;
$path = '';
}
// We have nothing to do if we have no host
if (!$host) {
return;
}
$uri->setScheme($this->enforcedScheme)
->setHost($host)
->setPath($path);
} | php | protected function enforceScheme(Uri $uri)
{
$path = $uri->getPath();
if (strpos($path, '/') !== false) {
list($host, $path) = explode('/', $path, 2);
$path = '/' . $path;
} else {
$host = $path;
$path = '';
}
// We have nothing to do if we have no host
if (!$host) {
return;
}
$uri->setScheme($this->enforcedScheme)
->setHost($host)
->setPath($path);
} | [
"protected",
"function",
"enforceScheme",
"(",
"Uri",
"$",
"uri",
")",
"{",
"$",
"path",
"=",
"$",
"uri",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"host",
",",
"$",
"path",
")",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
",",
"2",
")",
";",
"$",
"path",
"=",
"'/'",
".",
"$",
"path",
";",
"}",
"else",
"{",
"$",
"host",
"=",
"$",
"path",
";",
"$",
"path",
"=",
"''",
";",
"}",
"// We have nothing to do if we have no host",
"if",
"(",
"!",
"$",
"host",
")",
"{",
"return",
";",
"}",
"$",
"uri",
"->",
"setScheme",
"(",
"$",
"this",
"->",
"enforcedScheme",
")",
"->",
"setHost",
"(",
"$",
"host",
")",
"->",
"setPath",
"(",
"$",
"path",
")",
";",
"}"
] | Enforce the defined scheme on the URI
This will also adjust the host and path parts of the URI as expected in
the case of scheme-less network URIs
@param Uri $uri | [
"Enforce",
"the",
"defined",
"scheme",
"on",
"the",
"URI"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/UriNormalize.php#L126-L145 |
1,547 | marcqualie/mongominify | src/MongoMinify/Collection.php | Collection.insert | public function insert(&$data, array $options = array())
{
$document = new Document($data, $this);
$insert = $document->insert($options);
$data = $document->data;
return $insert;
} | php | public function insert(&$data, array $options = array())
{
$document = new Document($data, $this);
$insert = $document->insert($options);
$data = $document->data;
return $insert;
} | [
"public",
"function",
"insert",
"(",
"&",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"document",
"=",
"new",
"Document",
"(",
"$",
"data",
",",
"$",
"this",
")",
";",
"$",
"insert",
"=",
"$",
"document",
"->",
"insert",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"$",
"document",
"->",
"data",
";",
"return",
"$",
"insert",
";",
"}"
] | Insert new document
@param [type] $document [description]
@param array $options [description]
@return [type] [description] | [
"Insert",
"new",
"document"
] | 63240a91431e09279009235596bfc7f67636b269 | https://github.com/marcqualie/mongominify/blob/63240a91431e09279009235596bfc7f67636b269/src/MongoMinify/Collection.php#L78-L85 |
1,548 | marcqualie/mongominify | src/MongoMinify/Collection.php | Collection.findAndModify | public function findAndModify(array $query, array $update = array(), array $fields = null, array $options = array())
{
$document = new Document($query, $this);
$findAndModify = $document->findAndModify($update, $fields, $options);
return $findAndModify;
} | php | public function findAndModify(array $query, array $update = array(), array $fields = null, array $options = array())
{
$document = new Document($query, $this);
$findAndModify = $document->findAndModify($update, $fields, $options);
return $findAndModify;
} | [
"public",
"function",
"findAndModify",
"(",
"array",
"$",
"query",
",",
"array",
"$",
"update",
"=",
"array",
"(",
")",
",",
"array",
"$",
"fields",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"document",
"=",
"new",
"Document",
"(",
"$",
"query",
",",
"$",
"this",
")",
";",
"$",
"findAndModify",
"=",
"$",
"document",
"->",
"findAndModify",
"(",
"$",
"update",
",",
"$",
"fields",
",",
"$",
"options",
")",
";",
"return",
"$",
"findAndModify",
";",
"}"
] | Find and Modify Document | [
"Find",
"and",
"Modify",
"Document"
] | 63240a91431e09279009235596bfc7f67636b269 | https://github.com/marcqualie/mongominify/blob/63240a91431e09279009235596bfc7f67636b269/src/MongoMinify/Collection.php#L101-L107 |
1,549 | marcqualie/mongominify | src/MongoMinify/Collection.php | Collection.getShort | public function getShort($full)
{
if (strpos($full, '*') !== false) {
return $this->schema_index[substr($full, 0, -2)] . '.*';
}
if (isset($this->schema[$full]['short'])) {
return $this->schema[$full]['short'];
}
return $full;
} | php | public function getShort($full)
{
if (strpos($full, '*') !== false) {
return $this->schema_index[substr($full, 0, -2)] . '.*';
}
if (isset($this->schema[$full]['short'])) {
return $this->schema[$full]['short'];
}
return $full;
} | [
"public",
"function",
"getShort",
"(",
"$",
"full",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"full",
",",
"'*'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"schema_index",
"[",
"substr",
"(",
"$",
"full",
",",
"0",
",",
"-",
"2",
")",
"]",
".",
"'.*'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"schema",
"[",
"$",
"full",
"]",
"[",
"'short'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"schema",
"[",
"$",
"full",
"]",
"[",
"'short'",
"]",
";",
"}",
"return",
"$",
"full",
";",
"}"
] | Get short definitions based on full key | [
"Get",
"short",
"definitions",
"based",
"on",
"full",
"key"
] | 63240a91431e09279009235596bfc7f67636b269 | https://github.com/marcqualie/mongominify/blob/63240a91431e09279009235596bfc7f67636b269/src/MongoMinify/Collection.php#L235-L244 |
1,550 | indigophp-archive/http-adapter | src/Exception/RequestException.php | RequestException.create | public static function create(
Request $request,
Response $response = null,
Exception $previous = null
) {
if (!$response) {
return new self('Error completing request', $request, null, $previous);
}
$code = $response->getStatusCode();
switch ($code[0]) {
case '4':
$message = 'Client Error';
break;
case '5':
$message = 'Server Error';
break;
default:
$message = 'Unknown Error';
break;
}
return new self($message, $request, $response, $previous);
} | php | public static function create(
Request $request,
Response $response = null,
Exception $previous = null
) {
if (!$response) {
return new self('Error completing request', $request, null, $previous);
}
$code = $response->getStatusCode();
switch ($code[0]) {
case '4':
$message = 'Client Error';
break;
case '5':
$message = 'Server Error';
break;
default:
$message = 'Unknown Error';
break;
}
return new self($message, $request, $response, $previous);
} | [
"public",
"static",
"function",
"create",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
"=",
"null",
",",
"Exception",
"$",
"previous",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"response",
")",
"{",
"return",
"new",
"self",
"(",
"'Error completing request'",
",",
"$",
"request",
",",
"null",
",",
"$",
"previous",
")",
";",
"}",
"$",
"code",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"switch",
"(",
"$",
"code",
"[",
"0",
"]",
")",
"{",
"case",
"'4'",
":",
"$",
"message",
"=",
"'Client Error'",
";",
"break",
";",
"case",
"'5'",
":",
"$",
"message",
"=",
"'Server Error'",
";",
"break",
";",
"default",
":",
"$",
"message",
"=",
"'Unknown Error'",
";",
"break",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"message",
",",
"$",
"request",
",",
"$",
"response",
",",
"$",
"previous",
")",
";",
"}"
] | Creates a new exception based on input data
@param Request $request
@param Response $response
@param Exception $previous | [
"Creates",
"a",
"new",
"exception",
"based",
"on",
"input",
"data"
] | 2233e8329a0704e020857228c2b538438e127475 | https://github.com/indigophp-archive/http-adapter/blob/2233e8329a0704e020857228c2b538438e127475/src/Exception/RequestException.php#L60-L84 |
1,551 | AydinHassan/XmlFuse | src/AbstractParser.php | AbstractParser.getScalarRecords | public function getScalarRecords(SimpleXMLElement $element, $asArray = true)
{
$data = [];
//multiple elements
if ($element->count()) {
foreach ($element->children() as $name => $property) {
if (!$property->count()) {
$data[$name] = (string)$property;
}
}
return $data;
//only 1 element
} elseif ($asArray) {
return [$element->getName() => (string)$element];
} else {
return (string) $element;
}
} | php | public function getScalarRecords(SimpleXMLElement $element, $asArray = true)
{
$data = [];
//multiple elements
if ($element->count()) {
foreach ($element->children() as $name => $property) {
if (!$property->count()) {
$data[$name] = (string)$property;
}
}
return $data;
//only 1 element
} elseif ($asArray) {
return [$element->getName() => (string)$element];
} else {
return (string) $element;
}
} | [
"public",
"function",
"getScalarRecords",
"(",
"SimpleXMLElement",
"$",
"element",
",",
"$",
"asArray",
"=",
"true",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"//multiple elements",
"if",
"(",
"$",
"element",
"->",
"count",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"element",
"->",
"children",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"property",
"->",
"count",
"(",
")",
")",
"{",
"$",
"data",
"[",
"$",
"name",
"]",
"=",
"(",
"string",
")",
"$",
"property",
";",
"}",
"}",
"return",
"$",
"data",
";",
"//only 1 element",
"}",
"elseif",
"(",
"$",
"asArray",
")",
"{",
"return",
"[",
"$",
"element",
"->",
"getName",
"(",
")",
"=>",
"(",
"string",
")",
"$",
"element",
"]",
";",
"}",
"else",
"{",
"return",
"(",
"string",
")",
"$",
"element",
";",
"}",
"}"
] | Get all the Scalar records in the current
element. Ignore all nested data. The XPaths should be
used to include this data.
@param SimpleXMLElement $element
@param bool $asArray If there is only 1 record found from xPath,
whether to return as an array or just the value
@return array | [
"Get",
"all",
"the",
"Scalar",
"records",
"in",
"the",
"current",
"element",
".",
"Ignore",
"all",
"nested",
"data",
".",
"The",
"XPaths",
"should",
"be",
"used",
"to",
"include",
"this",
"data",
"."
] | 60c2fd0501fed06084ba6bc3b634c125b7e41580 | https://github.com/AydinHassan/XmlFuse/blob/60c2fd0501fed06084ba6bc3b634c125b7e41580/src/AbstractParser.php#L65-L84 |
1,552 | AydinHassan/XmlFuse | src/AbstractParser.php | AbstractParser.parse | public function parse()
{
if (!count($this->xPaths)) {
return [[]];
}
//create copy of xPaths
$xPaths = $this->xPaths;
return $this->parseXPath($xPaths, $this->xml);
} | php | public function parse()
{
if (!count($this->xPaths)) {
return [[]];
}
//create copy of xPaths
$xPaths = $this->xPaths;
return $this->parseXPath($xPaths, $this->xml);
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"xPaths",
")",
")",
"{",
"return",
"[",
"[",
"]",
"]",
";",
"}",
"//create copy of xPaths",
"$",
"xPaths",
"=",
"$",
"this",
"->",
"xPaths",
";",
"return",
"$",
"this",
"->",
"parseXPath",
"(",
"$",
"xPaths",
",",
"$",
"this",
"->",
"xml",
")",
";",
"}"
] | Start the Fusing process
Using the XPaths try to merge
nested data with child data, recursively | [
"Start",
"the",
"Fusing",
"process",
"Using",
"the",
"XPaths",
"try",
"to",
"merge",
"nested",
"data",
"with",
"child",
"data",
"recursively"
] | 60c2fd0501fed06084ba6bc3b634c125b7e41580 | https://github.com/AydinHassan/XmlFuse/blob/60c2fd0501fed06084ba6bc3b634c125b7e41580/src/AbstractParser.php#L91-L101 |
1,553 | CampusUnion/Sked | src/SkeForm.php | SkeForm.setAttribs | public function setAttribs(array $aAttribs)
{
if (!isset($aAttribs['method']))
$aAttribs['method'] = 'POST';
$aAttribs['class'] = isset($aAttribs['class'])
? $aAttribs['class'] . ' sked-form' : 'sked-form';
$this->aAttribs = $aAttribs;
return $this;
} | php | public function setAttribs(array $aAttribs)
{
if (!isset($aAttribs['method']))
$aAttribs['method'] = 'POST';
$aAttribs['class'] = isset($aAttribs['class'])
? $aAttribs['class'] . ' sked-form' : 'sked-form';
$this->aAttribs = $aAttribs;
return $this;
} | [
"public",
"function",
"setAttribs",
"(",
"array",
"$",
"aAttribs",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"aAttribs",
"[",
"'method'",
"]",
")",
")",
"$",
"aAttribs",
"[",
"'method'",
"]",
"=",
"'POST'",
";",
"$",
"aAttribs",
"[",
"'class'",
"]",
"=",
"isset",
"(",
"$",
"aAttribs",
"[",
"'class'",
"]",
")",
"?",
"$",
"aAttribs",
"[",
"'class'",
"]",
".",
"' sked-form'",
":",
"'sked-form'",
";",
"$",
"this",
"->",
"aAttribs",
"=",
"$",
"aAttribs",
";",
"return",
"$",
"this",
";",
"}"
] | Set the HTML element attributes.
@param array $aAttribs The HTML element attributes.
@return $this | [
"Set",
"the",
"HTML",
"element",
"attributes",
"."
] | 5b51afdb56c0f607e54364635c4725627b19ecc6 | https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeForm.php#L112-L120 |
1,554 | CampusUnion/Sked | src/SkeForm.php | SkeForm.setSkeVent | public function setSkeVent($skeVent)
{
if (is_array($skeVent))
$skeVent = new SkeVent($skeVent);
$this->skeVent = $skeVent;
return $this;
} | php | public function setSkeVent($skeVent)
{
if (is_array($skeVent))
$skeVent = new SkeVent($skeVent);
$this->skeVent = $skeVent;
return $this;
} | [
"public",
"function",
"setSkeVent",
"(",
"$",
"skeVent",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"skeVent",
")",
")",
"$",
"skeVent",
"=",
"new",
"SkeVent",
"(",
"$",
"skeVent",
")",
";",
"$",
"this",
"->",
"skeVent",
"=",
"$",
"skeVent",
";",
"return",
"$",
"this",
";",
"}"
] | Save event object for populating defaults.
@param array|CampusUnion\Sked\SkeVent Event object for populating defaults.
@return $this | [
"Save",
"event",
"object",
"for",
"populating",
"defaults",
"."
] | 5b51afdb56c0f607e54364635c4725627b19ecc6 | https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeForm.php#L128-L134 |
1,555 | CampusUnion/Sked | src/SkeForm.php | SkeForm.inputs | public function inputs()
{
$aReturn = [];
foreach ($this->getFieldDefinitions() as $strFieldName => $aField) {
$skeFormInput = new SkeFormInput(
$strFieldName,
$aField['type'] ?? 'text',
$aField['options'] ?? [],
$aField['attribs'] ?? []
);
// Set value for existing event
if ($this->skeVent) {
$skeFormInput->setValue($this->skeVent->getProperty($strFieldName));
if ($this->skeVent->hasError($strFieldName))
$skeFormInput->setError($this->skeVent->getError($strFieldName));
}
$aReturn[] = $skeFormInput;
}
return $aReturn;
} | php | public function inputs()
{
$aReturn = [];
foreach ($this->getFieldDefinitions() as $strFieldName => $aField) {
$skeFormInput = new SkeFormInput(
$strFieldName,
$aField['type'] ?? 'text',
$aField['options'] ?? [],
$aField['attribs'] ?? []
);
// Set value for existing event
if ($this->skeVent) {
$skeFormInput->setValue($this->skeVent->getProperty($strFieldName));
if ($this->skeVent->hasError($strFieldName))
$skeFormInput->setError($this->skeVent->getError($strFieldName));
}
$aReturn[] = $skeFormInput;
}
return $aReturn;
} | [
"public",
"function",
"inputs",
"(",
")",
"{",
"$",
"aReturn",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFieldDefinitions",
"(",
")",
"as",
"$",
"strFieldName",
"=>",
"$",
"aField",
")",
"{",
"$",
"skeFormInput",
"=",
"new",
"SkeFormInput",
"(",
"$",
"strFieldName",
",",
"$",
"aField",
"[",
"'type'",
"]",
"??",
"'text'",
",",
"$",
"aField",
"[",
"'options'",
"]",
"??",
"[",
"]",
",",
"$",
"aField",
"[",
"'attribs'",
"]",
"??",
"[",
"]",
")",
";",
"// Set value for existing event",
"if",
"(",
"$",
"this",
"->",
"skeVent",
")",
"{",
"$",
"skeFormInput",
"->",
"setValue",
"(",
"$",
"this",
"->",
"skeVent",
"->",
"getProperty",
"(",
"$",
"strFieldName",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"skeVent",
"->",
"hasError",
"(",
"$",
"strFieldName",
")",
")",
"$",
"skeFormInput",
"->",
"setError",
"(",
"$",
"this",
"->",
"skeVent",
"->",
"getError",
"(",
"$",
"strFieldName",
")",
")",
";",
"}",
"$",
"aReturn",
"[",
"]",
"=",
"$",
"skeFormInput",
";",
"}",
"return",
"$",
"aReturn",
";",
"}"
] | Get inputs for SkeVent form.
@return array | [
"Get",
"inputs",
"for",
"SkeVent",
"form",
"."
] | 5b51afdb56c0f607e54364635c4725627b19ecc6 | https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeForm.php#L309-L328 |
1,556 | tekkla/core-security | Core/Security/Password/HashGenerator.php | HashGenerator.checkPassword | public function checkPassword(): bool
{
if (!isset($this->regex)) {
return true;
}
return filter_var($this->password, FILTER_VALIDATE_REGEXP, [
'options' => [
'regexp' => $this->regex
]
]);
} | php | public function checkPassword(): bool
{
if (!isset($this->regex)) {
return true;
}
return filter_var($this->password, FILTER_VALIDATE_REGEXP, [
'options' => [
'regexp' => $this->regex
]
]);
} | [
"public",
"function",
"checkPassword",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"regex",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"filter_var",
"(",
"$",
"this",
"->",
"password",
",",
"FILTER_VALIDATE_REGEXP",
",",
"[",
"'options'",
"=>",
"[",
"'regexp'",
"=>",
"$",
"this",
"->",
"regex",
"]",
"]",
")",
";",
"}"
] | Checks the password agains the set regex and returns the boolean result of this check
@return bool | [
"Checks",
"the",
"password",
"agains",
"the",
"set",
"regex",
"and",
"returns",
"the",
"boolean",
"result",
"of",
"this",
"check"
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/Password/HashGenerator.php#L121-L132 |
1,557 | snapwp/snap-debug | src/Utils/Debug_Hook.php | Debug_Hook.get_data | public function get_data($priority = null)
{
if ($priority === null) {
return $this->data;
}
if (isset($this->data[ $priority ])) {
return $this->data[ $priority ];
}
return [];
} | php | public function get_data($priority = null)
{
if ($priority === null) {
return $this->data;
}
if (isset($this->data[ $priority ])) {
return $this->data[ $priority ];
}
return [];
} | [
"public",
"function",
"get_data",
"(",
"$",
"priority",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"priority",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"data",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"priority",
"]",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Return all data for the hook.
If $priority is supplied, then only data for that priority is returned.
@since 1.0.0
@param int $priority The priority to return the hook stack for.
@return array | [
"Return",
"all",
"data",
"for",
"the",
"hook",
"."
] | 49c0c258ce50098a3fca076ce122adf57571f2e2 | https://github.com/snapwp/snap-debug/blob/49c0c258ce50098a3fca076ce122adf57571f2e2/src/Utils/Debug_Hook.php#L106-L117 |
1,558 | snapwp/snap-debug | src/Utils/Debug_Hook.php | Debug_Hook.generate_hook_info | private function generate_hook_info($type, $reflector, $args)
{
$output = [
'type' => $type,
'file_name' => $reflector->getFileName(),
'line_number' => $reflector->getStartLine(),
'class' => null,
'name' => null,
'is_internal' => false,
];
if ($reflector instanceof ReflectionMethod) {
$output['class'] = $reflector->getDeclaringClass()->getName();
}
if ('Closure' !== $type) {
$output['name'] = $reflector->getName();
$output['is_internal'] = $reflector->isInternal();
}
$output['accepted_args'] = $args;
return $output;
} | php | private function generate_hook_info($type, $reflector, $args)
{
$output = [
'type' => $type,
'file_name' => $reflector->getFileName(),
'line_number' => $reflector->getStartLine(),
'class' => null,
'name' => null,
'is_internal' => false,
];
if ($reflector instanceof ReflectionMethod) {
$output['class'] = $reflector->getDeclaringClass()->getName();
}
if ('Closure' !== $type) {
$output['name'] = $reflector->getName();
$output['is_internal'] = $reflector->isInternal();
}
$output['accepted_args'] = $args;
return $output;
} | [
"private",
"function",
"generate_hook_info",
"(",
"$",
"type",
",",
"$",
"reflector",
",",
"$",
"args",
")",
"{",
"$",
"output",
"=",
"[",
"'type'",
"=>",
"$",
"type",
",",
"'file_name'",
"=>",
"$",
"reflector",
"->",
"getFileName",
"(",
")",
",",
"'line_number'",
"=>",
"$",
"reflector",
"->",
"getStartLine",
"(",
")",
",",
"'class'",
"=>",
"null",
",",
"'name'",
"=>",
"null",
",",
"'is_internal'",
"=>",
"false",
",",
"]",
";",
"if",
"(",
"$",
"reflector",
"instanceof",
"ReflectionMethod",
")",
"{",
"$",
"output",
"[",
"'class'",
"]",
"=",
"$",
"reflector",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
";",
"}",
"if",
"(",
"'Closure'",
"!==",
"$",
"type",
")",
"{",
"$",
"output",
"[",
"'name'",
"]",
"=",
"$",
"reflector",
"->",
"getName",
"(",
")",
";",
"$",
"output",
"[",
"'is_internal'",
"]",
"=",
"$",
"reflector",
"->",
"isInternal",
"(",
")",
";",
"}",
"$",
"output",
"[",
"'accepted_args'",
"]",
"=",
"$",
"args",
";",
"return",
"$",
"output",
";",
"}"
] | Generate output for a hook callback.
@since 1.0.0
@param string $type The callback type.
@param object $reflector The reflection object handling this callback.
@param int $args The number of args defined when this callback was added.
@return array | [
"Generate",
"output",
"for",
"a",
"hook",
"callback",
"."
] | 49c0c258ce50098a3fca076ce122adf57571f2e2 | https://github.com/snapwp/snap-debug/blob/49c0c258ce50098a3fca076ce122adf57571f2e2/src/Utils/Debug_Hook.php#L129-L152 |
1,559 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.extractMessagesForDisplay | protected function extractMessagesForDisplay(&$messages)
{
$output = [];
if (empty($messages) || count($messages) == 0) {
return $output;
}
foreach ($messages as $current) {
$message_entry["message"] = $current["message"];
if (!empty($current["code"])) {
$message_entry["code"] = $current["code"];
}
if (!empty($current["auto_hide"])) {
$message_entry["auto_hide"] = $this->getAutoHideTime();
}
if (!empty($current["details"]) && config_settings()->getParameter("show_message_details", false, 1)) {
$message_entry["details"] = $current["details"];
}
$output[] = $message_entry;
} // foreach
// unset messages because they has been shown
$messages = null;
return $output;
} | php | protected function extractMessagesForDisplay(&$messages)
{
$output = [];
if (empty($messages) || count($messages) == 0) {
return $output;
}
foreach ($messages as $current) {
$message_entry["message"] = $current["message"];
if (!empty($current["code"])) {
$message_entry["code"] = $current["code"];
}
if (!empty($current["auto_hide"])) {
$message_entry["auto_hide"] = $this->getAutoHideTime();
}
if (!empty($current["details"]) && config_settings()->getParameter("show_message_details", false, 1)) {
$message_entry["details"] = $current["details"];
}
$output[] = $message_entry;
} // foreach
// unset messages because they has been shown
$messages = null;
return $output;
} | [
"protected",
"function",
"extractMessagesForDisplay",
"(",
"&",
"$",
"messages",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"messages",
")",
"||",
"count",
"(",
"$",
"messages",
")",
"==",
"0",
")",
"{",
"return",
"$",
"output",
";",
"}",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"current",
")",
"{",
"$",
"message_entry",
"[",
"\"message\"",
"]",
"=",
"$",
"current",
"[",
"\"message\"",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"current",
"[",
"\"code\"",
"]",
")",
")",
"{",
"$",
"message_entry",
"[",
"\"code\"",
"]",
"=",
"$",
"current",
"[",
"\"code\"",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"current",
"[",
"\"auto_hide\"",
"]",
")",
")",
"{",
"$",
"message_entry",
"[",
"\"auto_hide\"",
"]",
"=",
"$",
"this",
"->",
"getAutoHideTime",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"current",
"[",
"\"details\"",
"]",
")",
"&&",
"config_settings",
"(",
")",
"->",
"getParameter",
"(",
"\"show_message_details\"",
",",
"false",
",",
"1",
")",
")",
"{",
"$",
"message_entry",
"[",
"\"details\"",
"]",
"=",
"$",
"current",
"[",
"\"details\"",
"]",
";",
"}",
"$",
"output",
"[",
"]",
"=",
"$",
"message_entry",
";",
"}",
"// foreach",
"// unset messages because they has been shown",
"$",
"messages",
"=",
"null",
";",
"return",
"$",
"output",
";",
"}"
] | This is internal auxiliary function for preparing messags for displaying.
When the messages are requested, it is assumed they will be displayed. Thus,
the message array is cleared to avoid displaying of the same messages twice.
The message details are removed if the flag show_message_details is false.
@param array $messages
The source array of messages.
@return array
Returns the array of messages for displaying.
@author Oleg Schildt | [
"This",
"is",
"internal",
"auxiliary",
"function",
"for",
"preparing",
"messags",
"for",
"displaying",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L72-L102 |
1,560 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.getFocusElement | public function getFocusElement()
{
if (empty(self::$session_vars["focus_element"])) {
return "";
}
$felm = self::$session_vars["focus_element"];
unset(self::$session_vars["focus_element"]);
return $felm;
} | php | public function getFocusElement()
{
if (empty(self::$session_vars["focus_element"])) {
return "";
}
$felm = self::$session_vars["focus_element"];
unset(self::$session_vars["focus_element"]);
return $felm;
} | [
"public",
"function",
"getFocusElement",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"focus_element\"",
"]",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"felm",
"=",
"self",
"::",
"$",
"session_vars",
"[",
"\"focus_element\"",
"]",
";",
"unset",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"focus_element\"",
"]",
")",
";",
"return",
"$",
"felm",
";",
"}"
] | Returns the element to be focused.
When this method is called, it is assumed that the element will be focused. Thus,
the stored element is cleared to avoid focusing of the same element twice.
@return string
Returns the ID of the element to be focused.
@see getFocusElement()
@author Oleg Schildt | [
"Returns",
"the",
"element",
"to",
"be",
"focused",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L166-L177 |
1,561 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.getActiveTab | public function getActiveTab()
{
if (empty(self::$session_vars["active_tab"])) {
return "";
}
$atab = self::$session_vars["active_tab"];
unset(self::$session_vars["active_tab"]);
return $atab;
} | php | public function getActiveTab()
{
if (empty(self::$session_vars["active_tab"])) {
return "";
}
$atab = self::$session_vars["active_tab"];
unset(self::$session_vars["active_tab"]);
return $atab;
} | [
"public",
"function",
"getActiveTab",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"active_tab\"",
"]",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"atab",
"=",
"self",
"::",
"$",
"session_vars",
"[",
"\"active_tab\"",
"]",
";",
"unset",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"active_tab\"",
"]",
")",
";",
"return",
"$",
"atab",
";",
"}"
] | Returns the tab to be activated.
When this method is called, it is assumed that the tab will be activated. Thus,
the stored active tab is cleared to avoid activating of the same tab twice.
@return string
Returns the ID of the tab to be activated.
@see setActiveTab()
@author Oleg Schildt | [
"Returns",
"the",
"tab",
"to",
"be",
"activated",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L209-L220 |
1,562 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.getErrorElement | public function getErrorElement()
{
if (empty(self::$session_vars["error_element"])) {
return "";
}
$felm = self::$session_vars["error_element"];
unset(self::$session_vars["error_element"]);
return $felm;
} | php | public function getErrorElement()
{
if (empty(self::$session_vars["error_element"])) {
return "";
}
$felm = self::$session_vars["error_element"];
unset(self::$session_vars["error_element"]);
return $felm;
} | [
"public",
"function",
"getErrorElement",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"error_element\"",
"]",
")",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"felm",
"=",
"self",
"::",
"$",
"session_vars",
"[",
"\"error_element\"",
"]",
";",
"unset",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"error_element\"",
"]",
")",
";",
"return",
"$",
"felm",
";",
"}"
] | Returns the field to be highlighted.
When this method is called, it is assumed that element will be highlighted. Thus,
the stored element is cleared to avoid highlighting of the same element twice.
@return string
Returns the ID of the field to be highlighted.
@see setErrorElement()
@author Oleg Schildt | [
"Returns",
"the",
"field",
"to",
"be",
"highlighted",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L253-L264 |
1,563 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.setError | public function setError($message, $details = "", $code = "")
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["errors"][$message] = ["message" => $message, "details" => $details, "code" => $code];
} | php | public function setError($message, $details = "", $code = "")
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["errors"][$message] = ["message" => $message, "details" => $details, "code" => $code];
} | [
"public",
"function",
"setError",
"(",
"$",
"message",
",",
"$",
"details",
"=",
"\"\"",
",",
"$",
"code",
"=",
"\"\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"return",
";",
"}",
"// we keep messages in the session",
"// until we are sure they are shown",
"// otherwise some messages may be lost",
"// because of redirection",
"self",
"::",
"$",
"session_vars",
"[",
"\"errors\"",
"]",
"[",
"$",
"message",
"]",
"=",
"[",
"\"message\"",
"=>",
"$",
"message",
",",
"\"details\"",
"=>",
"$",
"details",
",",
"\"code\"",
"=>",
"$",
"code",
"]",
";",
"}"
] | Stores the error to be reported.
@param string $message
The error message to be reported.
@param string $details
The error details to be reported. Here, more
technical details should be placed. Displaying
of this part might be controlled over a option
"display message details".
@param string $code
The error code to be reported.
@return void
@see getErrors()
@see clearErrors()
@see errorsExist()
@author Oleg Schildt | [
"Stores",
"the",
"error",
"to",
"be",
"reported",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L289-L300 |
1,564 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.setWarning | public function setWarning($message, $details = "")
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["warnings"][$message] = ["message" => $message, "details" => $details];
} | php | public function setWarning($message, $details = "")
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["warnings"][$message] = ["message" => $message, "details" => $details];
} | [
"public",
"function",
"setWarning",
"(",
"$",
"message",
",",
"$",
"details",
"=",
"\"\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"return",
";",
"}",
"// we keep messages in the session",
"// until we are sure they are shown",
"// otherwise some messages may be lost",
"// because of redirection",
"self",
"::",
"$",
"session_vars",
"[",
"\"warnings\"",
"]",
"[",
"$",
"message",
"]",
"=",
"[",
"\"message\"",
"=>",
"$",
"message",
",",
"\"details\"",
"=>",
"$",
"details",
"]",
";",
"}"
] | Stores the warning to be reported.
@param string $message
The warning message to be reported.
@param string $details
The warning details to be reported. Here, more
technical details should be placed. Displaying
of this part might be controlled over a option
"display message details".
@return void
@see getWarnings()
@see clearWarnings()
@see warningsExist()
@author Oleg Schildt | [
"Stores",
"the",
"warning",
"to",
"be",
"reported",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L390-L401 |
1,565 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.setProgWarning | public function setProgWarning($message, $details = "")
{
if (empty($message) || !$this->progWarningsActive()) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["prog_warnings"][$message] = ["message" => $message, "details" => $details];
} | php | public function setProgWarning($message, $details = "")
{
if (empty($message) || !$this->progWarningsActive()) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["prog_warnings"][$message] = ["message" => $message, "details" => $details];
} | [
"public",
"function",
"setProgWarning",
"(",
"$",
"message",
",",
"$",
"details",
"=",
"\"\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
"||",
"!",
"$",
"this",
"->",
"progWarningsActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"// we keep messages in the session",
"// until we are sure they are shown",
"// otherwise some messages may be lost",
"// because of redirection",
"self",
"::",
"$",
"session_vars",
"[",
"\"prog_warnings\"",
"]",
"[",
"$",
"message",
"]",
"=",
"[",
"\"message\"",
"=>",
"$",
"message",
",",
"\"details\"",
"=>",
"$",
"details",
"]",
";",
"}"
] | Stores the programming warning to be reported.
Programming warnings are shown only if the option
"show programming warning" is active.
@param string $message
The programming warning message to be reported.
@param string $details
The programming warning details to be reported. Here, more
technical details should be placed. Displaying
of this part might be controlled over a option
"display message details".
@return void
@see getProgWarnings()
@see clearProgWarnings()
@see progWarningsExist()
@author Oleg Schildt | [
"Stores",
"the",
"programming",
"warning",
"to",
"be",
"reported",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L494-L505 |
1,566 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.setDebugMessage | public function setDebugMessage($message, $details = "")
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["debug"][$message] = ["message" => $message, "details" => $details];
} | php | public function setDebugMessage($message, $details = "")
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["debug"][$message] = ["message" => $message, "details" => $details];
} | [
"public",
"function",
"setDebugMessage",
"(",
"$",
"message",
",",
"$",
"details",
"=",
"\"\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"return",
";",
"}",
"// we keep messages in the session",
"// until we are sure they are shown",
"// otherwise some messages may be lost",
"// because of redirection",
"self",
"::",
"$",
"session_vars",
"[",
"\"debug\"",
"]",
"[",
"$",
"message",
"]",
"=",
"[",
"\"message\"",
"=>",
"$",
"message",
",",
"\"details\"",
"=>",
"$",
"details",
"]",
";",
"}"
] | Stores the debugging message to be reported.
Displaying of the debugging messages might be
implemented to simplify the debugging process,
e.g. to the browser console or in a lightbox.
@param string $message
The debugging message message to be reported.
@param string $details
The debugging message details to be reported. Here, more
technical details should be placed. Displaying
of this part might be controlled over a option
"display message details".
@return void
@see getDebugMessages()
@see clearDebugMessages()
@see debugMessageExists()
@author Oleg Schildt | [
"Stores",
"the",
"debugging",
"message",
"to",
"be",
"reported",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L599-L610 |
1,567 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.setInfo | public function setInfo($message, $details = "", $auto_hide = false)
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["infos"][$message] = [
"message" => $message,
"details" => $details,
"auto_hide" => $auto_hide
];
} | php | public function setInfo($message, $details = "", $auto_hide = false)
{
if (empty($message)) {
return;
}
// we keep messages in the session
// until we are sure they are shown
// otherwise some messages may be lost
// because of redirection
self::$session_vars["infos"][$message] = [
"message" => $message,
"details" => $details,
"auto_hide" => $auto_hide
];
} | [
"public",
"function",
"setInfo",
"(",
"$",
"message",
",",
"$",
"details",
"=",
"\"\"",
",",
"$",
"auto_hide",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
")",
"{",
"return",
";",
"}",
"// we keep messages in the session",
"// until we are sure they are shown",
"// otherwise some messages may be lost",
"// because of redirection",
"self",
"::",
"$",
"session_vars",
"[",
"\"infos\"",
"]",
"[",
"$",
"message",
"]",
"=",
"[",
"\"message\"",
"=>",
"$",
"message",
",",
"\"details\"",
"=>",
"$",
"details",
",",
"\"auto_hide\"",
"=>",
"$",
"auto_hide",
"]",
";",
"}"
] | Stores the information message to be reported.
@param string $message
The information message to be reported.
@param string $details
The information message details to be reported. Here, more
technical details should be placed. Displaying
of this part might be controlled over a option
"display message details".
@param boolean $auto_hide
The flag that controls whether the message box should be closed
automatically after a time defined by the initialization.
@return void
@see getInfos()
@see clearInfos()
@see infosExist()
@author Oleg Schildt | [
"Stores",
"the",
"information",
"message",
"to",
"be",
"reported",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L704-L719 |
1,568 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.clearAll | public function clearAll()
{
$this->clearErrors();
$this->clearWarnings();
$this->clearProgWarnings();
$this->clearDebugMessages();
$this->clearInfos();
unset(self::$session_vars["focus_element"]);
unset(self::$session_vars["error_element"]);
unset(self::$session_vars["active_tab"]);
} | php | public function clearAll()
{
$this->clearErrors();
$this->clearWarnings();
$this->clearProgWarnings();
$this->clearDebugMessages();
$this->clearInfos();
unset(self::$session_vars["focus_element"]);
unset(self::$session_vars["error_element"]);
unset(self::$session_vars["active_tab"]);
} | [
"public",
"function",
"clearAll",
"(",
")",
"{",
"$",
"this",
"->",
"clearErrors",
"(",
")",
";",
"$",
"this",
"->",
"clearWarnings",
"(",
")",
";",
"$",
"this",
"->",
"clearProgWarnings",
"(",
")",
";",
"$",
"this",
"->",
"clearDebugMessages",
"(",
")",
";",
"$",
"this",
"->",
"clearInfos",
"(",
")",
";",
"unset",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"focus_element\"",
"]",
")",
";",
"unset",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"error_element\"",
"]",
")",
";",
"unset",
"(",
"self",
"::",
"$",
"session_vars",
"[",
"\"active_tab\"",
"]",
")",
";",
"}"
] | Clears all stored messages and active elements.
@return void
@see clearErrors()
@see clearWarnings()
@see clearProgWarnings()
@see clearDebugMessages()
@see clearInfos()
@author Oleg Schildt | [
"Clears",
"all",
"stored",
"messages",
"and",
"active",
"elements",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L802-L813 |
1,569 | oschildt/SmartFactory | src/SmartFactory/MessageManager.php | MessageManager.addMessagesToResponse | public function addMessagesToResponse(&$response)
{
if ($this->infosExist()) {
$response["INFO_MESSAGES"] = $this->getInfos();
}
if ($this->warningsExist()) {
$response["WARNING_MESSAGES"] = $this->getWarnings();
}
if ($this->errorsExist()) {
$response["ERROR_MESSAGES"] = $this->getErrors();
}
if ($this->progWarningsExist()) {
$response["PROG_WARNINGS"] = $this->getProgWarnings();
}
if ($this->debugMessageExists()) {
$response["DEBUG_MESSAGES"] = $this->getDebugMessages();
}
$response["AUTO_HIDE_TIME"] = $this->getAutoHideTime();
$response["FOCUS_ELEMENT"] = $this->getFocusElement();
$response["ACTIVE_TAB"] = $this->getActiveTab();
$response["ERROR_ELEMENT"] = $this->getErrorElement();
} | php | public function addMessagesToResponse(&$response)
{
if ($this->infosExist()) {
$response["INFO_MESSAGES"] = $this->getInfos();
}
if ($this->warningsExist()) {
$response["WARNING_MESSAGES"] = $this->getWarnings();
}
if ($this->errorsExist()) {
$response["ERROR_MESSAGES"] = $this->getErrors();
}
if ($this->progWarningsExist()) {
$response["PROG_WARNINGS"] = $this->getProgWarnings();
}
if ($this->debugMessageExists()) {
$response["DEBUG_MESSAGES"] = $this->getDebugMessages();
}
$response["AUTO_HIDE_TIME"] = $this->getAutoHideTime();
$response["FOCUS_ELEMENT"] = $this->getFocusElement();
$response["ACTIVE_TAB"] = $this->getActiveTab();
$response["ERROR_ELEMENT"] = $this->getErrorElement();
} | [
"public",
"function",
"addMessagesToResponse",
"(",
"&",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"infosExist",
"(",
")",
")",
"{",
"$",
"response",
"[",
"\"INFO_MESSAGES\"",
"]",
"=",
"$",
"this",
"->",
"getInfos",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"warningsExist",
"(",
")",
")",
"{",
"$",
"response",
"[",
"\"WARNING_MESSAGES\"",
"]",
"=",
"$",
"this",
"->",
"getWarnings",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"errorsExist",
"(",
")",
")",
"{",
"$",
"response",
"[",
"\"ERROR_MESSAGES\"",
"]",
"=",
"$",
"this",
"->",
"getErrors",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"progWarningsExist",
"(",
")",
")",
"{",
"$",
"response",
"[",
"\"PROG_WARNINGS\"",
"]",
"=",
"$",
"this",
"->",
"getProgWarnings",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"debugMessageExists",
"(",
")",
")",
"{",
"$",
"response",
"[",
"\"DEBUG_MESSAGES\"",
"]",
"=",
"$",
"this",
"->",
"getDebugMessages",
"(",
")",
";",
"}",
"$",
"response",
"[",
"\"AUTO_HIDE_TIME\"",
"]",
"=",
"$",
"this",
"->",
"getAutoHideTime",
"(",
")",
";",
"$",
"response",
"[",
"\"FOCUS_ELEMENT\"",
"]",
"=",
"$",
"this",
"->",
"getFocusElement",
"(",
")",
";",
"$",
"response",
"[",
"\"ACTIVE_TAB\"",
"]",
"=",
"$",
"this",
"->",
"getActiveTab",
"(",
")",
";",
"$",
"response",
"[",
"\"ERROR_ELEMENT\"",
"]",
"=",
"$",
"this",
"->",
"getErrorElement",
"(",
")",
";",
"}"
] | Add all stored existing messages to the response.
When the messages are requested, it is assumed they will be displayed. Thus,
the message array is cleared to avoid displaying of the same messages twice.
@param string $response
The target array where the messages should be added.
@return void
@author Oleg Schildt | [
"Add",
"all",
"stored",
"existing",
"messages",
"to",
"the",
"response",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/MessageManager.php#L843-L872 |
1,570 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.addNode | public function addNode(\DOMNode $node)
{
if ($node instanceof \DOMDocument) {
$node = $node->documentElement;
}
if (null !== $this->document && $this->document !== $node->ownerDocument) {
throw new \InvalidArgumentException('Attaching DOM nodes from multiple documents in the same crawler is forbidden.');
}
if (null === $this->document) {
$this->document = $node->ownerDocument;
}
// Don't add duplicate nodes in the Crawler
if (in_array($node, $this->nodes, true)) {
return;
}
$this->nodes[] = $node;
} | php | public function addNode(\DOMNode $node)
{
if ($node instanceof \DOMDocument) {
$node = $node->documentElement;
}
if (null !== $this->document && $this->document !== $node->ownerDocument) {
throw new \InvalidArgumentException('Attaching DOM nodes from multiple documents in the same crawler is forbidden.');
}
if (null === $this->document) {
$this->document = $node->ownerDocument;
}
// Don't add duplicate nodes in the Crawler
if (in_array($node, $this->nodes, true)) {
return;
}
$this->nodes[] = $node;
} | [
"public",
"function",
"addNode",
"(",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMDocument",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"documentElement",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"document",
"&&",
"$",
"this",
"->",
"document",
"!==",
"$",
"node",
"->",
"ownerDocument",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Attaching DOM nodes from multiple documents in the same crawler is forbidden.'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"document",
")",
"{",
"$",
"this",
"->",
"document",
"=",
"$",
"node",
"->",
"ownerDocument",
";",
"}",
"// Don't add duplicate nodes in the Crawler",
"if",
"(",
"in_array",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"nodes",
",",
"true",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"nodes",
"[",
"]",
"=",
"$",
"node",
";",
"}"
] | Adds a \DOMNode instance to the list of nodes.
@param \DOMNode $node A \DOMNode instance | [
"Adds",
"a",
"\\",
"DOMNode",
"instance",
"to",
"the",
"list",
"of",
"nodes",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L310-L330 |
1,571 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.parents | public function parents()
{
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
$nodes = array();
while ($node = $node->parentNode) {
if (XML_ELEMENT_NODE === $node->nodeType) {
$nodes[] = $node;
}
}
return $this->createSubCrawler($nodes);
} | php | public function parents()
{
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
$nodes = array();
while ($node = $node->parentNode) {
if (XML_ELEMENT_NODE === $node->nodeType) {
$nodes[] = $node;
}
}
return $this->createSubCrawler($nodes);
} | [
"public",
"function",
"parents",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"nodes",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The current node list is empty.'",
")",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"0",
")",
";",
"$",
"nodes",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"node",
"=",
"$",
"node",
"->",
"parentNode",
")",
"{",
"if",
"(",
"XML_ELEMENT_NODE",
"===",
"$",
"node",
"->",
"nodeType",
")",
"{",
"$",
"nodes",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"createSubCrawler",
"(",
"$",
"nodes",
")",
";",
"}"
] | Returns the parents nodes of the current selection.
@return self
@throws \InvalidArgumentException When current node is empty | [
"Returns",
"the",
"parents",
"nodes",
"of",
"the",
"current",
"selection",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L483-L499 |
1,572 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.evaluate | public function evaluate($xpath)
{
if (null === $this->document) {
throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
}
$data = array();
$domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));
foreach ($this->nodes as $node) {
$data[] = $domxpath->evaluate($xpath, $node);
}
if (isset($data[0]) && $data[0] instanceof \DOMNodeList) {
return $this->createSubCrawler($data);
}
return $data;
} | php | public function evaluate($xpath)
{
if (null === $this->document) {
throw new \LogicException('Cannot evaluate the expression on an uninitialized crawler.');
}
$data = array();
$domxpath = $this->createDOMXPath($this->document, $this->findNamespacePrefixes($xpath));
foreach ($this->nodes as $node) {
$data[] = $domxpath->evaluate($xpath, $node);
}
if (isset($data[0]) && $data[0] instanceof \DOMNodeList) {
return $this->createSubCrawler($data);
}
return $data;
} | [
"public",
"function",
"evaluate",
"(",
"$",
"xpath",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"document",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Cannot evaluate the expression on an uninitialized crawler.'",
")",
";",
"}",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"domxpath",
"=",
"$",
"this",
"->",
"createDOMXPath",
"(",
"$",
"this",
"->",
"document",
",",
"$",
"this",
"->",
"findNamespacePrefixes",
"(",
"$",
"xpath",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"domxpath",
"->",
"evaluate",
"(",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"&&",
"$",
"data",
"[",
"0",
"]",
"instanceof",
"\\",
"DOMNodeList",
")",
"{",
"return",
"$",
"this",
"->",
"createSubCrawler",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Evaluates an XPath expression.
Since an XPath expression might evaluate to either a simple type or a \DOMNodeList,
this method will return either an array of simple types or a new Crawler instance.
@param string $xpath An XPath expression
@return array|Crawler An array of evaluation results or a new Crawler instance | [
"Evaluates",
"an",
"XPath",
"expression",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L602-L620 |
1,573 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.selectLink | public function selectLink($value)
{
$xpath = sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) ', static::xpathLiteral(' '.$value.' ')).
sprintf('or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]]', static::xpathLiteral(' '.$value.' '));
return $this->filterRelativeXPath($xpath);
} | php | public function selectLink($value)
{
$xpath = sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) ', static::xpathLiteral(' '.$value.' ')).
sprintf('or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]]', static::xpathLiteral(' '.$value.' '));
return $this->filterRelativeXPath($xpath);
} | [
"public",
"function",
"selectLink",
"(",
"$",
"value",
")",
"{",
"$",
"xpath",
"=",
"sprintf",
"(",
"'descendant-or-self::a[contains(concat(\\' \\', normalize-space(string(.)), \\' \\'), %s) '",
",",
"static",
"::",
"xpathLiteral",
"(",
"' '",
".",
"$",
"value",
".",
"' '",
")",
")",
".",
"sprintf",
"(",
"'or ./img[contains(concat(\\' \\', normalize-space(string(@alt)), \\' \\'), %s)]]'",
",",
"static",
"::",
"xpathLiteral",
"(",
"' '",
".",
"$",
"value",
".",
"' '",
")",
")",
";",
"return",
"$",
"this",
"->",
"filterRelativeXPath",
"(",
"$",
"xpath",
")",
";",
"}"
] | Selects links by name or alt value for clickable images.
@param string $value The link text
@return self | [
"Selects",
"links",
"by",
"name",
"or",
"alt",
"value",
"for",
"clickable",
"images",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L711-L717 |
1,574 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.selectButton | public function selectButton($value)
{
$translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")';
$xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, static::xpathLiteral(' '.$value.' ')).
sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)).
sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value));
return $this->filterRelativeXPath($xpath);
} | php | public function selectButton($value)
{
$translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")';
$xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, static::xpathLiteral(' '.$value.' ')).
sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value)).
sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' '.$value.' '), static::xpathLiteral($value), static::xpathLiteral($value));
return $this->filterRelativeXPath($xpath);
} | [
"public",
"function",
"selectButton",
"(",
"$",
"value",
")",
"{",
"$",
"translate",
"=",
"'translate(@type, \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", \"abcdefghijklmnopqrstuvwxyz\")'",
";",
"$",
"xpath",
"=",
"sprintf",
"(",
"'descendant-or-self::input[((contains(%s, \"submit\") or contains(%1$s, \"button\")) and contains(concat(\\' \\', normalize-space(string(@value)), \\' \\'), %s)) '",
",",
"$",
"translate",
",",
"static",
"::",
"xpathLiteral",
"(",
"' '",
".",
"$",
"value",
".",
"' '",
")",
")",
".",
"sprintf",
"(",
"'or (contains(%s, \"image\") and contains(concat(\\' \\', normalize-space(string(@alt)), \\' \\'), %s)) or @id=%s or @name=%s] '",
",",
"$",
"translate",
",",
"static",
"::",
"xpathLiteral",
"(",
"' '",
".",
"$",
"value",
".",
"' '",
")",
",",
"static",
"::",
"xpathLiteral",
"(",
"$",
"value",
")",
",",
"static",
"::",
"xpathLiteral",
"(",
"$",
"value",
")",
")",
".",
"sprintf",
"(",
"'| descendant-or-self::button[contains(concat(\\' \\', normalize-space(string(.)), \\' \\'), %s) or @id=%s or @name=%s]'",
",",
"static",
"::",
"xpathLiteral",
"(",
"' '",
".",
"$",
"value",
".",
"' '",
")",
",",
"static",
"::",
"xpathLiteral",
"(",
"$",
"value",
")",
",",
"static",
"::",
"xpathLiteral",
"(",
"$",
"value",
")",
")",
";",
"return",
"$",
"this",
"->",
"filterRelativeXPath",
"(",
"$",
"xpath",
")",
";",
"}"
] | Selects a button by name or alt value for images.
@param string $value The button text
@return self | [
"Selects",
"a",
"button",
"by",
"name",
"or",
"alt",
"value",
"for",
"images",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L740-L748 |
1,575 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.link | public function link($method = 'get')
{
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
if (!$node instanceof \DOMElement) {
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
}
return new Link($node, $this->baseHref, $method);
} | php | public function link($method = 'get')
{
if (!$this->nodes) {
throw new \InvalidArgumentException('The current node list is empty.');
}
$node = $this->getNode(0);
if (!$node instanceof \DOMElement) {
throw new \InvalidArgumentException(sprintf('The selected node should be instance of DOMElement, got "%s".', get_class($node)));
}
return new Link($node, $this->baseHref, $method);
} | [
"public",
"function",
"link",
"(",
"$",
"method",
"=",
"'get'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"nodes",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The current node list is empty.'",
")",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"0",
")",
";",
"if",
"(",
"!",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The selected node should be instance of DOMElement, got \"%s\".'",
",",
"get_class",
"(",
"$",
"node",
")",
")",
")",
";",
"}",
"return",
"new",
"Link",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"baseHref",
",",
"$",
"method",
")",
";",
"}"
] | Returns a Link object for the first node in the list.
@param string $method The method for the link (get by default)
@return Link A Link instance
@throws \InvalidArgumentException If the current node list is empty or the selected node is not instance of DOMElement | [
"Returns",
"a",
"Link",
"object",
"for",
"the",
"first",
"node",
"in",
"the",
"list",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L759-L772 |
1,576 | TonyBogdanov/dom-crawler | Crawler.php | Crawler.links | public function links()
{
$links = array();
foreach ($this->nodes as $node) {
if (!$node instanceof \DOMElement) {
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_class($node)));
}
$links[] = new Link($node, $this->baseHref, 'get');
}
return $links;
} | php | public function links()
{
$links = array();
foreach ($this->nodes as $node) {
if (!$node instanceof \DOMElement) {
throw new \InvalidArgumentException(sprintf('The current node list should contain only DOMElement instances, "%s" found.', get_class($node)));
}
$links[] = new Link($node, $this->baseHref, 'get');
}
return $links;
} | [
"public",
"function",
"links",
"(",
")",
"{",
"$",
"links",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The current node list should contain only DOMElement instances, \"%s\" found.'",
",",
"get_class",
"(",
"$",
"node",
")",
")",
")",
";",
"}",
"$",
"links",
"[",
"]",
"=",
"new",
"Link",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"baseHref",
",",
"'get'",
")",
";",
"}",
"return",
"$",
"links",
";",
"}"
] | Returns an array of Link objects for the nodes in the list.
@return Link[] An array of Link instances
@throws \InvalidArgumentException If the current node list contains non-DOMElement instances | [
"Returns",
"an",
"array",
"of",
"Link",
"objects",
"for",
"the",
"nodes",
"in",
"the",
"list",
"."
] | 14a9434c46befd0cab99b62e418c2163ad0516b2 | https://github.com/TonyBogdanov/dom-crawler/blob/14a9434c46befd0cab99b62e418c2163ad0516b2/Crawler.php#L781-L793 |
1,577 | black-forest/piwik-bundle | src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisitAction.php | PiwikVisitAction.setVisit | public function setVisit(\BlackForest\PiwikBundle\Entity\PiwikVisit $visit = null)
{
$this->visit = $visit;
return $this;
} | php | public function setVisit(\BlackForest\PiwikBundle\Entity\PiwikVisit $visit = null)
{
$this->visit = $visit;
return $this;
} | [
"public",
"function",
"setVisit",
"(",
"\\",
"BlackForest",
"\\",
"PiwikBundle",
"\\",
"Entity",
"\\",
"PiwikVisit",
"$",
"visit",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"visit",
"=",
"$",
"visit",
";",
"return",
"$",
"this",
";",
"}"
] | Set visit.
@param \BlackForest\PiwikBundle\Entity\PiwikVisit|null $visit
@return PiwikVisitAction | [
"Set",
"visit",
"."
] | be1000f898f9583bb4ecbe4ca1933ab7b7e0e785 | https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisitAction.php#L354-L359 |
1,578 | black-forest/piwik-bundle | src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisitAction.php | PiwikVisitAction.setAction | public function setAction(\BlackForest\PiwikBundle\Entity\PiwikAction $action = null)
{
$this->action = $action;
return $this;
} | php | public function setAction(\BlackForest\PiwikBundle\Entity\PiwikAction $action = null)
{
$this->action = $action;
return $this;
} | [
"public",
"function",
"setAction",
"(",
"\\",
"BlackForest",
"\\",
"PiwikBundle",
"\\",
"Entity",
"\\",
"PiwikAction",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"$",
"action",
";",
"return",
"$",
"this",
";",
"}"
] | Set action.
@param \BlackForest\PiwikBundle\Entity\PiwikAction|null $action
@return PiwikVisitAction | [
"Set",
"action",
"."
] | be1000f898f9583bb4ecbe4ca1933ab7b7e0e785 | https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisitAction.php#L402-L407 |
1,579 | thytanium/tester | src/DatabaseMigrations.php | DatabaseMigrations.migrate | public function migrate()
{
$fs = new Filesystem;
$finder = new ClassFinder;
$path = env('MIGRATIONS_PATH', 'database/migrations');
if ($fs->exists($path)) {
foreach ($fs->files($path) as $file) {
$fs->requireOnce($file);
$class = $finder->findClass($file);
(new $class)->up();
}
}
} | php | public function migrate()
{
$fs = new Filesystem;
$finder = new ClassFinder;
$path = env('MIGRATIONS_PATH', 'database/migrations');
if ($fs->exists($path)) {
foreach ($fs->files($path) as $file) {
$fs->requireOnce($file);
$class = $finder->findClass($file);
(new $class)->up();
}
}
} | [
"public",
"function",
"migrate",
"(",
")",
"{",
"$",
"fs",
"=",
"new",
"Filesystem",
";",
"$",
"finder",
"=",
"new",
"ClassFinder",
";",
"$",
"path",
"=",
"env",
"(",
"'MIGRATIONS_PATH'",
",",
"'database/migrations'",
")",
";",
"if",
"(",
"$",
"fs",
"->",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"foreach",
"(",
"$",
"fs",
"->",
"files",
"(",
"$",
"path",
")",
"as",
"$",
"file",
")",
"{",
"$",
"fs",
"->",
"requireOnce",
"(",
"$",
"file",
")",
";",
"$",
"class",
"=",
"$",
"finder",
"->",
"findClass",
"(",
"$",
"file",
")",
";",
"(",
"new",
"$",
"class",
")",
"->",
"up",
"(",
")",
";",
"}",
"}",
"}"
] | Run package database migrations.
@return void | [
"Run",
"package",
"database",
"migrations",
"."
] | 3af29cf807db5900ec7a561abeffba8453d6957b | https://github.com/thytanium/tester/blob/3af29cf807db5900ec7a561abeffba8453d6957b/src/DatabaseMigrations.php#L14-L28 |
1,580 | payapi/payapi-magento-plugin-gateway | Model/PayapiPaymentMethod.php | PayapiPaymentMethod.isAvailable | public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
$this->_logger->debug("isAvaliable Payapi");
if (!$this->getConfigData('payapi_api_key') || !$this->getConfigData('payapi_public_id')) {
return false;
}
return parent::isAvailable($quote);
} | php | public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
$this->_logger->debug("isAvaliable Payapi");
if (!$this->getConfigData('payapi_api_key') || !$this->getConfigData('payapi_public_id')) {
return false;
}
return parent::isAvailable($quote);
} | [
"public",
"function",
"isAvailable",
"(",
"\\",
"Magento",
"\\",
"Quote",
"\\",
"Api",
"\\",
"Data",
"\\",
"CartInterface",
"$",
"quote",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_logger",
"->",
"debug",
"(",
"\"isAvaliable Payapi\"",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"getConfigData",
"(",
"'payapi_api_key'",
")",
"||",
"!",
"$",
"this",
"->",
"getConfigData",
"(",
"'payapi_public_id'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"parent",
"::",
"isAvailable",
"(",
"$",
"quote",
")",
";",
"}"
] | Determine method availability based on quote amount and config data
@param \Magento\Quote\Api\Data\CartInterface|null $quote
@return bool | [
"Determine",
"method",
"availability",
"based",
"on",
"quote",
"amount",
"and",
"config",
"data"
] | a0c53a9d137b32ab7cd1b7704e8e9629d4bf75e0 | https://github.com/payapi/payapi-magento-plugin-gateway/blob/a0c53a9d137b32ab7cd1b7704e8e9629d4bf75e0/Model/PayapiPaymentMethod.php#L47-L56 |
1,581 | konservs/brilliant.framework | libraries/HTTP/BRequest.php | BRequest.rmVar | public static function rmVar($name){
self::init();
if(isset(self::$variables[$name])){
unset(self::$variables[$name]);
}
return true;
} | php | public static function rmVar($name){
self::init();
if(isset(self::$variables[$name])){
unset(self::$variables[$name]);
}
return true;
} | [
"public",
"static",
"function",
"rmVar",
"(",
"$",
"name",
")",
"{",
"self",
"::",
"init",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"variables",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"self",
"::",
"$",
"variables",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Remove variable; | [
"Remove",
"variable",
";"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/HTTP/BRequest.php#L62-L68 |
1,582 | konservs/brilliant.framework | libraries/HTTP/BRequest.php | BRequest.getStrings | public static function getStrings($names=array(),$vartype=''){
$result=array();
if(!is_array($names)){
return $result;
}
foreach($names as $name){
$result[$name]=self::getVar($name,'',$vartype);
}
return $result;
} | php | public static function getStrings($names=array(),$vartype=''){
$result=array();
if(!is_array($names)){
return $result;
}
foreach($names as $name){
$result[$name]=self::getVar($name,'',$vartype);
}
return $result;
} | [
"public",
"static",
"function",
"getStrings",
"(",
"$",
"names",
"=",
"array",
"(",
")",
",",
"$",
"vartype",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"names",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"foreach",
"(",
"$",
"names",
"as",
"$",
"name",
")",
"{",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"self",
"::",
"getVar",
"(",
"$",
"name",
",",
"''",
",",
"$",
"vartype",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get strings array by keys... | [
"Get",
"strings",
"array",
"by",
"keys",
"..."
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/HTTP/BRequest.php#L174-L183 |
1,583 | reflex-php/lockdown | src/Reflex/Lockdown/Roles/RoleTraits.php | RoleTraits.has | public function has($permissions, $all = true)
{
if (! is_array($permissions)) {
$permissions = (array) $permissions;
}
$permissions= array_unique($permissions);
$filtered = array_where($permissions, [$this, 'hasFilter']);
if (true === $all) {
return count($permissions) === count($filtered);
}
return 0 < count($filtered);
} | php | public function has($permissions, $all = true)
{
if (! is_array($permissions)) {
$permissions = (array) $permissions;
}
$permissions= array_unique($permissions);
$filtered = array_where($permissions, [$this, 'hasFilter']);
if (true === $all) {
return count($permissions) === count($filtered);
}
return 0 < count($filtered);
} | [
"public",
"function",
"has",
"(",
"$",
"permissions",
",",
"$",
"all",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"permissions",
")",
")",
"{",
"$",
"permissions",
"=",
"(",
"array",
")",
"$",
"permissions",
";",
"}",
"$",
"permissions",
"=",
"array_unique",
"(",
"$",
"permissions",
")",
";",
"$",
"filtered",
"=",
"array_where",
"(",
"$",
"permissions",
",",
"[",
"$",
"this",
",",
"'hasFilter'",
"]",
")",
";",
"if",
"(",
"true",
"===",
"$",
"all",
")",
"{",
"return",
"count",
"(",
"$",
"permissions",
")",
"===",
"count",
"(",
"$",
"filtered",
")",
";",
"}",
"return",
"0",
"<",
"count",
"(",
"$",
"filtered",
")",
";",
"}"
] | Does this role have supplied permission
@param mixed $permissions Permission lookup
@param boolean $all Check for all permissions
@return boolean | [
"Does",
"this",
"role",
"have",
"supplied",
"permission"
] | 2798e448608eef469f2924d75013deccfd6aca44 | https://github.com/reflex-php/lockdown/blob/2798e448608eef469f2924d75013deccfd6aca44/src/Reflex/Lockdown/Roles/RoleTraits.php#L96-L110 |
1,584 | easy-system/es-cache | src/CacheFactory.php | CacheFactory.setConfig | public static function setConfig(array $config)
{
if (! isset($config['adapters']) || ! is_array($config['adapters'])) {
throw new DomainException(
'Missing adapters configuration.'
);
}
$defaultAdapter = static::DEFAULT_ADAPTER;
if (isset($config['defaults']['adapter'])) {
$defaultAdapter = $config['defaults']['adapter'];
}
if (! isset($config['adapters'][$defaultAdapter])) {
throw new DomainException(sprintf(
'Missing configuration of default adapter "%s".',
$defaultAdapter
));
}
foreach ($config['adapters'] as $adapter => $items) {
if (! isset($items['class'])) {
throw new DomainException(sprintf(
'The class of adapter "%s" is not specified.',
$adapter
));
}
}
static::$config = $config;
} | php | public static function setConfig(array $config)
{
if (! isset($config['adapters']) || ! is_array($config['adapters'])) {
throw new DomainException(
'Missing adapters configuration.'
);
}
$defaultAdapter = static::DEFAULT_ADAPTER;
if (isset($config['defaults']['adapter'])) {
$defaultAdapter = $config['defaults']['adapter'];
}
if (! isset($config['adapters'][$defaultAdapter])) {
throw new DomainException(sprintf(
'Missing configuration of default adapter "%s".',
$defaultAdapter
));
}
foreach ($config['adapters'] as $adapter => $items) {
if (! isset($items['class'])) {
throw new DomainException(sprintf(
'The class of adapter "%s" is not specified.',
$adapter
));
}
}
static::$config = $config;
} | [
"public",
"static",
"function",
"setConfig",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'adapters'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"config",
"[",
"'adapters'",
"]",
")",
")",
"{",
"throw",
"new",
"DomainException",
"(",
"'Missing adapters configuration.'",
")",
";",
"}",
"$",
"defaultAdapter",
"=",
"static",
"::",
"DEFAULT_ADAPTER",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'adapter'",
"]",
")",
")",
"{",
"$",
"defaultAdapter",
"=",
"$",
"config",
"[",
"'defaults'",
"]",
"[",
"'adapter'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'adapters'",
"]",
"[",
"$",
"defaultAdapter",
"]",
")",
")",
"{",
"throw",
"new",
"DomainException",
"(",
"sprintf",
"(",
"'Missing configuration of default adapter \"%s\".'",
",",
"$",
"defaultAdapter",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"config",
"[",
"'adapters'",
"]",
"as",
"$",
"adapter",
"=>",
"$",
"items",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"items",
"[",
"'class'",
"]",
")",
")",
"{",
"throw",
"new",
"DomainException",
"(",
"sprintf",
"(",
"'The class of adapter \"%s\" is not specified.'",
",",
"$",
"adapter",
")",
")",
";",
"}",
"}",
"static",
"::",
"$",
"config",
"=",
"$",
"config",
";",
"}"
] | Sets the configuration.
@param array $config The configuration
@throws \DomainException
- If the configuration of adapters not exists.
- If the configuration of adapters is not array.
- If the configuration of default adapter not exists.
- If the class of any adapter is not specified. | [
"Sets",
"the",
"configuration",
"."
] | 94ceacd8ac21b673ad2f2f222bc08696603ff2c6 | https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/CacheFactory.php#L66-L94 |
1,585 | easy-system/es-cache | src/CacheFactory.php | CacheFactory.make | public static function make($namespace = null, $adapter = null)
{
$defaults = isset(static::$config['defaults'])
? static::$config['defaults']
: [];
if (! $adapter) {
$adapter = isset($defaults['adapter'])
? $defaults['adapter']
: static::DEFAULT_ADAPTER;
}
if (! isset(static::$config['adapters'][$adapter])) {
throw new InvalidArgumentException(sprintf(
'Unknown type adapter of cache "%s".',
$adapter
));
}
$config = static::$config['adapters'][$adapter];
$class = $config['class'];
$options = array_merge(
isset($defaults['options']) ? (array) $defaults['options'] : [],
isset($config['options']) ? (array) $config['options'] : []
);
if (! $namespace) {
$namespace = 'default';
}
$options['namespace'] = $namespace;
$cache = new $class($options);
if (! $cache instanceof AbstractCache) {
throw new DomainException(sprintf(
'The class "%s" of adapter "%s" must inherit '
. 'an "Es\Cache\AbstractCache".',
$class,
$adapter
));
}
return $cache;
} | php | public static function make($namespace = null, $adapter = null)
{
$defaults = isset(static::$config['defaults'])
? static::$config['defaults']
: [];
if (! $adapter) {
$adapter = isset($defaults['adapter'])
? $defaults['adapter']
: static::DEFAULT_ADAPTER;
}
if (! isset(static::$config['adapters'][$adapter])) {
throw new InvalidArgumentException(sprintf(
'Unknown type adapter of cache "%s".',
$adapter
));
}
$config = static::$config['adapters'][$adapter];
$class = $config['class'];
$options = array_merge(
isset($defaults['options']) ? (array) $defaults['options'] : [],
isset($config['options']) ? (array) $config['options'] : []
);
if (! $namespace) {
$namespace = 'default';
}
$options['namespace'] = $namespace;
$cache = new $class($options);
if (! $cache instanceof AbstractCache) {
throw new DomainException(sprintf(
'The class "%s" of adapter "%s" must inherit '
. 'an "Es\Cache\AbstractCache".',
$class,
$adapter
));
}
return $cache;
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"namespace",
"=",
"null",
",",
"$",
"adapter",
"=",
"null",
")",
"{",
"$",
"defaults",
"=",
"isset",
"(",
"static",
"::",
"$",
"config",
"[",
"'defaults'",
"]",
")",
"?",
"static",
"::",
"$",
"config",
"[",
"'defaults'",
"]",
":",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"adapter",
")",
"{",
"$",
"adapter",
"=",
"isset",
"(",
"$",
"defaults",
"[",
"'adapter'",
"]",
")",
"?",
"$",
"defaults",
"[",
"'adapter'",
"]",
":",
"static",
"::",
"DEFAULT_ADAPTER",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"config",
"[",
"'adapters'",
"]",
"[",
"$",
"adapter",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unknown type adapter of cache \"%s\".'",
",",
"$",
"adapter",
")",
")",
";",
"}",
"$",
"config",
"=",
"static",
"::",
"$",
"config",
"[",
"'adapters'",
"]",
"[",
"$",
"adapter",
"]",
";",
"$",
"class",
"=",
"$",
"config",
"[",
"'class'",
"]",
";",
"$",
"options",
"=",
"array_merge",
"(",
"isset",
"(",
"$",
"defaults",
"[",
"'options'",
"]",
")",
"?",
"(",
"array",
")",
"$",
"defaults",
"[",
"'options'",
"]",
":",
"[",
"]",
",",
"isset",
"(",
"$",
"config",
"[",
"'options'",
"]",
")",
"?",
"(",
"array",
")",
"$",
"config",
"[",
"'options'",
"]",
":",
"[",
"]",
")",
";",
"if",
"(",
"!",
"$",
"namespace",
")",
"{",
"$",
"namespace",
"=",
"'default'",
";",
"}",
"$",
"options",
"[",
"'namespace'",
"]",
"=",
"$",
"namespace",
";",
"$",
"cache",
"=",
"new",
"$",
"class",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"cache",
"instanceof",
"AbstractCache",
")",
"{",
"throw",
"new",
"DomainException",
"(",
"sprintf",
"(",
"'The class \"%s\" of adapter \"%s\" must inherit '",
".",
"'an \"Es\\Cache\\AbstractCache\".'",
",",
"$",
"class",
",",
"$",
"adapter",
")",
")",
";",
"}",
"return",
"$",
"cache",
";",
"}"
] | Make the cache adapter.
@param string $namespace Optional; null by default. The namespace
@param string $adapter Optional; null by default. The type of adapter
@throws \InvalidArgumentException If the given adapter type not specified
in configuration
@throws \DomainException If the class of specified adapter not
inherit an Es\Cache\Adapter\AbstractCache
@return \Es\Cache\Adapter\AbstractCache The new instance of cache adapter | [
"Make",
"the",
"cache",
"adapter",
"."
] | 94ceacd8ac21b673ad2f2f222bc08696603ff2c6 | https://github.com/easy-system/es-cache/blob/94ceacd8ac21b673ad2f2f222bc08696603ff2c6/src/CacheFactory.php#L119-L160 |
1,586 | tonjoo/tiga-framework | src/Pagination.php | Pagination.init | public function init($config)
{
// init init error
//default
$this->config['per_page'] = 10;
$this->config['item_to_show'] = 2;
$this->config['skip_item'] = true;
$this->config['first_tag_open'] = "<li>";
$this->config['first_tag_close']= "</li>";
$this->config['last_tag_open'] = "<li>";
$this->config['last_tag_close'] = "</li>";
$this->config['prev_tag_open'] = "<li>";
$this->config['prev_tag_close'] = "</li>";
$this->config['prev_tag_text'] = "Prev";
$this->config['next_tag_open'] = "<li>";
$this->config['next_tag_close'] = "</li>";
$this->config['next_tag_text'] = "Next";
$this->config['cur_tag_open'] = "<li class='active'>";
$this->config['cur_tag_close'] = "</li>";
$this->config['link_attribute'] = "class=''";
$this->config['link_attribute_active'] = "class='active'";
$this->config['num_tag_open'] = "<li>";
$this->config['num_tag_close'] = "</li>";
$this->config['skip_tag_open'] = "<li>";
$this->config['skip_tag_close'] = "</li>";
$this->config['skip_tag_text'] = "<a href='#'>....</a>";
$this->config['start_page'] = 0;
//merge options
foreach ($config as $key => $value) {
$this->config[$key]=$value;
}
if($this->config['item_to_show']<2)
$this->config['item_to_show']=2;
$this->total = intval($config['rows']);
$this->per_page = intval($config['per_page']);
$this->current_page = intval($config['current_page']) ;
$this->base_url = urldecode($config['base_url']);
} | php | public function init($config)
{
// init init error
//default
$this->config['per_page'] = 10;
$this->config['item_to_show'] = 2;
$this->config['skip_item'] = true;
$this->config['first_tag_open'] = "<li>";
$this->config['first_tag_close']= "</li>";
$this->config['last_tag_open'] = "<li>";
$this->config['last_tag_close'] = "</li>";
$this->config['prev_tag_open'] = "<li>";
$this->config['prev_tag_close'] = "</li>";
$this->config['prev_tag_text'] = "Prev";
$this->config['next_tag_open'] = "<li>";
$this->config['next_tag_close'] = "</li>";
$this->config['next_tag_text'] = "Next";
$this->config['cur_tag_open'] = "<li class='active'>";
$this->config['cur_tag_close'] = "</li>";
$this->config['link_attribute'] = "class=''";
$this->config['link_attribute_active'] = "class='active'";
$this->config['num_tag_open'] = "<li>";
$this->config['num_tag_close'] = "</li>";
$this->config['skip_tag_open'] = "<li>";
$this->config['skip_tag_close'] = "</li>";
$this->config['skip_tag_text'] = "<a href='#'>....</a>";
$this->config['start_page'] = 0;
//merge options
foreach ($config as $key => $value) {
$this->config[$key]=$value;
}
if($this->config['item_to_show']<2)
$this->config['item_to_show']=2;
$this->total = intval($config['rows']);
$this->per_page = intval($config['per_page']);
$this->current_page = intval($config['current_page']) ;
$this->base_url = urldecode($config['base_url']);
} | [
"public",
"function",
"init",
"(",
"$",
"config",
")",
"{",
"// init init error",
"//default",
"$",
"this",
"->",
"config",
"[",
"'per_page'",
"]",
"=",
"10",
";",
"$",
"this",
"->",
"config",
"[",
"'item_to_show'",
"]",
"=",
"2",
";",
"$",
"this",
"->",
"config",
"[",
"'skip_item'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"config",
"[",
"'first_tag_open'",
"]",
"=",
"\"<li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'first_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'last_tag_open'",
"]",
"=",
"\"<li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'last_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'prev_tag_open'",
"]",
"=",
"\"<li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'prev_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'prev_tag_text'",
"]",
"=",
"\"Prev\"",
";",
"$",
"this",
"->",
"config",
"[",
"'next_tag_open'",
"]",
"=",
"\"<li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'next_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'next_tag_text'",
"]",
"=",
"\"Next\"",
";",
"$",
"this",
"->",
"config",
"[",
"'cur_tag_open'",
"]",
"=",
"\"<li class='active'>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'cur_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'link_attribute'",
"]",
"=",
"\"class=''\"",
";",
"$",
"this",
"->",
"config",
"[",
"'link_attribute_active'",
"]",
"=",
"\"class='active'\"",
";",
"$",
"this",
"->",
"config",
"[",
"'num_tag_open'",
"]",
"=",
"\"<li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'num_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'skip_tag_open'",
"]",
"=",
"\"<li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'skip_tag_close'",
"]",
"=",
"\"</li>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'skip_tag_text'",
"]",
"=",
"\"<a href='#'>....</a>\"",
";",
"$",
"this",
"->",
"config",
"[",
"'start_page'",
"]",
"=",
"0",
";",
"//merge options",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'item_to_show'",
"]",
"<",
"2",
")",
"$",
"this",
"->",
"config",
"[",
"'item_to_show'",
"]",
"=",
"2",
";",
"$",
"this",
"->",
"total",
"=",
"intval",
"(",
"$",
"config",
"[",
"'rows'",
"]",
")",
";",
"$",
"this",
"->",
"per_page",
"=",
"intval",
"(",
"$",
"config",
"[",
"'per_page'",
"]",
")",
";",
"$",
"this",
"->",
"current_page",
"=",
"intval",
"(",
"$",
"config",
"[",
"'current_page'",
"]",
")",
";",
"$",
"this",
"->",
"base_url",
"=",
"urldecode",
"(",
"$",
"config",
"[",
"'base_url'",
"]",
")",
";",
"}"
] | Initialize pagination config
@param array $config | [
"Initialize",
"pagination",
"config"
] | 3c2eebd3bc616106fa1bba3e43f1791aff75eec5 | https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Pagination.php#L16-L63 |
1,587 | timostamm/injector | src/Injector.php | Injector.alias | public function alias(string $from, string $to, array $params = null): void
{
if (!empty($params)) {
$this->config->registerClassParameters($to, $params);
}
$this->config->registerClassAlias($from, $to);
} | php | public function alias(string $from, string $to, array $params = null): void
{
if (!empty($params)) {
$this->config->registerClassParameters($to, $params);
}
$this->config->registerClassAlias($from, $to);
} | [
"public",
"function",
"alias",
"(",
"string",
"$",
"from",
",",
"string",
"$",
"to",
",",
"array",
"$",
"params",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"registerClassParameters",
"(",
"$",
"to",
",",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"config",
"->",
"registerClassAlias",
"(",
"$",
"from",
",",
"$",
"to",
")",
";",
"}"
] | Create a global alias for an interface.
Every time the injector sees this type, it will use the
given implementation instead of trying to use the
interface.
@param string $from class name to replace.
@param string $to new class name that should be used instead. | [
"Create",
"a",
"global",
"alias",
"for",
"an",
"interface",
"."
] | 5f5c0a0993bde368ad6703936ac578d6ab022fa7 | https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector.php#L51-L57 |
1,588 | timostamm/injector | src/Injector.php | Injector.singleton | public function singleton(string $className, array $params = null): void
{
if (! is_null($params)) {
$this->config->registerClassParameters($className, $params);
}
$this->config->registerSingleton($className);
} | php | public function singleton(string $className, array $params = null): void
{
if (! is_null($params)) {
$this->config->registerClassParameters($className, $params);
}
$this->config->registerSingleton($className);
} | [
"public",
"function",
"singleton",
"(",
"string",
"$",
"className",
",",
"array",
"$",
"params",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"params",
")",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"registerClassParameters",
"(",
"$",
"className",
",",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"config",
"->",
"registerSingleton",
"(",
"$",
"className",
")",
";",
"}"
] | Treat the class as a singleton.
The injector will only create one instance of this class and
return this instance on subsequent calls.
Custom parameters provided to instantiate() will be ignored.
You can update the parameter config for the singleton by calling
singleton() again, unless the class is instantiated.
If you already have an instance that you want to provide, use
intercept(). | [
"Treat",
"the",
"class",
"as",
"a",
"singleton",
"."
] | 5f5c0a0993bde368ad6703936ac578d6ab022fa7 | https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector.php#L75-L81 |
1,589 | timostamm/injector | src/Injector.php | Injector.decorate | public function decorate(string $className, callable $decorate): void
{
$this->config->registerClassDecorator($className, $decorate);
} | php | public function decorate(string $className, callable $decorate): void
{
$this->config->registerClassDecorator($className, $decorate);
} | [
"public",
"function",
"decorate",
"(",
"string",
"$",
"className",
",",
"callable",
"$",
"decorate",
")",
":",
"void",
"{",
"$",
"this",
"->",
"config",
"->",
"registerClassDecorator",
"(",
"$",
"className",
",",
"$",
"decorate",
")",
";",
"}"
] | Decorate a class.
$inj->decorate(Foo::class, function(Foo $foo, LoggerInterface $logger):void {
$foo->setLogger( $logger ) );
}) | [
"Decorate",
"a",
"class",
"."
] | 5f5c0a0993bde368ad6703936ac578d6ab022fa7 | https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector.php#L105-L108 |
1,590 | timostamm/injector | src/Injector.php | Injector.factory | public function factory(string $className, callable $factory):void
{
$this->config->registerClassFactory($className, $factory);
} | php | public function factory(string $className, callable $factory):void
{
$this->config->registerClassFactory($className, $factory);
} | [
"public",
"function",
"factory",
"(",
"string",
"$",
"className",
",",
"callable",
"$",
"factory",
")",
":",
"void",
"{",
"$",
"this",
"->",
"config",
"->",
"registerClassFactory",
"(",
"$",
"className",
",",
"$",
"factory",
")",
";",
"}"
] | Intercept a class instantiation.
$inj->factory(Foo::class, function(FooFactory $factory):Foo {
return $factory->create();
})
@param string $className
@param callable $factory | [
"Intercept",
"a",
"class",
"instantiation",
"."
] | 5f5c0a0993bde368ad6703936ac578d6ab022fa7 | https://github.com/timostamm/injector/blob/5f5c0a0993bde368ad6703936ac578d6ab022fa7/src/Injector.php#L121-L124 |
1,591 | journeygroup/cache | src/Adapters/LocalAdapter.php | LocalAdapter.clear | public function clear()
{
$key = $this->key();
$files = glob($this->path . "/_cache-" . $key . "*.cache");
$this->setKey();
$this->key(true);
foreach ($files as $file) {
unlink($file);
}
return $this;
} | php | public function clear()
{
$key = $this->key();
$files = glob($this->path . "/_cache-" . $key . "*.cache");
$this->setKey();
$this->key(true);
foreach ($files as $file) {
unlink($file);
}
return $this;
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"key",
"(",
")",
";",
"$",
"files",
"=",
"glob",
"(",
"$",
"this",
"->",
"path",
".",
"\"/_cache-\"",
".",
"$",
"key",
".",
"\"*.cache\"",
")",
";",
"$",
"this",
"->",
"setKey",
"(",
")",
";",
"$",
"this",
"->",
"key",
"(",
"true",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"unlink",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Clear all of the values set by this cache instance.
@return $this | [
"Clear",
"all",
"of",
"the",
"values",
"set",
"by",
"this",
"cache",
"instance",
"."
] | 9f009e4e444990aec8e615dff3445a36c66e34cd | https://github.com/journeygroup/cache/blob/9f009e4e444990aec8e615dff3445a36c66e34cd/src/Adapters/LocalAdapter.php#L92-L102 |
1,592 | journeygroup/cache | src/Adapters/LocalAdapter.php | LocalAdapter.createValue | public function createValue($value, $expiration)
{
$expiration = $expiration ? str_pad($expiration, 11, "0". STR_PAD_LEFT) : "00000000000";
return $expiration . $value;
} | php | public function createValue($value, $expiration)
{
$expiration = $expiration ? str_pad($expiration, 11, "0". STR_PAD_LEFT) : "00000000000";
return $expiration . $value;
} | [
"public",
"function",
"createValue",
"(",
"$",
"value",
",",
"$",
"expiration",
")",
"{",
"$",
"expiration",
"=",
"$",
"expiration",
"?",
"str_pad",
"(",
"$",
"expiration",
",",
"11",
",",
"\"0\"",
".",
"STR_PAD_LEFT",
")",
":",
"\"00000000000\"",
";",
"return",
"$",
"expiration",
".",
"$",
"value",
";",
"}"
] | Create a parsable value from the data and expiration date.
@param string $value value of the store
@param integer $expiration integer value of the expiration (unix timestamp)
@return void | [
"Create",
"a",
"parsable",
"value",
"from",
"the",
"data",
"and",
"expiration",
"date",
"."
] | 9f009e4e444990aec8e615dff3445a36c66e34cd | https://github.com/journeygroup/cache/blob/9f009e4e444990aec8e615dff3445a36c66e34cd/src/Adapters/LocalAdapter.php#L122-L126 |
1,593 | journeygroup/cache | src/Adapters/LocalAdapter.php | LocalAdapter.key | public function key($reset = false)
{
static $key;
$key = $reset ? false : $key;
if (!$key) {
$path = $this->path . "/.cache_key";
if (file_exists($path)) {
$key = file_get_contents($path);
} else {
$key = $this->setKey();
}
}
return $key;
} | php | public function key($reset = false)
{
static $key;
$key = $reset ? false : $key;
if (!$key) {
$path = $this->path . "/.cache_key";
if (file_exists($path)) {
$key = file_get_contents($path);
} else {
$key = $this->setKey();
}
}
return $key;
} | [
"public",
"function",
"key",
"(",
"$",
"reset",
"=",
"false",
")",
"{",
"static",
"$",
"key",
";",
"$",
"key",
"=",
"$",
"reset",
"?",
"false",
":",
"$",
"key",
";",
"if",
"(",
"!",
"$",
"key",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
".",
"\"/.cache_key\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"key",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"setKey",
"(",
")",
";",
"}",
"}",
"return",
"$",
"key",
";",
"}"
] | Gets the current cache namespace key.
Note: to save on time spent reading/writing to disk, this method uses
static caching. Its important that when a cache key gets reset this
method has it's local cache reset by passing `true`.
@param boolean $reset resets the static cache.
@return void | [
"Gets",
"the",
"current",
"cache",
"namespace",
"key",
"."
] | 9f009e4e444990aec8e615dff3445a36c66e34cd | https://github.com/journeygroup/cache/blob/9f009e4e444990aec8e615dff3445a36c66e34cd/src/Adapters/LocalAdapter.php#L138-L151 |
1,594 | journeygroup/cache | src/Adapters/LocalAdapter.php | LocalAdapter.setKey | public function setKey()
{
$path = $this->path . "/.cache_key";
$key = bin2hex(openssl_random_pseudo_bytes(6));
$umask = umask($this->umask);
file_put_contents($path, $key);
umask($umask);
return $key;
} | php | public function setKey()
{
$path = $this->path . "/.cache_key";
$key = bin2hex(openssl_random_pseudo_bytes(6));
$umask = umask($this->umask);
file_put_contents($path, $key);
umask($umask);
return $key;
} | [
"public",
"function",
"setKey",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
".",
"\"/.cache_key\"",
";",
"$",
"key",
"=",
"bin2hex",
"(",
"openssl_random_pseudo_bytes",
"(",
"6",
")",
")",
";",
"$",
"umask",
"=",
"umask",
"(",
"$",
"this",
"->",
"umask",
")",
";",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"key",
")",
";",
"umask",
"(",
"$",
"umask",
")",
";",
"return",
"$",
"key",
";",
"}"
] | Set the current cache key. | [
"Set",
"the",
"current",
"cache",
"key",
"."
] | 9f009e4e444990aec8e615dff3445a36c66e34cd | https://github.com/journeygroup/cache/blob/9f009e4e444990aec8e615dff3445a36c66e34cd/src/Adapters/LocalAdapter.php#L156-L164 |
1,595 | lucidphp/mux-cache | src/Matcher/MapLoader.php | MapLoader.load | public function load(CachedCollectionInterface $routes)
{
if (!is_file($file = $this->getFilePath($routes)) || filemtime($file) < $routes->getTimestamp()) {
$this->dumpMap($routes, $file);
}
return $this->loadMap($file);
} | php | public function load(CachedCollectionInterface $routes)
{
if (!is_file($file = $this->getFilePath($routes)) || filemtime($file) < $routes->getTimestamp()) {
$this->dumpMap($routes, $file);
}
return $this->loadMap($file);
} | [
"public",
"function",
"load",
"(",
"CachedCollectionInterface",
"$",
"routes",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
"=",
"$",
"this",
"->",
"getFilePath",
"(",
"$",
"routes",
")",
")",
"||",
"filemtime",
"(",
"$",
"file",
")",
"<",
"$",
"routes",
"->",
"getTimestamp",
"(",
")",
")",
"{",
"$",
"this",
"->",
"dumpMap",
"(",
"$",
"routes",
",",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
"->",
"loadMap",
"(",
"$",
"file",
")",
";",
"}"
] | Get the statuc route map.
@param CachedCollectionInterface $routes.
@return array | [
"Get",
"the",
"statuc",
"route",
"map",
"."
] | 5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43 | https://github.com/lucidphp/mux-cache/blob/5d48ad1b1ffaf4f40ca2ef12143006efd15f9a43/src/Matcher/MapLoader.php#L58-L65 |
1,596 | easy-system/es-controller-plugins | src/Plugin/Layout.php | Layout.setTemplate | public function setTemplate($template)
{
$layout = $this->getViewModel();
$layout->setTemplate((string) $template);
return $this;
} | php | public function setTemplate($template)
{
$layout = $this->getViewModel();
$layout->setTemplate((string) $template);
return $this;
} | [
"public",
"function",
"setTemplate",
"(",
"$",
"template",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"getViewModel",
"(",
")",
";",
"$",
"layout",
"->",
"setTemplate",
"(",
"(",
"string",
")",
"$",
"template",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the layout template.
@param string $template The template name
@return self | [
"Sets",
"the",
"layout",
"template",
"."
] | b1f58b0e62bb24d936aac15d34002826af7ee9b6 | https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/Plugin/Layout.php#L30-L36 |
1,597 | easy-system/es-controller-plugins | src/Plugin/Layout.php | Layout.setModule | public function setModule($module)
{
$layout = $this->getViewModel();
$layout->setModule((string) $module);
return $this;
} | php | public function setModule($module)
{
$layout = $this->getViewModel();
$layout->setModule((string) $module);
return $this;
} | [
"public",
"function",
"setModule",
"(",
"$",
"module",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"getViewModel",
"(",
")",
";",
"$",
"layout",
"->",
"setModule",
"(",
"(",
"string",
")",
"$",
"module",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the layout module name.
@param null|string $module The module name, if any
@return self | [
"Sets",
"the",
"layout",
"module",
"name",
"."
] | b1f58b0e62bb24d936aac15d34002826af7ee9b6 | https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/Plugin/Layout.php#L57-L63 |
1,598 | owenwilljones/Tadpole-Components | controller.php | controller.getView | public function getView($view) {
$path = explode("/", $view);
include (count($path) > 1) ? "src/views/" . $path[0] . "/" . $path[1] . ".php" : "src/views/" .$path[0] . "/index.php";
} | php | public function getView($view) {
$path = explode("/", $view);
include (count($path) > 1) ? "src/views/" . $path[0] . "/" . $path[1] . ".php" : "src/views/" .$path[0] . "/index.php";
} | [
"public",
"function",
"getView",
"(",
"$",
"view",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"view",
")",
";",
"include",
"(",
"count",
"(",
"$",
"path",
")",
">",
"1",
")",
"?",
"\"src/views/\"",
".",
"$",
"path",
"[",
"0",
"]",
".",
"\"/\"",
".",
"$",
"path",
"[",
"1",
"]",
".",
"\".php\"",
":",
"\"src/views/\"",
".",
"$",
"path",
"[",
"0",
"]",
".",
"\"/index.php\"",
";",
"}"
] | view being called is in the views directory, additional directories are taken into account. | [
"view",
"being",
"called",
"is",
"in",
"the",
"views",
"directory",
"additional",
"directories",
"are",
"taken",
"into",
"account",
"."
] | ff63ce220c673cdec7d8cfd643cca1a32ca34f4c | https://github.com/owenwilljones/Tadpole-Components/blob/ff63ce220c673cdec7d8cfd643cca1a32ca34f4c/controller.php#L29-L32 |
1,599 | spiritdead/resque | controllers/ResqueJobStatus.php | ResqueJobStatus.get | public function get()
{
if (!$this->isTracking()) {
return false;
}
$statusPacket = json_decode($this->resqueInstance->redis->get((string)$this), true);
if (!$statusPacket) {
return false;
}
return $statusPacket['status'];
} | php | public function get()
{
if (!$this->isTracking()) {
return false;
}
$statusPacket = json_decode($this->resqueInstance->redis->get((string)$this), true);
if (!$statusPacket) {
return false;
}
return $statusPacket['status'];
} | [
"public",
"function",
"get",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isTracking",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"statusPacket",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"resqueInstance",
"->",
"redis",
"->",
"get",
"(",
"(",
"string",
")",
"$",
"this",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"statusPacket",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"statusPacket",
"[",
"'status'",
"]",
";",
"}"
] | Fetch the status for the job being monitored.
@return mixed False if the status is not being monitored, otherwise the status as
as an integer, based on the Resque_Job_Status constants. | [
"Fetch",
"the",
"status",
"for",
"the",
"job",
"being",
"monitored",
"."
] | 6d1f58c5a15a7f50a90ca08f882e64bc07488cc4 | https://github.com/spiritdead/resque/blob/6d1f58c5a15a7f50a90ca08f882e64bc07488cc4/controllers/ResqueJobStatus.php#L119-L131 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.