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
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,400 | iRAP-software/package-core-libs | src/ArrayLib.php | ArrayLib.array_combine_list | public static function array_combine_list(array $keys, array $rows)
{
$output = array();
foreach ($rows as $row)
{
if (count($row) !== count($keys))
{
$msg = "array_combine_list: Number of values in one of the rows is " .
"not equal to the number of keys.";
throw new \Exception($msg);
}
$output[] = array_combine($keys, $row);
}
return $output;
} | php | public static function array_combine_list(array $keys, array $rows)
{
$output = array();
foreach ($rows as $row)
{
if (count($row) !== count($keys))
{
$msg = "array_combine_list: Number of values in one of the rows is " .
"not equal to the number of keys.";
throw new \Exception($msg);
}
$output[] = array_combine($keys, $row);
}
return $output;
} | [
"public",
"static",
"function",
"array_combine_list",
"(",
"array",
"$",
"keys",
",",
"array",
"$",
"rows",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"row",
")",
"!==",
"count",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"msg",
"=",
"\"array_combine_list: Number of values in one of the rows is \"",
".",
"\"not equal to the number of keys.\"",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"msg",
")",
";",
"}",
"$",
"output",
"[",
"]",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"row",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Wrapper around array_combine that works on a list of arrays for the
values instead of being given a single array for the values. The result is a
list of arrays who's keys are provided by the keys parameter and the values are the
corresponding values in the rows' arrays.
@param array $keys - list of keys to set for the rows. The length should be exactly the
same as the length of every row in the rows array.
@param array $rows - list of arrays that whill have array_combine performed on. Every row
in this list should have the same length as keys.
If any of the rows have indexes, these will be lost.
@return array - the generated array list of rows. | [
"Wrapper",
"around",
"array_combine",
"that",
"works",
"on",
"a",
"list",
"of",
"arrays",
"for",
"the",
"values",
"instead",
"of",
"being",
"given",
"a",
"single",
"array",
"for",
"the",
"values",
".",
"The",
"result",
"is",
"a",
"list",
"of",
"arrays",
"who",
"s",
"keys",
"are",
"provided",
"by",
"the",
"keys",
"parameter",
"and",
"the",
"values",
"are",
"the",
"corresponding",
"values",
"in",
"the",
"rows",
"arrays",
"."
] | 244871d2fbc2f3fac26ff4b98715224953d9befb | https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/ArrayLib.php#L391-L409 |
9,401 | netherphp/database | src/Nether/Database.php | Database.QueryOld | public function QueryOld($fmt,$parm=null) {
/*//
@depreciated obviously
@return Nether\Database\Query;
builds a query using pdo's bound parameter stuff.
//*/
//echo "<p>{$fmt}</p>";
// if given a Database\Query object and an object for the parameters then
// fetch the named args in the query and find their matching properties
// in the parm object.
if(is_object($fmt) && (is_object($parm)||is_array($parm))) {
$qarg = [];
$parm = (object)$parm;
foreach($fmt->GetNamedArgs() as $arg) {
if(property_exists($parm,$arg)) $qarg[":{$arg}"] = $parm->{$arg};
else if(property_exists($parm,":{$arg}")) $qarg["{$arg}"] = $parm->{":{$arg}"};
}
$parm = $qarg;
}
else {
// if parm is not an array then build it as an array from all the
// arguments that were passed to the method.
if(!is_array($parm))
$parm = array_slice(func_get_args(),1);
}
// try to prepare the statement.
$qtime = microtime(true);
if(!($statement = $this->Driver->prepare($fmt)))
throw new \Exception('SQL statement was unable to be prepared.');
// hand over a query object.
$result = new Nether\Database\Result($this->Driver,$statement,$parm);
static::$QueryTime = microtime(true) - $qtime;
static::$QueryCount++;
return $result;
} | php | public function QueryOld($fmt,$parm=null) {
/*//
@depreciated obviously
@return Nether\Database\Query;
builds a query using pdo's bound parameter stuff.
//*/
//echo "<p>{$fmt}</p>";
// if given a Database\Query object and an object for the parameters then
// fetch the named args in the query and find their matching properties
// in the parm object.
if(is_object($fmt) && (is_object($parm)||is_array($parm))) {
$qarg = [];
$parm = (object)$parm;
foreach($fmt->GetNamedArgs() as $arg) {
if(property_exists($parm,$arg)) $qarg[":{$arg}"] = $parm->{$arg};
else if(property_exists($parm,":{$arg}")) $qarg["{$arg}"] = $parm->{":{$arg}"};
}
$parm = $qarg;
}
else {
// if parm is not an array then build it as an array from all the
// arguments that were passed to the method.
if(!is_array($parm))
$parm = array_slice(func_get_args(),1);
}
// try to prepare the statement.
$qtime = microtime(true);
if(!($statement = $this->Driver->prepare($fmt)))
throw new \Exception('SQL statement was unable to be prepared.');
// hand over a query object.
$result = new Nether\Database\Result($this->Driver,$statement,$parm);
static::$QueryTime = microtime(true) - $qtime;
static::$QueryCount++;
return $result;
} | [
"public",
"function",
"QueryOld",
"(",
"$",
"fmt",
",",
"$",
"parm",
"=",
"null",
")",
"{",
"/*//\n\t@depreciated obviously\n\t@return Nether\\Database\\Query;\n\tbuilds a query using pdo's bound parameter stuff.\n\t//*/",
"//echo \"<p>{$fmt}</p>\";",
"// if given a Database\\Query object and an object for the parameters then",
"// fetch the named args in the query and find their matching properties",
"// in the parm object.",
"if",
"(",
"is_object",
"(",
"$",
"fmt",
")",
"&&",
"(",
"is_object",
"(",
"$",
"parm",
")",
"||",
"is_array",
"(",
"$",
"parm",
")",
")",
")",
"{",
"$",
"qarg",
"=",
"[",
"]",
";",
"$",
"parm",
"=",
"(",
"object",
")",
"$",
"parm",
";",
"foreach",
"(",
"$",
"fmt",
"->",
"GetNamedArgs",
"(",
")",
"as",
"$",
"arg",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"parm",
",",
"$",
"arg",
")",
")",
"$",
"qarg",
"[",
"\":{$arg}\"",
"]",
"=",
"$",
"parm",
"->",
"{",
"$",
"arg",
"}",
";",
"else",
"if",
"(",
"property_exists",
"(",
"$",
"parm",
",",
"\":{$arg}\"",
")",
")",
"$",
"qarg",
"[",
"\"{$arg}\"",
"]",
"=",
"$",
"parm",
"->",
"{",
"\":{$arg}\"",
"}",
";",
"}",
"$",
"parm",
"=",
"$",
"qarg",
";",
"}",
"else",
"{",
"// if parm is not an array then build it as an array from all the",
"// arguments that were passed to the method.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"parm",
")",
")",
"$",
"parm",
"=",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"1",
")",
";",
"}",
"// try to prepare the statement.",
"$",
"qtime",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"!",
"(",
"$",
"statement",
"=",
"$",
"this",
"->",
"Driver",
"->",
"prepare",
"(",
"$",
"fmt",
")",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'SQL statement was unable to be prepared.'",
")",
";",
"// hand over a query object.",
"$",
"result",
"=",
"new",
"Nether",
"\\",
"Database",
"\\",
"Result",
"(",
"$",
"this",
"->",
"Driver",
",",
"$",
"statement",
",",
"$",
"parm",
")",
";",
"static",
"::",
"$",
"QueryTime",
"=",
"microtime",
"(",
"true",
")",
"-",
"$",
"qtime",
";",
"static",
"::",
"$",
"QueryCount",
"++",
";",
"return",
"$",
"result",
";",
"}"
] | by better things. | [
"by",
"better",
"things",
"."
] | bcbf7d6079b6ff4e022ee600699be9ac38cd6e9d | https://github.com/netherphp/database/blob/bcbf7d6079b6ff4e022ee600699be9ac38cd6e9d/src/Nether/Database.php#L606-L651 |
9,402 | phergie/phergie-irc-plugin-react-eventfilter | src/AndFilter.php | AndFilter.filter | public function filter(EventInterface $event)
{
$output = null;
foreach ($this->filters as $filter) {
$result = $filter->filter($event);
if ($result === false) {
return false;
}
if ($result === true) {
$output = true;
}
}
return $output;
} | php | public function filter(EventInterface $event)
{
$output = null;
foreach ($this->filters as $filter) {
$result = $filter->filter($event);
if ($result === false) {
return false;
}
if ($result === true) {
$output = true;
}
}
return $output;
} | [
"public",
"function",
"filter",
"(",
"EventInterface",
"$",
"event",
")",
"{",
"$",
"output",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"$",
"result",
"=",
"$",
"filter",
"->",
"filter",
"(",
"$",
"event",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"$",
"output",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Filters events that pass all contained filters.
@param \Phergie\Irc\Event\EventInterface $event
@return boolean|null TRUE if the event passes all contained filters, FALSE
if it fails any filter, or NULL if all filters return NULL. | [
"Filters",
"events",
"that",
"pass",
"all",
"contained",
"filters",
"."
] | 8fdde571a23ab1379d62a48e9de4570845c0e9dd | https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/AndFilter.php#L30-L43 |
9,403 | crater-framework/crater-php-framework | Cli/Migrate.php | Migrate.newMigration | public function newMigration()
{
$fileName = (isset($this->arguments[1])) ? $this->arguments[1] : null;
$this->migrateManager->newMigration($fileName);
} | php | public function newMigration()
{
$fileName = (isset($this->arguments[1])) ? $this->arguments[1] : null;
$this->migrateManager->newMigration($fileName);
} | [
"public",
"function",
"newMigration",
"(",
")",
"{",
"$",
"fileName",
"=",
"(",
"isset",
"(",
"$",
"this",
"->",
"arguments",
"[",
"1",
"]",
")",
")",
"?",
"$",
"this",
"->",
"arguments",
"[",
"1",
"]",
":",
"null",
";",
"$",
"this",
"->",
"migrateManager",
"->",
"newMigration",
"(",
"$",
"fileName",
")",
";",
"}"
] | Generate new migration file | [
"Generate",
"new",
"migration",
"file"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Cli/Migrate.php#L55-L59 |
9,404 | crater-framework/crater-php-framework | Cli/Migrate.php | Migrate.getVersion | private function getVersion()
{
$select = new QueryBuilder();
$versionRow = $select
->query("SELECT value FROM {$this->table} WHERE param = 'migration_version'")
->fetchRow();
if (!isset($versionRow['value'])) die("Error: Please init the Crater Migration");
return $versionRow['value'];
} | php | private function getVersion()
{
$select = new QueryBuilder();
$versionRow = $select
->query("SELECT value FROM {$this->table} WHERE param = 'migration_version'")
->fetchRow();
if (!isset($versionRow['value'])) die("Error: Please init the Crater Migration");
return $versionRow['value'];
} | [
"private",
"function",
"getVersion",
"(",
")",
"{",
"$",
"select",
"=",
"new",
"QueryBuilder",
"(",
")",
";",
"$",
"versionRow",
"=",
"$",
"select",
"->",
"query",
"(",
"\"SELECT value FROM {$this->table} WHERE param = 'migration_version'\"",
")",
"->",
"fetchRow",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"versionRow",
"[",
"'value'",
"]",
")",
")",
"die",
"(",
"\"Error: Please init the Crater Migration\"",
")",
";",
"return",
"$",
"versionRow",
"[",
"'value'",
"]",
";",
"}"
] | Get current version of database | [
"Get",
"current",
"version",
"of",
"database"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Cli/Migrate.php#L92-L101 |
9,405 | crater-framework/crater-php-framework | Cli/Migrate.php | Migrate.getMigrationsFiles | private function getMigrationsFiles()
{
$migrationPath = $this->migrateManager->storagePath;
$files = array();
if ($handle = opendir($migrationPath)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && is_file($migrationPath . '/' . $entry)) {
$segments = explode('_', $entry);
$files[$segments[0]] = $entry;
}
}
closedir($handle);
return $files;
}
die (Utils::colorize("Error to open migrations storage", "FAILURE"));
} | php | private function getMigrationsFiles()
{
$migrationPath = $this->migrateManager->storagePath;
$files = array();
if ($handle = opendir($migrationPath)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && is_file($migrationPath . '/' . $entry)) {
$segments = explode('_', $entry);
$files[$segments[0]] = $entry;
}
}
closedir($handle);
return $files;
}
die (Utils::colorize("Error to open migrations storage", "FAILURE"));
} | [
"private",
"function",
"getMigrationsFiles",
"(",
")",
"{",
"$",
"migrationPath",
"=",
"$",
"this",
"->",
"migrateManager",
"->",
"storagePath",
";",
"$",
"files",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"migrationPath",
")",
")",
"{",
"while",
"(",
"false",
"!==",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"$",
"entry",
"!=",
"\".\"",
"&&",
"$",
"entry",
"!=",
"\"..\"",
"&&",
"is_file",
"(",
"$",
"migrationPath",
".",
"'/'",
".",
"$",
"entry",
")",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'_'",
",",
"$",
"entry",
")",
";",
"$",
"files",
"[",
"$",
"segments",
"[",
"0",
"]",
"]",
"=",
"$",
"entry",
";",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"return",
"$",
"files",
";",
"}",
"die",
"(",
"Utils",
"::",
"colorize",
"(",
"\"Error to open migrations storage\"",
",",
"\"FAILURE\"",
")",
")",
";",
"}"
] | Get all migration files
@return array
@throws Exception | [
"Get",
"all",
"migration",
"files"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Cli/Migrate.php#L124-L144 |
9,406 | crater-framework/crater-php-framework | Cli/Migrate.php | Migrate.apply | public function apply()
{
$files = $this->getMigrationsFiles();
$lastMigration = null;
asort($files);
foreach ($files as $key => $value) {
if ($key <= $this->getVersion()) continue;
include $this->migrateManager->storagePath . '/' . $value;
$className = "Migration_$key";
$class = new $className();
$class->up();
$lastMigration = $key;
unset($class);
}
if (!is_null($lastMigration)) {
$this->setVersion($lastMigration);
echo Utils::colorize("Done!", "SUCCESS");
} else {
echo Utils::colorize("The latest version is already installed.", "NOTE");
}
} | php | public function apply()
{
$files = $this->getMigrationsFiles();
$lastMigration = null;
asort($files);
foreach ($files as $key => $value) {
if ($key <= $this->getVersion()) continue;
include $this->migrateManager->storagePath . '/' . $value;
$className = "Migration_$key";
$class = new $className();
$class->up();
$lastMigration = $key;
unset($class);
}
if (!is_null($lastMigration)) {
$this->setVersion($lastMigration);
echo Utils::colorize("Done!", "SUCCESS");
} else {
echo Utils::colorize("The latest version is already installed.", "NOTE");
}
} | [
"public",
"function",
"apply",
"(",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getMigrationsFiles",
"(",
")",
";",
"$",
"lastMigration",
"=",
"null",
";",
"asort",
"(",
"$",
"files",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"<=",
"$",
"this",
"->",
"getVersion",
"(",
")",
")",
"continue",
";",
"include",
"$",
"this",
"->",
"migrateManager",
"->",
"storagePath",
".",
"'/'",
".",
"$",
"value",
";",
"$",
"className",
"=",
"\"Migration_$key\"",
";",
"$",
"class",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"class",
"->",
"up",
"(",
")",
";",
"$",
"lastMigration",
"=",
"$",
"key",
";",
"unset",
"(",
"$",
"class",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"lastMigration",
")",
")",
"{",
"$",
"this",
"->",
"setVersion",
"(",
"$",
"lastMigration",
")",
";",
"echo",
"Utils",
"::",
"colorize",
"(",
"\"Done!\"",
",",
"\"SUCCESS\"",
")",
";",
"}",
"else",
"{",
"echo",
"Utils",
"::",
"colorize",
"(",
"\"The latest version is already installed.\"",
",",
"\"NOTE\"",
")",
";",
"}",
"}"
] | Install all the migration files
@throws Exception | [
"Install",
"all",
"the",
"migration",
"files"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Cli/Migrate.php#L151-L176 |
9,407 | crater-framework/crater-php-framework | Cli/Migrate.php | Migrate.rollback | public function rollback($version)
{
$files = $this->getMigrationsFiles();
$lastMigration = null;
arsort($files);
foreach ($files as $key => $value) {
if ($key < $version) continue;
include $this->migrateManager->storagePath . '/' . $value;
$className = "Migration_$key";
$class = new $className();
$class->down();
$lastMigration = $key;
unset($class);
}
if (!is_null($lastMigration)) {
$this->setVersion($lastMigration - 1);
echo Utils::colorize("Done!", "SUCCESS");
} else {
echo Utils::colorize("The latest version is already installed.", "NOTE");
}
} | php | public function rollback($version)
{
$files = $this->getMigrationsFiles();
$lastMigration = null;
arsort($files);
foreach ($files as $key => $value) {
if ($key < $version) continue;
include $this->migrateManager->storagePath . '/' . $value;
$className = "Migration_$key";
$class = new $className();
$class->down();
$lastMigration = $key;
unset($class);
}
if (!is_null($lastMigration)) {
$this->setVersion($lastMigration - 1);
echo Utils::colorize("Done!", "SUCCESS");
} else {
echo Utils::colorize("The latest version is already installed.", "NOTE");
}
} | [
"public",
"function",
"rollback",
"(",
"$",
"version",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"getMigrationsFiles",
"(",
")",
";",
"$",
"lastMigration",
"=",
"null",
";",
"arsort",
"(",
"$",
"files",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"<",
"$",
"version",
")",
"continue",
";",
"include",
"$",
"this",
"->",
"migrateManager",
"->",
"storagePath",
".",
"'/'",
".",
"$",
"value",
";",
"$",
"className",
"=",
"\"Migration_$key\"",
";",
"$",
"class",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"class",
"->",
"down",
"(",
")",
";",
"$",
"lastMigration",
"=",
"$",
"key",
";",
"unset",
"(",
"$",
"class",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"lastMigration",
")",
")",
"{",
"$",
"this",
"->",
"setVersion",
"(",
"$",
"lastMigration",
"-",
"1",
")",
";",
"echo",
"Utils",
"::",
"colorize",
"(",
"\"Done!\"",
",",
"\"SUCCESS\"",
")",
";",
"}",
"else",
"{",
"echo",
"Utils",
"::",
"colorize",
"(",
"\"The latest version is already installed.\"",
",",
"\"NOTE\"",
")",
";",
"}",
"}"
] | Return to a specific version
@param string $version Version number
@throws Exception | [
"Return",
"to",
"a",
"specific",
"version"
] | ff7a4f69f8ee7beb37adee348b67d1be84c51ff1 | https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Cli/Migrate.php#L184-L207 |
9,408 | zepi/turbo-base | Zepi/Web/AccessControl/src/Manager/GroupManager.php | GroupManager.add | public function add(EntityInterface $group)
{
if (!is_a($group, self::ACCESS_ENTITY_TYPE)) {
throw new Exception('The given entity (' . get_class($group) . ') is not compatible with this data source (' . self::class . '.');
}
// If the name of the group already is used we cannot add a new group
if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $group->getName())) {
throw new Exception('Cannot add the group. The name of the group is already in use.');
}
// Add the access entity
$uuid = $this->accessControlManager->addAccessEntity($group);
if ($uuid === false) {
throw new Exception('Cannot add the group. Internal software error.');
}
return $group;
} | php | public function add(EntityInterface $group)
{
if (!is_a($group, self::ACCESS_ENTITY_TYPE)) {
throw new Exception('The given entity (' . get_class($group) . ') is not compatible with this data source (' . self::class . '.');
}
// If the name of the group already is used we cannot add a new group
if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $group->getName())) {
throw new Exception('Cannot add the group. The name of the group is already in use.');
}
// Add the access entity
$uuid = $this->accessControlManager->addAccessEntity($group);
if ($uuid === false) {
throw new Exception('Cannot add the group. Internal software error.');
}
return $group;
} | [
"public",
"function",
"add",
"(",
"EntityInterface",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"group",
",",
"self",
"::",
"ACCESS_ENTITY_TYPE",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The given entity ('",
".",
"get_class",
"(",
"$",
"group",
")",
".",
"') is not compatible with this data source ('",
".",
"self",
"::",
"class",
".",
"'.'",
")",
";",
"}",
"// If the name of the group already is used we cannot add a new group",
"if",
"(",
"$",
"this",
"->",
"accessControlManager",
"->",
"hasAccessEntityForName",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"group",
"->",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot add the group. The name of the group is already in use.'",
")",
";",
"}",
"// Add the access entity",
"$",
"uuid",
"=",
"$",
"this",
"->",
"accessControlManager",
"->",
"addAccessEntity",
"(",
"$",
"group",
")",
";",
"if",
"(",
"$",
"uuid",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot add the group. Internal software error.'",
")",
";",
"}",
"return",
"$",
"group",
";",
"}"
] | Adds the given group to the access entities
@param \Zepi\DataSource\Core\Entity\EntityInterface $group
@return false|\Zepi\Web\AccessControl\Entity\Group
@throws \Zepi\Web\AccessControl\Exception The given entity is not compatible with this data source.
@throws \Zepi\Web\AccessControl\Exception Cannot add the group. The name of the group is already in use.
@throws \Zepi\Web\AccessControl\Exception Cannot add the group. Internal software error. | [
"Adds",
"the",
"given",
"group",
"to",
"the",
"access",
"entities"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Manager/GroupManager.php#L86-L105 |
9,409 | zepi/turbo-base | Zepi/Web/AccessControl/src/Manager/GroupManager.php | GroupManager.update | public function update(EntityInterface $group)
{
if (!is_a($group, self::ACCESS_ENTITY_TYPE)) {
throw new Exception('The given entity (' . get_class($group) . ') is not compatible with this data source (' . self::class . '.');
}
// If the uuid does not exists we cannot update the group
if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $group->getUuid())) {
throw new Exception('Cannot update the group. The group does not exist.');
}
// Update the access entity
return $this->accessControlManager->updateAccessEntity($group);
} | php | public function update(EntityInterface $group)
{
if (!is_a($group, self::ACCESS_ENTITY_TYPE)) {
throw new Exception('The given entity (' . get_class($group) . ') is not compatible with this data source (' . self::class . '.');
}
// If the uuid does not exists we cannot update the group
if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $group->getUuid())) {
throw new Exception('Cannot update the group. The group does not exist.');
}
// Update the access entity
return $this->accessControlManager->updateAccessEntity($group);
} | [
"public",
"function",
"update",
"(",
"EntityInterface",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"group",
",",
"self",
"::",
"ACCESS_ENTITY_TYPE",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The given entity ('",
".",
"get_class",
"(",
"$",
"group",
")",
".",
"') is not compatible with this data source ('",
".",
"self",
"::",
"class",
".",
"'.'",
")",
";",
"}",
"// If the uuid does not exists we cannot update the group",
"if",
"(",
"!",
"$",
"this",
"->",
"accessControlManager",
"->",
"hasAccessEntityForUuid",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"group",
"->",
"getUuid",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot update the group. The group does not exist.'",
")",
";",
"}",
"// Update the access entity",
"return",
"$",
"this",
"->",
"accessControlManager",
"->",
"updateAccessEntity",
"(",
"$",
"group",
")",
";",
"}"
] | Updates the given Group
@param \Zepi\DataSource\Core\Entity\EntityInterface $group
@return boolean
@throws \Zepi\Web\AccessControl\Exception The given entity is not compatible with this data source.
@throws \Zepi\Web\AccessControl\Exception Cannot update the group. The group does not exist. | [
"Updates",
"the",
"given",
"Group"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Manager/GroupManager.php#L116-L129 |
9,410 | zepi/turbo-base | Zepi/Web/AccessControl/src/Manager/GroupManager.php | GroupManager.delete | public function delete(EntityInterface $group)
{
if (!is_a($group, self::ACCESS_ENTITY_TYPE)) {
throw new Exception('The given entity (' . get_class($group) . ') is not compatible with this data source (' . self::class . '.');
}
// If the uuid does not exists we cannot delete the group
if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $group->getUuid())) {
throw new Exception('Cannot update the group. Group does not exist.');
}
// Delete the access entity
return $this->accessControlManager->deleteAccessEntity($group);
} | php | public function delete(EntityInterface $group)
{
if (!is_a($group, self::ACCESS_ENTITY_TYPE)) {
throw new Exception('The given entity (' . get_class($group) . ') is not compatible with this data source (' . self::class . '.');
}
// If the uuid does not exists we cannot delete the group
if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $group->getUuid())) {
throw new Exception('Cannot update the group. Group does not exist.');
}
// Delete the access entity
return $this->accessControlManager->deleteAccessEntity($group);
} | [
"public",
"function",
"delete",
"(",
"EntityInterface",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"group",
",",
"self",
"::",
"ACCESS_ENTITY_TYPE",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The given entity ('",
".",
"get_class",
"(",
"$",
"group",
")",
".",
"') is not compatible with this data source ('",
".",
"self",
"::",
"class",
".",
"'.'",
")",
";",
"}",
"// If the uuid does not exists we cannot delete the group",
"if",
"(",
"!",
"$",
"this",
"->",
"accessControlManager",
"->",
"hasAccessEntityForUuid",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"group",
"->",
"getUuid",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot update the group. Group does not exist.'",
")",
";",
"}",
"// Delete the access entity",
"return",
"$",
"this",
"->",
"accessControlManager",
"->",
"deleteAccessEntity",
"(",
"$",
"group",
")",
";",
"}"
] | Deletes the group with the given uuid
@param \Zepi\DataSource\Core\Entity\EntityInterface $group
@return boolean
@throws \Zepi\Web\AccessControl\Exception The given entity is not compatible with this data source.
@throws \Zepi\Web\AccessControl\Exception Cannot delete the group. Group does not exist. | [
"Deletes",
"the",
"group",
"with",
"the",
"given",
"uuid"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Manager/GroupManager.php#L140-L153 |
9,411 | zepi/turbo-base | Zepi/Web/AccessControl/src/Manager/GroupManager.php | GroupManager.hasGroupForName | public function hasGroupForName($name)
{
if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name)) {
return true;
}
return false;
} | php | public function hasGroupForName($name)
{
if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name)) {
return true;
}
return false;
} | [
"public",
"function",
"hasGroupForName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"accessControlManager",
"->",
"hasAccessEntityForName",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Returns true if the given name of the group exists as access entity
@access public
@param string $name
@return boolean | [
"Returns",
"true",
"if",
"the",
"given",
"name",
"of",
"the",
"group",
"exists",
"as",
"access",
"entity"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Manager/GroupManager.php#L178-L185 |
9,412 | zepi/turbo-base | Zepi/Web/AccessControl/src/Manager/GroupManager.php | GroupManager.getGroupForUuid | public function getGroupForUuid($uuid)
{
if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $uuid)) {
return false;
}
// Get the access entity
$accessEntity = $this->accessControlManager->getAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $uuid);
if ($accessEntity === false) {
return false;
}
return $accessEntity;
} | php | public function getGroupForUuid($uuid)
{
if (!$this->accessControlManager->hasAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $uuid)) {
return false;
}
// Get the access entity
$accessEntity = $this->accessControlManager->getAccessEntityForUuid(self::ACCESS_ENTITY_TYPE, $uuid);
if ($accessEntity === false) {
return false;
}
return $accessEntity;
} | [
"public",
"function",
"getGroupForUuid",
"(",
"$",
"uuid",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"accessControlManager",
"->",
"hasAccessEntityForUuid",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"uuid",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Get the access entity",
"$",
"accessEntity",
"=",
"$",
"this",
"->",
"accessControlManager",
"->",
"getAccessEntityForUuid",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"uuid",
")",
";",
"if",
"(",
"$",
"accessEntity",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"accessEntity",
";",
"}"
] | Returns the group object for the given uuid
@access public
@param string $uuid
@return boolean | [
"Returns",
"the",
"group",
"object",
"for",
"the",
"given",
"uuid"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Manager/GroupManager.php#L194-L208 |
9,413 | zepi/turbo-base | Zepi/Web/AccessControl/src/Manager/GroupManager.php | GroupManager.getGroupForName | public function getGroupForName($name)
{
if (!$this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name)) {
return false;
}
// Get the access entity
$accessEntity = $this->accessControlManager->getAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name);
if ($accessEntity === false) {
return false;
}
return $accessEntity;
} | php | public function getGroupForName($name)
{
if (!$this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name)) {
return false;
}
// Get the access entity
$accessEntity = $this->accessControlManager->getAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name);
if ($accessEntity === false) {
return false;
}
return $accessEntity;
} | [
"public",
"function",
"getGroupForName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"accessControlManager",
"->",
"hasAccessEntityForName",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Get the access entity",
"$",
"accessEntity",
"=",
"$",
"this",
"->",
"accessControlManager",
"->",
"getAccessEntityForName",
"(",
"self",
"::",
"ACCESS_ENTITY_TYPE",
",",
"$",
"name",
")",
";",
"if",
"(",
"$",
"accessEntity",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"accessEntity",
";",
"}"
] | Returns the Group object for the given name
@access public
@param string $name
@return boolean | [
"Returns",
"the",
"Group",
"object",
"for",
"the",
"given",
"name"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/AccessControl/src/Manager/GroupManager.php#L217-L231 |
9,414 | damien-carcel/UserBundle | src/Manager/UserManager.php | UserManager.setRole | public function setRole(UserInterface $user, array $selectedRole)
{
$choices = $this->rolesManager->getChoices();
if (!isset($choices[$selectedRole['roles']])) {
throw new InvalidArgumentException(
sprintf('Impossible to set role %s', $selectedRole['roles'])
);
}
$user->setRoles([$choices[$selectedRole['roles']]]);
$this->entityManager->flush();
} | php | public function setRole(UserInterface $user, array $selectedRole)
{
$choices = $this->rolesManager->getChoices();
if (!isset($choices[$selectedRole['roles']])) {
throw new InvalidArgumentException(
sprintf('Impossible to set role %s', $selectedRole['roles'])
);
}
$user->setRoles([$choices[$selectedRole['roles']]]);
$this->entityManager->flush();
} | [
"public",
"function",
"setRole",
"(",
"UserInterface",
"$",
"user",
",",
"array",
"$",
"selectedRole",
")",
"{",
"$",
"choices",
"=",
"$",
"this",
"->",
"rolesManager",
"->",
"getChoices",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"choices",
"[",
"$",
"selectedRole",
"[",
"'roles'",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Impossible to set role %s'",
",",
"$",
"selectedRole",
"[",
"'roles'",
"]",
")",
")",
";",
"}",
"$",
"user",
"->",
"setRoles",
"(",
"[",
"$",
"choices",
"[",
"$",
"selectedRole",
"[",
"'roles'",
"]",
"]",
"]",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"flush",
"(",
")",
";",
"}"
] | Sets a user role.
New role is provided as an key-value array:
[
'roles' => 'ROLE_TO_SET',
]
@param UserInterface $user
@param array $selectedRole | [
"Sets",
"a",
"user",
"role",
"."
] | 22989aa3580184bb3317520281372415cd80ab4d | https://github.com/damien-carcel/UserBundle/blob/22989aa3580184bb3317520281372415cd80ab4d/src/Manager/UserManager.php#L81-L94 |
9,415 | acacha/ebre_escool_model | src/Traits/Periodable.php | Periodable.scopeActiveOn | public function scopeActiveOn($query, $period)
{
return $query->whereHas('periods', function($query) use ($period){
$query->where('academic_periods_id', $period);
});
} | php | public function scopeActiveOn($query, $period)
{
return $query->whereHas('periods', function($query) use ($period){
$query->where('academic_periods_id', $period);
});
} | [
"public",
"function",
"scopeActiveOn",
"(",
"$",
"query",
",",
"$",
"period",
")",
"{",
"return",
"$",
"query",
"->",
"whereHas",
"(",
"'periods'",
",",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"period",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'academic_periods_id'",
",",
"$",
"period",
")",
";",
"}",
")",
";",
"}"
] | Only studies active for given period.
@param \Illuminate\Database\Eloquent\Builder $query
@param $period
@return mixed | [
"Only",
"studies",
"active",
"for",
"given",
"period",
"."
] | 91c0b870714490baa9500215a6dc07935e525a75 | https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/Traits/Periodable.php#L32-L37 |
9,416 | encorephp/error | src/ServiceProvider.php | ServiceProvider.register | public function register()
{
$displayer = new BasicDisplayer;
$handler = new Handler($displayer);
$this->container->bind('error', $handler);
} | php | public function register()
{
$displayer = new BasicDisplayer;
$handler = new Handler($displayer);
$this->container->bind('error', $handler);
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"displayer",
"=",
"new",
"BasicDisplayer",
";",
"$",
"handler",
"=",
"new",
"Handler",
"(",
"$",
"displayer",
")",
";",
"$",
"this",
"->",
"container",
"->",
"bind",
"(",
"'error'",
",",
"$",
"handler",
")",
";",
"}"
] | Register the error handler into the container.
@return void | [
"Register",
"the",
"error",
"handler",
"into",
"the",
"container",
"."
] | 1e411efa4389412fa2727973a60841bdefb0102b | https://github.com/encorephp/error/blob/1e411efa4389412fa2727973a60841bdefb0102b/src/ServiceProvider.php#L15-L20 |
9,417 | PentagonalProject/SlimService | src/Hook.php | Hook.uniqueId | final private function uniqueId($function)
{
if (is_string($function)) {
return $function;
}
if (is_object($function)) {
// Closures are currently implemented as objects
$function = [ $function, '' ];
} elseif (!is_array($function)) {
$function = [ $function ];
}
$function = array_values($function);
if (is_object($function[0])) {
return \spl_object_hash($function[0]) . $function[1];
} elseif (count($function) > 1 || is_string($function[0])) {
// call as static
return $function[0] . '::' . $function[1];
}
// unexpected result
return null;
} | php | final private function uniqueId($function)
{
if (is_string($function)) {
return $function;
}
if (is_object($function)) {
// Closures are currently implemented as objects
$function = [ $function, '' ];
} elseif (!is_array($function)) {
$function = [ $function ];
}
$function = array_values($function);
if (is_object($function[0])) {
return \spl_object_hash($function[0]) . $function[1];
} elseif (count($function) > 1 || is_string($function[0])) {
// call as static
return $function[0] . '::' . $function[1];
}
// unexpected result
return null;
} | [
"final",
"private",
"function",
"uniqueId",
"(",
"$",
"function",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"function",
")",
")",
"{",
"return",
"$",
"function",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"function",
")",
")",
"{",
"// Closures are currently implemented as objects",
"$",
"function",
"=",
"[",
"$",
"function",
",",
"''",
"]",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"function",
")",
")",
"{",
"$",
"function",
"=",
"[",
"$",
"function",
"]",
";",
"}",
"$",
"function",
"=",
"array_values",
"(",
"$",
"function",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"function",
"[",
"0",
"]",
")",
")",
"{",
"return",
"\\",
"spl_object_hash",
"(",
"$",
"function",
"[",
"0",
"]",
")",
".",
"$",
"function",
"[",
"1",
"]",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"function",
")",
">",
"1",
"||",
"is_string",
"(",
"$",
"function",
"[",
"0",
"]",
")",
")",
"{",
"// call as static",
"return",
"$",
"function",
"[",
"0",
"]",
".",
"'::'",
".",
"$",
"function",
"[",
"1",
"]",
";",
"}",
"// unexpected result",
"return",
"null",
";",
"}"
] | Create Unique ID if function is not string
@param callable $function function to call
@access private
@return string|bool|null | [
"Create",
"Unique",
"ID",
"if",
"function",
"is",
"not",
"string"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L81-L104 |
9,418 | PentagonalProject/SlimService | src/Hook.php | Hook.exists | public function exists($hookName, $functionToCheck = false)
{
$hookName = $this->sanitizeKeyName($hookName);
if (! $hookName || ! isset($this->filters[$hookName])) {
return false;
}
// Don't reset the internal array pointer
$has = empty($this->filters[$hookName]);
// Make sure at least one priority has a filter callback
if ($has) {
$exists = false;
foreach ($this->filters[$hookName] as $callbacks) {
if (! empty($callbacks)) {
$exists = true;
break;
}
}
if (! $exists) {
$has = false;
}
}
// recheck
if ($functionToCheck === false || $has === false) {
return $has;
}
if (! $id = $this->uniqueId($functionToCheck)) {
return false;
}
foreach ($this->filters[$hookName] as $priority) {
if (isset($priority[$id])) {
return $priority;
}
}
return false;
} | php | public function exists($hookName, $functionToCheck = false)
{
$hookName = $this->sanitizeKeyName($hookName);
if (! $hookName || ! isset($this->filters[$hookName])) {
return false;
}
// Don't reset the internal array pointer
$has = empty($this->filters[$hookName]);
// Make sure at least one priority has a filter callback
if ($has) {
$exists = false;
foreach ($this->filters[$hookName] as $callbacks) {
if (! empty($callbacks)) {
$exists = true;
break;
}
}
if (! $exists) {
$has = false;
}
}
// recheck
if ($functionToCheck === false || $has === false) {
return $has;
}
if (! $id = $this->uniqueId($functionToCheck)) {
return false;
}
foreach ($this->filters[$hookName] as $priority) {
if (isset($priority[$id])) {
return $priority;
}
}
return false;
} | [
"public",
"function",
"exists",
"(",
"$",
"hookName",
",",
"$",
"functionToCheck",
"=",
"false",
")",
"{",
"$",
"hookName",
"=",
"$",
"this",
"->",
"sanitizeKeyName",
"(",
"$",
"hookName",
")",
";",
"if",
"(",
"!",
"$",
"hookName",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Don't reset the internal array pointer",
"$",
"has",
"=",
"empty",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
";",
"// Make sure at least one priority has a filter callback",
"if",
"(",
"$",
"has",
")",
"{",
"$",
"exists",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
"as",
"$",
"callbacks",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"callbacks",
")",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"exists",
")",
"{",
"$",
"has",
"=",
"false",
";",
"}",
"}",
"// recheck",
"if",
"(",
"$",
"functionToCheck",
"===",
"false",
"||",
"$",
"has",
"===",
"false",
")",
"{",
"return",
"$",
"has",
";",
"}",
"if",
"(",
"!",
"$",
"id",
"=",
"$",
"this",
"->",
"uniqueId",
"(",
"$",
"functionToCheck",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
"as",
"$",
"priority",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"priority",
"[",
"$",
"id",
"]",
")",
")",
"{",
"return",
"$",
"priority",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if hook name exists
@param string $hookName Hook name
@param string|mixed $functionToCheck Specially Functions on Hook
@return boolean|int | [
"Check",
"if",
"hook",
"name",
"exists"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L185-L225 |
9,419 | PentagonalProject/SlimService | src/Hook.php | Hook.call | public function call($hookName, $arg = '') : bool
{
$hookName = $this->sanitizeKeyName($hookName);
if (! $hookName) {
return false;
}
if (! isset($this->actions[$hookName])) {
$this->actions[$hookName] = 1;
} else {
$this->actions[$hookName]++;
}
if (! isset($this->filters[$hookName])) {
return false;
}
$this->current[] = $hookName;
$args = [];
if (is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0])) {
$args[] =& $arg[0];
} else {
$args[] = $arg;
}
for ($a = 2, $num = func_num_args(); $a < $num; $a++) {
$args[] = func_get_arg($a);
}
// Sort
if (! isset($this->merged[$hookName])) {
ksort($this->filters[$hookName]);
$this->merged[$hookName] = true;
}
reset($this->filters[$hookName]);
do {
foreach (current($this->filters[$hookName]) as $collection) {
if (!is_null($collection[self::KEY_FUNCTION])) {
call_user_func_array(
$collection[self::KEY_FUNCTION],
array_slice(
$args,
0,
(int) $collection[self::KEY_ACCEPTED_ARGS]
)
);
}
}
} while (next($this->filters[$hookName]) !== false);
array_pop($this->current);
return true;
} | php | public function call($hookName, $arg = '') : bool
{
$hookName = $this->sanitizeKeyName($hookName);
if (! $hookName) {
return false;
}
if (! isset($this->actions[$hookName])) {
$this->actions[$hookName] = 1;
} else {
$this->actions[$hookName]++;
}
if (! isset($this->filters[$hookName])) {
return false;
}
$this->current[] = $hookName;
$args = [];
if (is_array($arg) && 1 == count($arg) && isset($arg[0]) && is_object($arg[0])) {
$args[] =& $arg[0];
} else {
$args[] = $arg;
}
for ($a = 2, $num = func_num_args(); $a < $num; $a++) {
$args[] = func_get_arg($a);
}
// Sort
if (! isset($this->merged[$hookName])) {
ksort($this->filters[$hookName]);
$this->merged[$hookName] = true;
}
reset($this->filters[$hookName]);
do {
foreach (current($this->filters[$hookName]) as $collection) {
if (!is_null($collection[self::KEY_FUNCTION])) {
call_user_func_array(
$collection[self::KEY_FUNCTION],
array_slice(
$args,
0,
(int) $collection[self::KEY_ACCEPTED_ARGS]
)
);
}
}
} while (next($this->filters[$hookName]) !== false);
array_pop($this->current);
return true;
} | [
"public",
"function",
"call",
"(",
"$",
"hookName",
",",
"$",
"arg",
"=",
"''",
")",
":",
"bool",
"{",
"$",
"hookName",
"=",
"$",
"this",
"->",
"sanitizeKeyName",
"(",
"$",
"hookName",
")",
";",
"if",
"(",
"!",
"$",
"hookName",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"actions",
"[",
"$",
"hookName",
"]",
")",
")",
"{",
"$",
"this",
"->",
"actions",
"[",
"$",
"hookName",
"]",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"actions",
"[",
"$",
"hookName",
"]",
"++",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"current",
"[",
"]",
"=",
"$",
"hookName",
";",
"$",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"arg",
")",
"&&",
"1",
"==",
"count",
"(",
"$",
"arg",
")",
"&&",
"isset",
"(",
"$",
"arg",
"[",
"0",
"]",
")",
"&&",
"is_object",
"(",
"$",
"arg",
"[",
"0",
"]",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"&",
"$",
"arg",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"arg",
";",
"}",
"for",
"(",
"$",
"a",
"=",
"2",
",",
"$",
"num",
"=",
"func_num_args",
"(",
")",
";",
"$",
"a",
"<",
"$",
"num",
";",
"$",
"a",
"++",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"func_get_arg",
"(",
"$",
"a",
")",
";",
"}",
"// Sort",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"merged",
"[",
"$",
"hookName",
"]",
")",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
";",
"$",
"this",
"->",
"merged",
"[",
"$",
"hookName",
"]",
"=",
"true",
";",
"}",
"reset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
";",
"do",
"{",
"foreach",
"(",
"current",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
"as",
"$",
"collection",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"collection",
"[",
"self",
"::",
"KEY_FUNCTION",
"]",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"collection",
"[",
"self",
"::",
"KEY_FUNCTION",
"]",
",",
"array_slice",
"(",
"$",
"args",
",",
"0",
",",
"(",
"int",
")",
"$",
"collection",
"[",
"self",
"::",
"KEY_ACCEPTED_ARGS",
"]",
")",
")",
";",
"}",
"}",
"}",
"while",
"(",
"next",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
"!==",
"false",
")",
";",
"array_pop",
"(",
"$",
"this",
"->",
"current",
")",
";",
"return",
"true",
";",
"}"
] | Call hook from existing declared hook record
@param string $hookName Hook Name
@param string $arg the arguments for next parameter
@return boolean | [
"Call",
"hook",
"from",
"existing",
"declared",
"hook",
"record"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L291-L344 |
9,420 | PentagonalProject/SlimService | src/Hook.php | Hook.replace | public function replace(
$hookName,
$functionToReplace,
$callable,
$priority = 10,
$acceptedArguments = 1,
$create = true
) :bool {
$hookName = $this->sanitizeKeyName($hookName);
if (!$hookName) {
throw new InvalidArgumentException(
"Invalid Hook Name Specified",
E_USER_ERROR
);
}
if (!is_callable($callable)) {
throw new RuntimeException(
"Invalid Hook Callable Specified",
E_USER_ERROR
);
}
if (($has = $this->exists($hookName, $functionToReplace)) || $create) {
$has && $this->remove($hookName, $functionToReplace);
// add hooks first
return $this->add($hookName, $callable, $priority, $acceptedArguments);
}
return false;
} | php | public function replace(
$hookName,
$functionToReplace,
$callable,
$priority = 10,
$acceptedArguments = 1,
$create = true
) :bool {
$hookName = $this->sanitizeKeyName($hookName);
if (!$hookName) {
throw new InvalidArgumentException(
"Invalid Hook Name Specified",
E_USER_ERROR
);
}
if (!is_callable($callable)) {
throw new RuntimeException(
"Invalid Hook Callable Specified",
E_USER_ERROR
);
}
if (($has = $this->exists($hookName, $functionToReplace)) || $create) {
$has && $this->remove($hookName, $functionToReplace);
// add hooks first
return $this->add($hookName, $callable, $priority, $acceptedArguments);
}
return false;
} | [
"public",
"function",
"replace",
"(",
"$",
"hookName",
",",
"$",
"functionToReplace",
",",
"$",
"callable",
",",
"$",
"priority",
"=",
"10",
",",
"$",
"acceptedArguments",
"=",
"1",
",",
"$",
"create",
"=",
"true",
")",
":",
"bool",
"{",
"$",
"hookName",
"=",
"$",
"this",
"->",
"sanitizeKeyName",
"(",
"$",
"hookName",
")",
";",
"if",
"(",
"!",
"$",
"hookName",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Invalid Hook Name Specified\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Invalid Hook Callable Specified\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"(",
"$",
"has",
"=",
"$",
"this",
"->",
"exists",
"(",
"$",
"hookName",
",",
"$",
"functionToReplace",
")",
")",
"||",
"$",
"create",
")",
"{",
"$",
"has",
"&&",
"$",
"this",
"->",
"remove",
"(",
"$",
"hookName",
",",
"$",
"functionToReplace",
")",
";",
"// add hooks first",
"return",
"$",
"this",
"->",
"add",
"(",
"$",
"hookName",
",",
"$",
"callable",
",",
"$",
"priority",
",",
"$",
"acceptedArguments",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Replace Hooks Function, this will replace all existing hooks
@param string $hookName Hook Name
@param string $functionToReplace Function to replace
@param Callable $callable Callable
@param integer $priority priority
@param integer $acceptedArguments num count of accepted args / parameter
@param boolean $create true if want to create new if not exists
@return boolean
@throws InvalidArgumentException
@throws RuntimeException | [
"Replace",
"Hooks",
"Function",
"this",
"will",
"replace",
"all",
"existing",
"hooks"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L360-L390 |
9,421 | PentagonalProject/SlimService | src/Hook.php | Hook.count | public function count($hookName) : int
{
$hookName = $this->sanitizeKeyName($hookName);
if (!$hookName || ! isset($this->filters[$hookName])) {
return 0;
}
return count($this->filters[$hookName]);
} | php | public function count($hookName) : int
{
$hookName = $this->sanitizeKeyName($hookName);
if (!$hookName || ! isset($this->filters[$hookName])) {
return 0;
}
return count($this->filters[$hookName]);
} | [
"public",
"function",
"count",
"(",
"$",
"hookName",
")",
":",
"int",
"{",
"$",
"hookName",
"=",
"$",
"this",
"->",
"sanitizeKeyName",
"(",
"$",
"hookName",
")",
";",
"if",
"(",
"!",
"$",
"hookName",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"hookName",
"]",
")",
";",
"}"
] | Count all existences Hook
@param string $hookName Hook name
@return integer Hooks Count | [
"Count",
"all",
"existences",
"Hook"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L464-L471 |
9,422 | PentagonalProject/SlimService | src/Hook.php | Hook.hasDoing | public function hasDoing($hookName = null) : bool
{
if (null === $hookName) {
return ! empty($this->current);
}
$hookName = $this->sanitizeKeyName($hookName);
return $hookName && isset($this->current[$hookName]);
} | php | public function hasDoing($hookName = null) : bool
{
if (null === $hookName) {
return ! empty($this->current);
}
$hookName = $this->sanitizeKeyName($hookName);
return $hookName && isset($this->current[$hookName]);
} | [
"public",
"function",
"hasDoing",
"(",
"$",
"hookName",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"null",
"===",
"$",
"hookName",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"this",
"->",
"current",
")",
";",
"}",
"$",
"hookName",
"=",
"$",
"this",
"->",
"sanitizeKeyName",
"(",
"$",
"hookName",
")",
";",
"return",
"$",
"hookName",
"&&",
"isset",
"(",
"$",
"this",
"->",
"current",
"[",
"$",
"hookName",
"]",
")",
";",
"}"
] | Check if hook has doing
@param string $hookName Hook name
@return boolean true if has doing | [
"Check",
"if",
"hook",
"has",
"doing"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L480-L488 |
9,423 | PentagonalProject/SlimService | src/Hook.php | Hook.hasCalled | public function hasCalled($hookName) : int
{
$hookName = $this->sanitizeKeyName($hookName);
if (!$hookName || ! isset($this->actions[$hookName])) {
return 0;
}
return $this->actions[$hookName];
} | php | public function hasCalled($hookName) : int
{
$hookName = $this->sanitizeKeyName($hookName);
if (!$hookName || ! isset($this->actions[$hookName])) {
return 0;
}
return $this->actions[$hookName];
} | [
"public",
"function",
"hasCalled",
"(",
"$",
"hookName",
")",
":",
"int",
"{",
"$",
"hookName",
"=",
"$",
"this",
"->",
"sanitizeKeyName",
"(",
"$",
"hookName",
")",
";",
"if",
"(",
"!",
"$",
"hookName",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"actions",
"[",
"$",
"hookName",
"]",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"$",
"this",
"->",
"actions",
"[",
"$",
"hookName",
"]",
";",
"}"
] | Check if action hook as execute
@param string $hookName Hook Name
@return integer Count of hook action if has did action | [
"Check",
"if",
"action",
"hook",
"as",
"execute"
] | 65df2ad530e28b6d72aad5394a0872760aad44cb | https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/Hook.php#L497-L505 |
9,424 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionProjectcreate | public function actionProjectcreate()
{
$model = new Project();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['projectview', 'id' => $model->id]);
} else {
return $this->render('projectcreate', [
'model' => $model,
]);
}
} | php | public function actionProjectcreate()
{
$model = new Project();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['projectview', 'id' => $model->id]);
} else {
return $this->render('projectcreate', [
'model' => $model,
]);
}
} | [
"public",
"function",
"actionProjectcreate",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"Project",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'projectview'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'projectcreate'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] | Creates a new Projects model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed | [
"Creates",
"a",
"new",
"Projects",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L54-L65 |
9,425 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionProjectupdate | public
function actionProjectupdate()
{
$id = \Yii::$app->request->get('id');
if (!isset($id)) {
return new NotFoundHttpException('The requested project does not exist.');
}
$model = $this->findProjectmodel($id);
if (!$model instanceof Project) {
return false;
}
if ($model->load(Yii::$app->request->post()) /*&& $model->setautovalues()*/ && $model->save()) {
return $this->redirect(['projectview', 'id' => $model->id]);
} else {
return $this->render('projectupdate', [
'model' => $model,
]);
}
} | php | public
function actionProjectupdate()
{
$id = \Yii::$app->request->get('id');
if (!isset($id)) {
return new NotFoundHttpException('The requested project does not exist.');
}
$model = $this->findProjectmodel($id);
if (!$model instanceof Project) {
return false;
}
if ($model->load(Yii::$app->request->post()) /*&& $model->setautovalues()*/ && $model->save()) {
return $this->redirect(['projectview', 'id' => $model->id]);
} else {
return $this->render('projectupdate', [
'model' => $model,
]);
}
} | [
"public",
"function",
"actionProjectupdate",
"(",
")",
"{",
"$",
"id",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"return",
"new",
"NotFoundHttpException",
"(",
"'The requested project does not exist.'",
")",
";",
"}",
"$",
"model",
"=",
"$",
"this",
"->",
"findProjectmodel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"Project",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"/*&& $model->setautovalues()*/",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'projectview'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'projectupdate'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] | Updates an existing Projects model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Updates",
"an",
"existing",
"Projects",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L102-L121 |
9,426 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTaskcreate | public function actionTaskcreate($projectid = null, $parenttask = null)
{
if (!isset($projectid)) {
$projectid = $this->getRequestParam('projectid');
}
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(Url::toRoute(['taskview', 'projectid' => $projectid, 'id' => $model->id,]));
} else {
$model->projectID = $projectid;
$model->parenttask = isset($parenttask) ? $parenttask : 0;
return $this->render('taskcreate', [
'model' => $model,]);
}
} | php | public function actionTaskcreate($projectid = null, $parenttask = null)
{
if (!isset($projectid)) {
$projectid = $this->getRequestParam('projectid');
}
$model = new Task();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(Url::toRoute(['taskview', 'projectid' => $projectid, 'id' => $model->id,]));
} else {
$model->projectID = $projectid;
$model->parenttask = isset($parenttask) ? $parenttask : 0;
return $this->render('taskcreate', [
'model' => $model,]);
}
} | [
"public",
"function",
"actionTaskcreate",
"(",
"$",
"projectid",
"=",
"null",
",",
"$",
"parenttask",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"projectid",
")",
")",
"{",
"$",
"projectid",
"=",
"$",
"this",
"->",
"getRequestParam",
"(",
"'projectid'",
")",
";",
"}",
"$",
"model",
"=",
"new",
"Task",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"Url",
"::",
"toRoute",
"(",
"[",
"'taskview'",
",",
"'projectid'",
"=>",
"$",
"projectid",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"projectID",
"=",
"$",
"projectid",
";",
"$",
"model",
"->",
"parenttask",
"=",
"isset",
"(",
"$",
"parenttask",
")",
"?",
"$",
"parenttask",
":",
"0",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'taskcreate'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] | Creates a new Tasks model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed | [
"Creates",
"a",
"new",
"Tasks",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L170-L187 |
9,427 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTaskview | public function actionTaskview()
{
$id = $this->getRequestParam('id');
$model = Project::getTaskModel($id);
if (!isset($model)) {
throw new NotFoundHttpException('The Task "' . $id . '" not found.');
}
return $this->render('taskview', [
'model' => $model,
]);
} | php | public function actionTaskview()
{
$id = $this->getRequestParam('id');
$model = Project::getTaskModel($id);
if (!isset($model)) {
throw new NotFoundHttpException('The Task "' . $id . '" not found.');
}
return $this->render('taskview', [
'model' => $model,
]);
} | [
"public",
"function",
"actionTaskview",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getRequestParam",
"(",
"'id'",
")",
";",
"$",
"model",
"=",
"Project",
"::",
"getTaskModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"model",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The Task \"'",
".",
"$",
"id",
".",
"'\" not found.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'taskview'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | Displays a single Task model.
@return mixed
@throws NotFoundHttpException | [
"Displays",
"a",
"single",
"Task",
"model",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L194-L206 |
9,428 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTaskUpdate | public function actionTaskUpdate($id)
{
$model = Project::getTaskModel($id);
if (!isset($model)) {
throw new NotFoundHttpException('The Task "' . $id . '" not found.');
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['taskview', 'id' => $model->id,]);
} else {
return $this->render('taskupdate', [
'model' => $model,
]);
}
} | php | public function actionTaskUpdate($id)
{
$model = Project::getTaskModel($id);
if (!isset($model)) {
throw new NotFoundHttpException('The Task "' . $id . '" not found.');
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['taskview', 'id' => $model->id,]);
} else {
return $this->render('taskupdate', [
'model' => $model,
]);
}
} | [
"public",
"function",
"actionTaskUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"Project",
"::",
"getTaskModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"model",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The Task \"'",
".",
"$",
"id",
".",
"'\" not found.'",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'taskview'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'taskupdate'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] | Updates an existing Task model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed
@throws NotFoundHttpException | [
"Updates",
"an",
"existing",
"Task",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L215-L228 |
9,429 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTaskdelete | public function actionTaskdelete($id)
{
$task = Project::getTaskModel($id);
$projectid = $task->projectID;
$task->delete();
return $this->redirect(['tasklist', 'projectid' => $projectid]);
} | php | public function actionTaskdelete($id)
{
$task = Project::getTaskModel($id);
$projectid = $task->projectID;
$task->delete();
return $this->redirect(['tasklist', 'projectid' => $projectid]);
} | [
"public",
"function",
"actionTaskdelete",
"(",
"$",
"id",
")",
"{",
"$",
"task",
"=",
"Project",
"::",
"getTaskModel",
"(",
"$",
"id",
")",
";",
"$",
"projectid",
"=",
"$",
"task",
"->",
"projectID",
";",
"$",
"task",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'tasklist'",
",",
"'projectid'",
"=>",
"$",
"projectid",
"]",
")",
";",
"}"
] | Deletes an existing Tasks model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed | [
"Deletes",
"an",
"existing",
"Tasks",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L236-L244 |
9,430 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTasknotecreate | public function actionTasknotecreate($projectid, $taskid)
{
$model = new TaskNote();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(Url::toRoute(['tasknoteview', 'projectid' => $projectid, 'taskid' => $taskid, 'id' => $model->id,]));
} else {
$model->taskID = $taskid;
return $this->render('tasknotecreate', [
'model' => $model,]);
}
} | php | public function actionTasknotecreate($projectid, $taskid)
{
$model = new TaskNote();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(Url::toRoute(['tasknoteview', 'projectid' => $projectid, 'taskid' => $taskid, 'id' => $model->id,]));
} else {
$model->taskID = $taskid;
return $this->render('tasknotecreate', [
'model' => $model,]);
}
} | [
"public",
"function",
"actionTasknotecreate",
"(",
"$",
"projectid",
",",
"$",
"taskid",
")",
"{",
"$",
"model",
"=",
"new",
"TaskNote",
"(",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"Url",
"::",
"toRoute",
"(",
"[",
"'tasknoteview'",
",",
"'projectid'",
"=>",
"$",
"projectid",
",",
"'taskid'",
"=>",
"$",
"taskid",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
",",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"model",
"->",
"taskID",
"=",
"$",
"taskid",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'tasknotecreate'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] | Creates a new TaskNote model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed | [
"Creates",
"a",
"new",
"TaskNote",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L269-L280 |
9,431 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTasknoteview | public function actionTasknoteview($id)
{
$model = Task::getTaskNoteModel($id);
if (!isset($model)) {
throw new NotFoundHttpException('The Task "' . $id . '" not found.');
}
return $this->render('tasknoteview', [
'model' => Task::getTaskNoteModel($id), 'task' => $model,
]);
} | php | public function actionTasknoteview($id)
{
$model = Task::getTaskNoteModel($id);
if (!isset($model)) {
throw new NotFoundHttpException('The Task "' . $id . '" not found.');
}
return $this->render('tasknoteview', [
'model' => Task::getTaskNoteModel($id), 'task' => $model,
]);
} | [
"public",
"function",
"actionTasknoteview",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"Task",
"::",
"getTaskNoteModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"model",
")",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The Task \"'",
".",
"$",
"id",
".",
"'\" not found.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'tasknoteview'",
",",
"[",
"'model'",
"=>",
"Task",
"::",
"getTaskNoteModel",
"(",
"$",
"id",
")",
",",
"'task'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | Displays a single TaskComment model.
@param integer $id
@return mixed
@throws NotFoundHttpException | [
"Displays",
"a",
"single",
"TaskComment",
"model",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L288-L301 |
9,432 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTasknoteupdate | public function actionTasknoteupdate($id)
{
$model = Task::getTaskNoteModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['tasknoteview', 'id' => $model->id]);
} else {
return $this->render('tasknoteupdate', [
'model' => $model,
]);
}
} | php | public function actionTasknoteupdate($id)
{
$model = Task::getTaskNoteModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['tasknoteview', 'id' => $model->id]);
} else {
return $this->render('tasknoteupdate', [
'model' => $model,
]);
}
} | [
"public",
"function",
"actionTasknoteupdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"Task",
"::",
"getTaskNoteModel",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'tasknoteview'",
",",
"'id'",
"=>",
"$",
"model",
"->",
"id",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'tasknoteupdate'",
",",
"[",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}",
"}"
] | Updates an existing TaskComment model.
If update is successful, the browser will be redirected to the 'view' page.
@param integer $id
@return mixed | [
"Updates",
"an",
"existing",
"TaskComment",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"view",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L309-L320 |
9,433 | cubiclab/project-cube | controllers/DefaultController.php | DefaultController.actionTasknotedelete | public function actionTasknotedelete($taskid, $id)
{
Task::getTaskNoteModel($id)->delete();
return $this->redirect(['tasknotelist', 'taskid' => $taskid]);
} | php | public function actionTasknotedelete($taskid, $id)
{
Task::getTaskNoteModel($id)->delete();
return $this->redirect(['tasknotelist', 'taskid' => $taskid]);
} | [
"public",
"function",
"actionTasknotedelete",
"(",
"$",
"taskid",
",",
"$",
"id",
")",
"{",
"Task",
"::",
"getTaskNoteModel",
"(",
"$",
"id",
")",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'tasknotelist'",
",",
"'taskid'",
"=>",
"$",
"taskid",
"]",
")",
";",
"}"
] | Deletes an existing TaskComment model.
If deletion is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed | [
"Deletes",
"an",
"existing",
"TaskComment",
"model",
".",
"If",
"deletion",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] | 3a2a425d95ed76b999136c8a52bae9f3154b800a | https://github.com/cubiclab/project-cube/blob/3a2a425d95ed76b999136c8a52bae9f3154b800a/controllers/DefaultController.php#L328-L333 |
9,434 | BuildrPHP/Test-Tools | src/Traits/ReflectionUtilities.php | ReflectionUtilities.getPropertyValue | public function getPropertyValue($className, $propertyName, $concreteClass = NULL, $options = []) {
$callConstructor = (isset($options['callConstructor'])) ? (bool) $options['callConstructor'] : FALSE;
$reflector = new ReflectionClass($className);
//This is a default property
if($concreteClass === NULL && $callConstructor === FALSE) {
$properties = $reflector->getDefaultProperties();
return (isset($properties[$propertyName])) ? $properties[$propertyName] : NULL;
}
//Return NULL if this class not has the given property
if(!$reflector->hasProperty($propertyName)) {
return NULL;
}
//Get reflector for property and set it accessible
$propertyReflector = $reflector->getProperty($propertyName);
$propertyReflector->setAccessible(TRUE);
//If we give a concrete class returns the value from this class
if($concreteClass !== NULL) {
return $propertyReflector->getValue($concreteClass);
}
//Needs to call the class constructor
if($callConstructor === TRUE) {
$constructorParams = (isset($options['constructorParams'])) ? (array) $options['constructorParams'] : [];
return $propertyReflector->getValue($reflector->newInstanceArgs($constructorParams));
}
//This should never happen
//@codeCoverageIgnoreStart
return NULL;
//@codeCoverageIgnoreEnd
} | php | public function getPropertyValue($className, $propertyName, $concreteClass = NULL, $options = []) {
$callConstructor = (isset($options['callConstructor'])) ? (bool) $options['callConstructor'] : FALSE;
$reflector = new ReflectionClass($className);
//This is a default property
if($concreteClass === NULL && $callConstructor === FALSE) {
$properties = $reflector->getDefaultProperties();
return (isset($properties[$propertyName])) ? $properties[$propertyName] : NULL;
}
//Return NULL if this class not has the given property
if(!$reflector->hasProperty($propertyName)) {
return NULL;
}
//Get reflector for property and set it accessible
$propertyReflector = $reflector->getProperty($propertyName);
$propertyReflector->setAccessible(TRUE);
//If we give a concrete class returns the value from this class
if($concreteClass !== NULL) {
return $propertyReflector->getValue($concreteClass);
}
//Needs to call the class constructor
if($callConstructor === TRUE) {
$constructorParams = (isset($options['constructorParams'])) ? (array) $options['constructorParams'] : [];
return $propertyReflector->getValue($reflector->newInstanceArgs($constructorParams));
}
//This should never happen
//@codeCoverageIgnoreStart
return NULL;
//@codeCoverageIgnoreEnd
} | [
"public",
"function",
"getPropertyValue",
"(",
"$",
"className",
",",
"$",
"propertyName",
",",
"$",
"concreteClass",
"=",
"NULL",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"callConstructor",
"=",
"(",
"isset",
"(",
"$",
"options",
"[",
"'callConstructor'",
"]",
")",
")",
"?",
"(",
"bool",
")",
"$",
"options",
"[",
"'callConstructor'",
"]",
":",
"FALSE",
";",
"$",
"reflector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"//This is a default property",
"if",
"(",
"$",
"concreteClass",
"===",
"NULL",
"&&",
"$",
"callConstructor",
"===",
"FALSE",
")",
"{",
"$",
"properties",
"=",
"$",
"reflector",
"->",
"getDefaultProperties",
"(",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
")",
")",
"?",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
":",
"NULL",
";",
"}",
"//Return NULL if this class not has the given property",
"if",
"(",
"!",
"$",
"reflector",
"->",
"hasProperty",
"(",
"$",
"propertyName",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"//Get reflector for property and set it accessible",
"$",
"propertyReflector",
"=",
"$",
"reflector",
"->",
"getProperty",
"(",
"$",
"propertyName",
")",
";",
"$",
"propertyReflector",
"->",
"setAccessible",
"(",
"TRUE",
")",
";",
"//If we give a concrete class returns the value from this class",
"if",
"(",
"$",
"concreteClass",
"!==",
"NULL",
")",
"{",
"return",
"$",
"propertyReflector",
"->",
"getValue",
"(",
"$",
"concreteClass",
")",
";",
"}",
"//Needs to call the class constructor",
"if",
"(",
"$",
"callConstructor",
"===",
"TRUE",
")",
"{",
"$",
"constructorParams",
"=",
"(",
"isset",
"(",
"$",
"options",
"[",
"'constructorParams'",
"]",
")",
")",
"?",
"(",
"array",
")",
"$",
"options",
"[",
"'constructorParams'",
"]",
":",
"[",
"]",
";",
"return",
"$",
"propertyReflector",
"->",
"getValue",
"(",
"$",
"reflector",
"->",
"newInstanceArgs",
"(",
"$",
"constructorParams",
")",
")",
";",
"}",
"//This should never happen",
"//@codeCoverageIgnoreStart",
"return",
"NULL",
";",
"//@codeCoverageIgnoreEnd",
"}"
] | Read a property value from a given class or concrete object. This function can handle automatic creation
of new instances of the given class.
If no concrete object provided and the 'callConstructor' option is FALSE reads the property default value
from the class.
If a concrete object is provided returns the property value from the given concrete object.
If the 'callConstructor' is TRUE and concrete object is not provided this method try to instantiate a
new object from thi given class using the 'constructorParams' option.
options:
'callConstructor' => bool
'constructorParams' => array (key is variable name, value is the value of the variable)
@param string $className The FQCN
@param string $propertyName The property name
@param object|NULL $concreteClass Optionally concrete class
@param array $options Options defined as an array
@return NULL|mixed | [
"Read",
"a",
"property",
"value",
"from",
"a",
"given",
"class",
"or",
"concrete",
"object",
".",
"This",
"function",
"can",
"handle",
"automatic",
"creation",
"of",
"new",
"instances",
"of",
"the",
"given",
"class",
"."
] | 55978eb4447d6f063cc9b85501349636ca3fa67a | https://github.com/BuildrPHP/Test-Tools/blob/55978eb4447d6f063cc9b85501349636ca3fa67a/src/Traits/ReflectionUtilities.php#L45-L81 |
9,435 | BuildrPHP/Test-Tools | src/Traits/ReflectionUtilities.php | ReflectionUtilities.getStaticPropertyValue | public function getStaticPropertyValue($object, $propertyName) {
$className = $object;
if(is_object($className)) {
$className = get_class($object);
}
$reflector = new ReflectionClass($className);
$properties = $reflector->getStaticProperties();
return (isset($properties[$propertyName])) ? $properties[$propertyName] : NULL;
} | php | public function getStaticPropertyValue($object, $propertyName) {
$className = $object;
if(is_object($className)) {
$className = get_class($object);
}
$reflector = new ReflectionClass($className);
$properties = $reflector->getStaticProperties();
return (isset($properties[$propertyName])) ? $properties[$propertyName] : NULL;
} | [
"public",
"function",
"getStaticPropertyValue",
"(",
"$",
"object",
",",
"$",
"propertyName",
")",
"{",
"$",
"className",
"=",
"$",
"object",
";",
"if",
"(",
"is_object",
"(",
"$",
"className",
")",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"}",
"$",
"reflector",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"properties",
"=",
"$",
"reflector",
"->",
"getStaticProperties",
"(",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
")",
")",
"?",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
":",
"NULL",
";",
"}"
] | Returns a static property from the given class. You can pass this function an object or
a FQCN as string.
@param object|string $object A concrete class or a FQCN
@param string $propertyName The property name
@return NULL|mixed | [
"Returns",
"a",
"static",
"property",
"from",
"the",
"given",
"class",
".",
"You",
"can",
"pass",
"this",
"function",
"an",
"object",
"or",
"a",
"FQCN",
"as",
"string",
"."
] | 55978eb4447d6f063cc9b85501349636ca3fa67a | https://github.com/BuildrPHP/Test-Tools/blob/55978eb4447d6f063cc9b85501349636ca3fa67a/src/Traits/ReflectionUtilities.php#L92-L103 |
9,436 | BuildrPHP/Test-Tools | src/Traits/ReflectionUtilities.php | ReflectionUtilities.setProperty | public function setProperty($object, $property, $value) {
$objectReflector = new ReflectionObject($object);
if(!$objectReflector->hasProperty($property)) {
throw new Exception('Property cannot be set! This property not exist inside the given object!');
}
$propertyReflector = $objectReflector->getProperty($property);
$propertyReflector->setAccessible(TRUE);
$propertyReflector->setValue($object, $value);
return TRUE;
} | php | public function setProperty($object, $property, $value) {
$objectReflector = new ReflectionObject($object);
if(!$objectReflector->hasProperty($property)) {
throw new Exception('Property cannot be set! This property not exist inside the given object!');
}
$propertyReflector = $objectReflector->getProperty($property);
$propertyReflector->setAccessible(TRUE);
$propertyReflector->setValue($object, $value);
return TRUE;
} | [
"public",
"function",
"setProperty",
"(",
"$",
"object",
",",
"$",
"property",
",",
"$",
"value",
")",
"{",
"$",
"objectReflector",
"=",
"new",
"ReflectionObject",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"$",
"objectReflector",
"->",
"hasProperty",
"(",
"$",
"property",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Property cannot be set! This property not exist inside the given object!'",
")",
";",
"}",
"$",
"propertyReflector",
"=",
"$",
"objectReflector",
"->",
"getProperty",
"(",
"$",
"property",
")",
";",
"$",
"propertyReflector",
"->",
"setAccessible",
"(",
"TRUE",
")",
";",
"$",
"propertyReflector",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"value",
")",
";",
"return",
"TRUE",
";",
"}"
] | Set a property value on the given object. If the property is not found in the given object
an Exception will be thrown.
@param object $object A concrete object
@param string $property The property name
@param mixed $value The property new value
@return bool
@throws \BuildR\Foundation\Exception\Exception | [
"Set",
"a",
"property",
"value",
"on",
"the",
"given",
"object",
".",
"If",
"the",
"property",
"is",
"not",
"found",
"in",
"the",
"given",
"object",
"an",
"Exception",
"will",
"be",
"thrown",
"."
] | 55978eb4447d6f063cc9b85501349636ca3fa67a | https://github.com/BuildrPHP/Test-Tools/blob/55978eb4447d6f063cc9b85501349636ca3fa67a/src/Traits/ReflectionUtilities.php#L117-L129 |
9,437 | codebobbly/dvoconnector | Classes/Controller/FunctionaryStaticController.php | FunctionaryStaticController.singleFunctionaryAction | public function singleFunctionaryAction()
{
$this->checkStaticTemplateIsIncluded();
$this->checkSettings();
$this->slotExtendedAssignMultiple([
self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID],
self::VIEW_VARIABLE_FUNCTIONARY_ID => $this->settings[self::SETTINGS_FUNCTIONARY_ID]
], __CLASS__, __FUNCTION__);
return $this->view->render();
} | php | public function singleFunctionaryAction()
{
$this->checkStaticTemplateIsIncluded();
$this->checkSettings();
$this->slotExtendedAssignMultiple([
self::VIEW_VARIABLE_ASSOCIATION_ID => $this->settings[self::SETTINGS_ASSOCIATION_ID],
self::VIEW_VARIABLE_FUNCTIONARY_ID => $this->settings[self::SETTINGS_FUNCTIONARY_ID]
], __CLASS__, __FUNCTION__);
return $this->view->render();
} | [
"public",
"function",
"singleFunctionaryAction",
"(",
")",
"{",
"$",
"this",
"->",
"checkStaticTemplateIsIncluded",
"(",
")",
";",
"$",
"this",
"->",
"checkSettings",
"(",
")",
";",
"$",
"this",
"->",
"slotExtendedAssignMultiple",
"(",
"[",
"self",
"::",
"VIEW_VARIABLE_ASSOCIATION_ID",
"=>",
"$",
"this",
"->",
"settings",
"[",
"self",
"::",
"SETTINGS_ASSOCIATION_ID",
"]",
",",
"self",
"::",
"VIEW_VARIABLE_FUNCTIONARY_ID",
"=>",
"$",
"this",
"->",
"settings",
"[",
"self",
"::",
"SETTINGS_FUNCTIONARY_ID",
"]",
"]",
",",
"__CLASS__",
",",
"__FUNCTION__",
")",
";",
"return",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
")",
";",
"}"
] | single functionary action.
@return string | [
"single",
"functionary",
"action",
"."
] | 9b63790d2fc9fd21bf415b4a5757678895b73bbc | https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Controller/FunctionaryStaticController.php#L30-L41 |
9,438 | pinnackl/Sophwork | dist/Sophwork/app/app/SophworkApp.php | SophworkApp.get | public function get($route, $toController, $alias = null)
{
$route = [
'route' => $route,
'toController' => $toController,
'alias' => $alias,
'isDynamic' => preg_match("/{([^{}?&]+)}/", $route),
];
if (!is_null($alias))
$this->routes['GET'][$alias] = $route;
else
$this->routes['GET'][] = $route;
return new RouteMiddleware($this->appDispatcher, $route['route']);
} | php | public function get($route, $toController, $alias = null)
{
$route = [
'route' => $route,
'toController' => $toController,
'alias' => $alias,
'isDynamic' => preg_match("/{([^{}?&]+)}/", $route),
];
if (!is_null($alias))
$this->routes['GET'][$alias] = $route;
else
$this->routes['GET'][] = $route;
return new RouteMiddleware($this->appDispatcher, $route['route']);
} | [
"public",
"function",
"get",
"(",
"$",
"route",
",",
"$",
"toController",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"route",
"=",
"[",
"'route'",
"=>",
"$",
"route",
",",
"'toController'",
"=>",
"$",
"toController",
",",
"'alias'",
"=>",
"$",
"alias",
",",
"'isDynamic'",
"=>",
"preg_match",
"(",
"\"/{([^{}?&]+)}/\"",
",",
"$",
"route",
")",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"alias",
")",
")",
"$",
"this",
"->",
"routes",
"[",
"'GET'",
"]",
"[",
"$",
"alias",
"]",
"=",
"$",
"route",
";",
"else",
"$",
"this",
"->",
"routes",
"[",
"'GET'",
"]",
"[",
"]",
"=",
"$",
"route",
";",
"return",
"new",
"RouteMiddleware",
"(",
"$",
"this",
"->",
"appDispatcher",
",",
"$",
"route",
"[",
"'route'",
"]",
")",
";",
"}"
] | GET route method
@param [type] $route [description]
@param [type] $toController [description] | [
"GET",
"route",
"method"
] | 53f55905fd06ccb87669c2824152a2a642902f78 | https://github.com/pinnackl/Sophwork/blob/53f55905fd06ccb87669c2824152a2a642902f78/dist/Sophwork/app/app/SophworkApp.php#L96-L109 |
9,439 | pinnackl/Sophwork | dist/Sophwork/app/app/SophworkApp.php | SophworkApp.post | public function post($route, $toController, $alias = null)
{
$route = [
'route' => $route,
'toController' => $toController,
'alias' => $alias,
'isDynamic' => preg_match("/{([^{}?&]+)}/", $route),
];
$this->routes['POST'][] = $route;
} | php | public function post($route, $toController, $alias = null)
{
$route = [
'route' => $route,
'toController' => $toController,
'alias' => $alias,
'isDynamic' => preg_match("/{([^{}?&]+)}/", $route),
];
$this->routes['POST'][] = $route;
} | [
"public",
"function",
"post",
"(",
"$",
"route",
",",
"$",
"toController",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"$",
"route",
"=",
"[",
"'route'",
"=>",
"$",
"route",
",",
"'toController'",
"=>",
"$",
"toController",
",",
"'alias'",
"=>",
"$",
"alias",
",",
"'isDynamic'",
"=>",
"preg_match",
"(",
"\"/{([^{}?&]+)}/\"",
",",
"$",
"route",
")",
",",
"]",
";",
"$",
"this",
"->",
"routes",
"[",
"'POST'",
"]",
"[",
"]",
"=",
"$",
"route",
";",
"}"
] | POST route method
@param [type] $route [description]
@param [type] $toController [description] | [
"POST",
"route",
"method"
] | 53f55905fd06ccb87669c2824152a2a642902f78 | https://github.com/pinnackl/Sophwork/blob/53f55905fd06ccb87669c2824152a2a642902f78/dist/Sophwork/app/app/SophworkApp.php#L116-L125 |
9,440 | damien-carcel/UserBundle | src/EventSubscriber/MailerSubscriber.php | MailerSubscriber.getUserEmail | public function getUserEmail(GenericEvent $event)
{
$user = $event->getSubject();
if (!$user instanceof UserInterface) {
throw new \InvalidArgumentException('MailerSubscriber event is expected to contain an instance of User');
}
$this->mailAddress = $user->getEmail();
$this->username = $user->getUsername();
} | php | public function getUserEmail(GenericEvent $event)
{
$user = $event->getSubject();
if (!$user instanceof UserInterface) {
throw new \InvalidArgumentException('MailerSubscriber event is expected to contain an instance of User');
}
$this->mailAddress = $user->getEmail();
$this->username = $user->getUsername();
} | [
"public",
"function",
"getUserEmail",
"(",
"GenericEvent",
"$",
"event",
")",
"{",
"$",
"user",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
";",
"if",
"(",
"!",
"$",
"user",
"instanceof",
"UserInterface",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'MailerSubscriber event is expected to contain an instance of User'",
")",
";",
"}",
"$",
"this",
"->",
"mailAddress",
"=",
"$",
"user",
"->",
"getEmail",
"(",
")",
";",
"$",
"this",
"->",
"username",
"=",
"$",
"user",
"->",
"getUsername",
"(",
")",
";",
"}"
] | Gets the username and mail address of the user to be removed.
@param GenericEvent $event | [
"Gets",
"the",
"username",
"and",
"mail",
"address",
"of",
"the",
"user",
"to",
"be",
"removed",
"."
] | 22989aa3580184bb3317520281372415cd80ab4d | https://github.com/damien-carcel/UserBundle/blob/22989aa3580184bb3317520281372415cd80ab4d/src/EventSubscriber/MailerSubscriber.php#L60-L70 |
9,441 | coviu/coviu-php-sdk | src/Request.php | Request.request | public static function request($endpoint)
{
return (new Request(NULL, NULL, NULL))->host($endpoint)->get()->path('')->accept('application/json');
} | php | public static function request($endpoint)
{
return (new Request(NULL, NULL, NULL))->host($endpoint)->get()->path('')->accept('application/json');
} | [
"public",
"static",
"function",
"request",
"(",
"$",
"endpoint",
")",
"{",
"return",
"(",
"new",
"Request",
"(",
"NULL",
",",
"NULL",
",",
"NULL",
")",
")",
"->",
"host",
"(",
"$",
"endpoint",
")",
"->",
"get",
"(",
")",
"->",
"path",
"(",
"''",
")",
"->",
"accept",
"(",
"'application/json'",
")",
";",
"}"
] | Construct an new Request by providing an endpoint. | [
"Construct",
"an",
"new",
"Request",
"by",
"providing",
"an",
"endpoint",
"."
] | 606c35a36fa0500e27c4c4ca6b037da0d3d0cb3f | https://github.com/coviu/coviu-php-sdk/blob/606c35a36fa0500e27c4c4ca6b037da0d3d0cb3f/src/Request.php#L132-L135 |
9,442 | coviu/coviu-php-sdk | src/Request.php | Request.render | public function render()
{
if ($this->isSentinel()){
return [];
}
$result = $this->tail->render();
$result[$this->key] = $this->value;
return $result;
} | php | public function render()
{
if ($this->isSentinel()){
return [];
}
$result = $this->tail->render();
$result[$this->key] = $this->value;
return $result;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSentinel",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"tail",
"->",
"render",
"(",
")",
";",
"$",
"result",
"[",
"$",
"this",
"->",
"key",
"]",
"=",
"$",
"this",
"->",
"value",
";",
"return",
"$",
"result",
";",
"}"
] | Traverse the Request, calculating the final value for each request parameter. | [
"Traverse",
"the",
"Request",
"calculating",
"the",
"final",
"value",
"for",
"each",
"request",
"parameter",
"."
] | 606c35a36fa0500e27c4c4ca6b037da0d3d0cb3f | https://github.com/coviu/coviu-php-sdk/blob/606c35a36fa0500e27c4c4ca6b037da0d3d0cb3f/src/Request.php#L247-L255 |
9,443 | kherge-abandoned/Wisdom | src/lib/KevinGH/Wisdom/Loader/Loader.php | Loader.doReplace | public function doReplace($data)
{
$data = preg_replace_callback(
'/#([^\s\r#]+)#/',
function ($matches) {
if (defined($matches[1])) {
return constant($matches[1]);
}
return $matches[0];
},
$data
);
if (isset($this->values)) {
$values = $this->values;
$data = preg_replace_callback(
'/%([^\s\r%]+)%/',
function ($matches) use ($values) {
if (isset($values[$matches[1]])) {
return $values[$matches[1]];
}
return $matches[0];
},
$data
);
}
return $data;
} | php | public function doReplace($data)
{
$data = preg_replace_callback(
'/#([^\s\r#]+)#/',
function ($matches) {
if (defined($matches[1])) {
return constant($matches[1]);
}
return $matches[0];
},
$data
);
if (isset($this->values)) {
$values = $this->values;
$data = preg_replace_callback(
'/%([^\s\r%]+)%/',
function ($matches) use ($values) {
if (isset($values[$matches[1]])) {
return $values[$matches[1]];
}
return $matches[0];
},
$data
);
}
return $data;
} | [
"public",
"function",
"doReplace",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"preg_replace_callback",
"(",
"'/#([^\\s\\r#]+)#/'",
",",
"function",
"(",
"$",
"matches",
")",
"{",
"if",
"(",
"defined",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"constant",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"return",
"$",
"matches",
"[",
"0",
"]",
";",
"}",
",",
"$",
"data",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
")",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"values",
";",
"$",
"data",
"=",
"preg_replace_callback",
"(",
"'/%([^\\s\\r%]+)%/'",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
")",
")",
"{",
"return",
"$",
"values",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"}",
"return",
"$",
"matches",
"[",
"0",
"]",
";",
"}",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Performs the replacement on the raw data.
@param string $data The raw data.
@return string The replaced data. | [
"Performs",
"the",
"replacement",
"on",
"the",
"raw",
"data",
"."
] | eb5b1dadde0729f2ccd1b241c2cecebc778e22f3 | https://github.com/kherge-abandoned/Wisdom/blob/eb5b1dadde0729f2ccd1b241c2cecebc778e22f3/src/lib/KevinGH/Wisdom/Loader/Loader.php#L45-L76 |
9,444 | mizmoz/config | src/Environment.php | Environment.create | public static function create(
string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []
): EnvironmentInterface
{
if (! $allowed) {
$allowed = [
self::ENV_PRODUCTION,
self::ENV_STAGING,
self::ENV_TESTING,
self::ENV_DEVELOPMENT,
];
}
$projectRoot = realpath($projectRoot);
$filename = $projectRoot . '/.environment';
if (! $projectRoot || ! file_exists($filename)) {
return new static($default, $projectRoot);
}
// get the environment name
$name = file_get_contents($filename);
if (! in_array($name, $allowed)) {
throw new UnknownEnvironmentException(
'Unknown environment "' . $name . '". Either add to the allowed list or provide one of: '
. join(', ', $allowed)
);
}
return new static($name, $projectRoot);
} | php | public static function create(
string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []
): EnvironmentInterface
{
if (! $allowed) {
$allowed = [
self::ENV_PRODUCTION,
self::ENV_STAGING,
self::ENV_TESTING,
self::ENV_DEVELOPMENT,
];
}
$projectRoot = realpath($projectRoot);
$filename = $projectRoot . '/.environment';
if (! $projectRoot || ! file_exists($filename)) {
return new static($default, $projectRoot);
}
// get the environment name
$name = file_get_contents($filename);
if (! in_array($name, $allowed)) {
throw new UnknownEnvironmentException(
'Unknown environment "' . $name . '". Either add to the allowed list or provide one of: '
. join(', ', $allowed)
);
}
return new static($name, $projectRoot);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"projectRoot",
",",
"$",
"default",
"=",
"self",
"::",
"ENV_PRODUCTION",
",",
"array",
"$",
"allowed",
"=",
"[",
"]",
")",
":",
"EnvironmentInterface",
"{",
"if",
"(",
"!",
"$",
"allowed",
")",
"{",
"$",
"allowed",
"=",
"[",
"self",
"::",
"ENV_PRODUCTION",
",",
"self",
"::",
"ENV_STAGING",
",",
"self",
"::",
"ENV_TESTING",
",",
"self",
"::",
"ENV_DEVELOPMENT",
",",
"]",
";",
"}",
"$",
"projectRoot",
"=",
"realpath",
"(",
"$",
"projectRoot",
")",
";",
"$",
"filename",
"=",
"$",
"projectRoot",
".",
"'/.environment'",
";",
"if",
"(",
"!",
"$",
"projectRoot",
"||",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"default",
",",
"$",
"projectRoot",
")",
";",
"}",
"// get the environment name",
"$",
"name",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"allowed",
")",
")",
"{",
"throw",
"new",
"UnknownEnvironmentException",
"(",
"'Unknown environment \"'",
".",
"$",
"name",
".",
"'\". Either add to the allowed list or provide one of: '",
".",
"join",
"(",
"', '",
",",
"$",
"allowed",
")",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"name",
",",
"$",
"projectRoot",
")",
";",
"}"
] | Create the environment using the default params and by searching the .environment file.
@param string $projectRoot
@param string $default
@param array $allowed
@return EnvironmentInterface | [
"Create",
"the",
"environment",
"using",
"the",
"default",
"params",
"and",
"by",
"searching",
"the",
".",
"environment",
"file",
"."
] | 777f66de31603fc65a88416a7b502c1a2fe6d62b | https://github.com/mizmoz/config/blob/777f66de31603fc65a88416a7b502c1a2fe6d62b/src/Environment.php#L47-L78 |
9,445 | mizmoz/config | src/Environment.php | Environment.get | public static function get(string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []): string
{
return (static::create($projectRoot, $default, $allowed))->name();
} | php | public static function get(string $projectRoot, $default = self::ENV_PRODUCTION, array $allowed = []): string
{
return (static::create($projectRoot, $default, $allowed))->name();
} | [
"public",
"static",
"function",
"get",
"(",
"string",
"$",
"projectRoot",
",",
"$",
"default",
"=",
"self",
"::",
"ENV_PRODUCTION",
",",
"array",
"$",
"allowed",
"=",
"[",
"]",
")",
":",
"string",
"{",
"return",
"(",
"static",
"::",
"create",
"(",
"$",
"projectRoot",
",",
"$",
"default",
",",
"$",
"allowed",
")",
")",
"->",
"name",
"(",
")",
";",
"}"
] | Get the environment
@param string $projectRoot
@param string $default
@param array $allowed
@return string | [
"Get",
"the",
"environment"
] | 777f66de31603fc65a88416a7b502c1a2fe6d62b | https://github.com/mizmoz/config/blob/777f66de31603fc65a88416a7b502c1a2fe6d62b/src/Environment.php#L88-L91 |
9,446 | kodi-app/kodi-security | src/KodiSecurity/Model/Authentication/AuthenticationInterface.php | AuthenticationInterface.hashPassword | protected function hashPassword($pw, $salt=false) {
// Salt generálás
if (!$salt) {
$salt = bin2hex(openssl_random_pseudo_bytes(self::HASH_SALT_LENGTH));
}
$hash = $this->generatePbkdf2(self::HASH_ALGORITHM, $pw, $salt, self::HASH_COST, 32);
$r = new \stdClass();
$r->output = $salt.$hash;
$r->salt = $salt;
$r->hash = $hash;
return $r;
} | php | protected function hashPassword($pw, $salt=false) {
// Salt generálás
if (!$salt) {
$salt = bin2hex(openssl_random_pseudo_bytes(self::HASH_SALT_LENGTH));
}
$hash = $this->generatePbkdf2(self::HASH_ALGORITHM, $pw, $salt, self::HASH_COST, 32);
$r = new \stdClass();
$r->output = $salt.$hash;
$r->salt = $salt;
$r->hash = $hash;
return $r;
} | [
"protected",
"function",
"hashPassword",
"(",
"$",
"pw",
",",
"$",
"salt",
"=",
"false",
")",
"{",
"// Salt generálás",
"if",
"(",
"!",
"$",
"salt",
")",
"{",
"$",
"salt",
"=",
"bin2hex",
"(",
"openssl_random_pseudo_bytes",
"(",
"self",
"::",
"HASH_SALT_LENGTH",
")",
")",
";",
"}",
"$",
"hash",
"=",
"$",
"this",
"->",
"generatePbkdf2",
"(",
"self",
"::",
"HASH_ALGORITHM",
",",
"$",
"pw",
",",
"$",
"salt",
",",
"self",
"::",
"HASH_COST",
",",
"32",
")",
";",
"$",
"r",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"r",
"->",
"output",
"=",
"$",
"salt",
".",
"$",
"hash",
";",
"$",
"r",
"->",
"salt",
"=",
"$",
"salt",
";",
"$",
"r",
"->",
"hash",
"=",
"$",
"hash",
";",
"return",
"$",
"r",
";",
"}"
] | Hash password.
@param string $pw
@param string|bool $salt
@return \stdClass | [
"Hash",
"password",
"."
] | d4c577383c83bf948a84921ee6cce5ed0d651522 | https://github.com/kodi-app/kodi-security/blob/d4c577383c83bf948a84921ee6cce5ed0d651522/src/KodiSecurity/Model/Authentication/AuthenticationInterface.php#L73-L84 |
9,447 | kodi-app/kodi-security | src/KodiSecurity/Model/Authentication/AuthenticationInterface.php | AuthenticationInterface.generatePbkdf2 | protected function generatePbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false)
{
$algorithm = strtolower($algorithm);
if(!in_array($algorithm, hash_algos(), true))
trigger_error('PBKDF2 ERROR: Invalid hash algorithm.', E_USER_ERROR);
if($count <= 0 || $key_length <= 0)
trigger_error('PBKDF2 ERROR: Invalid parameters.', E_USER_ERROR);
if (function_exists("hash_pbkdf2")) {
// The output length is in NIBBLES (4-bits) if $raw_output is false!
if (!$raw_output) {
$key_length = $key_length * 2;
}
return hash_pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output);
}
$hash_length = strlen(hash($algorithm, "", true));
$block_count = ceil($key_length / $hash_length);
$output = "";
for($i = 1; $i <= $block_count; $i++) {
// $i encoded as 4 bytes, big endian.
$last = $salt . pack("N", $i);
// first iteration
$last = $xorsum = hash_hmac($algorithm, $last, $password, true);
// perform the other $count - 1 iterations
for ($j = 1; $j < $count; $j++) {
$xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true));
}
$output .= $xorsum;
}
if($raw_output)
return substr($output, 0, $key_length);
else
return bin2hex(substr($output, 0, $key_length));
} | php | protected function generatePbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false)
{
$algorithm = strtolower($algorithm);
if(!in_array($algorithm, hash_algos(), true))
trigger_error('PBKDF2 ERROR: Invalid hash algorithm.', E_USER_ERROR);
if($count <= 0 || $key_length <= 0)
trigger_error('PBKDF2 ERROR: Invalid parameters.', E_USER_ERROR);
if (function_exists("hash_pbkdf2")) {
// The output length is in NIBBLES (4-bits) if $raw_output is false!
if (!$raw_output) {
$key_length = $key_length * 2;
}
return hash_pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output);
}
$hash_length = strlen(hash($algorithm, "", true));
$block_count = ceil($key_length / $hash_length);
$output = "";
for($i = 1; $i <= $block_count; $i++) {
// $i encoded as 4 bytes, big endian.
$last = $salt . pack("N", $i);
// first iteration
$last = $xorsum = hash_hmac($algorithm, $last, $password, true);
// perform the other $count - 1 iterations
for ($j = 1; $j < $count; $j++) {
$xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true));
}
$output .= $xorsum;
}
if($raw_output)
return substr($output, 0, $key_length);
else
return bin2hex(substr($output, 0, $key_length));
} | [
"protected",
"function",
"generatePbkdf2",
"(",
"$",
"algorithm",
",",
"$",
"password",
",",
"$",
"salt",
",",
"$",
"count",
",",
"$",
"key_length",
",",
"$",
"raw_output",
"=",
"false",
")",
"{",
"$",
"algorithm",
"=",
"strtolower",
"(",
"$",
"algorithm",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"algorithm",
",",
"hash_algos",
"(",
")",
",",
"true",
")",
")",
"trigger_error",
"(",
"'PBKDF2 ERROR: Invalid hash algorithm.'",
",",
"E_USER_ERROR",
")",
";",
"if",
"(",
"$",
"count",
"<=",
"0",
"||",
"$",
"key_length",
"<=",
"0",
")",
"trigger_error",
"(",
"'PBKDF2 ERROR: Invalid parameters.'",
",",
"E_USER_ERROR",
")",
";",
"if",
"(",
"function_exists",
"(",
"\"hash_pbkdf2\"",
")",
")",
"{",
"// The output length is in NIBBLES (4-bits) if $raw_output is false!",
"if",
"(",
"!",
"$",
"raw_output",
")",
"{",
"$",
"key_length",
"=",
"$",
"key_length",
"*",
"2",
";",
"}",
"return",
"hash_pbkdf2",
"(",
"$",
"algorithm",
",",
"$",
"password",
",",
"$",
"salt",
",",
"$",
"count",
",",
"$",
"key_length",
",",
"$",
"raw_output",
")",
";",
"}",
"$",
"hash_length",
"=",
"strlen",
"(",
"hash",
"(",
"$",
"algorithm",
",",
"\"\"",
",",
"true",
")",
")",
";",
"$",
"block_count",
"=",
"ceil",
"(",
"$",
"key_length",
"/",
"$",
"hash_length",
")",
";",
"$",
"output",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"block_count",
";",
"$",
"i",
"++",
")",
"{",
"// $i encoded as 4 bytes, big endian.",
"$",
"last",
"=",
"$",
"salt",
".",
"pack",
"(",
"\"N\"",
",",
"$",
"i",
")",
";",
"// first iteration",
"$",
"last",
"=",
"$",
"xorsum",
"=",
"hash_hmac",
"(",
"$",
"algorithm",
",",
"$",
"last",
",",
"$",
"password",
",",
"true",
")",
";",
"// perform the other $count - 1 iterations",
"for",
"(",
"$",
"j",
"=",
"1",
";",
"$",
"j",
"<",
"$",
"count",
";",
"$",
"j",
"++",
")",
"{",
"$",
"xorsum",
"^=",
"(",
"$",
"last",
"=",
"hash_hmac",
"(",
"$",
"algorithm",
",",
"$",
"last",
",",
"$",
"password",
",",
"true",
")",
")",
";",
"}",
"$",
"output",
".=",
"$",
"xorsum",
";",
"}",
"if",
"(",
"$",
"raw_output",
")",
"return",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"$",
"key_length",
")",
";",
"else",
"return",
"bin2hex",
"(",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"$",
"key_length",
")",
")",
";",
"}"
] | Checks password correctness based on PBKDF2
@param string $algorithm Hashing algorithm
@param string $password The raw password
@param string $salt Salt
@param int $count Number of hash
@param int $key_length Key length
@param bool $raw_output
@return bool|mixed|string | [
"Checks",
"password",
"correctness",
"based",
"on",
"PBKDF2"
] | d4c577383c83bf948a84921ee6cce5ed0d651522 | https://github.com/kodi-app/kodi-security/blob/d4c577383c83bf948a84921ee6cce5ed0d651522/src/KodiSecurity/Model/Authentication/AuthenticationInterface.php#L97-L133 |
9,448 | easy-system/es-http | src/AbstractStream.php | AbstractStream.make | public static function make($resource = '', $mode = 'w+b')
{
switch (gettype($resource)) {
case 'resource':
return (new static(false))->setResource($resource, $mode);
case 'string':
$stream = fopen('php://temp', $mode);
if ($resource !== '') {
fwrite($stream, $resource);
fseek($stream, 0);
}
return (new static(false))->setResource($stream, $mode);
case 'object':
if ($resource instanceof self) {
return $resource;
} elseif (method_exists($resource, '__toString')) {
$resource = (string) $resource;
return static::make($resource, $mode);
}
default:
throw new InvalidArgumentException(sprintf(
'Invalid resource "%s" provided.',
is_object($resource) ? get_class($resource)
: gettype($resource)
));
}
} | php | public static function make($resource = '', $mode = 'w+b')
{
switch (gettype($resource)) {
case 'resource':
return (new static(false))->setResource($resource, $mode);
case 'string':
$stream = fopen('php://temp', $mode);
if ($resource !== '') {
fwrite($stream, $resource);
fseek($stream, 0);
}
return (new static(false))->setResource($stream, $mode);
case 'object':
if ($resource instanceof self) {
return $resource;
} elseif (method_exists($resource, '__toString')) {
$resource = (string) $resource;
return static::make($resource, $mode);
}
default:
throw new InvalidArgumentException(sprintf(
'Invalid resource "%s" provided.',
is_object($resource) ? get_class($resource)
: gettype($resource)
));
}
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"resource",
"=",
"''",
",",
"$",
"mode",
"=",
"'w+b'",
")",
"{",
"switch",
"(",
"gettype",
"(",
"$",
"resource",
")",
")",
"{",
"case",
"'resource'",
":",
"return",
"(",
"new",
"static",
"(",
"false",
")",
")",
"->",
"setResource",
"(",
"$",
"resource",
",",
"$",
"mode",
")",
";",
"case",
"'string'",
":",
"$",
"stream",
"=",
"fopen",
"(",
"'php://temp'",
",",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"resource",
"!==",
"''",
")",
"{",
"fwrite",
"(",
"$",
"stream",
",",
"$",
"resource",
")",
";",
"fseek",
"(",
"$",
"stream",
",",
"0",
")",
";",
"}",
"return",
"(",
"new",
"static",
"(",
"false",
")",
")",
"->",
"setResource",
"(",
"$",
"stream",
",",
"$",
"mode",
")",
";",
"case",
"'object'",
":",
"if",
"(",
"$",
"resource",
"instanceof",
"self",
")",
"{",
"return",
"$",
"resource",
";",
"}",
"elseif",
"(",
"method_exists",
"(",
"$",
"resource",
",",
"'__toString'",
")",
")",
"{",
"$",
"resource",
"=",
"(",
"string",
")",
"$",
"resource",
";",
"return",
"static",
"::",
"make",
"(",
"$",
"resource",
",",
"$",
"mode",
")",
";",
"}",
"default",
":",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid resource \"%s\" provided.'",
",",
"is_object",
"(",
"$",
"resource",
")",
"?",
"get_class",
"(",
"$",
"resource",
")",
":",
"gettype",
"(",
"$",
"resource",
")",
")",
")",
";",
"}",
"}"
] | Makes new stream instance of current stream class.
@param string|object|resource $resource Optional;
- the string as a body of new resource
- or an object which can be converted to a string (the instance of
AbstractStream returns without changes)
- or the resource to wrap
@param string $mode Optional; "w+b" by default. The type of access to
the stream if the access type is not specified
for a resource
@throws \InvalidArgumentException If the type of the specified resource
is not acceptable
@return self | [
"Makes",
"new",
"stream",
"instance",
"of",
"current",
"stream",
"class",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L61-L89 |
9,449 | easy-system/es-http | src/AbstractStream.php | AbstractStream.fopen | public static function fopen($resource = 'php://temp', $mode = 'w+b')
{
static::register();
$context = stream_context_create(
[static::PROTOCOL => ['resource' => $resource]]
);
set_error_handler(function () {
throw new Exception('Failed to open stream.');
});
try {
$fp = fopen(static::PROTOCOL . '://', $mode, false, $context);
} catch (Exception $ex) {
restore_error_handler();
throw new InvalidArgumentException(sprintf(
'Failed to create resource from "%s".',
is_resource($resource) ? get_resource_type($resource)
: gettype($resource)
), null, $ex);
}
restore_error_handler();
return $fp;
} | php | public static function fopen($resource = 'php://temp', $mode = 'w+b')
{
static::register();
$context = stream_context_create(
[static::PROTOCOL => ['resource' => $resource]]
);
set_error_handler(function () {
throw new Exception('Failed to open stream.');
});
try {
$fp = fopen(static::PROTOCOL . '://', $mode, false, $context);
} catch (Exception $ex) {
restore_error_handler();
throw new InvalidArgumentException(sprintf(
'Failed to create resource from "%s".',
is_resource($resource) ? get_resource_type($resource)
: gettype($resource)
), null, $ex);
}
restore_error_handler();
return $fp;
} | [
"public",
"static",
"function",
"fopen",
"(",
"$",
"resource",
"=",
"'php://temp'",
",",
"$",
"mode",
"=",
"'w+b'",
")",
"{",
"static",
"::",
"register",
"(",
")",
";",
"$",
"context",
"=",
"stream_context_create",
"(",
"[",
"static",
"::",
"PROTOCOL",
"=>",
"[",
"'resource'",
"=>",
"$",
"resource",
"]",
"]",
")",
";",
"set_error_handler",
"(",
"function",
"(",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Failed to open stream.'",
")",
";",
"}",
")",
";",
"try",
"{",
"$",
"fp",
"=",
"fopen",
"(",
"static",
"::",
"PROTOCOL",
".",
"'://'",
",",
"$",
"mode",
",",
"false",
",",
"$",
"context",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Failed to create resource from \"%s\".'",
",",
"is_resource",
"(",
"$",
"resource",
")",
"?",
"get_resource_type",
"(",
"$",
"resource",
")",
":",
"gettype",
"(",
"$",
"resource",
")",
")",
",",
"null",
",",
"$",
"ex",
")",
";",
"}",
"restore_error_handler",
"(",
")",
";",
"return",
"$",
"fp",
";",
"}"
] | Makes new resource from instance of current stream class.
@param string|resource $resource Optional; "php://temp" by default. The
resource wrapper reference as
"scheme://target" or resource to wrap
@param string $mode Optional; "w+b" by default. The type of
access to the stream if the access type
is not specified for a resource
@throws \InvalidArgumentException If failed to create resource from
received resource
@return resource New resource | [
"Makes",
"new",
"resource",
"from",
"instance",
"of",
"current",
"stream",
"class",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L106-L129 |
9,450 | easy-system/es-http | src/AbstractStream.php | AbstractStream.register | public static function register($flags = null)
{
$protocol = static::PROTOCOL;
if (static::isRegistered()) {
return true;
}
if (null === $flags) {
$flags = STREAM_IS_URL;
}
return stream_wrapper_register($protocol, static::class, $flags);
} | php | public static function register($flags = null)
{
$protocol = static::PROTOCOL;
if (static::isRegistered()) {
return true;
}
if (null === $flags) {
$flags = STREAM_IS_URL;
}
return stream_wrapper_register($protocol, static::class, $flags);
} | [
"public",
"static",
"function",
"register",
"(",
"$",
"flags",
"=",
"null",
")",
"{",
"$",
"protocol",
"=",
"static",
"::",
"PROTOCOL",
";",
"if",
"(",
"static",
"::",
"isRegistered",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"flags",
")",
"{",
"$",
"flags",
"=",
"STREAM_IS_URL",
";",
"}",
"return",
"stream_wrapper_register",
"(",
"$",
"protocol",
",",
"static",
"::",
"class",
",",
"$",
"flags",
")",
";",
"}"
] | Register the current class as wrapper for class-specified protocol.
@param int $flags Optional; null by default means "STREAM_IS_URL". The
specification of protocol type - URL protocol or local
@return bool Returns true on success, false otherwise | [
"Register",
"the",
"current",
"class",
"as",
"wrapper",
"for",
"class",
"-",
"specified",
"protocol",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L139-L151 |
9,451 | easy-system/es-http | src/AbstractStream.php | AbstractStream.open | public function open($path = null, $mode = null, $options = null, &$openedPath = null)
{
$context = [];
if (is_resource($this->context)) {
$context = stream_context_get_options($this->context);
}
$resource = 'php://temp';
if (isset($context[static::PROTOCOL]['resource'])) {
$resource = $context[static::PROTOCOL]['resource'];
}
if (is_resource($this->resource)) {
fclose($this->resource);
}
try {
$this->setResource($resource, $mode);
} catch (InvalidArgumentException $ex) {
return false;
}
return true;
} | php | public function open($path = null, $mode = null, $options = null, &$openedPath = null)
{
$context = [];
if (is_resource($this->context)) {
$context = stream_context_get_options($this->context);
}
$resource = 'php://temp';
if (isset($context[static::PROTOCOL]['resource'])) {
$resource = $context[static::PROTOCOL]['resource'];
}
if (is_resource($this->resource)) {
fclose($this->resource);
}
try {
$this->setResource($resource, $mode);
} catch (InvalidArgumentException $ex) {
return false;
}
return true;
} | [
"public",
"function",
"open",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"mode",
"=",
"null",
",",
"$",
"options",
"=",
"null",
",",
"&",
"$",
"openedPath",
"=",
"null",
")",
"{",
"$",
"context",
"=",
"[",
"]",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"context",
"=",
"stream_context_get_options",
"(",
"$",
"this",
"->",
"context",
")",
";",
"}",
"$",
"resource",
"=",
"'php://temp'",
";",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"static",
"::",
"PROTOCOL",
"]",
"[",
"'resource'",
"]",
")",
")",
"{",
"$",
"resource",
"=",
"$",
"context",
"[",
"static",
"::",
"PROTOCOL",
"]",
"[",
"'resource'",
"]",
";",
"}",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"setResource",
"(",
"$",
"resource",
",",
"$",
"mode",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Opens an stream.
Uses by PHP to open an stream for specified protocol.
@param string $path Not used. The path as "scheme://target"
@param string $mode Not used. The type of access to the stream
@param int $options Not used. Holds additional flags set by the
streams API
@param string $openedPath& Not used. The full path of the file/resource
to be set
@return bool Returns true on success, false otherwise | [
"Opens",
"an",
"stream",
".",
"Uses",
"by",
"PHP",
"to",
"open",
"an",
"stream",
"for",
"specified",
"protocol",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L186-L206 |
9,452 | easy-system/es-http | src/AbstractStream.php | AbstractStream.copy | public function copy($source)
{
if (! $this->resource) {
throw new RuntimeException('No resource available; cannot copy.');
}
$resource = null;
if ($source instanceof self) {
$resource = $source->getResource();
} elseif (is_resource($source)) {
$resource = $source;
} elseif (is_string($source)) {
set_error_handler(function () {
throw new Exception('Failed to open stream.');
});
try {
$resource = fopen($source, 'rb');
} catch (Exception $ex) {
restore_error_handler();
throw new InvalidArgumentException(sprintf(
'Invalid source path "%s" specified.',
$source
));
}
restore_error_handler();
} else {
throw new InvalidArgumentException(sprintf(
'Invalid source "%s" provided.',
is_object($source) ? get_class($source) : gettype($source)
));
}
$metadata = stream_get_meta_data($resource);
$mode = $metadata['mode'];
if (! (strstr($mode, 'r') || strstr($mode, '+'))) {
throw new InvalidArgumentException(
'The received source is not readable.'
);
}
$seekable = $metadata['seekable'];
if ($seekable) {
rewind($resource);
}
stream_copy_to_stream($resource, $this->resource);
rewind($this->resource);
if (is_string($source)) {
fclose($resource);
}
} | php | public function copy($source)
{
if (! $this->resource) {
throw new RuntimeException('No resource available; cannot copy.');
}
$resource = null;
if ($source instanceof self) {
$resource = $source->getResource();
} elseif (is_resource($source)) {
$resource = $source;
} elseif (is_string($source)) {
set_error_handler(function () {
throw new Exception('Failed to open stream.');
});
try {
$resource = fopen($source, 'rb');
} catch (Exception $ex) {
restore_error_handler();
throw new InvalidArgumentException(sprintf(
'Invalid source path "%s" specified.',
$source
));
}
restore_error_handler();
} else {
throw new InvalidArgumentException(sprintf(
'Invalid source "%s" provided.',
is_object($source) ? get_class($source) : gettype($source)
));
}
$metadata = stream_get_meta_data($resource);
$mode = $metadata['mode'];
if (! (strstr($mode, 'r') || strstr($mode, '+'))) {
throw new InvalidArgumentException(
'The received source is not readable.'
);
}
$seekable = $metadata['seekable'];
if ($seekable) {
rewind($resource);
}
stream_copy_to_stream($resource, $this->resource);
rewind($this->resource);
if (is_string($source)) {
fclose($resource);
}
} | [
"public",
"function",
"copy",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"resource",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No resource available; cannot copy.'",
")",
";",
"}",
"$",
"resource",
"=",
"null",
";",
"if",
"(",
"$",
"source",
"instanceof",
"self",
")",
"{",
"$",
"resource",
"=",
"$",
"source",
"->",
"getResource",
"(",
")",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"source",
")",
")",
"{",
"$",
"resource",
"=",
"$",
"source",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Failed to open stream.'",
")",
";",
"}",
")",
";",
"try",
"{",
"$",
"resource",
"=",
"fopen",
"(",
"$",
"source",
",",
"'rb'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid source path \"%s\" specified.'",
",",
"$",
"source",
")",
")",
";",
"}",
"restore_error_handler",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid source \"%s\" provided.'",
",",
"is_object",
"(",
"$",
"source",
")",
"?",
"get_class",
"(",
"$",
"source",
")",
":",
"gettype",
"(",
"$",
"source",
")",
")",
")",
";",
"}",
"$",
"metadata",
"=",
"stream_get_meta_data",
"(",
"$",
"resource",
")",
";",
"$",
"mode",
"=",
"$",
"metadata",
"[",
"'mode'",
"]",
";",
"if",
"(",
"!",
"(",
"strstr",
"(",
"$",
"mode",
",",
"'r'",
")",
"||",
"strstr",
"(",
"$",
"mode",
",",
"'+'",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The received source is not readable.'",
")",
";",
"}",
"$",
"seekable",
"=",
"$",
"metadata",
"[",
"'seekable'",
"]",
";",
"if",
"(",
"$",
"seekable",
")",
"{",
"rewind",
"(",
"$",
"resource",
")",
";",
"}",
"stream_copy_to_stream",
"(",
"$",
"resource",
",",
"$",
"this",
"->",
"resource",
")",
";",
"rewind",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"fclose",
"(",
"$",
"resource",
")",
";",
"}",
"}"
] | Copies the contents of source.
If the source is seekable, copies content from beginning. Otherwise
copies data from current position.
@param string|resource|AbstractStream $source The source to copy
@throws \RuntimeException If the internal resource is not
available
@throws \InvalidArgumentException
- If invalid source provided
- If source is not readable | [
"Copies",
"the",
"contents",
"of",
"source",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L223-L269 |
9,453 | easy-system/es-http | src/AbstractStream.php | AbstractStream.setResource | public function setResource($resource = 'php://temp', $mode = 'w+b')
{
if (is_resource($this->resource)) {
throw new DomainException('The resource is already set.');
}
if (is_resource($resource)) {
$this->resource = $resource;
} elseif (is_string($resource)) {
set_error_handler(function () {
throw new Exception('Failed to open stream.');
}, E_WARNING);
try {
$this->resource = fopen($resource, $mode);
} catch (Exception $ex) {
restore_error_handler();
throw new InvalidArgumentException(sprintf(
'Invalid path "%s" specified.',
$resource
));
}
restore_error_handler();
} else {
throw new InvalidArgumentException(sprintf(
'Invalid resource "%s" provided.',
is_object($resource) ? get_class($resource) : gettype($resource)
));
}
return $this;
} | php | public function setResource($resource = 'php://temp', $mode = 'w+b')
{
if (is_resource($this->resource)) {
throw new DomainException('The resource is already set.');
}
if (is_resource($resource)) {
$this->resource = $resource;
} elseif (is_string($resource)) {
set_error_handler(function () {
throw new Exception('Failed to open stream.');
}, E_WARNING);
try {
$this->resource = fopen($resource, $mode);
} catch (Exception $ex) {
restore_error_handler();
throw new InvalidArgumentException(sprintf(
'Invalid path "%s" specified.',
$resource
));
}
restore_error_handler();
} else {
throw new InvalidArgumentException(sprintf(
'Invalid resource "%s" provided.',
is_object($resource) ? get_class($resource) : gettype($resource)
));
}
return $this;
} | [
"public",
"function",
"setResource",
"(",
"$",
"resource",
"=",
"'php://temp'",
",",
"$",
"mode",
"=",
"'w+b'",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"throw",
"new",
"DomainException",
"(",
"'The resource is already set.'",
")",
";",
"}",
"if",
"(",
"is_resource",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"this",
"->",
"resource",
"=",
"$",
"resource",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"resource",
")",
")",
"{",
"set_error_handler",
"(",
"function",
"(",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Failed to open stream.'",
")",
";",
"}",
",",
"E_WARNING",
")",
";",
"try",
"{",
"$",
"this",
"->",
"resource",
"=",
"fopen",
"(",
"$",
"resource",
",",
"$",
"mode",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"restore_error_handler",
"(",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid path \"%s\" specified.'",
",",
"$",
"resource",
")",
")",
";",
"}",
"restore_error_handler",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid resource \"%s\" provided.'",
",",
"is_object",
"(",
"$",
"resource",
")",
"?",
"get_class",
"(",
"$",
"resource",
")",
":",
"gettype",
"(",
"$",
"resource",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the resource to wrapper.
@param string|resource $resource Optional; "php://temp" by default. The
resource wrapper reference as
"scheme://target" or resource to wrap
@param string $mode Optional; "w+b" by default. The type of
access to the stream if the access type
is not specified for a resource
@throws \DomainException If resource already set
@throws \InvalidArgumentException If the type of the specified resource
is not acceptable
@return self | [
"Sets",
"the",
"resource",
"to",
"wrapper",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L287-L317 |
9,454 | easy-system/es-http | src/AbstractStream.php | AbstractStream.stat | public function stat()
{
$stat = null;
if (is_resource($this->resource)) {
$stat = fstat($this->resource);
}
return $stat;
} | php | public function stat()
{
$stat = null;
if (is_resource($this->resource)) {
$stat = fstat($this->resource);
}
return $stat;
} | [
"public",
"function",
"stat",
"(",
")",
"{",
"$",
"stat",
"=",
"null",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"resource",
")",
")",
"{",
"$",
"stat",
"=",
"fstat",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"}",
"return",
"$",
"stat",
";",
"}"
] | Retrieve information about a resource.
@return array|null The statistics of the opened resource if any or null | [
"Retrieve",
"information",
"about",
"a",
"resource",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/AbstractStream.php#L334-L341 |
9,455 | GrupaZero/core | src/Gzero/Core/Query/OrderBy.php | OrderBy.apply | public function apply(Builder $query, string $tableAlias = null, string $customName = null)
{
if ($this->hasBeenApplied()) {
return;
}
$name = $this->buildDbName($tableAlias, $customName);
$query->orderBy($name, $this->direction);
$this->setApplied(true);
} | php | public function apply(Builder $query, string $tableAlias = null, string $customName = null)
{
if ($this->hasBeenApplied()) {
return;
}
$name = $this->buildDbName($tableAlias, $customName);
$query->orderBy($name, $this->direction);
$this->setApplied(true);
} | [
"public",
"function",
"apply",
"(",
"Builder",
"$",
"query",
",",
"string",
"$",
"tableAlias",
"=",
"null",
",",
"string",
"$",
"customName",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasBeenApplied",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"buildDbName",
"(",
"$",
"tableAlias",
",",
"$",
"customName",
")",
";",
"$",
"query",
"->",
"orderBy",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"direction",
")",
";",
"$",
"this",
"->",
"setApplied",
"(",
"true",
")",
";",
"}"
] | Applies orderBy on Eloquent query builder
@param Builder $query Eloquent query builder
@param string|null $tableAlias SQL table alias
@param string|null $customName Override field name
@return void | [
"Applies",
"orderBy",
"on",
"Eloquent",
"query",
"builder"
] | 093e515234fa0385b259ba4d8bc7832174a44eab | https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Query/OrderBy.php#L92-L102 |
9,456 | rseyferth/activerecord | lib/SQLBuilder.php | SQLBuilder.bindValues | public function bindValues()
{
$ret = array();
if ($this->data)
$ret = array_values($this->data);
if ($this->getWhereValues())
$ret = array_merge($ret,$this->getWhereValues());
return \ChickenTools\Arry::flatten($ret);
} | php | public function bindValues()
{
$ret = array();
if ($this->data)
$ret = array_values($this->data);
if ($this->getWhereValues())
$ret = array_merge($ret,$this->getWhereValues());
return \ChickenTools\Arry::flatten($ret);
} | [
"public",
"function",
"bindValues",
"(",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"data",
")",
"$",
"ret",
"=",
"array_values",
"(",
"$",
"this",
"->",
"data",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getWhereValues",
"(",
")",
")",
"$",
"ret",
"=",
"array_merge",
"(",
"$",
"ret",
",",
"$",
"this",
"->",
"getWhereValues",
"(",
")",
")",
";",
"return",
"\\",
"ChickenTools",
"\\",
"Arry",
"::",
"flatten",
"(",
"$",
"ret",
")",
";",
"}"
] | Returns the bind values.
@return array | [
"Returns",
"the",
"bind",
"values",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/SQLBuilder.php#L80-L91 |
9,457 | rseyferth/activerecord | lib/SQLBuilder.php | SQLBuilder.reverseOrder | public static function reverseOrder($order)
{
if (!trim($order))
return $order;
$parts = explode(',',$order);
for ($i=0,$n=count($parts); $i<$n; ++$i)
{
$v = strtolower($parts[$i]);
if (strpos($v,' asc') !== false)
$parts[$i] = preg_replace('/asc/i','DESC',$parts[$i]);
elseif (strpos($v,' desc') !== false)
$parts[$i] = preg_replace('/desc/i','ASC',$parts[$i]);
else
$parts[$i] .= ' DESC';
}
return join(',',$parts);
} | php | public static function reverseOrder($order)
{
if (!trim($order))
return $order;
$parts = explode(',',$order);
for ($i=0,$n=count($parts); $i<$n; ++$i)
{
$v = strtolower($parts[$i]);
if (strpos($v,' asc') !== false)
$parts[$i] = preg_replace('/asc/i','DESC',$parts[$i]);
elseif (strpos($v,' desc') !== false)
$parts[$i] = preg_replace('/desc/i','ASC',$parts[$i]);
else
$parts[$i] .= ' DESC';
}
return join(',',$parts);
} | [
"public",
"static",
"function",
"reverseOrder",
"(",
"$",
"order",
")",
"{",
"if",
"(",
"!",
"trim",
"(",
"$",
"order",
")",
")",
"return",
"$",
"order",
";",
"$",
"parts",
"=",
"explode",
"(",
"','",
",",
"$",
"order",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"n",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"$",
"i",
"<",
"$",
"n",
";",
"++",
"$",
"i",
")",
"{",
"$",
"v",
"=",
"strtolower",
"(",
"$",
"parts",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"v",
",",
"' asc'",
")",
"!==",
"false",
")",
"$",
"parts",
"[",
"$",
"i",
"]",
"=",
"preg_replace",
"(",
"'/asc/i'",
",",
"'DESC'",
",",
"$",
"parts",
"[",
"$",
"i",
"]",
")",
";",
"elseif",
"(",
"strpos",
"(",
"$",
"v",
",",
"' desc'",
")",
"!==",
"false",
")",
"$",
"parts",
"[",
"$",
"i",
"]",
"=",
"preg_replace",
"(",
"'/desc/i'",
",",
"'ASC'",
",",
"$",
"parts",
"[",
"$",
"i",
"]",
")",
";",
"else",
"$",
"parts",
"[",
"$",
"i",
"]",
".=",
"' DESC'",
";",
"}",
"return",
"join",
"(",
"','",
",",
"$",
"parts",
")",
";",
"}"
] | Reverses an order clause. | [
"Reverses",
"an",
"order",
"clause",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/SQLBuilder.php#L185-L204 |
9,458 | rseyferth/activerecord | lib/SQLBuilder.php | SQLBuilder.createHashFromUnderscoredString | public static function createHashFromUnderscoredString($name, &$values=array(), &$map=null)
{
throw new \Exception("This should be refactored!!!", 1);
$parts = preg_split('/(_and_|_or_)/i',$name);
$hash = array();
for ($i=0,$n=count($parts); $i<$n; ++$i)
{
// map to correct name if $map was supplied
$name = $map && isset($map[$parts[$i]]) ? $map[$parts[$i]] : $parts[$i];
$hash[$name] = $values[$i];
}
return $hash;
} | php | public static function createHashFromUnderscoredString($name, &$values=array(), &$map=null)
{
throw new \Exception("This should be refactored!!!", 1);
$parts = preg_split('/(_and_|_or_)/i',$name);
$hash = array();
for ($i=0,$n=count($parts); $i<$n; ++$i)
{
// map to correct name if $map was supplied
$name = $map && isset($map[$parts[$i]]) ? $map[$parts[$i]] : $parts[$i];
$hash[$name] = $values[$i];
}
return $hash;
} | [
"public",
"static",
"function",
"createHashFromUnderscoredString",
"(",
"$",
"name",
",",
"&",
"$",
"values",
"=",
"array",
"(",
")",
",",
"&",
"$",
"map",
"=",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"This should be refactored!!!\"",
",",
"1",
")",
";",
"$",
"parts",
"=",
"preg_split",
"(",
"'/(_and_|_or_)/i'",
",",
"$",
"name",
")",
";",
"$",
"hash",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"n",
"=",
"count",
"(",
"$",
"parts",
")",
";",
"$",
"i",
"<",
"$",
"n",
";",
"++",
"$",
"i",
")",
"{",
"// map to correct name if $map was supplied",
"$",
"name",
"=",
"$",
"map",
"&&",
"isset",
"(",
"$",
"map",
"[",
"$",
"parts",
"[",
"$",
"i",
"]",
"]",
")",
"?",
"$",
"map",
"[",
"$",
"parts",
"[",
"$",
"i",
"]",
"]",
":",
"$",
"parts",
"[",
"$",
"i",
"]",
";",
"$",
"hash",
"[",
"$",
"name",
"]",
"=",
"$",
"values",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"hash",
";",
"}"
] | Like create_conditions_from_underscored_string but returns a hash of name => value array instead.
@param string $name A string containing attribute names connected with _and_ or _or_
@param $args Array of values for each attribute in $name
@param $map A hash of "mapped_column_name" => "real_column_name"
@return array A hash of array(name => value, ...) | [
"Like",
"create_conditions_from_underscored_string",
"but",
"returns",
"a",
"hash",
"of",
"name",
"=",
">",
"value",
"array",
"instead",
"."
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/SQLBuilder.php#L265-L279 |
9,459 | rseyferth/activerecord | lib/SQLBuilder.php | SQLBuilder.prependTableNameToFields | private function prependTableNameToFields($hash=array())
{
$new = array();
$table = $this->connection->quoteName($this->table);
foreach ($hash as $key => $value)
{
$k = $this->connection->quoteName($key);
$new[$table.'.'.$k] = $value;
}
return $new;
} | php | private function prependTableNameToFields($hash=array())
{
$new = array();
$table = $this->connection->quoteName($this->table);
foreach ($hash as $key => $value)
{
$k = $this->connection->quoteName($key);
$new[$table.'.'.$k] = $value;
}
return $new;
} | [
"private",
"function",
"prependTableNameToFields",
"(",
"$",
"hash",
"=",
"array",
"(",
")",
")",
"{",
"$",
"new",
"=",
"array",
"(",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"connection",
"->",
"quoteName",
"(",
"$",
"this",
"->",
"table",
")",
";",
"foreach",
"(",
"$",
"hash",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"k",
"=",
"$",
"this",
"->",
"connection",
"->",
"quoteName",
"(",
"$",
"key",
")",
";",
"$",
"new",
"[",
"$",
"table",
".",
"'.'",
".",
"$",
"k",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"new",
";",
"}"
] | prepends table name to hash of field names to get around ambiguous fields when SQL builder
has joins
@param array $hash
@return array $new | [
"prepends",
"table",
"name",
"to",
"hash",
"of",
"field",
"names",
"to",
"get",
"around",
"ambiguous",
"fields",
"when",
"SQL",
"builder",
"has",
"joins"
] | 0e7b1cbddd6f967c3a09adf38753babd5f698e39 | https://github.com/rseyferth/activerecord/blob/0e7b1cbddd6f967c3a09adf38753babd5f698e39/lib/SQLBuilder.php#L288-L300 |
9,460 | clusterpoint/php-client-api | command_classes.php | CPS_SearchRequest.setQuery | public function setQuery($value)
{
if (is_array($value)) {
$this->setParam('query', CPS_QueryArray($value));
} else {
$this->setParam('query', $value);
}
} | php | public function setQuery($value)
{
if (is_array($value)) {
$this->setParam('query', CPS_QueryArray($value));
} else {
$this->setParam('query', $value);
}
} | [
"public",
"function",
"setQuery",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"setParam",
"(",
"'query'",
",",
"CPS_QueryArray",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setParam",
"(",
"'query'",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Sets the search query.
Example usage:
<code>$r->setQuery('(' . CPS_Term('predefined_term', '/generated_fields/type/') . CPS_QueryTerm($user_supplied_terms, '/searchable_fields/text') . ')');</code>
or
<code>$r->setQuery(array('tags' => array('title' => 'Title', 'text' => 'Text')));</code>
or
<code>$r->setQuery(array('tags/title' => 'Title', 'tags/text' => 'Text'));</code>
@param array|string $value The query array/string.
If the string form is used, all <, > and & characters that aren't supposed to be XML tags, should be escaped (e.g. with {@link CPS_Term} or {@link CPS_QueryTerm});
@see CPS_QueryTerm, CPS_Term | [
"Sets",
"the",
"search",
"query",
"."
] | 44c98a727271c91bb9b9a70975ec4f69d99e64e7 | https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/command_classes.php#L275-L282 |
9,461 | clusterpoint/php-client-api | command_classes.php | CPS_SearchRequest.setList | public function setList($array)
{
$listString = '';
foreach ($array as $key => $value) {
$listString .= CPS_Term($value, $key);
}
$this->setParam('list', $listString);
} | php | public function setList($array)
{
$listString = '';
foreach ($array as $key => $value) {
$listString .= CPS_Term($value, $key);
}
$this->setParam('list', $listString);
} | [
"public",
"function",
"setList",
"(",
"$",
"array",
")",
"{",
"$",
"listString",
"=",
"''",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"listString",
".=",
"CPS_Term",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"setParam",
"(",
"'list'",
",",
"$",
"listString",
")",
";",
"}"
] | Defines which tags of the search results should be listed in the response
@param array $array an associative array with tag xpaths as keys and listing options (yes, no, snippet or highlight) as values | [
"Defines",
"which",
"tags",
"of",
"the",
"search",
"results",
"should",
"be",
"listed",
"in",
"the",
"response"
] | 44c98a727271c91bb9b9a70975ec4f69d99e64e7 | https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/command_classes.php#L344-L351 |
9,462 | clusterpoint/php-client-api | command_classes.php | CPS_SearchRequest.setOrdering | public function setOrdering($order)
{
if (is_array($order)) {
$order = implode('', $order);
}
$this->setParam('ordering', $order);
} | php | public function setOrdering($order)
{
if (is_array($order)) {
$order = implode('', $order);
}
$this->setParam('ordering', $order);
} | [
"public",
"function",
"setOrdering",
"(",
"$",
"order",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"order",
")",
")",
"{",
"$",
"order",
"=",
"implode",
"(",
"''",
",",
"$",
"order",
")",
";",
"}",
"$",
"this",
"->",
"setParam",
"(",
"'ordering'",
",",
"$",
"order",
")",
";",
"}"
] | Defines the order in which results should be returned.
@param string|array $order either a single sorting string or an array of those. Could be conveniently generated with ordering macros,
e.g. $q->setOrdering(array(CPS_NumericOrdering('user_count', 'desc'), CPS_RelevanceOrdering())) will sort the documents in descending order
according to the user_count, and if user_count is equal will sort them by relevance.
@see CPS_RelevanceOrdering, CPS_NumericOrdering, CPS_LatLonDistanceOrdering, CPS_PlainDistanceOrdering | [
"Defines",
"the",
"order",
"in",
"which",
"results",
"should",
"be",
"returned",
"."
] | 44c98a727271c91bb9b9a70975ec4f69d99e64e7 | https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/command_classes.php#L360-L366 |
9,463 | clusterpoint/php-client-api | command_classes.php | CPS_SearchResponse.getDocuments | public function getDocuments($type = DOC_TYPE_SIMPLEXML)
{
if (isset($this->_simpleXml->cursor_id)) return $this->getCursor($type);
return parent::getRawDocuments($type);
} | php | public function getDocuments($type = DOC_TYPE_SIMPLEXML)
{
if (isset($this->_simpleXml->cursor_id)) return $this->getCursor($type);
return parent::getRawDocuments($type);
} | [
"public",
"function",
"getDocuments",
"(",
"$",
"type",
"=",
"DOC_TYPE_SIMPLEXML",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_simpleXml",
"->",
"cursor_id",
")",
")",
"return",
"$",
"this",
"->",
"getCursor",
"(",
"$",
"type",
")",
";",
"return",
"parent",
"::",
"getRawDocuments",
"(",
"$",
"type",
")",
";",
"}"
] | Returns the documents from the response as an associative array, where keys are document IDs and values area document contents
@param int $type defines which datatype the returned documents will be in. Default is DOC_TYPE_SIMPLEXML, other possible values are DOC_TYPE_ARRAY and DOC_TYPE_STDCLASS
@return array | [
"Returns",
"the",
"documents",
"from",
"the",
"response",
"as",
"an",
"associative",
"array",
"where",
"keys",
"are",
"document",
"IDs",
"and",
"values",
"area",
"document",
"contents"
] | 44c98a727271c91bb9b9a70975ec4f69d99e64e7 | https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/command_classes.php#L410-L414 |
9,464 | clusterpoint/php-client-api | command_classes.php | CPS_AlternativesResponse.getWordCount | public function getWordCount($word)
{
if (is_null($this->_localWords)) {
$this->_localWords = $this->getRawWordCounts();
}
return isset($this->_localWords[$word]) ? $this->_localWords[$word] : 0;
} | php | public function getWordCount($word)
{
if (is_null($this->_localWords)) {
$this->_localWords = $this->getRawWordCounts();
}
return isset($this->_localWords[$word]) ? $this->_localWords[$word] : 0;
} | [
"public",
"function",
"getWordCount",
"(",
"$",
"word",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"_localWords",
")",
")",
"{",
"$",
"this",
"->",
"_localWords",
"=",
"$",
"this",
"->",
"getRawWordCounts",
"(",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"_localWords",
"[",
"$",
"word",
"]",
")",
"?",
"$",
"this",
"->",
"_localWords",
"[",
"$",
"word",
"]",
":",
"0",
";",
"}"
] | Gets the occurence count of a particular word from the original query
@param string $word
@return int | [
"Gets",
"the",
"occurence",
"count",
"of",
"a",
"particular",
"word",
"from",
"the",
"original",
"query"
] | 44c98a727271c91bb9b9a70975ec4f69d99e64e7 | https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/command_classes.php#L1015-L1021 |
9,465 | pokap/pool-dbm | src/Pok/PoolDBM/Mapping/ClassMetadata.php | ClassMetadata.getIdentifierReference | public function getIdentifierReference($manager)
{
if (!isset($this->identifierReferences[$manager])) {
$rule = new \stdClass();
$rule->referenceField = $this->identifierField;
$rule->field = $this->identifierField;
return $rule;
}
return $this->identifierReferences[$manager];
} | php | public function getIdentifierReference($manager)
{
if (!isset($this->identifierReferences[$manager])) {
$rule = new \stdClass();
$rule->referenceField = $this->identifierField;
$rule->field = $this->identifierField;
return $rule;
}
return $this->identifierReferences[$manager];
} | [
"public",
"function",
"getIdentifierReference",
"(",
"$",
"manager",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"identifierReferences",
"[",
"$",
"manager",
"]",
")",
")",
"{",
"$",
"rule",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"rule",
"->",
"referenceField",
"=",
"$",
"this",
"->",
"identifierField",
";",
"$",
"rule",
"->",
"field",
"=",
"$",
"this",
"->",
"identifierField",
";",
"return",
"$",
"rule",
";",
"}",
"return",
"$",
"this",
"->",
"identifierReferences",
"[",
"$",
"manager",
"]",
";",
"}"
] | Returns field idendifier given by manager.
If manager not specific, returns identifier field of model reference.
@param string $manager
@return \stdClass | [
"Returns",
"field",
"idendifier",
"given",
"by",
"manager",
".",
"If",
"manager",
"not",
"specific",
"returns",
"identifier",
"field",
"of",
"model",
"reference",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Mapping/ClassMetadata.php#L167-L178 |
9,466 | pokap/pool-dbm | src/Pok/PoolDBM/Mapping/ClassMetadata.php | ClassMetadata.addModel | public function addModel($field, $modelName, array $subFields = array(), $repository_method = null)
{
$mapping = new ModelDefinition($modelName, $field, $subFields);
$mapping->setRepositoryMethod($repository_method);
$this->fieldMappings[$field] = $mapping;
return $mapping;
} | php | public function addModel($field, $modelName, array $subFields = array(), $repository_method = null)
{
$mapping = new ModelDefinition($modelName, $field, $subFields);
$mapping->setRepositoryMethod($repository_method);
$this->fieldMappings[$field] = $mapping;
return $mapping;
} | [
"public",
"function",
"addModel",
"(",
"$",
"field",
",",
"$",
"modelName",
",",
"array",
"$",
"subFields",
"=",
"array",
"(",
")",
",",
"$",
"repository_method",
"=",
"null",
")",
"{",
"$",
"mapping",
"=",
"new",
"ModelDefinition",
"(",
"$",
"modelName",
",",
"$",
"field",
",",
"$",
"subFields",
")",
";",
"$",
"mapping",
"->",
"setRepositoryMethod",
"(",
"$",
"repository_method",
")",
";",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"field",
"]",
"=",
"$",
"mapping",
";",
"return",
"$",
"mapping",
";",
"}"
] | Map fields per model.
@param string $field Manager name
@param string $modelName
@param array $subFields (optional)
@param string $repository_method (optional)
@return ModelDefinition | [
"Map",
"fields",
"per",
"model",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Mapping/ClassMetadata.php#L253-L261 |
9,467 | pokap/pool-dbm | src/Pok/PoolDBM/Mapping/ClassMetadata.php | ClassMetadata.addAssociation | public function addAssociation($isCollection, $field, $targetMultiModel, array $compatible = array(), array $references = array())
{
$mapping = new AssociationDefinition($field, $targetMultiModel, $isCollection);
$mapping->setCompatible($compatible);
$mapping->setReferences($references);
$this->associationMappings[$field] = $mapping;
return $mapping;
} | php | public function addAssociation($isCollection, $field, $targetMultiModel, array $compatible = array(), array $references = array())
{
$mapping = new AssociationDefinition($field, $targetMultiModel, $isCollection);
$mapping->setCompatible($compatible);
$mapping->setReferences($references);
$this->associationMappings[$field] = $mapping;
return $mapping;
} | [
"public",
"function",
"addAssociation",
"(",
"$",
"isCollection",
",",
"$",
"field",
",",
"$",
"targetMultiModel",
",",
"array",
"$",
"compatible",
"=",
"array",
"(",
")",
",",
"array",
"$",
"references",
"=",
"array",
"(",
")",
")",
"{",
"$",
"mapping",
"=",
"new",
"AssociationDefinition",
"(",
"$",
"field",
",",
"$",
"targetMultiModel",
",",
"$",
"isCollection",
")",
";",
"$",
"mapping",
"->",
"setCompatible",
"(",
"$",
"compatible",
")",
";",
"$",
"mapping",
"->",
"setReferences",
"(",
"$",
"references",
")",
";",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"field",
"]",
"=",
"$",
"mapping",
";",
"return",
"$",
"mapping",
";",
"}"
] | Adding associtation mapping between multi-model.
@param boolean $isCollection
@param string $field
@param string $targetMultiModel
@param array $compatible (optional)
@param array $references (optional)
@return AssociationDefinition | [
"Adding",
"associtation",
"mapping",
"between",
"multi",
"-",
"model",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Mapping/ClassMetadata.php#L294-L303 |
9,468 | pokap/pool-dbm | src/Pok/PoolDBM/Mapping/ClassMetadata.php | ClassMetadata.getAssociationReferenceNames | public function getAssociationReferenceNames()
{
$referenceNames = array();
foreach ($this->associationMappings as $assoc) {
$referenceNames[] = $assoc->getReferenceField($this->getManagerIdentifier()) ?: $assoc->getField();
}
return $referenceNames;
} | php | public function getAssociationReferenceNames()
{
$referenceNames = array();
foreach ($this->associationMappings as $assoc) {
$referenceNames[] = $assoc->getReferenceField($this->getManagerIdentifier()) ?: $assoc->getField();
}
return $referenceNames;
} | [
"public",
"function",
"getAssociationReferenceNames",
"(",
")",
"{",
"$",
"referenceNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"associationMappings",
"as",
"$",
"assoc",
")",
"{",
"$",
"referenceNames",
"[",
"]",
"=",
"$",
"assoc",
"->",
"getReferenceField",
"(",
"$",
"this",
"->",
"getManagerIdentifier",
"(",
")",
")",
"?",
":",
"$",
"assoc",
"->",
"getField",
"(",
")",
";",
"}",
"return",
"$",
"referenceNames",
";",
"}"
] | Returns list of association field per reference model.
@eturn array | [
"Returns",
"list",
"of",
"association",
"field",
"per",
"reference",
"model",
"."
] | cce32d7cb5f13f42c358c8140b2f97ddf1d9435a | https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Mapping/ClassMetadata.php#L448-L456 |
9,469 | sgtlambda/jvwp | src/admin/metaboxes/fields/Field.php | Field.getValue | public function getValue ($post_ID)
{
if ($post_ID === self::SITE)
return get_option($this->identifier, $this->default);
else {
$value = get_post_meta($post_ID, $this->identifier, true);
return $value === '' ? $this->default : $value;
}
} | php | public function getValue ($post_ID)
{
if ($post_ID === self::SITE)
return get_option($this->identifier, $this->default);
else {
$value = get_post_meta($post_ID, $this->identifier, true);
return $value === '' ? $this->default : $value;
}
} | [
"public",
"function",
"getValue",
"(",
"$",
"post_ID",
")",
"{",
"if",
"(",
"$",
"post_ID",
"===",
"self",
"::",
"SITE",
")",
"return",
"get_option",
"(",
"$",
"this",
"->",
"identifier",
",",
"$",
"this",
"->",
"default",
")",
";",
"else",
"{",
"$",
"value",
"=",
"get_post_meta",
"(",
"$",
"post_ID",
",",
"$",
"this",
"->",
"identifier",
",",
"true",
")",
";",
"return",
"$",
"value",
"===",
"''",
"?",
"$",
"this",
"->",
"default",
":",
"$",
"value",
";",
"}",
"}"
] | Gets the value of this field for a given post
@param int|string $post_ID The post ID or <pre>Field::SITE</pre> if it is a global option
@return string | [
"Gets",
"the",
"value",
"of",
"this",
"field",
"for",
"a",
"given",
"post"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/metaboxes/fields/Field.php#L38-L46 |
9,470 | sgtlambda/jvwp | src/admin/metaboxes/fields/Field.php | Field.display | public function display ($post)
{
echo '<div class="wrap-meta-field type-' . $this->getType() . '">';
$this->outputLabel();
$identifier = $post instanceof WP_Post ? $post->ID : $post;
$this->output($this->getValue($identifier));
echo '</div>';
} | php | public function display ($post)
{
echo '<div class="wrap-meta-field type-' . $this->getType() . '">';
$this->outputLabel();
$identifier = $post instanceof WP_Post ? $post->ID : $post;
$this->output($this->getValue($identifier));
echo '</div>';
} | [
"public",
"function",
"display",
"(",
"$",
"post",
")",
"{",
"echo",
"'<div class=\"wrap-meta-field type-'",
".",
"$",
"this",
"->",
"getType",
"(",
")",
".",
"'\">'",
";",
"$",
"this",
"->",
"outputLabel",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"post",
"instanceof",
"WP_Post",
"?",
"$",
"post",
"->",
"ID",
":",
"$",
"post",
";",
"$",
"this",
"->",
"output",
"(",
"$",
"this",
"->",
"getValue",
"(",
"$",
"identifier",
")",
")",
";",
"echo",
"'</div>'",
";",
"}"
] | Displays the field control for a given post
@param WP_Post $post | [
"Displays",
"the",
"field",
"control",
"for",
"a",
"given",
"post"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/metaboxes/fields/Field.php#L65-L72 |
9,471 | sgtlambda/jvwp | src/admin/metaboxes/fields/Field.php | Field.save | public function save ($post_ID)
{
if (!$this->doSave())
return;
if ($post_ID === self::SITE)
update_option($this->identifier, $this->getPostValue());
else
update_post_meta($post_ID, $this->identifier, $this->getPostValue());
} | php | public function save ($post_ID)
{
if (!$this->doSave())
return;
if ($post_ID === self::SITE)
update_option($this->identifier, $this->getPostValue());
else
update_post_meta($post_ID, $this->identifier, $this->getPostValue());
} | [
"public",
"function",
"save",
"(",
"$",
"post_ID",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"doSave",
"(",
")",
")",
"return",
";",
"if",
"(",
"$",
"post_ID",
"===",
"self",
"::",
"SITE",
")",
"update_option",
"(",
"$",
"this",
"->",
"identifier",
",",
"$",
"this",
"->",
"getPostValue",
"(",
")",
")",
";",
"else",
"update_post_meta",
"(",
"$",
"post_ID",
",",
"$",
"this",
"->",
"identifier",
",",
"$",
"this",
"->",
"getPostValue",
"(",
")",
")",
";",
"}"
] | Saves the updated meta value to the database
@param int|string $post_ID The post ID or <pre>Field::SITE</pre> if it is a global option | [
"Saves",
"the",
"updated",
"meta",
"value",
"to",
"the",
"database"
] | 85dba59281216ccb9cff580d26063d304350bbe0 | https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/admin/metaboxes/fields/Field.php#L79-L87 |
9,472 | joomlatools/joomlatools-platform-categories | plugins/content/categories/categories.php | PlgContentCategories.onContentBeforeDelete | public function onContentBeforeDelete($context, $data)
{
// Skip plugin if we are deleting something other than categories
if ($context != 'com_categories.category')
{
return true;
}
// Check if this function is enabled.
if (!$this->params->def('check_categories', 1))
{
return true;
}
$extension = JFactory::getApplication()->input->getString('extension');
// Default to true if not a core extension
$result = true;
$tableInfo = array(
'com_content' => array('table_name' => '#__content'),
);
// Now check to see if this is a known core extension
if (isset($tableInfo[$extension]))
{
// Get table name for known core extensions
$table = $tableInfo[$extension]['table_name'];
// See if this category has any content items
$count = $this->_countItemsInCategory($table, $data->get('id'));
// Return false if db error
if ($count === false)
{
$result = false;
}
else
{
// Show error if items are found in the category
if ($count > 0)
{
$msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title'))
. JText::plural('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
JError::raiseWarning(403, $msg);
$result = false;
}
// Check for items in any child categories (if it is a leaf, there are no child categories)
if (!$data->isLeaf())
{
$count = $this->_countItemsInChildren($table, $data->get('id'), $data);
if ($count === false)
{
$result = false;
}
elseif ($count > 0)
{
$msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title'))
. JText::plural('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
JError::raiseWarning(403, $msg);
$result = false;
}
}
}
return $result;
}
} | php | public function onContentBeforeDelete($context, $data)
{
// Skip plugin if we are deleting something other than categories
if ($context != 'com_categories.category')
{
return true;
}
// Check if this function is enabled.
if (!$this->params->def('check_categories', 1))
{
return true;
}
$extension = JFactory::getApplication()->input->getString('extension');
// Default to true if not a core extension
$result = true;
$tableInfo = array(
'com_content' => array('table_name' => '#__content'),
);
// Now check to see if this is a known core extension
if (isset($tableInfo[$extension]))
{
// Get table name for known core extensions
$table = $tableInfo[$extension]['table_name'];
// See if this category has any content items
$count = $this->_countItemsInCategory($table, $data->get('id'));
// Return false if db error
if ($count === false)
{
$result = false;
}
else
{
// Show error if items are found in the category
if ($count > 0)
{
$msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title'))
. JText::plural('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
JError::raiseWarning(403, $msg);
$result = false;
}
// Check for items in any child categories (if it is a leaf, there are no child categories)
if (!$data->isLeaf())
{
$count = $this->_countItemsInChildren($table, $data->get('id'), $data);
if ($count === false)
{
$result = false;
}
elseif ($count > 0)
{
$msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title'))
. JText::plural('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
JError::raiseWarning(403, $msg);
$result = false;
}
}
}
return $result;
}
} | [
"public",
"function",
"onContentBeforeDelete",
"(",
"$",
"context",
",",
"$",
"data",
")",
"{",
"// Skip plugin if we are deleting something other than categories",
"if",
"(",
"$",
"context",
"!=",
"'com_categories.category'",
")",
"{",
"return",
"true",
";",
"}",
"// Check if this function is enabled.",
"if",
"(",
"!",
"$",
"this",
"->",
"params",
"->",
"def",
"(",
"'check_categories'",
",",
"1",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"extension",
"=",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"input",
"->",
"getString",
"(",
"'extension'",
")",
";",
"// Default to true if not a core extension",
"$",
"result",
"=",
"true",
";",
"$",
"tableInfo",
"=",
"array",
"(",
"'com_content'",
"=>",
"array",
"(",
"'table_name'",
"=>",
"'#__content'",
")",
",",
")",
";",
"// Now check to see if this is a known core extension",
"if",
"(",
"isset",
"(",
"$",
"tableInfo",
"[",
"$",
"extension",
"]",
")",
")",
"{",
"// Get table name for known core extensions",
"$",
"table",
"=",
"$",
"tableInfo",
"[",
"$",
"extension",
"]",
"[",
"'table_name'",
"]",
";",
"// See if this category has any content items",
"$",
"count",
"=",
"$",
"this",
"->",
"_countItemsInCategory",
"(",
"$",
"table",
",",
"$",
"data",
"->",
"get",
"(",
"'id'",
")",
")",
";",
"// Return false if db error",
"if",
"(",
"$",
"count",
"===",
"false",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"else",
"{",
"// Show error if items are found in the category",
"if",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"msg",
"=",
"JText",
"::",
"sprintf",
"(",
"'COM_CATEGORIES_DELETE_NOT_ALLOWED'",
",",
"$",
"data",
"->",
"get",
"(",
"'title'",
")",
")",
".",
"JText",
"::",
"plural",
"(",
"'COM_CATEGORIES_N_ITEMS_ASSIGNED'",
",",
"$",
"count",
")",
";",
"JError",
"::",
"raiseWarning",
"(",
"403",
",",
"$",
"msg",
")",
";",
"$",
"result",
"=",
"false",
";",
"}",
"// Check for items in any child categories (if it is a leaf, there are no child categories)",
"if",
"(",
"!",
"$",
"data",
"->",
"isLeaf",
"(",
")",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"_countItemsInChildren",
"(",
"$",
"table",
",",
"$",
"data",
"->",
"get",
"(",
"'id'",
")",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"count",
"===",
"false",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"count",
">",
"0",
")",
"{",
"$",
"msg",
"=",
"JText",
"::",
"sprintf",
"(",
"'COM_CATEGORIES_DELETE_NOT_ALLOWED'",
",",
"$",
"data",
"->",
"get",
"(",
"'title'",
")",
")",
".",
"JText",
"::",
"plural",
"(",
"'COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS'",
",",
"$",
"count",
")",
";",
"JError",
"::",
"raiseWarning",
"(",
"403",
",",
"$",
"msg",
")",
";",
"$",
"result",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}",
"}"
] | Don't allow categories to be deleted if they contain items or subcategories with items
@param string $context The context for the content passed to the plugin.
@param object $data The data relating to the content that was deleted.
@return boolean
@since 1.6 | [
"Don",
"t",
"allow",
"categories",
"to",
"be",
"deleted",
"if",
"they",
"contain",
"items",
"or",
"subcategories",
"with",
"items"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/content/categories/categories.php#L29-L98 |
9,473 | joomlatools/joomlatools-platform-categories | plugins/content/categories/categories.php | PlgContentCategories._countItemsInCategory | private function _countItemsInCategory($table, $catid)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Count the items in this category
$query->select('COUNT(id)')
->from($table)
->where('catid = ' . $catid);
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
return $count;
} | php | private function _countItemsInCategory($table, $catid)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Count the items in this category
$query->select('COUNT(id)')
->from($table)
->where('catid = ' . $catid);
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
return $count;
} | [
"private",
"function",
"_countItemsInCategory",
"(",
"$",
"table",
",",
"$",
"catid",
")",
"{",
"$",
"db",
"=",
"JFactory",
"::",
"getDbo",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
";",
"// Count the items in this category",
"$",
"query",
"->",
"select",
"(",
"'COUNT(id)'",
")",
"->",
"from",
"(",
"$",
"table",
")",
"->",
"where",
"(",
"'catid = '",
".",
"$",
"catid",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"try",
"{",
"$",
"count",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"JError",
"::",
"raiseWarning",
"(",
"500",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"count",
";",
"}"
] | Get count of items in a category
@param string $table table name of component table (column is catid)
@param integer $catid id of the category to check
@return mixed count of items found or false if db error
@since 1.6 | [
"Get",
"count",
"of",
"items",
"in",
"a",
"category"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/content/categories/categories.php#L110-L133 |
9,474 | joomlatools/joomlatools-platform-categories | plugins/content/categories/categories.php | PlgContentCategories._countItemsInChildren | private function _countItemsInChildren($table, $catid, $data)
{
$db = JFactory::getDbo();
// Create subquery for list of child categories
$childCategoryTree = $data->getTree();
// First element in tree is the current category, so we can skip that one
unset($childCategoryTree[0]);
$childCategoryIds = array();
foreach ($childCategoryTree as $node)
{
$childCategoryIds[] = $node->id;
}
// Make sure we only do the query if we have some categories to look in
if (count($childCategoryIds))
{
// Count the items in this category
$query = $db->getQuery(true)
->select('COUNT(id)')
->from($table)
->where('catid IN (' . implode(',', $childCategoryIds) . ')');
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
return $count;
}
else
// If we didn't have any categories to check, return 0
{
return 0;
}
} | php | private function _countItemsInChildren($table, $catid, $data)
{
$db = JFactory::getDbo();
// Create subquery for list of child categories
$childCategoryTree = $data->getTree();
// First element in tree is the current category, so we can skip that one
unset($childCategoryTree[0]);
$childCategoryIds = array();
foreach ($childCategoryTree as $node)
{
$childCategoryIds[] = $node->id;
}
// Make sure we only do the query if we have some categories to look in
if (count($childCategoryIds))
{
// Count the items in this category
$query = $db->getQuery(true)
->select('COUNT(id)')
->from($table)
->where('catid IN (' . implode(',', $childCategoryIds) . ')');
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
return $count;
}
else
// If we didn't have any categories to check, return 0
{
return 0;
}
} | [
"private",
"function",
"_countItemsInChildren",
"(",
"$",
"table",
",",
"$",
"catid",
",",
"$",
"data",
")",
"{",
"$",
"db",
"=",
"JFactory",
"::",
"getDbo",
"(",
")",
";",
"// Create subquery for list of child categories",
"$",
"childCategoryTree",
"=",
"$",
"data",
"->",
"getTree",
"(",
")",
";",
"// First element in tree is the current category, so we can skip that one",
"unset",
"(",
"$",
"childCategoryTree",
"[",
"0",
"]",
")",
";",
"$",
"childCategoryIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"childCategoryTree",
"as",
"$",
"node",
")",
"{",
"$",
"childCategoryIds",
"[",
"]",
"=",
"$",
"node",
"->",
"id",
";",
"}",
"// Make sure we only do the query if we have some categories to look in",
"if",
"(",
"count",
"(",
"$",
"childCategoryIds",
")",
")",
"{",
"// Count the items in this category",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'COUNT(id)'",
")",
"->",
"from",
"(",
"$",
"table",
")",
"->",
"where",
"(",
"'catid IN ('",
".",
"implode",
"(",
"','",
",",
"$",
"childCategoryIds",
")",
".",
"')'",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"try",
"{",
"$",
"count",
"=",
"$",
"db",
"->",
"loadResult",
"(",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"JError",
"::",
"raiseWarning",
"(",
"500",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"count",
";",
"}",
"else",
"// If we didn't have any categories to check, return 0",
"{",
"return",
"0",
";",
"}",
"}"
] | Get count of items in a category's child categories
@param string $table table name of component table (column is catid)
@param integer $catid id of the category to check
@param object $data The data relating to the content that was deleted.
@return mixed count of items found or false if db error
@since 1.6 | [
"Get",
"count",
"of",
"items",
"in",
"a",
"category",
"s",
"child",
"categories"
] | 9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350 | https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/plugins/content/categories/categories.php#L146-L190 |
9,475 | easy-system/es-router | src/Router.php | Router.add | public function add($name, RouteInterface $route)
{
$this->routes[(string) $name] = $route;
return $this;
} | php | public function add($name, RouteInterface $route)
{
$this->routes[(string) $name] = $route;
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"name",
",",
"RouteInterface",
"$",
"route",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"(",
"string",
")",
"$",
"name",
"]",
"=",
"$",
"route",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the route.
@param string $name The route name
@param RouteInterface $route The instance of route
@return self | [
"Adds",
"the",
"route",
"."
] | 79d56967839d5e2e9543349190edd3539dab6211 | https://github.com/easy-system/es-router/blob/79d56967839d5e2e9543349190edd3539dab6211/src/Router.php#L91-L96 |
9,476 | easy-system/es-router | src/Router.php | Router.remove | public function remove($name)
{
if (isset($this->routes[$name])) {
unset($this->routes[$name]);
}
return $this;
} | php | public function remove($name)
{
if (isset($this->routes[$name])) {
unset($this->routes[$name]);
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes the route.
@param string $name The route name
@return self | [
"Removes",
"the",
"route",
"."
] | 79d56967839d5e2e9543349190edd3539dab6211 | https://github.com/easy-system/es-router/blob/79d56967839d5e2e9543349190edd3539dab6211/src/Router.php#L117-L124 |
9,477 | easy-system/es-router | src/Router.php | Router.get | public function get($name)
{
if (! isset($this->routes[$name])) {
throw new InvalidArgumentException(
sprintf('The route with given name "%s" not exists.', $name)
);
}
return $this->routes[$name];
} | php | public function get($name)
{
if (! isset($this->routes[$name])) {
throw new InvalidArgumentException(
sprintf('The route with given name "%s" not exists.', $name)
);
}
return $this->routes[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The route with given name \"%s\" not exists.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
";",
"}"
] | Gets the route.
@param string $name The route name
@throws \InvalidArgumentException If the route with given name not exists
@return RouteInterface The route | [
"Gets",
"the",
"route",
"."
] | 79d56967839d5e2e9543349190edd3539dab6211 | https://github.com/easy-system/es-router/blob/79d56967839d5e2e9543349190edd3539dab6211/src/Router.php#L135-L144 |
9,478 | easy-system/es-router | src/Router.php | Router.merge | public function merge(RouterInterface $source = null)
{
if (null == $source) {
return [
$this->routes,
$this->defaultParams,
];
}
list($routes, $params) = $source->merge();
$this->routes = array_merge($this->routes, $routes);
$this->defaultParams = array_merge($this->defaultParams, $params);
} | php | public function merge(RouterInterface $source = null)
{
if (null == $source) {
return [
$this->routes,
$this->defaultParams,
];
}
list($routes, $params) = $source->merge();
$this->routes = array_merge($this->routes, $routes);
$this->defaultParams = array_merge($this->defaultParams, $params);
} | [
"public",
"function",
"merge",
"(",
"RouterInterface",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"source",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"routes",
",",
"$",
"this",
"->",
"defaultParams",
",",
"]",
";",
"}",
"list",
"(",
"$",
"routes",
",",
"$",
"params",
")",
"=",
"$",
"source",
"->",
"merge",
"(",
")",
";",
"$",
"this",
"->",
"routes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"routes",
",",
"$",
"routes",
")",
";",
"$",
"this",
"->",
"defaultParams",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaultParams",
",",
"$",
"params",
")",
";",
"}"
] | Merges with other router.
@param RouterInterface $source The data source
@return null|array If the source was passed returns
null, source data otherwise | [
"Merges",
"with",
"other",
"router",
"."
] | 79d56967839d5e2e9543349190edd3539dab6211 | https://github.com/easy-system/es-router/blob/79d56967839d5e2e9543349190edd3539dab6211/src/Router.php#L253-L265 |
9,479 | phonetworks/pho-lib-graphql-parser | src/Pho/Lib/GraphQL/Parser/Definitions/AbstractDefinition.php | AbstractDefinition._retrieveAll | protected function _retrieveAll(string $internally, string $graphql, string $class): array
{
if(isset($this->$internally)) {
return $this->$internally;
}
$sought = $this->def[$graphql];
if(!is_array($sought)) {
$this->$internally = [];
return [];
}
$class = "\\".__NAMESPACE__."\\".$class;
foreach($sought as $s) {
$this->$internally[] = new $class($s);
}
return $this->$internally;
} | php | protected function _retrieveAll(string $internally, string $graphql, string $class): array
{
if(isset($this->$internally)) {
return $this->$internally;
}
$sought = $this->def[$graphql];
if(!is_array($sought)) {
$this->$internally = [];
return [];
}
$class = "\\".__NAMESPACE__."\\".$class;
foreach($sought as $s) {
$this->$internally[] = new $class($s);
}
return $this->$internally;
} | [
"protected",
"function",
"_retrieveAll",
"(",
"string",
"$",
"internally",
",",
"string",
"$",
"graphql",
",",
"string",
"$",
"class",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"internally",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"internally",
";",
"}",
"$",
"sought",
"=",
"$",
"this",
"->",
"def",
"[",
"$",
"graphql",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"sought",
")",
")",
"{",
"$",
"this",
"->",
"$",
"internally",
"=",
"[",
"]",
";",
"return",
"[",
"]",
";",
"}",
"$",
"class",
"=",
"\"\\\\\"",
".",
"__NAMESPACE__",
".",
"\"\\\\\"",
".",
"$",
"class",
";",
"foreach",
"(",
"$",
"sought",
"as",
"$",
"s",
")",
"{",
"$",
"this",
"->",
"$",
"internally",
"[",
"]",
"=",
"new",
"$",
"class",
"(",
"$",
"s",
")",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"internally",
";",
"}"
] | A helper method to retrieve an array of a specific type from the given GraphQL definition.
@param string $internally What the object in question is called internally.
@param string $graphql What the object in question is called in GraphQL definition AST.
@param string $class What class the object in question is associated within this parser.
@return array An array of objects in question. | [
"A",
"helper",
"method",
"to",
"retrieve",
"an",
"array",
"of",
"a",
"specific",
"type",
"from",
"the",
"given",
"GraphQL",
"definition",
"."
] | d13ec938bce8b7703d77c8365c175bac7178dd73 | https://github.com/phonetworks/pho-lib-graphql-parser/blob/d13ec938bce8b7703d77c8365c175bac7178dd73/src/Pho/Lib/GraphQL/Parser/Definitions/AbstractDefinition.php#L54-L69 |
9,480 | phonetworks/pho-lib-graphql-parser | src/Pho/Lib/GraphQL/Parser/Definitions/AbstractDefinition.php | AbstractDefinition._retrieveOne | protected function _retrieveOne(string $internally, string $graphql, string $class, int $n) // : mixed
{
if(isset($this->$internally[$n])) {
return $this->$internally[$n];
}
if(isset($this->def[$graphql][$n])) {
$class = "\\".__NAMESPACE__."\\".$class;
return new $class($this->def[$graphql][$n]);
}
return new $class();
} | php | protected function _retrieveOne(string $internally, string $graphql, string $class, int $n) // : mixed
{
if(isset($this->$internally[$n])) {
return $this->$internally[$n];
}
if(isset($this->def[$graphql][$n])) {
$class = "\\".__NAMESPACE__."\\".$class;
return new $class($this->def[$graphql][$n]);
}
return new $class();
} | [
"protected",
"function",
"_retrieveOne",
"(",
"string",
"$",
"internally",
",",
"string",
"$",
"graphql",
",",
"string",
"$",
"class",
",",
"int",
"$",
"n",
")",
"// : mixed",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"$",
"internally",
"[",
"$",
"n",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"internally",
"[",
"$",
"n",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"def",
"[",
"$",
"graphql",
"]",
"[",
"$",
"n",
"]",
")",
")",
"{",
"$",
"class",
"=",
"\"\\\\\"",
".",
"__NAMESPACE__",
".",
"\"\\\\\"",
".",
"$",
"class",
";",
"return",
"new",
"$",
"class",
"(",
"$",
"this",
"->",
"def",
"[",
"$",
"graphql",
"]",
"[",
"$",
"n",
"]",
")",
";",
"}",
"return",
"new",
"$",
"class",
"(",
")",
";",
"}"
] | A helper method to retrieve a single object of a specific type, at given position,
from the given GraphQL definition.
@param string $internally What the object in question is called internally.
@param string $graphql What the object in question is called in GraphQL definition AST.
@param string $class What class the object in question is associated within this parser.
@param int $n Position.
@return mixed A parser definition type as defined by the 3rd parameter of this method. | [
"A",
"helper",
"method",
"to",
"retrieve",
"a",
"single",
"object",
"of",
"a",
"specific",
"type",
"at",
"given",
"position",
"from",
"the",
"given",
"GraphQL",
"definition",
"."
] | d13ec938bce8b7703d77c8365c175bac7178dd73 | https://github.com/phonetworks/pho-lib-graphql-parser/blob/d13ec938bce8b7703d77c8365c175bac7178dd73/src/Pho/Lib/GraphQL/Parser/Definitions/AbstractDefinition.php#L82-L92 |
9,481 | tsommie/eloquent-search | src/EloquentSearchTrait.php | EloquentSearchTrait.scopeSearch | public function scopeSearch($query, $keyword)
{
$columns = $this->searchColumns();
foreach ($columns as $column) {
if ($columns === reset($columns)) {
$query->where($column, 'like', "%{$keyword}%");
}
$query->orWhere($column, 'like', "%{$keyword}%");
}
return $query;
} | php | public function scopeSearch($query, $keyword)
{
$columns = $this->searchColumns();
foreach ($columns as $column) {
if ($columns === reset($columns)) {
$query->where($column, 'like', "%{$keyword}%");
}
$query->orWhere($column, 'like', "%{$keyword}%");
}
return $query;
} | [
"public",
"function",
"scopeSearch",
"(",
"$",
"query",
",",
"$",
"keyword",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"searchColumns",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"columns",
"===",
"reset",
"(",
"$",
"columns",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"column",
",",
"'like'",
",",
"\"%{$keyword}%\"",
")",
";",
"}",
"$",
"query",
"->",
"orWhere",
"(",
"$",
"column",
",",
"'like'",
",",
"\"%{$keyword}%\"",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] | Scope a query to search for a keyword.
@param \Illuminate\Database\Eloquent\Builder $query
@param string $keyword
@return \Illuminate\Database\Eloquent\Builder | [
"Scope",
"a",
"query",
"to",
"search",
"for",
"a",
"keyword",
"."
] | 91d4e859227f04dfc324c2c89cc0a31f08bbfd74 | https://github.com/tsommie/eloquent-search/blob/91d4e859227f04dfc324c2c89cc0a31f08bbfd74/src/EloquentSearchTrait.php#L20-L36 |
9,482 | jeromeklam/freefw | src/FreeFW/Tools/PBXString.php | PBXString.parse | public static function parse($p_string, $p_data = array(), $p_regex = null)
{
if (! is_array($p_data)) {
if (is_object($p_data) && method_exists($p_data, '__toArray')) {
$datas = $p_data->__toArray();
}
} else {
$datas = $p_data;
}
if ($p_regex === null) {
$p_regex = self::REGEX_PARAM_PLACEHOLDER;
}
if (0 < preg_match_all($p_regex, $p_string, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = '';
if (array_key_exists($match[1], $datas)) {
$replace = $datas[$match[1]];
}
$p_string = str_replace(
$match[0],
$replace,
$p_string
);
}
return self::parse($p_string, $datas, $p_regex);
}
return $p_string;
} | php | public static function parse($p_string, $p_data = array(), $p_regex = null)
{
if (! is_array($p_data)) {
if (is_object($p_data) && method_exists($p_data, '__toArray')) {
$datas = $p_data->__toArray();
}
} else {
$datas = $p_data;
}
if ($p_regex === null) {
$p_regex = self::REGEX_PARAM_PLACEHOLDER;
}
if (0 < preg_match_all($p_regex, $p_string, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
$replace = '';
if (array_key_exists($match[1], $datas)) {
$replace = $datas[$match[1]];
}
$p_string = str_replace(
$match[0],
$replace,
$p_string
);
}
return self::parse($p_string, $datas, $p_regex);
}
return $p_string;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"p_string",
",",
"$",
"p_data",
"=",
"array",
"(",
")",
",",
"$",
"p_regex",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"p_data",
")",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"p_data",
")",
"&&",
"method_exists",
"(",
"$",
"p_data",
",",
"'__toArray'",
")",
")",
"{",
"$",
"datas",
"=",
"$",
"p_data",
"->",
"__toArray",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"datas",
"=",
"$",
"p_data",
";",
"}",
"if",
"(",
"$",
"p_regex",
"===",
"null",
")",
"{",
"$",
"p_regex",
"=",
"self",
"::",
"REGEX_PARAM_PLACEHOLDER",
";",
"}",
"if",
"(",
"0",
"<",
"preg_match_all",
"(",
"$",
"p_regex",
",",
"$",
"p_string",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"match",
")",
"{",
"$",
"replace",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"$",
"datas",
")",
")",
"{",
"$",
"replace",
"=",
"$",
"datas",
"[",
"$",
"match",
"[",
"1",
"]",
"]",
";",
"}",
"$",
"p_string",
"=",
"str_replace",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"$",
"replace",
",",
"$",
"p_string",
")",
";",
"}",
"return",
"self",
"::",
"parse",
"(",
"$",
"p_string",
",",
"$",
"datas",
",",
"$",
"p_regex",
")",
";",
"}",
"return",
"$",
"p_string",
";",
"}"
] | Parse et remplace suivant les marqueur
@param string $p_string
@param array $p_data
@param string $p_regex
@return string | [
"Parse",
"et",
"remplace",
"suivant",
"les",
"marqueur"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/PBXString.php#L34-L63 |
9,483 | jeromeklam/freefw | src/FreeFW/Tools/PBXString.php | PBXString.toCamelCase | public static function toCamelCase($p_str, $p_first = false, $p_glue = '_')
{
if (trim($p_str) == '') {
return $p_str;
}
if ($p_first) {
$p_str[0] = strtoupper($p_str[0]);
}
return preg_replace_callback(
"|{$p_glue}([a-z])|",
function ($matches) use ($p_glue) {
return str_replace($p_glue, '', strtoupper($matches[0]));
},
$p_str
);
} | php | public static function toCamelCase($p_str, $p_first = false, $p_glue = '_')
{
if (trim($p_str) == '') {
return $p_str;
}
if ($p_first) {
$p_str[0] = strtoupper($p_str[0]);
}
return preg_replace_callback(
"|{$p_glue}([a-z])|",
function ($matches) use ($p_glue) {
return str_replace($p_glue, '', strtoupper($matches[0]));
},
$p_str
);
} | [
"public",
"static",
"function",
"toCamelCase",
"(",
"$",
"p_str",
",",
"$",
"p_first",
"=",
"false",
",",
"$",
"p_glue",
"=",
"'_'",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"p_str",
")",
"==",
"''",
")",
"{",
"return",
"$",
"p_str",
";",
"}",
"if",
"(",
"$",
"p_first",
")",
"{",
"$",
"p_str",
"[",
"0",
"]",
"=",
"strtoupper",
"(",
"$",
"p_str",
"[",
"0",
"]",
")",
";",
"}",
"return",
"preg_replace_callback",
"(",
"\"|{$p_glue}([a-z])|\"",
",",
"function",
"(",
"$",
"matches",
")",
"use",
"(",
"$",
"p_glue",
")",
"{",
"return",
"str_replace",
"(",
"$",
"p_glue",
",",
"''",
",",
"strtoupper",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
")",
";",
"}",
",",
"$",
"p_str",
")",
";",
"}"
] | Conversion en CamelCase
@param string $p_str
@param boolean $p_first
@param string $p_glue
@return string | [
"Conversion",
"en",
"CamelCase"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/PBXString.php#L74-L89 |
9,484 | jeromeklam/freefw | src/FreeFW/Tools/PBXString.php | PBXString.removeComments | public static function removeComments($output)
{
$lines = explode("\n", $output);
$output = "";
// try to keep mem. use down
$linecount = count($lines);
$in_comment = false;
for ($i=0; $i<$linecount; $i++) {
if (preg_match("/^\/\*/", $lines[$i])) {
$in_comment = true;
}
if (!$in_comment) {
$output .= $lines[$i] . "\n";
}
if (preg_match("/\*\/$/", $lines[$i])) {
$in_comment = false;
}
}
unset($lines);
return $output;
} | php | public static function removeComments($output)
{
$lines = explode("\n", $output);
$output = "";
// try to keep mem. use down
$linecount = count($lines);
$in_comment = false;
for ($i=0; $i<$linecount; $i++) {
if (preg_match("/^\/\*/", $lines[$i])) {
$in_comment = true;
}
if (!$in_comment) {
$output .= $lines[$i] . "\n";
}
if (preg_match("/\*\/$/", $lines[$i])) {
$in_comment = false;
}
}
unset($lines);
return $output;
} | [
"public",
"static",
"function",
"removeComments",
"(",
"$",
"output",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
";",
"$",
"output",
"=",
"\"\"",
";",
"// try to keep mem. use down",
"$",
"linecount",
"=",
"count",
"(",
"$",
"lines",
")",
";",
"$",
"in_comment",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"linecount",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^\\/\\*/\"",
",",
"$",
"lines",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"in_comment",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"in_comment",
")",
"{",
"$",
"output",
".=",
"$",
"lines",
"[",
"$",
"i",
"]",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"preg_match",
"(",
"\"/\\*\\/$/\"",
",",
"$",
"lines",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"in_comment",
"=",
"false",
";",
"}",
"}",
"unset",
"(",
"$",
"lines",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Remove comments from string
@param string $output
@return string | [
"Remove",
"comments",
"from",
"string"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/PBXString.php#L148-L168 |
9,485 | jeromeklam/freefw | src/FreeFW/Tools/PBXString.php | PBXString.jsonToList | public static function jsonToList($p_json)
{
$str = '';
$arr = json_decode($p_json, true);
foreach ($arr as $key => $value) {
if ($str == '') {
$str = $str . $key . '=' . $value;
} else {
$str = $str . ', ' . $key . '=' . $value;
}
}
return $str;
} | php | public static function jsonToList($p_json)
{
$str = '';
$arr = json_decode($p_json, true);
foreach ($arr as $key => $value) {
if ($str == '') {
$str = $str . $key . '=' . $value;
} else {
$str = $str . ', ' . $key . '=' . $value;
}
}
return $str;
} | [
"public",
"static",
"function",
"jsonToList",
"(",
"$",
"p_json",
")",
"{",
"$",
"str",
"=",
"''",
";",
"$",
"arr",
"=",
"json_decode",
"(",
"$",
"p_json",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"str",
"==",
"''",
")",
"{",
"$",
"str",
"=",
"$",
"str",
".",
"$",
"key",
".",
"'='",
".",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"str",
"=",
"$",
"str",
".",
"', '",
".",
"$",
"key",
".",
"'='",
".",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"str",
";",
"}"
] | Transforme un json en liste
@return string | [
"Transforme",
"un",
"json",
"en",
"liste"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/PBXString.php#L224-L237 |
9,486 | jeromeklam/freefw | src/FreeFW/Tools/PBXString.php | PBXString.hidePart | public static function hidePart($p_string, $p_replace = 'X', $p_left = 4, $p_right = 4)
{
$len = strlen($p_string);
$str = substr($p_string, 0, $p_left) .
str_pad('', $len - $p_left - $p_right, $p_replace) .
substr($p_string, $len - $p_right);
return $str;
} | php | public static function hidePart($p_string, $p_replace = 'X', $p_left = 4, $p_right = 4)
{
$len = strlen($p_string);
$str = substr($p_string, 0, $p_left) .
str_pad('', $len - $p_left - $p_right, $p_replace) .
substr($p_string, $len - $p_right);
return $str;
} | [
"public",
"static",
"function",
"hidePart",
"(",
"$",
"p_string",
",",
"$",
"p_replace",
"=",
"'X'",
",",
"$",
"p_left",
"=",
"4",
",",
"$",
"p_right",
"=",
"4",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"p_string",
")",
";",
"$",
"str",
"=",
"substr",
"(",
"$",
"p_string",
",",
"0",
",",
"$",
"p_left",
")",
".",
"str_pad",
"(",
"''",
",",
"$",
"len",
"-",
"$",
"p_left",
"-",
"$",
"p_right",
",",
"$",
"p_replace",
")",
".",
"substr",
"(",
"$",
"p_string",
",",
"$",
"len",
"-",
"$",
"p_right",
")",
";",
"return",
"$",
"str",
";",
"}"
] | Hide part of string with a caracter
@param string $p_string
@param string $p_replace
@param number $p_left
@param number $p_right
@return string | [
"Hide",
"part",
"of",
"string",
"with",
"a",
"caracter"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/PBXString.php#L321-L328 |
9,487 | mothepro/MoCompiler | src/Constants.php | Constants.run | public function run($require = false) {
foreach($this->const as $name => $val)
define(self::nameEncode($name, self::NAMESPACE_SEPERATOR), self::encode($val) );
foreach($this->ini as $name => $val)
ini_set(self::nameEncode($name, self::INI_SEPERATOR), self::encode($val) );
$GLOBALS["constants"] = $this->public;
if($require)
foreach($this->require as $file)
require $file;
} | php | public function run($require = false) {
foreach($this->const as $name => $val)
define(self::nameEncode($name, self::NAMESPACE_SEPERATOR), self::encode($val) );
foreach($this->ini as $name => $val)
ini_set(self::nameEncode($name, self::INI_SEPERATOR), self::encode($val) );
$GLOBALS["constants"] = $this->public;
if($require)
foreach($this->require as $file)
require $file;
} | [
"public",
"function",
"run",
"(",
"$",
"require",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"const",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"define",
"(",
"self",
"::",
"nameEncode",
"(",
"$",
"name",
",",
"self",
"::",
"NAMESPACE_SEPERATOR",
")",
",",
"self",
"::",
"encode",
"(",
"$",
"val",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"ini",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"ini_set",
"(",
"self",
"::",
"nameEncode",
"(",
"$",
"name",
",",
"self",
"::",
"INI_SEPERATOR",
")",
",",
"self",
"::",
"encode",
"(",
"$",
"val",
")",
")",
";",
"$",
"GLOBALS",
"[",
"\"constants\"",
"]",
"=",
"$",
"this",
"->",
"public",
";",
"if",
"(",
"$",
"require",
")",
"foreach",
"(",
"$",
"this",
"->",
"require",
"as",
"$",
"file",
")",
"require",
"$",
"file",
";",
"}"
] | Adds the constants for the current app
@param boolean $require Whether to require the files | [
"Adds",
"the",
"constants",
"for",
"the",
"current",
"app"
] | bedc26fe9f11fbd87bc062175deba95051c7b9b0 | https://github.com/mothepro/MoCompiler/blob/bedc26fe9f11fbd87bc062175deba95051c7b9b0/src/Constants.php#L170-L182 |
9,488 | gibboncms/liana-core | src/Liana.php | Liana.prepareForConsoleCommand | public function prepareForConsoleCommand()
{
$this->withFacades();
$this->make('cache');
$this->make('queue');
$this->configure('database');
$this->register('Illuminate\Queue\ConsoleServiceProvider');
} | php | public function prepareForConsoleCommand()
{
$this->withFacades();
$this->make('cache');
$this->make('queue');
$this->configure('database');
$this->register('Illuminate\Queue\ConsoleServiceProvider');
} | [
"public",
"function",
"prepareForConsoleCommand",
"(",
")",
"{",
"$",
"this",
"->",
"withFacades",
"(",
")",
";",
"$",
"this",
"->",
"make",
"(",
"'cache'",
")",
";",
"$",
"this",
"->",
"make",
"(",
"'queue'",
")",
";",
"$",
"this",
"->",
"configure",
"(",
"'database'",
")",
";",
"$",
"this",
"->",
"register",
"(",
"'Illuminate\\Queue\\ConsoleServiceProvider'",
")",
";",
"}"
] | Prepare the application to execute a console command.
Removed migration and seeding providers
@return void | [
"Prepare",
"the",
"application",
"to",
"execute",
"a",
"console",
"command",
".",
"Removed",
"migration",
"and",
"seeding",
"providers"
] | f76af9ecd5bf35ca5c55ff4f638008c2fd41ecaf | https://github.com/gibboncms/liana-core/blob/f76af9ecd5bf35ca5c55ff4f638008c2fd41ecaf/src/Liana.php#L34-L44 |
9,489 | jivoo/core | src/Parse/ParseInput.php | ParseInput.pop | public function pop()
{
if (isset($this->input[$this->pos])) {
return $this->input[$this->pos ++];
}
return null;
} | php | public function pop()
{
if (isset($this->input[$this->pos])) {
return $this->input[$this->pos ++];
}
return null;
} | [
"public",
"function",
"pop",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"input",
"[",
"$",
"this",
"->",
"pos",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"input",
"[",
"$",
"this",
"->",
"pos",
"++",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Return the current element and advance the sequence position.
@return mxied|null The element or null if end of sequence. | [
"Return",
"the",
"current",
"element",
"and",
"advance",
"the",
"sequence",
"position",
"."
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Parse/ParseInput.php#L73-L79 |
9,490 | lrc-se/bth-anax-repository | src/Repository/RepositoryManager.php | RepositoryManager.createRepository | public function createRepository($model, $config)
{
$defaults = [
'type' => 'db-soft',
'key' => 'id',
'deleted' => 'deleted'
];
$config = array_merge($defaults, $config);
switch ($config['type']) {
case 'db':
$repo = new DbRepository($config['db'], $config['table'], $model, $config['key']);
break;
case 'db-soft':
$repo = new SoftDbRepository($config['db'], $config['table'], $model, $config['deleted'], $config['key']);
break;
default:
throw new RepositoryException("Repository type '" . $config['type'] . "' not implemented");
}
$this->addRepository($repo);
return $repo;
} | php | public function createRepository($model, $config)
{
$defaults = [
'type' => 'db-soft',
'key' => 'id',
'deleted' => 'deleted'
];
$config = array_merge($defaults, $config);
switch ($config['type']) {
case 'db':
$repo = new DbRepository($config['db'], $config['table'], $model, $config['key']);
break;
case 'db-soft':
$repo = new SoftDbRepository($config['db'], $config['table'], $model, $config['deleted'], $config['key']);
break;
default:
throw new RepositoryException("Repository type '" . $config['type'] . "' not implemented");
}
$this->addRepository($repo);
return $repo;
} | [
"public",
"function",
"createRepository",
"(",
"$",
"model",
",",
"$",
"config",
")",
"{",
"$",
"defaults",
"=",
"[",
"'type'",
"=>",
"'db-soft'",
",",
"'key'",
"=>",
"'id'",
",",
"'deleted'",
"=>",
"'deleted'",
"]",
";",
"$",
"config",
"=",
"array_merge",
"(",
"$",
"defaults",
",",
"$",
"config",
")",
";",
"switch",
"(",
"$",
"config",
"[",
"'type'",
"]",
")",
"{",
"case",
"'db'",
":",
"$",
"repo",
"=",
"new",
"DbRepository",
"(",
"$",
"config",
"[",
"'db'",
"]",
",",
"$",
"config",
"[",
"'table'",
"]",
",",
"$",
"model",
",",
"$",
"config",
"[",
"'key'",
"]",
")",
";",
"break",
";",
"case",
"'db-soft'",
":",
"$",
"repo",
"=",
"new",
"SoftDbRepository",
"(",
"$",
"config",
"[",
"'db'",
"]",
",",
"$",
"config",
"[",
"'table'",
"]",
",",
"$",
"model",
",",
"$",
"config",
"[",
"'deleted'",
"]",
",",
"$",
"config",
"[",
"'key'",
"]",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"RepositoryException",
"(",
"\"Repository type '\"",
".",
"$",
"config",
"[",
"'type'",
"]",
".",
"\"' not implemented\"",
")",
";",
"}",
"$",
"this",
"->",
"addRepository",
"(",
"$",
"repo",
")",
";",
"return",
"$",
"repo",
";",
"}"
] | Create a new repository and add it to the manager.
@param string $model Model class.
@param array $config Repository configuration.
@return ManagedRepository The created repository.
@throws RepositoryException If the requested repository type is not implemented. | [
"Create",
"a",
"new",
"repository",
"and",
"add",
"it",
"to",
"the",
"manager",
"."
] | 344a0795fbfadf34ea768719dc5cf2f1d90154df | https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/RepositoryManager.php#L26-L48 |
9,491 | lrc-se/bth-anax-repository | src/Repository/RepositoryManager.php | RepositoryManager.addRepository | public function addRepository($repository)
{
$class = $repository->getModelClass();
if ($this->getByClass($class)) {
throw new RepositoryException("The manager already contains a repository for the model class '$class'");
}
$repository->setManager($this);
$this->repositories[$class] = $repository;
} | php | public function addRepository($repository)
{
$class = $repository->getModelClass();
if ($this->getByClass($class)) {
throw new RepositoryException("The manager already contains a repository for the model class '$class'");
}
$repository->setManager($this);
$this->repositories[$class] = $repository;
} | [
"public",
"function",
"addRepository",
"(",
"$",
"repository",
")",
"{",
"$",
"class",
"=",
"$",
"repository",
"->",
"getModelClass",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getByClass",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"RepositoryException",
"(",
"\"The manager already contains a repository for the model class '$class'\"",
")",
";",
"}",
"$",
"repository",
"->",
"setManager",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"repositories",
"[",
"$",
"class",
"]",
"=",
"$",
"repository",
";",
"}"
] | Register a repository with the manager.
@param ManagedRepository $repository Manageable repository.
@throws RepositoryException If the manager already contains a repository for the same model class. | [
"Register",
"a",
"repository",
"with",
"the",
"manager",
"."
] | 344a0795fbfadf34ea768719dc5cf2f1d90154df | https://github.com/lrc-se/bth-anax-repository/blob/344a0795fbfadf34ea768719dc5cf2f1d90154df/src/Repository/RepositoryManager.php#L58-L67 |
9,492 | n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListEntry.php | Zend_Gdata_Spreadsheets_ListEntry.getCustomByName | public function getCustomByName($name = null)
{
if ($name === null) {
return $this->_customByName;
} else {
if (array_key_exists($name, $this->customByName)) {
return $this->_customByName[$name];
} else {
return null;
}
}
} | php | public function getCustomByName($name = null)
{
if ($name === null) {
return $this->_customByName;
} else {
if (array_key_exists($name, $this->customByName)) {
return $this->_customByName[$name];
} else {
return null;
}
}
} | [
"public",
"function",
"getCustomByName",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_customByName",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"customByName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_customByName",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"}"
] | Gets a single row element contained by this list entry using its name.
@param string $name The name of a custom element to return. If null
or not defined, an array containing all custom elements
indexed by name will be returned.
@return mixed If a name is specified, the
Zend_Gdata_Spreadsheets_Extension_Custom element requested,
is returned or null if not found. Otherwise, an array of all
Zend_Gdata_Spreadsheets_Extension_Custom elements is returned
indexed by name. | [
"Gets",
"a",
"single",
"row",
"element",
"contained",
"by",
"this",
"list",
"entry",
"using",
"its",
"name",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListEntry.php#L117-L128 |
9,493 | n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListEntry.php | Zend_Gdata_Spreadsheets_ListEntry.setCustom | public function setCustom($custom)
{
$this->_custom = array();
foreach ($custom as $c) {
$this->addCustom($c);
}
return $this;
} | php | public function setCustom($custom)
{
$this->_custom = array();
foreach ($custom as $c) {
$this->addCustom($c);
}
return $this;
} | [
"public",
"function",
"setCustom",
"(",
"$",
"custom",
")",
"{",
"$",
"this",
"->",
"_custom",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"custom",
"as",
"$",
"c",
")",
"{",
"$",
"this",
"->",
"addCustom",
"(",
"$",
"c",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the row elements contained by this list entry. If any
custom row elements were previously stored, they will be overwritten.
@param array $custom The custom row elements to be contained in this
list entry.
@return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface. | [
"Sets",
"the",
"row",
"elements",
"contained",
"by",
"this",
"list",
"entry",
".",
"If",
"any",
"custom",
"row",
"elements",
"were",
"previously",
"stored",
"they",
"will",
"be",
"overwritten",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListEntry.php#L137-L144 |
9,494 | n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListEntry.php | Zend_Gdata_Spreadsheets_ListEntry.addCustom | public function addCustom($custom)
{
$this->_custom[] = $custom;
$this->_customByName[$custom->getColumnName()] = $custom;
return $this;
} | php | public function addCustom($custom)
{
$this->_custom[] = $custom;
$this->_customByName[$custom->getColumnName()] = $custom;
return $this;
} | [
"public",
"function",
"addCustom",
"(",
"$",
"custom",
")",
"{",
"$",
"this",
"->",
"_custom",
"[",
"]",
"=",
"$",
"custom",
";",
"$",
"this",
"->",
"_customByName",
"[",
"$",
"custom",
"->",
"getColumnName",
"(",
")",
"]",
"=",
"$",
"custom",
";",
"return",
"$",
"this",
";",
"}"
] | Add an individual custom row element to this list entry.
@param Zend_Gdata_Spreadsheets_Extension_Custom $custom The custom
element to be added.
@return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface. | [
"Add",
"an",
"individual",
"custom",
"row",
"element",
"to",
"this",
"list",
"entry",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListEntry.php#L152-L157 |
9,495 | n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListEntry.php | Zend_Gdata_Spreadsheets_ListEntry.removeCustom | public function removeCustom($index)
{
if (array_key_exists($index, $this->_custom)) {
$element = $this->_custom[$index];
// Remove element
unset($this->_custom[$index]);
// Re-index the array
$this->_custom = array_values($this->_custom);
// Be sure to delete form both arrays!
$key = array_search($element, $this->_customByName);
unset($this->_customByName[$key]);
} else {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Element does not exist.');
}
return $this;
} | php | public function removeCustom($index)
{
if (array_key_exists($index, $this->_custom)) {
$element = $this->_custom[$index];
// Remove element
unset($this->_custom[$index]);
// Re-index the array
$this->_custom = array_values($this->_custom);
// Be sure to delete form both arrays!
$key = array_search($element, $this->_customByName);
unset($this->_customByName[$key]);
} else {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Element does not exist.');
}
return $this;
} | [
"public",
"function",
"removeCustom",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"_custom",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"_custom",
"[",
"$",
"index",
"]",
";",
"// Remove element",
"unset",
"(",
"$",
"this",
"->",
"_custom",
"[",
"$",
"index",
"]",
")",
";",
"// Re-index the array",
"$",
"this",
"->",
"_custom",
"=",
"array_values",
"(",
"$",
"this",
"->",
"_custom",
")",
";",
"// Be sure to delete form both arrays!",
"$",
"key",
"=",
"array_search",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"_customByName",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_customByName",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Element does not exist.'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove an individual row element from this list entry by index. This
will cause the array to be re-indexed.
@param int $index The index of the custom element to be deleted.
@return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface.
@throws Zend_Gdata_App_InvalidArgumentException | [
"Remove",
"an",
"individual",
"row",
"element",
"from",
"this",
"list",
"entry",
"by",
"index",
".",
"This",
"will",
"cause",
"the",
"array",
"to",
"be",
"re",
"-",
"indexed",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListEntry.php#L166-L183 |
9,496 | n0m4dz/laracasa | Zend/Gdata/Spreadsheets/ListEntry.php | Zend_Gdata_Spreadsheets_ListEntry.removeCustomByName | public function removeCustomByName($name)
{
if (array_key_exists($name, $this->_customByName)) {
$element = $this->_customByName[$name];
// Remove element
unset($this->_customByName[$name]);
// Be sure to delete from both arrays!
$key = array_search($element, $this->_custom);
unset($this->_custom[$key]);
} else {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Element does not exist.');
}
return $this;
} | php | public function removeCustomByName($name)
{
if (array_key_exists($name, $this->_customByName)) {
$element = $this->_customByName[$name];
// Remove element
unset($this->_customByName[$name]);
// Be sure to delete from both arrays!
$key = array_search($element, $this->_custom);
unset($this->_custom[$key]);
} else {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Element does not exist.');
}
return $this;
} | [
"public",
"function",
"removeCustomByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"_customByName",
")",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"_customByName",
"[",
"$",
"name",
"]",
";",
"// Remove element",
"unset",
"(",
"$",
"this",
"->",
"_customByName",
"[",
"$",
"name",
"]",
")",
";",
"// Be sure to delete from both arrays!",
"$",
"key",
"=",
"array_search",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"_custom",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_custom",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Element does not exist.'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove an individual row element from this list entry by name.
@param string $name The name of the custom element to be deleted.
@return Zend_Gdata_Spreadsheets_ListEntry Provides a fluent interface.
@throws Zend_Gdata_App_InvalidArgumentException | [
"Remove",
"an",
"individual",
"row",
"element",
"from",
"this",
"list",
"entry",
"by",
"name",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/Spreadsheets/ListEntry.php#L191-L206 |
9,497 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.embedJs | public function embedJs($src, $opts = array(), $in_admin = false) {
$js = new Script($src, $opts, $in_admin);
if ($js->getInAdmin()) {
array_push($this->scripts_admin, $js);
} else {
array_push($this->scripts_frontend, $js);
}
} | php | public function embedJs($src, $opts = array(), $in_admin = false) {
$js = new Script($src, $opts, $in_admin);
if ($js->getInAdmin()) {
array_push($this->scripts_admin, $js);
} else {
array_push($this->scripts_frontend, $js);
}
} | [
"public",
"function",
"embedJs",
"(",
"$",
"src",
",",
"$",
"opts",
"=",
"array",
"(",
")",
",",
"$",
"in_admin",
"=",
"false",
")",
"{",
"$",
"js",
"=",
"new",
"Script",
"(",
"$",
"src",
",",
"$",
"opts",
",",
"$",
"in_admin",
")",
";",
"if",
"(",
"$",
"js",
"->",
"getInAdmin",
"(",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"scripts_admin",
",",
"$",
"js",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"scripts_frontend",
",",
"$",
"js",
")",
";",
"}",
"}"
] | Permite agregar un js a la pila de scripts para ser cargado en el punto espesificado
@param string $src nombre o ruta del archivo js que se encuentra en assets/js
@param array $opts Opciones de configuracion necesarias para cargar el js
@param boolean $in_admin Indica si el js sera cargado en el administrador
o en el frontend
@return void | [
"Permite",
"agregar",
"un",
"js",
"a",
"la",
"pila",
"de",
"scripts",
"para",
"ser",
"cargado",
"en",
"el",
"punto",
"espesificado"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L69-L77 |
9,498 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.embedCss | public function embedCss($src, $opts = array(), $in_admin = false) {
$css = new Style($src, $opts, $in_admin);
if ($css->getInAdmin()) {
array_push($this->styles_admin, $css);
} else {
array_push($this->styles_frontend, $css);
}
} | php | public function embedCss($src, $opts = array(), $in_admin = false) {
$css = new Style($src, $opts, $in_admin);
if ($css->getInAdmin()) {
array_push($this->styles_admin, $css);
} else {
array_push($this->styles_frontend, $css);
}
} | [
"public",
"function",
"embedCss",
"(",
"$",
"src",
",",
"$",
"opts",
"=",
"array",
"(",
")",
",",
"$",
"in_admin",
"=",
"false",
")",
"{",
"$",
"css",
"=",
"new",
"Style",
"(",
"$",
"src",
",",
"$",
"opts",
",",
"$",
"in_admin",
")",
";",
"if",
"(",
"$",
"css",
"->",
"getInAdmin",
"(",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"styles_admin",
",",
"$",
"css",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"styles_frontend",
",",
"$",
"css",
")",
";",
"}",
"}"
] | Permite agregar un css a la pila de styles para ser cargado en el punto espesificado
@param string $src nombre o ruta del archivo css que se encuentra en assets/css
@param array $opts Opciones de configuracion necesarias para cargar el css
@param boolean $in_admin Indica si el css sera cargado en el administrador
o en el frontend
@return void | [
"Permite",
"agregar",
"un",
"css",
"a",
"la",
"pila",
"de",
"styles",
"para",
"ser",
"cargado",
"en",
"el",
"punto",
"espesificado"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L87-L95 |
9,499 | GustavoGutierrez/insight | framework/Base/Plugin.php | Plugin.get_plugin_name | protected function get_plugin_name() {
$path = $this->get_path();
$array = explode('/', $path);
unset($array[count($array) - 1]);
unset($array[count($array) - 1]);
return end($array) . '/' . DIRECTORY_APP_NAME;
} | php | protected function get_plugin_name() {
$path = $this->get_path();
$array = explode('/', $path);
unset($array[count($array) - 1]);
unset($array[count($array) - 1]);
return end($array) . '/' . DIRECTORY_APP_NAME;
} | [
"protected",
"function",
"get_plugin_name",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"get_path",
"(",
")",
";",
"$",
"array",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"unset",
"(",
"$",
"array",
"[",
"count",
"(",
"$",
"array",
")",
"-",
"1",
"]",
")",
";",
"unset",
"(",
"$",
"array",
"[",
"count",
"(",
"$",
"array",
")",
"-",
"1",
"]",
")",
";",
"return",
"end",
"(",
"$",
"array",
")",
".",
"'/'",
".",
"DIRECTORY_APP_NAME",
";",
"}"
] | get folder name of plugin builder_complex_app
@return string folder plugin parent name | [
"get",
"folder",
"name",
"of",
"plugin",
"builder_complex_app"
] | 6b70e4e139fcc1cc0bd6e75e847ec59488ecc897 | https://github.com/GustavoGutierrez/insight/blob/6b70e4e139fcc1cc0bd6e75e847ec59488ecc897/framework/Base/Plugin.php#L101-L107 |
Subsets and Splits