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,800
|
enygma/gauth
|
src/GAuth/Auth.php
|
Auth.buildLookup
|
public function buildLookup()
{
$lookup = array_combine(
array_merge(range('A', 'Z'), range(2, 7)),
range(0, 31)
);
$this->setLookup($lookup);
}
|
php
|
public function buildLookup()
{
$lookup = array_combine(
array_merge(range('A', 'Z'), range(2, 7)),
range(0, 31)
);
$this->setLookup($lookup);
}
|
[
"public",
"function",
"buildLookup",
"(",
")",
"{",
"$",
"lookup",
"=",
"array_combine",
"(",
"array_merge",
"(",
"range",
"(",
"'A'",
",",
"'Z'",
")",
",",
"range",
"(",
"2",
",",
"7",
")",
")",
",",
"range",
"(",
"0",
",",
"31",
")",
")",
";",
"$",
"this",
"->",
"setLookup",
"(",
"$",
"lookup",
")",
";",
"}"
] |
Build the base32 lookup table
@return null
|
[
"Build",
"the",
"base32",
"lookup",
"table"
] |
a559a35209c80ff3a3f787eb46d1358e1cc4bcdf
|
https://github.com/enygma/gauth/blob/a559a35209c80ff3a3f787eb46d1358e1cc4bcdf/src/GAuth/Auth.php#L69-L76
|
223,801
|
enygma/gauth
|
src/GAuth/Auth.php
|
Auth.setInitKey
|
public function setInitKey($key)
{
if (preg_match('/^['.implode('', array_keys($this->getLookup())).']+$/', $key) == false) {
throw new \InvalidArgumentException('Invalid base32 hash!');
}
$this->initKey = $key;
return $this;
}
|
php
|
public function setInitKey($key)
{
if (preg_match('/^['.implode('', array_keys($this->getLookup())).']+$/', $key) == false) {
throw new \InvalidArgumentException('Invalid base32 hash!');
}
$this->initKey = $key;
return $this;
}
|
[
"public",
"function",
"setInitKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/^['",
".",
"implode",
"(",
"''",
",",
"array_keys",
"(",
"$",
"this",
"->",
"getLookup",
"(",
")",
")",
")",
".",
"']+$/'",
",",
"$",
"key",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid base32 hash!'",
")",
";",
"}",
"$",
"this",
"->",
"initKey",
"=",
"$",
"key",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the initialization key for the object
@param string $key Initialization key
@throws \InvalidArgumentException If hash is not valid base32
@return \GAuth\Auth instance
|
[
"Set",
"the",
"initialization",
"key",
"for",
"the",
"object"
] |
a559a35209c80ff3a3f787eb46d1358e1cc4bcdf
|
https://github.com/enygma/gauth/blob/a559a35209c80ff3a3f787eb46d1358e1cc4bcdf/src/GAuth/Auth.php#L109-L116
|
223,802
|
enygma/gauth
|
src/GAuth/Auth.php
|
Auth.validateCode
|
public function validateCode($code, $initKey = null, $timestamp = null, $range = null)
{
if (strlen($code) !== $this->getCodeLength()) {
throw new \InvalidArgumentException('Incorrect code length');
}
$range = ($range == null) ? $this->getRange() : $range;
$timestamp = ($timestamp == null) ? $this->generateTimestamp() : $timestamp;
$initKey = ($initKey == null) ? $this->getInitKey() : $initKey;
$binary = $this->base32_decode($initKey);
for ($time = ($timestamp - $range); $time <= ($timestamp + $range); $time++) {
if ($this->generateOneTime($binary, $time) == $code) {
return true;
}
}
return false;
}
|
php
|
public function validateCode($code, $initKey = null, $timestamp = null, $range = null)
{
if (strlen($code) !== $this->getCodeLength()) {
throw new \InvalidArgumentException('Incorrect code length');
}
$range = ($range == null) ? $this->getRange() : $range;
$timestamp = ($timestamp == null) ? $this->generateTimestamp() : $timestamp;
$initKey = ($initKey == null) ? $this->getInitKey() : $initKey;
$binary = $this->base32_decode($initKey);
for ($time = ($timestamp - $range); $time <= ($timestamp + $range); $time++) {
if ($this->generateOneTime($binary, $time) == $code) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"validateCode",
"(",
"$",
"code",
",",
"$",
"initKey",
"=",
"null",
",",
"$",
"timestamp",
"=",
"null",
",",
"$",
"range",
"=",
"null",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"code",
")",
"!==",
"$",
"this",
"->",
"getCodeLength",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Incorrect code length'",
")",
";",
"}",
"$",
"range",
"=",
"(",
"$",
"range",
"==",
"null",
")",
"?",
"$",
"this",
"->",
"getRange",
"(",
")",
":",
"$",
"range",
";",
"$",
"timestamp",
"=",
"(",
"$",
"timestamp",
"==",
"null",
")",
"?",
"$",
"this",
"->",
"generateTimestamp",
"(",
")",
":",
"$",
"timestamp",
";",
"$",
"initKey",
"=",
"(",
"$",
"initKey",
"==",
"null",
")",
"?",
"$",
"this",
"->",
"getInitKey",
"(",
")",
":",
"$",
"initKey",
";",
"$",
"binary",
"=",
"$",
"this",
"->",
"base32_decode",
"(",
"$",
"initKey",
")",
";",
"for",
"(",
"$",
"time",
"=",
"(",
"$",
"timestamp",
"-",
"$",
"range",
")",
";",
"$",
"time",
"<=",
"(",
"$",
"timestamp",
"+",
"$",
"range",
")",
";",
"$",
"time",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"generateOneTime",
"(",
"$",
"binary",
",",
"$",
"time",
")",
"==",
"$",
"code",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Validate the given code
@param string $code Code entered by user
@param string $initKey Initialization key
@param string $timestamp Timestamp for calculation
@param integer $range Seconds before/after to validate hash against
@throws \InvalidArgumentException If incorrect code length
@return boolean Pass/fail of validation
|
[
"Validate",
"the",
"given",
"code"
] |
a559a35209c80ff3a3f787eb46d1358e1cc4bcdf
|
https://github.com/enygma/gauth/blob/a559a35209c80ff3a3f787eb46d1358e1cc4bcdf/src/GAuth/Auth.php#L212-L230
|
223,803
|
enygma/gauth
|
src/GAuth/Auth.php
|
Auth.generateOneTime
|
public function generateOneTime($initKey = null, $timestamp = null)
{
$initKey = ($initKey == null) ? $this->getInitKey() : $initKey;
$timestamp = ($timestamp == null) ? $this->generateTimestamp() : $timestamp;
$hash = hash_hmac (
'sha1',
pack('N*', 0) . pack('N*', $timestamp),
$initKey,
true
);
return str_pad($this->truncateHash($hash), $this->getCodeLength(), '0', STR_PAD_LEFT);
}
|
php
|
public function generateOneTime($initKey = null, $timestamp = null)
{
$initKey = ($initKey == null) ? $this->getInitKey() : $initKey;
$timestamp = ($timestamp == null) ? $this->generateTimestamp() : $timestamp;
$hash = hash_hmac (
'sha1',
pack('N*', 0) . pack('N*', $timestamp),
$initKey,
true
);
return str_pad($this->truncateHash($hash), $this->getCodeLength(), '0', STR_PAD_LEFT);
}
|
[
"public",
"function",
"generateOneTime",
"(",
"$",
"initKey",
"=",
"null",
",",
"$",
"timestamp",
"=",
"null",
")",
"{",
"$",
"initKey",
"=",
"(",
"$",
"initKey",
"==",
"null",
")",
"?",
"$",
"this",
"->",
"getInitKey",
"(",
")",
":",
"$",
"initKey",
";",
"$",
"timestamp",
"=",
"(",
"$",
"timestamp",
"==",
"null",
")",
"?",
"$",
"this",
"->",
"generateTimestamp",
"(",
")",
":",
"$",
"timestamp",
";",
"$",
"hash",
"=",
"hash_hmac",
"(",
"'sha1'",
",",
"pack",
"(",
"'N*'",
",",
"0",
")",
".",
"pack",
"(",
"'N*'",
",",
"$",
"timestamp",
")",
",",
"$",
"initKey",
",",
"true",
")",
";",
"return",
"str_pad",
"(",
"$",
"this",
"->",
"truncateHash",
"(",
"$",
"hash",
")",
",",
"$",
"this",
"->",
"getCodeLength",
"(",
")",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"}"
] |
Generate a one-time code
@param string $initKey Initialization key [optional]
@param string $timestamp Timestamp for calculation [optional]
@return string Geneerated code/hash
|
[
"Generate",
"a",
"one",
"-",
"time",
"code"
] |
a559a35209c80ff3a3f787eb46d1358e1cc4bcdf
|
https://github.com/enygma/gauth/blob/a559a35209c80ff3a3f787eb46d1358e1cc4bcdf/src/GAuth/Auth.php#L239-L252
|
223,804
|
enygma/gauth
|
src/GAuth/Auth.php
|
Auth.truncateHash
|
public function truncateHash($hash)
{
$offset = ord($hash[19]) & 0xf;
return (
((ord($hash[$offset+0]) & 0x7f) << 24 ) |
((ord($hash[$offset+1]) & 0xff) << 16 ) |
((ord($hash[$offset+2]) & 0xff) << 8 ) |
(ord($hash[$offset+3]) & 0xff)
) % pow(10, $this->getCodeLength());
}
|
php
|
public function truncateHash($hash)
{
$offset = ord($hash[19]) & 0xf;
return (
((ord($hash[$offset+0]) & 0x7f) << 24 ) |
((ord($hash[$offset+1]) & 0xff) << 16 ) |
((ord($hash[$offset+2]) & 0xff) << 8 ) |
(ord($hash[$offset+3]) & 0xff)
) % pow(10, $this->getCodeLength());
}
|
[
"public",
"function",
"truncateHash",
"(",
"$",
"hash",
")",
"{",
"$",
"offset",
"=",
"ord",
"(",
"$",
"hash",
"[",
"19",
"]",
")",
"&",
"0xf",
";",
"return",
"(",
"(",
"(",
"ord",
"(",
"$",
"hash",
"[",
"$",
"offset",
"+",
"0",
"]",
")",
"&",
"0x7f",
")",
"<<",
"24",
")",
"|",
"(",
"(",
"ord",
"(",
"$",
"hash",
"[",
"$",
"offset",
"+",
"1",
"]",
")",
"&",
"0xff",
")",
"<<",
"16",
")",
"|",
"(",
"(",
"ord",
"(",
"$",
"hash",
"[",
"$",
"offset",
"+",
"2",
"]",
")",
"&",
"0xff",
")",
"<<",
"8",
")",
"|",
"(",
"ord",
"(",
"$",
"hash",
"[",
"$",
"offset",
"+",
"3",
"]",
")",
"&",
"0xff",
")",
")",
"%",
"pow",
"(",
"10",
",",
"$",
"this",
"->",
"getCodeLength",
"(",
")",
")",
";",
"}"
] |
Truncate the given hash down to just what we need
@param string $hash Hash to truncate
@return string Truncated hash value
|
[
"Truncate",
"the",
"given",
"hash",
"down",
"to",
"just",
"what",
"we",
"need"
] |
a559a35209c80ff3a3f787eb46d1358e1cc4bcdf
|
https://github.com/enygma/gauth/blob/a559a35209c80ff3a3f787eb46d1358e1cc4bcdf/src/GAuth/Auth.php#L318-L328
|
223,805
|
enygma/gauth
|
src/GAuth/Auth.php
|
Auth.base32_decode
|
public function base32_decode($hash)
{
$lookup = $this->getLookup();
if (preg_match('/^['.implode('', array_keys($lookup)).']+$/', $hash) == false) {
throw new \InvalidArgumentException('Invalid base32 hash!');
}
$hash = strtoupper($hash);
$buffer = 0;
$length = 0;
$binary = '';
for ($i = 0; $i < strlen($hash); $i++) {
$buffer = $buffer << 5;
$buffer += $lookup[$hash[$i]];
$length += 5;
if ($length >= 8) {
$length -= 8;
$binary .= chr(($buffer & (0xFF << $length)) >> $length);
}
}
return $binary;
}
|
php
|
public function base32_decode($hash)
{
$lookup = $this->getLookup();
if (preg_match('/^['.implode('', array_keys($lookup)).']+$/', $hash) == false) {
throw new \InvalidArgumentException('Invalid base32 hash!');
}
$hash = strtoupper($hash);
$buffer = 0;
$length = 0;
$binary = '';
for ($i = 0; $i < strlen($hash); $i++) {
$buffer = $buffer << 5;
$buffer += $lookup[$hash[$i]];
$length += 5;
if ($length >= 8) {
$length -= 8;
$binary .= chr(($buffer & (0xFF << $length)) >> $length);
}
}
return $binary;
}
|
[
"public",
"function",
"base32_decode",
"(",
"$",
"hash",
")",
"{",
"$",
"lookup",
"=",
"$",
"this",
"->",
"getLookup",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^['",
".",
"implode",
"(",
"''",
",",
"array_keys",
"(",
"$",
"lookup",
")",
")",
".",
"']+$/'",
",",
"$",
"hash",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid base32 hash!'",
")",
";",
"}",
"$",
"hash",
"=",
"strtoupper",
"(",
"$",
"hash",
")",
";",
"$",
"buffer",
"=",
"0",
";",
"$",
"length",
"=",
"0",
";",
"$",
"binary",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"hash",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"buffer",
"=",
"$",
"buffer",
"<<",
"5",
";",
"$",
"buffer",
"+=",
"$",
"lookup",
"[",
"$",
"hash",
"[",
"$",
"i",
"]",
"]",
";",
"$",
"length",
"+=",
"5",
";",
"if",
"(",
"$",
"length",
">=",
"8",
")",
"{",
"$",
"length",
"-=",
"8",
";",
"$",
"binary",
".=",
"chr",
"(",
"(",
"$",
"buffer",
"&",
"(",
"0xFF",
"<<",
"$",
"length",
")",
")",
">>",
"$",
"length",
")",
";",
"}",
"}",
"return",
"$",
"binary",
";",
"}"
] |
Base32 decoding function
@param string base32 encoded hash
@throws \InvalidArgumentException When hash is not valid
@return string Binary value of hash
|
[
"Base32",
"decoding",
"function"
] |
a559a35209c80ff3a3f787eb46d1358e1cc4bcdf
|
https://github.com/enygma/gauth/blob/a559a35209c80ff3a3f787eb46d1358e1cc4bcdf/src/GAuth/Auth.php#L337-L362
|
223,806
|
nilportugues/php-sitemap
|
src/Item/Video/Validator/RatingValidator.php
|
RatingValidator.validate
|
public static function validate($rating)
{
if (\is_numeric($rating) && $rating > -0.01 && $rating < 5.01) {
\preg_match('/([0-9].[0-9])/', $rating, $matches);
$matches[0] = \floatval($matches[0]);
return (!empty($matches[0]) && $matches[0] <= 5.0 && $matches[0] >= 0.0) ? $matches[0] : false;
}
return false;
}
|
php
|
public static function validate($rating)
{
if (\is_numeric($rating) && $rating > -0.01 && $rating < 5.01) {
\preg_match('/([0-9].[0-9])/', $rating, $matches);
$matches[0] = \floatval($matches[0]);
return (!empty($matches[0]) && $matches[0] <= 5.0 && $matches[0] >= 0.0) ? $matches[0] : false;
}
return false;
}
|
[
"public",
"static",
"function",
"validate",
"(",
"$",
"rating",
")",
"{",
"if",
"(",
"\\",
"is_numeric",
"(",
"$",
"rating",
")",
"&&",
"$",
"rating",
">",
"-",
"0.01",
"&&",
"$",
"rating",
"<",
"5.01",
")",
"{",
"\\",
"preg_match",
"(",
"'/([0-9].[0-9])/'",
",",
"$",
"rating",
",",
"$",
"matches",
")",
";",
"$",
"matches",
"[",
"0",
"]",
"=",
"\\",
"floatval",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"return",
"(",
"!",
"empty",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
"&&",
"$",
"matches",
"[",
"0",
"]",
"<=",
"5.0",
"&&",
"$",
"matches",
"[",
"0",
"]",
">=",
"0.0",
")",
"?",
"$",
"matches",
"[",
"0",
"]",
":",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
The rating of the video. Allowed values are float numbers in the range 0.0 to 5.0.
@param $rating
@return string|false
|
[
"The",
"rating",
"of",
"the",
"video",
".",
"Allowed",
"values",
"are",
"float",
"numbers",
"in",
"the",
"range",
"0",
".",
"0",
"to",
"5",
".",
"0",
"."
] |
b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd
|
https://github.com/nilportugues/php-sitemap/blob/b1c7109d6e0c30ee9a0f9ef3b73bac406add9bfd/src/Item/Video/Validator/RatingValidator.php#L25-L35
|
223,807
|
puli/manager
|
src/Api/Discovery/NoSuchBindingException.php
|
NoSuchBindingException.forUuidAndModule
|
public static function forUuidAndModule(Uuid $uuid, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The binding with UUID "%s" does not exist in module "%s".',
$uuid->toString(),
$moduleName
), 0, $cause);
}
|
php
|
public static function forUuidAndModule(Uuid $uuid, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The binding with UUID "%s" does not exist in module "%s".',
$uuid->toString(),
$moduleName
), 0, $cause);
}
|
[
"public",
"static",
"function",
"forUuidAndModule",
"(",
"Uuid",
"$",
"uuid",
",",
"$",
"moduleName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The binding with UUID \"%s\" does not exist in module \"%s\".'",
",",
"$",
"uuid",
"->",
"toString",
"(",
")",
",",
"$",
"moduleName",
")",
",",
"0",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for a UUID that was not found in a given module.
@param Uuid $uuid The UUID.
@param string $moduleName The name of the containing module.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception.
|
[
"Creates",
"an",
"exception",
"for",
"a",
"UUID",
"that",
"was",
"not",
"found",
"in",
"a",
"given",
"module",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Discovery/NoSuchBindingException.php#L53-L60
|
223,808
|
puli/manager
|
src/Api/Installer/NoSuchInstallerException.php
|
NoSuchInstallerException.forInstallerNameAndModuleName
|
public static function forInstallerNameAndModuleName($installerName, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The installer "%s" does not exist in module "%s".',
$installerName,
$moduleName
), 0, $cause);
}
|
php
|
public static function forInstallerNameAndModuleName($installerName, $moduleName, Exception $cause = null)
{
return new static(sprintf(
'The installer "%s" does not exist in module "%s".',
$installerName,
$moduleName
), 0, $cause);
}
|
[
"public",
"static",
"function",
"forInstallerNameAndModuleName",
"(",
"$",
"installerName",
",",
"$",
"moduleName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The installer \"%s\" does not exist in module \"%s\".'",
",",
"$",
"installerName",
",",
"$",
"moduleName",
")",
",",
"0",
",",
"$",
"cause",
")",
";",
"}"
] |
Creates an exception for an installer name that was not found in a given
module.
@param string $installerName The installer name.
@param string $moduleName The module 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",
"in",
"a",
"given",
"module",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Installer/NoSuchInstallerException.php#L53-L60
|
223,809
|
ongr-io/FilterManagerBundle
|
Search/FilterContainer.php
|
FilterContainer.buildSearchRequest
|
public function buildSearchRequest(Request $request)
{
$search = new SearchRequest();
/** @var FilterInterface[] $filters */
$filters = $this->all();
foreach ($filters as $name => $filter) {
$state = $filter->getState($request);
$state->setName($name);
$search->set($name, $state);
}
return $search;
}
|
php
|
public function buildSearchRequest(Request $request)
{
$search = new SearchRequest();
/** @var FilterInterface[] $filters */
$filters = $this->all();
foreach ($filters as $name => $filter) {
$state = $filter->getState($request);
$state->setName($name);
$search->set($name, $state);
}
return $search;
}
|
[
"public",
"function",
"buildSearchRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"search",
"=",
"new",
"SearchRequest",
"(",
")",
";",
"/** @var FilterInterface[] $filters */",
"$",
"filters",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"$",
"state",
"=",
"$",
"filter",
"->",
"getState",
"(",
"$",
"request",
")",
";",
"$",
"state",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"search",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"state",
")",
";",
"}",
"return",
"$",
"search",
";",
"}"
] |
Builds search request according to given filters.
@param Request $request
@return SearchRequest
|
[
"Builds",
"search",
"request",
"according",
"to",
"given",
"filters",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Search/FilterContainer.php#L91-L104
|
223,810
|
ongr-io/FilterManagerBundle
|
Search/FilterContainer.php
|
FilterContainer.buildSearch
|
public function buildSearch(SearchRequest $request, $filters = null)
{
$search = new Search();
/** @var FilterInterface[] $filters */
$filters = $filters ? $filters : $this->all();
foreach ($filters as $name => $filter) {
$filter->modifySearch($search, $request->get($name), $request);
}
return $search;
}
|
php
|
public function buildSearch(SearchRequest $request, $filters = null)
{
$search = new Search();
/** @var FilterInterface[] $filters */
$filters = $filters ? $filters : $this->all();
foreach ($filters as $name => $filter) {
$filter->modifySearch($search, $request->get($name), $request);
}
return $search;
}
|
[
"public",
"function",
"buildSearch",
"(",
"SearchRequest",
"$",
"request",
",",
"$",
"filters",
"=",
"null",
")",
"{",
"$",
"search",
"=",
"new",
"Search",
"(",
")",
";",
"/** @var FilterInterface[] $filters */",
"$",
"filters",
"=",
"$",
"filters",
"?",
"$",
"filters",
":",
"$",
"this",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"name",
"=>",
"$",
"filter",
")",
"{",
"$",
"filter",
"->",
"modifySearch",
"(",
"$",
"search",
",",
"$",
"request",
"->",
"get",
"(",
"$",
"name",
")",
",",
"$",
"request",
")",
";",
"}",
"return",
"$",
"search",
";",
"}"
] |
Builds elastic search query by given SearchRequest and filters.
@param SearchRequest $request
@param \ArrayIterator|null $filters
@return Search
|
[
"Builds",
"elastic",
"search",
"query",
"by",
"given",
"SearchRequest",
"and",
"filters",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Search/FilterContainer.php#L114-L125
|
223,811
|
puli/manager
|
src/Api/Container.php
|
Container.parseHomeDirectory
|
private static function parseHomeDirectory()
{
try {
$homeDir = System::parseHomeDirectory();
System::denyWebAccess($homeDir);
return $homeDir;
} catch (InvalidConfigException $e) {
// Context variable was not found -> no home directory
// This happens often on web servers where the home directory is
// not set manually
return null;
}
}
|
php
|
private static function parseHomeDirectory()
{
try {
$homeDir = System::parseHomeDirectory();
System::denyWebAccess($homeDir);
return $homeDir;
} catch (InvalidConfigException $e) {
// Context variable was not found -> no home directory
// This happens often on web servers where the home directory is
// not set manually
return null;
}
}
|
[
"private",
"static",
"function",
"parseHomeDirectory",
"(",
")",
"{",
"try",
"{",
"$",
"homeDir",
"=",
"System",
"::",
"parseHomeDirectory",
"(",
")",
";",
"System",
"::",
"denyWebAccess",
"(",
"$",
"homeDir",
")",
";",
"return",
"$",
"homeDir",
";",
"}",
"catch",
"(",
"InvalidConfigException",
"$",
"e",
")",
"{",
"// Context variable was not found -> no home directory",
"// This happens often on web servers where the home directory is",
"// not set manually",
"return",
"null",
";",
"}",
"}"
] |
Parses the system context for a home directory.
@return null|string Returns the path to the home directory or `null`
if none was found.
|
[
"Parses",
"the",
"system",
"context",
"for",
"a",
"home",
"directory",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L303-L317
|
223,812
|
puli/manager
|
src/Api/Container.php
|
Container.start
|
public function start()
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
if (null !== $this->rootDir) {
$this->context = $this->createProjectContext($this->rootDir, $this->env);
$bootstrapFile = $this->context->getConfig()->get(Config::BOOTSTRAP_FILE);
// Run the project's bootstrap file to enable project-specific
// autoloading
if (null !== $bootstrapFile) {
// Backup autoload functions of the PHAR
$autoloadFunctions = spl_autoload_functions();
foreach ($autoloadFunctions as $autoloadFunction) {
spl_autoload_unregister($autoloadFunction);
}
// Add project-specific autoload functions
require_once Path::makeAbsolute($bootstrapFile, $this->rootDir);
// Prepend autoload functions of the PHAR again
// This is needed if the user specific autoload functions were
// added with $prepend=true (as done by Composer)
// Classes in the PHAR should always take precedence
for ($i = count($autoloadFunctions) - 1; $i >= 0; --$i) {
spl_autoload_register($autoloadFunctions[$i], true, true);
}
}
} else {
$this->context = $this->createGlobalContext();
}
$this->dispatcher = $this->context->getEventDispatcher();
$this->started = true;
// Start plugins once the container is running
if ($this->rootDir && $this->pluginsEnabled) {
$this->activatePlugins();
}
}
|
php
|
public function start()
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
if (null !== $this->rootDir) {
$this->context = $this->createProjectContext($this->rootDir, $this->env);
$bootstrapFile = $this->context->getConfig()->get(Config::BOOTSTRAP_FILE);
// Run the project's bootstrap file to enable project-specific
// autoloading
if (null !== $bootstrapFile) {
// Backup autoload functions of the PHAR
$autoloadFunctions = spl_autoload_functions();
foreach ($autoloadFunctions as $autoloadFunction) {
spl_autoload_unregister($autoloadFunction);
}
// Add project-specific autoload functions
require_once Path::makeAbsolute($bootstrapFile, $this->rootDir);
// Prepend autoload functions of the PHAR again
// This is needed if the user specific autoload functions were
// added with $prepend=true (as done by Composer)
// Classes in the PHAR should always take precedence
for ($i = count($autoloadFunctions) - 1; $i >= 0; --$i) {
spl_autoload_register($autoloadFunctions[$i], true, true);
}
}
} else {
$this->context = $this->createGlobalContext();
}
$this->dispatcher = $this->context->getEventDispatcher();
$this->started = true;
// Start plugins once the container is running
if ($this->rootDir && $this->pluginsEnabled) {
$this->activatePlugins();
}
}
|
[
"public",
"function",
"start",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli is already started'",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"rootDir",
")",
"{",
"$",
"this",
"->",
"context",
"=",
"$",
"this",
"->",
"createProjectContext",
"(",
"$",
"this",
"->",
"rootDir",
",",
"$",
"this",
"->",
"env",
")",
";",
"$",
"bootstrapFile",
"=",
"$",
"this",
"->",
"context",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"Config",
"::",
"BOOTSTRAP_FILE",
")",
";",
"// Run the project's bootstrap file to enable project-specific",
"// autoloading",
"if",
"(",
"null",
"!==",
"$",
"bootstrapFile",
")",
"{",
"// Backup autoload functions of the PHAR",
"$",
"autoloadFunctions",
"=",
"spl_autoload_functions",
"(",
")",
";",
"foreach",
"(",
"$",
"autoloadFunctions",
"as",
"$",
"autoloadFunction",
")",
"{",
"spl_autoload_unregister",
"(",
"$",
"autoloadFunction",
")",
";",
"}",
"// Add project-specific autoload functions",
"require_once",
"Path",
"::",
"makeAbsolute",
"(",
"$",
"bootstrapFile",
",",
"$",
"this",
"->",
"rootDir",
")",
";",
"// Prepend autoload functions of the PHAR again",
"// This is needed if the user specific autoload functions were",
"// added with $prepend=true (as done by Composer)",
"// Classes in the PHAR should always take precedence",
"for",
"(",
"$",
"i",
"=",
"count",
"(",
"$",
"autoloadFunctions",
")",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"--",
"$",
"i",
")",
"{",
"spl_autoload_register",
"(",
"$",
"autoloadFunctions",
"[",
"$",
"i",
"]",
",",
"true",
",",
"true",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"context",
"=",
"$",
"this",
"->",
"createGlobalContext",
"(",
")",
";",
"}",
"$",
"this",
"->",
"dispatcher",
"=",
"$",
"this",
"->",
"context",
"->",
"getEventDispatcher",
"(",
")",
";",
"$",
"this",
"->",
"started",
"=",
"true",
";",
"// Start plugins once the container is running",
"if",
"(",
"$",
"this",
"->",
"rootDir",
"&&",
"$",
"this",
"->",
"pluginsEnabled",
")",
"{",
"$",
"this",
"->",
"activatePlugins",
"(",
")",
";",
"}",
"}"
] |
Starts the service container.
|
[
"Starts",
"the",
"service",
"container",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L340-L382
|
223,813
|
puli/manager
|
src/Api/Container.php
|
Container.setRootDirectory
|
public function setRootDirectory($rootDir)
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
Assert::nullOrDirectory($rootDir);
$this->rootDir = $rootDir ? Path::canonicalize($rootDir) : null;
}
|
php
|
public function setRootDirectory($rootDir)
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
Assert::nullOrDirectory($rootDir);
$this->rootDir = $rootDir ? Path::canonicalize($rootDir) : null;
}
|
[
"public",
"function",
"setRootDirectory",
"(",
"$",
"rootDir",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli is already started'",
")",
";",
"}",
"Assert",
"::",
"nullOrDirectory",
"(",
"$",
"rootDir",
")",
";",
"$",
"this",
"->",
"rootDir",
"=",
"$",
"rootDir",
"?",
"Path",
"::",
"canonicalize",
"(",
"$",
"rootDir",
")",
":",
"null",
";",
"}"
] |
Sets the root directory of the managed Puli project.
@param string|null $rootDir The root directory of the managed Puli
project or `null` to start Puli outside of a
specific project.
|
[
"Sets",
"the",
"root",
"directory",
"of",
"the",
"managed",
"Puli",
"project",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L402-L411
|
223,814
|
puli/manager
|
src/Api/Container.php
|
Container.setEnvironment
|
public function setEnvironment($env)
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
$this->env = $env;
}
|
php
|
public function setEnvironment($env)
{
if ($this->started) {
throw new LogicException('Puli is already started');
}
Assert::oneOf($env, Environment::all(), 'The environment must be one of: %2$s. Got: %s');
$this->env = $env;
}
|
[
"public",
"function",
"setEnvironment",
"(",
"$",
"env",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli is already started'",
")",
";",
"}",
"Assert",
"::",
"oneOf",
"(",
"$",
"env",
",",
"Environment",
"::",
"all",
"(",
")",
",",
"'The environment must be one of: %2$s. Got: %s'",
")",
";",
"$",
"this",
"->",
"env",
"=",
"$",
"env",
";",
"}"
] |
Sets the environment of the managed Puli project.
@param string $env One of the {@link Environment} constants.
|
[
"Sets",
"the",
"environment",
"of",
"the",
"managed",
"Puli",
"project",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L418-L427
|
223,815
|
puli/manager
|
src/Api/Container.php
|
Container.getRepository
|
public function getRepository()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->context instanceof ProjectContext) {
return null;
}
if (!$this->repo) {
$this->repo = $this->getFactory()->createRepository();
}
return $this->repo;
}
|
php
|
public function getRepository()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->context instanceof ProjectContext) {
return null;
}
if (!$this->repo) {
$this->repo = $this->getFactory()->createRepository();
}
return $this->repo;
}
|
[
"public",
"function",
"getRepository",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"repo",
")",
"{",
"$",
"this",
"->",
"repo",
"=",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"createRepository",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"repo",
";",
"}"
] |
Returns the resource repository of the project.
@return EditableRepository The resource repository.
|
[
"Returns",
"the",
"resource",
"repository",
"of",
"the",
"project",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L546-L561
|
223,816
|
puli/manager
|
src/Api/Container.php
|
Container.getDiscovery
|
public function getDiscovery()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->context instanceof ProjectContext) {
return null;
}
if (!$this->discovery) {
$this->discovery = $this->getFactory()->createDiscovery($this->getRepository());
}
return $this->discovery;
}
|
php
|
public function getDiscovery()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->context instanceof ProjectContext) {
return null;
}
if (!$this->discovery) {
$this->discovery = $this->getFactory()->createDiscovery($this->getRepository());
}
return $this->discovery;
}
|
[
"public",
"function",
"getDiscovery",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"discovery",
")",
"{",
"$",
"this",
"->",
"discovery",
"=",
"$",
"this",
"->",
"getFactory",
"(",
")",
"->",
"createDiscovery",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"discovery",
";",
"}"
] |
Returns the resource discovery of the project.
@return EditableDiscovery The resource discovery.
|
[
"Returns",
"the",
"resource",
"discovery",
"of",
"the",
"project",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L568-L583
|
223,817
|
puli/manager
|
src/Api/Container.php
|
Container.getConfigFileManager
|
public function getConfigFileManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->configFileManager && $this->context->getHomeDirectory()) {
$this->configFileManager = new ConfigFileManagerImpl(
$this->context,
$this->getJsonStorage()
);
}
return $this->configFileManager;
}
|
php
|
public function getConfigFileManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->configFileManager && $this->context->getHomeDirectory()) {
$this->configFileManager = new ConfigFileManagerImpl(
$this->context,
$this->getJsonStorage()
);
}
return $this->configFileManager;
}
|
[
"public",
"function",
"getConfigFileManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"configFileManager",
"&&",
"$",
"this",
"->",
"context",
"->",
"getHomeDirectory",
"(",
")",
")",
"{",
"$",
"this",
"->",
"configFileManager",
"=",
"new",
"ConfigFileManagerImpl",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"getJsonStorage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"configFileManager",
";",
"}"
] |
Returns the configuration file manager.
@return ConfigFileManager The configuration file manager.
|
[
"Returns",
"the",
"configuration",
"file",
"manager",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L630-L644
|
223,818
|
puli/manager
|
src/Api/Container.php
|
Container.getRootModuleFileManager
|
public function getRootModuleFileManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->rootModuleFileManager && $this->context instanceof ProjectContext) {
$this->rootModuleFileManager = new RootModuleFileManagerImpl(
$this->context,
$this->getJsonStorage()
);
}
return $this->rootModuleFileManager;
}
|
php
|
public function getRootModuleFileManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->rootModuleFileManager && $this->context instanceof ProjectContext) {
$this->rootModuleFileManager = new RootModuleFileManagerImpl(
$this->context,
$this->getJsonStorage()
);
}
return $this->rootModuleFileManager;
}
|
[
"public",
"function",
"getRootModuleFileManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"rootModuleFileManager",
"&&",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"$",
"this",
"->",
"rootModuleFileManager",
"=",
"new",
"RootModuleFileManagerImpl",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"getJsonStorage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rootModuleFileManager",
";",
"}"
] |
Returns the root module file manager.
@return RootModuleFileManager The module file manager.
|
[
"Returns",
"the",
"root",
"module",
"file",
"manager",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L651-L665
|
223,819
|
puli/manager
|
src/Api/Container.php
|
Container.getModuleManager
|
public function getModuleManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->moduleManager && $this->context instanceof ProjectContext) {
$this->moduleManager = new ModuleManagerImpl(
$this->context,
$this->getJsonStorage()
);
}
return $this->moduleManager;
}
|
php
|
public function getModuleManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->moduleManager && $this->context instanceof ProjectContext) {
$this->moduleManager = new ModuleManagerImpl(
$this->context,
$this->getJsonStorage()
);
}
return $this->moduleManager;
}
|
[
"public",
"function",
"getModuleManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"moduleManager",
"&&",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"$",
"this",
"->",
"moduleManager",
"=",
"new",
"ModuleManagerImpl",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"getJsonStorage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"moduleManager",
";",
"}"
] |
Returns the module manager.
@return ModuleManager The module manager.
|
[
"Returns",
"the",
"module",
"manager",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L672-L686
|
223,820
|
puli/manager
|
src/Api/Container.php
|
Container.getRepositoryManager
|
public function getRepositoryManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->repositoryManager && $this->context instanceof ProjectContext) {
$this->repositoryManager = new RepositoryManagerImpl(
$this->context,
$this->getRepository(),
$this->getModuleManager()->findModules(Expr::method('isEnabled', Expr::same(true))),
$this->getJsonStorage()
);
}
return $this->repositoryManager;
}
|
php
|
public function getRepositoryManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->repositoryManager && $this->context instanceof ProjectContext) {
$this->repositoryManager = new RepositoryManagerImpl(
$this->context,
$this->getRepository(),
$this->getModuleManager()->findModules(Expr::method('isEnabled', Expr::same(true))),
$this->getJsonStorage()
);
}
return $this->repositoryManager;
}
|
[
"public",
"function",
"getRepositoryManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"repositoryManager",
"&&",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"$",
"this",
"->",
"repositoryManager",
"=",
"new",
"RepositoryManagerImpl",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"getRepository",
"(",
")",
",",
"$",
"this",
"->",
"getModuleManager",
"(",
")",
"->",
"findModules",
"(",
"Expr",
"::",
"method",
"(",
"'isEnabled'",
",",
"Expr",
"::",
"same",
"(",
"true",
")",
")",
")",
",",
"$",
"this",
"->",
"getJsonStorage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"repositoryManager",
";",
"}"
] |
Returns the resource repository manager.
@return RepositoryManager The repository manager.
|
[
"Returns",
"the",
"resource",
"repository",
"manager",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L693-L709
|
223,821
|
puli/manager
|
src/Api/Container.php
|
Container.getDiscoveryManager
|
public function getDiscoveryManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->discoveryManager && $this->context instanceof ProjectContext) {
$this->discoveryManager = new DiscoveryManagerImpl(
$this->context,
$this->getDiscovery(),
$this->getModuleManager()->findModules(Expr::method('isEnabled', Expr::same(true))),
$this->getJsonStorage(),
$this->logger
);
}
return $this->discoveryManager;
}
|
php
|
public function getDiscoveryManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->discoveryManager && $this->context instanceof ProjectContext) {
$this->discoveryManager = new DiscoveryManagerImpl(
$this->context,
$this->getDiscovery(),
$this->getModuleManager()->findModules(Expr::method('isEnabled', Expr::same(true))),
$this->getJsonStorage(),
$this->logger
);
}
return $this->discoveryManager;
}
|
[
"public",
"function",
"getDiscoveryManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"discoveryManager",
"&&",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"$",
"this",
"->",
"discoveryManager",
"=",
"new",
"DiscoveryManagerImpl",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"this",
"->",
"getDiscovery",
"(",
")",
",",
"$",
"this",
"->",
"getModuleManager",
"(",
")",
"->",
"findModules",
"(",
"Expr",
"::",
"method",
"(",
"'isEnabled'",
",",
"Expr",
"::",
"same",
"(",
"true",
")",
")",
")",
",",
"$",
"this",
"->",
"getJsonStorage",
"(",
")",
",",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"return",
"$",
"this",
"->",
"discoveryManager",
";",
"}"
] |
Returns the resource discovery manager.
@return DiscoveryManager The discovery manager.
|
[
"Returns",
"the",
"resource",
"discovery",
"manager",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L716-L733
|
223,822
|
puli/manager
|
src/Api/Container.php
|
Container.getServerManager
|
public function getServerManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->serverManager && $this->context instanceof ProjectContext) {
$this->serverManager = new ModuleFileServerManager(
$this->getRootModuleFileManager(),
$this->getInstallerManager()
);
}
return $this->serverManager;
}
|
php
|
public function getServerManager()
{
if (!$this->started) {
throw new LogicException('Puli was not started');
}
if (!$this->serverManager && $this->context instanceof ProjectContext) {
$this->serverManager = new ModuleFileServerManager(
$this->getRootModuleFileManager(),
$this->getInstallerManager()
);
}
return $this->serverManager;
}
|
[
"public",
"function",
"getServerManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Puli was not started'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"serverManager",
"&&",
"$",
"this",
"->",
"context",
"instanceof",
"ProjectContext",
")",
"{",
"$",
"this",
"->",
"serverManager",
"=",
"new",
"ModuleFileServerManager",
"(",
"$",
"this",
"->",
"getRootModuleFileManager",
"(",
")",
",",
"$",
"this",
"->",
"getInstallerManager",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"serverManager",
";",
"}"
] |
Returns the server manager.
@return ServerManager The server manager.
|
[
"Returns",
"the",
"server",
"manager",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L805-L819
|
223,823
|
puli/manager
|
src/Api/Container.php
|
Container.getJsonEncoder
|
public function getJsonEncoder()
{
if (!$this->jsonEncoder) {
$this->jsonEncoder = new JsonEncoder();
$this->jsonEncoder->setPrettyPrinting(true);
$this->jsonEncoder->setEscapeSlash(false);
$this->jsonEncoder->setTerminateWithLineFeed(true);
}
return $this->jsonEncoder;
}
|
php
|
public function getJsonEncoder()
{
if (!$this->jsonEncoder) {
$this->jsonEncoder = new JsonEncoder();
$this->jsonEncoder->setPrettyPrinting(true);
$this->jsonEncoder->setEscapeSlash(false);
$this->jsonEncoder->setTerminateWithLineFeed(true);
}
return $this->jsonEncoder;
}
|
[
"public",
"function",
"getJsonEncoder",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jsonEncoder",
")",
"{",
"$",
"this",
"->",
"jsonEncoder",
"=",
"new",
"JsonEncoder",
"(",
")",
";",
"$",
"this",
"->",
"jsonEncoder",
"->",
"setPrettyPrinting",
"(",
"true",
")",
";",
"$",
"this",
"->",
"jsonEncoder",
"->",
"setEscapeSlash",
"(",
"false",
")",
";",
"$",
"this",
"->",
"jsonEncoder",
"->",
"setTerminateWithLineFeed",
"(",
"true",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jsonEncoder",
";",
"}"
] |
Returns the JSON encoder.
@return JsonEncoder The JSON encoder.
|
[
"Returns",
"the",
"JSON",
"encoder",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L965-L975
|
223,824
|
puli/manager
|
src/Api/Container.php
|
Container.getJsonValidator
|
public function getJsonValidator()
{
if (!$this->jsonValidator) {
$uriRetriever = new UriRetriever();
// Load puli.io schemas from the schema/ directory
$uriRetriever->setUriRetriever(new LocalUriRetriever());
$this->jsonValidator = new JsonValidator(null, $uriRetriever);
}
return $this->jsonValidator;
}
|
php
|
public function getJsonValidator()
{
if (!$this->jsonValidator) {
$uriRetriever = new UriRetriever();
// Load puli.io schemas from the schema/ directory
$uriRetriever->setUriRetriever(new LocalUriRetriever());
$this->jsonValidator = new JsonValidator(null, $uriRetriever);
}
return $this->jsonValidator;
}
|
[
"public",
"function",
"getJsonValidator",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jsonValidator",
")",
"{",
"$",
"uriRetriever",
"=",
"new",
"UriRetriever",
"(",
")",
";",
"// Load puli.io schemas from the schema/ directory",
"$",
"uriRetriever",
"->",
"setUriRetriever",
"(",
"new",
"LocalUriRetriever",
"(",
")",
")",
";",
"$",
"this",
"->",
"jsonValidator",
"=",
"new",
"JsonValidator",
"(",
"null",
",",
"$",
"uriRetriever",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jsonValidator",
";",
"}"
] |
Returns the JSON validator.
@return JsonValidator The JSON validator.
|
[
"Returns",
"the",
"JSON",
"validator",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L996-L1008
|
223,825
|
puli/manager
|
src/Api/Container.php
|
Container.createProjectContext
|
private function createProjectContext($rootDir, $env)
{
Assert::fileExists($rootDir, 'Could not load Puli context: The root %s does not exist.');
Assert::directory($rootDir, 'Could not load Puli context: The root %s is a file. Expected a directory.');
$baseConfig = new DefaultConfig();
$homeDir = self::parseHomeDirectory();
if (null !== $configFile = $this->loadConfigFile($homeDir, $baseConfig)) {
$baseConfig = $configFile->getConfig();
}
// Create a storage without the factory manager
$jsonStorage = new JsonStorage(
$this->getStorage(),
new JsonConverterProvider($this),
$this->getJsonEncoder(),
$this->getJsonDecoder()
);
$rootDir = Path::canonicalize($rootDir);
$rootFilePath = $this->rootDir.'/puli.json';
try {
$rootModuleFile = $jsonStorage->loadRootModuleFile($rootFilePath, $baseConfig);
} catch (FileNotFoundException $e) {
$rootModuleFile = new RootModuleFile(null, $rootFilePath, $baseConfig);
}
$config = new EnvConfig($rootModuleFile->getConfig());
return new ProjectContext($homeDir, $rootDir, $config, $rootModuleFile, $configFile, $this->dispatcher, $env);
}
|
php
|
private function createProjectContext($rootDir, $env)
{
Assert::fileExists($rootDir, 'Could not load Puli context: The root %s does not exist.');
Assert::directory($rootDir, 'Could not load Puli context: The root %s is a file. Expected a directory.');
$baseConfig = new DefaultConfig();
$homeDir = self::parseHomeDirectory();
if (null !== $configFile = $this->loadConfigFile($homeDir, $baseConfig)) {
$baseConfig = $configFile->getConfig();
}
// Create a storage without the factory manager
$jsonStorage = new JsonStorage(
$this->getStorage(),
new JsonConverterProvider($this),
$this->getJsonEncoder(),
$this->getJsonDecoder()
);
$rootDir = Path::canonicalize($rootDir);
$rootFilePath = $this->rootDir.'/puli.json';
try {
$rootModuleFile = $jsonStorage->loadRootModuleFile($rootFilePath, $baseConfig);
} catch (FileNotFoundException $e) {
$rootModuleFile = new RootModuleFile(null, $rootFilePath, $baseConfig);
}
$config = new EnvConfig($rootModuleFile->getConfig());
return new ProjectContext($homeDir, $rootDir, $config, $rootModuleFile, $configFile, $this->dispatcher, $env);
}
|
[
"private",
"function",
"createProjectContext",
"(",
"$",
"rootDir",
",",
"$",
"env",
")",
"{",
"Assert",
"::",
"fileExists",
"(",
"$",
"rootDir",
",",
"'Could not load Puli context: The root %s does not exist.'",
")",
";",
"Assert",
"::",
"directory",
"(",
"$",
"rootDir",
",",
"'Could not load Puli context: The root %s is a file. Expected a directory.'",
")",
";",
"$",
"baseConfig",
"=",
"new",
"DefaultConfig",
"(",
")",
";",
"$",
"homeDir",
"=",
"self",
"::",
"parseHomeDirectory",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"configFile",
"=",
"$",
"this",
"->",
"loadConfigFile",
"(",
"$",
"homeDir",
",",
"$",
"baseConfig",
")",
")",
"{",
"$",
"baseConfig",
"=",
"$",
"configFile",
"->",
"getConfig",
"(",
")",
";",
"}",
"// Create a storage without the factory manager",
"$",
"jsonStorage",
"=",
"new",
"JsonStorage",
"(",
"$",
"this",
"->",
"getStorage",
"(",
")",
",",
"new",
"JsonConverterProvider",
"(",
"$",
"this",
")",
",",
"$",
"this",
"->",
"getJsonEncoder",
"(",
")",
",",
"$",
"this",
"->",
"getJsonDecoder",
"(",
")",
")",
";",
"$",
"rootDir",
"=",
"Path",
"::",
"canonicalize",
"(",
"$",
"rootDir",
")",
";",
"$",
"rootFilePath",
"=",
"$",
"this",
"->",
"rootDir",
".",
"'/puli.json'",
";",
"try",
"{",
"$",
"rootModuleFile",
"=",
"$",
"jsonStorage",
"->",
"loadRootModuleFile",
"(",
"$",
"rootFilePath",
",",
"$",
"baseConfig",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"e",
")",
"{",
"$",
"rootModuleFile",
"=",
"new",
"RootModuleFile",
"(",
"null",
",",
"$",
"rootFilePath",
",",
"$",
"baseConfig",
")",
";",
"}",
"$",
"config",
"=",
"new",
"EnvConfig",
"(",
"$",
"rootModuleFile",
"->",
"getConfig",
"(",
")",
")",
";",
"return",
"new",
"ProjectContext",
"(",
"$",
"homeDir",
",",
"$",
"rootDir",
",",
"$",
"config",
",",
"$",
"rootModuleFile",
",",
"$",
"configFile",
",",
"$",
"this",
"->",
"dispatcher",
",",
"$",
"env",
")",
";",
"}"
] |
Creates the context of a Puli project.
The home directory is read from the context variable "PULI_HOME".
If this variable is not set, the home directory defaults to:
* `$HOME/.puli` on Linux, where `$HOME` is the context variable
"HOME".
* `$APPDATA/Puli` on Windows, where `$APPDATA` is the context
variable "APPDATA".
If none of these variables can be found, an exception is thrown.
A .htaccess file is put into the home directory to protect it from web
access.
@param string $rootDir The path to the project.
@return ProjectContext The project context.
|
[
"Creates",
"the",
"context",
"of",
"a",
"Puli",
"project",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L1055-L1087
|
223,826
|
puli/manager
|
src/Api/Container.php
|
Container.getJsonStorage
|
private function getJsonStorage()
{
if (!$this->jsonStorage) {
$this->jsonStorage = new JsonStorage(
$this->getStorage(),
new JsonConverterProvider($this),
$this->getJsonEncoder(),
$this->getJsonDecoder(),
$this->getFactoryManager()
);
}
return $this->jsonStorage;
}
|
php
|
private function getJsonStorage()
{
if (!$this->jsonStorage) {
$this->jsonStorage = new JsonStorage(
$this->getStorage(),
new JsonConverterProvider($this),
$this->getJsonEncoder(),
$this->getJsonDecoder(),
$this->getFactoryManager()
);
}
return $this->jsonStorage;
}
|
[
"private",
"function",
"getJsonStorage",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jsonStorage",
")",
"{",
"$",
"this",
"->",
"jsonStorage",
"=",
"new",
"JsonStorage",
"(",
"$",
"this",
"->",
"getStorage",
"(",
")",
",",
"new",
"JsonConverterProvider",
"(",
"$",
"this",
")",
",",
"$",
"this",
"->",
"getJsonEncoder",
"(",
")",
",",
"$",
"this",
"->",
"getJsonDecoder",
"(",
")",
",",
"$",
"this",
"->",
"getFactoryManager",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jsonStorage",
";",
"}"
] |
Returns the JSON file storage.
@return JsonStorage The JSON file storage.
|
[
"Returns",
"the",
"JSON",
"file",
"storage",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L1107-L1120
|
223,827
|
puli/manager
|
src/Api/Container.php
|
Container.getJsonVersioner
|
private function getJsonVersioner()
{
if (!$this->jsonVersioner) {
$this->jsonVersioner = new ChainVersioner(array(
// check the schema of the "$schema" field by default
new SchemaUriVersioner(),
// fall back to the "version" field for 1.0
new VersionFieldVersioner(),
));
}
return $this->jsonVersioner;
}
|
php
|
private function getJsonVersioner()
{
if (!$this->jsonVersioner) {
$this->jsonVersioner = new ChainVersioner(array(
// check the schema of the "$schema" field by default
new SchemaUriVersioner(),
// fall back to the "version" field for 1.0
new VersionFieldVersioner(),
));
}
return $this->jsonVersioner;
}
|
[
"private",
"function",
"getJsonVersioner",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"jsonVersioner",
")",
"{",
"$",
"this",
"->",
"jsonVersioner",
"=",
"new",
"ChainVersioner",
"(",
"array",
"(",
"// check the schema of the \"$schema\" field by default",
"new",
"SchemaUriVersioner",
"(",
")",
",",
"// fall back to the \"version\" field for 1.0",
"new",
"VersionFieldVersioner",
"(",
")",
",",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"jsonVersioner",
";",
"}"
] |
Returns the JSON versioner.
@return JsonVersioner The JSON versioner.
|
[
"Returns",
"the",
"JSON",
"versioner",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L1127-L1139
|
223,828
|
puli/manager
|
src/Api/Container.php
|
Container.getModuleFileMigrationManager
|
private function getModuleFileMigrationManager()
{
if (!$this->moduleFileMigrationManager) {
$this->moduleFileMigrationManager = new MigrationManager(array(
new ModuleFile10To20Migration(),
), $this->getJsonVersioner());
}
return $this->moduleFileMigrationManager;
}
|
php
|
private function getModuleFileMigrationManager()
{
if (!$this->moduleFileMigrationManager) {
$this->moduleFileMigrationManager = new MigrationManager(array(
new ModuleFile10To20Migration(),
), $this->getJsonVersioner());
}
return $this->moduleFileMigrationManager;
}
|
[
"private",
"function",
"getModuleFileMigrationManager",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"moduleFileMigrationManager",
")",
"{",
"$",
"this",
"->",
"moduleFileMigrationManager",
"=",
"new",
"MigrationManager",
"(",
"array",
"(",
"new",
"ModuleFile10To20Migration",
"(",
")",
",",
")",
",",
"$",
"this",
"->",
"getJsonVersioner",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"moduleFileMigrationManager",
";",
"}"
] |
Returns the migration manager for module files.
@return MigrationManager The migration manager.
|
[
"Returns",
"the",
"migration",
"manager",
"for",
"module",
"files",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L1146-L1155
|
223,829
|
puli/manager
|
src/Api/Container.php
|
Container.validatePluginClass
|
private function validatePluginClass($pluginClass)
{
if (!class_exists($pluginClass)) {
throw new InvalidConfigException(sprintf(
'The plugin class %s does not exist.',
$pluginClass
));
}
if (!in_array('Puli\Manager\Api\PuliPlugin', class_implements($pluginClass))) {
throw new InvalidConfigException(sprintf(
'The plugin class %s must implement PuliPlugin.',
$pluginClass
));
}
}
|
php
|
private function validatePluginClass($pluginClass)
{
if (!class_exists($pluginClass)) {
throw new InvalidConfigException(sprintf(
'The plugin class %s does not exist.',
$pluginClass
));
}
if (!in_array('Puli\Manager\Api\PuliPlugin', class_implements($pluginClass))) {
throw new InvalidConfigException(sprintf(
'The plugin class %s must implement PuliPlugin.',
$pluginClass
));
}
}
|
[
"private",
"function",
"validatePluginClass",
"(",
"$",
"pluginClass",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"pluginClass",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"sprintf",
"(",
"'The plugin class %s does not exist.'",
",",
"$",
"pluginClass",
")",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"'Puli\\Manager\\Api\\PuliPlugin'",
",",
"class_implements",
"(",
"$",
"pluginClass",
")",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"sprintf",
"(",
"'The plugin class %s must implement PuliPlugin.'",
",",
"$",
"pluginClass",
")",
")",
";",
"}",
"}"
] |
Validates the given plugin class name.
@param string $pluginClass The fully qualified name of a plugin class.
|
[
"Validates",
"the",
"given",
"plugin",
"class",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Container.php#L1162-L1177
|
223,830
|
bitverseio/identicon
|
src/Bitverse/Identicon/Generator/PixelsGenerator.php
|
PixelsGenerator.getPixel
|
private function getPixel($x, $y, Color $color)
{
return (new Rectangle($x * 80 + 40, $y * 80 + 40, 80, 80))
->setFillColor($color)
->setStrokeWidth(0);
}
|
php
|
private function getPixel($x, $y, Color $color)
{
return (new Rectangle($x * 80 + 40, $y * 80 + 40, 80, 80))
->setFillColor($color)
->setStrokeWidth(0);
}
|
[
"private",
"function",
"getPixel",
"(",
"$",
"x",
",",
"$",
"y",
",",
"Color",
"$",
"color",
")",
"{",
"return",
"(",
"new",
"Rectangle",
"(",
"$",
"x",
"*",
"80",
"+",
"40",
",",
"$",
"y",
"*",
"80",
"+",
"40",
",",
"80",
",",
"80",
")",
")",
"->",
"setFillColor",
"(",
"$",
"color",
")",
"->",
"setStrokeWidth",
"(",
"0",
")",
";",
"}"
] |
Returns a pixel drawn accordingly to the passed parameters.
@param integer $x
@param integer $y
@param Color $color
@return SvgNode
|
[
"Returns",
"a",
"pixel",
"drawn",
"accordingly",
"to",
"the",
"passed",
"parameters",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Generator/PixelsGenerator.php#L56-L61
|
223,831
|
bitverseio/identicon
|
src/Bitverse/Identicon/Generator/PixelsGenerator.php
|
PixelsGenerator.showPixel
|
private function showPixel($x, $y, $hash)
{
return hexdec(substr($hash, 6 + abs(2-$x) * 5 + $y, 1)) % 2 === 0;
}
|
php
|
private function showPixel($x, $y, $hash)
{
return hexdec(substr($hash, 6 + abs(2-$x) * 5 + $y, 1)) % 2 === 0;
}
|
[
"private",
"function",
"showPixel",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"hash",
")",
"{",
"return",
"hexdec",
"(",
"substr",
"(",
"$",
"hash",
",",
"6",
"+",
"abs",
"(",
"2",
"-",
"$",
"x",
")",
"*",
"5",
"+",
"$",
"y",
",",
"1",
")",
")",
"%",
"2",
"===",
"0",
";",
"}"
] |
Determines whether a pixel from the 5x5 grid should be visible.
@param integer $x
@param integer $y
@param string $hash
@return boolean
|
[
"Determines",
"whether",
"a",
"pixel",
"from",
"the",
"5x5",
"grid",
"should",
"be",
"visible",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Generator/PixelsGenerator.php#L72-L75
|
223,832
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.forModules
|
public static function forModules(ModuleList $modules)
{
$graph = new static($modules->getModuleNames());
foreach ($modules as $module) {
if (null === $module->getModuleFile()) {
continue;
}
foreach ($module->getModuleFile()->getDependencies() as $dependency) {
if ($graph->hasModuleName($dependency)) {
$graph->addDependency($module->getName(), $dependency);
}
}
}
// Do we have a root module?
if (null === $modules->getRootModule()) {
return $graph;
}
// Make sure we have numeric, ascending keys here
$moduleOrder = array_values($modules->getRootModule()->getModuleFile()->getModuleOrder());
// Each module overrides the previous one in the list
for ($i = 1, $l = count($moduleOrder); $i < $l; ++$i) {
$dependency = $moduleOrder[$i - 1];
$moduleName = $moduleOrder[$i];
if ($graph->hasModuleName($dependency)) {
$graph->addDependency($moduleName, $dependency);
}
}
return $graph;
}
|
php
|
public static function forModules(ModuleList $modules)
{
$graph = new static($modules->getModuleNames());
foreach ($modules as $module) {
if (null === $module->getModuleFile()) {
continue;
}
foreach ($module->getModuleFile()->getDependencies() as $dependency) {
if ($graph->hasModuleName($dependency)) {
$graph->addDependency($module->getName(), $dependency);
}
}
}
// Do we have a root module?
if (null === $modules->getRootModule()) {
return $graph;
}
// Make sure we have numeric, ascending keys here
$moduleOrder = array_values($modules->getRootModule()->getModuleFile()->getModuleOrder());
// Each module overrides the previous one in the list
for ($i = 1, $l = count($moduleOrder); $i < $l; ++$i) {
$dependency = $moduleOrder[$i - 1];
$moduleName = $moduleOrder[$i];
if ($graph->hasModuleName($dependency)) {
$graph->addDependency($moduleName, $dependency);
}
}
return $graph;
}
|
[
"public",
"static",
"function",
"forModules",
"(",
"ModuleList",
"$",
"modules",
")",
"{",
"$",
"graph",
"=",
"new",
"static",
"(",
"$",
"modules",
"->",
"getModuleNames",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"module",
"->",
"getModuleFile",
"(",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"module",
"->",
"getModuleFile",
"(",
")",
"->",
"getDependencies",
"(",
")",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"$",
"graph",
"->",
"hasModuleName",
"(",
"$",
"dependency",
")",
")",
"{",
"$",
"graph",
"->",
"addDependency",
"(",
"$",
"module",
"->",
"getName",
"(",
")",
",",
"$",
"dependency",
")",
";",
"}",
"}",
"}",
"// Do we have a root module?",
"if",
"(",
"null",
"===",
"$",
"modules",
"->",
"getRootModule",
"(",
")",
")",
"{",
"return",
"$",
"graph",
";",
"}",
"// Make sure we have numeric, ascending keys here",
"$",
"moduleOrder",
"=",
"array_values",
"(",
"$",
"modules",
"->",
"getRootModule",
"(",
")",
"->",
"getModuleFile",
"(",
")",
"->",
"getModuleOrder",
"(",
")",
")",
";",
"// Each module overrides the previous one in the list",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"l",
"=",
"count",
"(",
"$",
"moduleOrder",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"$",
"dependency",
"=",
"$",
"moduleOrder",
"[",
"$",
"i",
"-",
"1",
"]",
";",
"$",
"moduleName",
"=",
"$",
"moduleOrder",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"graph",
"->",
"hasModuleName",
"(",
"$",
"dependency",
")",
")",
"{",
"$",
"graph",
"->",
"addDependency",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
")",
";",
"}",
"}",
"return",
"$",
"graph",
";",
"}"
] |
Creates an override graph for the given modules.
@param ModuleList $modules The modules to load.
@return static The created override graph.
|
[
"Creates",
"an",
"override",
"graph",
"for",
"the",
"given",
"modules",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L92-L127
|
223,833
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.addModuleName
|
public function addModuleName($moduleName)
{
if (isset($this->moduleNames[$moduleName])) {
throw new RuntimeException(sprintf(
'The module "%s" was added to the graph twice.',
$moduleName
));
}
$this->moduleNames[$moduleName] = true;
$this->dependencies[$moduleName] = array();
}
|
php
|
public function addModuleName($moduleName)
{
if (isset($this->moduleNames[$moduleName])) {
throw new RuntimeException(sprintf(
'The module "%s" was added to the graph twice.',
$moduleName
));
}
$this->moduleNames[$moduleName] = true;
$this->dependencies[$moduleName] = array();
}
|
[
"public",
"function",
"addModuleName",
"(",
"$",
"moduleName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"moduleNames",
"[",
"$",
"moduleName",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The module \"%s\" was added to the graph twice.'",
",",
"$",
"moduleName",
")",
")",
";",
"}",
"$",
"this",
"->",
"moduleNames",
"[",
"$",
"moduleName",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"=",
"array",
"(",
")",
";",
"}"
] |
Adds a module name to the graph.
@param string $moduleName The module name.
@throws RuntimeException If the module name already exists.
|
[
"Adds",
"a",
"module",
"name",
"to",
"the",
"graph",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L147-L158
|
223,834
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.getSortedModuleNames
|
public function getSortedModuleNames(array $namesToSort = array())
{
if (count($namesToSort) > 0) {
$namesToSort = array_flip($namesToSort);
foreach ($namesToSort as $module => $_) {
if (!isset($this->moduleNames[$module])) {
throw new RuntimeException(sprintf(
'The module "%s" does not exist in the graph.',
$module
));
}
}
} else {
$namesToSort = $this->moduleNames;
}
$sorted = array();
// Do a topologic sort
// Start with any module and process until no more are left
while (false !== reset($namesToSort)) {
$this->sortModulesDFS(key($namesToSort), $namesToSort, $sorted);
}
return $sorted;
}
|
php
|
public function getSortedModuleNames(array $namesToSort = array())
{
if (count($namesToSort) > 0) {
$namesToSort = array_flip($namesToSort);
foreach ($namesToSort as $module => $_) {
if (!isset($this->moduleNames[$module])) {
throw new RuntimeException(sprintf(
'The module "%s" does not exist in the graph.',
$module
));
}
}
} else {
$namesToSort = $this->moduleNames;
}
$sorted = array();
// Do a topologic sort
// Start with any module and process until no more are left
while (false !== reset($namesToSort)) {
$this->sortModulesDFS(key($namesToSort), $namesToSort, $sorted);
}
return $sorted;
}
|
[
"public",
"function",
"getSortedModuleNames",
"(",
"array",
"$",
"namesToSort",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"namesToSort",
")",
">",
"0",
")",
"{",
"$",
"namesToSort",
"=",
"array_flip",
"(",
"$",
"namesToSort",
")",
";",
"foreach",
"(",
"$",
"namesToSort",
"as",
"$",
"module",
"=>",
"$",
"_",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"moduleNames",
"[",
"$",
"module",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The module \"%s\" does not exist in the graph.'",
",",
"$",
"module",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"namesToSort",
"=",
"$",
"this",
"->",
"moduleNames",
";",
"}",
"$",
"sorted",
"=",
"array",
"(",
")",
";",
"// Do a topologic sort",
"// Start with any module and process until no more are left",
"while",
"(",
"false",
"!==",
"reset",
"(",
"$",
"namesToSort",
")",
")",
"{",
"$",
"this",
"->",
"sortModulesDFS",
"(",
"key",
"(",
"$",
"namesToSort",
")",
",",
"$",
"namesToSort",
",",
"$",
"sorted",
")",
";",
"}",
"return",
"$",
"sorted",
";",
"}"
] |
Returns the sorted module names.
The names are sorted such that if a module m1 depends on a module m2,
then m2 comes before m1 in the sorted set.
If module names are passed, only those module names are sorted. Otherwise
all module names are sorted.
@param string[] $namesToSort The module names which should be sorted.
@return string[] The sorted module names.
@throws RuntimeException If any of the passed module names does not
exist in the graph.
|
[
"Returns",
"the",
"sorted",
"module",
"names",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L212-L238
|
223,835
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.addDependency
|
public function addDependency($moduleName, $dependency)
{
if (!isset($this->moduleNames[$dependency])) {
throw new RuntimeException(sprintf(
'The module "%s" does not exist in the graph.',
$dependency
));
}
if (!isset($this->moduleNames[$moduleName])) {
throw new RuntimeException(sprintf(
'The module "%s" does not exist in the graph.',
$moduleName
));
}
if (null !== ($path = $this->getPath($dependency, $moduleName))) {
$last = array_pop($path);
throw new CyclicDependencyException(sprintf(
'A cyclic dependency was discovered between the modules "%s" '.
'and "%s". Please check the "override" keys defined in these '.
'modules.',
implode('", "', $path),
$last
));
}
$this->dependencies[$moduleName][$dependency] = true;
}
|
php
|
public function addDependency($moduleName, $dependency)
{
if (!isset($this->moduleNames[$dependency])) {
throw new RuntimeException(sprintf(
'The module "%s" does not exist in the graph.',
$dependency
));
}
if (!isset($this->moduleNames[$moduleName])) {
throw new RuntimeException(sprintf(
'The module "%s" does not exist in the graph.',
$moduleName
));
}
if (null !== ($path = $this->getPath($dependency, $moduleName))) {
$last = array_pop($path);
throw new CyclicDependencyException(sprintf(
'A cyclic dependency was discovered between the modules "%s" '.
'and "%s". Please check the "override" keys defined in these '.
'modules.',
implode('", "', $path),
$last
));
}
$this->dependencies[$moduleName][$dependency] = true;
}
|
[
"public",
"function",
"addDependency",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"moduleNames",
"[",
"$",
"dependency",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The module \"%s\" does not exist in the graph.'",
",",
"$",
"dependency",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"moduleNames",
"[",
"$",
"moduleName",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The module \"%s\" does not exist in the graph.'",
",",
"$",
"moduleName",
")",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"dependency",
",",
"$",
"moduleName",
")",
")",
")",
"{",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"path",
")",
";",
"throw",
"new",
"CyclicDependencyException",
"(",
"sprintf",
"(",
"'A cyclic dependency was discovered between the modules \"%s\" '",
".",
"'and \"%s\". Please check the \"override\" keys defined in these '",
".",
"'modules.'",
",",
"implode",
"(",
"'\", \"'",
",",
"$",
"path",
")",
",",
"$",
"last",
")",
")",
";",
"}",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"[",
"$",
"dependency",
"]",
"=",
"true",
";",
"}"
] |
Adds a dependency from one to another module.
@param string $moduleName The module name.
@param string $dependency The name of the dependency.
|
[
"Adds",
"a",
"dependency",
"from",
"one",
"to",
"another",
"module",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L246-L275
|
223,836
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.hasDependency
|
public function hasDependency($moduleName, $dependency, $recursive = true)
{
if ($recursive) {
return $this->hasPath($moduleName, $dependency);
}
return isset($this->dependencies[$moduleName][$dependency]);
}
|
php
|
public function hasDependency($moduleName, $dependency, $recursive = true)
{
if ($recursive) {
return $this->hasPath($moduleName, $dependency);
}
return isset($this->dependencies[$moduleName][$dependency]);
}
|
[
"public",
"function",
"hasDependency",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"recursive",
")",
"{",
"return",
"$",
"this",
"->",
"hasPath",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"[",
"$",
"dependency",
"]",
")",
";",
"}"
] |
Returns whether a module directly depends on another module.
@param string $moduleName The module name.
@param string $dependency The name of the dependency.
@param bool $recursive Whether to take recursive dependencies into
account.
@return bool Whether an edge exists from the origin to the target module.
|
[
"Returns",
"whether",
"a",
"module",
"directly",
"depends",
"on",
"another",
"module",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L298-L305
|
223,837
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.hasPath
|
public function hasPath($moduleName, $dependency)
{
// does not exist in the graph
if (!isset($this->dependencies[$moduleName])) {
return false;
}
// adjacent node
if (isset($this->dependencies[$moduleName][$dependency])) {
return true;
}
// DFS
foreach ($this->dependencies[$moduleName] as $predecessor => $_) {
if ($this->hasPath($predecessor, $dependency)) {
return true;
}
}
return false;
}
|
php
|
public function hasPath($moduleName, $dependency)
{
// does not exist in the graph
if (!isset($this->dependencies[$moduleName])) {
return false;
}
// adjacent node
if (isset($this->dependencies[$moduleName][$dependency])) {
return true;
}
// DFS
foreach ($this->dependencies[$moduleName] as $predecessor => $_) {
if ($this->hasPath($predecessor, $dependency)) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"hasPath",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
")",
"{",
"// does not exist in the graph",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// adjacent node",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"[",
"$",
"dependency",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"// DFS",
"foreach",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"as",
"$",
"predecessor",
"=>",
"$",
"_",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasPath",
"(",
"$",
"predecessor",
",",
"$",
"dependency",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns whether a path exists from a module to a dependency.
@param string $moduleName The module name.
@param string $dependency The name of the dependency.
@return bool Whether a path exists from the origin to the target module.
|
[
"Returns",
"whether",
"a",
"path",
"exists",
"from",
"a",
"module",
"to",
"a",
"dependency",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L315-L335
|
223,838
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.getPath
|
public function getPath($moduleName, $dependency)
{
if ($this->getPathDFS($moduleName, $dependency, $reversePath)) {
return array_reverse($reversePath);
}
return null;
}
|
php
|
public function getPath($moduleName, $dependency)
{
if ($this->getPathDFS($moduleName, $dependency, $reversePath)) {
return array_reverse($reversePath);
}
return null;
}
|
[
"public",
"function",
"getPath",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPathDFS",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
",",
"$",
"reversePath",
")",
")",
"{",
"return",
"array_reverse",
"(",
"$",
"reversePath",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the path from a module name to a dependency.
@param string $moduleName The module name.
@param string $dependency The name of the dependency.
@return null|string[] The sorted module names on the path or `null` if no
path was found.
|
[
"Returns",
"the",
"path",
"from",
"a",
"module",
"name",
"to",
"a",
"dependency",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L346-L353
|
223,839
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.getPathDFS
|
private function getPathDFS($moduleName, $dependency, &$reversePath = array())
{
// does not exist in the graph
if (!isset($this->dependencies[$moduleName])) {
return false;
}
$reversePath[] = $moduleName;
// adjacent node
if (isset($this->dependencies[$moduleName][$dependency])) {
$reversePath[] = $dependency;
return true;
}
// DFS
foreach ($this->dependencies[$moduleName] as $predecessor => $_) {
if ($this->getPathDFS($predecessor, $dependency, $reversePath)) {
return true;
}
}
return false;
}
|
php
|
private function getPathDFS($moduleName, $dependency, &$reversePath = array())
{
// does not exist in the graph
if (!isset($this->dependencies[$moduleName])) {
return false;
}
$reversePath[] = $moduleName;
// adjacent node
if (isset($this->dependencies[$moduleName][$dependency])) {
$reversePath[] = $dependency;
return true;
}
// DFS
foreach ($this->dependencies[$moduleName] as $predecessor => $_) {
if ($this->getPathDFS($predecessor, $dependency, $reversePath)) {
return true;
}
}
return false;
}
|
[
"private",
"function",
"getPathDFS",
"(",
"$",
"moduleName",
",",
"$",
"dependency",
",",
"&",
"$",
"reversePath",
"=",
"array",
"(",
")",
")",
"{",
"// does not exist in the graph",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"reversePath",
"[",
"]",
"=",
"$",
"moduleName",
";",
"// adjacent node",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"[",
"$",
"dependency",
"]",
")",
")",
"{",
"$",
"reversePath",
"[",
"]",
"=",
"$",
"dependency",
";",
"return",
"true",
";",
"}",
"// DFS",
"foreach",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"as",
"$",
"predecessor",
"=>",
"$",
"_",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPathDFS",
"(",
"$",
"predecessor",
",",
"$",
"dependency",
",",
"$",
"reversePath",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Finds a path between modules using Depth-First Search.
@param string $moduleName The end module name.
@param string $dependency The start module name.
@param array $reversePath The path in reverse order.
@return bool Whether a path was found.
|
[
"Finds",
"a",
"path",
"between",
"modules",
"using",
"Depth",
"-",
"First",
"Search",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L364-L388
|
223,840
|
puli/manager
|
src/Conflict/DependencyGraph.php
|
DependencyGraph.sortModulesDFS
|
private function sortModulesDFS($currentName, array &$namesToSort, array &$output)
{
unset($namesToSort[$currentName]);
// Before adding the module itself to the path, add all predecessors.
// Do so recursively, then we make sure that each module is visited
// in the path before any of its successors.
foreach ($this->dependencies[$currentName] as $predecessor => $_) {
// The module was already processed. Either the module is on the
// path already, then we're good. Otherwise, we have a cycle.
// However, addEdge() guarantees that the graph is cycle-free.
if (isset($namesToSort[$predecessor])) {
$this->sortModulesDFS($predecessor, $namesToSort, $output);
}
}
$output[] = $currentName;
}
|
php
|
private function sortModulesDFS($currentName, array &$namesToSort, array &$output)
{
unset($namesToSort[$currentName]);
// Before adding the module itself to the path, add all predecessors.
// Do so recursively, then we make sure that each module is visited
// in the path before any of its successors.
foreach ($this->dependencies[$currentName] as $predecessor => $_) {
// The module was already processed. Either the module is on the
// path already, then we're good. Otherwise, we have a cycle.
// However, addEdge() guarantees that the graph is cycle-free.
if (isset($namesToSort[$predecessor])) {
$this->sortModulesDFS($predecessor, $namesToSort, $output);
}
}
$output[] = $currentName;
}
|
[
"private",
"function",
"sortModulesDFS",
"(",
"$",
"currentName",
",",
"array",
"&",
"$",
"namesToSort",
",",
"array",
"&",
"$",
"output",
")",
"{",
"unset",
"(",
"$",
"namesToSort",
"[",
"$",
"currentName",
"]",
")",
";",
"// Before adding the module itself to the path, add all predecessors.",
"// Do so recursively, then we make sure that each module is visited",
"// in the path before any of its successors.",
"foreach",
"(",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"currentName",
"]",
"as",
"$",
"predecessor",
"=>",
"$",
"_",
")",
"{",
"// The module was already processed. Either the module is on the",
"// path already, then we're good. Otherwise, we have a cycle.",
"// However, addEdge() guarantees that the graph is cycle-free.",
"if",
"(",
"isset",
"(",
"$",
"namesToSort",
"[",
"$",
"predecessor",
"]",
")",
")",
"{",
"$",
"this",
"->",
"sortModulesDFS",
"(",
"$",
"predecessor",
",",
"$",
"namesToSort",
",",
"$",
"output",
")",
";",
"}",
"}",
"$",
"output",
"[",
"]",
"=",
"$",
"currentName",
";",
"}"
] |
Topologically sorts the given module name into the output array.
The resulting array is sorted such that all predecessors of the module
come before the module (and their predecessors before them, and so on).
@param string $currentName The current module name to sort.
@param array $namesToSort The module names yet to be sorted.
@param array $output The output array.
|
[
"Topologically",
"sorts",
"the",
"given",
"module",
"name",
"into",
"the",
"output",
"array",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/DependencyGraph.php#L400-L417
|
223,841
|
apoutchika/MediaBundle
|
Filesystem/Local.php
|
Local.getAdapter
|
public function getAdapter(array $configs)
{
if ($configs['force_absolute_url'] === true) {
$this->urlRelative = $this->urlAbsolute;
}
return new LocalAdapter($this->path);
}
|
php
|
public function getAdapter(array $configs)
{
if ($configs['force_absolute_url'] === true) {
$this->urlRelative = $this->urlAbsolute;
}
return new LocalAdapter($this->path);
}
|
[
"public",
"function",
"getAdapter",
"(",
"array",
"$",
"configs",
")",
"{",
"if",
"(",
"$",
"configs",
"[",
"'force_absolute_url'",
"]",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"urlRelative",
"=",
"$",
"this",
"->",
"urlAbsolute",
";",
"}",
"return",
"new",
"LocalAdapter",
"(",
"$",
"this",
"->",
"path",
")",
";",
"}"
] |
Get Adapter.
@param array $configs Parameters in filesystems name, injected in gaufrette adapter
return \Gaufrette\Adapter\Adapter
|
[
"Get",
"Adapter",
"."
] |
dd52efed4a4463041da73af2cb25bdbe00365fcc
|
https://github.com/apoutchika/MediaBundle/blob/dd52efed4a4463041da73af2cb25bdbe00365fcc/Filesystem/Local.php#L41-L48
|
223,842
|
madeyourday/contao-rocksolid-columns
|
src/Columns.php
|
Columns.onsubmitCallback
|
public function onsubmitCallback($dc)
{
$activeRecord = $dc->activeRecord;
if (!$activeRecord) {
return;
}
if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') {
// Find the next columns or column element
$nextElement = \Database::getInstance()
->prepare('
SELECT type
FROM tl_content
WHERE pid = ?
AND (ptable = ? OR ptable = ?)
AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\')
AND sorting > ?
ORDER BY sorting ASC
LIMIT 1
')
->execute(
$activeRecord->pid,
$activeRecord->ptable ?: 'tl_article',
$activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable,
$activeRecord->sorting
);
// Check if a stop element should be created
if (
!$nextElement->type
|| ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop')
|| ($activeRecord->type === 'rs_column_start' && (
$nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop'
))
) {
$set = array();
// Get all default values for the new entry
foreach ($GLOBALS['TL_DCA']['tl_content']['fields'] as $field => $config) {
if (array_key_exists('default', $config)) {
$set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default'];
if ($GLOBALS['TL_DCA']['tl_content']['fields'][$field]['eval']['encrypt']) {
$set[$field] = \Encryption::encrypt($set[$field]);
}
}
}
$set['pid'] = $activeRecord->pid;
$set['ptable'] = $activeRecord->ptable ?: 'tl_article';
$set['type'] = substr($activeRecord->type, 0, -5) . 'stop';
$set['sorting'] = $activeRecord->sorting + 1;
$set['invisible'] = $activeRecord->invisible;
$set['start'] = $activeRecord->start;
$set['stop'] = $activeRecord->stop;
$set['tstamp'] = time();
\Database::getInstance()
->prepare('INSERT INTO tl_content %s')
->set($set)
->execute();
}
}
}
|
php
|
public function onsubmitCallback($dc)
{
$activeRecord = $dc->activeRecord;
if (!$activeRecord) {
return;
}
if ($activeRecord->type === 'rs_columns_start' || $activeRecord->type === 'rs_column_start') {
// Find the next columns or column element
$nextElement = \Database::getInstance()
->prepare('
SELECT type
FROM tl_content
WHERE pid = ?
AND (ptable = ? OR ptable = ?)
AND type IN (\'rs_column_start\', \'rs_column_stop\', \'rs_columns_start\', \'rs_columns_stop\')
AND sorting > ?
ORDER BY sorting ASC
LIMIT 1
')
->execute(
$activeRecord->pid,
$activeRecord->ptable ?: 'tl_article',
$activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable,
$activeRecord->sorting
);
// Check if a stop element should be created
if (
!$nextElement->type
|| ($activeRecord->type === 'rs_columns_start' && $nextElement->type === 'rs_column_stop')
|| ($activeRecord->type === 'rs_column_start' && (
$nextElement->type === 'rs_column_start' || $nextElement->type === 'rs_columns_stop'
))
) {
$set = array();
// Get all default values for the new entry
foreach ($GLOBALS['TL_DCA']['tl_content']['fields'] as $field => $config) {
if (array_key_exists('default', $config)) {
$set[$field] = \is_array($config['default']) ? serialize($config['default']) : $config['default'];
if ($GLOBALS['TL_DCA']['tl_content']['fields'][$field]['eval']['encrypt']) {
$set[$field] = \Encryption::encrypt($set[$field]);
}
}
}
$set['pid'] = $activeRecord->pid;
$set['ptable'] = $activeRecord->ptable ?: 'tl_article';
$set['type'] = substr($activeRecord->type, 0, -5) . 'stop';
$set['sorting'] = $activeRecord->sorting + 1;
$set['invisible'] = $activeRecord->invisible;
$set['start'] = $activeRecord->start;
$set['stop'] = $activeRecord->stop;
$set['tstamp'] = time();
\Database::getInstance()
->prepare('INSERT INTO tl_content %s')
->set($set)
->execute();
}
}
}
|
[
"public",
"function",
"onsubmitCallback",
"(",
"$",
"dc",
")",
"{",
"$",
"activeRecord",
"=",
"$",
"dc",
"->",
"activeRecord",
";",
"if",
"(",
"!",
"$",
"activeRecord",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"activeRecord",
"->",
"type",
"===",
"'rs_columns_start'",
"||",
"$",
"activeRecord",
"->",
"type",
"===",
"'rs_column_start'",
")",
"{",
"// Find the next columns or column element",
"$",
"nextElement",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"'\n\t\t\t\t\tSELECT type\n\t\t\t\t\tFROM tl_content\n\t\t\t\t\tWHERE pid = ?\n\t\t\t\t\t\tAND (ptable = ? OR ptable = ?)\n\t\t\t\t\t\tAND type IN (\\'rs_column_start\\', \\'rs_column_stop\\', \\'rs_columns_start\\', \\'rs_columns_stop\\')\n\t\t\t\t\t\tAND sorting > ?\n\t\t\t\t\tORDER BY sorting ASC\n\t\t\t\t\tLIMIT 1\n\t\t\t\t'",
")",
"->",
"execute",
"(",
"$",
"activeRecord",
"->",
"pid",
",",
"$",
"activeRecord",
"->",
"ptable",
"?",
":",
"'tl_article'",
",",
"$",
"activeRecord",
"->",
"ptable",
"===",
"'tl_article'",
"?",
"''",
":",
"$",
"activeRecord",
"->",
"ptable",
",",
"$",
"activeRecord",
"->",
"sorting",
")",
";",
"// Check if a stop element should be created",
"if",
"(",
"!",
"$",
"nextElement",
"->",
"type",
"||",
"(",
"$",
"activeRecord",
"->",
"type",
"===",
"'rs_columns_start'",
"&&",
"$",
"nextElement",
"->",
"type",
"===",
"'rs_column_stop'",
")",
"||",
"(",
"$",
"activeRecord",
"->",
"type",
"===",
"'rs_column_start'",
"&&",
"(",
"$",
"nextElement",
"->",
"type",
"===",
"'rs_column_start'",
"||",
"$",
"nextElement",
"->",
"type",
"===",
"'rs_columns_stop'",
")",
")",
")",
"{",
"$",
"set",
"=",
"array",
"(",
")",
";",
"// Get all default values for the new entry",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"'tl_content'",
"]",
"[",
"'fields'",
"]",
"as",
"$",
"field",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'default'",
",",
"$",
"config",
")",
")",
"{",
"$",
"set",
"[",
"$",
"field",
"]",
"=",
"\\",
"is_array",
"(",
"$",
"config",
"[",
"'default'",
"]",
")",
"?",
"serialize",
"(",
"$",
"config",
"[",
"'default'",
"]",
")",
":",
"$",
"config",
"[",
"'default'",
"]",
";",
"if",
"(",
"$",
"GLOBALS",
"[",
"'TL_DCA'",
"]",
"[",
"'tl_content'",
"]",
"[",
"'fields'",
"]",
"[",
"$",
"field",
"]",
"[",
"'eval'",
"]",
"[",
"'encrypt'",
"]",
")",
"{",
"$",
"set",
"[",
"$",
"field",
"]",
"=",
"\\",
"Encryption",
"::",
"encrypt",
"(",
"$",
"set",
"[",
"$",
"field",
"]",
")",
";",
"}",
"}",
"}",
"$",
"set",
"[",
"'pid'",
"]",
"=",
"$",
"activeRecord",
"->",
"pid",
";",
"$",
"set",
"[",
"'ptable'",
"]",
"=",
"$",
"activeRecord",
"->",
"ptable",
"?",
":",
"'tl_article'",
";",
"$",
"set",
"[",
"'type'",
"]",
"=",
"substr",
"(",
"$",
"activeRecord",
"->",
"type",
",",
"0",
",",
"-",
"5",
")",
".",
"'stop'",
";",
"$",
"set",
"[",
"'sorting'",
"]",
"=",
"$",
"activeRecord",
"->",
"sorting",
"+",
"1",
";",
"$",
"set",
"[",
"'invisible'",
"]",
"=",
"$",
"activeRecord",
"->",
"invisible",
";",
"$",
"set",
"[",
"'start'",
"]",
"=",
"$",
"activeRecord",
"->",
"start",
";",
"$",
"set",
"[",
"'stop'",
"]",
"=",
"$",
"activeRecord",
"->",
"stop",
";",
"$",
"set",
"[",
"'tstamp'",
"]",
"=",
"time",
"(",
")",
";",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"'INSERT INTO tl_content %s'",
")",
"->",
"set",
"(",
"$",
"set",
")",
"->",
"execute",
"(",
")",
";",
"}",
"}",
"}"
] |
tl_content DCA onsubmit callback
Creates a stop element after a start element was created
@param DataContainer $dc Data container
@return void
|
[
"tl_content",
"DCA",
"onsubmit",
"callback"
] |
35ca1f9b17c19fd0b774ed3307a85b58fa4b2705
|
https://github.com/madeyourday/contao-rocksolid-columns/blob/35ca1f9b17c19fd0b774ed3307a85b58fa4b2705/src/Columns.php#L90-L154
|
223,843
|
puli/manager
|
src/Json/JsonStorage.php
|
JsonStorage.saveConfigFile
|
public function saveConfigFile(ConfigFile $configFile)
{
$this->saveFile($configFile, $configFile->getPath());
if ($this->factoryManager) {
$this->factoryManager->autoGenerateFactoryClass();
}
}
|
php
|
public function saveConfigFile(ConfigFile $configFile)
{
$this->saveFile($configFile, $configFile->getPath());
if ($this->factoryManager) {
$this->factoryManager->autoGenerateFactoryClass();
}
}
|
[
"public",
"function",
"saveConfigFile",
"(",
"ConfigFile",
"$",
"configFile",
")",
"{",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"configFile",
",",
"$",
"configFile",
"->",
"getPath",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"factoryManager",
")",
"{",
"$",
"this",
"->",
"factoryManager",
"->",
"autoGenerateFactoryClass",
"(",
")",
";",
"}",
"}"
] |
Saves a configuration file.
The configuration file is saved to the same path that it was read from.
@param ConfigFile $configFile The configuration file to save.
@throws WriteException If the file cannot be written.
@throws InvalidConfigException If the file contains invalid configuration.
|
[
"Saves",
"a",
"configuration",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Json/JsonStorage.php#L122-L129
|
223,844
|
puli/manager
|
src/Json/JsonStorage.php
|
JsonStorage.saveModuleFile
|
public function saveModuleFile(ModuleFile $moduleFile)
{
$this->saveFile($moduleFile, $moduleFile->getPath(), array(
'targetVersion' => $moduleFile->getVersion(),
));
}
|
php
|
public function saveModuleFile(ModuleFile $moduleFile)
{
$this->saveFile($moduleFile, $moduleFile->getPath(), array(
'targetVersion' => $moduleFile->getVersion(),
));
}
|
[
"public",
"function",
"saveModuleFile",
"(",
"ModuleFile",
"$",
"moduleFile",
")",
"{",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"moduleFile",
",",
"$",
"moduleFile",
"->",
"getPath",
"(",
")",
",",
"array",
"(",
"'targetVersion'",
"=>",
"$",
"moduleFile",
"->",
"getVersion",
"(",
")",
",",
")",
")",
";",
"}"
] |
Saves a module file.
The module file is saved to the same path that it was read from.
@param ModuleFile $moduleFile The module file to save.
@throws WriteException If the file cannot be written.
@throws InvalidConfigException If the file contains invalid configuration.
|
[
"Saves",
"a",
"module",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Json/JsonStorage.php#L157-L162
|
223,845
|
puli/manager
|
src/Json/JsonStorage.php
|
JsonStorage.saveRootModuleFile
|
public function saveRootModuleFile(RootModuleFile $moduleFile)
{
$this->saveFile($moduleFile, $moduleFile->getPath(), array(
'targetVersion' => $moduleFile->getVersion(),
));
if ($this->factoryManager) {
$this->factoryManager->autoGenerateFactoryClass();
}
}
|
php
|
public function saveRootModuleFile(RootModuleFile $moduleFile)
{
$this->saveFile($moduleFile, $moduleFile->getPath(), array(
'targetVersion' => $moduleFile->getVersion(),
));
if ($this->factoryManager) {
$this->factoryManager->autoGenerateFactoryClass();
}
}
|
[
"public",
"function",
"saveRootModuleFile",
"(",
"RootModuleFile",
"$",
"moduleFile",
")",
"{",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"moduleFile",
",",
"$",
"moduleFile",
"->",
"getPath",
"(",
")",
",",
"array",
"(",
"'targetVersion'",
"=>",
"$",
"moduleFile",
"->",
"getVersion",
"(",
")",
",",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"factoryManager",
")",
"{",
"$",
"this",
"->",
"factoryManager",
"->",
"autoGenerateFactoryClass",
"(",
")",
";",
"}",
"}"
] |
Saves a root module file.
The module file is saved to the same path that it was read from.
@param RootModuleFile $moduleFile The module file to save.
@throws WriteException If the file cannot be written.
@throws InvalidConfigException If the file contains invalid configuration.
|
[
"Saves",
"a",
"root",
"module",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Json/JsonStorage.php#L194-L203
|
223,846
|
puli/manager
|
src/Api/Repository/PathConflict.php
|
PathConflict.addMapping
|
public function addMapping(PathMapping $mapping)
{
if (!$mapping->isLoaded()) {
throw new NotLoadedException('The passed mapping must be loaded.');
}
$moduleName = $mapping->getContainingModule()->getName();
$previousMapping = isset($this->mappings[$moduleName]) ? $this->mappings[$moduleName] : null;
if ($previousMapping === $mapping) {
return;
}
if ($previousMapping) {
$previousMapping->removeConflict($this);
}
$this->mappings[$moduleName] = $mapping;
$mapping->addConflict($this);
}
|
php
|
public function addMapping(PathMapping $mapping)
{
if (!$mapping->isLoaded()) {
throw new NotLoadedException('The passed mapping must be loaded.');
}
$moduleName = $mapping->getContainingModule()->getName();
$previousMapping = isset($this->mappings[$moduleName]) ? $this->mappings[$moduleName] : null;
if ($previousMapping === $mapping) {
return;
}
if ($previousMapping) {
$previousMapping->removeConflict($this);
}
$this->mappings[$moduleName] = $mapping;
$mapping->addConflict($this);
}
|
[
"public",
"function",
"addMapping",
"(",
"PathMapping",
"$",
"mapping",
")",
"{",
"if",
"(",
"!",
"$",
"mapping",
"->",
"isLoaded",
"(",
")",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The passed mapping must be loaded.'",
")",
";",
"}",
"$",
"moduleName",
"=",
"$",
"mapping",
"->",
"getContainingModule",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"previousMapping",
"=",
"isset",
"(",
"$",
"this",
"->",
"mappings",
"[",
"$",
"moduleName",
"]",
")",
"?",
"$",
"this",
"->",
"mappings",
"[",
"$",
"moduleName",
"]",
":",
"null",
";",
"if",
"(",
"$",
"previousMapping",
"===",
"$",
"mapping",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"previousMapping",
")",
"{",
"$",
"previousMapping",
"->",
"removeConflict",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"mappings",
"[",
"$",
"moduleName",
"]",
"=",
"$",
"mapping",
";",
"$",
"mapping",
"->",
"addConflict",
"(",
"$",
"this",
")",
";",
"}"
] |
Adds a path mapping involved in the conflict.
@param PathMapping $mapping The path mapping to add.
@throws NotLoadedException If the passed mapping is not loaded.
|
[
"Adds",
"a",
"path",
"mapping",
"involved",
"in",
"the",
"conflict",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathConflict.php#L65-L84
|
223,847
|
puli/manager
|
src/Api/Repository/PathConflict.php
|
PathConflict.removeMapping
|
public function removeMapping(PathMapping $mapping)
{
if (!$mapping->isLoaded()) {
throw new NotLoadedException('The passed mapping must be loaded.');
}
$moduleName = $mapping->getContainingModule()->getName();
if (!isset($this->mappings[$moduleName]) || $mapping !== $this->mappings[$moduleName]) {
return;
}
unset($this->mappings[$moduleName]);
$mapping->removeConflict($this);
// Conflict was resolved
if (count($this->mappings) < 2) {
$resolvedMappings = $this->mappings;
$this->mappings = array();
foreach ($resolvedMappings as $resolvedMapping) {
$resolvedMapping->removeConflict($this);
}
}
}
|
php
|
public function removeMapping(PathMapping $mapping)
{
if (!$mapping->isLoaded()) {
throw new NotLoadedException('The passed mapping must be loaded.');
}
$moduleName = $mapping->getContainingModule()->getName();
if (!isset($this->mappings[$moduleName]) || $mapping !== $this->mappings[$moduleName]) {
return;
}
unset($this->mappings[$moduleName]);
$mapping->removeConflict($this);
// Conflict was resolved
if (count($this->mappings) < 2) {
$resolvedMappings = $this->mappings;
$this->mappings = array();
foreach ($resolvedMappings as $resolvedMapping) {
$resolvedMapping->removeConflict($this);
}
}
}
|
[
"public",
"function",
"removeMapping",
"(",
"PathMapping",
"$",
"mapping",
")",
"{",
"if",
"(",
"!",
"$",
"mapping",
"->",
"isLoaded",
"(",
")",
")",
"{",
"throw",
"new",
"NotLoadedException",
"(",
"'The passed mapping must be loaded.'",
")",
";",
"}",
"$",
"moduleName",
"=",
"$",
"mapping",
"->",
"getContainingModule",
"(",
")",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mappings",
"[",
"$",
"moduleName",
"]",
")",
"||",
"$",
"mapping",
"!==",
"$",
"this",
"->",
"mappings",
"[",
"$",
"moduleName",
"]",
")",
"{",
"return",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"mappings",
"[",
"$",
"moduleName",
"]",
")",
";",
"$",
"mapping",
"->",
"removeConflict",
"(",
"$",
"this",
")",
";",
"// Conflict was resolved",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"mappings",
")",
"<",
"2",
")",
"{",
"$",
"resolvedMappings",
"=",
"$",
"this",
"->",
"mappings",
";",
"$",
"this",
"->",
"mappings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"resolvedMappings",
"as",
"$",
"resolvedMapping",
")",
"{",
"$",
"resolvedMapping",
"->",
"removeConflict",
"(",
"$",
"this",
")",
";",
"}",
"}",
"}"
] |
Removes a path mapping from the conflict.
If only one path mapping is left after removing this mapping, that
mapping is removed as well. The conflict is then resolved.
@param PathMapping $mapping The path mapping to remove.
@throws NotLoadedException If the passed mapping is not loaded.
|
[
"Removes",
"a",
"path",
"mapping",
"from",
"the",
"conflict",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathConflict.php#L110-L134
|
223,848
|
puli/manager
|
src/Api/Repository/PathConflict.php
|
PathConflict.resolve
|
public function resolve()
{
foreach ($this->mappings as $mapping) {
$mapping->removeConflict($this);
}
$this->mappings = array();
}
|
php
|
public function resolve()
{
foreach ($this->mappings as $mapping) {
$mapping->removeConflict($this);
}
$this->mappings = array();
}
|
[
"public",
"function",
"resolve",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"mappings",
"as",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"->",
"removeConflict",
"(",
"$",
"this",
")",
";",
"}",
"$",
"this",
"->",
"mappings",
"=",
"array",
"(",
")",
";",
"}"
] |
Resolves the conflict.
This method removes all mappings from the conflict. After calling this
method, {@link isResolved()} returns `true`.
|
[
"Resolves",
"the",
"conflict",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Repository/PathConflict.php#L152-L159
|
223,849
|
ongr-io/FilterManagerBundle
|
Filter/Widget/Search/MatchSearch.php
|
MatchSearch.buildMatchPart
|
private function buildMatchPart($field, FilterState $state)
{
if (strpos($field, '>') !== false) {
list ($path, $field) = explode('>', $field);
}
if (strpos($field, '^') !== false) {
list ($field, $boost) = explode('^', $field);
}
$query = new MatchQuery($field, $state->getValue(), $this->getOptions());
!isset($boost) ? : $query->addParameter('boost', $boost);
if (isset($path)) {
$query = new NestedQuery($path, $query);
}
return $query;
}
|
php
|
private function buildMatchPart($field, FilterState $state)
{
if (strpos($field, '>') !== false) {
list ($path, $field) = explode('>', $field);
}
if (strpos($field, '^') !== false) {
list ($field, $boost) = explode('^', $field);
}
$query = new MatchQuery($field, $state->getValue(), $this->getOptions());
!isset($boost) ? : $query->addParameter('boost', $boost);
if (isset($path)) {
$query = new NestedQuery($path, $query);
}
return $query;
}
|
[
"private",
"function",
"buildMatchPart",
"(",
"$",
"field",
",",
"FilterState",
"$",
"state",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"field",
",",
"'>'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"path",
",",
"$",
"field",
")",
"=",
"explode",
"(",
"'>'",
",",
"$",
"field",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"field",
",",
"'^'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"field",
",",
"$",
"boost",
")",
"=",
"explode",
"(",
"'^'",
",",
"$",
"field",
")",
";",
"}",
"$",
"query",
"=",
"new",
"MatchQuery",
"(",
"$",
"field",
",",
"$",
"state",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"getOptions",
"(",
")",
")",
";",
"!",
"isset",
"(",
"$",
"boost",
")",
"?",
":",
"$",
"query",
"->",
"addParameter",
"(",
"'boost'",
",",
"$",
"boost",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"path",
")",
")",
"{",
"$",
"query",
"=",
"new",
"NestedQuery",
"(",
"$",
"path",
",",
"$",
"query",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Build possibly nested match part.
@param string $field
@param FilterState $state
@return BuilderInterface
|
[
"Build",
"possibly",
"nested",
"match",
"part",
"."
] |
26c1125457f0440019b9bf20090bf23ba4bb1905
|
https://github.com/ongr-io/FilterManagerBundle/blob/26c1125457f0440019b9bf20090bf23ba4bb1905/Filter/Widget/Search/MatchSearch.php#L51-L69
|
223,850
|
puli/manager
|
src/Api/Module/ModuleList.php
|
ModuleList.add
|
public function add(Module $module)
{
$this->modules[$module->getName()] = $module;
if ($module instanceof RootModule) {
$this->rootModule = $module;
}
}
|
php
|
public function add(Module $module)
{
$this->modules[$module->getName()] = $module;
if ($module instanceof RootModule) {
$this->rootModule = $module;
}
}
|
[
"public",
"function",
"add",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"modules",
"[",
"$",
"module",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"module",
";",
"if",
"(",
"$",
"module",
"instanceof",
"RootModule",
")",
"{",
"$",
"this",
"->",
"rootModule",
"=",
"$",
"module",
";",
"}",
"}"
] |
Adds a module to the collection.
@param Module $module The added module.
|
[
"Adds",
"a",
"module",
"to",
"the",
"collection",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleList.php#L48-L55
|
223,851
|
puli/manager
|
src/Api/Module/ModuleList.php
|
ModuleList.remove
|
public function remove($name)
{
if ($this->rootModule && $name === $this->rootModule->getName()) {
$this->rootModule = null;
}
unset($this->modules[$name]);
}
|
php
|
public function remove($name)
{
if ($this->rootModule && $name === $this->rootModule->getName()) {
$this->rootModule = null;
}
unset($this->modules[$name]);
}
|
[
"public",
"function",
"remove",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"rootModule",
"&&",
"$",
"name",
"===",
"$",
"this",
"->",
"rootModule",
"->",
"getName",
"(",
")",
")",
"{",
"$",
"this",
"->",
"rootModule",
"=",
"null",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"modules",
"[",
"$",
"name",
"]",
")",
";",
"}"
] |
Removes a module from the collection.
@param string $name The module name.
|
[
"Removes",
"a",
"module",
"from",
"the",
"collection",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleList.php#L85-L92
|
223,852
|
puli/manager
|
src/Api/Module/ModuleList.php
|
ModuleList.get
|
public function get($name)
{
if (!isset($this->modules[$name])) {
throw new NoSuchModuleException(sprintf(
'The module "%s" was not found.',
$name
));
}
return $this->modules[$name];
}
|
php
|
public function get($name)
{
if (!isset($this->modules[$name])) {
throw new NoSuchModuleException(sprintf(
'The module "%s" was not found.',
$name
));
}
return $this->modules[$name];
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"modules",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"NoSuchModuleException",
"(",
"sprintf",
"(",
"'The module \"%s\" was not found.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"modules",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns the module with the given name.
@param string $name The module name.
@return Module The module with the passed name.
@throws NoSuchModuleException If the module was not found.
|
[
"Returns",
"the",
"module",
"with",
"the",
"given",
"name",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleList.php#L115-L125
|
223,853
|
puli/manager
|
src/Api/Module/ModuleList.php
|
ModuleList.getInstalledModules
|
public function getInstalledModules()
{
$modules = $this->modules;
if ($this->rootModule) {
unset($modules[$this->rootModule->getName()]);
}
return $modules;
}
|
php
|
public function getInstalledModules()
{
$modules = $this->modules;
if ($this->rootModule) {
unset($modules[$this->rootModule->getName()]);
}
return $modules;
}
|
[
"public",
"function",
"getInstalledModules",
"(",
")",
"{",
"$",
"modules",
"=",
"$",
"this",
"->",
"modules",
";",
"if",
"(",
"$",
"this",
"->",
"rootModule",
")",
"{",
"unset",
"(",
"$",
"modules",
"[",
"$",
"this",
"->",
"rootModule",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"modules",
";",
"}"
] |
Returns all installed modules.
The installed modules are all modules that are not the root module.
@return Module[] The installed modules indexed by their names.
|
[
"Returns",
"all",
"installed",
"modules",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleList.php#L170-L179
|
223,854
|
puli/manager
|
src/Conflict/ModuleConflictDetector.php
|
ModuleConflictDetector.claim
|
public function claim($token, $moduleName)
{
if (!isset($this->tokens[$token])) {
$this->tokens[$token] = array();
}
$this->tokens[$token][$moduleName] = true;
}
|
php
|
public function claim($token, $moduleName)
{
if (!isset($this->tokens[$token])) {
$this->tokens[$token] = array();
}
$this->tokens[$token][$moduleName] = true;
}
|
[
"public",
"function",
"claim",
"(",
"$",
"token",
",",
"$",
"moduleName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"token",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tokens",
"[",
"$",
"token",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"tokens",
"[",
"$",
"token",
"]",
"[",
"$",
"moduleName",
"]",
"=",
"true",
";",
"}"
] |
Claims a token for a module.
@param int|string $token The claimed token. Can be any integer or
string.
@param string $moduleName The module name.
|
[
"Claims",
"a",
"token",
"for",
"a",
"module",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/ModuleConflictDetector.php#L98-L105
|
223,855
|
puli/manager
|
src/Conflict/ModuleConflictDetector.php
|
ModuleConflictDetector.detectConflicts
|
public function detectConflicts(array $tokens = null)
{
$tokens = null === $tokens ? array_keys($this->tokens) : $tokens;
$conflicts = array();
foreach ($tokens as $token) {
// Claim was released
if (!isset($this->tokens[$token])) {
continue;
}
$moduleNames = array_keys($this->tokens[$token]);
// Token claimed by only one module
if (1 === count($moduleNames)) {
continue;
}
$sortedNames = $this->dependencyGraph->getSortedModuleNames($moduleNames);
$conflictingNames = array();
// An edge must exist between each module pair in the sorted set,
// otherwise the dependencies are not sufficiently defined
for ($i = 1, $l = count($sortedNames); $i < $l; ++$i) {
// Exclude recursive dependencies
if (!$this->dependencyGraph->hasDependency($sortedNames[$i], $sortedNames[$i - 1], false)) {
$conflictingNames[$sortedNames[$i - 1]] = true;
$conflictingNames[$sortedNames[$i]] = true;
}
}
if (count($conflictingNames) > 0) {
$conflicts[] = new ModuleConflict($token, array_keys($conflictingNames));
}
}
return $conflicts;
}
|
php
|
public function detectConflicts(array $tokens = null)
{
$tokens = null === $tokens ? array_keys($this->tokens) : $tokens;
$conflicts = array();
foreach ($tokens as $token) {
// Claim was released
if (!isset($this->tokens[$token])) {
continue;
}
$moduleNames = array_keys($this->tokens[$token]);
// Token claimed by only one module
if (1 === count($moduleNames)) {
continue;
}
$sortedNames = $this->dependencyGraph->getSortedModuleNames($moduleNames);
$conflictingNames = array();
// An edge must exist between each module pair in the sorted set,
// otherwise the dependencies are not sufficiently defined
for ($i = 1, $l = count($sortedNames); $i < $l; ++$i) {
// Exclude recursive dependencies
if (!$this->dependencyGraph->hasDependency($sortedNames[$i], $sortedNames[$i - 1], false)) {
$conflictingNames[$sortedNames[$i - 1]] = true;
$conflictingNames[$sortedNames[$i]] = true;
}
}
if (count($conflictingNames) > 0) {
$conflicts[] = new ModuleConflict($token, array_keys($conflictingNames));
}
}
return $conflicts;
}
|
[
"public",
"function",
"detectConflicts",
"(",
"array",
"$",
"tokens",
"=",
"null",
")",
"{",
"$",
"tokens",
"=",
"null",
"===",
"$",
"tokens",
"?",
"array_keys",
"(",
"$",
"this",
"->",
"tokens",
")",
":",
"$",
"tokens",
";",
"$",
"conflicts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"token",
")",
"{",
"// Claim was released",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"token",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"moduleNames",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"tokens",
"[",
"$",
"token",
"]",
")",
";",
"// Token claimed by only one module",
"if",
"(",
"1",
"===",
"count",
"(",
"$",
"moduleNames",
")",
")",
"{",
"continue",
";",
"}",
"$",
"sortedNames",
"=",
"$",
"this",
"->",
"dependencyGraph",
"->",
"getSortedModuleNames",
"(",
"$",
"moduleNames",
")",
";",
"$",
"conflictingNames",
"=",
"array",
"(",
")",
";",
"// An edge must exist between each module pair in the sorted set,",
"// otherwise the dependencies are not sufficiently defined",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"l",
"=",
"count",
"(",
"$",
"sortedNames",
")",
";",
"$",
"i",
"<",
"$",
"l",
";",
"++",
"$",
"i",
")",
"{",
"// Exclude recursive dependencies",
"if",
"(",
"!",
"$",
"this",
"->",
"dependencyGraph",
"->",
"hasDependency",
"(",
"$",
"sortedNames",
"[",
"$",
"i",
"]",
",",
"$",
"sortedNames",
"[",
"$",
"i",
"-",
"1",
"]",
",",
"false",
")",
")",
"{",
"$",
"conflictingNames",
"[",
"$",
"sortedNames",
"[",
"$",
"i",
"-",
"1",
"]",
"]",
"=",
"true",
";",
"$",
"conflictingNames",
"[",
"$",
"sortedNames",
"[",
"$",
"i",
"]",
"]",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"conflictingNames",
")",
">",
"0",
")",
"{",
"$",
"conflicts",
"[",
"]",
"=",
"new",
"ModuleConflict",
"(",
"$",
"token",
",",
"array_keys",
"(",
"$",
"conflictingNames",
")",
")",
";",
"}",
"}",
"return",
"$",
"conflicts",
";",
"}"
] |
Checks the passed tokens for conflicts.
If no tokens are passed, all tokens are checked.
A conflict is returned for every token that is claimed by two modules
that are not connected by an edge in the override graph. In other words,
if two modules A and B claim the same token, an edge must exist from A
to B (A is overridden by B) or from B to A (B is overridden by A).
Otherwise a conflict is returned.
@param int[]|string[]|null $tokens The tokens to check. If `null`, all
claimed tokens are checked for
conflicts. You are advised to pass
tokens if possible to improve the
performance of the conflict detection.
@return ModuleConflict[] The detected conflicts.
|
[
"Checks",
"the",
"passed",
"tokens",
"for",
"conflicts",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Conflict/ModuleConflictDetector.php#L138-L175
|
223,856
|
OXID-eSales/oxid-eshop-ide-helper
|
src/Core/DirectoryScanner.php
|
DirectoryScanner.scanDirectory
|
private function scanDirectory($directoryPath)
{
if (is_dir($directoryPath)) {
$files = scandir($directoryPath);
foreach ($files as $fileName) {
$filePath = Path::join($directoryPath, $fileName);
if (is_dir($filePath) && !in_array($fileName, ['.', '..'])) {
$this->scanDirectory($filePath);
} elseif ($this->searchForFileName == strtolower($fileName)) {
$this->filePaths[] = $filePath;
}
}
}
}
|
php
|
private function scanDirectory($directoryPath)
{
if (is_dir($directoryPath)) {
$files = scandir($directoryPath);
foreach ($files as $fileName) {
$filePath = Path::join($directoryPath, $fileName);
if (is_dir($filePath) && !in_array($fileName, ['.', '..'])) {
$this->scanDirectory($filePath);
} elseif ($this->searchForFileName == strtolower($fileName)) {
$this->filePaths[] = $filePath;
}
}
}
}
|
[
"private",
"function",
"scanDirectory",
"(",
"$",
"directoryPath",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directoryPath",
")",
")",
"{",
"$",
"files",
"=",
"scandir",
"(",
"$",
"directoryPath",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"fileName",
")",
"{",
"$",
"filePath",
"=",
"Path",
"::",
"join",
"(",
"$",
"directoryPath",
",",
"$",
"fileName",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"filePath",
")",
"&&",
"!",
"in_array",
"(",
"$",
"fileName",
",",
"[",
"'.'",
",",
"'..'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"scanDirectory",
"(",
"$",
"filePath",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"searchForFileName",
"==",
"strtolower",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"this",
"->",
"filePaths",
"[",
"]",
"=",
"$",
"filePath",
";",
"}",
"}",
"}",
"}"
] |
Recursive search for matching files.
@param string $clearFolderPath Sub-folder path to check for search file name.
|
[
"Recursive",
"search",
"for",
"matching",
"files",
"."
] |
e29836a482e7e2386ebb1cefd01e31240e2b3847
|
https://github.com/OXID-eSales/oxid-eshop-ide-helper/blob/e29836a482e7e2386ebb1cefd01e31240e2b3847/src/Core/DirectoryScanner.php#L60-L73
|
223,857
|
puli/manager
|
src/Installer/ModuleFileInstallerManager.php
|
ModuleFileInstallerManager.installerToData
|
private function installerToData(InstallerDescriptor $installer)
{
$data = (object) array(
'class' => $installer->getClassName(),
);
if ($installer->getDescription()) {
$data->description = $installer->getDescription();
}
if ($installer->getParameters()) {
$data->parameters = $this->parametersToData($installer->getParameters());
}
return $data;
}
|
php
|
private function installerToData(InstallerDescriptor $installer)
{
$data = (object) array(
'class' => $installer->getClassName(),
);
if ($installer->getDescription()) {
$data->description = $installer->getDescription();
}
if ($installer->getParameters()) {
$data->parameters = $this->parametersToData($installer->getParameters());
}
return $data;
}
|
[
"private",
"function",
"installerToData",
"(",
"InstallerDescriptor",
"$",
"installer",
")",
"{",
"$",
"data",
"=",
"(",
"object",
")",
"array",
"(",
"'class'",
"=>",
"$",
"installer",
"->",
"getClassName",
"(",
")",
",",
")",
";",
"if",
"(",
"$",
"installer",
"->",
"getDescription",
"(",
")",
")",
"{",
"$",
"data",
"->",
"description",
"=",
"$",
"installer",
"->",
"getDescription",
"(",
")",
";",
"}",
"if",
"(",
"$",
"installer",
"->",
"getParameters",
"(",
")",
")",
"{",
"$",
"data",
"->",
"parameters",
"=",
"$",
"this",
"->",
"parametersToData",
"(",
"$",
"installer",
"->",
"getParameters",
"(",
")",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Extracting an object containing the data from an installer descriptor.
@param InstallerDescriptor $installer The installer descriptor.
@return stdClass
|
[
"Extracting",
"an",
"object",
"containing",
"the",
"data",
"from",
"an",
"installer",
"descriptor",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Installer/ModuleFileInstallerManager.php#L472-L487
|
223,858
|
madeyourday/contao-rocksolid-frontend-helper
|
src/BackendHooks.php
|
BackendHooks.removeRsfhrParam
|
private function removeRsfhrParam($ref)
{
$session = \System::getContainer()->get('session');
if (!$session->isStarted()) {
return;
}
$referrerSession = $session->get('referer');
if (!empty($referrerSession[$ref]['current'])) {
$referrerSession[$ref]['current'] = preg_replace('(([&?])rsfhr=1(&|$))', '$1', $referrerSession[$ref]['current']);
$session->set('referer', $referrerSession);
}
}
|
php
|
private function removeRsfhrParam($ref)
{
$session = \System::getContainer()->get('session');
if (!$session->isStarted()) {
return;
}
$referrerSession = $session->get('referer');
if (!empty($referrerSession[$ref]['current'])) {
$referrerSession[$ref]['current'] = preg_replace('(([&?])rsfhr=1(&|$))', '$1', $referrerSession[$ref]['current']);
$session->set('referer', $referrerSession);
}
}
|
[
"private",
"function",
"removeRsfhrParam",
"(",
"$",
"ref",
")",
"{",
"$",
"session",
"=",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'session'",
")",
";",
"if",
"(",
"!",
"$",
"session",
"->",
"isStarted",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"referrerSession",
"=",
"$",
"session",
"->",
"get",
"(",
"'referer'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"referrerSession",
"[",
"$",
"ref",
"]",
"[",
"'current'",
"]",
")",
")",
"{",
"$",
"referrerSession",
"[",
"$",
"ref",
"]",
"[",
"'current'",
"]",
"=",
"preg_replace",
"(",
"'(([&?])rsfhr=1(&|$))'",
",",
"'$1'",
",",
"$",
"referrerSession",
"[",
"$",
"ref",
"]",
"[",
"'current'",
"]",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'referer'",
",",
"$",
"referrerSession",
")",
";",
"}",
"}"
] |
Remove the `rsfhr=1` parameter from the session referer
@param string $ref
|
[
"Remove",
"the",
"rsfhr",
"=",
"1",
"parameter",
"from",
"the",
"session",
"referer"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/BackendHooks.php#L70-L82
|
223,859
|
madeyourday/contao-rocksolid-frontend-helper
|
src/BackendHooks.php
|
BackendHooks.handleTemplateSelection
|
private function handleTemplateSelection()
{
if (\Input::get('key') !== 'new_tpl') {
return;
}
if (\Input::get('original') && !\Input::post('original')) {
// Preselect the original template
\Input::setPost('original', \Input::get('original'));
}
if (\Input::get('target') && !\Input::post('target')) {
// Preselect the target template folder
\Input::setPost('target', \Input::get('target'));
}
}
|
php
|
private function handleTemplateSelection()
{
if (\Input::get('key') !== 'new_tpl') {
return;
}
if (\Input::get('original') && !\Input::post('original')) {
// Preselect the original template
\Input::setPost('original', \Input::get('original'));
}
if (\Input::get('target') && !\Input::post('target')) {
// Preselect the target template folder
\Input::setPost('target', \Input::get('target'));
}
}
|
[
"private",
"function",
"handleTemplateSelection",
"(",
")",
"{",
"if",
"(",
"\\",
"Input",
"::",
"get",
"(",
"'key'",
")",
"!==",
"'new_tpl'",
")",
"{",
"return",
";",
"}",
"if",
"(",
"\\",
"Input",
"::",
"get",
"(",
"'original'",
")",
"&&",
"!",
"\\",
"Input",
"::",
"post",
"(",
"'original'",
")",
")",
"{",
"// Preselect the original template",
"\\",
"Input",
"::",
"setPost",
"(",
"'original'",
",",
"\\",
"Input",
"::",
"get",
"(",
"'original'",
")",
")",
";",
"}",
"if",
"(",
"\\",
"Input",
"::",
"get",
"(",
"'target'",
")",
"&&",
"!",
"\\",
"Input",
"::",
"post",
"(",
"'target'",
")",
")",
"{",
"// Preselect the target template folder",
"\\",
"Input",
"::",
"setPost",
"(",
"'target'",
",",
"\\",
"Input",
"::",
"get",
"(",
"'target'",
")",
")",
";",
"}",
"}"
] |
Preselects the original template in the template editor
|
[
"Preselects",
"the",
"original",
"template",
"in",
"the",
"template",
"editor"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/BackendHooks.php#L87-L102
|
223,860
|
madeyourday/contao-rocksolid-frontend-helper
|
src/BackendHooks.php
|
BackendHooks.storeFrontendReferrer
|
private function storeFrontendReferrer()
{
$base = \Environment::get('path');
$base .= \System::getContainer()->get('router')->generate('contao_backend');
$referrer = parse_url(\Environment::get('httpReferer'));
$referrer = $referrer['path'] . ($referrer['query'] ? '?' . $referrer['query'] : '');
// Stop if the referrer is a backend URL
if (
substr($referrer, 0, strlen($base)) === $base
&& in_array(substr($referrer, strlen($base), 1), array(false, '/', '?'), true)
) {
return;
}
// Fix empty referrers
if (empty($referrer)) {
$referrer = '/';
}
// Make homepage possible as referrer
if ($referrer === \Environment::get('path') . '/') {
$referrer .= '?';
}
$referrer = \Environment::get('path') . '/bundles/rocksolidfrontendhelper/html/referrer.html?referrer=' . rawurlencode($referrer);
// set the frontend URL as referrer
$referrerSession = \System::getContainer()->get('session')->get('referer');
if (defined('TL_REFERER_ID') && !\Input::get('ref')) {
$referrer = substr($referrer, strlen(TL_PATH) + 1);
$tlRefererId = substr(md5(TL_START - 1), 0, 8);
$referrerSession[$tlRefererId]['current'] = $referrer;
\Input::setGet('ref', $tlRefererId);
$requestUri = \Environment::get('requestUri');
$requestUri .= (strpos($requestUri, '?') === false ? '?' : '&') . 'ref=' . $tlRefererId;
\Environment::set('requestUri', $requestUri);
\System::getContainer()->get('request_stack')->getCurrentRequest()->query->set('ref', $tlRefererId);
}
\System::getContainer()->get('session')->set('referer', $referrerSession);
}
|
php
|
private function storeFrontendReferrer()
{
$base = \Environment::get('path');
$base .= \System::getContainer()->get('router')->generate('contao_backend');
$referrer = parse_url(\Environment::get('httpReferer'));
$referrer = $referrer['path'] . ($referrer['query'] ? '?' . $referrer['query'] : '');
// Stop if the referrer is a backend URL
if (
substr($referrer, 0, strlen($base)) === $base
&& in_array(substr($referrer, strlen($base), 1), array(false, '/', '?'), true)
) {
return;
}
// Fix empty referrers
if (empty($referrer)) {
$referrer = '/';
}
// Make homepage possible as referrer
if ($referrer === \Environment::get('path') . '/') {
$referrer .= '?';
}
$referrer = \Environment::get('path') . '/bundles/rocksolidfrontendhelper/html/referrer.html?referrer=' . rawurlencode($referrer);
// set the frontend URL as referrer
$referrerSession = \System::getContainer()->get('session')->get('referer');
if (defined('TL_REFERER_ID') && !\Input::get('ref')) {
$referrer = substr($referrer, strlen(TL_PATH) + 1);
$tlRefererId = substr(md5(TL_START - 1), 0, 8);
$referrerSession[$tlRefererId]['current'] = $referrer;
\Input::setGet('ref', $tlRefererId);
$requestUri = \Environment::get('requestUri');
$requestUri .= (strpos($requestUri, '?') === false ? '?' : '&') . 'ref=' . $tlRefererId;
\Environment::set('requestUri', $requestUri);
\System::getContainer()->get('request_stack')->getCurrentRequest()->query->set('ref', $tlRefererId);
}
\System::getContainer()->get('session')->set('referer', $referrerSession);
}
|
[
"private",
"function",
"storeFrontendReferrer",
"(",
")",
"{",
"$",
"base",
"=",
"\\",
"Environment",
"::",
"get",
"(",
"'path'",
")",
";",
"$",
"base",
".=",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'contao_backend'",
")",
";",
"$",
"referrer",
"=",
"parse_url",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpReferer'",
")",
")",
";",
"$",
"referrer",
"=",
"$",
"referrer",
"[",
"'path'",
"]",
".",
"(",
"$",
"referrer",
"[",
"'query'",
"]",
"?",
"'?'",
".",
"$",
"referrer",
"[",
"'query'",
"]",
":",
"''",
")",
";",
"// Stop if the referrer is a backend URL",
"if",
"(",
"substr",
"(",
"$",
"referrer",
",",
"0",
",",
"strlen",
"(",
"$",
"base",
")",
")",
"===",
"$",
"base",
"&&",
"in_array",
"(",
"substr",
"(",
"$",
"referrer",
",",
"strlen",
"(",
"$",
"base",
")",
",",
"1",
")",
",",
"array",
"(",
"false",
",",
"'/'",
",",
"'?'",
")",
",",
"true",
")",
")",
"{",
"return",
";",
"}",
"// Fix empty referrers",
"if",
"(",
"empty",
"(",
"$",
"referrer",
")",
")",
"{",
"$",
"referrer",
"=",
"'/'",
";",
"}",
"// Make homepage possible as referrer",
"if",
"(",
"$",
"referrer",
"===",
"\\",
"Environment",
"::",
"get",
"(",
"'path'",
")",
".",
"'/'",
")",
"{",
"$",
"referrer",
".=",
"'?'",
";",
"}",
"$",
"referrer",
"=",
"\\",
"Environment",
"::",
"get",
"(",
"'path'",
")",
".",
"'/bundles/rocksolidfrontendhelper/html/referrer.html?referrer='",
".",
"rawurlencode",
"(",
"$",
"referrer",
")",
";",
"// set the frontend URL as referrer",
"$",
"referrerSession",
"=",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'session'",
")",
"->",
"get",
"(",
"'referer'",
")",
";",
"if",
"(",
"defined",
"(",
"'TL_REFERER_ID'",
")",
"&&",
"!",
"\\",
"Input",
"::",
"get",
"(",
"'ref'",
")",
")",
"{",
"$",
"referrer",
"=",
"substr",
"(",
"$",
"referrer",
",",
"strlen",
"(",
"TL_PATH",
")",
"+",
"1",
")",
";",
"$",
"tlRefererId",
"=",
"substr",
"(",
"md5",
"(",
"TL_START",
"-",
"1",
")",
",",
"0",
",",
"8",
")",
";",
"$",
"referrerSession",
"[",
"$",
"tlRefererId",
"]",
"[",
"'current'",
"]",
"=",
"$",
"referrer",
";",
"\\",
"Input",
"::",
"setGet",
"(",
"'ref'",
",",
"$",
"tlRefererId",
")",
";",
"$",
"requestUri",
"=",
"\\",
"Environment",
"::",
"get",
"(",
"'requestUri'",
")",
";",
"$",
"requestUri",
".=",
"(",
"strpos",
"(",
"$",
"requestUri",
",",
"'?'",
")",
"===",
"false",
"?",
"'?'",
":",
"'&'",
")",
".",
"'ref='",
".",
"$",
"tlRefererId",
";",
"\\",
"Environment",
"::",
"set",
"(",
"'requestUri'",
",",
"$",
"requestUri",
")",
";",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'request_stack'",
")",
"->",
"getCurrentRequest",
"(",
")",
"->",
"query",
"->",
"set",
"(",
"'ref'",
",",
"$",
"tlRefererId",
")",
";",
"}",
"\\",
"System",
"::",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'session'",
")",
"->",
"set",
"(",
"'referer'",
",",
"$",
"referrerSession",
")",
";",
"}"
] |
Saves the referrer in the session if it is a frontend URL
|
[
"Saves",
"the",
"referrer",
"in",
"the",
"session",
"if",
"it",
"is",
"a",
"frontend",
"URL"
] |
1a0bf45a3d3913f8436ccd284965e7c37a463f28
|
https://github.com/madeyourday/contao-rocksolid-frontend-helper/blob/1a0bf45a3d3913f8436ccd284965e7c37a463f28/src/BackendHooks.php#L107-L153
|
223,861
|
puli/manager
|
src/Api/Module/ModuleFile.php
|
ModuleFile.setVersion
|
public function setVersion($version)
{
Assert::string($version, 'The module file version must be a string. Got: %s');
Assert::regex($version, '~^\d\.\d$~', 'The module file version must have the format "<digit>.<digit>". Got: %s</digit>');
$this->version = $version;
}
|
php
|
public function setVersion($version)
{
Assert::string($version, 'The module file version must be a string. Got: %s');
Assert::regex($version, '~^\d\.\d$~', 'The module file version must have the format "<digit>.<digit>". Got: %s</digit>');
$this->version = $version;
}
|
[
"public",
"function",
"setVersion",
"(",
"$",
"version",
")",
"{",
"Assert",
"::",
"string",
"(",
"$",
"version",
",",
"'The module file version must be a string. Got: %s'",
")",
";",
"Assert",
"::",
"regex",
"(",
"$",
"version",
",",
"'~^\\d\\.\\d$~'",
",",
"'The module file version must have the format \"<digit>.<digit>\". Got: %s</digit>'",
")",
";",
"$",
"this",
"->",
"version",
"=",
"$",
"version",
";",
"}"
] |
Sets the version of the module file.
@param string $version The module file version.
|
[
"Sets",
"the",
"version",
"of",
"the",
"module",
"file",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleFile.php#L106-L112
|
223,862
|
puli/manager
|
src/Api/Module/ModuleFile.php
|
ModuleFile.setDependencies
|
public function setDependencies(array $moduleNames)
{
$this->dependencies = array();
foreach ($moduleNames as $moduleName) {
$this->dependencies[$moduleName] = true;
}
}
|
php
|
public function setDependencies(array $moduleNames)
{
$this->dependencies = array();
foreach ($moduleNames as $moduleName) {
$this->dependencies[$moduleName] = true;
}
}
|
[
"public",
"function",
"setDependencies",
"(",
"array",
"$",
"moduleNames",
")",
"{",
"$",
"this",
"->",
"dependencies",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"moduleNames",
"as",
"$",
"moduleName",
")",
"{",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"moduleName",
"]",
"=",
"true",
";",
"}",
"}"
] |
Sets the names of the modules this module depends on.
@param string[] $moduleNames The names of the modules.
|
[
"Sets",
"the",
"names",
"of",
"the",
"modules",
"this",
"module",
"depends",
"on",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleFile.php#L154-L161
|
223,863
|
puli/manager
|
src/Api/Module/ModuleFile.php
|
ModuleFile.getPathMapping
|
public function getPathMapping($repositoryPath)
{
if (!isset($this->pathMappings[$repositoryPath])) {
throw NoSuchPathMappingException::forRepositoryPath($repositoryPath);
}
return $this->pathMappings[$repositoryPath];
}
|
php
|
public function getPathMapping($repositoryPath)
{
if (!isset($this->pathMappings[$repositoryPath])) {
throw NoSuchPathMappingException::forRepositoryPath($repositoryPath);
}
return $this->pathMappings[$repositoryPath];
}
|
[
"public",
"function",
"getPathMapping",
"(",
"$",
"repositoryPath",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"pathMappings",
"[",
"$",
"repositoryPath",
"]",
")",
")",
"{",
"throw",
"NoSuchPathMappingException",
"::",
"forRepositoryPath",
"(",
"$",
"repositoryPath",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pathMappings",
"[",
"$",
"repositoryPath",
"]",
";",
"}"
] |
Returns the path mapping for a repository path.
@param string $repositoryPath The repository path.
@return PathMapping The corresponding path mapping.
@throws NoSuchPathMappingException If the repository path is not mapped.
|
[
"Returns",
"the",
"path",
"mapping",
"for",
"a",
"repository",
"path",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleFile.php#L243-L250
|
223,864
|
puli/manager
|
src/Api/Module/ModuleFile.php
|
ModuleFile.getBindingDescriptor
|
public function getBindingDescriptor(Uuid $uuid)
{
$uuidString = $uuid->toString();
if (!isset($this->bindingDescriptors[$uuidString])) {
throw NoSuchBindingException::forUuid($uuid);
}
return $this->bindingDescriptors[$uuidString];
}
|
php
|
public function getBindingDescriptor(Uuid $uuid)
{
$uuidString = $uuid->toString();
if (!isset($this->bindingDescriptors[$uuidString])) {
throw NoSuchBindingException::forUuid($uuid);
}
return $this->bindingDescriptors[$uuidString];
}
|
[
"public",
"function",
"getBindingDescriptor",
"(",
"Uuid",
"$",
"uuid",
")",
"{",
"$",
"uuidString",
"=",
"$",
"uuid",
"->",
"toString",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"bindingDescriptors",
"[",
"$",
"uuidString",
"]",
")",
")",
"{",
"throw",
"NoSuchBindingException",
"::",
"forUuid",
"(",
"$",
"uuid",
")",
";",
"}",
"return",
"$",
"this",
"->",
"bindingDescriptors",
"[",
"$",
"uuidString",
"]",
";",
"}"
] |
Returns the binding descriptor with the given UUID.
@param Uuid $uuid The UUID of the binding descriptor.
@return BindingDescriptor The binding descriptor.
@throws NoSuchBindingException If the UUID was not found.
|
[
"Returns",
"the",
"binding",
"descriptor",
"with",
"the",
"given",
"UUID",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleFile.php#L324-L333
|
223,865
|
puli/manager
|
src/Api/Module/ModuleFile.php
|
ModuleFile.getExtraKey
|
public function getExtraKey($key, $default = null)
{
return array_key_exists($key, $this->extra) ? $this->extra[$key] : $default;
}
|
php
|
public function getExtraKey($key, $default = null)
{
return array_key_exists($key, $this->extra) ? $this->extra[$key] : $default;
}
|
[
"public",
"function",
"getExtraKey",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"extra",
")",
"?",
"$",
"this",
"->",
"extra",
"[",
"$",
"key",
"]",
":",
"$",
"default",
";",
"}"
] |
Returns the value of an extra key.
@param string $key The name of the key.
@param mixed $default The value to return if the key was not set.
@return mixed The value stored for the key.
@see setExtraKey()
|
[
"Returns",
"the",
"value",
"of",
"an",
"extra",
"key",
"."
] |
b3e726e35c2e6da809fd13f73d590290fb3fca43
|
https://github.com/puli/manager/blob/b3e726e35c2e6da809fd13f73d590290fb3fca43/src/Api/Module/ModuleFile.php#L540-L543
|
223,866
|
bitverseio/identicon
|
src/Bitverse/Identicon/Generator/RingsGenerator.php
|
RingsGenerator.getBackground
|
private function getBackground()
{
return (new Circle($this->getX(), $this->getY(), $this->getRadius()))
->setFillColor($this->getBackgroundColor())
->setStrokeWidth(0);
}
|
php
|
private function getBackground()
{
return (new Circle($this->getX(), $this->getY(), $this->getRadius()))
->setFillColor($this->getBackgroundColor())
->setStrokeWidth(0);
}
|
[
"private",
"function",
"getBackground",
"(",
")",
"{",
"return",
"(",
"new",
"Circle",
"(",
"$",
"this",
"->",
"getX",
"(",
")",
",",
"$",
"this",
"->",
"getY",
"(",
")",
",",
"$",
"this",
"->",
"getRadius",
"(",
")",
")",
")",
"->",
"setFillColor",
"(",
"$",
"this",
"->",
"getBackgroundColor",
"(",
")",
")",
"->",
"setStrokeWidth",
"(",
"0",
")",
";",
"}"
] |
Returns the background for the image.
@return SvgNode
|
[
"Returns",
"the",
"background",
"for",
"the",
"image",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Generator/RingsGenerator.php#L57-L62
|
223,867
|
bitverseio/identicon
|
src/Bitverse/Identicon/Generator/RingsGenerator.php
|
RingsGenerator.getCenter
|
private function getCenter(Color $color)
{
return (new Circle($this->getX(), $this->getY(), $this->getCenterRadius()))
->setFillColor($color)
->setStrokeWidth(0);
}
|
php
|
private function getCenter(Color $color)
{
return (new Circle($this->getX(), $this->getY(), $this->getCenterRadius()))
->setFillColor($color)
->setStrokeWidth(0);
}
|
[
"private",
"function",
"getCenter",
"(",
"Color",
"$",
"color",
")",
"{",
"return",
"(",
"new",
"Circle",
"(",
"$",
"this",
"->",
"getX",
"(",
")",
",",
"$",
"this",
"->",
"getY",
"(",
")",
",",
"$",
"this",
"->",
"getCenterRadius",
"(",
")",
")",
")",
"->",
"setFillColor",
"(",
"$",
"color",
")",
"->",
"setStrokeWidth",
"(",
"0",
")",
";",
"}"
] |
Returns the center dot for the image.
@param Color $color Color for the dot.
@return SvgNode
|
[
"Returns",
"the",
"center",
"dot",
"for",
"the",
"image",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Generator/RingsGenerator.php#L71-L76
|
223,868
|
bitverseio/identicon
|
src/Bitverse/Identicon/Generator/RingsGenerator.php
|
RingsGenerator.getArc
|
private function getArc(Color $color, $x, $y, $radius, $angle, $width, $start = 0)
{
return (new Path(
$x + $radius * cos(deg2rad($start)),
$y + $radius * sin(deg2rad($start))
))
->setFillColor($color)
->setStrokeColor($color)
->setStrokeWidth(1)
->arcTo(
$x + $radius * cos(deg2rad($start + $angle)),
$y + $radius * sin(deg2rad($start + $angle)),
$radius,
$radius,
0,
$angle > 180,
1
)
->lineTo(
$x + ($radius + $width) * cos(deg2rad($start + $angle)),
$y + ($radius + $width) * sin(deg2rad($start + $angle))
)
->arcTo(
$x + ($radius + $width) * cos(deg2rad($start)),
$y + ($radius + $width) * sin(deg2rad($start)),
$radius + $width,
$radius + $width,
0,
$angle > 180,
0
)
->lineTo(
$x + $radius * cos(deg2rad($start)),
$y + $radius * sin(deg2rad($start))
);
}
|
php
|
private function getArc(Color $color, $x, $y, $radius, $angle, $width, $start = 0)
{
return (new Path(
$x + $radius * cos(deg2rad($start)),
$y + $radius * sin(deg2rad($start))
))
->setFillColor($color)
->setStrokeColor($color)
->setStrokeWidth(1)
->arcTo(
$x + $radius * cos(deg2rad($start + $angle)),
$y + $radius * sin(deg2rad($start + $angle)),
$radius,
$radius,
0,
$angle > 180,
1
)
->lineTo(
$x + ($radius + $width) * cos(deg2rad($start + $angle)),
$y + ($radius + $width) * sin(deg2rad($start + $angle))
)
->arcTo(
$x + ($radius + $width) * cos(deg2rad($start)),
$y + ($radius + $width) * sin(deg2rad($start)),
$radius + $width,
$radius + $width,
0,
$angle > 180,
0
)
->lineTo(
$x + $radius * cos(deg2rad($start)),
$y + $radius * sin(deg2rad($start))
);
}
|
[
"private",
"function",
"getArc",
"(",
"Color",
"$",
"color",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"radius",
",",
"$",
"angle",
",",
"$",
"width",
",",
"$",
"start",
"=",
"0",
")",
"{",
"return",
"(",
"new",
"Path",
"(",
"$",
"x",
"+",
"$",
"radius",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"start",
")",
")",
",",
"$",
"y",
"+",
"$",
"radius",
"*",
"sin",
"(",
"deg2rad",
"(",
"$",
"start",
")",
")",
")",
")",
"->",
"setFillColor",
"(",
"$",
"color",
")",
"->",
"setStrokeColor",
"(",
"$",
"color",
")",
"->",
"setStrokeWidth",
"(",
"1",
")",
"->",
"arcTo",
"(",
"$",
"x",
"+",
"$",
"radius",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"start",
"+",
"$",
"angle",
")",
")",
",",
"$",
"y",
"+",
"$",
"radius",
"*",
"sin",
"(",
"deg2rad",
"(",
"$",
"start",
"+",
"$",
"angle",
")",
")",
",",
"$",
"radius",
",",
"$",
"radius",
",",
"0",
",",
"$",
"angle",
">",
"180",
",",
"1",
")",
"->",
"lineTo",
"(",
"$",
"x",
"+",
"(",
"$",
"radius",
"+",
"$",
"width",
")",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"start",
"+",
"$",
"angle",
")",
")",
",",
"$",
"y",
"+",
"(",
"$",
"radius",
"+",
"$",
"width",
")",
"*",
"sin",
"(",
"deg2rad",
"(",
"$",
"start",
"+",
"$",
"angle",
")",
")",
")",
"->",
"arcTo",
"(",
"$",
"x",
"+",
"(",
"$",
"radius",
"+",
"$",
"width",
")",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"start",
")",
")",
",",
"$",
"y",
"+",
"(",
"$",
"radius",
"+",
"$",
"width",
")",
"*",
"sin",
"(",
"deg2rad",
"(",
"$",
"start",
")",
")",
",",
"$",
"radius",
"+",
"$",
"width",
",",
"$",
"radius",
"+",
"$",
"width",
",",
"0",
",",
"$",
"angle",
">",
"180",
",",
"0",
")",
"->",
"lineTo",
"(",
"$",
"x",
"+",
"$",
"radius",
"*",
"cos",
"(",
"deg2rad",
"(",
"$",
"start",
")",
")",
",",
"$",
"y",
"+",
"$",
"radius",
"*",
"sin",
"(",
"deg2rad",
"(",
"$",
"start",
")",
")",
")",
";",
"}"
] |
Returns an arc drawn according to the passed specification.
@param float $radius Radius of the arc.
@param float $angle Angle of the arc.
@param float $start Starting angle for the arc.
@return SvgNode
|
[
"Returns",
"an",
"arc",
"drawn",
"according",
"to",
"the",
"passed",
"specification",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Generator/RingsGenerator.php#L87-L122
|
223,869
|
bitverseio/identicon
|
src/Bitverse/Identicon/Generator/RingsGenerator.php
|
RingsGenerator.getRingAngle
|
private function getRingAngle($ring, $hash)
{
return 10 * pow(2, 3 - $ring) * array_reduce(
str_split($hash, pow(2, 3 - $ring)),
function ($total, $substr) {
return $total + (hexdec($substr) % 2);
},
0
);
}
|
php
|
private function getRingAngle($ring, $hash)
{
return 10 * pow(2, 3 - $ring) * array_reduce(
str_split($hash, pow(2, 3 - $ring)),
function ($total, $substr) {
return $total + (hexdec($substr) % 2);
},
0
);
}
|
[
"private",
"function",
"getRingAngle",
"(",
"$",
"ring",
",",
"$",
"hash",
")",
"{",
"return",
"10",
"*",
"pow",
"(",
"2",
",",
"3",
"-",
"$",
"ring",
")",
"*",
"array_reduce",
"(",
"str_split",
"(",
"$",
"hash",
",",
"pow",
"(",
"2",
",",
"3",
"-",
"$",
"ring",
")",
")",
",",
"function",
"(",
"$",
"total",
",",
"$",
"substr",
")",
"{",
"return",
"$",
"total",
"+",
"(",
"hexdec",
"(",
"$",
"substr",
")",
"%",
"2",
")",
";",
"}",
",",
"0",
")",
";",
"}"
] |
Returns the angle in degrees for the given ring, based on the hash.
@param integer $ring
@param string $hash
@return integer
|
[
"Returns",
"the",
"angle",
"in",
"degrees",
"for",
"the",
"given",
"ring",
"based",
"on",
"the",
"hash",
"."
] |
5a015546e7f29d537807e0877446e2cd704ca438
|
https://github.com/bitverseio/identicon/blob/5a015546e7f29d537807e0877446e2cd704ca438/src/Bitverse/Identicon/Generator/RingsGenerator.php#L184-L193
|
223,870
|
GGGGino/WordBundle
|
Factory.php
|
Factory.createPHPWordObject
|
public function createPHPWordObject($filename = null)
{
return (null === $filename) ? new PhpWord() : call_user_func(array($this->phpWordIO, 'load'), $filename);
}
|
php
|
public function createPHPWordObject($filename = null)
{
return (null === $filename) ? new PhpWord() : call_user_func(array($this->phpWordIO, 'load'), $filename);
}
|
[
"public",
"function",
"createPHPWordObject",
"(",
"$",
"filename",
"=",
"null",
")",
"{",
"return",
"(",
"null",
"===",
"$",
"filename",
")",
"?",
"new",
"PhpWord",
"(",
")",
":",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
"->",
"phpWordIO",
",",
"'load'",
")",
",",
"$",
"filename",
")",
";",
"}"
] |
Creates an empty PhpWord Object if the filename is empty, otherwise loads the file into the object.
@param string $filename
@return PhpWord
|
[
"Creates",
"an",
"empty",
"PhpWord",
"Object",
"if",
"the",
"filename",
"is",
"empty",
"otherwise",
"loads",
"the",
"file",
"into",
"the",
"object",
"."
] |
2a1ace7c89326d0e64d1a1cbfb0224eebeb2fe36
|
https://github.com/GGGGino/WordBundle/blob/2a1ace7c89326d0e64d1a1cbfb0224eebeb2fe36/Factory.php#L33-L36
|
223,871
|
GGGGino/WordBundle
|
Factory.php
|
Factory.getPhpWordObjFromTemplate
|
public function getPhpWordObjFromTemplate($templateobj)
{
$fileName = $templateobj->save();
$phpWordObject = IOFactory::load($fileName);
unlink($fileName);
return $phpWordObject;
}
|
php
|
public function getPhpWordObjFromTemplate($templateobj)
{
$fileName = $templateobj->save();
$phpWordObject = IOFactory::load($fileName);
unlink($fileName);
return $phpWordObject;
}
|
[
"public",
"function",
"getPhpWordObjFromTemplate",
"(",
"$",
"templateobj",
")",
"{",
"$",
"fileName",
"=",
"$",
"templateobj",
"->",
"save",
"(",
")",
";",
"$",
"phpWordObject",
"=",
"IOFactory",
"::",
"load",
"(",
"$",
"fileName",
")",
";",
"unlink",
"(",
"$",
"fileName",
")",
";",
"return",
"$",
"phpWordObject",
";",
"}"
] |
From the template load the
@param TemplateProcessor $templateobj
@return PhpWord
|
[
"From",
"the",
"template",
"load",
"the"
] |
2a1ace7c89326d0e64d1a1cbfb0224eebeb2fe36
|
https://github.com/GGGGino/WordBundle/blob/2a1ace7c89326d0e64d1a1cbfb0224eebeb2fe36/Factory.php#L57-L66
|
223,872
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Init.php
|
Init.reconfigure
|
public function reconfigure( array $settings = [] ): void
{
if($this->is_running) {
throw new Exceptions\KernelAlreadyRunningException("You cannot reconfigure a running kernel.");
}
$this["settings"] = $settings;
$this["config"] = $this->share(function($c) {
$config = new \Zend\Config\Config(include __DIR__ . DIRECTORY_SEPARATOR . "defaults.php");
$config->merge(new \Zend\Config\Config($c["settings"]));
return $config;
});
$this["space"] = $this->share(function($c) {
$space_class = $c["config"]->default_objects->space;
return new $space_class($c);
});
$this["alien"] = $this->share(function($c) {
$alien_class = $c["config"]->default_objects->alien;
return new $alien_class($c);
});
$this["gs"] = $this->share(function($c) {
return new Graphsystem($c);
});
$this->is_configured = true;
}
|
php
|
public function reconfigure( array $settings = [] ): void
{
if($this->is_running) {
throw new Exceptions\KernelAlreadyRunningException("You cannot reconfigure a running kernel.");
}
$this["settings"] = $settings;
$this["config"] = $this->share(function($c) {
$config = new \Zend\Config\Config(include __DIR__ . DIRECTORY_SEPARATOR . "defaults.php");
$config->merge(new \Zend\Config\Config($c["settings"]));
return $config;
});
$this["space"] = $this->share(function($c) {
$space_class = $c["config"]->default_objects->space;
return new $space_class($c);
});
$this["alien"] = $this->share(function($c) {
$alien_class = $c["config"]->default_objects->alien;
return new $alien_class($c);
});
$this["gs"] = $this->share(function($c) {
return new Graphsystem($c);
});
$this->is_configured = true;
}
|
[
"public",
"function",
"reconfigure",
"(",
"array",
"$",
"settings",
"=",
"[",
"]",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"is_running",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"KernelAlreadyRunningException",
"(",
"\"You cannot reconfigure a running kernel.\"",
")",
";",
"}",
"$",
"this",
"[",
"\"settings\"",
"]",
"=",
"$",
"settings",
";",
"$",
"this",
"[",
"\"config\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"{",
"$",
"config",
"=",
"new",
"\\",
"Zend",
"\\",
"Config",
"\\",
"Config",
"(",
"include",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"\"defaults.php\"",
")",
";",
"$",
"config",
"->",
"merge",
"(",
"new",
"\\",
"Zend",
"\\",
"Config",
"\\",
"Config",
"(",
"$",
"c",
"[",
"\"settings\"",
"]",
")",
")",
";",
"return",
"$",
"config",
";",
"}",
")",
";",
"$",
"this",
"[",
"\"space\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"{",
"$",
"space_class",
"=",
"$",
"c",
"[",
"\"config\"",
"]",
"->",
"default_objects",
"->",
"space",
";",
"return",
"new",
"$",
"space_class",
"(",
"$",
"c",
")",
";",
"}",
")",
";",
"$",
"this",
"[",
"\"alien\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"{",
"$",
"alien_class",
"=",
"$",
"c",
"[",
"\"config\"",
"]",
"->",
"default_objects",
"->",
"alien",
";",
"return",
"new",
"$",
"alien_class",
"(",
"$",
"c",
")",
";",
"}",
")",
";",
"$",
"this",
"[",
"\"gs\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"{",
"return",
"new",
"Graphsystem",
"(",
"$",
"c",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"is_configured",
"=",
"true",
";",
"}"
] |
Sets up the kernel settings.
Configuration variables can be passed to the kernel either
at construction (e.g. ```$kernel = new Kernel(...);```)
or afterwards, using this function ```$kernel->reconfigure(...);```
Please note, this function should be run before calling the
*boot* function, or otherwise it will not have an effect
and throw the {@link Pho\Kernel\Exceptions\KernelIsAlreadyRunningException} exception.
@param array $settings Service configurations.
@throws KernelIsAlreadyRunningException When run after the kernel has booted up.
|
[
"Sets",
"up",
"the",
"kernel",
"settings",
"."
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Init.php#L67-L90
|
223,873
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Init.php
|
Init.setupServices
|
protected function setupServices(): void
{
$service_factory = new Services\ServiceFactory($this);
foreach($this->config()->services->toArray() as $key => $service) {
$this[$key] = $this->share( function($c) use($key, $service, $service_factory) {
try {
return $service_factory->create($key, $service['type'], $service['uri']);
}
catch(AdapterNonExistentException $e) {
$this->logger()->warning("The service %s - %s does not exist.", $key, $service['type']);
}
});
}
}
|
php
|
protected function setupServices(): void
{
$service_factory = new Services\ServiceFactory($this);
foreach($this->config()->services->toArray() as $key => $service) {
$this[$key] = $this->share( function($c) use($key, $service, $service_factory) {
try {
return $service_factory->create($key, $service['type'], $service['uri']);
}
catch(AdapterNonExistentException $e) {
$this->logger()->warning("The service %s - %s does not exist.", $key, $service['type']);
}
});
}
}
|
[
"protected",
"function",
"setupServices",
"(",
")",
":",
"void",
"{",
"$",
"service_factory",
"=",
"new",
"Services",
"\\",
"ServiceFactory",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"services",
"->",
"toArray",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"service",
")",
"{",
"$",
"this",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"key",
",",
"$",
"service",
",",
"$",
"service_factory",
")",
"{",
"try",
"{",
"return",
"$",
"service_factory",
"->",
"create",
"(",
"$",
"key",
",",
"$",
"service",
"[",
"'type'",
"]",
",",
"$",
"service",
"[",
"'uri'",
"]",
")",
";",
"}",
"catch",
"(",
"AdapterNonExistentException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"warning",
"(",
"\"The service %s - %s does not exist.\"",
",",
"$",
"key",
",",
"$",
"service",
"[",
"'type'",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] |
Sets up kernel services.
Private method that readies kernel services according to user settings and system
defaults. The services don't initialize right away but start when requested.
|
[
"Sets",
"up",
"kernel",
"services",
"."
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Init.php#L99-L112
|
223,874
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Init.php
|
Init.registerListeners
|
protected function registerListeners(Graph\GraphInterface $graph): void
{
$this->logger()->info("Registering listeners.");
$nodes = array_values($graph->members());
$node_count = count($nodes);
$this->logger()->info(
"Total # of nodes for the graph \"%s\": %s", $graph->id(), (string) $node_count
);
$graph->init();
for($i=0; $i<$node_count; $i++) {
$node = $nodes[$i];
$this->logger()->info(
"Registering listeners for node %s, a %s", $node->id(), $node->label()
);
// recursiveness
if($node instanceof Graph\GraphInterface && $node->id() != $graph->id()) {
$this->registerListeners($node);
}
else {
$node->init();
}
// memory management.
// clean up after use.
unset($nodes[$i]); // $nodes[$i] = null;
// gc_collect_cycles(); // perhaps give the user option to choose Fast Boot vs Memory Controlled Boot (good for resource-constrainted distributed systems that may tolerate slow boot)
}
}
|
php
|
protected function registerListeners(Graph\GraphInterface $graph): void
{
$this->logger()->info("Registering listeners.");
$nodes = array_values($graph->members());
$node_count = count($nodes);
$this->logger()->info(
"Total # of nodes for the graph \"%s\": %s", $graph->id(), (string) $node_count
);
$graph->init();
for($i=0; $i<$node_count; $i++) {
$node = $nodes[$i];
$this->logger()->info(
"Registering listeners for node %s, a %s", $node->id(), $node->label()
);
// recursiveness
if($node instanceof Graph\GraphInterface && $node->id() != $graph->id()) {
$this->registerListeners($node);
}
else {
$node->init();
}
// memory management.
// clean up after use.
unset($nodes[$i]); // $nodes[$i] = null;
// gc_collect_cycles(); // perhaps give the user option to choose Fast Boot vs Memory Controlled Boot (good for resource-constrainted distributed systems that may tolerate slow boot)
}
}
|
[
"protected",
"function",
"registerListeners",
"(",
"Graph",
"\\",
"GraphInterface",
"$",
"graph",
")",
":",
"void",
"{",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"Registering listeners.\"",
")",
";",
"$",
"nodes",
"=",
"array_values",
"(",
"$",
"graph",
"->",
"members",
"(",
")",
")",
";",
"$",
"node_count",
"=",
"count",
"(",
"$",
"nodes",
")",
";",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"Total # of nodes for the graph \\\"%s\\\": %s\"",
",",
"$",
"graph",
"->",
"id",
"(",
")",
",",
"(",
"string",
")",
"$",
"node_count",
")",
";",
"$",
"graph",
"->",
"init",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"node_count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"node",
"=",
"$",
"nodes",
"[",
"$",
"i",
"]",
";",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"Registering listeners for node %s, a %s\"",
",",
"$",
"node",
"->",
"id",
"(",
")",
",",
"$",
"node",
"->",
"label",
"(",
")",
")",
";",
"// recursiveness",
"if",
"(",
"$",
"node",
"instanceof",
"Graph",
"\\",
"GraphInterface",
"&&",
"$",
"node",
"->",
"id",
"(",
")",
"!=",
"$",
"graph",
"->",
"id",
"(",
")",
")",
"{",
"$",
"this",
"->",
"registerListeners",
"(",
"$",
"node",
")",
";",
"}",
"else",
"{",
"$",
"node",
"->",
"init",
"(",
")",
";",
"}",
"// memory management.",
"// clean up after use.",
"unset",
"(",
"$",
"nodes",
"[",
"$",
"i",
"]",
")",
";",
"// $nodes[$i] = null;",
"// gc_collect_cycles(); // perhaps give the user option to choose Fast Boot vs Memory Controlled Boot (good for resource-constrainted distributed systems that may tolerate slow boot)",
"}",
"}"
] |
Registers listeners that are default to the kernel.
@param AbstractContext $graph The graph object to start traversal from.
|
[
"Registers",
"listeners",
"that",
"are",
"default",
"to",
"the",
"kernel",
"."
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Init.php#L120-L152
|
223,875
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Init.php
|
Init.seedRoot
|
protected function seedRoot(? Foundation\AbstractActor $founder = null): void
{
$graph_id = $this->database()->get("configs:graph_id");
if(isset($graph_id)) {
$this->logger()->info(
"Existing network with id: %s",
$graph_id
);
$this["graph"] = $this->share(function($c) use($graph_id) {
return $c["gs"]->node($graph_id);
});
$this["founder"] = $this->share(function($c) {
$founder = $c["graph"]->getFounder();
return $founder;
});
}
else {
$this->logger()->info("Creating a new graph from scratch");
if(!is_null($founder)) {
$founder->persist();
}
else {
throw new Exceptions\FounderMustBeSetException();
}
$this["founder"] = $this->share(function($c) use ($founder) {
return $founder;
});
$this["graph"] = $this->share(function($c) {
$graph_class = $c["config"]->default_objects->graph;
$graph = new $graph_class($c, $c["founder"], $c["space"], $c["founder"]);
$c["logger"]->info("Changing founder context as graph");
$c["founder"]->changeContext($graph);
//$c["founder"]->hydrate($c, $c["graph"]); // // to make sure that is set up, since the services are now available.
return $graph;
});
$this->database()->set("configs:graph_id", $this->graph()->id());
$this->logger()->info(
"New graph with id: %s and founder: %s", $this->graph()->id(), $this->founder()->id()
);
}
$this->logger()->info("Root seed complete. Time to integrate space & graph");
$this["gs"]->warmUpCache();
try {
// $this["space"]->add($this["graph"]);
}
catch(NodeAlreadyMemberException $e) {
// do nothing
}
}
|
php
|
protected function seedRoot(? Foundation\AbstractActor $founder = null): void
{
$graph_id = $this->database()->get("configs:graph_id");
if(isset($graph_id)) {
$this->logger()->info(
"Existing network with id: %s",
$graph_id
);
$this["graph"] = $this->share(function($c) use($graph_id) {
return $c["gs"]->node($graph_id);
});
$this["founder"] = $this->share(function($c) {
$founder = $c["graph"]->getFounder();
return $founder;
});
}
else {
$this->logger()->info("Creating a new graph from scratch");
if(!is_null($founder)) {
$founder->persist();
}
else {
throw new Exceptions\FounderMustBeSetException();
}
$this["founder"] = $this->share(function($c) use ($founder) {
return $founder;
});
$this["graph"] = $this->share(function($c) {
$graph_class = $c["config"]->default_objects->graph;
$graph = new $graph_class($c, $c["founder"], $c["space"], $c["founder"]);
$c["logger"]->info("Changing founder context as graph");
$c["founder"]->changeContext($graph);
//$c["founder"]->hydrate($c, $c["graph"]); // // to make sure that is set up, since the services are now available.
return $graph;
});
$this->database()->set("configs:graph_id", $this->graph()->id());
$this->logger()->info(
"New graph with id: %s and founder: %s", $this->graph()->id(), $this->founder()->id()
);
}
$this->logger()->info("Root seed complete. Time to integrate space & graph");
$this["gs"]->warmUpCache();
try {
// $this["space"]->add($this["graph"]);
}
catch(NodeAlreadyMemberException $e) {
// do nothing
}
}
|
[
"protected",
"function",
"seedRoot",
"(",
"?",
"Foundation",
"\\",
"AbstractActor",
"$",
"founder",
"=",
"null",
")",
":",
"void",
"{",
"$",
"graph_id",
"=",
"$",
"this",
"->",
"database",
"(",
")",
"->",
"get",
"(",
"\"configs:graph_id\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"graph_id",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"Existing network with id: %s\"",
",",
"$",
"graph_id",
")",
";",
"$",
"this",
"[",
"\"graph\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"graph_id",
")",
"{",
"return",
"$",
"c",
"[",
"\"gs\"",
"]",
"->",
"node",
"(",
"$",
"graph_id",
")",
";",
"}",
")",
";",
"$",
"this",
"[",
"\"founder\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"{",
"$",
"founder",
"=",
"$",
"c",
"[",
"\"graph\"",
"]",
"->",
"getFounder",
"(",
")",
";",
"return",
"$",
"founder",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"Creating a new graph from scratch\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"founder",
")",
")",
"{",
"$",
"founder",
"->",
"persist",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exceptions",
"\\",
"FounderMustBeSetException",
"(",
")",
";",
"}",
"$",
"this",
"[",
"\"founder\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"founder",
")",
"{",
"return",
"$",
"founder",
";",
"}",
")",
";",
"$",
"this",
"[",
"\"graph\"",
"]",
"=",
"$",
"this",
"->",
"share",
"(",
"function",
"(",
"$",
"c",
")",
"{",
"$",
"graph_class",
"=",
"$",
"c",
"[",
"\"config\"",
"]",
"->",
"default_objects",
"->",
"graph",
";",
"$",
"graph",
"=",
"new",
"$",
"graph_class",
"(",
"$",
"c",
",",
"$",
"c",
"[",
"\"founder\"",
"]",
",",
"$",
"c",
"[",
"\"space\"",
"]",
",",
"$",
"c",
"[",
"\"founder\"",
"]",
")",
";",
"$",
"c",
"[",
"\"logger\"",
"]",
"->",
"info",
"(",
"\"Changing founder context as graph\"",
")",
";",
"$",
"c",
"[",
"\"founder\"",
"]",
"->",
"changeContext",
"(",
"$",
"graph",
")",
";",
"//$c[\"founder\"]->hydrate($c, $c[\"graph\"]); // // to make sure that is set up, since the services are now available.",
"return",
"$",
"graph",
";",
"}",
")",
";",
"$",
"this",
"->",
"database",
"(",
")",
"->",
"set",
"(",
"\"configs:graph_id\"",
",",
"$",
"this",
"->",
"graph",
"(",
")",
"->",
"id",
"(",
")",
")",
";",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"New graph with id: %s and founder: %s\"",
",",
"$",
"this",
"->",
"graph",
"(",
")",
"->",
"id",
"(",
")",
",",
"$",
"this",
"->",
"founder",
"(",
")",
"->",
"id",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"Root seed complete. Time to integrate space & graph\"",
")",
";",
"$",
"this",
"[",
"\"gs\"",
"]",
"->",
"warmUpCache",
"(",
")",
";",
"try",
"{",
"// $this[\"space\"]->add($this[\"graph\"]);",
"}",
"catch",
"(",
"NodeAlreadyMemberException",
"$",
"e",
")",
"{",
"// do nothing",
"}",
"}"
] |
Ensures that there is a root Graph attached to the kernel.
Used privately by the kernel.
@param ?Foundation\AbstractActor The founder object or null (to set
it up with default values or retrieve from the database)
@return void
|
[
"Ensures",
"that",
"there",
"is",
"a",
"root",
"Graph",
"attached",
"to",
"the",
"kernel",
".",
"Used",
"privately",
"by",
"the",
"kernel",
"."
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Init.php#L163-L217
|
223,876
|
tivie/php-git-log-parser
|
src/Format.php
|
Format.setFormat
|
public function setFormat($format, $commitDelimiter, $fieldDelimiter)
{
if (!is_string($format)) {
throw new InvalidArgumentException('string', 0);
}
if (!is_string($commitDelimiter)) {
throw new InvalidArgumentException('string', 1);
}
if (!is_string($fieldDelimiter)) {
throw new InvalidArgumentException('string', 2);
}
$this->commitDelimiter = $commitDelimiter;
$this->fieldDelimiter = $fieldDelimiter;
$this->format = $format;
return $this;
}
|
php
|
public function setFormat($format, $commitDelimiter, $fieldDelimiter)
{
if (!is_string($format)) {
throw new InvalidArgumentException('string', 0);
}
if (!is_string($commitDelimiter)) {
throw new InvalidArgumentException('string', 1);
}
if (!is_string($fieldDelimiter)) {
throw new InvalidArgumentException('string', 2);
}
$this->commitDelimiter = $commitDelimiter;
$this->fieldDelimiter = $fieldDelimiter;
$this->format = $format;
return $this;
}
|
[
"public",
"function",
"setFormat",
"(",
"$",
"format",
",",
"$",
"commitDelimiter",
",",
"$",
"fieldDelimiter",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"format",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'string'",
",",
"0",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"commitDelimiter",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'string'",
",",
"1",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"fieldDelimiter",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'string'",
",",
"2",
")",
";",
"}",
"$",
"this",
"->",
"commitDelimiter",
"=",
"$",
"commitDelimiter",
";",
"$",
"this",
"->",
"fieldDelimiter",
"=",
"$",
"fieldDelimiter",
";",
"$",
"this",
"->",
"format",
"=",
"$",
"format",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the format that should be used by git log command
@param string $format A string that follows the git log format specification.
@param string $commitDelimiter The commit delimiter used by this format
@param string $fieldDelimiter The field delimiter used by this format
@return $this
@throws InvalidArgumentException
@see http://git-scm.com/docs/git-log#_pretty_formats
|
[
"Set",
"the",
"format",
"that",
"should",
"be",
"used",
"by",
"git",
"log",
"command"
] |
bb6742cbbd4dd293f92b0d50b63c458b9b3986c2
|
https://github.com/tivie/php-git-log-parser/blob/bb6742cbbd4dd293f92b0d50b63c458b9b3986c2/src/Format.php#L133-L149
|
223,877
|
koala-framework/composer-extra-assets
|
Kwf/ComposerExtraAssets/LinkWriter.php
|
LinkWriter.writeLink
|
public function writeLink($target)
{
$fileName = basename($target);
$realTarget = realpath($target);
$relativePathToTarget = $this->makePathRelative(dirname($realTarget), $this->binaryDir).basename($realTarget);
// If Windows cmd link
if (pathinfo($target, PATHINFO_EXTENSION) == "cmd") {
$this->writeWindows($fileName, $relativePathToTarget);
} else {
$this->writeBash($fileName, $relativePathToTarget);
}
}
|
php
|
public function writeLink($target)
{
$fileName = basename($target);
$realTarget = realpath($target);
$relativePathToTarget = $this->makePathRelative(dirname($realTarget), $this->binaryDir).basename($realTarget);
// If Windows cmd link
if (pathinfo($target, PATHINFO_EXTENSION) == "cmd") {
$this->writeWindows($fileName, $relativePathToTarget);
} else {
$this->writeBash($fileName, $relativePathToTarget);
}
}
|
[
"public",
"function",
"writeLink",
"(",
"$",
"target",
")",
"{",
"$",
"fileName",
"=",
"basename",
"(",
"$",
"target",
")",
";",
"$",
"realTarget",
"=",
"realpath",
"(",
"$",
"target",
")",
";",
"$",
"relativePathToTarget",
"=",
"$",
"this",
"->",
"makePathRelative",
"(",
"dirname",
"(",
"$",
"realTarget",
")",
",",
"$",
"this",
"->",
"binaryDir",
")",
".",
"basename",
"(",
"$",
"realTarget",
")",
";",
"// If Windows cmd link",
"if",
"(",
"pathinfo",
"(",
"$",
"target",
",",
"PATHINFO_EXTENSION",
")",
"==",
"\"cmd\"",
")",
"{",
"$",
"this",
"->",
"writeWindows",
"(",
"$",
"fileName",
",",
"$",
"relativePathToTarget",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"writeBash",
"(",
"$",
"fileName",
",",
"$",
"relativePathToTarget",
")",
";",
"}",
"}"
] |
Writes a shortcut to the target link in the vendor directory.
@param string $target
|
[
"Writes",
"a",
"shortcut",
"to",
"the",
"target",
"link",
"in",
"the",
"vendor",
"directory",
"."
] |
8421543ac20ee59f5171e7b36a8830b7070a57cb
|
https://github.com/koala-framework/composer-extra-assets/blob/8421543ac20ee59f5171e7b36a8830b7070a57cb/Kwf/ComposerExtraAssets/LinkWriter.php#L26-L38
|
223,878
|
harryxu/laravel-theme
|
src/Bigecko/LaravelTheme/Theme.php
|
Theme.viewPath
|
public function viewPath()
{
return is_null($this->options['views_path'])
? public_path($this->options['public_dirname'] . '/' . $this->name() . '/views')
: rtrim($this->options['views_path'], '/') . '/' . $this->name();
}
|
php
|
public function viewPath()
{
return is_null($this->options['views_path'])
? public_path($this->options['public_dirname'] . '/' . $this->name() . '/views')
: rtrim($this->options['views_path'], '/') . '/' . $this->name();
}
|
[
"public",
"function",
"viewPath",
"(",
")",
"{",
"return",
"is_null",
"(",
"$",
"this",
"->",
"options",
"[",
"'views_path'",
"]",
")",
"?",
"public_path",
"(",
"$",
"this",
"->",
"options",
"[",
"'public_dirname'",
"]",
".",
"'/'",
".",
"$",
"this",
"->",
"name",
"(",
")",
".",
"'/views'",
")",
":",
"rtrim",
"(",
"$",
"this",
"->",
"options",
"[",
"'views_path'",
"]",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"name",
"(",
")",
";",
"}"
] |
Get current theme view path.
|
[
"Get",
"current",
"theme",
"view",
"path",
"."
] |
cd856ce82226bdef01c332002105c55eda856a94
|
https://github.com/harryxu/laravel-theme/blob/cd856ce82226bdef01c332002105c55eda856a94/src/Bigecko/LaravelTheme/Theme.php#L63-L68
|
223,879
|
harryxu/laravel-theme
|
src/Bigecko/LaravelTheme/Theme.php
|
Theme.publicPath
|
public function publicPath($path = '')
{
return public_path($this->options['public_dirname'] . '/' . $this->name()
. (empty($path) ? '' : '/' . rtrim($path)));
}
|
php
|
public function publicPath($path = '')
{
return public_path($this->options['public_dirname'] . '/' . $this->name()
. (empty($path) ? '' : '/' . rtrim($path)));
}
|
[
"public",
"function",
"publicPath",
"(",
"$",
"path",
"=",
"''",
")",
"{",
"return",
"public_path",
"(",
"$",
"this",
"->",
"options",
"[",
"'public_dirname'",
"]",
".",
"'/'",
".",
"$",
"this",
"->",
"name",
"(",
")",
".",
"(",
"empty",
"(",
"$",
"path",
")",
"?",
"''",
":",
"'/'",
".",
"rtrim",
"(",
"$",
"path",
")",
")",
")",
";",
"}"
] |
Get the fully qualified path to the theme public directory.
|
[
"Get",
"the",
"fully",
"qualified",
"path",
"to",
"the",
"theme",
"public",
"directory",
"."
] |
cd856ce82226bdef01c332002105c55eda856a94
|
https://github.com/harryxu/laravel-theme/blob/cd856ce82226bdef01c332002105c55eda856a94/src/Bigecko/LaravelTheme/Theme.php#L73-L77
|
223,880
|
shiftonelabs/laravel-nomad
|
src/LaravelNomadServiceProvider.php
|
LaravelNomadServiceProvider.registerConnections
|
public function registerConnections()
{
$driver = $this->app['nomad.feature.detection']->connectionResolverDriver();
$method = 'registerVia'.studly_case($driver);
if (method_exists($this, $method)) {
return $this->{$method}();
}
throw new LogicException(sprintf('Connection registration method [%s] does not exist.', $method));
}
|
php
|
public function registerConnections()
{
$driver = $this->app['nomad.feature.detection']->connectionResolverDriver();
$method = 'registerVia'.studly_case($driver);
if (method_exists($this, $method)) {
return $this->{$method}();
}
throw new LogicException(sprintf('Connection registration method [%s] does not exist.', $method));
}
|
[
"public",
"function",
"registerConnections",
"(",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"app",
"[",
"'nomad.feature.detection'",
"]",
"->",
"connectionResolverDriver",
"(",
")",
";",
"$",
"method",
"=",
"'registerVia'",
".",
"studly_case",
"(",
"$",
"driver",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
")",
";",
"}",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Connection registration method [%s] does not exist.'",
",",
"$",
"method",
")",
")",
";",
"}"
] |
Register the database connection extensions.
@return void
|
[
"Register",
"the",
"database",
"connection",
"extensions",
"."
] |
818b54ea10f92b91ad357386a70b9a2bb9058194
|
https://github.com/shiftonelabs/laravel-nomad/blob/818b54ea10f92b91ad357386a70b9a2bb9058194/src/LaravelNomadServiceProvider.php#L50-L61
|
223,881
|
shiftonelabs/laravel-nomad
|
src/LaravelNomadServiceProvider.php
|
LaravelNomadServiceProvider.registerViaConnectionMethod
|
public function registerViaConnectionMethod()
{
foreach ($this->classes as $driver => $class) {
Connection::resolverFor($driver, function ($connection, $database, $prefix, $config) use ($class) {
return new $class($connection, $database, $prefix, $config);
});
}
}
|
php
|
public function registerViaConnectionMethod()
{
foreach ($this->classes as $driver => $class) {
Connection::resolverFor($driver, function ($connection, $database, $prefix, $config) use ($class) {
return new $class($connection, $database, $prefix, $config);
});
}
}
|
[
"public",
"function",
"registerViaConnectionMethod",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"classes",
"as",
"$",
"driver",
"=>",
"$",
"class",
")",
"{",
"Connection",
"::",
"resolverFor",
"(",
"$",
"driver",
",",
"function",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
",",
"$",
"config",
")",
"use",
"(",
"$",
"class",
")",
"{",
"return",
"new",
"$",
"class",
"(",
"$",
"connection",
",",
"$",
"database",
",",
"$",
"prefix",
",",
"$",
"config",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Register the database connection extensions through the `Connection` method.
@return void
|
[
"Register",
"the",
"database",
"connection",
"extensions",
"through",
"the",
"Connection",
"method",
"."
] |
818b54ea10f92b91ad357386a70b9a2bb9058194
|
https://github.com/shiftonelabs/laravel-nomad/blob/818b54ea10f92b91ad357386a70b9a2bb9058194/src/LaravelNomadServiceProvider.php#L80-L87
|
223,882
|
shiftonelabs/laravel-nomad
|
src/Traits/Database/Schema/Grammars/PassthruTrait.php
|
PassthruTrait.typePassthru
|
protected function typePassthru(Fluent $column)
{
return !empty($column->definition) ? $column->definition : $column->realType;
}
|
php
|
protected function typePassthru(Fluent $column)
{
return !empty($column->definition) ? $column->definition : $column->realType;
}
|
[
"protected",
"function",
"typePassthru",
"(",
"Fluent",
"$",
"column",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"column",
"->",
"definition",
")",
"?",
"$",
"column",
"->",
"definition",
":",
"$",
"column",
"->",
"realType",
";",
"}"
] |
Create the column definition for a string type.
@param \Illuminate\Support\Fluent $column
@return string
|
[
"Create",
"the",
"column",
"definition",
"for",
"a",
"string",
"type",
"."
] |
818b54ea10f92b91ad357386a70b9a2bb9058194
|
https://github.com/shiftonelabs/laravel-nomad/blob/818b54ea10f92b91ad357386a70b9a2bb9058194/src/Traits/Database/Schema/Grammars/PassthruTrait.php#L16-L19
|
223,883
|
jakoch/nginx-conf
|
src/Parser.php
|
Parser.readComment
|
function readComment()
{
$str = substr($this->source, $this->index);
$result = preg_match('/^(.*?)(?:\r\n|\n|$)/', $str, $matches);
$this->index += ($result) ? strlen($matches[0]) : 0;
return substr($matches[1], 1); // ignore # character and EOL
}
|
php
|
function readComment()
{
$str = substr($this->source, $this->index);
$result = preg_match('/^(.*?)(?:\r\n|\n|$)/', $str, $matches);
$this->index += ($result) ? strlen($matches[0]) : 0;
return substr($matches[1], 1); // ignore # character and EOL
}
|
[
"function",
"readComment",
"(",
")",
"{",
"$",
"str",
"=",
"substr",
"(",
"$",
"this",
"->",
"source",
",",
"$",
"this",
"->",
"index",
")",
";",
"$",
"result",
"=",
"preg_match",
"(",
"'/^(.*?)(?:\\r\\n|\\n|$)/'",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"$",
"this",
"->",
"index",
"+=",
"(",
"$",
"result",
")",
"?",
"strlen",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
":",
"0",
";",
"return",
"substr",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"1",
")",
";",
"// ignore # character and EOL",
"}"
] |
a comment doesn't have to end with a semicolon
|
[
"a",
"comment",
"doesn",
"t",
"have",
"to",
"end",
"with",
"a",
"semicolon"
] |
9647f883a1e9e25d48463741d4966ea2f72feff5
|
https://github.com/jakoch/nginx-conf/blob/9647f883a1e9e25d48463741d4966ea2f72feff5/src/Parser.php#L183-L191
|
223,884
|
RikudouSage/QrPaymentCZ
|
src/QrPayment.php
|
QrPayment.checkProperties
|
protected function checkProperties(): void
{
foreach (get_object_vars($this) as $property => $value) {
if ($property !== "dueDate" && strpos($value, "*") !== false) {
throw new QrPaymentException("Error: properties cannot contain asterisk (*). Property $property contains it.", QrPaymentException::ERR_ASTERISK);
}
}
}
|
php
|
protected function checkProperties(): void
{
foreach (get_object_vars($this) as $property => $value) {
if ($property !== "dueDate" && strpos($value, "*") !== false) {
throw new QrPaymentException("Error: properties cannot contain asterisk (*). Property $property contains it.", QrPaymentException::ERR_ASTERISK);
}
}
}
|
[
"protected",
"function",
"checkProperties",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"property",
"!==",
"\"dueDate\"",
"&&",
"strpos",
"(",
"$",
"value",
",",
"\"*\"",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"QrPaymentException",
"(",
"\"Error: properties cannot contain asterisk (*). Property $property contains it.\"",
",",
"QrPaymentException",
"::",
"ERR_ASTERISK",
")",
";",
"}",
"}",
"}"
] |
Checks all properties for asterisk and throws exception if asterisk
is found
@throws \rikudou\CzQrPayment\QrPaymentException
|
[
"Checks",
"all",
"properties",
"for",
"asterisk",
"and",
"throws",
"exception",
"if",
"asterisk",
"is",
"found"
] |
ef94ef5551363cc3486bfdaac6af69395fbb9088
|
https://github.com/RikudouSage/QrPaymentCZ/blob/ef94ef5551363cc3486bfdaac6af69395fbb9088/src/QrPayment.php#L187-L194
|
223,885
|
RikudouSage/QrPaymentCZ
|
src/QrPayment.php
|
QrPayment.getQrImage
|
public function getQrImage(bool $setPngHeader = false): QrCode
{
if (!class_exists("Endroid\QrCode\QrCode")) {
throw new QrPaymentException("Error: library endroid/qr-code is not loaded.", QrPaymentException::ERR_MISSING_LIBRARY);
}
if ($setPngHeader) {
header("Content-type: image/png");
}
return new QrCode($this->getQrString());
}
|
php
|
public function getQrImage(bool $setPngHeader = false): QrCode
{
if (!class_exists("Endroid\QrCode\QrCode")) {
throw new QrPaymentException("Error: library endroid/qr-code is not loaded.", QrPaymentException::ERR_MISSING_LIBRARY);
}
if ($setPngHeader) {
header("Content-type: image/png");
}
return new QrCode($this->getQrString());
}
|
[
"public",
"function",
"getQrImage",
"(",
"bool",
"$",
"setPngHeader",
"=",
"false",
")",
":",
"QrCode",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"\"Endroid\\QrCode\\QrCode\"",
")",
")",
"{",
"throw",
"new",
"QrPaymentException",
"(",
"\"Error: library endroid/qr-code is not loaded.\"",
",",
"QrPaymentException",
"::",
"ERR_MISSING_LIBRARY",
")",
";",
"}",
"if",
"(",
"$",
"setPngHeader",
")",
"{",
"header",
"(",
"\"Content-type: image/png\"",
")",
";",
"}",
"return",
"new",
"QrCode",
"(",
"$",
"this",
"->",
"getQrString",
"(",
")",
")",
";",
"}"
] |
Return QrCode object with QrString set, for more info see Endroid QrCode
documentation
@param bool $setPngHeader
@return \Endroid\QrCode\QrCode
@throws \rikudou\CzQrPayment\QrPaymentException
|
[
"Return",
"QrCode",
"object",
"with",
"QrString",
"set",
"for",
"more",
"info",
"see",
"Endroid",
"QrCode",
"documentation"
] |
ef94ef5551363cc3486bfdaac6af69395fbb9088
|
https://github.com/RikudouSage/QrPaymentCZ/blob/ef94ef5551363cc3486bfdaac6af69395fbb9088/src/QrPayment.php#L204-L215
|
223,886
|
thephpleague/phpunit-coverage-listener
|
src/League/PHPUnitCoverageListener/Listener.php
|
Listener.collectAndWriteCoverage
|
public function collectAndWriteCoverage($args)
{
if ($this->valid($args)) {
extract($args);
// Check for exist and valid hook
if (isset($hook) && $hook instanceof HookInterface) {
$this->hook = $hook;
unset($hook);
}
// Get the realpath coverage directory
$coverage_dir = realpath($coverage_dir);
$coverage_file = $coverage_dir.DIRECTORY_SEPARATOR.self::COVERAGE_FILE;
$coverage_output = $coverage_dir.DIRECTORY_SEPARATOR.self::COVERAGE_OUTPUT;
// Get the coverage information
if (is_dir($coverage_dir) && is_file($coverage_file)) {
// Build the coverage xml object
$xml = file_get_contents($coverage_file);
$coverage = new SimpleXMLElement($xml);
// Prepare the coveralls payload
$data = $this->collect($coverage, $args);
// Write the coverage output
$this->printer->out('Writing coverage output...');
file_put_contents($coverage_output, json_encode($data->all(), JSON_NUMERIC_CHECK));
}
}
}
|
php
|
public function collectAndWriteCoverage($args)
{
if ($this->valid($args)) {
extract($args);
// Check for exist and valid hook
if (isset($hook) && $hook instanceof HookInterface) {
$this->hook = $hook;
unset($hook);
}
// Get the realpath coverage directory
$coverage_dir = realpath($coverage_dir);
$coverage_file = $coverage_dir.DIRECTORY_SEPARATOR.self::COVERAGE_FILE;
$coverage_output = $coverage_dir.DIRECTORY_SEPARATOR.self::COVERAGE_OUTPUT;
// Get the coverage information
if (is_dir($coverage_dir) && is_file($coverage_file)) {
// Build the coverage xml object
$xml = file_get_contents($coverage_file);
$coverage = new SimpleXMLElement($xml);
// Prepare the coveralls payload
$data = $this->collect($coverage, $args);
// Write the coverage output
$this->printer->out('Writing coverage output...');
file_put_contents($coverage_output, json_encode($data->all(), JSON_NUMERIC_CHECK));
}
}
}
|
[
"public",
"function",
"collectAndWriteCoverage",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"valid",
"(",
"$",
"args",
")",
")",
"{",
"extract",
"(",
"$",
"args",
")",
";",
"// Check for exist and valid hook",
"if",
"(",
"isset",
"(",
"$",
"hook",
")",
"&&",
"$",
"hook",
"instanceof",
"HookInterface",
")",
"{",
"$",
"this",
"->",
"hook",
"=",
"$",
"hook",
";",
"unset",
"(",
"$",
"hook",
")",
";",
"}",
"// Get the realpath coverage directory",
"$",
"coverage_dir",
"=",
"realpath",
"(",
"$",
"coverage_dir",
")",
";",
"$",
"coverage_file",
"=",
"$",
"coverage_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"COVERAGE_FILE",
";",
"$",
"coverage_output",
"=",
"$",
"coverage_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"COVERAGE_OUTPUT",
";",
"// Get the coverage information",
"if",
"(",
"is_dir",
"(",
"$",
"coverage_dir",
")",
"&&",
"is_file",
"(",
"$",
"coverage_file",
")",
")",
"{",
"// Build the coverage xml object",
"$",
"xml",
"=",
"file_get_contents",
"(",
"$",
"coverage_file",
")",
";",
"$",
"coverage",
"=",
"new",
"SimpleXMLElement",
"(",
"$",
"xml",
")",
";",
"// Prepare the coveralls payload",
"$",
"data",
"=",
"$",
"this",
"->",
"collect",
"(",
"$",
"coverage",
",",
"$",
"args",
")",
";",
"// Write the coverage output",
"$",
"this",
"->",
"printer",
"->",
"out",
"(",
"'Writing coverage output...'",
")",
";",
"file_put_contents",
"(",
"$",
"coverage_output",
",",
"json_encode",
"(",
"$",
"data",
"->",
"all",
"(",
")",
",",
"JSON_NUMERIC_CHECK",
")",
")",
";",
"}",
"}",
"}"
] |
Main api for collecting code-coverage information and write it into json payload
@param array
|
[
"Main",
"api",
"for",
"collecting",
"code",
"-",
"coverage",
"information",
"and",
"write",
"it",
"into",
"json",
"payload"
] |
dbc833a21990973e1182431b42842918595dc20a
|
https://github.com/thephpleague/phpunit-coverage-listener/blob/dbc833a21990973e1182431b42842918595dc20a/src/League/PHPUnitCoverageListener/Listener.php#L104-L134
|
223,887
|
thephpleague/phpunit-coverage-listener
|
src/League/PHPUnitCoverageListener/Listener.php
|
Listener.collectAndSendCoverage
|
public function collectAndSendCoverage($args)
{
// Collect and write out the data
$this->collectAndWriteCoverage($args);
if ($this->valid($args)) {
extract($args);
// Get the realpath coverage directory
$coverage_dir = realpath($coverage_dir);
$coverage_output = $coverage_dir.DIRECTORY_SEPARATOR.self::COVERAGE_OUTPUT;
// Send it!
$this->printer->out('Sending coverage output...');
// Workaround for cURL create file
if (function_exists('curl_file_create')) {
$payload = curl_file_create('json_file', 'application/json', $coverage_output);
} else {
$payload = array('json_file'=>'@'.$coverage_output);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
// Save output into output buffer
ob_start();
$result = curl_exec ($ch);
$curlOutput = ob_get_contents();
ob_end_clean();
curl_close ($ch);
$this->printer->printOut('cURL Output:'.$curlOutput);
$this->printer->printOut('cURL Result:'.$result);
}
}
|
php
|
public function collectAndSendCoverage($args)
{
// Collect and write out the data
$this->collectAndWriteCoverage($args);
if ($this->valid($args)) {
extract($args);
// Get the realpath coverage directory
$coverage_dir = realpath($coverage_dir);
$coverage_output = $coverage_dir.DIRECTORY_SEPARATOR.self::COVERAGE_OUTPUT;
// Send it!
$this->printer->out('Sending coverage output...');
// Workaround for cURL create file
if (function_exists('curl_file_create')) {
$payload = curl_file_create('json_file', 'application/json', $coverage_output);
} else {
$payload = array('json_file'=>'@'.$coverage_output);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
// Save output into output buffer
ob_start();
$result = curl_exec ($ch);
$curlOutput = ob_get_contents();
ob_end_clean();
curl_close ($ch);
$this->printer->printOut('cURL Output:'.$curlOutput);
$this->printer->printOut('cURL Result:'.$result);
}
}
|
[
"public",
"function",
"collectAndSendCoverage",
"(",
"$",
"args",
")",
"{",
"// Collect and write out the data",
"$",
"this",
"->",
"collectAndWriteCoverage",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"this",
"->",
"valid",
"(",
"$",
"args",
")",
")",
"{",
"extract",
"(",
"$",
"args",
")",
";",
"// Get the realpath coverage directory",
"$",
"coverage_dir",
"=",
"realpath",
"(",
"$",
"coverage_dir",
")",
";",
"$",
"coverage_output",
"=",
"$",
"coverage_dir",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"COVERAGE_OUTPUT",
";",
"// Send it!",
"$",
"this",
"->",
"printer",
"->",
"out",
"(",
"'Sending coverage output...'",
")",
";",
"// Workaround for cURL create file",
"if",
"(",
"function_exists",
"(",
"'curl_file_create'",
")",
")",
"{",
"$",
"payload",
"=",
"curl_file_create",
"(",
"'json_file'",
",",
"'application/json'",
",",
"$",
"coverage_output",
")",
";",
"}",
"else",
"{",
"$",
"payload",
"=",
"array",
"(",
"'json_file'",
"=>",
"'@'",
".",
"$",
"coverage_output",
")",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"target_url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"payload",
")",
";",
"// Save output into output buffer",
"ob_start",
"(",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"curlOutput",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"$",
"this",
"->",
"printer",
"->",
"printOut",
"(",
"'cURL Output:'",
".",
"$",
"curlOutput",
")",
";",
"$",
"this",
"->",
"printer",
"->",
"printOut",
"(",
"'cURL Result:'",
".",
"$",
"result",
")",
";",
"}",
"}"
] |
Main api for collecting code-coverage information
@param array Contains repo secret hash, target url, coverage directory and optional Namespace
|
[
"Main",
"api",
"for",
"collecting",
"code",
"-",
"coverage",
"information"
] |
dbc833a21990973e1182431b42842918595dc20a
|
https://github.com/thephpleague/phpunit-coverage-listener/blob/dbc833a21990973e1182431b42842918595dc20a/src/League/PHPUnitCoverageListener/Listener.php#L141-L179
|
223,888
|
thephpleague/phpunit-coverage-listener
|
src/League/PHPUnitCoverageListener/Listener.php
|
Listener.collect
|
protected function collect(SimpleXMLElement $coverage, $args = array())
{
extract($args);
$data = new Collection(array(
'repo_token' => $repo_token,
'source_files' => array(),
'run_at' => gmdate('Y-m-d H:i:s -0000'),
'git' => $this->collectFromGit()->all(),
));
// Before collect hook
if ( ! empty($this->hook)) {
$data = $this->hook->beforeCollect($data);
}
// Prepare temporary source_files holder
$sourceArray = new Collection();
if (count($coverage->project->package) > 0) {
// Iterate over the package
foreach ($coverage->project->package as $package) {
// Then itterate on each package file
foreach ($package->file as $packageFile) {
$this->printer->printOut('Checking:'.$packageFile['name']);
$sourceArray->add(array(
md5($packageFile['name']) => $this->collectFromFile($packageFile, $namespace)
));
}
}
}
// In case the files are not using any namespace at all...
// @codeCoverageIgnoreStart
if (count($coverage->project->file) > 0) {
// itterate over the files
foreach ($coverage->project->file as $file) {
$this->printer->printOut('Checking:'.$file['name']);
$sourceArray->add(array(
md5($file['name']) => $this->collectFromFile($file, $namespace)
));
}
}
// @codeCoverageIgnoreEnd
// Last, pass the source information it it contains any information
if ($sourceArray->count() > 0) {
$data->set('source_files', array_values($sourceArray->all()));
}
// After collect hook
if ( ! empty($this->hook)) {
$data = $this->hook->afterCollect($data);
}
return $data;
}
|
php
|
protected function collect(SimpleXMLElement $coverage, $args = array())
{
extract($args);
$data = new Collection(array(
'repo_token' => $repo_token,
'source_files' => array(),
'run_at' => gmdate('Y-m-d H:i:s -0000'),
'git' => $this->collectFromGit()->all(),
));
// Before collect hook
if ( ! empty($this->hook)) {
$data = $this->hook->beforeCollect($data);
}
// Prepare temporary source_files holder
$sourceArray = new Collection();
if (count($coverage->project->package) > 0) {
// Iterate over the package
foreach ($coverage->project->package as $package) {
// Then itterate on each package file
foreach ($package->file as $packageFile) {
$this->printer->printOut('Checking:'.$packageFile['name']);
$sourceArray->add(array(
md5($packageFile['name']) => $this->collectFromFile($packageFile, $namespace)
));
}
}
}
// In case the files are not using any namespace at all...
// @codeCoverageIgnoreStart
if (count($coverage->project->file) > 0) {
// itterate over the files
foreach ($coverage->project->file as $file) {
$this->printer->printOut('Checking:'.$file['name']);
$sourceArray->add(array(
md5($file['name']) => $this->collectFromFile($file, $namespace)
));
}
}
// @codeCoverageIgnoreEnd
// Last, pass the source information it it contains any information
if ($sourceArray->count() > 0) {
$data->set('source_files', array_values($sourceArray->all()));
}
// After collect hook
if ( ! empty($this->hook)) {
$data = $this->hook->afterCollect($data);
}
return $data;
}
|
[
"protected",
"function",
"collect",
"(",
"SimpleXMLElement",
"$",
"coverage",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"extract",
"(",
"$",
"args",
")",
";",
"$",
"data",
"=",
"new",
"Collection",
"(",
"array",
"(",
"'repo_token'",
"=>",
"$",
"repo_token",
",",
"'source_files'",
"=>",
"array",
"(",
")",
",",
"'run_at'",
"=>",
"gmdate",
"(",
"'Y-m-d H:i:s -0000'",
")",
",",
"'git'",
"=>",
"$",
"this",
"->",
"collectFromGit",
"(",
")",
"->",
"all",
"(",
")",
",",
")",
")",
";",
"// Before collect hook",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"hook",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"hook",
"->",
"beforeCollect",
"(",
"$",
"data",
")",
";",
"}",
"// Prepare temporary source_files holder",
"$",
"sourceArray",
"=",
"new",
"Collection",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"coverage",
"->",
"project",
"->",
"package",
")",
">",
"0",
")",
"{",
"// Iterate over the package",
"foreach",
"(",
"$",
"coverage",
"->",
"project",
"->",
"package",
"as",
"$",
"package",
")",
"{",
"// Then itterate on each package file",
"foreach",
"(",
"$",
"package",
"->",
"file",
"as",
"$",
"packageFile",
")",
"{",
"$",
"this",
"->",
"printer",
"->",
"printOut",
"(",
"'Checking:'",
".",
"$",
"packageFile",
"[",
"'name'",
"]",
")",
";",
"$",
"sourceArray",
"->",
"add",
"(",
"array",
"(",
"md5",
"(",
"$",
"packageFile",
"[",
"'name'",
"]",
")",
"=>",
"$",
"this",
"->",
"collectFromFile",
"(",
"$",
"packageFile",
",",
"$",
"namespace",
")",
")",
")",
";",
"}",
"}",
"}",
"// In case the files are not using any namespace at all...",
"// @codeCoverageIgnoreStart",
"if",
"(",
"count",
"(",
"$",
"coverage",
"->",
"project",
"->",
"file",
")",
">",
"0",
")",
"{",
"// itterate over the files",
"foreach",
"(",
"$",
"coverage",
"->",
"project",
"->",
"file",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"printer",
"->",
"printOut",
"(",
"'Checking:'",
".",
"$",
"file",
"[",
"'name'",
"]",
")",
";",
"$",
"sourceArray",
"->",
"add",
"(",
"array",
"(",
"md5",
"(",
"$",
"file",
"[",
"'name'",
"]",
")",
"=>",
"$",
"this",
"->",
"collectFromFile",
"(",
"$",
"file",
",",
"$",
"namespace",
")",
")",
")",
";",
"}",
"}",
"// @codeCoverageIgnoreEnd",
"// Last, pass the source information it it contains any information",
"if",
"(",
"$",
"sourceArray",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"data",
"->",
"set",
"(",
"'source_files'",
",",
"array_values",
"(",
"$",
"sourceArray",
"->",
"all",
"(",
")",
")",
")",
";",
"}",
"// After collect hook",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"hook",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"hook",
"->",
"afterCollect",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Main collector method
@param SimpleXMLElement Coverage report from PHPUnit
@param array
@return Collection
|
[
"Main",
"collector",
"method"
] |
dbc833a21990973e1182431b42842918595dc20a
|
https://github.com/thephpleague/phpunit-coverage-listener/blob/dbc833a21990973e1182431b42842918595dc20a/src/League/PHPUnitCoverageListener/Listener.php#L220-L278
|
223,889
|
thephpleague/phpunit-coverage-listener
|
src/League/PHPUnitCoverageListener/Listener.php
|
Listener.collectFromFile
|
protected function collectFromFile(SimpleXMLElement $file, $namespace = '')
{
// Validate
if ( ! is_file($file['name'])) throw new \RuntimeException('Invalid '.self::COVERAGE_FILE.' file');
// Get current dir
$currentDir = $this->getDirectory();
// Initial return values
$name = '';
$source = '';
$coverage = array();
// #1 Get the relative file name
$pathComponents = explode($currentDir, $file['name']);
$relativeName = count($pathComponents) == 2 ? $pathComponents[1] : current($pathComponents);
$name = trim($relativeName, DIRECTORY_SEPARATOR);
if ( ! empty($namespace)) {
// Replace backslash with directory separator
$ns = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
$nsComponents = explode($ns, $relativeName);
$namespacedName = count($nsComponents) == 2 ? $nsComponents[1] : current($nsComponents);
$name = count($nsComponents) == 2 ? $ns.DIRECTORY_SEPARATOR.trim($namespacedName, DIRECTORY_SEPARATOR) : $namespacedName;
}
// Then, we will overwrite any coverage block into it!
if (count($file->line) > 1) {
// #2 Build coverage data and the source code
$count = 0;
$handle = fopen($file['name'], "r");
while(!feof($handle)){
$source .= fgets($handle);
$count++;
}
fclose($handle);
// Here we build the default coverage values
$coverage = array_fill(0, $count, null);
foreach ($file->line as $line) {
$attributes = current($line->attributes());
// Only stmt would be count
if (isset($attributes['type'])
&& isset($attributes['count'])
&& $attributes['type'] === 'stmt') {
// Decrease the line number by one
// since key 0 (within coverage array) is actually line number 1
$num = (int) $attributes['num'] - 1;
// Ensure it match count boundaries
if ($num > 0 && $num <= $count) {
$coverage[$num] = (int) $attributes['count'];
}
}
}
}
return compact('name', 'source', 'coverage');
}
|
php
|
protected function collectFromFile(SimpleXMLElement $file, $namespace = '')
{
// Validate
if ( ! is_file($file['name'])) throw new \RuntimeException('Invalid '.self::COVERAGE_FILE.' file');
// Get current dir
$currentDir = $this->getDirectory();
// Initial return values
$name = '';
$source = '';
$coverage = array();
// #1 Get the relative file name
$pathComponents = explode($currentDir, $file['name']);
$relativeName = count($pathComponents) == 2 ? $pathComponents[1] : current($pathComponents);
$name = trim($relativeName, DIRECTORY_SEPARATOR);
if ( ! empty($namespace)) {
// Replace backslash with directory separator
$ns = str_replace('\\', DIRECTORY_SEPARATOR, $namespace);
$nsComponents = explode($ns, $relativeName);
$namespacedName = count($nsComponents) == 2 ? $nsComponents[1] : current($nsComponents);
$name = count($nsComponents) == 2 ? $ns.DIRECTORY_SEPARATOR.trim($namespacedName, DIRECTORY_SEPARATOR) : $namespacedName;
}
// Then, we will overwrite any coverage block into it!
if (count($file->line) > 1) {
// #2 Build coverage data and the source code
$count = 0;
$handle = fopen($file['name'], "r");
while(!feof($handle)){
$source .= fgets($handle);
$count++;
}
fclose($handle);
// Here we build the default coverage values
$coverage = array_fill(0, $count, null);
foreach ($file->line as $line) {
$attributes = current($line->attributes());
// Only stmt would be count
if (isset($attributes['type'])
&& isset($attributes['count'])
&& $attributes['type'] === 'stmt') {
// Decrease the line number by one
// since key 0 (within coverage array) is actually line number 1
$num = (int) $attributes['num'] - 1;
// Ensure it match count boundaries
if ($num > 0 && $num <= $count) {
$coverage[$num] = (int) $attributes['count'];
}
}
}
}
return compact('name', 'source', 'coverage');
}
|
[
"protected",
"function",
"collectFromFile",
"(",
"SimpleXMLElement",
"$",
"file",
",",
"$",
"namespace",
"=",
"''",
")",
"{",
"// Validate",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
"[",
"'name'",
"]",
")",
")",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Invalid '",
".",
"self",
"::",
"COVERAGE_FILE",
".",
"' file'",
")",
";",
"// Get current dir",
"$",
"currentDir",
"=",
"$",
"this",
"->",
"getDirectory",
"(",
")",
";",
"// Initial return values",
"$",
"name",
"=",
"''",
";",
"$",
"source",
"=",
"''",
";",
"$",
"coverage",
"=",
"array",
"(",
")",
";",
"// #1 Get the relative file name",
"$",
"pathComponents",
"=",
"explode",
"(",
"$",
"currentDir",
",",
"$",
"file",
"[",
"'name'",
"]",
")",
";",
"$",
"relativeName",
"=",
"count",
"(",
"$",
"pathComponents",
")",
"==",
"2",
"?",
"$",
"pathComponents",
"[",
"1",
"]",
":",
"current",
"(",
"$",
"pathComponents",
")",
";",
"$",
"name",
"=",
"trim",
"(",
"$",
"relativeName",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"namespace",
")",
")",
"{",
"// Replace backslash with directory separator",
"$",
"ns",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"namespace",
")",
";",
"$",
"nsComponents",
"=",
"explode",
"(",
"$",
"ns",
",",
"$",
"relativeName",
")",
";",
"$",
"namespacedName",
"=",
"count",
"(",
"$",
"nsComponents",
")",
"==",
"2",
"?",
"$",
"nsComponents",
"[",
"1",
"]",
":",
"current",
"(",
"$",
"nsComponents",
")",
";",
"$",
"name",
"=",
"count",
"(",
"$",
"nsComponents",
")",
"==",
"2",
"?",
"$",
"ns",
".",
"DIRECTORY_SEPARATOR",
".",
"trim",
"(",
"$",
"namespacedName",
",",
"DIRECTORY_SEPARATOR",
")",
":",
"$",
"namespacedName",
";",
"}",
"// Then, we will overwrite any coverage block into it!",
"if",
"(",
"count",
"(",
"$",
"file",
"->",
"line",
")",
">",
"1",
")",
"{",
"// #2 Build coverage data and the source code",
"$",
"count",
"=",
"0",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"file",
"[",
"'name'",
"]",
",",
"\"r\"",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"handle",
")",
")",
"{",
"$",
"source",
".=",
"fgets",
"(",
"$",
"handle",
")",
";",
"$",
"count",
"++",
";",
"}",
"fclose",
"(",
"$",
"handle",
")",
";",
"// Here we build the default coverage values",
"$",
"coverage",
"=",
"array_fill",
"(",
"0",
",",
"$",
"count",
",",
"null",
")",
";",
"foreach",
"(",
"$",
"file",
"->",
"line",
"as",
"$",
"line",
")",
"{",
"$",
"attributes",
"=",
"current",
"(",
"$",
"line",
"->",
"attributes",
"(",
")",
")",
";",
"// Only stmt would be count",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'type'",
"]",
")",
"&&",
"isset",
"(",
"$",
"attributes",
"[",
"'count'",
"]",
")",
"&&",
"$",
"attributes",
"[",
"'type'",
"]",
"===",
"'stmt'",
")",
"{",
"// Decrease the line number by one",
"// since key 0 (within coverage array) is actually line number 1",
"$",
"num",
"=",
"(",
"int",
")",
"$",
"attributes",
"[",
"'num'",
"]",
"-",
"1",
";",
"// Ensure it match count boundaries",
"if",
"(",
"$",
"num",
">",
"0",
"&&",
"$",
"num",
"<=",
"$",
"count",
")",
"{",
"$",
"coverage",
"[",
"$",
"num",
"]",
"=",
"(",
"int",
")",
"$",
"attributes",
"[",
"'count'",
"]",
";",
"}",
"}",
"}",
"}",
"return",
"compact",
"(",
"'name'",
",",
"'source'",
",",
"'coverage'",
")",
";",
"}"
] |
Collect code-coverage information from a file
@param SimpleXMLElement contains coverage information
@param string Optional file namespace identifier
@throws RuntimeException
@return array contains code-coverage data with keys as follow : name, source, coverage
|
[
"Collect",
"code",
"-",
"coverage",
"information",
"from",
"a",
"file"
] |
dbc833a21990973e1182431b42842918595dc20a
|
https://github.com/thephpleague/phpunit-coverage-listener/blob/dbc833a21990973e1182431b42842918595dc20a/src/League/PHPUnitCoverageListener/Listener.php#L288-L351
|
223,890
|
thephpleague/phpunit-coverage-listener
|
src/League/PHPUnitCoverageListener/Listener.php
|
Listener.collectFromGit
|
public function collectFromGit()
{
// Initial git data
$git = new Collection();
$gitDirectory = $this->getDirectory().DIRECTORY_SEPARATOR.self::GIT_DIRECTORY;
if (is_dir($gitDirectory)) {
// Get refs info from HEAD
$branch = '';
$head = Yaml::parse($gitDirectory.DIRECTORY_SEPARATOR.self::GIT_HEAD);
// @codeCoverageIgnoreStart
if (is_array($head) && array_key_exists('ref', $head)) {
$ref = $head['ref'];
$r = explode('/', $ref);
$branch = array_pop($r);
}
// @codeCoverageIgnoreEnd
// Assign branch information
$git->set('branch', $branch);
// Get log information
$logRaw = self::execute('cd '.$this->getDirectory().';git log -1');
$idRaw = $logRaw[0];
$authorRaw = $logRaw[1];
// Build head information
if (strpos($authorRaw, '<') !== false) {
list($author, $email) = explode('<', str_replace('Author:', '', $authorRaw));
$id = trim(str_replace('commit', '', $idRaw));
$author_name = $committer_name = trim($author);
$author_email = $committer_email = trim($email, '>');
$message = $logRaw[4].(isset($logRaw[5]) ? '...' : '');
}
// Assign Head information
$git->set('head', compact('id', 'author_name', 'author_email',
'committer_name', 'committer_email', 'message'));
// Get remotes information
$remotes = array();
$configRaw = self::execute('cd '.$this->getDirectory().';git config --local -l');
array_walk($configRaw,function($v) use(&$remotes)
{
if (0 === strpos($v, 'remote')) {
list($key, $prop) = explode('=', $v);
$k = explode('.', $key);
$attribute = array_pop($k);
$name = array_pop($k);
$remotes[$name]['name'] = $name;
$remotes[$name][$attribute] = $prop;
}
});
// Assign Remotes information
$git->set('remotes', array_values($remotes));
}
return $git;
}
|
php
|
public function collectFromGit()
{
// Initial git data
$git = new Collection();
$gitDirectory = $this->getDirectory().DIRECTORY_SEPARATOR.self::GIT_DIRECTORY;
if (is_dir($gitDirectory)) {
// Get refs info from HEAD
$branch = '';
$head = Yaml::parse($gitDirectory.DIRECTORY_SEPARATOR.self::GIT_HEAD);
// @codeCoverageIgnoreStart
if (is_array($head) && array_key_exists('ref', $head)) {
$ref = $head['ref'];
$r = explode('/', $ref);
$branch = array_pop($r);
}
// @codeCoverageIgnoreEnd
// Assign branch information
$git->set('branch', $branch);
// Get log information
$logRaw = self::execute('cd '.$this->getDirectory().';git log -1');
$idRaw = $logRaw[0];
$authorRaw = $logRaw[1];
// Build head information
if (strpos($authorRaw, '<') !== false) {
list($author, $email) = explode('<', str_replace('Author:', '', $authorRaw));
$id = trim(str_replace('commit', '', $idRaw));
$author_name = $committer_name = trim($author);
$author_email = $committer_email = trim($email, '>');
$message = $logRaw[4].(isset($logRaw[5]) ? '...' : '');
}
// Assign Head information
$git->set('head', compact('id', 'author_name', 'author_email',
'committer_name', 'committer_email', 'message'));
// Get remotes information
$remotes = array();
$configRaw = self::execute('cd '.$this->getDirectory().';git config --local -l');
array_walk($configRaw,function($v) use(&$remotes)
{
if (0 === strpos($v, 'remote')) {
list($key, $prop) = explode('=', $v);
$k = explode('.', $key);
$attribute = array_pop($k);
$name = array_pop($k);
$remotes[$name]['name'] = $name;
$remotes[$name][$attribute] = $prop;
}
});
// Assign Remotes information
$git->set('remotes', array_values($remotes));
}
return $git;
}
|
[
"public",
"function",
"collectFromGit",
"(",
")",
"{",
"// Initial git data",
"$",
"git",
"=",
"new",
"Collection",
"(",
")",
";",
"$",
"gitDirectory",
"=",
"$",
"this",
"->",
"getDirectory",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"GIT_DIRECTORY",
";",
"if",
"(",
"is_dir",
"(",
"$",
"gitDirectory",
")",
")",
"{",
"// Get refs info from HEAD",
"$",
"branch",
"=",
"''",
";",
"$",
"head",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"gitDirectory",
".",
"DIRECTORY_SEPARATOR",
".",
"self",
"::",
"GIT_HEAD",
")",
";",
"// @codeCoverageIgnoreStart",
"if",
"(",
"is_array",
"(",
"$",
"head",
")",
"&&",
"array_key_exists",
"(",
"'ref'",
",",
"$",
"head",
")",
")",
"{",
"$",
"ref",
"=",
"$",
"head",
"[",
"'ref'",
"]",
";",
"$",
"r",
"=",
"explode",
"(",
"'/'",
",",
"$",
"ref",
")",
";",
"$",
"branch",
"=",
"array_pop",
"(",
"$",
"r",
")",
";",
"}",
"// @codeCoverageIgnoreEnd",
"// Assign branch information",
"$",
"git",
"->",
"set",
"(",
"'branch'",
",",
"$",
"branch",
")",
";",
"// Get log information",
"$",
"logRaw",
"=",
"self",
"::",
"execute",
"(",
"'cd '",
".",
"$",
"this",
"->",
"getDirectory",
"(",
")",
".",
"';git log -1'",
")",
";",
"$",
"idRaw",
"=",
"$",
"logRaw",
"[",
"0",
"]",
";",
"$",
"authorRaw",
"=",
"$",
"logRaw",
"[",
"1",
"]",
";",
"// Build head information",
"if",
"(",
"strpos",
"(",
"$",
"authorRaw",
",",
"'<'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"author",
",",
"$",
"email",
")",
"=",
"explode",
"(",
"'<'",
",",
"str_replace",
"(",
"'Author:'",
",",
"''",
",",
"$",
"authorRaw",
")",
")",
";",
"$",
"id",
"=",
"trim",
"(",
"str_replace",
"(",
"'commit'",
",",
"''",
",",
"$",
"idRaw",
")",
")",
";",
"$",
"author_name",
"=",
"$",
"committer_name",
"=",
"trim",
"(",
"$",
"author",
")",
";",
"$",
"author_email",
"=",
"$",
"committer_email",
"=",
"trim",
"(",
"$",
"email",
",",
"'>'",
")",
";",
"$",
"message",
"=",
"$",
"logRaw",
"[",
"4",
"]",
".",
"(",
"isset",
"(",
"$",
"logRaw",
"[",
"5",
"]",
")",
"?",
"'...'",
":",
"''",
")",
";",
"}",
"// Assign Head information",
"$",
"git",
"->",
"set",
"(",
"'head'",
",",
"compact",
"(",
"'id'",
",",
"'author_name'",
",",
"'author_email'",
",",
"'committer_name'",
",",
"'committer_email'",
",",
"'message'",
")",
")",
";",
"// Get remotes information",
"$",
"remotes",
"=",
"array",
"(",
")",
";",
"$",
"configRaw",
"=",
"self",
"::",
"execute",
"(",
"'cd '",
".",
"$",
"this",
"->",
"getDirectory",
"(",
")",
".",
"';git config --local -l'",
")",
";",
"array_walk",
"(",
"$",
"configRaw",
",",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"&",
"$",
"remotes",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"v",
",",
"'remote'",
")",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"prop",
")",
"=",
"explode",
"(",
"'='",
",",
"$",
"v",
")",
";",
"$",
"k",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"attribute",
"=",
"array_pop",
"(",
"$",
"k",
")",
";",
"$",
"name",
"=",
"array_pop",
"(",
"$",
"k",
")",
";",
"$",
"remotes",
"[",
"$",
"name",
"]",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"remotes",
"[",
"$",
"name",
"]",
"[",
"$",
"attribute",
"]",
"=",
"$",
"prop",
";",
"}",
"}",
")",
";",
"// Assign Remotes information",
"$",
"git",
"->",
"set",
"(",
"'remotes'",
",",
"array_values",
"(",
"$",
"remotes",
")",
")",
";",
"}",
"return",
"$",
"git",
";",
"}"
] |
Collect git information
@return Collection
|
[
"Collect",
"git",
"information"
] |
dbc833a21990973e1182431b42842918595dc20a
|
https://github.com/thephpleague/phpunit-coverage-listener/blob/dbc833a21990973e1182431b42842918595dc20a/src/League/PHPUnitCoverageListener/Listener.php#L358-L421
|
223,891
|
thephpleague/phpunit-coverage-listener
|
src/League/PHPUnitCoverageListener/Listener.php
|
Listener.execute
|
protected static function execute($command)
{
$res = array();
ob_start();
passthru($command, $success);
$output = ob_get_clean();
foreach ((explode("\n", $output)) as $line) $res[] = trim($line);
return array_filter($res);
}
|
php
|
protected static function execute($command)
{
$res = array();
ob_start();
passthru($command, $success);
$output = ob_get_clean();
foreach ((explode("\n", $output)) as $line) $res[] = trim($line);
return array_filter($res);
}
|
[
"protected",
"static",
"function",
"execute",
"(",
"$",
"command",
")",
"{",
"$",
"res",
"=",
"array",
"(",
")",
";",
"ob_start",
"(",
")",
";",
"passthru",
"(",
"$",
"command",
",",
"$",
"success",
")",
";",
"$",
"output",
"=",
"ob_get_clean",
"(",
")",
";",
"foreach",
"(",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"output",
")",
")",
"as",
"$",
"line",
")",
"$",
"res",
"[",
"]",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"return",
"array_filter",
"(",
"$",
"res",
")",
";",
"}"
] |
Execute a command and parse the output as array
@param string
@return array
|
[
"Execute",
"a",
"command",
"and",
"parse",
"the",
"output",
"as",
"array"
] |
dbc833a21990973e1182431b42842918595dc20a
|
https://github.com/thephpleague/phpunit-coverage-listener/blob/dbc833a21990973e1182431b42842918595dc20a/src/League/PHPUnitCoverageListener/Listener.php#L429-L440
|
223,892
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Acl/AbstractAcl.php
|
AbstractAcl._setPermission
|
protected function _setPermission(string $pointer, string $mode): void
{
$this->permissions[$pointer] = $mode;
$pointer_with_special_graph = '/^g:([a-f0-9\-]+):$/i';
if(preg_match($pointer_with_special_graph, $pointer, $matches)) {
$this->permissions_with_graph[] = $matches[1];
}
}
|
php
|
protected function _setPermission(string $pointer, string $mode): void
{
$this->permissions[$pointer] = $mode;
$pointer_with_special_graph = '/^g:([a-f0-9\-]+):$/i';
if(preg_match($pointer_with_special_graph, $pointer, $matches)) {
$this->permissions_with_graph[] = $matches[1];
}
}
|
[
"protected",
"function",
"_setPermission",
"(",
"string",
"$",
"pointer",
",",
"string",
"$",
"mode",
")",
":",
"void",
"{",
"$",
"this",
"->",
"permissions",
"[",
"$",
"pointer",
"]",
"=",
"$",
"mode",
";",
"$",
"pointer_with_special_graph",
"=",
"'/^g:([a-f0-9\\-]+):$/i'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pointer_with_special_graph",
",",
"$",
"pointer",
",",
"$",
"matches",
")",
")",
"{",
"$",
"this",
"->",
"permissions_with_graph",
"[",
"]",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"}"
] |
Internal permission setter
**Warning:** This function is for internal use only. To
set up a new permission, use the ```set``` function instead.
This does not perform checks, assumes it was done apriori.
Do not use this function unless you know what you are doing,
use ```set()``` instead.
This function is responsible to make sure the permissions_with_graph
array is filled up properly.
@see set If you need to set permission from outside.
@param string $pointer
@param string $mode
@return void
|
[
"Internal",
"permission",
"setter"
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Acl/AbstractAcl.php#L97-L104
|
223,893
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Acl/AbstractAcl.php
|
AbstractAcl.get
|
public function get(string $entity_pointer): string
{
if(isset($this->permissions[$entity_pointer])) {
return $this->permissions[$entity_pointer];
}
throw new Exceptions\NonExistentAclPointer($entity_pointer, (string) $this->core->id());
}
|
php
|
public function get(string $entity_pointer): string
{
if(isset($this->permissions[$entity_pointer])) {
return $this->permissions[$entity_pointer];
}
throw new Exceptions\NonExistentAclPointer($entity_pointer, (string) $this->core->id());
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"entity_pointer",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"permissions",
"[",
"$",
"entity_pointer",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"permissions",
"[",
"$",
"entity_pointer",
"]",
";",
"}",
"throw",
"new",
"Exceptions",
"\\",
"NonExistentAclPointer",
"(",
"$",
"entity_pointer",
",",
"(",
"string",
")",
"$",
"this",
"->",
"core",
"->",
"id",
"(",
")",
")",
";",
"}"
] |
Retrieves the permissions for this node with the given pointer
@param string $entity_pointer The entity pointer
@return string The permissions in string format
@throws Exceptions\NonExistentAclPointer thrown when there is no such pointer for given node.
|
[
"Retrieves",
"the",
"permissions",
"for",
"this",
"node",
"with",
"the",
"given",
"pointer"
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Acl/AbstractAcl.php#L154-L160
|
223,894
|
phonetworks/pho-microkernel
|
src/Pho/Kernel/Acl/AbstractAcl.php
|
AbstractAcl.del
|
public function del(string $entity_pointer): void
{
$valid_pointer = "/^([ug]):([a-f0-9\-]+):$/i";
if(!preg_match($valid_pointer, $entity_pointer, $matches)) {
throw new Exceptions\InvalidAclPointerException($entity_pointer, $valid_pointer, __FUNCTION__);
}
$type = $matches[1];
$uuid = $matches[2];
// check if uuid points to a actor or graph
// throw exception if $type and actual type don't match
unset($this->permissions[$entity_pointer]);
if($type=="g")
unset($this->permissions_with_graph[array_search($uuid, $this->permissions_with_graph)]);
}
|
php
|
public function del(string $entity_pointer): void
{
$valid_pointer = "/^([ug]):([a-f0-9\-]+):$/i";
if(!preg_match($valid_pointer, $entity_pointer, $matches)) {
throw new Exceptions\InvalidAclPointerException($entity_pointer, $valid_pointer, __FUNCTION__);
}
$type = $matches[1];
$uuid = $matches[2];
// check if uuid points to a actor or graph
// throw exception if $type and actual type don't match
unset($this->permissions[$entity_pointer]);
if($type=="g")
unset($this->permissions_with_graph[array_search($uuid, $this->permissions_with_graph)]);
}
|
[
"public",
"function",
"del",
"(",
"string",
"$",
"entity_pointer",
")",
":",
"void",
"{",
"$",
"valid_pointer",
"=",
"\"/^([ug]):([a-f0-9\\-]+):$/i\"",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"valid_pointer",
",",
"$",
"entity_pointer",
",",
"$",
"matches",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidAclPointerException",
"(",
"$",
"entity_pointer",
",",
"$",
"valid_pointer",
",",
"__FUNCTION__",
")",
";",
"}",
"$",
"type",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"uuid",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"// check if uuid points to a actor or graph ",
"// throw exception if $type and actual type don't match",
"unset",
"(",
"$",
"this",
"->",
"permissions",
"[",
"$",
"entity_pointer",
"]",
")",
";",
"if",
"(",
"$",
"type",
"==",
"\"g\"",
")",
"unset",
"(",
"$",
"this",
"->",
"permissions_with_graph",
"[",
"array_search",
"(",
"$",
"uuid",
",",
"$",
"this",
"->",
"permissions_with_graph",
")",
"]",
")",
";",
"}"
] |
can delete specific users and graphs
|
[
"can",
"delete",
"specific",
"users",
"and",
"graphs"
] |
3983764e4e7cf980bc11d0385f1c6ea57ae723b1
|
https://github.com/phonetworks/pho-microkernel/blob/3983764e4e7cf980bc11d0385f1c6ea57ae723b1/src/Pho/Kernel/Acl/AbstractAcl.php#L182-L195
|
223,895
|
Orajo/zf2-tus-server
|
src/ZfTusServer/Server.php
|
Server.process
|
public function process($send = false) {
try {
$method = $this->getRequest()->getMethod();
switch ($method) {
case 'POST':
if(!$this->checkTusVersion()) {
throw new Exception\Request('The requested protocol version is not supported', \Zend\Http\Response::STATUS_CODE_405);
}
$this->buildUuid();
$this->processPost();
break;
case 'HEAD':
if(!$this->checkTusVersion()) {
throw new Exception\Request('The requested protocol version is not supported', \Zend\Http\Response::STATUS_CODE_405);
}
$this->getUserUuid();
$this->processHead();
break;
case 'PATCH':
if(!$this->checkTusVersion()) {
throw new Exception\Request('The requested protocol version is not supported', \Zend\Http\Response::STATUS_CODE_405);
}
$this->getUserUuid();
$this->processPatch();
break;
case 'OPTIONS':
$this->processOptions();
break;
case 'GET':
$this->getUserUuid();
$this->processGet($send);
break;
default:
throw new Exception\Request('The requested method ' . $method . ' is not allowed', \Zend\Http\Response::STATUS_CODE_405);
}
$this->addCommonHeader($this->getRequest()->isOptions());
if ($send === false) {
return $this->response;
}
}
catch (Exception\BadHeader $e) {
if ($send === false) {
throw $e;
}
$this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_400);
$this->addCommonHeader();
}
catch (Exception\Request $e) {
if ($send === false) {
throw $e;
}
$this->getResponse()->setStatusCode($e->getCode())
->setContent($e->getMessage());
$this->addCommonHeader(true);
}
catch (\Exception $e) {
if ($send === false) {
throw $e;
}
$this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_500)
->setContent($e->getMessage());
$this->addCommonHeader();
}
$this->getResponse()->sendHeaders();
$this->getResponse()->sendContent();
// The process must only sent the HTTP headers and content: kill request after send
exit;
}
|
php
|
public function process($send = false) {
try {
$method = $this->getRequest()->getMethod();
switch ($method) {
case 'POST':
if(!$this->checkTusVersion()) {
throw new Exception\Request('The requested protocol version is not supported', \Zend\Http\Response::STATUS_CODE_405);
}
$this->buildUuid();
$this->processPost();
break;
case 'HEAD':
if(!$this->checkTusVersion()) {
throw new Exception\Request('The requested protocol version is not supported', \Zend\Http\Response::STATUS_CODE_405);
}
$this->getUserUuid();
$this->processHead();
break;
case 'PATCH':
if(!$this->checkTusVersion()) {
throw new Exception\Request('The requested protocol version is not supported', \Zend\Http\Response::STATUS_CODE_405);
}
$this->getUserUuid();
$this->processPatch();
break;
case 'OPTIONS':
$this->processOptions();
break;
case 'GET':
$this->getUserUuid();
$this->processGet($send);
break;
default:
throw new Exception\Request('The requested method ' . $method . ' is not allowed', \Zend\Http\Response::STATUS_CODE_405);
}
$this->addCommonHeader($this->getRequest()->isOptions());
if ($send === false) {
return $this->response;
}
}
catch (Exception\BadHeader $e) {
if ($send === false) {
throw $e;
}
$this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_400);
$this->addCommonHeader();
}
catch (Exception\Request $e) {
if ($send === false) {
throw $e;
}
$this->getResponse()->setStatusCode($e->getCode())
->setContent($e->getMessage());
$this->addCommonHeader(true);
}
catch (\Exception $e) {
if ($send === false) {
throw $e;
}
$this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_500)
->setContent($e->getMessage());
$this->addCommonHeader();
}
$this->getResponse()->sendHeaders();
$this->getResponse()->sendContent();
// The process must only sent the HTTP headers and content: kill request after send
exit;
}
|
[
"public",
"function",
"process",
"(",
"$",
"send",
"=",
"false",
")",
"{",
"try",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getMethod",
"(",
")",
";",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"'POST'",
":",
"if",
"(",
"!",
"$",
"this",
"->",
"checkTusVersion",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The requested protocol version is not supported'",
",",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_405",
")",
";",
"}",
"$",
"this",
"->",
"buildUuid",
"(",
")",
";",
"$",
"this",
"->",
"processPost",
"(",
")",
";",
"break",
";",
"case",
"'HEAD'",
":",
"if",
"(",
"!",
"$",
"this",
"->",
"checkTusVersion",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The requested protocol version is not supported'",
",",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_405",
")",
";",
"}",
"$",
"this",
"->",
"getUserUuid",
"(",
")",
";",
"$",
"this",
"->",
"processHead",
"(",
")",
";",
"break",
";",
"case",
"'PATCH'",
":",
"if",
"(",
"!",
"$",
"this",
"->",
"checkTusVersion",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The requested protocol version is not supported'",
",",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_405",
")",
";",
"}",
"$",
"this",
"->",
"getUserUuid",
"(",
")",
";",
"$",
"this",
"->",
"processPatch",
"(",
")",
";",
"break",
";",
"case",
"'OPTIONS'",
":",
"$",
"this",
"->",
"processOptions",
"(",
")",
";",
"break",
";",
"case",
"'GET'",
":",
"$",
"this",
"->",
"getUserUuid",
"(",
")",
";",
"$",
"this",
"->",
"processGet",
"(",
"$",
"send",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The requested method '",
".",
"$",
"method",
".",
"' is not allowed'",
",",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_405",
")",
";",
"}",
"$",
"this",
"->",
"addCommonHeader",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"isOptions",
"(",
")",
")",
";",
"if",
"(",
"$",
"send",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"response",
";",
"}",
"}",
"catch",
"(",
"Exception",
"\\",
"BadHeader",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"send",
"===",
"false",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_400",
")",
";",
"$",
"this",
"->",
"addCommonHeader",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"\\",
"Request",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"send",
"===",
"false",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
"->",
"setContent",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"addCommonHeader",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"send",
"===",
"false",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_500",
")",
"->",
"setContent",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"addCommonHeader",
"(",
")",
";",
"}",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"sendHeaders",
"(",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"sendContent",
"(",
")",
";",
"// The process must only sent the HTTP headers and content: kill request after send",
"exit",
";",
"}"
] |
Process the client request
@param bool $send True to send the response, false to return the response
@return void|Symfony\Component\HttpFoundation\Response void if send = true else Response object
@throws \\Exception\Request If the method isn't available
@access public
|
[
"Process",
"the",
"client",
"request"
] |
38deebf73e6144217498bfafc3999a0b7e783736
|
https://github.com/Orajo/zf2-tus-server/blob/38deebf73e6144217498bfafc3999a0b7e783736/src/ZfTusServer/Server.php#L73-L154
|
223,896
|
Orajo/zf2-tus-server
|
src/ZfTusServer/Server.php
|
Server.checkTusVersion
|
private function checkTusVersion() {
$tusVersion = $this->getRequest()->getHeader('Tus-Resumable');
if ($tusVersion instanceof \Zend\Http\Header\HeaderInterface) {
return $tusVersion->getFieldValue() === self::TUS_VERSION;
}
return false;
}
|
php
|
private function checkTusVersion() {
$tusVersion = $this->getRequest()->getHeader('Tus-Resumable');
if ($tusVersion instanceof \Zend\Http\Header\HeaderInterface) {
return $tusVersion->getFieldValue() === self::TUS_VERSION;
}
return false;
}
|
[
"private",
"function",
"checkTusVersion",
"(",
")",
"{",
"$",
"tusVersion",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getHeader",
"(",
"'Tus-Resumable'",
")",
";",
"if",
"(",
"$",
"tusVersion",
"instanceof",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Header",
"\\",
"HeaderInterface",
")",
"{",
"return",
"$",
"tusVersion",
"->",
"getFieldValue",
"(",
")",
"===",
"self",
"::",
"TUS_VERSION",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks compatibility with requested Tus protocol
@return boolean
|
[
"Checks",
"compatibility",
"with",
"requested",
"Tus",
"protocol"
] |
38deebf73e6144217498bfafc3999a0b7e783736
|
https://github.com/Orajo/zf2-tus-server/blob/38deebf73e6144217498bfafc3999a0b7e783736/src/ZfTusServer/Server.php#L161-L167
|
223,897
|
Orajo/zf2-tus-server
|
src/ZfTusServer/Server.php
|
Server.processPost
|
private function processPost() {
if ($this->existsInMetaData($this->uuid, 'ID') === true) {
throw new \Exception('The UUID already exists');
}
$headers = $this->extractHeaders(array('Upload-Length', 'Upload-Metadata'));
if (is_numeric($headers['Upload-Length']) === false || $headers['Upload-Length'] < 0) {
throw new Exception\BadHeader('Upload-Length must be a positive integer');
}
$final_length = (int) $headers['Upload-Length'];
$this->setRealFileName($headers['Upload-Metadata']);
$file = $this->directory . $this->getFilename();
if (file_exists($file) === true) {
throw new Exception\File('File already exists : ' . $file);
}
if (touch($file) === false) {
throw new Exception\File('Impossible to touch ' . $file);
}
$this->setMetaDataValue($this->uuid, 'ID', $this->uuid);
$this->saveMetaData($final_length, 0, false, true);
$this->getResponse()->setStatusCode(201);
$uri = $this->getRequest()->getUri();
$this->getResponse()->setHeaders(
(new \Zend\Http\Headers())->addHeaderLine('Location', $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath() . '/' . $this->uuid)
);
unset($uri);
}
|
php
|
private function processPost() {
if ($this->existsInMetaData($this->uuid, 'ID') === true) {
throw new \Exception('The UUID already exists');
}
$headers = $this->extractHeaders(array('Upload-Length', 'Upload-Metadata'));
if (is_numeric($headers['Upload-Length']) === false || $headers['Upload-Length'] < 0) {
throw new Exception\BadHeader('Upload-Length must be a positive integer');
}
$final_length = (int) $headers['Upload-Length'];
$this->setRealFileName($headers['Upload-Metadata']);
$file = $this->directory . $this->getFilename();
if (file_exists($file) === true) {
throw new Exception\File('File already exists : ' . $file);
}
if (touch($file) === false) {
throw new Exception\File('Impossible to touch ' . $file);
}
$this->setMetaDataValue($this->uuid, 'ID', $this->uuid);
$this->saveMetaData($final_length, 0, false, true);
$this->getResponse()->setStatusCode(201);
$uri = $this->getRequest()->getUri();
$this->getResponse()->setHeaders(
(new \Zend\Http\Headers())->addHeaderLine('Location', $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath() . '/' . $this->uuid)
);
unset($uri);
}
|
[
"private",
"function",
"processPost",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"existsInMetaData",
"(",
"$",
"this",
"->",
"uuid",
",",
"'ID'",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The UUID already exists'",
")",
";",
"}",
"$",
"headers",
"=",
"$",
"this",
"->",
"extractHeaders",
"(",
"array",
"(",
"'Upload-Length'",
",",
"'Upload-Metadata'",
")",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"headers",
"[",
"'Upload-Length'",
"]",
")",
"===",
"false",
"||",
"$",
"headers",
"[",
"'Upload-Length'",
"]",
"<",
"0",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"BadHeader",
"(",
"'Upload-Length must be a positive integer'",
")",
";",
"}",
"$",
"final_length",
"=",
"(",
"int",
")",
"$",
"headers",
"[",
"'Upload-Length'",
"]",
";",
"$",
"this",
"->",
"setRealFileName",
"(",
"$",
"headers",
"[",
"'Upload-Metadata'",
"]",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"directory",
".",
"$",
"this",
"->",
"getFilename",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"File",
"(",
"'File already exists : '",
".",
"$",
"file",
")",
";",
"}",
"if",
"(",
"touch",
"(",
"$",
"file",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"File",
"(",
"'Impossible to touch '",
".",
"$",
"file",
")",
";",
"}",
"$",
"this",
"->",
"setMetaDataValue",
"(",
"$",
"this",
"->",
"uuid",
",",
"'ID'",
",",
"$",
"this",
"->",
"uuid",
")",
";",
"$",
"this",
"->",
"saveMetaData",
"(",
"$",
"final_length",
",",
"0",
",",
"false",
",",
"true",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"201",
")",
";",
"$",
"uri",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getUri",
"(",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setHeaders",
"(",
"(",
"new",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Headers",
"(",
")",
")",
"->",
"addHeaderLine",
"(",
"'Location'",
",",
"$",
"uri",
"->",
"getScheme",
"(",
")",
".",
"'://'",
".",
"$",
"uri",
"->",
"getHost",
"(",
")",
".",
"$",
"uri",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"uuid",
")",
")",
";",
"unset",
"(",
"$",
"uri",
")",
";",
"}"
] |
Process the POST request
@throws \Exception If the uuid already exists
@throws \ZfTusServer\Exception\BadHeader If the final length header isn't a positive integer
@throws \ZfTusServer\Exception\File If the file already exists in the filesystem
@throws \ZfTusServer\Exception\File If the creation of file failed
|
[
"Process",
"the",
"POST",
"request"
] |
38deebf73e6144217498bfafc3999a0b7e783736
|
https://github.com/Orajo/zf2-tus-server/blob/38deebf73e6144217498bfafc3999a0b7e783736/src/ZfTusServer/Server.php#L207-L244
|
223,898
|
Orajo/zf2-tus-server
|
src/ZfTusServer/Server.php
|
Server.processHead
|
private function processHead() {
if ($this->existsInMetaData($this->uuid, 'ID') === false) {
$this->getResponse()->setStatusCode(PhpResponse::STATUS_CODE_404);
return;
}
// if file in storage does not exists
if (!file_exists($this->directory . $this->getFilename())) {
// allow new upload
$this->removeFromMetaData($this->uuid);
$this->getResponse()->setStatusCode(PhpResponse::STATUS_CODE_404);
return;
}
$this->getResponse()->setStatusCode(PhpResponse::STATUS_CODE_200);
$offset = $this->getMetaDataValue($this->uuid, 'Offset');
$headers = $this->getResponse()->getHeaders();
$headers->addHeaderLine('Upload-Offset', $offset);
$length = $this->getMetaDataValue($this->uuid, 'Size');
$headers->addHeaderLine('Upload-Length', $length);
$headers->addHeaderLine('Cache-Control', 'no-store');
}
|
php
|
private function processHead() {
if ($this->existsInMetaData($this->uuid, 'ID') === false) {
$this->getResponse()->setStatusCode(PhpResponse::STATUS_CODE_404);
return;
}
// if file in storage does not exists
if (!file_exists($this->directory . $this->getFilename())) {
// allow new upload
$this->removeFromMetaData($this->uuid);
$this->getResponse()->setStatusCode(PhpResponse::STATUS_CODE_404);
return;
}
$this->getResponse()->setStatusCode(PhpResponse::STATUS_CODE_200);
$offset = $this->getMetaDataValue($this->uuid, 'Offset');
$headers = $this->getResponse()->getHeaders();
$headers->addHeaderLine('Upload-Offset', $offset);
$length = $this->getMetaDataValue($this->uuid, 'Size');
$headers->addHeaderLine('Upload-Length', $length);
$headers->addHeaderLine('Cache-Control', 'no-store');
}
|
[
"private",
"function",
"processHead",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"existsInMetaData",
"(",
"$",
"this",
"->",
"uuid",
",",
"'ID'",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"PhpResponse",
"::",
"STATUS_CODE_404",
")",
";",
"return",
";",
"}",
"// if file in storage does not exists",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"directory",
".",
"$",
"this",
"->",
"getFilename",
"(",
")",
")",
")",
"{",
"// allow new upload",
"$",
"this",
"->",
"removeFromMetaData",
"(",
"$",
"this",
"->",
"uuid",
")",
";",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"PhpResponse",
"::",
"STATUS_CODE_404",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"setStatusCode",
"(",
"PhpResponse",
"::",
"STATUS_CODE_200",
")",
";",
"$",
"offset",
"=",
"$",
"this",
"->",
"getMetaDataValue",
"(",
"$",
"this",
"->",
"uuid",
",",
"'Offset'",
")",
";",
"$",
"headers",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"getHeaders",
"(",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Upload-Offset'",
",",
"$",
"offset",
")",
";",
"$",
"length",
"=",
"$",
"this",
"->",
"getMetaDataValue",
"(",
"$",
"this",
"->",
"uuid",
",",
"'Size'",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Upload-Length'",
",",
"$",
"length",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Cache-Control'",
",",
"'no-store'",
")",
";",
"}"
] |
Process the HEAD request
@link http://tus.io/protocols/resumable-upload.html#head Description of this reuest type
@throws \Exception If the uuid isn't know
|
[
"Process",
"the",
"HEAD",
"request"
] |
38deebf73e6144217498bfafc3999a0b7e783736
|
https://github.com/Orajo/zf2-tus-server/blob/38deebf73e6144217498bfafc3999a0b7e783736/src/ZfTusServer/Server.php#L253-L277
|
223,899
|
Orajo/zf2-tus-server
|
src/ZfTusServer/Server.php
|
Server.processGet
|
private function processGet($send) {
if (!$this->allowGetMethod) {
throw new Exception\Request('The requested method ' . $method . ' is not allowed', \Zend\Http\Response::STATUS_CODE_405);
}
$file = $this->directory . $this->getFilename();
if (!file_exists($file)) {
throw new Exception\Request('The file ' . $this->uuid . ' doesn\'t exist', 404);
}
if (!is_readable($file)) {
throw new Exception\Request('The file ' . $this->uuid . ' is unaccessible', 403);
}
if (!file_exists($file . '.info') || !is_readable($file . '.info')) {
throw new Exception\Request('The file ' . $this->uuid . ' has no metadata', 500);
}
$fileName = $this->getMetaDataValue($file, 'FileName');
if ($this->debugMode) {
$isInfo = $this->getRequest()->getQuery('info', -1);
if ($isInfo !== -1) {
FileToolsService::downloadFile($file . '.info', $fileName . '.info');
}
else {
$mime = FileToolsService::detectMimeType($file);
FileToolsService::downloadFile($file, $fileName, $mime);
}
}
else {
$mime = FileToolsService::detectMimeType($file);
FileToolsService::downloadFile($file, $fileName, $mime);
}
exit;
}
|
php
|
private function processGet($send) {
if (!$this->allowGetMethod) {
throw new Exception\Request('The requested method ' . $method . ' is not allowed', \Zend\Http\Response::STATUS_CODE_405);
}
$file = $this->directory . $this->getFilename();
if (!file_exists($file)) {
throw new Exception\Request('The file ' . $this->uuid . ' doesn\'t exist', 404);
}
if (!is_readable($file)) {
throw new Exception\Request('The file ' . $this->uuid . ' is unaccessible', 403);
}
if (!file_exists($file . '.info') || !is_readable($file . '.info')) {
throw new Exception\Request('The file ' . $this->uuid . ' has no metadata', 500);
}
$fileName = $this->getMetaDataValue($file, 'FileName');
if ($this->debugMode) {
$isInfo = $this->getRequest()->getQuery('info', -1);
if ($isInfo !== -1) {
FileToolsService::downloadFile($file . '.info', $fileName . '.info');
}
else {
$mime = FileToolsService::detectMimeType($file);
FileToolsService::downloadFile($file, $fileName, $mime);
}
}
else {
$mime = FileToolsService::detectMimeType($file);
FileToolsService::downloadFile($file, $fileName, $mime);
}
exit;
}
|
[
"private",
"function",
"processGet",
"(",
"$",
"send",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"allowGetMethod",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The requested method '",
".",
"$",
"method",
".",
"' is not allowed'",
",",
"\\",
"Zend",
"\\",
"Http",
"\\",
"Response",
"::",
"STATUS_CODE_405",
")",
";",
"}",
"$",
"file",
"=",
"$",
"this",
"->",
"directory",
".",
"$",
"this",
"->",
"getFilename",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The file '",
".",
"$",
"this",
"->",
"uuid",
".",
"' doesn\\'t exist'",
",",
"404",
")",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The file '",
".",
"$",
"this",
"->",
"uuid",
".",
"' is unaccessible'",
",",
"403",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
".",
"'.info'",
")",
"||",
"!",
"is_readable",
"(",
"$",
"file",
".",
"'.info'",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"Request",
"(",
"'The file '",
".",
"$",
"this",
"->",
"uuid",
".",
"' has no metadata'",
",",
"500",
")",
";",
"}",
"$",
"fileName",
"=",
"$",
"this",
"->",
"getMetaDataValue",
"(",
"$",
"file",
",",
"'FileName'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debugMode",
")",
"{",
"$",
"isInfo",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
"'info'",
",",
"-",
"1",
")",
";",
"if",
"(",
"$",
"isInfo",
"!==",
"-",
"1",
")",
"{",
"FileToolsService",
"::",
"downloadFile",
"(",
"$",
"file",
".",
"'.info'",
",",
"$",
"fileName",
".",
"'.info'",
")",
";",
"}",
"else",
"{",
"$",
"mime",
"=",
"FileToolsService",
"::",
"detectMimeType",
"(",
"$",
"file",
")",
";",
"FileToolsService",
"::",
"downloadFile",
"(",
"$",
"file",
",",
"$",
"fileName",
",",
"$",
"mime",
")",
";",
"}",
"}",
"else",
"{",
"$",
"mime",
"=",
"FileToolsService",
"::",
"detectMimeType",
"(",
"$",
"file",
")",
";",
"FileToolsService",
"::",
"downloadFile",
"(",
"$",
"file",
",",
"$",
"fileName",
",",
"$",
"mime",
")",
";",
"}",
"exit",
";",
"}"
] |
Process the GET request
FIXME: check and eventually remove $send param
@param bool $send Description
@access private
|
[
"Process",
"the",
"GET",
"request"
] |
38deebf73e6144217498bfafc3999a0b7e783736
|
https://github.com/Orajo/zf2-tus-server/blob/38deebf73e6144217498bfafc3999a0b7e783736/src/ZfTusServer/Server.php#L468-L502
|
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.