id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
223,700
|
puli/manager
|
src/Api/Installation/NotInstallableException.php
|
NotInstallableException.installerNotFound
|
public static function installerNotFound($installerName, Exception $cause = null)
{
return new static(sprintf(
'The installer "%s" does not exist.',
$installerName
), self::INSTALLER_NOT_FOUND, $cause);
}
|
php
|
public static function installerNotFound($installerName, Exception $cause = null)
{
return new static(sprintf(
'The installer "%s" does not exist.',
$installerName
), self::INSTALLER_NOT_FOUND, $cause);
}
|
[
"public",
"static",
"function",
"installerNotFound",
"(",
"$",
"installerName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The installer \"%s\" does not exist.'",
",",
"$",
"installerName",
")",
",",
"self",
"::",
"INSTALLER_NOT_FOUND",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for an installer name that was not found.
@param string $installerName The installer name.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"an",
"installer",
"name",
"that",
"was",
"not",
"found",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/NotInstallableException.php#L112-L118
|
223,701
|
puli/manager
|
src/Api/Installation/NotInstallableException.php
|
NotInstallableException.noResourceMatches
|
public static function noResourceMatches($glob, Exception $cause = null)
{
return new static(sprintf(
'The glob "%s" did not return any resources.',
$glob
), self::NO_RESOURCE_MATCHES, $cause);
}
|
php
|
public static function noResourceMatches($glob, Exception $cause = null)
{
return new static(sprintf(
'The glob "%s" did not return any resources.',
$glob
), self::NO_RESOURCE_MATCHES, $cause);
}
|
[
"public",
"static",
"function",
"noResourceMatches",
"(",
"$",
"glob",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The glob \"%s\" did not return any resources.'",
",",
"$",
"glob",
")",
",",
"self",
"::",
"NO_RESOURCE_MATCHES",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for an glob that did not return any matches.
@param string $glob The resource glob.
@param Exception|null $cause The exception that caused this exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"an",
"glob",
"that",
"did",
"not",
"return",
"any",
"matches",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/NotInstallableException.php#L128-L134
|
223,702
|
puli/manager
|
src/Api/Installation/NotInstallableException.php
|
NotInstallableException.serverNotFound
|
public static function serverNotFound($serverName, Exception $cause = null)
{
return new static(sprintf(
'The asset server "%s" does not exist.',
$serverName
), self::SERVER_NOT_FOUND, $cause);
}
|
php
|
public static function serverNotFound($serverName, Exception $cause = null)
{
return new static(sprintf(
'The asset server "%s" does not exist.',
$serverName
), self::SERVER_NOT_FOUND, $cause);
}
|
[
"public",
"static",
"function",
"serverNotFound",
"(",
"$",
"serverName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The asset server \"%s\" does not exist.'",
",",
"$",
"serverName",
")",
",",
"self",
"::",
"SERVER_NOT_FOUND",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for a server name that was not found.
@param string $serverName The server name.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"a",
"server",
"name",
"that",
"was",
"not",
"found",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/NotInstallableException.php#L145-L151
|
223,703
|
puli/manager
|
src/Api/Installation/NotInstallableException.php
|
NotInstallableException.installerClassNotFound
|
public static function installerClassNotFound($installerClass, Exception $cause = null)
{
return new static(sprintf(
'The installer class "%s" does not exist.',
$installerClass
), self::INSTALLER_CLASS_NOT_FOUND, $cause);
}
|
php
|
public static function installerClassNotFound($installerClass, Exception $cause = null)
{
return new static(sprintf(
'The installer class "%s" does not exist.',
$installerClass
), self::INSTALLER_CLASS_NOT_FOUND, $cause);
}
|
[
"public",
"static",
"function",
"installerClassNotFound",
"(",
"$",
"installerClass",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The installer class \"%s\" does not exist.'",
",",
"$",
"installerClass",
")",
",",
"self",
"::",
"INSTALLER_CLASS_NOT_FOUND",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for an installer class that was not found.
@param string $installerClass The installer class.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"an",
"installer",
"class",
"that",
"was",
"not",
"found",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/NotInstallableException.php#L162-L168
|
223,704
|
puli/manager
|
src/Api/Installation/NotInstallableException.php
|
NotInstallableException.installerClassNoDefaultConstructor
|
public static function installerClassNoDefaultConstructor($installerClass, Exception $cause = null)
{
return new static(sprintf(
'The constructor of class "%s" must not have required parameters.',
$installerClass
), self::INSTALLER_CLASS_NO_DEFAULT_CONSTRUCTOR, $cause);
}
|
php
|
public static function installerClassNoDefaultConstructor($installerClass, Exception $cause = null)
{
return new static(sprintf(
'The constructor of class "%s" must not have required parameters.',
$installerClass
), self::INSTALLER_CLASS_NO_DEFAULT_CONSTRUCTOR, $cause);
}
|
[
"public",
"static",
"function",
"installerClassNoDefaultConstructor",
"(",
"$",
"installerClass",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The constructor of class \"%s\" must not have required parameters.'",
",",
"$",
"installerClass",
")",
",",
"self",
"::",
"INSTALLER_CLASS_NO_DEFAULT_CONSTRUCTOR",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for an installer class that has no default
constructor.
@param string $installerClass The installer class.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"an",
"installer",
"class",
"that",
"has",
"no",
"default",
"constructor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installation/NotInstallableException.php#L180-L186
|
223,705
|
ongr-io/FilterManagerBundle
|
DependencyInjection/Compiler/FilterPass.php
|
FilterPass.addRelation
|
private function addRelation(Definition $definition, $filter, $urlType, $relationType)
{
if (empty($filter['relations'][$urlType][$relationType])) {
return;
}
$relation = new Definition(
sprintf('ONGR\FilterManagerBundle\Relation\%sRelation', ucfirst($relationType)),
[$filter['relations'][$urlType][$relationType]]
);
$definition->addMethodCall(
'set' . ucfirst($urlType) . 'Relation',
[$relation]
);
}
|
php
|
private function addRelation(Definition $definition, $filter, $urlType, $relationType)
{
if (empty($filter['relations'][$urlType][$relationType])) {
return;
}
$relation = new Definition(
sprintf('ONGR\FilterManagerBundle\Relation\%sRelation', ucfirst($relationType)),
[$filter['relations'][$urlType][$relationType]]
);
$definition->addMethodCall(
'set' . ucfirst($urlType) . 'Relation',
[$relation]
);
}
|
[
"private",
"function",
"addRelation",
"(",
"Definition",
"$",
"definition",
",",
"$",
"filter",
",",
"$",
"urlType",
",",
"$",
"relationType",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"filter",
"[",
"'relations'",
"]",
"[",
"$",
"urlType",
"]",
"[",
"$",
"relationType",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"relation",
"=",
"new",
"Definition",
"(",
"sprintf",
"(",
"'ONGR\\FilterManagerBundle\\Relation\\%sRelation'",
",",
"ucfirst",
"(",
"$",
"relationType",
")",
")",
",",
"[",
"$",
"filter",
"[",
"'relations'",
"]",
"[",
"$",
"urlType",
"]",
"[",
"$",
"relationType",
"]",
"]",
")",
";",
"$",
"definition",
"->",
"addMethodCall",
"(",
"'set'",
".",
"ucfirst",
"(",
"$",
"urlType",
")",
".",
"'Relation'",
",",
"[",
"$",
"relation",
"]",
")",
";",
"}"
] |
Adds relation to filter.
@param Definition $definition
@param array $filter
@param string $urlType
@param string $relationType
|
[
"Adds",
"relation",
"to",
"filter",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/DependencyInjection/Compiler/FilterPass.php#L99-L113
|
223,706
|
puli/manager
|
src/Api/Discovery/BindingState.php
|
BindingState.all
|
public static function all()
{
return array(
self::ENABLED,
self::DISABLED,
self::TYPE_NOT_FOUND,
self::TYPE_NOT_ENABLED,
self::INVALID,
);
}
|
php
|
public static function all()
{
return array(
self::ENABLED,
self::DISABLED,
self::TYPE_NOT_FOUND,
self::TYPE_NOT_ENABLED,
self::INVALID,
);
}
|
[
"public",
"static",
"function",
"all",
"(",
")",
"{",
"return",
"array",
"(",
"self",
"::",
"ENABLED",
",",
"self",
"::",
"DISABLED",
",",
"self",
"::",
"TYPE_NOT_FOUND",
",",
"self",
"::",
"TYPE_NOT_ENABLED",
",",
"self",
"::",
"INVALID",
",",
")",
";",
"}"
] |
Returns all binding states.
@return int[] The binding states.
|
[
"Returns",
"all",
"binding",
"states",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingState.php#L53-L62
|
223,707
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.set
|
public function set($primaryKey, $secondaryKey, $value)
{
if (!isset($this->values[$primaryKey])) {
$this->values[$primaryKey] = array();
}
$this->values[$primaryKey][$secondaryKey] = $value;
}
|
php
|
public function set($primaryKey, $secondaryKey, $value)
{
if (!isset($this->values[$primaryKey])) {
$this->values[$primaryKey] = array();
}
$this->values[$primaryKey][$secondaryKey] = $value;
}
|
[
"public",
"function",
"set",
"(",
"$",
"primaryKey",
",",
"$",
"secondaryKey",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
"[",
"$",
"secondaryKey",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets a value in the store.
@param int|string $primaryKey The primary key.
@param int|string $secondaryKey The secondary key.
@param mixed $value The value.
|
[
"Sets",
"a",
"value",
"in",
"the",
"store",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L42-L49
|
223,708
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.remove
|
public function remove($primaryKey, $secondaryKey)
{
unset($this->values[$primaryKey][$secondaryKey]);
if (isset($this->values[$primaryKey]) && 0 === count($this->values[$primaryKey])) {
unset($this->values[$primaryKey]);
}
}
|
php
|
public function remove($primaryKey, $secondaryKey)
{
unset($this->values[$primaryKey][$secondaryKey]);
if (isset($this->values[$primaryKey]) && 0 === count($this->values[$primaryKey])) {
unset($this->values[$primaryKey]);
}
}
|
[
"public",
"function",
"remove",
"(",
"$",
"primaryKey",
",",
"$",
"secondaryKey",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
"[",
"$",
"secondaryKey",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
"&&",
"0",
"===",
"count",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}",
"}"
] |
Removes a value from the store.
This method ignores non-existing keys.
@param int|string $primaryKey The primary key.
@param int|string $secondaryKey The secondary key.
|
[
"Removes",
"a",
"value",
"from",
"the",
"store",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L59-L66
|
223,709
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.get
|
public function get($primaryKey, $secondaryKey)
{
if (!isset($this->values[$primaryKey][$secondaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key ("%s","%s") does not exist.',
$primaryKey,
$secondaryKey
));
}
return $this->values[$primaryKey][$secondaryKey];
}
|
php
|
public function get($primaryKey, $secondaryKey)
{
if (!isset($this->values[$primaryKey][$secondaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key ("%s","%s") does not exist.',
$primaryKey,
$secondaryKey
));
}
return $this->values[$primaryKey][$secondaryKey];
}
|
[
"public",
"function",
"get",
"(",
"$",
"primaryKey",
",",
"$",
"secondaryKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
"[",
"$",
"secondaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key (\"%s\",\"%s\") does not exist.'",
",",
"$",
"primaryKey",
",",
"$",
"secondaryKey",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
"[",
"$",
"secondaryKey",
"]",
";",
"}"
] |
Returns a value from the store.
@param int|string $primaryKey The primary key.
@param int|string $secondaryKey The secondary key.
@return mixed The value.
@throws OutOfBoundsException If no value is set for the given keys.
|
[
"Returns",
"a",
"value",
"from",
"the",
"store",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L90-L101
|
223,710
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.getFirst
|
public function getFirst($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return reset($this->values[$primaryKey]);
}
|
php
|
public function getFirst($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return reset($this->values[$primaryKey]);
}
|
[
"public",
"function",
"getFirst",
"(",
"$",
"primaryKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"primaryKey",
")",
")",
";",
"}",
"return",
"reset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}"
] |
Returns the first value set for the given primary key.
@param int|string $primaryKey The primary key.
@return mixed The value.
@throws OutOfBoundsException If the primary key does not exist.
|
[
"Returns",
"the",
"first",
"value",
"set",
"for",
"the",
"given",
"primary",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L133-L143
|
223,711
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.getLast
|
public function getLast($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return end($this->values[$primaryKey]);
}
|
php
|
public function getLast($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return end($this->values[$primaryKey]);
}
|
[
"public",
"function",
"getLast",
"(",
"$",
"primaryKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"primaryKey",
")",
")",
";",
"}",
"return",
"end",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}"
] |
Returns the last value set for the given primary key.
@param int|string $primaryKey The primary key.
@return mixed The value.
@throws OutOfBoundsException If the primary key does not exist.
|
[
"Returns",
"the",
"last",
"value",
"set",
"for",
"the",
"given",
"primary",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L154-L164
|
223,712
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.getCount
|
public function getCount($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return count($this->values[$primaryKey]);
}
|
php
|
public function getCount($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return count($this->values[$primaryKey]);
}
|
[
"public",
"function",
"getCount",
"(",
"$",
"primaryKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"primaryKey",
")",
")",
";",
"}",
"return",
"count",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}"
] |
Returns the number of secondary keys set for the given primary key.
@param int|string $primaryKey The primary key.
@return int The number of secondary keys set for the primary key.
@throws OutOfBoundsException If the primary key does not exist.
|
[
"Returns",
"the",
"number",
"of",
"secondary",
"keys",
"set",
"for",
"the",
"given",
"primary",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L175-L185
|
223,713
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.listByPrimaryKey
|
public function listByPrimaryKey($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return $this->values[$primaryKey];
}
|
php
|
public function listByPrimaryKey($primaryKey)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return $this->values[$primaryKey];
}
|
[
"public",
"function",
"listByPrimaryKey",
"(",
"$",
"primaryKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"primaryKey",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
";",
"}"
] |
Returns all values set for the given primary key.
@param int|string $primaryKey The primary key.
@return array The values indexed by their secondary keys.
@throws OutOfBoundsException If the primary key does not exist.
|
[
"Returns",
"all",
"values",
"set",
"for",
"the",
"given",
"primary",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L196-L206
|
223,714
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.listBySecondaryKey
|
public function listBySecondaryKey($secondaryKey)
{
$list = array();
foreach ($this->values as $primaryKey => $valuesBySecondaryKey) {
if (isset($valuesBySecondaryKey[$secondaryKey])) {
$list[$primaryKey] = $valuesBySecondaryKey[$secondaryKey];
}
}
if (!$list) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$secondaryKey
));
}
return $list;
}
|
php
|
public function listBySecondaryKey($secondaryKey)
{
$list = array();
foreach ($this->values as $primaryKey => $valuesBySecondaryKey) {
if (isset($valuesBySecondaryKey[$secondaryKey])) {
$list[$primaryKey] = $valuesBySecondaryKey[$secondaryKey];
}
}
if (!$list) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$secondaryKey
));
}
return $list;
}
|
[
"public",
"function",
"listBySecondaryKey",
"(",
"$",
"secondaryKey",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"primaryKey",
"=>",
"$",
"valuesBySecondaryKey",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"valuesBySecondaryKey",
"[",
"$",
"secondaryKey",
"]",
")",
")",
"{",
"$",
"list",
"[",
"$",
"primaryKey",
"]",
"=",
"$",
"valuesBySecondaryKey",
"[",
"$",
"secondaryKey",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"list",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"secondaryKey",
")",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
Returns all values set for the given secondary key.
@param int|string $secondaryKey The secondary key.
@return array The values indexed by their primary keys.
@throws OutOfBoundsException If the secondary key does not exist.
|
[
"Returns",
"all",
"values",
"set",
"for",
"the",
"given",
"secondary",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L217-L235
|
223,715
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.getSecondaryKeys
|
public function getSecondaryKeys($primaryKey = null)
{
if ($primaryKey) {
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return array_keys($this->values[$primaryKey]);
}
$allSecondaryKeys = array();
foreach ($this->values as $primaryKey => $valuesBySecondaryKey) {
foreach ($valuesBySecondaryKey as $secondaryKey => $values) {
$allSecondaryKeys[$secondaryKey] = true;
}
}
return array_keys($allSecondaryKeys);
}
|
php
|
public function getSecondaryKeys($primaryKey = null)
{
if ($primaryKey) {
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
return array_keys($this->values[$primaryKey]);
}
$allSecondaryKeys = array();
foreach ($this->values as $primaryKey => $valuesBySecondaryKey) {
foreach ($valuesBySecondaryKey as $secondaryKey => $values) {
$allSecondaryKeys[$secondaryKey] = true;
}
}
return array_keys($allSecondaryKeys);
}
|
[
"public",
"function",
"getSecondaryKeys",
"(",
"$",
"primaryKey",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"primaryKey",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"primaryKey",
")",
")",
";",
"}",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}",
"$",
"allSecondaryKeys",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"primaryKey",
"=>",
"$",
"valuesBySecondaryKey",
")",
"{",
"foreach",
"(",
"$",
"valuesBySecondaryKey",
"as",
"$",
"secondaryKey",
"=>",
"$",
"values",
")",
"{",
"$",
"allSecondaryKeys",
"[",
"$",
"secondaryKey",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"array_keys",
"(",
"$",
"allSecondaryKeys",
")",
";",
"}"
] |
Returns the secondary keys for the given primary key.
The primary key is optional. If this argument is not provided, all secondary keys will be returned.
@param int|string|null $primaryKey The primary key.
@return int[]|string[] The secondary keys.
@throws OutOfBoundsException If the primary key does not exist.
|
[
"Returns",
"the",
"secondary",
"keys",
"for",
"the",
"given",
"primary",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L248-L270
|
223,716
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.sortPrimaryKeys
|
public function sortPrimaryKeys(array $order = null)
{
if (!$order) {
ksort($this->values);
return;
}
$orderedKeys = array_intersect_key(array_flip($order), $this->values);
$this->values = array_replace($orderedKeys, $this->values);
}
|
php
|
public function sortPrimaryKeys(array $order = null)
{
if (!$order) {
ksort($this->values);
return;
}
$orderedKeys = array_intersect_key(array_flip($order), $this->values);
$this->values = array_replace($orderedKeys, $this->values);
}
|
[
"public",
"function",
"sortPrimaryKeys",
"(",
"array",
"$",
"order",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"order",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"values",
")",
";",
"return",
";",
"}",
"$",
"orderedKeys",
"=",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"order",
")",
",",
"$",
"this",
"->",
"values",
")",
";",
"$",
"this",
"->",
"values",
"=",
"array_replace",
"(",
"$",
"orderedKeys",
",",
"$",
"this",
"->",
"values",
")",
";",
"}"
] |
Sorts the primary keys of the map.
@param int[]|string[]|null $order The keys in the desired order.
|
[
"Sorts",
"the",
"primary",
"keys",
"of",
"the",
"map",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L308-L319
|
223,717
|
puli/manager
|
src/Util/TwoDimensionalHashMap.php
|
TwoDimensionalHashMap.sortSecondaryKeys
|
public function sortSecondaryKeys($primaryKey, array $order = null)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
if (!$order) {
ksort($this->values[$primaryKey]);
return;
}
$orderedKeys = array_intersect_key(array_flip($order), $this->values[$primaryKey]);
$this->values[$primaryKey] = array_replace($orderedKeys, $this->values[$primaryKey]);
}
|
php
|
public function sortSecondaryKeys($primaryKey, array $order = null)
{
if (!isset($this->values[$primaryKey])) {
throw new OutOfBoundsException(sprintf(
'The key "%s" does not exist.',
$primaryKey
));
}
if (!$order) {
ksort($this->values[$primaryKey]);
return;
}
$orderedKeys = array_intersect_key(array_flip($order), $this->values[$primaryKey]);
$this->values[$primaryKey] = array_replace($orderedKeys, $this->values[$primaryKey]);
}
|
[
"public",
"function",
"sortSecondaryKeys",
"(",
"$",
"primaryKey",
",",
"array",
"$",
"order",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The key \"%s\" does not exist.'",
",",
"$",
"primaryKey",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"order",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"return",
";",
"}",
"$",
"orderedKeys",
"=",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"order",
")",
",",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
"=",
"array_replace",
"(",
"$",
"orderedKeys",
",",
"$",
"this",
"->",
"values",
"[",
"$",
"primaryKey",
"]",
")",
";",
"}"
] |
Sorts the secondary keys of a map entry.
@param int|string $primaryKey The primary key.
@param int[]|string[]|null $order The keys in the desired order.
|
[
"Sorts",
"the",
"secondary",
"keys",
"of",
"a",
"map",
"entry",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Util/TwoDimensionalHashMap.php#L327-L345
|
223,718
|
puli/manager
|
src/Factory/FactoryManagerImpl.php
|
FactoryManagerImpl.camelizeKeys
|
private function camelizeKeys(array $array)
{
$camelized = array();
foreach ($array as $key => $value) {
$camelized[$this->camelize($key)] = is_array($value)
? $this->camelizeKeys($value)
: $value;
}
return $camelized;
}
|
php
|
private function camelizeKeys(array $array)
{
$camelized = array();
foreach ($array as $key => $value) {
$camelized[$this->camelize($key)] = is_array($value)
? $this->camelizeKeys($value)
: $value;
}
return $camelized;
}
|
[
"private",
"function",
"camelizeKeys",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"camelized",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"camelized",
"[",
"$",
"this",
"->",
"camelize",
"(",
"$",
"key",
")",
"]",
"=",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"this",
"->",
"camelizeKeys",
"(",
"$",
"value",
")",
":",
"$",
"value",
";",
"}",
"return",
"$",
"camelized",
";",
"}"
] |
Recursively camelizes the keys of an array.
@param array $array The array to process.
@return array The input array with camelized keys.
|
[
"Recursively",
"camelizes",
"the",
"keys",
"of",
"an",
"array",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Factory/FactoryManagerImpl.php#L442-L453
|
223,719
|
puli/manager
|
src/Api/Discovery/BindingTypeDescriptor.php
|
BindingTypeDescriptor.load
|
public function load(Module $containingModule)
{
if (null !== $this->state) {
throw new AlreadyLoadedException('The type descriptor is already loaded.');
}
$this->containingModule = $containingModule;
$this->state = BindingTypeState::ENABLED;
}
|
php
|
public function load(Module $containingModule)
{
if (null !== $this->state) {
throw new AlreadyLoadedException('The type descriptor is already loaded.');
}
$this->containingModule = $containingModule;
$this->state = BindingTypeState::ENABLED;
}
|
[
"public",
"function",
"load",
"(",
"Module",
"$",
"containingModule",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"AlreadyLoadedException",
"(",
"'The type descriptor is already loaded.'",
")",
";",
"}",
"$",
"this",
"->",
"containingModule",
"=",
"$",
"containingModule",
";",
"$",
"this",
"->",
"state",
"=",
"BindingTypeState",
"::",
"ENABLED",
";",
"}"
] |
Loads the type descriptor.
@param Module $containingModule The module that contains the type
descriptor.
@throws AlreadyLoadedException If the descriptor is already loaded.
|
[
"Loads",
"the",
"type",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingTypeDescriptor.php#L99-L107
|
223,720
|
puli/manager
|
src/Api/Discovery/BindingTypeDescriptor.php
|
BindingTypeDescriptor.unload
|
public function unload()
{
if (null === $this->state) {
throw new NotLoadedException('The type descriptor is not loaded.');
}
$this->containingModule = null;
$this->state = null;
}
|
php
|
public function unload()
{
if (null === $this->state) {
throw new NotLoadedException('The type descriptor is not loaded.');
}
$this->containingModule = null;
$this->state = null;
}
|
[
"public",
"function",
"unload",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The type descriptor is not loaded.'",
")",
";",
"}",
"$",
"this",
"->",
"containingModule",
"=",
"null",
";",
"$",
"this",
"->",
"state",
"=",
"null",
";",
"}"
] |
Unloads the type descriptor.
All memory allocated during {@link load()} is freed.
@throws NotLoadedException If the descriptor is not loaded.
|
[
"Unloads",
"the",
"type",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingTypeDescriptor.php#L116-L124
|
223,721
|
puli/manager
|
src/Api/Discovery/BindingTypeDescriptor.php
|
BindingTypeDescriptor.markDuplicate
|
public function markDuplicate($duplicate)
{
Assert::boolean($duplicate);
if (null === $this->state) {
throw new NotLoadedException('The type descriptor is not loaded.');
}
$this->state = $duplicate ? BindingTypeState::DUPLICATE : BindingTypeState::ENABLED;
}
|
php
|
public function markDuplicate($duplicate)
{
Assert::boolean($duplicate);
if (null === $this->state) {
throw new NotLoadedException('The type descriptor is not loaded.');
}
$this->state = $duplicate ? BindingTypeState::DUPLICATE : BindingTypeState::ENABLED;
}
|
[
"public",
"function",
"markDuplicate",
"(",
"$",
"duplicate",
")",
"{",
"Assert",
"::",
"boolean",
"(",
"$",
"duplicate",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The type descriptor is not loaded.'",
")",
";",
"}",
"$",
"this",
"->",
"state",
"=",
"$",
"duplicate",
"?",
"BindingTypeState",
"::",
"DUPLICATE",
":",
"BindingTypeState",
"::",
"ENABLED",
";",
"}"
] |
Marks or unmarks the type as duplicate.
The method {@link load()} needs to be called before calling this method,
otherwise an exception is thrown.
@param bool $duplicate Whether or not the type is a duplicate.
@throws NotLoadedException If the descriptor is not loaded.
|
[
"Marks",
"or",
"unmarks",
"the",
"type",
"as",
"duplicate",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingTypeDescriptor.php#L146-L155
|
223,722
|
puli/manager
|
src/Api/Discovery/BindingTypeDescriptor.php
|
BindingTypeDescriptor.getParameterDescription
|
public function getParameterDescription($parameterName)
{
if (!$this->type->hasParameter($parameterName)) {
throw new NoSuchParameterException(sprintf(
'The parameter "%s" does not exist.',
$parameterName
));
}
if (!isset($this->parameterDescriptions[$parameterName])) {
throw new OutOfBoundsException(sprintf(
'No description exists for parameter "%s".',
$parameterName
));
}
return $this->parameterDescriptions[$parameterName];
}
|
php
|
public function getParameterDescription($parameterName)
{
if (!$this->type->hasParameter($parameterName)) {
throw new NoSuchParameterException(sprintf(
'The parameter "%s" does not exist.',
$parameterName
));
}
if (!isset($this->parameterDescriptions[$parameterName])) {
throw new OutOfBoundsException(sprintf(
'No description exists for parameter "%s".',
$parameterName
));
}
return $this->parameterDescriptions[$parameterName];
}
|
[
"public",
"function",
"getParameterDescription",
"(",
"$",
"parameterName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"type",
"->",
"hasParameter",
"(",
"$",
"parameterName",
")",
")",
"{",
"throw",
"new",
"NoSuchParameterException",
"(",
"sprintf",
"(",
"'The parameter \"%s\" does not exist.'",
",",
"$",
"parameterName",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parameterDescriptions",
"[",
"$",
"parameterName",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'No description exists for parameter \"%s\".'",
",",
"$",
"parameterName",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parameterDescriptions",
"[",
"$",
"parameterName",
"]",
";",
"}"
] |
Returns the description for a parameter.
@param string $parameterName The parameter name.
@return string The description of the parameter.
@throws NoSuchParameterException If the parameter does not exist.
@throws OutOfBoundsException If the parameter has no description.
|
[
"Returns",
"the",
"description",
"for",
"a",
"parameter",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/BindingTypeDescriptor.php#L207-L224
|
223,723
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHelperUser.php
|
FrontendHelperUser.authenticate
|
public function authenticate()
{
// Backwards compatibility for Contao 4.4
if (!$this instanceof UserInterface) {
if ($this->frontendHelperUserAuthenticated === null) {
$this->frontendHelperUserAuthenticated = \User::authenticate();
}
return $this->frontendHelperUserAuthenticated;
}
return $this->username && $this->intId;
}
|
php
|
public function authenticate()
{
// Backwards compatibility for Contao 4.4
if (!$this instanceof UserInterface) {
if ($this->frontendHelperUserAuthenticated === null) {
$this->frontendHelperUserAuthenticated = \User::authenticate();
}
return $this->frontendHelperUserAuthenticated;
}
return $this->username && $this->intId;
}
|
[
"public",
"function",
"authenticate",
"(",
")",
"{",
"// Backwards compatibility for Contao 4.4",
"if",
"(",
"!",
"$",
"this",
"instanceof",
"UserInterface",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"frontendHelperUserAuthenticated",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"frontendHelperUserAuthenticated",
"=",
"\\",
"User",
"::",
"authenticate",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"frontendHelperUserAuthenticated",
";",
"}",
"return",
"$",
"this",
"->",
"username",
"&&",
"$",
"this",
"->",
"intId",
";",
"}"
] |
Disable BackendUser authentication redirect and cache the result
|
[
"Disable",
"BackendUser",
"authentication",
"redirect",
"and",
"cache",
"the",
"result"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHelperUser.php#L36-L47
|
223,724
|
madeyourday/contao-rocksolid-frontend-helper
|
src/FrontendHelperUser.php
|
FrontendHelperUser.setUserFromDb
|
protected function setUserFromDb()
{
$this->intId = $this->id;
foreach ($this->arrData as $key => $value) {
if (! is_numeric($value)) {
$this->$key = \StringUtil::deserialize($value);
}
}
$always = array('alexf');
$depends = array();
if (is_array($GLOBALS['TL_PERMISSIONS']) && ! empty($GLOBALS['TL_PERMISSIONS'])) {
$depends = array_merge($depends, $GLOBALS['TL_PERMISSIONS']);
}
if ($this->inherit == 'group') {
foreach ($depends as $field) {
$this->$field = array();
}
}
$inherit = in_array($this->inherit, array('group', 'extend')) ? array_merge($always, $depends) : $always;
$time = time();
foreach ((array) $this->groups as $id) {
$objGroup = $this->Database
->prepare("SELECT * FROM tl_user_group WHERE id=? AND disable!=1 AND (start='' OR start<$time) AND (stop='' OR stop>$time)")
->limit(1)
->execute($id);
if ($objGroup->numRows > 0) {
foreach ($inherit as $field) {
$value = \StringUtil::deserialize($objGroup->$field, true);
if (!empty($value)) {
$this->$field = array_merge((is_array($this->$field) ? $this->$field : (($this->$field != '') ? array($this->$field) : array())), $value);
$this->$field = array_unique($this->$field);
}
}
}
}
}
|
php
|
protected function setUserFromDb()
{
$this->intId = $this->id;
foreach ($this->arrData as $key => $value) {
if (! is_numeric($value)) {
$this->$key = \StringUtil::deserialize($value);
}
}
$always = array('alexf');
$depends = array();
if (is_array($GLOBALS['TL_PERMISSIONS']) && ! empty($GLOBALS['TL_PERMISSIONS'])) {
$depends = array_merge($depends, $GLOBALS['TL_PERMISSIONS']);
}
if ($this->inherit == 'group') {
foreach ($depends as $field) {
$this->$field = array();
}
}
$inherit = in_array($this->inherit, array('group', 'extend')) ? array_merge($always, $depends) : $always;
$time = time();
foreach ((array) $this->groups as $id) {
$objGroup = $this->Database
->prepare("SELECT * FROM tl_user_group WHERE id=? AND disable!=1 AND (start='' OR start<$time) AND (stop='' OR stop>$time)")
->limit(1)
->execute($id);
if ($objGroup->numRows > 0) {
foreach ($inherit as $field) {
$value = \StringUtil::deserialize($objGroup->$field, true);
if (!empty($value)) {
$this->$field = array_merge((is_array($this->$field) ? $this->$field : (($this->$field != '') ? array($this->$field) : array())), $value);
$this->$field = array_unique($this->$field);
}
}
}
}
}
|
[
"protected",
"function",
"setUserFromDb",
"(",
")",
"{",
"$",
"this",
"->",
"intId",
"=",
"$",
"this",
"->",
"id",
";",
"foreach",
"(",
"$",
"this",
"->",
"arrData",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"\\",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"value",
")",
";",
"}",
"}",
"$",
"always",
"=",
"array",
"(",
"'alexf'",
")",
";",
"$",
"depends",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"GLOBALS",
"[",
"'TL_PERMISSIONS'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'TL_PERMISSIONS'",
"]",
")",
")",
"{",
"$",
"depends",
"=",
"array_merge",
"(",
"$",
"depends",
",",
"$",
"GLOBALS",
"[",
"'TL_PERMISSIONS'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"inherit",
"==",
"'group'",
")",
"{",
"foreach",
"(",
"$",
"depends",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"$",
"field",
"=",
"array",
"(",
")",
";",
"}",
"}",
"$",
"inherit",
"=",
"in_array",
"(",
"$",
"this",
"->",
"inherit",
",",
"array",
"(",
"'group'",
",",
"'extend'",
")",
")",
"?",
"array_merge",
"(",
"$",
"always",
",",
"$",
"depends",
")",
":",
"$",
"always",
";",
"$",
"time",
"=",
"time",
"(",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"groups",
"as",
"$",
"id",
")",
"{",
"$",
"objGroup",
"=",
"$",
"this",
"->",
"Database",
"->",
"prepare",
"(",
"\"SELECT * FROM tl_user_group WHERE id=? AND disable!=1 AND (start='' OR start<$time) AND (stop='' OR stop>$time)\"",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"execute",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"objGroup",
"->",
"numRows",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"inherit",
"as",
"$",
"field",
")",
"{",
"$",
"value",
"=",
"\\",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"objGroup",
"->",
"$",
"field",
",",
"true",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"$",
"field",
"=",
"array_merge",
"(",
"(",
"is_array",
"(",
"$",
"this",
"->",
"$",
"field",
")",
"?",
"$",
"this",
"->",
"$",
"field",
":",
"(",
"(",
"$",
"this",
"->",
"$",
"field",
"!=",
"''",
")",
"?",
"array",
"(",
"$",
"this",
"->",
"$",
"field",
")",
":",
"array",
"(",
")",
")",
")",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"$",
"field",
"=",
"array_unique",
"(",
"$",
"this",
"->",
"$",
"field",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
set all user properties from a database record
|
[
"set",
"all",
"user",
"properties",
"from",
"a",
"database",
"record"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/FrontendHelperUser.php#L57-L101
|
223,725
|
OXID-eSales/oxid-eshop-ide-helper
|
src/Generator.php
|
Generator.generate
|
public function generate()
{
$output = $this->generateIdeHelperOutput();
$this->writeIdeHelperFile($output, '.ide-helper.php');
$outputForPhpStormIde = $this->generatePhpStormIdeHelperOutput();
$this->writeIdeHelperFile($outputForPhpStormIde, '.phpstorm.meta.php/oxid.meta.php');
}
|
php
|
public function generate()
{
$output = $this->generateIdeHelperOutput();
$this->writeIdeHelperFile($output, '.ide-helper.php');
$outputForPhpStormIde = $this->generatePhpStormIdeHelperOutput();
$this->writeIdeHelperFile($outputForPhpStormIde, '.phpstorm.meta.php/oxid.meta.php');
}
|
[
"public",
"function",
"generate",
"(",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"generateIdeHelperOutput",
"(",
")",
";",
"$",
"this",
"->",
"writeIdeHelperFile",
"(",
"$",
"output",
",",
"'.ide-helper.php'",
")",
";",
"$",
"outputForPhpStormIde",
"=",
"$",
"this",
"->",
"generatePhpStormIdeHelperOutput",
"(",
")",
";",
"$",
"this",
"->",
"writeIdeHelperFile",
"(",
"$",
"outputForPhpStormIde",
",",
"'.phpstorm.meta.php/oxid.meta.php'",
")",
";",
"}"
] |
Generate a helper file for IDE auto-completion
|
[
"Generate",
"a",
"helper",
"file",
"for",
"IDE",
"auto",
"-",
"completion"
] |
e29836a482e7e2386ebb1cefd01e31240e2b3847
|
https://github.com/OXID-eSales/oxid-eshop-ide-helper/blob/e29836a482e7e2386ebb1cefd01e31240e2b3847/src/Generator.php#L68-L75
|
223,726
|
OXID-eSales/oxid-eshop-ide-helper
|
src/Generator.php
|
Generator.getSmarty
|
protected function getSmarty()
{
$smarty = new \Smarty();
$currentDirectory = dirname(__FILE__);
$smarty->template_dir = realpath(
$currentDirectory . DIRECTORY_SEPARATOR .
'smarty' . DIRECTORY_SEPARATOR .
'templates' . DIRECTORY_SEPARATOR
);
$smarty->compile_dir = realpath(
$currentDirectory . '' . DIRECTORY_SEPARATOR .
'smarty' . DIRECTORY_SEPARATOR .
'templates_c' . DIRECTORY_SEPARATOR
);
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
return $smarty;
}
|
php
|
protected function getSmarty()
{
$smarty = new \Smarty();
$currentDirectory = dirname(__FILE__);
$smarty->template_dir = realpath(
$currentDirectory . DIRECTORY_SEPARATOR .
'smarty' . DIRECTORY_SEPARATOR .
'templates' . DIRECTORY_SEPARATOR
);
$smarty->compile_dir = realpath(
$currentDirectory . '' . DIRECTORY_SEPARATOR .
'smarty' . DIRECTORY_SEPARATOR .
'templates_c' . DIRECTORY_SEPARATOR
);
$smarty->left_delimiter = '{{';
$smarty->right_delimiter = '}}';
return $smarty;
}
|
[
"protected",
"function",
"getSmarty",
"(",
")",
"{",
"$",
"smarty",
"=",
"new",
"\\",
"Smarty",
"(",
")",
";",
"$",
"currentDirectory",
"=",
"dirname",
"(",
"__FILE__",
")",
";",
"$",
"smarty",
"->",
"template_dir",
"=",
"realpath",
"(",
"$",
"currentDirectory",
".",
"DIRECTORY_SEPARATOR",
".",
"'smarty'",
".",
"DIRECTORY_SEPARATOR",
".",
"'templates'",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"smarty",
"->",
"compile_dir",
"=",
"realpath",
"(",
"$",
"currentDirectory",
".",
"''",
".",
"DIRECTORY_SEPARATOR",
".",
"'smarty'",
".",
"DIRECTORY_SEPARATOR",
".",
"'templates_c'",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"smarty",
"->",
"left_delimiter",
"=",
"'{{'",
";",
"$",
"smarty",
"->",
"right_delimiter",
"=",
"'}}'",
";",
"return",
"$",
"smarty",
";",
"}"
] |
Return an instance of smarty
@return \Smarty
|
[
"Return",
"an",
"instance",
"of",
"smarty"
] |
e29836a482e7e2386ebb1cefd01e31240e2b3847
|
https://github.com/OXID-eSales/oxid-eshop-ide-helper/blob/e29836a482e7e2386ebb1cefd01e31240e2b3847/src/Generator.php#L170-L188
|
223,727
|
ongr-io/FilterManagerBundle
|
Twig/PagerExtension.php
|
PagerExtension.path
|
public function path($route, $page, array $parameters = [])
{
$fieldName = 'page';
if (isset($parameters['_page'])) {
$fieldName = $parameters['_page'];
unset($parameters['_page']);
}
$parameters[$fieldName] = $page;
return $this->router->generate($route, $parameters);
}
|
php
|
public function path($route, $page, array $parameters = [])
{
$fieldName = 'page';
if (isset($parameters['_page'])) {
$fieldName = $parameters['_page'];
unset($parameters['_page']);
}
$parameters[$fieldName] = $page;
return $this->router->generate($route, $parameters);
}
|
[
"public",
"function",
"path",
"(",
"$",
"route",
",",
"$",
"page",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"fieldName",
"=",
"'page'",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'_page'",
"]",
")",
")",
"{",
"$",
"fieldName",
"=",
"$",
"parameters",
"[",
"'_page'",
"]",
";",
"unset",
"(",
"$",
"parameters",
"[",
"'_page'",
"]",
")",
";",
"}",
"$",
"parameters",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"page",
";",
"return",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"$",
"route",
",",
"$",
"parameters",
")",
";",
"}"
] |
Generates url to certain page.
@param string $route
@param string $page
@param array $parameters
@return string
|
[
"Generates",
"url",
"to",
"certain",
"page",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Twig/PagerExtension.php#L89-L101
|
223,728
|
QoboLtd/cakephp-calendar
|
src/Shell/Task/SyncTask.php
|
SyncTask.getOptionParser
|
public function getOptionParser()
{
$parser = parent::getOptionParser();
$parser->setDescription(
(string)__('Synchronize local and remote calendars with the database')
);
$parser->addOption('start', [
'description' => (string)__('Specify start interval for the events to fetch'),
'help' => (string)__("Start date 'YYYY-MM-DD HH:MM:SS' for events to fetch"),
]);
$parser->addOption('end', [
'description' => (string)__('Specify end interval for the events to fetch'),
'help' => (string)__("End date 'YYYY-MM-DD HH:MM:SS' for events to fetch"),
]);
return $parser;
}
|
php
|
public function getOptionParser()
{
$parser = parent::getOptionParser();
$parser->setDescription(
(string)__('Synchronize local and remote calendars with the database')
);
$parser->addOption('start', [
'description' => (string)__('Specify start interval for the events to fetch'),
'help' => (string)__("Start date 'YYYY-MM-DD HH:MM:SS' for events to fetch"),
]);
$parser->addOption('end', [
'description' => (string)__('Specify end interval for the events to fetch'),
'help' => (string)__("End date 'YYYY-MM-DD HH:MM:SS' for events to fetch"),
]);
return $parser;
}
|
[
"public",
"function",
"getOptionParser",
"(",
")",
"{",
"$",
"parser",
"=",
"parent",
"::",
"getOptionParser",
"(",
")",
";",
"$",
"parser",
"->",
"setDescription",
"(",
"(",
"string",
")",
"__",
"(",
"'Synchronize local and remote calendars with the database'",
")",
")",
";",
"$",
"parser",
"->",
"addOption",
"(",
"'start'",
",",
"[",
"'description'",
"=>",
"(",
"string",
")",
"__",
"(",
"'Specify start interval for the events to fetch'",
")",
",",
"'help'",
"=>",
"(",
"string",
")",
"__",
"(",
"\"Start date 'YYYY-MM-DD HH:MM:SS' for events to fetch\"",
")",
",",
"]",
")",
";",
"$",
"parser",
"->",
"addOption",
"(",
"'end'",
",",
"[",
"'description'",
"=>",
"(",
"string",
")",
"__",
"(",
"'Specify end interval for the events to fetch'",
")",
",",
"'help'",
"=>",
"(",
"string",
")",
"__",
"(",
"\"End date 'YYYY-MM-DD HH:MM:SS' for events to fetch\"",
")",
",",
"]",
")",
";",
"return",
"$",
"parser",
";",
"}"
] |
Manage available options via Parser
@return \Cake\Console\ConsoleOptionParser
|
[
"Manage",
"available",
"options",
"via",
"Parser"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Shell/Task/SyncTask.php#L42-L60
|
223,729
|
QoboLtd/cakephp-calendar
|
src/Shell/Task/SyncTask.php
|
SyncTask.setDefaultTimePeriod
|
protected function setDefaultTimePeriod(array $params = []): array
{
$options = [];
if (!empty($params['start'])) {
$options['period']['start_date'] = $params['start'];
}
if (!empty($params['end'])) {
$options['period']['end_date'] = $params['end'];
}
return $options;
}
|
php
|
protected function setDefaultTimePeriod(array $params = []): array
{
$options = [];
if (!empty($params['start'])) {
$options['period']['start_date'] = $params['start'];
}
if (!empty($params['end'])) {
$options['period']['end_date'] = $params['end'];
}
return $options;
}
|
[
"protected",
"function",
"setDefaultTimePeriod",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'start'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'start_date'",
"]",
"=",
"$",
"params",
"[",
"'start'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'end'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'period'",
"]",
"[",
"'end_date'",
"]",
"=",
"$",
"params",
"[",
"'end'",
"]",
";",
"}",
"return",
"$",
"options",
";",
"}"
] |
Set Default Time period
@param mixed[] $params with CLI period options
@return mixed[] $options with prepopulated opts.
|
[
"Set",
"Default",
"Time",
"period"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Shell/Task/SyncTask.php#L150-L162
|
223,730
|
QoboLtd/cakephp-calendar
|
src/Object/ObjectFactory.php
|
ObjectFactory.getModuleFiles
|
public static function getModuleFiles(?string $path = null): array
{
$configs = [];
if (empty($path)) {
throw new InvalidArgumentException((string)__('Specify [path] for the JSON configs'));
}
$folder = new Folder($path);
$files = $folder->findRecursive('.*\.json');
if (!empty($files)) {
$configs = $files;
}
return $configs;
}
|
php
|
public static function getModuleFiles(?string $path = null): array
{
$configs = [];
if (empty($path)) {
throw new InvalidArgumentException((string)__('Specify [path] for the JSON configs'));
}
$folder = new Folder($path);
$files = $folder->findRecursive('.*\.json');
if (!empty($files)) {
$configs = $files;
}
return $configs;
}
|
[
"public",
"static",
"function",
"getModuleFiles",
"(",
"?",
"string",
"$",
"path",
"=",
"null",
")",
":",
"array",
"{",
"$",
"configs",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"(",
"string",
")",
"__",
"(",
"'Specify [path] for the JSON configs'",
")",
")",
";",
"}",
"$",
"folder",
"=",
"new",
"Folder",
"(",
"$",
"path",
")",
";",
"$",
"files",
"=",
"$",
"folder",
"->",
"findRecursive",
"(",
"'.*\\.json'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"$",
"configs",
"=",
"$",
"files",
";",
"}",
"return",
"$",
"configs",
";",
"}"
] |
Get JSON config files to map entities
@param string|null $path to map directory config/Modules/Integrations/
@return string[]
|
[
"Get",
"JSON",
"config",
"files",
"to",
"map",
"entities"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Object/ObjectFactory.php#L138-L154
|
223,731
|
QoboLtd/cakephp-calendar
|
src/Object/ObjectFactory.php
|
ObjectFactory.getModuleConfigNames
|
public static function getModuleConfigNames(string $entityName, array $files = [], string $path = ''): array
{
$configs = [];
foreach ($files as $k => $file) {
$label = str_replace($path, '', $file);
$label = str_replace('.json', '', $label);
$parts = array_filter(explode('/', $label));
$parts = array_values($parts);
foreach ($parts as $key => $part) {
$parts[$key] = Inflector::camelize($part);
}
array_unshift($parts, 'Json', $entityName);
$name = implode(self::TYPE_DELIMITER, $parts);
$configs[$file] = $name;
}
return $configs;
}
|
php
|
public static function getModuleConfigNames(string $entityName, array $files = [], string $path = ''): array
{
$configs = [];
foreach ($files as $k => $file) {
$label = str_replace($path, '', $file);
$label = str_replace('.json', '', $label);
$parts = array_filter(explode('/', $label));
$parts = array_values($parts);
foreach ($parts as $key => $part) {
$parts[$key] = Inflector::camelize($part);
}
array_unshift($parts, 'Json', $entityName);
$name = implode(self::TYPE_DELIMITER, $parts);
$configs[$file] = $name;
}
return $configs;
}
|
[
"public",
"static",
"function",
"getModuleConfigNames",
"(",
"string",
"$",
"entityName",
",",
"array",
"$",
"files",
"=",
"[",
"]",
",",
"string",
"$",
"path",
"=",
"''",
")",
":",
"array",
"{",
"$",
"configs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"k",
"=>",
"$",
"file",
")",
"{",
"$",
"label",
"=",
"str_replace",
"(",
"$",
"path",
",",
"''",
",",
"$",
"file",
")",
";",
"$",
"label",
"=",
"str_replace",
"(",
"'.json'",
",",
"''",
",",
"$",
"label",
")",
";",
"$",
"parts",
"=",
"array_filter",
"(",
"explode",
"(",
"'/'",
",",
"$",
"label",
")",
")",
";",
"$",
"parts",
"=",
"array_values",
"(",
"$",
"parts",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"key",
"=>",
"$",
"part",
")",
"{",
"$",
"parts",
"[",
"$",
"key",
"]",
"=",
"Inflector",
"::",
"camelize",
"(",
"$",
"part",
")",
";",
"}",
"array_unshift",
"(",
"$",
"parts",
",",
"'Json'",
",",
"$",
"entityName",
")",
";",
"$",
"name",
"=",
"implode",
"(",
"self",
"::",
"TYPE_DELIMITER",
",",
"$",
"parts",
")",
";",
"$",
"configs",
"[",
"$",
"file",
"]",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"configs",
";",
"}"
] |
Trim down the list of configs based on the file paths
@param string $entityName of the object, aka 'Calls'
@param string[] $files from the given config directory
@param string $path of the basename
@return mixed[] $configs with files converted to human-readable format
|
[
"Trim",
"down",
"the",
"list",
"of",
"configs",
"based",
"on",
"the",
"file",
"paths"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Object/ObjectFactory.php#L165-L186
|
223,732
|
szmnmichalowski/ZF2-NoCaptcha
|
src/NoCaptcha/Service/ReCaptcha.php
|
ReCaptcha.verify
|
public function verify($response)
{
if (!$this->secretKey) {
throw new Exception('Missing secret key');
}
$params = array(
'secret' => $this->secretKey,
'response' => $response,
);
if ($this->ip !== null) {
$params['remoteip'] = $this->ip;
}
$this->httpClient->setUri(self::VERIFY_SERVER);
$this->httpClient->setParameterPost($params);
if ($this->options) {
$this->httpClient->setOptions($this->options);
}
$this->httpClient->setMethod('POST');
$response = $this->httpClient->send();
return new CaptchaResponse($response);
}
|
php
|
public function verify($response)
{
if (!$this->secretKey) {
throw new Exception('Missing secret key');
}
$params = array(
'secret' => $this->secretKey,
'response' => $response,
);
if ($this->ip !== null) {
$params['remoteip'] = $this->ip;
}
$this->httpClient->setUri(self::VERIFY_SERVER);
$this->httpClient->setParameterPost($params);
if ($this->options) {
$this->httpClient->setOptions($this->options);
}
$this->httpClient->setMethod('POST');
$response = $this->httpClient->send();
return new CaptchaResponse($response);
}
|
[
"public",
"function",
"verify",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"secretKey",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Missing secret key'",
")",
";",
"}",
"$",
"params",
"=",
"array",
"(",
"'secret'",
"=>",
"$",
"this",
"->",
"secretKey",
",",
"'response'",
"=>",
"$",
"response",
",",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ip",
"!==",
"null",
")",
"{",
"$",
"params",
"[",
"'remoteip'",
"]",
"=",
"$",
"this",
"->",
"ip",
";",
"}",
"$",
"this",
"->",
"httpClient",
"->",
"setUri",
"(",
"self",
"::",
"VERIFY_SERVER",
")",
";",
"$",
"this",
"->",
"httpClient",
"->",
"setParameterPost",
"(",
"$",
"params",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
")",
"{",
"$",
"this",
"->",
"httpClient",
"->",
"setOptions",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}",
"$",
"this",
"->",
"httpClient",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"send",
"(",
")",
";",
"return",
"new",
"CaptchaResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Verify the user input
@param $response
@return Response
@throws \Exception
|
[
"Verify",
"the",
"user",
"input"
] |
f839e9a6b2e9f400b1c6777be0ece995f691cbdb
|
https://github.com/szmnmichalowski/ZF2-NoCaptcha/blob/f839e9a6b2e9f400b1c6777be0ece995f691cbdb/src/NoCaptcha/Service/ReCaptcha.php#L85-L111
|
223,733
|
szmnmichalowski/ZF2-NoCaptcha
|
src/NoCaptcha/Service/ReCaptcha.php
|
ReCaptcha.setOptions
|
public function setOptions($options = array())
{
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (!is_array($options)) {
throw new \Exception('Config parameter is not a valid');
}
foreach ($options as $key => $value) {
$this->options[$key] = $value;
}
return $this;
}
|
php
|
public function setOptions($options = array())
{
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (!is_array($options)) {
throw new \Exception('Config parameter is not a valid');
}
foreach ($options as $key => $value) {
$this->options[$key] = $value;
}
return $this;
}
|
[
"public",
"function",
"setOptions",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"options",
"instanceof",
"Traversable",
")",
"{",
"$",
"options",
"=",
"ArrayUtils",
"::",
"iteratorToArray",
"(",
"$",
"options",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Config parameter is not a valid'",
")",
";",
"}",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set configuration parameters for HTTP client
@param array|Traversable $options
@throws \Exception
@return $this
|
[
"Set",
"configuration",
"parameters",
"for",
"HTTP",
"client"
] |
f839e9a6b2e9f400b1c6777be0ece995f691cbdb
|
https://github.com/szmnmichalowski/ZF2-NoCaptcha/blob/f839e9a6b2e9f400b1c6777be0ece995f691cbdb/src/NoCaptcha/Service/ReCaptcha.php#L129-L144
|
223,734
|
QoboLtd/cakephp-calendar
|
src/Model/Table/Traits/ObjectTrait.php
|
ObjectTrait.getObjectInstance
|
public function getObjectInstance(EntityInterface $entity, $map, ArrayObject $options)
{
$object = null;
$object = new EventObject();
foreach ($map as $field => $config) {
$method = Inflector::variable('set ' . Inflector::variable($field));
if ('field' == $config->type) {
$object->$method($entity->{$config->value});
}
if ('value' == $config->type) {
$object->$method($config->value);
}
if ('callback' == $config->type && method_exists($this, $config->value)) {
$calleeResult = $this->{$config->value}($entity, $options, $map);
$object->$method($calleeResult);
}
}
return $object;
}
|
php
|
public function getObjectInstance(EntityInterface $entity, $map, ArrayObject $options)
{
$object = null;
$object = new EventObject();
foreach ($map as $field => $config) {
$method = Inflector::variable('set ' . Inflector::variable($field));
if ('field' == $config->type) {
$object->$method($entity->{$config->value});
}
if ('value' == $config->type) {
$object->$method($config->value);
}
if ('callback' == $config->type && method_exists($this, $config->value)) {
$calleeResult = $this->{$config->value}($entity, $options, $map);
$object->$method($calleeResult);
}
}
return $object;
}
|
[
"public",
"function",
"getObjectInstance",
"(",
"EntityInterface",
"$",
"entity",
",",
"$",
"map",
",",
"ArrayObject",
"$",
"options",
")",
"{",
"$",
"object",
"=",
"null",
";",
"$",
"object",
"=",
"new",
"EventObject",
"(",
")",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"field",
"=>",
"$",
"config",
")",
"{",
"$",
"method",
"=",
"Inflector",
"::",
"variable",
"(",
"'set '",
".",
"Inflector",
"::",
"variable",
"(",
"$",
"field",
")",
")",
";",
"if",
"(",
"'field'",
"==",
"$",
"config",
"->",
"type",
")",
"{",
"$",
"object",
"->",
"$",
"method",
"(",
"$",
"entity",
"->",
"{",
"$",
"config",
"->",
"value",
"}",
")",
";",
"}",
"if",
"(",
"'value'",
"==",
"$",
"config",
"->",
"type",
")",
"{",
"$",
"object",
"->",
"$",
"method",
"(",
"$",
"config",
"->",
"value",
")",
";",
"}",
"if",
"(",
"'callback'",
"==",
"$",
"config",
"->",
"type",
"&&",
"method_exists",
"(",
"$",
"this",
",",
"$",
"config",
"->",
"value",
")",
")",
"{",
"$",
"calleeResult",
"=",
"$",
"this",
"->",
"{",
"$",
"config",
"->",
"value",
"}",
"(",
"$",
"entity",
",",
"$",
"options",
",",
"$",
"map",
")",
";",
"$",
"object",
"->",
"$",
"method",
"(",
"$",
"calleeResult",
")",
";",
"}",
"}",
"return",
"$",
"object",
";",
"}"
] |
Get Object Type instance
Return prepopulated Object instance for being later saved in the db.
@param \Cake\Datasource\EntityInterface $entity to be converted
@param \stdClass $map containing ORM\Entity translation to Object instance
@param \ArrayObject $options with passed from the app
@return \Qobo\Calendar\Object\ObjectInterface $object
|
[
"Get",
"Object",
"Type",
"instance"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/Traits/ObjectTrait.php#L28-L52
|
223,735
|
QoboLtd/cakephp-calendar
|
src/Model/Table/Traits/ObjectTrait.php
|
ObjectTrait.getEventType
|
public function getEventType(EntityInterface $entity, ArrayObject $options, $map = null)
{
$result = 'Json::' . $entity->getSource() . '::Default';
if (! empty($options['event_type'])) {
$result = $options['event_type'];
}
return $result;
}
|
php
|
public function getEventType(EntityInterface $entity, ArrayObject $options, $map = null)
{
$result = 'Json::' . $entity->getSource() . '::Default';
if (! empty($options['event_type'])) {
$result = $options['event_type'];
}
return $result;
}
|
[
"public",
"function",
"getEventType",
"(",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
",",
"$",
"map",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"'Json::'",
".",
"$",
"entity",
"->",
"getSource",
"(",
")",
".",
"'::Default'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'event_type'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"options",
"[",
"'event_type'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get Default Event Type
@param \Cake\Datasource\EntityInterface $entity resource
@param \ArrayObject $options of the entity
@param mixed|null $map to transfer the object
@return string $result of event type
|
[
"Get",
"Default",
"Event",
"Type"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/Traits/ObjectTrait.php#L63-L72
|
223,736
|
QoboLtd/cakephp-calendar
|
src/Model/Table/Traits/ObjectTrait.php
|
ObjectTrait.getCalendarId
|
public function getCalendarId(EntityInterface $entity, ArrayObject $options, $map = null)
{
$result = null;
if (empty($options['calendar'])) {
return $result;
}
$result = $options['calendar']->id;
return $result;
}
|
php
|
public function getCalendarId(EntityInterface $entity, ArrayObject $options, $map = null)
{
$result = null;
if (empty($options['calendar'])) {
return $result;
}
$result = $options['calendar']->id;
return $result;
}
|
[
"public",
"function",
"getCalendarId",
"(",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
",",
"$",
"map",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'calendar'",
"]",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"$",
"options",
"[",
"'calendar'",
"]",
"->",
"id",
";",
"return",
"$",
"result",
";",
"}"
] |
Get Calendar ID.
@param \Cake\Datasource\EntityInterface $entity of the received record
@param \ArrayObject $options passed from the event
@param array $map of the object
@return string|null $result of the record
|
[
"Get",
"Calendar",
"ID",
"."
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/Traits/ObjectTrait.php#L83-L94
|
223,737
|
QoboLtd/cakephp-calendar
|
src/Model/Table/Traits/ObjectTrait.php
|
ObjectTrait.getCalendarEventEndDate
|
public function getCalendarEventEndDate(EntityInterface $entity, ArrayObject $options, $map = null)
{
$source = $map->end_date->options->source;
$ts = Time::parse($entity->get($source));
$endDate = $ts->modify('+ 1 hour')->i18nFormat('yyyy-MM-dd HH:mm');
$result = new Time($endDate);
return $result;
}
|
php
|
public function getCalendarEventEndDate(EntityInterface $entity, ArrayObject $options, $map = null)
{
$source = $map->end_date->options->source;
$ts = Time::parse($entity->get($source));
$endDate = $ts->modify('+ 1 hour')->i18nFormat('yyyy-MM-dd HH:mm');
$result = new Time($endDate);
return $result;
}
|
[
"public",
"function",
"getCalendarEventEndDate",
"(",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
",",
"$",
"map",
"=",
"null",
")",
"{",
"$",
"source",
"=",
"$",
"map",
"->",
"end_date",
"->",
"options",
"->",
"source",
";",
"$",
"ts",
"=",
"Time",
"::",
"parse",
"(",
"$",
"entity",
"->",
"get",
"(",
"$",
"source",
")",
")",
";",
"$",
"endDate",
"=",
"$",
"ts",
"->",
"modify",
"(",
"'+ 1 hour'",
")",
"->",
"i18nFormat",
"(",
"'yyyy-MM-dd HH:mm'",
")",
";",
"$",
"result",
"=",
"new",
"Time",
"(",
"$",
"endDate",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Get Calendar Event end_date
@param \Cake\Datasource\EntityInterface $entity of the event
@param \ArrayObject $options based on the configs
@param array $map of the config
@return \Cake\I18n\Time
|
[
"Get",
"Calendar",
"Event",
"end_date"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/Traits/ObjectTrait.php#L105-L115
|
223,738
|
QoboLtd/cakephp-calendar
|
src/Model/Table/Traits/ObjectTrait.php
|
ObjectTrait.getCalendarEventTitle
|
public function getCalendarEventTitle(EntityInterface $entity, ArrayObject $options, $map = null)
{
$table = TableRegistry::getTableLocator()->get($entity->source());
$displayField = $entity->get($table->getDisplayField());
$result = sprintf("%s - %s", Inflector::humanize($entity->source()), $displayField);
return $result;
}
|
php
|
public function getCalendarEventTitle(EntityInterface $entity, ArrayObject $options, $map = null)
{
$table = TableRegistry::getTableLocator()->get($entity->source());
$displayField = $entity->get($table->getDisplayField());
$result = sprintf("%s - %s", Inflector::humanize($entity->source()), $displayField);
return $result;
}
|
[
"public",
"function",
"getCalendarEventTitle",
"(",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
",",
"$",
"map",
"=",
"null",
")",
"{",
"$",
"table",
"=",
"TableRegistry",
"::",
"getTableLocator",
"(",
")",
"->",
"get",
"(",
"$",
"entity",
"->",
"source",
"(",
")",
")",
";",
"$",
"displayField",
"=",
"$",
"entity",
"->",
"get",
"(",
"$",
"table",
"->",
"getDisplayField",
"(",
")",
")",
";",
"$",
"result",
"=",
"sprintf",
"(",
"\"%s - %s\"",
",",
"Inflector",
"::",
"humanize",
"(",
"$",
"entity",
"->",
"source",
"(",
")",
")",
",",
"$",
"displayField",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Get Calendar Event Title
@param \Cake\Datasource\EntityInterface $entity of the event
@param \ArrayObject $options of the configs
@param array $map of the config fields
@return string
|
[
"Get",
"Calendar",
"Event",
"Title"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/Traits/ObjectTrait.php#L126-L135
|
223,739
|
QoboLtd/cakephp-calendar
|
src/Model/Table/Traits/ObjectTrait.php
|
ObjectTrait.getCalendarEventContent
|
public function getCalendarEventContent(EntityInterface $entity, ArrayObject $options, $map = null)
{
$source = $map->content->options->source;
$result = $entity->get($source);
if (!empty($options['viewEntity'])) {
$url = $options['viewEntity']->Html->link(__('Source'), ['action' => 'view', $entity->get('id')]);
$result .= "<br/><p>Reference: $url </p>";
}
return $result;
}
|
php
|
public function getCalendarEventContent(EntityInterface $entity, ArrayObject $options, $map = null)
{
$source = $map->content->options->source;
$result = $entity->get($source);
if (!empty($options['viewEntity'])) {
$url = $options['viewEntity']->Html->link(__('Source'), ['action' => 'view', $entity->get('id')]);
$result .= "<br/><p>Reference: $url </p>";
}
return $result;
}
|
[
"public",
"function",
"getCalendarEventContent",
"(",
"EntityInterface",
"$",
"entity",
",",
"ArrayObject",
"$",
"options",
",",
"$",
"map",
"=",
"null",
")",
"{",
"$",
"source",
"=",
"$",
"map",
"->",
"content",
"->",
"options",
"->",
"source",
";",
"$",
"result",
"=",
"$",
"entity",
"->",
"get",
"(",
"$",
"source",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'viewEntity'",
"]",
")",
")",
"{",
"$",
"url",
"=",
"$",
"options",
"[",
"'viewEntity'",
"]",
"->",
"Html",
"->",
"link",
"(",
"__",
"(",
"'Source'",
")",
",",
"[",
"'action'",
"=>",
"'view'",
",",
"$",
"entity",
"->",
"get",
"(",
"'id'",
")",
"]",
")",
";",
"$",
"result",
".=",
"\"<br/><p>Reference: $url </p>\"",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get Calendar Event Content
Prepopulate content of the calendar event with backlink to source
@param \Cake\Datasource\EntityInterface $entity of the origin orm
@param \ArrayObject $options of the configs
@param array $map of the config conversion
@return string
|
[
"Get",
"Calendar",
"Event",
"Content"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/Traits/ObjectTrait.php#L148-L160
|
223,740
|
puli/manager
|
src/Api/Server/Server.php
|
Server.getParameterValue
|
public function getParameterValue($name)
{
if (!isset($this->parameterValues[$name])) {
throw NoSuchParameterException::forParameterName($name, $this->installerName);
}
return $this->parameterValues[$name];
}
|
php
|
public function getParameterValue($name)
{
if (!isset($this->parameterValues[$name])) {
throw NoSuchParameterException::forParameterName($name, $this->installerName);
}
return $this->parameterValues[$name];
}
|
[
"public",
"function",
"getParameterValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"parameterValues",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"NoSuchParameterException",
"::",
"forParameterName",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"installerName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"parameterValues",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns the value of the given parameter.
@param string $name The parameter name.
@return string The parameter value.
@throws NoSuchParameterException If the parameter was not found.
|
[
"Returns",
"the",
"value",
"of",
"the",
"given",
"parameter",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Server/Server.php#L154-L161
|
223,741
|
apoutchika/MediaBundle
|
Services/Filter.php
|
Filter.set
|
public function set($name)
{
$filters = array_unique ($this->session->get('filters', array()));
if (in_array ($name, $filters)) {
return array_search ($name, $filters);
}
$filterKey = 'filter_'.sha1(microtime(true).mt_rand().$name);
$filters[$filterKey] = $name;
$this->session->set('filters', $filters);
return $filterKey;
}
|
php
|
public function set($name)
{
$filters = array_unique ($this->session->get('filters', array()));
if (in_array ($name, $filters)) {
return array_search ($name, $filters);
}
$filterKey = 'filter_'.sha1(microtime(true).mt_rand().$name);
$filters[$filterKey] = $name;
$this->session->set('filters', $filters);
return $filterKey;
}
|
[
"public",
"function",
"set",
"(",
"$",
"name",
")",
"{",
"$",
"filters",
"=",
"array_unique",
"(",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'filters'",
",",
"array",
"(",
")",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"filters",
")",
")",
"{",
"return",
"array_search",
"(",
"$",
"name",
",",
"$",
"filters",
")",
";",
"}",
"$",
"filterKey",
"=",
"'filter_'",
".",
"sha1",
"(",
"microtime",
"(",
"true",
")",
".",
"mt_rand",
"(",
")",
".",
"$",
"name",
")",
";",
"$",
"filters",
"[",
"$",
"filterKey",
"]",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"'filters'",
",",
"$",
"filters",
")",
";",
"return",
"$",
"filterKey",
";",
"}"
] |
set filter.
@param string $name
@return string Key of new filter
|
[
"set",
"filter",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/Filter.php#L42-L55
|
223,742
|
puli/manager
|
src/Api/Config/Config.php
|
Config.get
|
public function get($key, $default = null, $fallback = true)
{
return $this->replacePlaceholders($this->getRaw($key, $default, $fallback), $fallback);
}
|
php
|
public function get($key, $default = null, $fallback = true)
{
return $this->replacePlaceholders($this->getRaw($key, $default, $fallback), $fallback);
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"replacePlaceholders",
"(",
"$",
"this",
"->",
"getRaw",
"(",
"$",
"key",
",",
"$",
"default",
",",
"$",
"fallback",
")",
",",
"$",
"fallback",
")",
";",
"}"
] |
Returns the value of a configuration key.
If fallback is enabled, the value of the base configuration is returned
if the key was not set.
You can also pass a default value in the second parameter. This default
value is returned if the configuration key was neither found in this nor
in its fallback configuration.
@param string $key The configuration key.
@param mixed $default The value to return if the key was not set.
@param bool $fallback Whether to return the value of the base
configuration if the key was not set.
@return mixed The value of the configuration key.
@throws NoSuchConfigKeyException If the configuration key is invalid.
|
[
"Returns",
"the",
"value",
"of",
"a",
"configuration",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L287-L290
|
223,743
|
puli/manager
|
src/Api/Config/Config.php
|
Config.getRaw
|
public function getRaw($key, $default = null, $fallback = true)
{
if (isset(self::$compositeKeys[$key])) {
return array_replace_recursive(
is_array($default) ? $default : array(),
$fallback && $this->baseConfig ? $this->baseConfig->getRaw($key) : array(),
$this->filterByKeyPrefix($key.'.')
);
}
if (!isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
if (!array_key_exists($key, $this->values) && $fallback && $this->baseConfig) {
return $this->baseConfig->getRaw($key, $default);
}
return isset($this->values[$key]) ? $this->values[$key] : $default;
}
|
php
|
public function getRaw($key, $default = null, $fallback = true)
{
if (isset(self::$compositeKeys[$key])) {
return array_replace_recursive(
is_array($default) ? $default : array(),
$fallback && $this->baseConfig ? $this->baseConfig->getRaw($key) : array(),
$this->filterByKeyPrefix($key.'.')
);
}
if (!isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
if (!array_key_exists($key, $this->values) && $fallback && $this->baseConfig) {
return $this->baseConfig->getRaw($key, $default);
}
return isset($this->values[$key]) ? $this->values[$key] : $default;
}
|
[
"public",
"function",
"getRaw",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"compositeKeys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"array_replace_recursive",
"(",
"is_array",
"(",
"$",
"default",
")",
"?",
"$",
"default",
":",
"array",
"(",
")",
",",
"$",
"fallback",
"&&",
"$",
"this",
"->",
"baseConfig",
"?",
"$",
"this",
"->",
"baseConfig",
"->",
"getRaw",
"(",
"$",
"key",
")",
":",
"array",
"(",
")",
",",
"$",
"this",
"->",
"filterByKeyPrefix",
"(",
"$",
"key",
".",
"'.'",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"NoSuchConfigKeyException",
"::",
"forKey",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"values",
")",
"&&",
"$",
"fallback",
"&&",
"$",
"this",
"->",
"baseConfig",
")",
"{",
"return",
"$",
"this",
"->",
"baseConfig",
"->",
"getRaw",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}"
] |
Returns the raw value of a configuration key.
Unlike {@link get()}, this method does not resolve placeholders:
```php
$config = new Config();
$config->set(Config::PULI_DIR, '.puli');
$config->set(Config::INSTALL_FILE, '{$puli-dir}/install-file.json');
echo $config->get(Config::PULI_DIR);
// => .puli/install-file.json
echo $config->getRaw(Config::PULI_DIR);
// => {$puli-dir}/install-file.json
```
@param string $key The configuration key.
@param mixed $default The value to return if the key was not set.
@param bool $fallback Whether to return the value of the base
configuration if the key was not set.
@return mixed The value of the configuration key.
@throws NoSuchConfigKeyException If the configuration key is invalid.
|
[
"Returns",
"the",
"raw",
"value",
"of",
"a",
"configuration",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L318-L337
|
223,744
|
puli/manager
|
src/Api/Config/Config.php
|
Config.contains
|
public function contains($key, $fallback = true)
{
if (!isset(self::$compositeKeys[$key]) && !isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
if (array_key_exists($key, $this->values)) {
return true;
}
if (isset(self::$compositeKeys[$key]) && $this->containsKeyPrefix($key.'.')) {
return true;
}
if ($fallback && $this->baseConfig) {
return $this->baseConfig->contains($key);
}
return false;
}
|
php
|
public function contains($key, $fallback = true)
{
if (!isset(self::$compositeKeys[$key]) && !isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
if (array_key_exists($key, $this->values)) {
return true;
}
if (isset(self::$compositeKeys[$key]) && $this->containsKeyPrefix($key.'.')) {
return true;
}
if ($fallback && $this->baseConfig) {
return $this->baseConfig->contains($key);
}
return false;
}
|
[
"public",
"function",
"contains",
"(",
"$",
"key",
",",
"$",
"fallback",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"compositeKeys",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"isset",
"(",
"self",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"NoSuchConfigKeyException",
"::",
"forKey",
"(",
"$",
"key",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"compositeKeys",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"this",
"->",
"containsKeyPrefix",
"(",
"$",
"key",
".",
"'.'",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"fallback",
"&&",
"$",
"this",
"->",
"baseConfig",
")",
"{",
"return",
"$",
"this",
"->",
"baseConfig",
"->",
"contains",
"(",
"$",
"key",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns whether a configuration key is set.
@param string $key The configuration key to search.
@param bool $fallback Whether to check the base configuration if the
key is not found.
@return bool Returns `true` if the configuration key is set.
@throws NoSuchConfigKeyException If the configuration key is invalid.
|
[
"Returns",
"whether",
"a",
"configuration",
"key",
"is",
"set",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L350-L369
|
223,745
|
puli/manager
|
src/Api/Config/Config.php
|
Config.set
|
public function set($key, $value)
{
if (isset(self::$compositeKeys[$key])) {
$this->assertArray($key, $value);
$this->removeByKeyPrefix($key.'.');
foreach ($value as $k => $v) {
$this->set($key.'.'.$k, $v);
}
return;
}
if (!isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
$this->validate($key, $value);
$this->values[$key] = $value;
}
|
php
|
public function set($key, $value)
{
if (isset(self::$compositeKeys[$key])) {
$this->assertArray($key, $value);
$this->removeByKeyPrefix($key.'.');
foreach ($value as $k => $v) {
$this->set($key.'.'.$k, $v);
}
return;
}
if (!isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
$this->validate($key, $value);
$this->values[$key] = $value;
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"compositeKeys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"assertArray",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"removeByKeyPrefix",
"(",
"$",
"key",
".",
"'.'",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
".",
"'.'",
".",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"NoSuchConfigKeyException",
"::",
"forKey",
"(",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"validate",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets the value of a configuration key.
@param string $key The configuration key.
@param mixed $value The value to set.
@throws NoSuchConfigKeyException If the configuration key is invalid.
@throws InvalidConfigException If the value is invalid.
|
[
"Sets",
"the",
"value",
"of",
"a",
"configuration",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L380-L400
|
223,746
|
puli/manager
|
src/Api/Config/Config.php
|
Config.remove
|
public function remove($key)
{
if (isset(self::$compositeKeys[$key])) {
$this->removeByKeyPrefix($key.'.');
return;
}
if (!isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
unset($this->values[$key]);
}
|
php
|
public function remove($key)
{
if (isset(self::$compositeKeys[$key])) {
$this->removeByKeyPrefix($key.'.');
return;
}
if (!isset(self::$keys[$key])) {
throw NoSuchConfigKeyException::forKey($key);
}
unset($this->values[$key]);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"compositeKeys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"removeByKeyPrefix",
"(",
"$",
"key",
".",
"'.'",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"keys",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"NoSuchConfigKeyException",
"::",
"forKey",
"(",
"$",
"key",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Removes a configuration key.
If the configuration has a base configuration, the default value will
be returned by {@link get()} after removing the key.
@param string $key The configuration key to remove.
@throws NoSuchConfigKeyException If the configuration key is invalid.
|
[
"Removes",
"a",
"configuration",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L441-L454
|
223,747
|
puli/manager
|
src/Api/Config/Config.php
|
Config.toFlatRawArray
|
public function toFlatRawArray($includeFallback = true)
{
return $includeFallback && $this->baseConfig
? array_replace($this->baseConfig->toFlatRawArray(), $this->values)
: $this->values;
}
|
php
|
public function toFlatRawArray($includeFallback = true)
{
return $includeFallback && $this->baseConfig
? array_replace($this->baseConfig->toFlatRawArray(), $this->values)
: $this->values;
}
|
[
"public",
"function",
"toFlatRawArray",
"(",
"$",
"includeFallback",
"=",
"true",
")",
"{",
"return",
"$",
"includeFallback",
"&&",
"$",
"this",
"->",
"baseConfig",
"?",
"array_replace",
"(",
"$",
"this",
"->",
"baseConfig",
"->",
"toFlatRawArray",
"(",
")",
",",
"$",
"this",
"->",
"values",
")",
":",
"$",
"this",
"->",
"values",
";",
"}"
] |
Returns all raw configuration values as flat array.
Unlike {@link toFlatArray()}, this method does not resolve placeholders:
```php
$config = new Config();
$config->set(Config::PULI_DIR, '.puli');
$config->set(Config::REGISTRY_FILE, '{$puli-dir}/ServiceRegistry.php');
print_r($config->toFlatArray());
// Array(
// 'puli-dir' => '.puli',
// 'registry-file' => '.puli/ServiceRegistry.php',
// )
print_r($config->toFlatRawArray());
// Array(
// 'puli-dir' => '.puli',
// 'registry-file' => '{$puli-dir}/ServiceRegistry.php',
// )
```
@param bool $includeFallback Whether to include values set in the base
configuration passed to {@link __construct()}.
@return array The raw configuration values.
|
[
"Returns",
"all",
"raw",
"configuration",
"values",
"as",
"flat",
"array",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L508-L513
|
223,748
|
puli/manager
|
src/Api/Config/Config.php
|
Config.toRawArray
|
public function toRawArray($includeFallback = true)
{
$values = array();
foreach ($this->values as $key => $value) {
$this->addKeyValue($key, $value, $values);
}
return $includeFallback && $this->baseConfig
? array_replace_recursive($this->baseConfig->toRawArray(), $values)
: $values;
}
|
php
|
public function toRawArray($includeFallback = true)
{
$values = array();
foreach ($this->values as $key => $value) {
$this->addKeyValue($key, $value, $values);
}
return $includeFallback && $this->baseConfig
? array_replace_recursive($this->baseConfig->toRawArray(), $values)
: $values;
}
|
[
"public",
"function",
"toRawArray",
"(",
"$",
"includeFallback",
"=",
"true",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addKeyValue",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"values",
")",
";",
"}",
"return",
"$",
"includeFallback",
"&&",
"$",
"this",
"->",
"baseConfig",
"?",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"baseConfig",
"->",
"toRawArray",
"(",
")",
",",
"$",
"values",
")",
":",
"$",
"values",
";",
"}"
] |
Returns all raw configuration values as nested array.
Unlike {@link toArray()}, this method does not resolve placeholders:
```php
$config = new Config();
$config->set(Config::PULI_DIR, '.puli');
$config->set(Config::REPO_STORAGE_DIR, '{$puli-dir}/repository');
print_r($config->toArray());
// Array(
// 'puli-dir' => '.puli',
// 'repository. => array(
// 'storage-dir' => '.puli/repository',
// ),
// )
print_r($config->toRawArray());
// Array(
// 'puli-dir' => '.puli',
// 'repository. => array(
// 'storage-dir' => '{$puli-dir}/repository',
// ),
// )
```
@param bool $includeFallback Whether to include values set in the base
configuration passed to {@link __construct()}.
@return array The raw configuration values.
|
[
"Returns",
"all",
"raw",
"configuration",
"values",
"as",
"nested",
"array",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L560-L571
|
223,749
|
puli/manager
|
src/Api/Config/Config.php
|
Config.isEmpty
|
public function isEmpty($includeFallback = true)
{
if (!empty($this->values)) {
return false;
}
return $includeFallback && $this->baseConfig
? $this->baseConfig->isEmpty(true)
: true;
}
|
php
|
public function isEmpty($includeFallback = true)
{
if (!empty($this->values)) {
return false;
}
return $includeFallback && $this->baseConfig
? $this->baseConfig->isEmpty(true)
: true;
}
|
[
"public",
"function",
"isEmpty",
"(",
"$",
"includeFallback",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"values",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"includeFallback",
"&&",
"$",
"this",
"->",
"baseConfig",
"?",
"$",
"this",
"->",
"baseConfig",
"->",
"isEmpty",
"(",
"true",
")",
":",
"true",
";",
"}"
] |
Returns whether the configuration is empty.
@param bool $includeFallback Whether to include values set in the base
configuration passed to {@link __construct()}.
@return bool Returns `true` if no key is set and `false` otherwise.
|
[
"Returns",
"whether",
"the",
"configuration",
"is",
"empty",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Config/Config.php#L581-L590
|
223,750
|
puli/manager
|
src/Repository/Mapping/ConflictCollection.php
|
ConflictCollection.get
|
public function get($repositoryPath)
{
if (!isset($this->conflicts[$repositoryPath])) {
throw new OutOfBoundsException(sprintf(
'No conflict is stored for the path "%s".',
$repositoryPath
));
}
return $this->conflicts[$repositoryPath];
}
|
php
|
public function get($repositoryPath)
{
if (!isset($this->conflicts[$repositoryPath])) {
throw new OutOfBoundsException(sprintf(
'No conflict is stored for the path "%s".',
$repositoryPath
));
}
return $this->conflicts[$repositoryPath];
}
|
[
"public",
"function",
"get",
"(",
"$",
"repositoryPath",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'No conflict is stored for the path \"%s\".'",
",",
"$",
"repositoryPath",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
";",
"}"
] |
Get a path conflict.
@param string $repositoryPath The repository path
@throws OutOfBoundsException If the collection does not contain a conflict for the given repository path.
@return PathConflict The path conflict
|
[
"Get",
"a",
"path",
"conflict",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Repository/Mapping/ConflictCollection.php#L67-L77
|
223,751
|
puli/manager
|
src/Api/Repository/DuplicatePathMappingException.php
|
DuplicatePathMappingException.forRepositoryPath
|
public static function forRepositoryPath($repositoryPath, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The path "%s" is already mapped in module "%s".',
$repositoryPath,
$moduleName
), 0, $cause);
}
|
php
|
public static function forRepositoryPath($repositoryPath, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The path "%s" is already mapped in module "%s".',
$repositoryPath,
$moduleName
), 0, $cause);
}
|
[
"public",
"static",
"function",
"forRepositoryPath",
"(",
"$",
"repositoryPath",
",",
"$",
"moduleName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The path \"%s\" is already mapped in module \"%s\".'",
",",
"$",
"repositoryPath",
",",
"$",
"moduleName",
")",
",",
"0",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for a duplicate repository path.
@param string $repositoryPath The mapped repository path.
@param string $moduleName The name of the module containing
the mapping.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"a",
"duplicate",
"repository",
"path",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/DuplicatePathMappingException.php#L37-L44
|
223,752
|
yosymfony/config-loader
|
src/ConfigLoader.php
|
ConfigLoader.load
|
public function load($resource, $type = null) : RepositoryInterface
{
$repository = $this->resolveLoader($resource, $type)->load($resource, $type);
return $repository;
}
|
php
|
public function load($resource, $type = null) : RepositoryInterface
{
$repository = $this->resolveLoader($resource, $type)->load($resource, $type);
return $repository;
}
|
[
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
":",
"RepositoryInterface",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"resolveLoader",
"(",
"$",
"resource",
",",
"$",
"type",
")",
"->",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
")",
";",
"return",
"$",
"repository",
";",
"}"
] |
Loads a resource such as a file or an inline configuration
@param string $resource Filename or string representation
@param string $type The resource type. Doesn't set this argument in
case of a filename passes as resource
@return RepositoryInterface
@throws LoaderLoadException If the loader not found
|
[
"Loads",
"a",
"resource",
"such",
"as",
"a",
"file",
"or",
"an",
"inline",
"configuration"
] |
47c97f5014e2d1134f8655a1f14fd3504c997cf2
|
https://github.com/yosymfony/config-loader/blob/47c97f5014e2d1134f8655a1f14fd3504c997cf2/src/ConfigLoader.php#L47-L52
|
223,753
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.getUserId
|
public function getUserId() {
if (!$this->authSource->isAuthenticated()) {
return NULL;
}
$attributes = $this->authSource->getAttributes();
if (!array_key_exists($this->usernameAttribute, $attributes)) {
throw new SimpleSAML_Error_Exception('Missing username attribute ' .
var_export($this->usernameAttribute, TRUE) . ' in the attributes of the user.');
}
$values = array_values($attributes[$this->usernameAttribute]);
if (empty($values)) {
throw new SimpleSAML_Error_Exception('Username attribute was empty.');
}
if (count($values) > 1) {
throw new SimpleSAML_Error_Exception('More than one attribute value in username.');
}
$userId = $values[0];
return $userId;
}
|
php
|
public function getUserId() {
if (!$this->authSource->isAuthenticated()) {
return NULL;
}
$attributes = $this->authSource->getAttributes();
if (!array_key_exists($this->usernameAttribute, $attributes)) {
throw new SimpleSAML_Error_Exception('Missing username attribute ' .
var_export($this->usernameAttribute, TRUE) . ' in the attributes of the user.');
}
$values = array_values($attributes[$this->usernameAttribute]);
if (empty($values)) {
throw new SimpleSAML_Error_Exception('Username attribute was empty.');
}
if (count($values) > 1) {
throw new SimpleSAML_Error_Exception('More than one attribute value in username.');
}
$userId = $values[0];
return $userId;
}
|
[
"public",
"function",
"getUserId",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"authSource",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"attributes",
"=",
"$",
"this",
"->",
"authSource",
"->",
"getAttributes",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"this",
"->",
"usernameAttribute",
",",
"$",
"attributes",
")",
")",
"{",
"throw",
"new",
"SimpleSAML_Error_Exception",
"(",
"'Missing username attribute '",
".",
"var_export",
"(",
"$",
"this",
"->",
"usernameAttribute",
",",
"TRUE",
")",
".",
"' in the attributes of the user.'",
")",
";",
"}",
"$",
"values",
"=",
"array_values",
"(",
"$",
"attributes",
"[",
"$",
"this",
"->",
"usernameAttribute",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"SimpleSAML_Error_Exception",
"(",
"'Username attribute was empty.'",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"values",
")",
">",
"1",
")",
"{",
"throw",
"new",
"SimpleSAML_Error_Exception",
"(",
"'More than one attribute value in username.'",
")",
";",
"}",
"$",
"userId",
"=",
"$",
"values",
"[",
"0",
"]",
";",
"return",
"$",
"userId",
";",
"}"
] |
Retrieve the current user ID.
@return string The current user ID, or NULL if the user isn't authenticated.
|
[
"Retrieve",
"the",
"current",
"user",
"ID",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L133-L155
|
223,754
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.getIdentity
|
public function getIdentity() {
$userId = $this->getUserId();
if ($userId === NULL) {
return NULL;
}
$identity = SimpleSAML\Module::getModuleURL('openidProvider/user.php/' . $userId);
return $identity;
}
|
php
|
public function getIdentity() {
$userId = $this->getUserId();
if ($userId === NULL) {
return NULL;
}
$identity = SimpleSAML\Module::getModuleURL('openidProvider/user.php/' . $userId);
return $identity;
}
|
[
"public",
"function",
"getIdentity",
"(",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"getUserId",
"(",
")",
";",
"if",
"(",
"$",
"userId",
"===",
"NULL",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"identity",
"=",
"SimpleSAML",
"\\",
"Module",
"::",
"getModuleURL",
"(",
"'openidProvider/user.php/'",
".",
"$",
"userId",
")",
";",
"return",
"$",
"identity",
";",
"}"
] |
Retrieve the current identity.
@return string The current identity, or NULL if the user isn't authenticated.
|
[
"Retrieve",
"the",
"current",
"identity",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L163-L172
|
223,755
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.addTrustRoot
|
public function addTrustRoot($identity, $trustRoot) {
assert('is_string($identity)');
assert('is_string($trustRoot)');
$trs = $this->getTrustRoots($identity);
if (!in_array($trustRoot, $trs, TRUE)) {
$trs[] = $trustRoot;
}
$this->saveTrustRoots($identity, $trs);
}
|
php
|
public function addTrustRoot($identity, $trustRoot) {
assert('is_string($identity)');
assert('is_string($trustRoot)');
$trs = $this->getTrustRoots($identity);
if (!in_array($trustRoot, $trs, TRUE)) {
$trs[] = $trustRoot;
}
$this->saveTrustRoots($identity, $trs);
}
|
[
"public",
"function",
"addTrustRoot",
"(",
"$",
"identity",
",",
"$",
"trustRoot",
")",
"{",
"assert",
"(",
"'is_string($identity)'",
")",
";",
"assert",
"(",
"'is_string($trustRoot)'",
")",
";",
"$",
"trs",
"=",
"$",
"this",
"->",
"getTrustRoots",
"(",
"$",
"identity",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"trustRoot",
",",
"$",
"trs",
",",
"TRUE",
")",
")",
"{",
"$",
"trs",
"[",
"]",
"=",
"$",
"trustRoot",
";",
"}",
"$",
"this",
"->",
"saveTrustRoots",
"(",
"$",
"identity",
",",
"$",
"trs",
")",
";",
"}"
] |
Add the given trust root to the user.
@param string $identity The identity of the user.
@param string $trustRoot The trust root.
|
[
"Add",
"the",
"given",
"trust",
"root",
"to",
"the",
"user",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L264-L274
|
223,756
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.removeTrustRoot
|
public function removeTrustRoot($identity, $trustRoot) {
assert('is_string($identity)');
assert('is_string($trustRoot)');
$trs = $this->getTrustRoots($identity);
$i = array_search($trustRoot, $trs, TRUE);
if ($i === FALSE) {
return;
}
array_splice($trs, $i, 1, array());
$this->saveTrustRoots($identity, $trs);
}
|
php
|
public function removeTrustRoot($identity, $trustRoot) {
assert('is_string($identity)');
assert('is_string($trustRoot)');
$trs = $this->getTrustRoots($identity);
$i = array_search($trustRoot, $trs, TRUE);
if ($i === FALSE) {
return;
}
array_splice($trs, $i, 1, array());
$this->saveTrustRoots($identity, $trs);
}
|
[
"public",
"function",
"removeTrustRoot",
"(",
"$",
"identity",
",",
"$",
"trustRoot",
")",
"{",
"assert",
"(",
"'is_string($identity)'",
")",
";",
"assert",
"(",
"'is_string($trustRoot)'",
")",
";",
"$",
"trs",
"=",
"$",
"this",
"->",
"getTrustRoots",
"(",
"$",
"identity",
")",
";",
"$",
"i",
"=",
"array_search",
"(",
"$",
"trustRoot",
",",
"$",
"trs",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"i",
"===",
"FALSE",
")",
"{",
"return",
";",
"}",
"array_splice",
"(",
"$",
"trs",
",",
"$",
"i",
",",
"1",
",",
"array",
"(",
")",
")",
";",
"$",
"this",
"->",
"saveTrustRoots",
"(",
"$",
"identity",
",",
"$",
"trs",
")",
";",
"}"
] |
Remove the given trust root from the trust list of the user.
@param string $identity The identity of the user.
@param string $trustRoot The trust root.
|
[
"Remove",
"the",
"given",
"trust",
"root",
"from",
"the",
"trust",
"list",
"of",
"the",
"user",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L283-L295
|
223,757
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.isTrusted
|
private function isTrusted($identity, $trustRoot) {
assert('is_string($identity)');
assert('is_string($trustRoot)');
$trs = $this->getTrustRoots($identity);
return in_array($trustRoot, $trs, TRUE);
}
|
php
|
private function isTrusted($identity, $trustRoot) {
assert('is_string($identity)');
assert('is_string($trustRoot)');
$trs = $this->getTrustRoots($identity);
return in_array($trustRoot, $trs, TRUE);
}
|
[
"private",
"function",
"isTrusted",
"(",
"$",
"identity",
",",
"$",
"trustRoot",
")",
"{",
"assert",
"(",
"'is_string($identity)'",
")",
";",
"assert",
"(",
"'is_string($trustRoot)'",
")",
";",
"$",
"trs",
"=",
"$",
"this",
"->",
"getTrustRoots",
"(",
"$",
"identity",
")",
";",
"return",
"in_array",
"(",
"$",
"trustRoot",
",",
"$",
"trs",
",",
"TRUE",
")",
";",
"}"
] |
Is the given trust root trusted by the user?
@param string $identity The identity of the user.
@param string $trustRoot The trust root.
@return TRUE if it is trusted, FALSE if not.
|
[
"Is",
"the",
"given",
"trust",
"root",
"trusted",
"by",
"the",
"user?"
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L305-L311
|
223,758
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.getStateURL
|
private function getStateURL($page, array $state) {
assert('is_string($page)');
$stateId = SimpleSAML_Auth_State::saveState($state, 'openidProvider:resumeState');
$stateURL = SimpleSAML\Module::getModuleURL('openidProvider/' . $page);
$stateURL = \SimpleSAML\Utils\HTTP::addURLParameters($stateURL, array('StateID' => $stateId));
return $stateURL;
}
|
php
|
private function getStateURL($page, array $state) {
assert('is_string($page)');
$stateId = SimpleSAML_Auth_State::saveState($state, 'openidProvider:resumeState');
$stateURL = SimpleSAML\Module::getModuleURL('openidProvider/' . $page);
$stateURL = \SimpleSAML\Utils\HTTP::addURLParameters($stateURL, array('StateID' => $stateId));
return $stateURL;
}
|
[
"private",
"function",
"getStateURL",
"(",
"$",
"page",
",",
"array",
"$",
"state",
")",
"{",
"assert",
"(",
"'is_string($page)'",
")",
";",
"$",
"stateId",
"=",
"SimpleSAML_Auth_State",
"::",
"saveState",
"(",
"$",
"state",
",",
"'openidProvider:resumeState'",
")",
";",
"$",
"stateURL",
"=",
"SimpleSAML",
"\\",
"Module",
"::",
"getModuleURL",
"(",
"'openidProvider/'",
".",
"$",
"page",
")",
";",
"$",
"stateURL",
"=",
"\\",
"SimpleSAML",
"\\",
"Utils",
"\\",
"HTTP",
"::",
"addURLParameters",
"(",
"$",
"stateURL",
",",
"array",
"(",
"'StateID'",
"=>",
"$",
"stateId",
")",
")",
";",
"return",
"$",
"stateURL",
";",
"}"
] |
Save the state, and return a URL that can contain a reference to the state.
@param string $page The name of the page.
@param array $state The state array.
@return string A URL with the state ID as a parameter.
|
[
"Save",
"the",
"state",
"and",
"return",
"a",
"URL",
"that",
"can",
"contain",
"a",
"reference",
"to",
"the",
"state",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L321-L329
|
223,759
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.sendResponse
|
private function sendResponse(Auth_OpenID_ServerResponse $response) {
SimpleSAML\Logger::debug('openidProvider::sendResponse');
$webresponse = $this->server->encodeResponse($response);
if ($webresponse->code !== 200) {
header('HTTP/1.1 ' . $webresponse->code, TRUE, $webresponse->code);
}
foreach ($webresponse->headers as $k => $v) {
header($k . ': ' . $v);
}
header('Connection: Close');
print($webresponse->body);
exit(0);
}
|
php
|
private function sendResponse(Auth_OpenID_ServerResponse $response) {
SimpleSAML\Logger::debug('openidProvider::sendResponse');
$webresponse = $this->server->encodeResponse($response);
if ($webresponse->code !== 200) {
header('HTTP/1.1 ' . $webresponse->code, TRUE, $webresponse->code);
}
foreach ($webresponse->headers as $k => $v) {
header($k . ': ' . $v);
}
header('Connection: Close');
print($webresponse->body);
exit(0);
}
|
[
"private",
"function",
"sendResponse",
"(",
"Auth_OpenID_ServerResponse",
"$",
"response",
")",
"{",
"SimpleSAML",
"\\",
"Logger",
"::",
"debug",
"(",
"'openidProvider::sendResponse'",
")",
";",
"$",
"webresponse",
"=",
"$",
"this",
"->",
"server",
"->",
"encodeResponse",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"webresponse",
"->",
"code",
"!==",
"200",
")",
"{",
"header",
"(",
"'HTTP/1.1 '",
".",
"$",
"webresponse",
"->",
"code",
",",
"TRUE",
",",
"$",
"webresponse",
"->",
"code",
")",
";",
"}",
"foreach",
"(",
"$",
"webresponse",
"->",
"headers",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"header",
"(",
"$",
"k",
".",
"': '",
".",
"$",
"v",
")",
";",
"}",
"header",
"(",
"'Connection: Close'",
")",
";",
"print",
"(",
"$",
"webresponse",
"->",
"body",
")",
";",
"exit",
"(",
"0",
")",
";",
"}"
] |
Send an OpenID response.
This function never returns.
@param Auth_OpenID_ServerResponse $response The response.
|
[
"Send",
"an",
"OpenID",
"response",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L352-L369
|
223,760
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Server.php
|
sspmod_openidProvider_Server.receiveRequest
|
public function receiveRequest() {
$request = $this->server->decodeRequest();
if (!in_array($request->mode, array('checkid_immediate', 'checkid_setup'), TRUE)) {
$this->sendResponse($this->server->handleRequest($request));
}
$state = array(
'request' => $request,
);
$this->processRequest($state);
}
|
php
|
public function receiveRequest() {
$request = $this->server->decodeRequest();
if (!in_array($request->mode, array('checkid_immediate', 'checkid_setup'), TRUE)) {
$this->sendResponse($this->server->handleRequest($request));
}
$state = array(
'request' => $request,
);
$this->processRequest($state);
}
|
[
"public",
"function",
"receiveRequest",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"server",
"->",
"decodeRequest",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"request",
"->",
"mode",
",",
"array",
"(",
"'checkid_immediate'",
",",
"'checkid_setup'",
")",
",",
"TRUE",
")",
")",
"{",
"$",
"this",
"->",
"sendResponse",
"(",
"$",
"this",
"->",
"server",
"->",
"handleRequest",
"(",
"$",
"request",
")",
")",
";",
"}",
"$",
"state",
"=",
"array",
"(",
"'request'",
"=>",
"$",
"request",
",",
")",
";",
"$",
"this",
"->",
"processRequest",
"(",
"$",
"state",
")",
";",
"}"
] |
Receive an incoming request.
This function never returns.
|
[
"Receive",
"an",
"incoming",
"request",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Server.php#L470-L483
|
223,761
|
apoutchika/MediaBundle
|
DependencyInjection/ApoutchikaMediaExtension.php
|
ApoutchikaMediaExtension.addParameters
|
private function addParameters(ContainerBuilder $container, array $parameters)
{
foreach ($parameters as $key => $value) {
$container->setParameter('apoutchika_media.'.$key, $value);
}
}
|
php
|
private function addParameters(ContainerBuilder $container, array $parameters)
{
foreach ($parameters as $key => $value) {
$container->setParameter('apoutchika_media.'.$key, $value);
}
}
|
[
"private",
"function",
"addParameters",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"parameters",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"container",
"->",
"setParameter",
"(",
"'apoutchika_media.'",
".",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Add parameter in container.
@param ContainerBuilder $container
@param array $parameter List of parameters with keys / values (without base parameter name)
|
[
"Add",
"parameter",
"in",
"container",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/DependencyInjection/ApoutchikaMediaExtension.php#L74-L79
|
223,762
|
ongr-io/FilterManagerBundle
|
Filter/Widget/Choice/MultiTermChoice.php
|
MultiTermChoice.getOptionUrlParameters
|
protected function getOptionUrlParameters($key, ViewData $data)
{
$parameters = $data->getUrlParameters();
if (isset($parameters[$this->getRequestField()])) {
$parameters[$this->getRequestField()][] = $key;
} else {
$parameters[$this->getRequestField()] = [$key];
}
return $parameters;
}
|
php
|
protected function getOptionUrlParameters($key, ViewData $data)
{
$parameters = $data->getUrlParameters();
if (isset($parameters[$this->getRequestField()])) {
$parameters[$this->getRequestField()][] = $key;
} else {
$parameters[$this->getRequestField()] = [$key];
}
return $parameters;
}
|
[
"protected",
"function",
"getOptionUrlParameters",
"(",
"$",
"key",
",",
"ViewData",
"$",
"data",
")",
"{",
"$",
"parameters",
"=",
"$",
"data",
"->",
"getUrlParameters",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"$",
"this",
"->",
"getRequestField",
"(",
")",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"$",
"this",
"->",
"getRequestField",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"else",
"{",
"$",
"parameters",
"[",
"$",
"this",
"->",
"getRequestField",
"(",
")",
"]",
"=",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] |
Returns url with selected term applied.
@param string $key
@param ViewData $data
@return array
|
[
"Returns",
"url",
"with",
"selected",
"term",
"applied",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Filter/Widget/Choice/MultiTermChoice.php#L59-L70
|
223,763
|
ongr-io/FilterManagerBundle
|
Controller/ManagerController.php
|
ManagerController.getFilterManagerResponse
|
protected function getFilterManagerResponse(Request $request, $managerName)
{
return [
'filter_manager' => $this->get(ONGRFilterManagerExtension::getFilterManagerId($managerName))
->handleRequest($request)
];
}
|
php
|
protected function getFilterManagerResponse(Request $request, $managerName)
{
return [
'filter_manager' => $this->get(ONGRFilterManagerExtension::getFilterManagerId($managerName))
->handleRequest($request)
];
}
|
[
"protected",
"function",
"getFilterManagerResponse",
"(",
"Request",
"$",
"request",
",",
"$",
"managerName",
")",
"{",
"return",
"[",
"'filter_manager'",
"=>",
"$",
"this",
"->",
"get",
"(",
"ONGRFilterManagerExtension",
"::",
"getFilterManagerId",
"(",
"$",
"managerName",
")",
")",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"]",
";",
"}"
] |
Returns search response results from filter manager.
@param Request $request Request.
@param string $managerName Filter manager name.
@return array
|
[
"Returns",
"search",
"response",
"results",
"from",
"filter",
"manager",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Controller/ManagerController.php#L50-L56
|
223,764
|
ongr-io/FilterManagerBundle
|
Controller/ManagerController.php
|
ManagerController.jsonAction
|
public function jsonAction(Request $request, $managerName)
{
$data = $this->get(ONGRFilterManagerExtension::getFilterManagerId($managerName))
->handleRequest($request)
->getSerializableData();
$response = new JsonResponse($data);
if ($request->query->has('pretty')) {
$response->setEncodingOptions(JSON_PRETTY_PRINT);
}
return $response;
}
|
php
|
public function jsonAction(Request $request, $managerName)
{
$data = $this->get(ONGRFilterManagerExtension::getFilterManagerId($managerName))
->handleRequest($request)
->getSerializableData();
$response = new JsonResponse($data);
if ($request->query->has('pretty')) {
$response->setEncodingOptions(JSON_PRETTY_PRINT);
}
return $response;
}
|
[
"public",
"function",
"jsonAction",
"(",
"Request",
"$",
"request",
",",
"$",
"managerName",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"get",
"(",
"ONGRFilterManagerExtension",
"::",
"getFilterManagerId",
"(",
"$",
"managerName",
")",
")",
"->",
"handleRequest",
"(",
"$",
"request",
")",
"->",
"getSerializableData",
"(",
")",
";",
"$",
"response",
"=",
"new",
"JsonResponse",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"request",
"->",
"query",
"->",
"has",
"(",
"'pretty'",
")",
")",
"{",
"$",
"response",
"->",
"setEncodingOptions",
"(",
"JSON_PRETTY_PRINT",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Returns JSON response with search response data.
@param Request $request Request.
@param string $name Filter manager name.
@return JsonResponse
|
[
"Returns",
"JSON",
"response",
"with",
"search",
"response",
"data",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Controller/ManagerController.php#L66-L79
|
223,765
|
apoutchika/MediaBundle
|
Services/FileInfo.php
|
FileInfo.getMimeType
|
public function getMimeType()
{
if ($this->file instanceof UploadedFile) {
return $this->file->getClientMimeType();
}
return $this->file->getMimeType();
}
|
php
|
public function getMimeType()
{
if ($this->file instanceof UploadedFile) {
return $this->file->getClientMimeType();
}
return $this->file->getMimeType();
}
|
[
"public",
"function",
"getMimeType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"file",
"instanceof",
"UploadedFile",
")",
"{",
"return",
"$",
"this",
"->",
"file",
"->",
"getClientMimeType",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"file",
"->",
"getMimeType",
"(",
")",
";",
"}"
] |
Get mime type of file.
@return string
|
[
"Get",
"mime",
"type",
"of",
"file",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/FileInfo.php#L52-L59
|
223,766
|
apoutchika/MediaBundle
|
Services/FileInfo.php
|
FileInfo.getName
|
public function getName()
{
if ($this->file instanceof UploadedFile) {
return $this->file->getClientOriginalName();
}
return $this->file->getFilename();
}
|
php
|
public function getName()
{
if ($this->file instanceof UploadedFile) {
return $this->file->getClientOriginalName();
}
return $this->file->getFilename();
}
|
[
"public",
"function",
"getName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"file",
"instanceof",
"UploadedFile",
")",
"{",
"return",
"$",
"this",
"->",
"file",
"->",
"getClientOriginalName",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"file",
"->",
"getFilename",
"(",
")",
";",
"}"
] |
Get original name of file.
@return string
|
[
"Get",
"original",
"name",
"of",
"file",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/FileInfo.php#L66-L73
|
223,767
|
apoutchika/MediaBundle
|
Services/FileInfo.php
|
FileInfo.getType
|
public function getType()
{
$mimeType = preg_replace('#^([^/]+)/.*$#', '$1', $this->getMimeType());
if ($mimeType == 'video') {
return Media::VIDEO;
}
if ($mimeType == 'audio') {
return Media::AUDIO;
}
if ($mimeType == 'image') {
return Media::IMAGE;
}
$extension = $this->getExtension();
if (in_array($extension, $this->imagesExtensions())) {
return Media::IMAGE;
}
if (in_array($extension, $this->audiosExtensions())) {
return Media::AUDIO;
}
if (in_array($extension, $this->videosExtensions())) {
return Media::VIDEO;
}
return Media::OTHER;
}
|
php
|
public function getType()
{
$mimeType = preg_replace('#^([^/]+)/.*$#', '$1', $this->getMimeType());
if ($mimeType == 'video') {
return Media::VIDEO;
}
if ($mimeType == 'audio') {
return Media::AUDIO;
}
if ($mimeType == 'image') {
return Media::IMAGE;
}
$extension = $this->getExtension();
if (in_array($extension, $this->imagesExtensions())) {
return Media::IMAGE;
}
if (in_array($extension, $this->audiosExtensions())) {
return Media::AUDIO;
}
if (in_array($extension, $this->videosExtensions())) {
return Media::VIDEO;
}
return Media::OTHER;
}
|
[
"public",
"function",
"getType",
"(",
")",
"{",
"$",
"mimeType",
"=",
"preg_replace",
"(",
"'#^([^/]+)/.*$#'",
",",
"'$1'",
",",
"$",
"this",
"->",
"getMimeType",
"(",
")",
")",
";",
"if",
"(",
"$",
"mimeType",
"==",
"'video'",
")",
"{",
"return",
"Media",
"::",
"VIDEO",
";",
"}",
"if",
"(",
"$",
"mimeType",
"==",
"'audio'",
")",
"{",
"return",
"Media",
"::",
"AUDIO",
";",
"}",
"if",
"(",
"$",
"mimeType",
"==",
"'image'",
")",
"{",
"return",
"Media",
"::",
"IMAGE",
";",
"}",
"$",
"extension",
"=",
"$",
"this",
"->",
"getExtension",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"extension",
",",
"$",
"this",
"->",
"imagesExtensions",
"(",
")",
")",
")",
"{",
"return",
"Media",
"::",
"IMAGE",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"extension",
",",
"$",
"this",
"->",
"audiosExtensions",
"(",
")",
")",
")",
"{",
"return",
"Media",
"::",
"AUDIO",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"extension",
",",
"$",
"this",
"->",
"videosExtensions",
"(",
")",
")",
")",
"{",
"return",
"Media",
"::",
"VIDEO",
";",
"}",
"return",
"Media",
"::",
"OTHER",
";",
"}"
] |
Get type of file. It's a constace in Media class.
@return int
|
[
"Get",
"type",
"of",
"file",
".",
"It",
"s",
"a",
"constace",
"in",
"Media",
"class",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/FileInfo.php#L80-L111
|
223,768
|
puli/manager
|
src/Api/Repository/PathMapping.php
|
PathMapping.load
|
public function load(Module $containingModule, ModuleList $modules)
{
if (null !== $this->state) {
throw new AlreadyLoadedException('The mapping is already loaded.');
}
$filesystemPaths = array();
$pathMappings = array();
$loadErrors = array();
foreach ($this->pathReferences as $relativePath) {
$loadError = null;
try {
$absolutePath = $this->makeAbsolute($relativePath, $containingModule, $modules);
$this->assertFileExists($absolutePath, $relativePath, $containingModule);
$filesystemPaths[] = $absolutePath;
} catch (NoSuchModuleException $loadError) {
} catch (FileNotFoundException $loadError) {
}
if ($loadError) {
$loadErrors[] = $loadError;
}
}
foreach ($filesystemPaths as $filesystemPath) {
$pathMappings[$filesystemPath] = $this->repositoryPath;
if (!is_dir($filesystemPath)) {
continue;
}
$prefixLength = strlen($filesystemPath);
$directoryEntries = iterator_to_array(new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
$filesystemPath,
RecursiveDirectoryIterator::CURRENT_AS_PATHNAME | RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::SELF_FIRST
));
// RecursiveDirectoryIterator is not guaranteed to sort its results,
// so sort them here
// We need to sort in the loop and not at the very end because the
// order of the $filesystemPaths should be kept in $pathMappings
ksort($directoryEntries);
foreach ($directoryEntries as $nestedFilesystemPath) {
$pathMappings[$nestedFilesystemPath] = substr_replace($nestedFilesystemPath, $this->repositoryPath, 0, $prefixLength);
}
}
$this->repositoryPaths = array_unique($pathMappings);
$this->filesystemPaths = $filesystemPaths;
$this->pathMappings = $pathMappings;
$this->loadErrors = $loadErrors;
$this->containingModule = $containingModule;
sort($this->repositoryPaths);
$this->refreshState();
}
|
php
|
public function load(Module $containingModule, ModuleList $modules)
{
if (null !== $this->state) {
throw new AlreadyLoadedException('The mapping is already loaded.');
}
$filesystemPaths = array();
$pathMappings = array();
$loadErrors = array();
foreach ($this->pathReferences as $relativePath) {
$loadError = null;
try {
$absolutePath = $this->makeAbsolute($relativePath, $containingModule, $modules);
$this->assertFileExists($absolutePath, $relativePath, $containingModule);
$filesystemPaths[] = $absolutePath;
} catch (NoSuchModuleException $loadError) {
} catch (FileNotFoundException $loadError) {
}
if ($loadError) {
$loadErrors[] = $loadError;
}
}
foreach ($filesystemPaths as $filesystemPath) {
$pathMappings[$filesystemPath] = $this->repositoryPath;
if (!is_dir($filesystemPath)) {
continue;
}
$prefixLength = strlen($filesystemPath);
$directoryEntries = iterator_to_array(new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
$filesystemPath,
RecursiveDirectoryIterator::CURRENT_AS_PATHNAME | RecursiveDirectoryIterator::SKIP_DOTS
),
RecursiveIteratorIterator::SELF_FIRST
));
// RecursiveDirectoryIterator is not guaranteed to sort its results,
// so sort them here
// We need to sort in the loop and not at the very end because the
// order of the $filesystemPaths should be kept in $pathMappings
ksort($directoryEntries);
foreach ($directoryEntries as $nestedFilesystemPath) {
$pathMappings[$nestedFilesystemPath] = substr_replace($nestedFilesystemPath, $this->repositoryPath, 0, $prefixLength);
}
}
$this->repositoryPaths = array_unique($pathMappings);
$this->filesystemPaths = $filesystemPaths;
$this->pathMappings = $pathMappings;
$this->loadErrors = $loadErrors;
$this->containingModule = $containingModule;
sort($this->repositoryPaths);
$this->refreshState();
}
|
[
"public",
"function",
"load",
"(",
"Module",
"$",
"containingModule",
",",
"ModuleList",
"$",
"modules",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"AlreadyLoadedException",
"(",
"'The mapping is already loaded.'",
")",
";",
"}",
"$",
"filesystemPaths",
"=",
"array",
"(",
")",
";",
"$",
"pathMappings",
"=",
"array",
"(",
")",
";",
"$",
"loadErrors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"pathReferences",
"as",
"$",
"relativePath",
")",
"{",
"$",
"loadError",
"=",
"null",
";",
"try",
"{",
"$",
"absolutePath",
"=",
"$",
"this",
"->",
"makeAbsolute",
"(",
"$",
"relativePath",
",",
"$",
"containingModule",
",",
"$",
"modules",
")",
";",
"$",
"this",
"->",
"assertFileExists",
"(",
"$",
"absolutePath",
",",
"$",
"relativePath",
",",
"$",
"containingModule",
")",
";",
"$",
"filesystemPaths",
"[",
"]",
"=",
"$",
"absolutePath",
";",
"}",
"catch",
"(",
"NoSuchModuleException",
"$",
"loadError",
")",
"{",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"loadError",
")",
"{",
"}",
"if",
"(",
"$",
"loadError",
")",
"{",
"$",
"loadErrors",
"[",
"]",
"=",
"$",
"loadError",
";",
"}",
"}",
"foreach",
"(",
"$",
"filesystemPaths",
"as",
"$",
"filesystemPath",
")",
"{",
"$",
"pathMappings",
"[",
"$",
"filesystemPath",
"]",
"=",
"$",
"this",
"->",
"repositoryPath",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"filesystemPath",
")",
")",
"{",
"continue",
";",
"}",
"$",
"prefixLength",
"=",
"strlen",
"(",
"$",
"filesystemPath",
")",
";",
"$",
"directoryEntries",
"=",
"iterator_to_array",
"(",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"filesystemPath",
",",
"RecursiveDirectoryIterator",
"::",
"CURRENT_AS_PATHNAME",
"|",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
",",
"RecursiveIteratorIterator",
"::",
"SELF_FIRST",
")",
")",
";",
"// RecursiveDirectoryIterator is not guaranteed to sort its results,",
"// so sort them here",
"// We need to sort in the loop and not at the very end because the",
"// order of the $filesystemPaths should be kept in $pathMappings",
"ksort",
"(",
"$",
"directoryEntries",
")",
";",
"foreach",
"(",
"$",
"directoryEntries",
"as",
"$",
"nestedFilesystemPath",
")",
"{",
"$",
"pathMappings",
"[",
"$",
"nestedFilesystemPath",
"]",
"=",
"substr_replace",
"(",
"$",
"nestedFilesystemPath",
",",
"$",
"this",
"->",
"repositoryPath",
",",
"0",
",",
"$",
"prefixLength",
")",
";",
"}",
"}",
"$",
"this",
"->",
"repositoryPaths",
"=",
"array_unique",
"(",
"$",
"pathMappings",
")",
";",
"$",
"this",
"->",
"filesystemPaths",
"=",
"$",
"filesystemPaths",
";",
"$",
"this",
"->",
"pathMappings",
"=",
"$",
"pathMappings",
";",
"$",
"this",
"->",
"loadErrors",
"=",
"$",
"loadErrors",
";",
"$",
"this",
"->",
"containingModule",
"=",
"$",
"containingModule",
";",
"sort",
"(",
"$",
"this",
"->",
"repositoryPaths",
")",
";",
"$",
"this",
"->",
"refreshState",
"(",
")",
";",
"}"
] |
Loads the mapping.
@param Module $containingModule The module that contains the
mapping.
@param ModuleList $modules A list of modules that can
be referenced using
`@vendor/module:` prefixes
in the path references.
@throws AlreadyLoadedException If the mapping is already loaded.
|
[
"Loads",
"the",
"mapping",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathMapping.php#L123-L186
|
223,769
|
puli/manager
|
src/Api/Repository/PathMapping.php
|
PathMapping.unload
|
public function unload()
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$conflictsToRelease = $this->conflicts;
$this->conflicts = array();
foreach ($conflictsToRelease as $conflict) {
$conflict->removeMapping($this);
}
$this->filesystemPaths = array();
$this->pathMappings = array();
$this->repositoryPaths = array();
$this->loadErrors = array();
$this->containingModule = null;
$this->state = null;
}
|
php
|
public function unload()
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$conflictsToRelease = $this->conflicts;
$this->conflicts = array();
foreach ($conflictsToRelease as $conflict) {
$conflict->removeMapping($this);
}
$this->filesystemPaths = array();
$this->pathMappings = array();
$this->repositoryPaths = array();
$this->loadErrors = array();
$this->containingModule = null;
$this->state = null;
}
|
[
"public",
"function",
"unload",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The mapping is not loaded.'",
")",
";",
"}",
"$",
"conflictsToRelease",
"=",
"$",
"this",
"->",
"conflicts",
";",
"$",
"this",
"->",
"conflicts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"conflictsToRelease",
"as",
"$",
"conflict",
")",
"{",
"$",
"conflict",
"->",
"removeMapping",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"filesystemPaths",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"pathMappings",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"repositoryPaths",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"loadErrors",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"containingModule",
"=",
"null",
";",
"$",
"this",
"->",
"state",
"=",
"null",
";",
"}"
] |
Unloads the mapping.
This method reverses the effects of {@link load()}. Additionally, all
associated conflicts are dereferenced.
@throws NotLoadedException If the mapping is not loaded.
|
[
"Unloads",
"the",
"mapping",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathMapping.php#L196-L216
|
223,770
|
puli/manager
|
src/Api/Repository/PathMapping.php
|
PathMapping.addConflict
|
public function addConflict(PathConflict $conflict)
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
if (!Path::isBasePath($this->repositoryPath, $conflict->getRepositoryPath())) {
throw new InvalidArgumentException(sprintf(
'The conflicting path %s is not within the path %s of the '.
'mapping.',
$conflict->getRepositoryPath(),
$this->repositoryPath
));
}
$repositoryPath = $conflict->getRepositoryPath();
$previousConflict = isset($this->conflicts[$repositoryPath]) ? $this->conflicts[$repositoryPath] : null;
if ($previousConflict === $conflict) {
return;
}
if ($previousConflict) {
$previousConflict->removeMapping($this);
}
$this->conflicts[$repositoryPath] = $conflict;
$conflict->addMapping($this);
$this->refreshState();
}
|
php
|
public function addConflict(PathConflict $conflict)
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
if (!Path::isBasePath($this->repositoryPath, $conflict->getRepositoryPath())) {
throw new InvalidArgumentException(sprintf(
'The conflicting path %s is not within the path %s of the '.
'mapping.',
$conflict->getRepositoryPath(),
$this->repositoryPath
));
}
$repositoryPath = $conflict->getRepositoryPath();
$previousConflict = isset($this->conflicts[$repositoryPath]) ? $this->conflicts[$repositoryPath] : null;
if ($previousConflict === $conflict) {
return;
}
if ($previousConflict) {
$previousConflict->removeMapping($this);
}
$this->conflicts[$repositoryPath] = $conflict;
$conflict->addMapping($this);
$this->refreshState();
}
|
[
"public",
"function",
"addConflict",
"(",
"PathConflict",
"$",
"conflict",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The mapping is not loaded.'",
")",
";",
"}",
"if",
"(",
"!",
"Path",
"::",
"isBasePath",
"(",
"$",
"this",
"->",
"repositoryPath",
",",
"$",
"conflict",
"->",
"getRepositoryPath",
"(",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The conflicting path %s is not within the path %s of the '",
".",
"'mapping.'",
",",
"$",
"conflict",
"->",
"getRepositoryPath",
"(",
")",
",",
"$",
"this",
"->",
"repositoryPath",
")",
")",
";",
"}",
"$",
"repositoryPath",
"=",
"$",
"conflict",
"->",
"getRepositoryPath",
"(",
")",
";",
"$",
"previousConflict",
"=",
"isset",
"(",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
")",
"?",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
":",
"null",
";",
"if",
"(",
"$",
"previousConflict",
"===",
"$",
"conflict",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"previousConflict",
")",
"{",
"$",
"previousConflict",
"->",
"removeMapping",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
"=",
"$",
"conflict",
";",
"$",
"conflict",
"->",
"addMapping",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"refreshState",
"(",
")",
";",
"}"
] |
Adds a conflict to the mapping.
A mapping can refer to at most one conflict per conflicting repository
path. If the same conflict is added twice, the second addition is
ignored. If a different conflict is added for an existing repository
path, the previous conflict is removed before adding the new conflict
for the repository path.
The repository path of the conflict must either be the repository path
of the mapping or any path within. If a conflict with a different path
is added, an exception is thrown.
The method {@link load()} needs to be called before calling this method,
otherwise an exception is thrown.
@param PathConflict $conflict The conflict to be added.
@throws NotLoadedException If the mapping is not loaded.
@throws InvalidArgumentException If the path of the conflict is not
within the repository path of the
mapping.
|
[
"Adds",
"a",
"conflict",
"to",
"the",
"mapping",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathMapping.php#L373-L403
|
223,771
|
puli/manager
|
src/Api/Repository/PathMapping.php
|
PathMapping.removeConflict
|
public function removeConflict(PathConflict $conflict)
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$repositoryPath = $conflict->getRepositoryPath();
if (!isset($this->conflicts[$repositoryPath]) || $conflict !== $this->conflicts[$repositoryPath]) {
return;
}
unset($this->conflicts[$repositoryPath]);
$conflict->removeMapping($this);
$this->refreshState();
}
|
php
|
public function removeConflict(PathConflict $conflict)
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$repositoryPath = $conflict->getRepositoryPath();
if (!isset($this->conflicts[$repositoryPath]) || $conflict !== $this->conflicts[$repositoryPath]) {
return;
}
unset($this->conflicts[$repositoryPath]);
$conflict->removeMapping($this);
$this->refreshState();
}
|
[
"public",
"function",
"removeConflict",
"(",
"PathConflict",
"$",
"conflict",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The mapping is not loaded.'",
")",
";",
"}",
"$",
"repositoryPath",
"=",
"$",
"conflict",
"->",
"getRepositoryPath",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
")",
"||",
"$",
"conflict",
"!==",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
")",
"{",
"return",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"conflicts",
"[",
"$",
"repositoryPath",
"]",
")",
";",
"$",
"conflict",
"->",
"removeMapping",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"refreshState",
"(",
")",
";",
"}"
] |
Removes a conflict from the mapping.
The method {@link load()} needs to be called before calling this method,
otherwise an exception is thrown.
@param PathConflict $conflict The conflict to remove.
@throws NotLoadedException If the mapping is not loaded.
|
[
"Removes",
"a",
"conflict",
"from",
"the",
"mapping",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathMapping.php#L415-L431
|
223,772
|
puli/manager
|
src/Api/Repository/PathMapping.php
|
PathMapping.getConflictingModules
|
public function getConflictingModules()
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$collection = new ModuleList();
foreach ($this->conflicts as $conflict) {
foreach ($conflict->getMappings() as $mapping) {
if ($this === $mapping) {
continue;
}
$collection->add($mapping->getContainingModule());
}
}
return $collection;
}
|
php
|
public function getConflictingModules()
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$collection = new ModuleList();
foreach ($this->conflicts as $conflict) {
foreach ($conflict->getMappings() as $mapping) {
if ($this === $mapping) {
continue;
}
$collection->add($mapping->getContainingModule());
}
}
return $collection;
}
|
[
"public",
"function",
"getConflictingModules",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The mapping is not loaded.'",
")",
";",
"}",
"$",
"collection",
"=",
"new",
"ModuleList",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"conflicts",
"as",
"$",
"conflict",
")",
"{",
"foreach",
"(",
"$",
"conflict",
"->",
"getMappings",
"(",
")",
"as",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"this",
"===",
"$",
"mapping",
")",
"{",
"continue",
";",
"}",
"$",
"collection",
"->",
"add",
"(",
"$",
"mapping",
"->",
"getContainingModule",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Returns all modules with conflicting path mappings.
The method {@link load()} needs to be called before calling this method,
otherwise an exception is thrown.
@return ModuleList The conflicting modules.
@throws NotLoadedException If the mapping is not loaded.
|
[
"Returns",
"all",
"modules",
"with",
"conflicting",
"path",
"mappings",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathMapping.php#L462-L481
|
223,773
|
puli/manager
|
src/Api/Repository/PathMapping.php
|
PathMapping.getConflictingMappings
|
public function getConflictingMappings()
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$conflictingMappings = array();
foreach ($this->conflicts as $conflict) {
foreach ($conflict->getMappings() as $mapping) {
if ($this === $mapping) {
continue;
}
$conflictingMappings[spl_object_hash($mapping)] = $mapping;
}
}
return array_values($conflictingMappings);
}
|
php
|
public function getConflictingMappings()
{
if (null === $this->state) {
throw new NotLoadedException('The mapping is not loaded.');
}
$conflictingMappings = array();
foreach ($this->conflicts as $conflict) {
foreach ($conflict->getMappings() as $mapping) {
if ($this === $mapping) {
continue;
}
$conflictingMappings[spl_object_hash($mapping)] = $mapping;
}
}
return array_values($conflictingMappings);
}
|
[
"public",
"function",
"getConflictingMappings",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"state",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The mapping is not loaded.'",
")",
";",
"}",
"$",
"conflictingMappings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"conflicts",
"as",
"$",
"conflict",
")",
"{",
"foreach",
"(",
"$",
"conflict",
"->",
"getMappings",
"(",
")",
"as",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"this",
"===",
"$",
"mapping",
")",
"{",
"continue",
";",
"}",
"$",
"conflictingMappings",
"[",
"spl_object_hash",
"(",
"$",
"mapping",
")",
"]",
"=",
"$",
"mapping",
";",
"}",
"}",
"return",
"array_values",
"(",
"$",
"conflictingMappings",
")",
";",
"}"
] |
Returns all conflicting path mappings.
The method {@link load()} needs to be called before calling this method,
otherwise an exception is thrown.
@return PathMapping[] The conflicting path mappings.
@throws NotLoadedException If the mapping is not loaded.
|
[
"Returns",
"all",
"conflicting",
"path",
"mappings",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathMapping.php#L493-L512
|
223,774
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.setClassName
|
public function setClassName($className)
{
Assert::stringNotEmpty($className, 'The class name must be a non-empty string. Got: %s');
$pos = strrpos($className, '\\');
if (false === $pos) {
$this->namespaceName = '';
$this->shortClassName = $className;
} else {
$this->namespaceName = substr($className, 0, $pos);
$this->shortClassName = substr($className, $pos + 1);
}
return $this;
}
|
php
|
public function setClassName($className)
{
Assert::stringNotEmpty($className, 'The class name must be a non-empty string. Got: %s');
$pos = strrpos($className, '\\');
if (false === $pos) {
$this->namespaceName = '';
$this->shortClassName = $className;
} else {
$this->namespaceName = substr($className, 0, $pos);
$this->shortClassName = substr($className, $pos + 1);
}
return $this;
}
|
[
"public",
"function",
"setClassName",
"(",
"$",
"className",
")",
"{",
"Assert",
"::",
"stringNotEmpty",
"(",
"$",
"className",
",",
"'The class name must be a non-empty string. Got: %s'",
")",
";",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
";",
"if",
"(",
"false",
"===",
"$",
"pos",
")",
"{",
"$",
"this",
"->",
"namespaceName",
"=",
"''",
";",
"$",
"this",
"->",
"shortClassName",
"=",
"$",
"className",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"namespaceName",
"=",
"substr",
"(",
"$",
"className",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"this",
"->",
"shortClassName",
"=",
"substr",
"(",
"$",
"className",
",",
"$",
"pos",
"+",
"1",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the fully-qualified name of the factory class.
@param string $className The fully-qualified class name.
@return static The current instance.
|
[
"Sets",
"the",
"fully",
"-",
"qualified",
"name",
"of",
"the",
"factory",
"class",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L95-L110
|
223,775
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.setDirectory
|
public function setDirectory($directory)
{
Assert::stringNotEmpty($directory, 'The factory directory must be a non-empty string. Got: %s');
$this->directory = Path::canonicalize($directory);
return $this;
}
|
php
|
public function setDirectory($directory)
{
Assert::stringNotEmpty($directory, 'The factory directory must be a non-empty string. Got: %s');
$this->directory = Path::canonicalize($directory);
return $this;
}
|
[
"public",
"function",
"setDirectory",
"(",
"$",
"directory",
")",
"{",
"Assert",
"::",
"stringNotEmpty",
"(",
"$",
"directory",
",",
"'The factory directory must be a non-empty string. Got: %s'",
")",
";",
"$",
"this",
"->",
"directory",
"=",
"Path",
"::",
"canonicalize",
"(",
"$",
"directory",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the path to the directory holding the factory class file.
@param string $directory The absolute directory path.
@return static The current instance.
|
[
"Sets",
"the",
"path",
"to",
"the",
"directory",
"holding",
"the",
"factory",
"class",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L162-L169
|
223,776
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.setFilePath
|
public function setFilePath($filePath)
{
Assert::stringNotEmpty($filePath, 'The factory file path must be a non-empty string. Got: %s');
$this->setDirectory(Path::getDirectory($filePath));
$this->setFileName(Path::getFilename($filePath));
return $this;
}
|
php
|
public function setFilePath($filePath)
{
Assert::stringNotEmpty($filePath, 'The factory file path must be a non-empty string. Got: %s');
$this->setDirectory(Path::getDirectory($filePath));
$this->setFileName(Path::getFilename($filePath));
return $this;
}
|
[
"public",
"function",
"setFilePath",
"(",
"$",
"filePath",
")",
"{",
"Assert",
"::",
"stringNotEmpty",
"(",
"$",
"filePath",
",",
"'The factory file path must be a non-empty string. Got: %s'",
")",
";",
"$",
"this",
"->",
"setDirectory",
"(",
"Path",
"::",
"getDirectory",
"(",
"$",
"filePath",
")",
")",
";",
"$",
"this",
"->",
"setFileName",
"(",
"Path",
"::",
"getFilename",
"(",
"$",
"filePath",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the absolute file path of the factory class file.
@param string $filePath The absolute file path.
@return static The current instance.
|
[
"Sets",
"the",
"absolute",
"file",
"path",
"of",
"the",
"factory",
"class",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L236-L244
|
223,777
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.addImplementedInterface
|
public function addImplementedInterface($interfaceName)
{
Assert::stringNotEmpty($interfaceName, 'The interface name must be a non-empty string. Got: %s');
$this->implementedInterfaces[$interfaceName] = true;
return $this;
}
|
php
|
public function addImplementedInterface($interfaceName)
{
Assert::stringNotEmpty($interfaceName, 'The interface name must be a non-empty string. Got: %s');
$this->implementedInterfaces[$interfaceName] = true;
return $this;
}
|
[
"public",
"function",
"addImplementedInterface",
"(",
"$",
"interfaceName",
")",
"{",
"Assert",
"::",
"stringNotEmpty",
"(",
"$",
"interfaceName",
",",
"'The interface name must be a non-empty string. Got: %s'",
")",
";",
"$",
"this",
"->",
"implementedInterfaces",
"[",
"$",
"interfaceName",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds an implemented interface to the class definition.
If you don't pass a fully-qualified name, make sure to import the name
with {@link addImport()}.
@param string $interfaceName The name of the added interfaces.
@return static The current instance.
|
[
"Adds",
"an",
"implemented",
"interface",
"to",
"the",
"class",
"definition",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L372-L379
|
223,778
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.addImport
|
public function addImport(Import $import)
{
if (isset($this->imports[$import->getClassName()])) {
return $this;
}
$symbol = $import->getAlias() ?: $import->getShortClassName();
if (isset($this->importedSymbols[$symbol])) {
throw new RuntimeException(sprintf(
'The symbol "%s" was imported already.',
$import->getShortClassName()
));
}
$this->imports[$import->getClassName()] = $import;
$this->importedSymbols[$symbol] = true;
ksort($this->imports);
return $this;
}
|
php
|
public function addImport(Import $import)
{
if (isset($this->imports[$import->getClassName()])) {
return $this;
}
$symbol = $import->getAlias() ?: $import->getShortClassName();
if (isset($this->importedSymbols[$symbol])) {
throw new RuntimeException(sprintf(
'The symbol "%s" was imported already.',
$import->getShortClassName()
));
}
$this->imports[$import->getClassName()] = $import;
$this->importedSymbols[$symbol] = true;
ksort($this->imports);
return $this;
}
|
[
"public",
"function",
"addImport",
"(",
"Import",
"$",
"import",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"import",
"->",
"getClassName",
"(",
")",
"]",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"symbol",
"=",
"$",
"import",
"->",
"getAlias",
"(",
")",
"?",
":",
"$",
"import",
"->",
"getShortClassName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"importedSymbols",
"[",
"$",
"symbol",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The symbol \"%s\" was imported already.'",
",",
"$",
"import",
"->",
"getShortClassName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"imports",
"[",
"$",
"import",
"->",
"getClassName",
"(",
")",
"]",
"=",
"$",
"import",
";",
"$",
"this",
"->",
"importedSymbols",
"[",
"$",
"symbol",
"]",
"=",
"true",
";",
"ksort",
"(",
"$",
"this",
"->",
"imports",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds an import statement to the class file.
@param Import $import The imported fully-qualified class name.
@return static The current instance.
|
[
"Adds",
"an",
"import",
"statement",
"to",
"the",
"class",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L471-L492
|
223,779
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.removeImport
|
public function removeImport($className)
{
if (isset($this->imports[$className])) {
$import = $this->imports[$className];
$symbol = $import->getAlias() ?: $import->getShortClassName();
unset($this->imports[$className]);
unset($this->importedSymbols[$symbol]);
}
return $this;
}
|
php
|
public function removeImport($className)
{
if (isset($this->imports[$className])) {
$import = $this->imports[$className];
$symbol = $import->getAlias() ?: $import->getShortClassName();
unset($this->imports[$className]);
unset($this->importedSymbols[$symbol]);
}
return $this;
}
|
[
"public",
"function",
"removeImport",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"import",
"=",
"$",
"this",
"->",
"imports",
"[",
"$",
"className",
"]",
";",
"$",
"symbol",
"=",
"$",
"import",
"->",
"getAlias",
"(",
")",
"?",
":",
"$",
"import",
"->",
"getShortClassName",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"className",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"importedSymbols",
"[",
"$",
"symbol",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Removes an import statement from the class file.
If the import statement is not found, this method does nothing.
@param string $className The removed imported class name.
@return static The current instance.
|
[
"Removes",
"an",
"import",
"statement",
"from",
"the",
"class",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L503-L514
|
223,780
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.getMethod
|
public function getMethod($name)
{
if (!isset($this->methods[$name])) {
throw new OutOfBoundsException(sprintf(
'The method "%s" does not exist.',
$name
));
}
return $this->methods[$name];
}
|
php
|
public function getMethod($name)
{
if (!isset($this->methods[$name])) {
throw new OutOfBoundsException(sprintf(
'The method "%s" does not exist.',
$name
));
}
return $this->methods[$name];
}
|
[
"public",
"function",
"getMethod",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"methods",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'The method \"%s\" does not exist.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"methods",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns the method with the given name.
@param string $name The name of the method.
@return Method The method.
@throws OutOfBoundsException If the method with the given name does not
exist.
|
[
"Returns",
"the",
"method",
"with",
"the",
"given",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L548-L558
|
223,781
|
puli/manager
|
src/Api/Php/Clazz.php
|
Clazz.addMethod
|
public function addMethod(Method $method)
{
if (isset($this->methods[$method->getName()])) {
throw new RuntimeException(sprintf(
'The method "%s" exists already.',
$method->getName()
));
}
$this->methods[$method->getName()] = $method;
$method->setClass($this);
return $this;
}
|
php
|
public function addMethod(Method $method)
{
if (isset($this->methods[$method->getName()])) {
throw new RuntimeException(sprintf(
'The method "%s" exists already.',
$method->getName()
));
}
$this->methods[$method->getName()] = $method;
$method->setClass($this);
return $this;
}
|
[
"public",
"function",
"addMethod",
"(",
"Method",
"$",
"method",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"methods",
"[",
"$",
"method",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The method \"%s\" exists already.'",
",",
"$",
"method",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"methods",
"[",
"$",
"method",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"method",
";",
"$",
"method",
"->",
"setClass",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a method to the class.
@param Method $method The method to add to the class.
@return static The current instance.
|
[
"Adds",
"a",
"method",
"to",
"the",
"class",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Php/Clazz.php#L627-L641
|
223,782
|
QoboLtd/cakephp-calendar
|
src/Controller/CalendarEventsController.php
|
CalendarEventsController.add
|
public function add()
{
$this->request->allowMethod(['post', 'patch', 'put']);
$response = [
'success' => false,
'data' => [],
'errors' => [],
];
$calendarsTable = TableRegistry::get('Calendars');
$data = $this->request->getData();
$data = is_array($data) ? $data : [];
if (empty($data['calendar_id'])) {
$response['errors'][] = "Calendar ID is missing";
$this->set(compact('response'));
$this->set('_serialize', 'response');
return $this->response;
}
$calendar = $calendarsTable->get($data['calendar_id']);
$postData = $this->CalendarEvents->setCalendarEventData($data, $calendar);
$calendarEvent = $this->CalendarEvents->newEntity();
$calendarEvent = $this->CalendarEvents->patchEntity(
$calendarEvent,
$postData,
[
'associated' => ['CalendarAttendees'],
]
);
$saved = $this->CalendarEvents->save($calendarEvent);
if ($saved) {
$response['success'] = true;
$response['data'] = $this->CalendarEvents->getEventInfo($saved->id, $calendar);
} else {
$response['errors'] = $calendarEvent->getErrors();
}
$this->set(compact('response'));
$this->set('_serialize', 'response');
}
|
php
|
public function add()
{
$this->request->allowMethod(['post', 'patch', 'put']);
$response = [
'success' => false,
'data' => [],
'errors' => [],
];
$calendarsTable = TableRegistry::get('Calendars');
$data = $this->request->getData();
$data = is_array($data) ? $data : [];
if (empty($data['calendar_id'])) {
$response['errors'][] = "Calendar ID is missing";
$this->set(compact('response'));
$this->set('_serialize', 'response');
return $this->response;
}
$calendar = $calendarsTable->get($data['calendar_id']);
$postData = $this->CalendarEvents->setCalendarEventData($data, $calendar);
$calendarEvent = $this->CalendarEvents->newEntity();
$calendarEvent = $this->CalendarEvents->patchEntity(
$calendarEvent,
$postData,
[
'associated' => ['CalendarAttendees'],
]
);
$saved = $this->CalendarEvents->save($calendarEvent);
if ($saved) {
$response['success'] = true;
$response['data'] = $this->CalendarEvents->getEventInfo($saved->id, $calendar);
} else {
$response['errors'] = $calendarEvent->getErrors();
}
$this->set(compact('response'));
$this->set('_serialize', 'response');
}
|
[
"public",
"function",
"add",
"(",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"allowMethod",
"(",
"[",
"'post'",
",",
"'patch'",
",",
"'put'",
"]",
")",
";",
"$",
"response",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'data'",
"=>",
"[",
"]",
",",
"'errors'",
"=>",
"[",
"]",
",",
"]",
";",
"$",
"calendarsTable",
"=",
"TableRegistry",
"::",
"get",
"(",
"'Calendars'",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
")",
";",
"$",
"data",
"=",
"is_array",
"(",
"$",
"data",
")",
"?",
"$",
"data",
":",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'calendar_id'",
"]",
")",
")",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"\"Calendar ID is missing\"",
";",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'response'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"'response'",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}",
"$",
"calendar",
"=",
"$",
"calendarsTable",
"->",
"get",
"(",
"$",
"data",
"[",
"'calendar_id'",
"]",
")",
";",
"$",
"postData",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"setCalendarEventData",
"(",
"$",
"data",
",",
"$",
"calendar",
")",
";",
"$",
"calendarEvent",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"newEntity",
"(",
")",
";",
"$",
"calendarEvent",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"patchEntity",
"(",
"$",
"calendarEvent",
",",
"$",
"postData",
",",
"[",
"'associated'",
"=>",
"[",
"'CalendarAttendees'",
"]",
",",
"]",
")",
";",
"$",
"saved",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"save",
"(",
"$",
"calendarEvent",
")",
";",
"if",
"(",
"$",
"saved",
")",
"{",
"$",
"response",
"[",
"'success'",
"]",
"=",
"true",
";",
"$",
"response",
"[",
"'data'",
"]",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"getEventInfo",
"(",
"$",
"saved",
"->",
"id",
",",
"$",
"calendar",
")",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"=",
"$",
"calendarEvent",
"->",
"getErrors",
"(",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'response'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"'response'",
")",
";",
"}"
] |
Create Event via AJAX call
@return \Cake\Http\Response|void|null
|
[
"Create",
"Event",
"via",
"AJAX",
"call"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Controller/CalendarEventsController.php#L58-L102
|
223,783
|
QoboLtd/cakephp-calendar
|
src/Controller/CalendarEventsController.php
|
CalendarEventsController.view
|
public function view()
{
$response = [
'success' => false,
'data' => [],
'errors' => []
];
if ($this->request->is(['post', 'patch', 'put'])) {
$data = $this->request->getData();
$result = $this->CalendarEvents->getEventInfo($data['id']);
if (!empty($result)) {
$response['success'] = true;
$response['data'] = $result;
} else {
$response['errors'][] = "Couldn't find Event with id {$data['id']}";
}
}
$this->set(compact('response'));
$this->set('_serialize', 'response');
}
|
php
|
public function view()
{
$response = [
'success' => false,
'data' => [],
'errors' => []
];
if ($this->request->is(['post', 'patch', 'put'])) {
$data = $this->request->getData();
$result = $this->CalendarEvents->getEventInfo($data['id']);
if (!empty($result)) {
$response['success'] = true;
$response['data'] = $result;
} else {
$response['errors'][] = "Couldn't find Event with id {$data['id']}";
}
}
$this->set(compact('response'));
$this->set('_serialize', 'response');
}
|
[
"public",
"function",
"view",
"(",
")",
"{",
"$",
"response",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'data'",
"=>",
"[",
"]",
",",
"'errors'",
"=>",
"[",
"]",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"[",
"'post'",
",",
"'patch'",
",",
"'put'",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"getEventInfo",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"response",
"[",
"'success'",
"]",
"=",
"true",
";",
"$",
"response",
"[",
"'data'",
"]",
"=",
"$",
"result",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"\"Couldn't find Event with id {$data['id']}\"",
";",
"}",
"}",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'response'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"'response'",
")",
";",
"}"
] |
View Event via AJAX
@return \Cake\Http\Response|void|null
|
[
"View",
"Event",
"via",
"AJAX"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Controller/CalendarEventsController.php#L109-L131
|
223,784
|
QoboLtd/cakephp-calendar
|
src/Controller/CalendarEventsController.php
|
CalendarEventsController.getEventTypes
|
public function getEventTypes()
{
$this->request->allowMethod(['post', 'patch', 'put']);
$calendarsTable = TableRegistry::Get('Qobo/Calendar.Calendars');
$eventTypes = [];
$data = $this->request->getData();
$calendar = $calendarsTable->get($data['calendar_id']);
$types = $this->CalendarEvents->getEventTypes(['calendar' => $calendar, 'user' => $this->Auth->user()]);
foreach ($types as $item) {
if (isset($item['name'])) {
$eventTypes[] = $item;
} else {
$eventTypes[] = ['name' => $item, 'value' => $item];
}
}
if (!empty($data['exclude'])) {
foreach ($data['exclude'] as $type) {
foreach ($eventTypes as $k => $item) {
if (preg_match("/^$type/i", $item['value'])) {
unset($eventTypes[$k]);
}
}
}
$eventTypes = array_values($eventTypes);
}
$this->set(compact('eventTypes'));
$this->set('_serialize', 'eventTypes');
}
|
php
|
public function getEventTypes()
{
$this->request->allowMethod(['post', 'patch', 'put']);
$calendarsTable = TableRegistry::Get('Qobo/Calendar.Calendars');
$eventTypes = [];
$data = $this->request->getData();
$calendar = $calendarsTable->get($data['calendar_id']);
$types = $this->CalendarEvents->getEventTypes(['calendar' => $calendar, 'user' => $this->Auth->user()]);
foreach ($types as $item) {
if (isset($item['name'])) {
$eventTypes[] = $item;
} else {
$eventTypes[] = ['name' => $item, 'value' => $item];
}
}
if (!empty($data['exclude'])) {
foreach ($data['exclude'] as $type) {
foreach ($eventTypes as $k => $item) {
if (preg_match("/^$type/i", $item['value'])) {
unset($eventTypes[$k]);
}
}
}
$eventTypes = array_values($eventTypes);
}
$this->set(compact('eventTypes'));
$this->set('_serialize', 'eventTypes');
}
|
[
"public",
"function",
"getEventTypes",
"(",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"allowMethod",
"(",
"[",
"'post'",
",",
"'patch'",
",",
"'put'",
"]",
")",
";",
"$",
"calendarsTable",
"=",
"TableRegistry",
"::",
"Get",
"(",
"'Qobo/Calendar.Calendars'",
")",
";",
"$",
"eventTypes",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
")",
";",
"$",
"calendar",
"=",
"$",
"calendarsTable",
"->",
"get",
"(",
"$",
"data",
"[",
"'calendar_id'",
"]",
")",
";",
"$",
"types",
"=",
"$",
"this",
"->",
"CalendarEvents",
"->",
"getEventTypes",
"(",
"[",
"'calendar'",
"=>",
"$",
"calendar",
",",
"'user'",
"=>",
"$",
"this",
"->",
"Auth",
"->",
"user",
"(",
")",
"]",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"eventTypes",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"else",
"{",
"$",
"eventTypes",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"item",
",",
"'value'",
"=>",
"$",
"item",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'exclude'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'exclude'",
"]",
"as",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"eventTypes",
"as",
"$",
"k",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^$type/i\"",
",",
"$",
"item",
"[",
"'value'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"eventTypes",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"}",
"$",
"eventTypes",
"=",
"array_values",
"(",
"$",
"eventTypes",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'eventTypes'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"'eventTypes'",
")",
";",
"}"
] |
Get Event types based on the calendar id
@return \Cake\Http\Response|void|null
|
[
"Get",
"Event",
"types",
"based",
"on",
"the",
"calendar",
"id"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Controller/CalendarEventsController.php#L138-L171
|
223,785
|
QoboLtd/cakephp-calendar
|
src/Controller/CalendarEventsController.php
|
CalendarEventsController.eventTypeConfig
|
public function eventTypeConfig()
{
$this->request->allowMethod(['post', 'put', 'patch']);
$response = [
'success' => false,
'data' => [],
'errors' => [],
];
$data = $this->request->getData();
try {
$config = ObjectFactory::getConfig(null, 'Event', $data['event_type']);
if (!empty($config)) {
$response['success'] = true;
$response['data'] = $config;
}
} catch (Exception $e) {
$response['errors'][] = $e->getMessage();
throw $e;
}
$this->set(compact('response'));
$this->set('_serialize', 'response');
}
|
php
|
public function eventTypeConfig()
{
$this->request->allowMethod(['post', 'put', 'patch']);
$response = [
'success' => false,
'data' => [],
'errors' => [],
];
$data = $this->request->getData();
try {
$config = ObjectFactory::getConfig(null, 'Event', $data['event_type']);
if (!empty($config)) {
$response['success'] = true;
$response['data'] = $config;
}
} catch (Exception $e) {
$response['errors'][] = $e->getMessage();
throw $e;
}
$this->set(compact('response'));
$this->set('_serialize', 'response');
}
|
[
"public",
"function",
"eventTypeConfig",
"(",
")",
"{",
"$",
"this",
"->",
"request",
"->",
"allowMethod",
"(",
"[",
"'post'",
",",
"'put'",
",",
"'patch'",
"]",
")",
";",
"$",
"response",
"=",
"[",
"'success'",
"=>",
"false",
",",
"'data'",
"=>",
"[",
"]",
",",
"'errors'",
"=>",
"[",
"]",
",",
"]",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"request",
"->",
"getData",
"(",
")",
";",
"try",
"{",
"$",
"config",
"=",
"ObjectFactory",
"::",
"getConfig",
"(",
"null",
",",
"'Event'",
",",
"$",
"data",
"[",
"'event_type'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
")",
")",
"{",
"$",
"response",
"[",
"'success'",
"]",
"=",
"true",
";",
"$",
"response",
"[",
"'data'",
"]",
"=",
"$",
"config",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"[",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"compact",
"(",
"'response'",
")",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'_serialize'",
",",
"'response'",
")",
";",
"}"
] |
Event Type Config getter method
Return event type configuration from ObjectFactory
@return \Cake\Http\Response|void|null
|
[
"Event",
"Type",
"Config",
"getter",
"method"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Controller/CalendarEventsController.php#L202-L228
|
223,786
|
ongr-io/FilterManagerBundle
|
Filter/ViewData/PagerAwareViewData.php
|
PagerAwareViewData.setData
|
public function setData($totalItems, $currentPage, $itemsPerPage = 12, $maxPages = 10)
{
$this->totalItems = $totalItems;
$this->currentPage = $currentPage;
$this->itemsPerPage = $itemsPerPage;
// if ($maxPages < 3) {
// throw new \InvalidArgumentException('Max pages has to be more than 3.');
// }
$this->maxPages = $maxPages;
$this->numPages = (int) ceil($this->totalItems/$this->itemsPerPage);
}
|
php
|
public function setData($totalItems, $currentPage, $itemsPerPage = 12, $maxPages = 10)
{
$this->totalItems = $totalItems;
$this->currentPage = $currentPage;
$this->itemsPerPage = $itemsPerPage;
// if ($maxPages < 3) {
// throw new \InvalidArgumentException('Max pages has to be more than 3.');
// }
$this->maxPages = $maxPages;
$this->numPages = (int) ceil($this->totalItems/$this->itemsPerPage);
}
|
[
"public",
"function",
"setData",
"(",
"$",
"totalItems",
",",
"$",
"currentPage",
",",
"$",
"itemsPerPage",
"=",
"12",
",",
"$",
"maxPages",
"=",
"10",
")",
"{",
"$",
"this",
"->",
"totalItems",
"=",
"$",
"totalItems",
";",
"$",
"this",
"->",
"currentPage",
"=",
"$",
"currentPage",
";",
"$",
"this",
"->",
"itemsPerPage",
"=",
"$",
"itemsPerPage",
";",
"// if ($maxPages < 3) {",
"// throw new \\InvalidArgumentException('Max pages has to be more than 3.');",
"// }",
"$",
"this",
"->",
"maxPages",
"=",
"$",
"maxPages",
";",
"$",
"this",
"->",
"numPages",
"=",
"(",
"int",
")",
"ceil",
"(",
"$",
"this",
"->",
"totalItems",
"/",
"$",
"this",
"->",
"itemsPerPage",
")",
";",
"}"
] |
Initializes data for pagination.
@param $totalItems
@param $currentPage
@param int $itemsPerPage
@param int $maxPages
|
[
"Initializes",
"data",
"for",
"pagination",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Filter/ViewData/PagerAwareViewData.php#L57-L69
|
223,787
|
puli/manager
|
src/Api/Asset/DuplicateAssetMappingException.php
|
DuplicateAssetMappingException.forUuid
|
public static function forUuid(Uuid $uuid, Exception $cause = null)
{
return new static(sprintf(
'The asset mapping "%s" exists already.',
$uuid->toString()
), 0, $cause);
}
|
php
|
public static function forUuid(Uuid $uuid, Exception $cause = null)
{
return new static(sprintf(
'The asset mapping "%s" exists already.',
$uuid->toString()
), 0, $cause);
}
|
[
"public",
"static",
"function",
"forUuid",
"(",
"Uuid",
"$",
"uuid",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The asset mapping \"%s\" exists already.'",
",",
"$",
"uuid",
"->",
"toString",
"(",
")",
")",
",",
"0",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for a UUID that exists already.
@param Uuid $uuid The UUID of the mapping.
@param Exception|null $cause The exception that caused this exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"a",
"UUID",
"that",
"exists",
"already",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Asset/DuplicateAssetMappingException.php#L34-L40
|
223,788
|
madeyourday/contao-rocksolid-columns
|
src/Element/ColumnsStart.php
|
ColumnsStart.getColumnsConfiguration
|
public static function getColumnsConfiguration(array $data)
{
$config = array();
$lastColumns = null;
foreach (array('large', 'medium', 'small') as $media) {
$columns = isset($data['rs_columns_' . $media])
? $data['rs_columns_' . $media]
: null;
if (!$columns) {
$columns = $lastColumns ?: '2';
}
$lastColumns = $columns;
$columns = array_map(function($value) {
return (int)$value ?: 1;
}, explode('-', $columns));
if (count($columns) === 1 && $columns[0] > 1) {
$columns = array_fill(0, (int)$columns[0], '1');
}
$columnsTotal = array_reduce($columns, function($a, $b) {
return $a + $b;
});
$classes = array();
foreach ($columns as $key => $column) {
$classes[] = array('-' . $media . '-col-' . $columnsTotal . '-' . $column);
}
$classes[0][] = '-' . $media . '-first';
$classes[count($classes) - 1][] = '-' . $media . '-last';
$config[$media] = $classes;
}
return $config;
}
|
php
|
public static function getColumnsConfiguration(array $data)
{
$config = array();
$lastColumns = null;
foreach (array('large', 'medium', 'small') as $media) {
$columns = isset($data['rs_columns_' . $media])
? $data['rs_columns_' . $media]
: null;
if (!$columns) {
$columns = $lastColumns ?: '2';
}
$lastColumns = $columns;
$columns = array_map(function($value) {
return (int)$value ?: 1;
}, explode('-', $columns));
if (count($columns) === 1 && $columns[0] > 1) {
$columns = array_fill(0, (int)$columns[0], '1');
}
$columnsTotal = array_reduce($columns, function($a, $b) {
return $a + $b;
});
$classes = array();
foreach ($columns as $key => $column) {
$classes[] = array('-' . $media . '-col-' . $columnsTotal . '-' . $column);
}
$classes[0][] = '-' . $media . '-first';
$classes[count($classes) - 1][] = '-' . $media . '-last';
$config[$media] = $classes;
}
return $config;
}
|
[
"public",
"static",
"function",
"getColumnsConfiguration",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"$",
"lastColumns",
"=",
"null",
";",
"foreach",
"(",
"array",
"(",
"'large'",
",",
"'medium'",
",",
"'small'",
")",
"as",
"$",
"media",
")",
"{",
"$",
"columns",
"=",
"isset",
"(",
"$",
"data",
"[",
"'rs_columns_'",
".",
"$",
"media",
"]",
")",
"?",
"$",
"data",
"[",
"'rs_columns_'",
".",
"$",
"media",
"]",
":",
"null",
";",
"if",
"(",
"!",
"$",
"columns",
")",
"{",
"$",
"columns",
"=",
"$",
"lastColumns",
"?",
":",
"'2'",
";",
"}",
"$",
"lastColumns",
"=",
"$",
"columns",
";",
"$",
"columns",
"=",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"int",
")",
"$",
"value",
"?",
":",
"1",
";",
"}",
",",
"explode",
"(",
"'-'",
",",
"$",
"columns",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"columns",
")",
"===",
"1",
"&&",
"$",
"columns",
"[",
"0",
"]",
">",
"1",
")",
"{",
"$",
"columns",
"=",
"array_fill",
"(",
"0",
",",
"(",
"int",
")",
"$",
"columns",
"[",
"0",
"]",
",",
"'1'",
")",
";",
"}",
"$",
"columnsTotal",
"=",
"array_reduce",
"(",
"$",
"columns",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"return",
"$",
"a",
"+",
"$",
"b",
";",
"}",
")",
";",
"$",
"classes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"key",
"=>",
"$",
"column",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"array",
"(",
"'-'",
".",
"$",
"media",
".",
"'-col-'",
".",
"$",
"columnsTotal",
".",
"'-'",
".",
"$",
"column",
")",
";",
"}",
"$",
"classes",
"[",
"0",
"]",
"[",
"]",
"=",
"'-'",
".",
"$",
"media",
".",
"'-first'",
";",
"$",
"classes",
"[",
"count",
"(",
"$",
"classes",
")",
"-",
"1",
"]",
"[",
"]",
"=",
"'-'",
".",
"$",
"media",
".",
"'-last'",
";",
"$",
"config",
"[",
"$",
"media",
"]",
"=",
"$",
"classes",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Generate the columns configuration
@param array $data Data array
@return array Columns configuration
|
[
"Generate",
"the",
"columns",
"configuration"
] |
35ca1f9b17c19fd0b774ed3307a85b58fa4b2705
|
https://github.com/madeyourday/contao-rocksolid-columns/blob/35ca1f9b17c19fd0b774ed3307a85b58fa4b2705/src/Element/ColumnsStart.php#L79-L116
|
223,789
|
yosymfony/config-loader
|
src/ConfigFileLoader.php
|
ConfigFileLoader.parseImports
|
protected function parseImports(RepositoryInterface $repository, string $file) : RepositoryInterface
{
if (!isset($repository[self::IMPORT_KEY])) {
return $repository;
}
if (!is_array($repository[self::IMPORT_KEY])) {
$keyName = self::IMPORT_KEY;
$message = "The \"{$keyName}\" key should contain an array in {$file}. Check your YAML syntax.";
throw new \InvalidArgumentException($message);
}
foreach ($repository[self::IMPORT_KEY] as $import) {
if (!is_array($import)) {
$import = ['resource' => $import];
}
$ignoreErrors = isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false;
$importedResource = $this->import($import['resource'], null, $ignoreErrors, $file);
if ($importedResource) {
$repository = $repository->union($importedResource);
}
}
$repository->del(self::IMPORT_KEY);
return $repository;
}
|
php
|
protected function parseImports(RepositoryInterface $repository, string $file) : RepositoryInterface
{
if (!isset($repository[self::IMPORT_KEY])) {
return $repository;
}
if (!is_array($repository[self::IMPORT_KEY])) {
$keyName = self::IMPORT_KEY;
$message = "The \"{$keyName}\" key should contain an array in {$file}. Check your YAML syntax.";
throw new \InvalidArgumentException($message);
}
foreach ($repository[self::IMPORT_KEY] as $import) {
if (!is_array($import)) {
$import = ['resource' => $import];
}
$ignoreErrors = isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false;
$importedResource = $this->import($import['resource'], null, $ignoreErrors, $file);
if ($importedResource) {
$repository = $repository->union($importedResource);
}
}
$repository->del(self::IMPORT_KEY);
return $repository;
}
|
[
"protected",
"function",
"parseImports",
"(",
"RepositoryInterface",
"$",
"repository",
",",
"string",
"$",
"file",
")",
":",
"RepositoryInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"repository",
"[",
"self",
"::",
"IMPORT_KEY",
"]",
")",
")",
"{",
"return",
"$",
"repository",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"repository",
"[",
"self",
"::",
"IMPORT_KEY",
"]",
")",
")",
"{",
"$",
"keyName",
"=",
"self",
"::",
"IMPORT_KEY",
";",
"$",
"message",
"=",
"\"The \\\"{$keyName}\\\" key should contain an array in {$file}. Check your YAML syntax.\"",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"foreach",
"(",
"$",
"repository",
"[",
"self",
"::",
"IMPORT_KEY",
"]",
"as",
"$",
"import",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"import",
")",
")",
"{",
"$",
"import",
"=",
"[",
"'resource'",
"=>",
"$",
"import",
"]",
";",
"}",
"$",
"ignoreErrors",
"=",
"isset",
"(",
"$",
"import",
"[",
"'ignore_errors'",
"]",
")",
"?",
"(",
"bool",
")",
"$",
"import",
"[",
"'ignore_errors'",
"]",
":",
"false",
";",
"$",
"importedResource",
"=",
"$",
"this",
"->",
"import",
"(",
"$",
"import",
"[",
"'resource'",
"]",
",",
"null",
",",
"$",
"ignoreErrors",
",",
"$",
"file",
")",
";",
"if",
"(",
"$",
"importedResource",
")",
"{",
"$",
"repository",
"=",
"$",
"repository",
"->",
"union",
"(",
"$",
"importedResource",
")",
";",
"}",
"}",
"$",
"repository",
"->",
"del",
"(",
"self",
"::",
"IMPORT_KEY",
")",
";",
"return",
"$",
"repository",
";",
"}"
] |
Parses the repositories in "imports" key
@param Repository $repository
@param string $file
@return RepositoryInterface
@throws InvalidArgumentException If error with "imports" key
|
[
"Parses",
"the",
"repositories",
"in",
"imports",
"key"
] |
47c97f5014e2d1134f8655a1f14fd3504c997cf2
|
https://github.com/yosymfony/config-loader/blob/47c97f5014e2d1134f8655a1f14fd3504c997cf2/src/ConfigFileLoader.php#L123-L152
|
223,790
|
yosymfony/config-loader
|
src/ConfigFileLoader.php
|
ConfigFileLoader.readFile
|
protected function readFile(string $file) : string
{
if (is_file($file) === false) {
throw new BadFileException("The file \"{$file}\" is not a file.", $file);
}
if (is_readable($file) === false) {
throw new BadFileException("Unable to open \"{$file}\" as the file is not readable.", $file);
}
return file_get_contents($file);
}
|
php
|
protected function readFile(string $file) : string
{
if (is_file($file) === false) {
throw new BadFileException("The file \"{$file}\" is not a file.", $file);
}
if (is_readable($file) === false) {
throw new BadFileException("Unable to open \"{$file}\" as the file is not readable.", $file);
}
return file_get_contents($file);
}
|
[
"protected",
"function",
"readFile",
"(",
"string",
"$",
"file",
")",
":",
"string",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"BadFileException",
"(",
"\"The file \\\"{$file}\\\" is not a file.\"",
",",
"$",
"file",
")",
";",
"}",
"if",
"(",
"is_readable",
"(",
"$",
"file",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"BadFileException",
"(",
"\"Unable to open \\\"{$file}\\\" as the file is not readable.\"",
",",
"$",
"file",
")",
";",
"}",
"return",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"}"
] |
Reads a file
@param string $file The name of the file
@return string The file's content
@throws BadFileException If the file is not a file or it is not readable
|
[
"Reads",
"a",
"file"
] |
47c97f5014e2d1134f8655a1f14fd3504c997cf2
|
https://github.com/yosymfony/config-loader/blob/47c97f5014e2d1134f8655a1f14fd3504c997cf2/src/ConfigFileLoader.php#L177-L188
|
223,791
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Utils.php
|
sspmod_openidProvider_Utils.maskErrors
|
public static function maskErrors($mask)
{
if (!is_int($mask)) {
throw new \InvalidArgumentException('Invalid input parameters.');
}
$currentEnabled = error_reporting();
self::$logLevelStack[] = array($currentEnabled, self::$logMask);
$currentEnabled &= ~$mask;
error_reporting($currentEnabled);
self::$logMask |= $mask;
}
|
php
|
public static function maskErrors($mask)
{
if (!is_int($mask)) {
throw new \InvalidArgumentException('Invalid input parameters.');
}
$currentEnabled = error_reporting();
self::$logLevelStack[] = array($currentEnabled, self::$logMask);
$currentEnabled &= ~$mask;
error_reporting($currentEnabled);
self::$logMask |= $mask;
}
|
[
"public",
"static",
"function",
"maskErrors",
"(",
"$",
"mask",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"mask",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid input parameters.'",
")",
";",
"}",
"$",
"currentEnabled",
"=",
"error_reporting",
"(",
")",
";",
"self",
"::",
"$",
"logLevelStack",
"[",
"]",
"=",
"array",
"(",
"$",
"currentEnabled",
",",
"self",
"::",
"$",
"logMask",
")",
";",
"$",
"currentEnabled",
"&=",
"~",
"$",
"mask",
";",
"error_reporting",
"(",
"$",
"currentEnabled",
")",
";",
"self",
"::",
"$",
"logMask",
"|=",
"$",
"mask",
";",
"}"
] |
Disable reporting of the given log levels.
Every call to this function must be followed by a call to popErrorMask();
@param int $mask The log levels that should be masked.
@throws \InvalidArgumentException If $mask is not an integer.
@author Olav Morken, UNINETT AS <olav.morken@uninett.no>
|
[
"Disable",
"reporting",
"of",
"the",
"given",
"log",
"levels",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Utils.php#L43-L55
|
223,792
|
simplesamlphp/simplesamlphp-module-openidprovider
|
lib/Utils.php
|
sspmod_openidProvider_Utils.popErrorMask
|
public static function popErrorMask()
{
$lastMask = array_pop(self::$logLevelStack);
error_reporting($lastMask[0]);
self::$logMask = $lastMask[1];
}
|
php
|
public static function popErrorMask()
{
$lastMask = array_pop(self::$logLevelStack);
error_reporting($lastMask[0]);
self::$logMask = $lastMask[1];
}
|
[
"public",
"static",
"function",
"popErrorMask",
"(",
")",
"{",
"$",
"lastMask",
"=",
"array_pop",
"(",
"self",
"::",
"$",
"logLevelStack",
")",
";",
"error_reporting",
"(",
"$",
"lastMask",
"[",
"0",
"]",
")",
";",
"self",
"::",
"$",
"logMask",
"=",
"$",
"lastMask",
"[",
"1",
"]",
";",
"}"
] |
Pop an error mask.
This function restores the previous error mask.
@author Olav Morken, UNINETT AS <olav.morken@uninett.no>
|
[
"Pop",
"an",
"error",
"mask",
"."
] |
1b2c50660712fd87946d43e73032e1b1830ebf61
|
https://github.com/simplesamlphp/simplesamlphp-module-openidprovider/blob/1b2c50660712fd87946d43e73032e1b1830ebf61/lib/Utils.php#L65-L70
|
223,793
|
QoboLtd/cakephp-calendar
|
src/Model/Table/CalendarAttendeesTable.php
|
CalendarAttendeesTable.saveAttendee
|
public function saveAttendee(array $entity): array
{
$response = [
'status' => false,
'errors' => [],
'entity' => null,
];
if (empty($entity['id'])) {
unset($entity['id']);
}
$query = $this->find()
->where([
'source' => $entity['source'],
'source_id' => $entity['source_id'],
'contact_details' => $entity['contact_details'],
]);
$query->execute();
if (!$query->count()) {
$item = $this->newEntity();
$item = $this->patchEntity($item, $entity);
} else {
$item = $query->firstOrFail();
if (!($item instanceof EntityInterface)) {
throw new RuntimeException('Expected instance of EntityInterface');
}
$item = $this->patchEntity($item, $entity);
}
$saved = $this->save($item);
if ($saved) {
$response['status'] = true;
$response['entity'] = $saved;
} else {
$response['errors'] = $item->getErrors();
}
return $response;
}
|
php
|
public function saveAttendee(array $entity): array
{
$response = [
'status' => false,
'errors' => [],
'entity' => null,
];
if (empty($entity['id'])) {
unset($entity['id']);
}
$query = $this->find()
->where([
'source' => $entity['source'],
'source_id' => $entity['source_id'],
'contact_details' => $entity['contact_details'],
]);
$query->execute();
if (!$query->count()) {
$item = $this->newEntity();
$item = $this->patchEntity($item, $entity);
} else {
$item = $query->firstOrFail();
if (!($item instanceof EntityInterface)) {
throw new RuntimeException('Expected instance of EntityInterface');
}
$item = $this->patchEntity($item, $entity);
}
$saved = $this->save($item);
if ($saved) {
$response['status'] = true;
$response['entity'] = $saved;
} else {
$response['errors'] = $item->getErrors();
}
return $response;
}
|
[
"public",
"function",
"saveAttendee",
"(",
"array",
"$",
"entity",
")",
":",
"array",
"{",
"$",
"response",
"=",
"[",
"'status'",
"=>",
"false",
",",
"'errors'",
"=>",
"[",
"]",
",",
"'entity'",
"=>",
"null",
",",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"entity",
"[",
"'id'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"entity",
"[",
"'id'",
"]",
")",
";",
"}",
"$",
"query",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'source'",
"=>",
"$",
"entity",
"[",
"'source'",
"]",
",",
"'source_id'",
"=>",
"$",
"entity",
"[",
"'source_id'",
"]",
",",
"'contact_details'",
"=>",
"$",
"entity",
"[",
"'contact_details'",
"]",
",",
"]",
")",
";",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"$",
"query",
"->",
"count",
"(",
")",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"newEntity",
"(",
")",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"item",
",",
"$",
"entity",
")",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"$",
"query",
"->",
"firstOrFail",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"item",
"instanceof",
"EntityInterface",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Expected instance of EntityInterface'",
")",
";",
"}",
"$",
"item",
"=",
"$",
"this",
"->",
"patchEntity",
"(",
"$",
"item",
",",
"$",
"entity",
")",
";",
"}",
"$",
"saved",
"=",
"$",
"this",
"->",
"save",
"(",
"$",
"item",
")",
";",
"if",
"(",
"$",
"saved",
")",
"{",
"$",
"response",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"response",
"[",
"'entity'",
"]",
"=",
"$",
"saved",
";",
"}",
"else",
"{",
"$",
"response",
"[",
"'errors'",
"]",
"=",
"$",
"item",
"->",
"getErrors",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Save Calendar Attendees
@param mixed[] $entity of the attendee
@return mixed[] $response containing save state and saved record
|
[
"Save",
"Calendar",
"Attendees"
] |
e0ea2c4dd4257a6af972707f206151d01bb4dfbb
|
https://github.com/QoboLtd/cakephp-calendar/blob/e0ea2c4dd4257a6af972707f206151d01bb4dfbb/src/Model/Table/CalendarAttendeesTable.php#L104-L146
|
223,794
|
apoutchika/MediaBundle
|
Filesystem/FilesystemManipulator.php
|
FilesystemManipulator.saveContent
|
public function saveContent($key, $content)
{
$this->master->getFilesystem()->write($key, $content, true);
foreach ($this->slaves as $slave) {
$slave->getFilesystem()->write($key, $content, true);
}
}
|
php
|
public function saveContent($key, $content)
{
$this->master->getFilesystem()->write($key, $content, true);
foreach ($this->slaves as $slave) {
$slave->getFilesystem()->write($key, $content, true);
}
}
|
[
"public",
"function",
"saveContent",
"(",
"$",
"key",
",",
"$",
"content",
")",
"{",
"$",
"this",
"->",
"master",
"->",
"getFilesystem",
"(",
")",
"->",
"write",
"(",
"$",
"key",
",",
"$",
"content",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"slaves",
"as",
"$",
"slave",
")",
"{",
"$",
"slave",
"->",
"getFilesystem",
"(",
")",
"->",
"write",
"(",
"$",
"key",
",",
"$",
"content",
",",
"true",
")",
";",
"}",
"}"
] |
Save file from string, in master and slaves.
@param string $key Path of file
@param string content of file
|
[
"Save",
"file",
"from",
"string",
"in",
"master",
"and",
"slaves",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Filesystem/FilesystemManipulator.php#L116-L123
|
223,795
|
apoutchika/MediaBundle
|
Filesystem/FilesystemManipulator.php
|
FilesystemManipulator.delete
|
public function delete($key)
{
$this->master->getFilesystem()->delete($key);
foreach ($this->slaves as $slave) {
$slave->getFilesystem()->delete($key);
}
}
|
php
|
public function delete($key)
{
$this->master->getFilesystem()->delete($key);
foreach ($this->slaves as $slave) {
$slave->getFilesystem()->delete($key);
}
}
|
[
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"master",
"->",
"getFilesystem",
"(",
")",
"->",
"delete",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"slaves",
"as",
"$",
"slave",
")",
"{",
"$",
"slave",
"->",
"getFilesystem",
"(",
")",
"->",
"delete",
"(",
"$",
"key",
")",
";",
"}",
"}"
] |
delete file in master and slaves.
@param string $key Path of file
|
[
"delete",
"file",
"in",
"master",
"and",
"slaves",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Filesystem/FilesystemManipulator.php#L142-L149
|
223,796
|
apoutchika/MediaBundle
|
Factory/AliasManipulatorFactory.php
|
AliasManipulatorFactory.setAlias
|
public function setAlias($alias)
{
$aliasManipulator = new AliasManipulator($this->originalDir, $this->alias);
$aliasManipulator->setAlias($alias);
return $aliasManipulator;
}
|
php
|
public function setAlias($alias)
{
$aliasManipulator = new AliasManipulator($this->originalDir, $this->alias);
$aliasManipulator->setAlias($alias);
return $aliasManipulator;
}
|
[
"public",
"function",
"setAlias",
"(",
"$",
"alias",
")",
"{",
"$",
"aliasManipulator",
"=",
"new",
"AliasManipulator",
"(",
"$",
"this",
"->",
"originalDir",
",",
"$",
"this",
"->",
"alias",
")",
";",
"$",
"aliasManipulator",
"->",
"setAlias",
"(",
"$",
"alias",
")",
";",
"return",
"$",
"aliasManipulator",
";",
"}"
] |
Set alias, and return AliasManipulator.
@param array|string|null $alias
@return AliasManipulator
|
[
"Set",
"alias",
"and",
"return",
"AliasManipulator",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Factory/AliasManipulatorFactory.php#L54-L60
|
223,797
|
OXID-eSales/oxid-eshop-ide-helper
|
src/Core/ModuleMetadataParser.php
|
ModuleMetadataParser.getChainExtendedClasses
|
public function getChainExtendedClasses()
{
$chainExtendMap = [];
$paths = $this->scanner->getFilePaths();
foreach ($paths as $path) {
$aModule = [];
include($path);
if (isset($aModule['extend'])) {
$chainExtendMap = array_merge($chainExtendMap, array_flip($aModule['extend']));
}
}
return $chainExtendMap;
}
|
php
|
public function getChainExtendedClasses()
{
$chainExtendMap = [];
$paths = $this->scanner->getFilePaths();
foreach ($paths as $path) {
$aModule = [];
include($path);
if (isset($aModule['extend'])) {
$chainExtendMap = array_merge($chainExtendMap, array_flip($aModule['extend']));
}
}
return $chainExtendMap;
}
|
[
"public",
"function",
"getChainExtendedClasses",
"(",
")",
"{",
"$",
"chainExtendMap",
"=",
"[",
"]",
";",
"$",
"paths",
"=",
"$",
"this",
"->",
"scanner",
"->",
"getFilePaths",
"(",
")",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"aModule",
"=",
"[",
"]",
";",
"include",
"(",
"$",
"path",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"aModule",
"[",
"'extend'",
"]",
")",
")",
"{",
"$",
"chainExtendMap",
"=",
"array_merge",
"(",
"$",
"chainExtendMap",
",",
"array_flip",
"(",
"$",
"aModule",
"[",
"'extend'",
"]",
")",
")",
";",
"}",
"}",
"return",
"$",
"chainExtendMap",
";",
"}"
] |
Get all module chain extensions.
Key is module class, value is shop class.
@return array
|
[
"Get",
"all",
"module",
"chain",
"extensions",
".",
"Key",
"is",
"module",
"class",
"value",
"is",
"shop",
"class",
"."
] |
e29836a482e7e2386ebb1cefd01e31240e2b3847
|
https://github.com/OXID-eSales/oxid-eshop-ide-helper/blob/e29836a482e7e2386ebb1cefd01e31240e2b3847/src/Core/ModuleMetadataParser.php#L35-L48
|
223,798
|
middlewares/negotiation
|
src/ContentType.php
|
ContentType.detectCharset
|
private function detectCharset(ServerRequestInterface $request)
{
$accept = $request->getHeaderLine('Accept-Charset');
return $this->negotiateHeader($accept, new CharsetNegotiator(), $this->charsets);
}
|
php
|
private function detectCharset(ServerRequestInterface $request)
{
$accept = $request->getHeaderLine('Accept-Charset');
return $this->negotiateHeader($accept, new CharsetNegotiator(), $this->charsets);
}
|
[
"private",
"function",
"detectCharset",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"$",
"accept",
"=",
"$",
"request",
"->",
"getHeaderLine",
"(",
"'Accept-Charset'",
")",
";",
"return",
"$",
"this",
"->",
"negotiateHeader",
"(",
"$",
"accept",
",",
"new",
"CharsetNegotiator",
"(",
")",
",",
"$",
"this",
"->",
"charsets",
")",
";",
"}"
] |
Returns the charset accepted.
@return null|string
|
[
"Returns",
"the",
"charset",
"accepted",
"."
] |
107d31132cd5af446be97827bfd0202f15189a34
|
https://github.com/middlewares/negotiation/blob/107d31132cd5af446be97827bfd0202f15189a34/src/ContentType.php#L175-L180
|
223,799
|
apoutchika/MediaBundle
|
Services/Image/BaseImage.php
|
BaseImage.apply
|
public function apply($aliasName = null)
{
$reset = false;
if ($aliasName === null) {
$aliasName = $this->mediaManager->getOriginalDir();
$reset = true;
}
$this->updateFile($this->image);
$this->updateFocus($this->media);
$fs = $this
->mediaManager
->getFilesystemManipulator();
$fs->saveContent(
$aliasName.'/'.$this->media->getReference(),
$this->image->get($this->media->getExtension())
);
$this->mediaManager
->setSizeWidthAndHeight($this->media)
->save($this->media);
if ($reset === true) {
$this->mediaManager->reset($this->media);
}
}
|
php
|
public function apply($aliasName = null)
{
$reset = false;
if ($aliasName === null) {
$aliasName = $this->mediaManager->getOriginalDir();
$reset = true;
}
$this->updateFile($this->image);
$this->updateFocus($this->media);
$fs = $this
->mediaManager
->getFilesystemManipulator();
$fs->saveContent(
$aliasName.'/'.$this->media->getReference(),
$this->image->get($this->media->getExtension())
);
$this->mediaManager
->setSizeWidthAndHeight($this->media)
->save($this->media);
if ($reset === true) {
$this->mediaManager->reset($this->media);
}
}
|
[
"public",
"function",
"apply",
"(",
"$",
"aliasName",
"=",
"null",
")",
"{",
"$",
"reset",
"=",
"false",
";",
"if",
"(",
"$",
"aliasName",
"===",
"null",
")",
"{",
"$",
"aliasName",
"=",
"$",
"this",
"->",
"mediaManager",
"->",
"getOriginalDir",
"(",
")",
";",
"$",
"reset",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"updateFile",
"(",
"$",
"this",
"->",
"image",
")",
";",
"$",
"this",
"->",
"updateFocus",
"(",
"$",
"this",
"->",
"media",
")",
";",
"$",
"fs",
"=",
"$",
"this",
"->",
"mediaManager",
"->",
"getFilesystemManipulator",
"(",
")",
";",
"$",
"fs",
"->",
"saveContent",
"(",
"$",
"aliasName",
".",
"'/'",
".",
"$",
"this",
"->",
"media",
"->",
"getReference",
"(",
")",
",",
"$",
"this",
"->",
"image",
"->",
"get",
"(",
"$",
"this",
"->",
"media",
"->",
"getExtension",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"mediaManager",
"->",
"setSizeWidthAndHeight",
"(",
"$",
"this",
"->",
"media",
")",
"->",
"save",
"(",
"$",
"this",
"->",
"media",
")",
";",
"if",
"(",
"$",
"reset",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"mediaManager",
"->",
"reset",
"(",
"$",
"this",
"->",
"media",
")",
";",
"}",
"}"
] |
Apply the filter.
@param string $aliasName
|
[
"Apply",
"the",
"filter",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Services/Image/BaseImage.php#L56-L83
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.