id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
3,500 | phlexible/phlexible | src/Phlexible/Bundle/DashboardBundle/Portlet/Portlet.php | Portlet.toArray | public function toArray()
{
return array(
'id' => $this->getId(),
'title' => $this->getTitle(),
'class' => $this->getClass(),
'iconCls' => $this->getIconClass(),
'data' => $this->getData(),
'settings' => $this->getSettings(),
);
} | php | public function toArray()
{
return array(
'id' => $this->getId(),
'title' => $this->getTitle(),
'class' => $this->getClass(),
'iconCls' => $this->getIconClass(),
'data' => $this->getData(),
'settings' => $this->getSettings(),
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"'title'",
"=>",
"$",
"this",
"->",
"getTitle",
"(",
")",
",",
"'class'",
"=>",
"$",
"this",
"->",
"getClass",
"(",
")",
",",
"'iconCls'",
"=>",
"$",
"this",
"->",
"getIconClass",
"(",
")",
",",
"'data'",
"=>",
"$",
"this",
"->",
"getData",
"(",
")",
",",
"'settings'",
"=>",
"$",
"this",
"->",
"getSettings",
"(",
")",
",",
")",
";",
"}"
] | Return array representation of this portlet.
@return array | [
"Return",
"array",
"representation",
"of",
"this",
"portlet",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/DashboardBundle/Portlet/Portlet.php#L180-L190 |
3,501 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.get | public function get(
$uri,
array $parameters = [],
array $headers = [],
string $protocol = '1.1'
): ResponseInterface {
$promise = $this->getAsync($uri, $parameters, $headers, $protocol);
$promise->wait();
if ($promise->getState() === Promise::REJECTED) {
throw $promise->getException();
}
return $promise->getResponse();
} | php | public function get(
$uri,
array $parameters = [],
array $headers = [],
string $protocol = '1.1'
): ResponseInterface {
$promise = $this->getAsync($uri, $parameters, $headers, $protocol);
$promise->wait();
if ($promise->getState() === Promise::REJECTED) {
throw $promise->getException();
}
return $promise->getResponse();
} | [
"public",
"function",
"get",
"(",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"ResponseInterface",
"{",
"$",
"promise",
"=",
"$",
"this",
"->",
"getAsync",
"(",
"$",
"uri",
",",
"$",
"parameters",
",",
"$",
"headers",
",",
"$",
"protocol",
")",
";",
"$",
"promise",
"->",
"wait",
"(",
")",
";",
"if",
"(",
"$",
"promise",
"->",
"getState",
"(",
")",
"===",
"Promise",
"::",
"REJECTED",
")",
"{",
"throw",
"$",
"promise",
"->",
"getException",
"(",
")",
";",
"}",
"return",
"$",
"promise",
"->",
"getResponse",
"(",
")",
";",
"}"
] | Sends a GET request
@param string|UriInterface $uri Request URI
@param array $parameters Query parameters
@param array $headers Request headers
@param string $protocol Protocol version
@return ResponseInterface
@throws Throwable When an error occurs | [
"Sends",
"a",
"GET",
"request"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L96-L110 |
3,502 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.getAsync | public function getAsync(
$uri,
array $parameters = [],
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createQueryRequest(
static::METHOD_GET,
$uri,
$parameters,
$headers,
$protocol
);
return $this->sendAsync($request);
} | php | public function getAsync(
$uri,
array $parameters = [],
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createQueryRequest(
static::METHOD_GET,
$uri,
$parameters,
$headers,
$protocol
);
return $this->sendAsync($request);
} | [
"public",
"function",
"getAsync",
"(",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"Promise",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createQueryRequest",
"(",
"static",
"::",
"METHOD_GET",
",",
"$",
"uri",
",",
"$",
"parameters",
",",
"$",
"headers",
",",
"$",
"protocol",
")",
";",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"request",
")",
";",
"}"
] | Sends a GET request asynchronously
@param string|UriInterface $uri Request URI
@param array $parameters Query parameters
@param array $headers Request headers
@param string $protocol Protocol version
@return Promise | [
"Sends",
"a",
"GET",
"request",
"asynchronously"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L242-L257 |
3,503 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.postAsync | public function postAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_POST,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | php | public function postAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_POST,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | [
"public",
"function",
"postAsync",
"(",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"?",
"ContentType",
"$",
"contentType",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"Promise",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createBodyRequest",
"(",
"static",
"::",
"METHOD_POST",
",",
"$",
"uri",
",",
"$",
"parameters",
",",
"$",
"contentType",
",",
"$",
"headers",
",",
"$",
"protocol",
")",
";",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"request",
")",
";",
"}"
] | Sends a POST request asynchronously
@param string|UriInterface $uri Request URI
@param array $parameters Body parameters
@param ContentType|null $contentType The content type
@param array $headers Request headers
@param string $protocol Protocol version
@return Promise | [
"Sends",
"a",
"POST",
"request",
"asynchronously"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L270-L287 |
3,504 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.putAsync | public function putAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_PUT,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | php | public function putAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_PUT,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | [
"public",
"function",
"putAsync",
"(",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"?",
"ContentType",
"$",
"contentType",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"Promise",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createBodyRequest",
"(",
"static",
"::",
"METHOD_PUT",
",",
"$",
"uri",
",",
"$",
"parameters",
",",
"$",
"contentType",
",",
"$",
"headers",
",",
"$",
"protocol",
")",
";",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"request",
")",
";",
"}"
] | Sends a PUT request asynchronously
@param string|UriInterface $uri Request URI
@param array $parameters Query parameters
@param ContentType|null $contentType The content type
@param array $headers Request headers
@param string $protocol Protocol version
@return Promise | [
"Sends",
"a",
"PUT",
"request",
"asynchronously"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L300-L317 |
3,505 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.patchAsync | public function patchAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_PATCH,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | php | public function patchAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_PATCH,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | [
"public",
"function",
"patchAsync",
"(",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"?",
"ContentType",
"$",
"contentType",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"Promise",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createBodyRequest",
"(",
"static",
"::",
"METHOD_PATCH",
",",
"$",
"uri",
",",
"$",
"parameters",
",",
"$",
"contentType",
",",
"$",
"headers",
",",
"$",
"protocol",
")",
";",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"request",
")",
";",
"}"
] | Sends a PATCH request asynchronously
@param string|UriInterface $uri Request URI
@param array $parameters Query parameters
@param ContentType|null $contentType The content type
@param array $headers Request headers
@param string $protocol Protocol version
@return Promise | [
"Sends",
"a",
"PATCH",
"request",
"asynchronously"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L330-L347 |
3,506 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.deleteAsync | public function deleteAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_DELETE,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | php | public function deleteAsync(
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): Promise {
$request = $this->createBodyRequest(
static::METHOD_DELETE,
$uri,
$parameters,
$contentType,
$headers,
$protocol
);
return $this->sendAsync($request);
} | [
"public",
"function",
"deleteAsync",
"(",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"?",
"ContentType",
"$",
"contentType",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"Promise",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"createBodyRequest",
"(",
"static",
"::",
"METHOD_DELETE",
",",
"$",
"uri",
",",
"$",
"parameters",
",",
"$",
"contentType",
",",
"$",
"headers",
",",
"$",
"protocol",
")",
";",
"return",
"$",
"this",
"->",
"sendAsync",
"(",
"$",
"request",
")",
";",
"}"
] | Sends a DELETE request asynchronously
@param string|UriInterface $uri Request URI
@param array $parameters Query parameters
@param ContentType|null $contentType The content type
@param array $headers Request headers
@param string $protocol Protocol version
@return Promise | [
"Sends",
"a",
"DELETE",
"request",
"asynchronously"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L360-L377 |
3,507 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.createQueryRequest | protected function createQueryRequest(
string $method,
$uri,
array $parameters = [],
array $headers = [],
string $protocol = '1.1'
): RequestInterface {
$uri = $this->createUri($uri);
if (!empty($parameters)) {
$queryString = http_build_query($parameters);
if ($uri->getQuery() === '') {
$uri = $uri->withQuery($queryString);
} else {
$uri = $uri->withQuery($uri->getQuery().'&'.$queryString);
}
}
return $this->createRequest($method, $uri, $headers, null, $protocol);
} | php | protected function createQueryRequest(
string $method,
$uri,
array $parameters = [],
array $headers = [],
string $protocol = '1.1'
): RequestInterface {
$uri = $this->createUri($uri);
if (!empty($parameters)) {
$queryString = http_build_query($parameters);
if ($uri->getQuery() === '') {
$uri = $uri->withQuery($queryString);
} else {
$uri = $uri->withQuery($uri->getQuery().'&'.$queryString);
}
}
return $this->createRequest($method, $uri, $headers, null, $protocol);
} | [
"protected",
"function",
"createQueryRequest",
"(",
"string",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"RequestInterface",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"createUri",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"queryString",
"=",
"http_build_query",
"(",
"$",
"parameters",
")",
";",
"if",
"(",
"$",
"uri",
"->",
"getQuery",
"(",
")",
"===",
"''",
")",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"$",
"queryString",
")",
";",
"}",
"else",
"{",
"$",
"uri",
"=",
"$",
"uri",
"->",
"withQuery",
"(",
"$",
"uri",
"->",
"getQuery",
"(",
")",
".",
"'&'",
".",
"$",
"queryString",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"createRequest",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"headers",
",",
"null",
",",
"$",
"protocol",
")",
";",
"}"
] | Creates a query request
@param string $method Request method
@param string|UriInterface $uri Request URI
@param array $parameters Query parameters
@param array $headers Request headers
@param string $protocol Protocol version
@return RequestInterface | [
"Creates",
"a",
"query",
"request"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L448-L467 |
3,508 | novuso/common | src/Application/HttpClient/HttpService.php | HttpService.createBodyRequest | protected function createBodyRequest(
string $method,
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): RequestInterface {
if ($contentType === null) {
$contentType = ContentType::fromValue(ContentType::FORM);
}
$body = null;
if (!empty($parameters)) {
switch ($contentType->value()) {
case ContentType::FORM:
$body = http_build_query($parameters);
break;
case ContentType::JSON:
$body = json_encode($parameters);
break;
default:
break;
}
}
if ($body !== null) {
$headers = array_merge(['Content-Type' => $contentType->value()], $headers);
}
$uri = $this->createUri($uri);
$body = $this->createStream($body);
return $this->createRequest($method, $uri, $headers, $body, $protocol);
} | php | protected function createBodyRequest(
string $method,
$uri,
array $parameters = [],
?ContentType $contentType = null,
array $headers = [],
string $protocol = '1.1'
): RequestInterface {
if ($contentType === null) {
$contentType = ContentType::fromValue(ContentType::FORM);
}
$body = null;
if (!empty($parameters)) {
switch ($contentType->value()) {
case ContentType::FORM:
$body = http_build_query($parameters);
break;
case ContentType::JSON:
$body = json_encode($parameters);
break;
default:
break;
}
}
if ($body !== null) {
$headers = array_merge(['Content-Type' => $contentType->value()], $headers);
}
$uri = $this->createUri($uri);
$body = $this->createStream($body);
return $this->createRequest($method, $uri, $headers, $body, $protocol);
} | [
"protected",
"function",
"createBodyRequest",
"(",
"string",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"?",
"ContentType",
"$",
"contentType",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"string",
"$",
"protocol",
"=",
"'1.1'",
")",
":",
"RequestInterface",
"{",
"if",
"(",
"$",
"contentType",
"===",
"null",
")",
"{",
"$",
"contentType",
"=",
"ContentType",
"::",
"fromValue",
"(",
"ContentType",
"::",
"FORM",
")",
";",
"}",
"$",
"body",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"switch",
"(",
"$",
"contentType",
"->",
"value",
"(",
")",
")",
"{",
"case",
"ContentType",
"::",
"FORM",
":",
"$",
"body",
"=",
"http_build_query",
"(",
"$",
"parameters",
")",
";",
"break",
";",
"case",
"ContentType",
"::",
"JSON",
":",
"$",
"body",
"=",
"json_encode",
"(",
"$",
"parameters",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"body",
"!==",
"null",
")",
"{",
"$",
"headers",
"=",
"array_merge",
"(",
"[",
"'Content-Type'",
"=>",
"$",
"contentType",
"->",
"value",
"(",
")",
"]",
",",
"$",
"headers",
")",
";",
"}",
"$",
"uri",
"=",
"$",
"this",
"->",
"createUri",
"(",
"$",
"uri",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"createStream",
"(",
"$",
"body",
")",
";",
"return",
"$",
"this",
"->",
"createRequest",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"headers",
",",
"$",
"body",
",",
"$",
"protocol",
")",
";",
"}"
] | Creates a body request
@param string $method Request method
@param string|UriInterface $uri Request URI
@param array $parameters Body parameters
@param ContentType|null $contentType The content type
@param array $headers Request headers
@param string $protocol Protocol version
@return RequestInterface | [
"Creates",
"a",
"body",
"request"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/HttpClient/HttpService.php#L481-L515 |
3,509 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.initFromItemClass | public static function initFromItemClass($itemClass)
{
$itemMetaData = new ItemMetaData();
$itemMetaData->setItemClass($itemClass);
$contruct = new ReflectionMethod($itemClass, '__construct');
/* @var $param \ReflectionParameter */
foreach($contruct->getParameters() as $key => $param)
{
$itemMetaData->setHitPosition($param->getName(), $key);
if(!$param->isOptional())
{
$itemMetaData->addRequiredHit($param->getName());
}
}
return $itemMetaData;
} | php | public static function initFromItemClass($itemClass)
{
$itemMetaData = new ItemMetaData();
$itemMetaData->setItemClass($itemClass);
$contruct = new ReflectionMethod($itemClass, '__construct');
/* @var $param \ReflectionParameter */
foreach($contruct->getParameters() as $key => $param)
{
$itemMetaData->setHitPosition($param->getName(), $key);
if(!$param->isOptional())
{
$itemMetaData->addRequiredHit($param->getName());
}
}
return $itemMetaData;
} | [
"public",
"static",
"function",
"initFromItemClass",
"(",
"$",
"itemClass",
")",
"{",
"$",
"itemMetaData",
"=",
"new",
"ItemMetaData",
"(",
")",
";",
"$",
"itemMetaData",
"->",
"setItemClass",
"(",
"$",
"itemClass",
")",
";",
"$",
"contruct",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"itemClass",
",",
"'__construct'",
")",
";",
"/* @var $param \\ReflectionParameter */",
"foreach",
"(",
"$",
"contruct",
"->",
"getParameters",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"param",
")",
"{",
"$",
"itemMetaData",
"->",
"setHitPosition",
"(",
"$",
"param",
"->",
"getName",
"(",
")",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"param",
"->",
"isOptional",
"(",
")",
")",
"{",
"$",
"itemMetaData",
"->",
"addRequiredHit",
"(",
"$",
"param",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"itemMetaData",
";",
"}"
] | Initializes a new View instance that will hold the object-relational
mapping of the class with the given name.
@param string $itemClass The name of the item class the new instance is used for.
return ItemMetaData | [
"Initializes",
"a",
"new",
"View",
"instance",
"that",
"will",
"hold",
"the",
"object",
"-",
"relational",
"mapping",
"of",
"the",
"class",
"with",
"the",
"given",
"name",
"."
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L104-L119 |
3,510 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.validateAndCompleteEntity | protected function validateAndCompleteEntity($entityIdentifier, $entityDefinition)
{
if(!isset($entityDefinition['label']))
{
throw MappingException::requiredMapping($this->itemClass, 'label', $entityIdentifier);
}
elseif(!settype($entityDefinition['label'], 'string'))
{
throw MappingException::invalidMappingType($this->itemClass, 'label', 'string', $entityIdentifier);
}
else
{
$this->entityLabels[$entityIdentifier] = $entityDefinition['label'];
}
if(!isset($entityDefinition['entityClass']))
{
throw MappingException::requiredMapping($this->itemClass, 'entityClass', $entityIdentifier);
}
elseif(!settype($entityDefinition['entityClass'], 'string'))
{
throw MappingException::invalidMappingType($this->itemClass, 'entityClass', 'string', $entityIdentifier);
}
else
{
$this->entityClasses[$entityIdentifier] = $entityDefinition['entityClass'];
}
} | php | protected function validateAndCompleteEntity($entityIdentifier, $entityDefinition)
{
if(!isset($entityDefinition['label']))
{
throw MappingException::requiredMapping($this->itemClass, 'label', $entityIdentifier);
}
elseif(!settype($entityDefinition['label'], 'string'))
{
throw MappingException::invalidMappingType($this->itemClass, 'label', 'string', $entityIdentifier);
}
else
{
$this->entityLabels[$entityIdentifier] = $entityDefinition['label'];
}
if(!isset($entityDefinition['entityClass']))
{
throw MappingException::requiredMapping($this->itemClass, 'entityClass', $entityIdentifier);
}
elseif(!settype($entityDefinition['entityClass'], 'string'))
{
throw MappingException::invalidMappingType($this->itemClass, 'entityClass', 'string', $entityIdentifier);
}
else
{
$this->entityClasses[$entityIdentifier] = $entityDefinition['entityClass'];
}
} | [
"protected",
"function",
"validateAndCompleteEntity",
"(",
"$",
"entityIdentifier",
",",
"$",
"entityDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entityDefinition",
"[",
"'label'",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"requiredMapping",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'label'",
",",
"$",
"entityIdentifier",
")",
";",
"}",
"elseif",
"(",
"!",
"settype",
"(",
"$",
"entityDefinition",
"[",
"'label'",
"]",
",",
"'string'",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidMappingType",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'label'",
",",
"'string'",
",",
"$",
"entityIdentifier",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"entityLabels",
"[",
"$",
"entityIdentifier",
"]",
"=",
"$",
"entityDefinition",
"[",
"'label'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"entityDefinition",
"[",
"'entityClass'",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"requiredMapping",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'entityClass'",
",",
"$",
"entityIdentifier",
")",
";",
"}",
"elseif",
"(",
"!",
"settype",
"(",
"$",
"entityDefinition",
"[",
"'entityClass'",
"]",
",",
"'string'",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidMappingType",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'entityClass'",
",",
"'string'",
",",
"$",
"entityIdentifier",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"entityClasses",
"[",
"$",
"entityIdentifier",
"]",
"=",
"$",
"entityDefinition",
"[",
"'entityClass'",
"]",
";",
"}",
"}"
] | Validates & completes the given entity definition.
@param string $entityIdentifier
@param array $entityDefinition
@throws MappingException | [
"Validates",
"&",
"completes",
"the",
"given",
"entity",
"definition",
"."
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L189-L216 |
3,511 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.validateAndCompleteHit | protected function validateAndCompleteHit($hitIdentifier, array &$hitDefinition)
{
$this->addRequiredHit($hitIdentifier);
if(!isset($hitDefinition['scoreFactor']))
{
$this->setHitScoreFactor($hitIdentifier, 1);
}
elseif(!settype($hitDefinition['scoreFactor'], 'integer'))
{
throw MappingException::invalidMappingType($this->itemClass, 'scoreFactor', 'integer', $hitIdentifier);
}
else
{
$this->setHitScoreFactor($hitIdentifier, $hitDefinition['scoreFactor']);
}
//Defaut non sortable, non added to $this->sortableHits
if(isset($hitDefinition['sortable']) && !settype($hitDefinition['sortable'], 'boolean'))
{
throw MappingException::invalidMappingType($this->itemClass, 'sortable', 'boolean', $hitIdentifier);
}
elseif(isset($hitDefinition['sortable']) && $hitDefinition['sortable'] === true)
{
$this->addSortableHit($hitIdentifier);
}
if(!isset($hitDefinition['label']))
{
throw MappingException::requiredMapping($this->itemClass, 'label', $hitIdentifier);
}
elseif(!settype($hitDefinition['label'], 'string'))
{
throw MappingException::invalidMappingType($this->itemClass, 'label', 'string', $hitIdentifier);
}
else
{
$this->hitLabels[$hitIdentifier] = $hitDefinition['label'];
}
foreach($hitDefinition['mapping'] as $entityIdentifier => $attribute)
{
$this->setHitEntityAttribute($hitIdentifier, $entityIdentifier, $attribute);
}
} | php | protected function validateAndCompleteHit($hitIdentifier, array &$hitDefinition)
{
$this->addRequiredHit($hitIdentifier);
if(!isset($hitDefinition['scoreFactor']))
{
$this->setHitScoreFactor($hitIdentifier, 1);
}
elseif(!settype($hitDefinition['scoreFactor'], 'integer'))
{
throw MappingException::invalidMappingType($this->itemClass, 'scoreFactor', 'integer', $hitIdentifier);
}
else
{
$this->setHitScoreFactor($hitIdentifier, $hitDefinition['scoreFactor']);
}
//Defaut non sortable, non added to $this->sortableHits
if(isset($hitDefinition['sortable']) && !settype($hitDefinition['sortable'], 'boolean'))
{
throw MappingException::invalidMappingType($this->itemClass, 'sortable', 'boolean', $hitIdentifier);
}
elseif(isset($hitDefinition['sortable']) && $hitDefinition['sortable'] === true)
{
$this->addSortableHit($hitIdentifier);
}
if(!isset($hitDefinition['label']))
{
throw MappingException::requiredMapping($this->itemClass, 'label', $hitIdentifier);
}
elseif(!settype($hitDefinition['label'], 'string'))
{
throw MappingException::invalidMappingType($this->itemClass, 'label', 'string', $hitIdentifier);
}
else
{
$this->hitLabels[$hitIdentifier] = $hitDefinition['label'];
}
foreach($hitDefinition['mapping'] as $entityIdentifier => $attribute)
{
$this->setHitEntityAttribute($hitIdentifier, $entityIdentifier, $attribute);
}
} | [
"protected",
"function",
"validateAndCompleteHit",
"(",
"$",
"hitIdentifier",
",",
"array",
"&",
"$",
"hitDefinition",
")",
"{",
"$",
"this",
"->",
"addRequiredHit",
"(",
"$",
"hitIdentifier",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"hitDefinition",
"[",
"'scoreFactor'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setHitScoreFactor",
"(",
"$",
"hitIdentifier",
",",
"1",
")",
";",
"}",
"elseif",
"(",
"!",
"settype",
"(",
"$",
"hitDefinition",
"[",
"'scoreFactor'",
"]",
",",
"'integer'",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidMappingType",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'scoreFactor'",
",",
"'integer'",
",",
"$",
"hitIdentifier",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setHitScoreFactor",
"(",
"$",
"hitIdentifier",
",",
"$",
"hitDefinition",
"[",
"'scoreFactor'",
"]",
")",
";",
"}",
"//Defaut non sortable, non added to $this->sortableHits",
"if",
"(",
"isset",
"(",
"$",
"hitDefinition",
"[",
"'sortable'",
"]",
")",
"&&",
"!",
"settype",
"(",
"$",
"hitDefinition",
"[",
"'sortable'",
"]",
",",
"'boolean'",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidMappingType",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'sortable'",
",",
"'boolean'",
",",
"$",
"hitIdentifier",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"hitDefinition",
"[",
"'sortable'",
"]",
")",
"&&",
"$",
"hitDefinition",
"[",
"'sortable'",
"]",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"addSortableHit",
"(",
"$",
"hitIdentifier",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"hitDefinition",
"[",
"'label'",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"requiredMapping",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'label'",
",",
"$",
"hitIdentifier",
")",
";",
"}",
"elseif",
"(",
"!",
"settype",
"(",
"$",
"hitDefinition",
"[",
"'label'",
"]",
",",
"'string'",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidMappingType",
"(",
"$",
"this",
"->",
"itemClass",
",",
"'label'",
",",
"'string'",
",",
"$",
"hitIdentifier",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"hitLabels",
"[",
"$",
"hitIdentifier",
"]",
"=",
"$",
"hitDefinition",
"[",
"'label'",
"]",
";",
"}",
"foreach",
"(",
"$",
"hitDefinition",
"[",
"'mapping'",
"]",
"as",
"$",
"entityIdentifier",
"=>",
"$",
"attribute",
")",
"{",
"$",
"this",
"->",
"setHitEntityAttribute",
"(",
"$",
"hitIdentifier",
",",
"$",
"entityIdentifier",
",",
"$",
"attribute",
")",
";",
"}",
"}"
] | Validates & completes the given hit definition.
@param string $hitIdentifier the hit identifier
@param array $hitDefinition The attribute mapping to validated & complete.
@throws MappingException | [
"Validates",
"&",
"completes",
"the",
"given",
"hit",
"definition",
"."
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L258-L302 |
3,512 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.getOrderedRequiredHits | public function getOrderedRequiredHits()
{
$hitIdentifiers = array();
foreach($this->requiredHits as $hitIdentifier)
{
$hitIdentifiers[$this->hitPositions[$hitIdentifier]] = $hitIdentifier;
}
krsort($hitIdentifiers);
return $hitIdentifiers;
} | php | public function getOrderedRequiredHits()
{
$hitIdentifiers = array();
foreach($this->requiredHits as $hitIdentifier)
{
$hitIdentifiers[$this->hitPositions[$hitIdentifier]] = $hitIdentifier;
}
krsort($hitIdentifiers);
return $hitIdentifiers;
} | [
"public",
"function",
"getOrderedRequiredHits",
"(",
")",
"{",
"$",
"hitIdentifiers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"requiredHits",
"as",
"$",
"hitIdentifier",
")",
"{",
"$",
"hitIdentifiers",
"[",
"$",
"this",
"->",
"hitPositions",
"[",
"$",
"hitIdentifier",
"]",
"]",
"=",
"$",
"hitIdentifier",
";",
"}",
"krsort",
"(",
"$",
"hitIdentifiers",
")",
";",
"return",
"$",
"hitIdentifiers",
";",
"}"
] | Get required hits names,
ordered by item constructor positions
@return string[] | [
"Get",
"required",
"hits",
"names",
"ordered",
"by",
"item",
"constructor",
"positions"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L386-L395 |
3,513 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.addRequiredHit | public function addRequiredHit($hitIdentifier)
{
if(!in_array($hitIdentifier, $this->requiredHits))
{
$this->requiredHits[] = $hitIdentifier;
}
return $this;
} | php | public function addRequiredHit($hitIdentifier)
{
if(!in_array($hitIdentifier, $this->requiredHits))
{
$this->requiredHits[] = $hitIdentifier;
}
return $this;
} | [
"public",
"function",
"addRequiredHit",
"(",
"$",
"hitIdentifier",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"hitIdentifier",
",",
"$",
"this",
"->",
"requiredHits",
")",
")",
"{",
"$",
"this",
"->",
"requiredHits",
"[",
"]",
"=",
"$",
"hitIdentifier",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add Required Hit
@param type $hitIdentifier
@return \Emhar\SearchDoctrineBundle\Mapping\ItemMetaData | [
"Add",
"Required",
"Hit"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L403-L410 |
3,514 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.addSortableHit | public function addSortableHit($hitIdentifier)
{
if(!in_array($hitIdentifier, $this->sortableHits))
{
$this->sortableHits[] = $hitIdentifier;
}
return $this;
} | php | public function addSortableHit($hitIdentifier)
{
if(!in_array($hitIdentifier, $this->sortableHits))
{
$this->sortableHits[] = $hitIdentifier;
}
return $this;
} | [
"public",
"function",
"addSortableHit",
"(",
"$",
"hitIdentifier",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"hitIdentifier",
",",
"$",
"this",
"->",
"sortableHits",
")",
")",
"{",
"$",
"this",
"->",
"sortableHits",
"[",
"]",
"=",
"$",
"hitIdentifier",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add sortable hit.
@param string $hitIdentifier
@return ItemMetaData | [
"Add",
"sortable",
"hit",
"."
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L451-L458 |
3,515 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.getHitEntityAttribute | public function getHitEntityAttribute($hitIdentifier, $entityIdentifier)
{
return isset($this->entityHitMapping[$entityIdentifier][$hitIdentifier]) ?
$this->entityHitMapping[$entityIdentifier][$hitIdentifier] : null;
} | php | public function getHitEntityAttribute($hitIdentifier, $entityIdentifier)
{
return isset($this->entityHitMapping[$entityIdentifier][$hitIdentifier]) ?
$this->entityHitMapping[$entityIdentifier][$hitIdentifier] : null;
} | [
"public",
"function",
"getHitEntityAttribute",
"(",
"$",
"hitIdentifier",
",",
"$",
"entityIdentifier",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"entityHitMapping",
"[",
"$",
"entityIdentifier",
"]",
"[",
"$",
"hitIdentifier",
"]",
")",
"?",
"$",
"this",
"->",
"entityHitMapping",
"[",
"$",
"entityIdentifier",
"]",
"[",
"$",
"hitIdentifier",
"]",
":",
"null",
";",
"}"
] | Get hit entity attribute
return null if there is no mapping for this hit
@param string $hitIdentifier
@param string $entityIdentifier
@return string|null | [
"Get",
"hit",
"entity",
"attribute",
"return",
"null",
"if",
"there",
"is",
"no",
"mapping",
"for",
"this",
"hit"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L468-L472 |
3,516 | emhar/SearchDoctrineBundle | Mapping/ItemMetaData.php | ItemMetaData.setHitEntityAttribute | public function setHitEntityAttribute($hitIdentifier, $entityIdentifier, $attribute)
{
if(!array_key_exists($entityIdentifier, $this->entityClasses))
{
throw MappingException::invalidEntity($this->itemClass, $entityIdentifier);
}
$this->entityHitMapping[$entityIdentifier][$hitIdentifier] = $attribute;
return $this;
} | php | public function setHitEntityAttribute($hitIdentifier, $entityIdentifier, $attribute)
{
if(!array_key_exists($entityIdentifier, $this->entityClasses))
{
throw MappingException::invalidEntity($this->itemClass, $entityIdentifier);
}
$this->entityHitMapping[$entityIdentifier][$hitIdentifier] = $attribute;
return $this;
} | [
"public",
"function",
"setHitEntityAttribute",
"(",
"$",
"hitIdentifier",
",",
"$",
"entityIdentifier",
",",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"entityIdentifier",
",",
"$",
"this",
"->",
"entityClasses",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidEntity",
"(",
"$",
"this",
"->",
"itemClass",
",",
"$",
"entityIdentifier",
")",
";",
"}",
"$",
"this",
"->",
"entityHitMapping",
"[",
"$",
"entityIdentifier",
"]",
"[",
"$",
"hitIdentifier",
"]",
"=",
"$",
"attribute",
";",
"return",
"$",
"this",
";",
"}"
] | Set hit entity attribute
@param string $hitIdentifier
@param string $entityIdentifier
@param string $attribute
@return ItemMetaData | [
"Set",
"hit",
"entity",
"attribute"
] | 0844cda4a6972dd71c04c0b38dba1ebf9b15c238 | https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaData.php#L482-L490 |
3,517 | MESD/JasperReportViewerBundle | Twig/Extension/ReportViewerExtension.php | ReportViewerExtension.getFunctions | public function getFunctions()
{
//Function definition
return array(
'mesd_jasper_reportviewer_stored_report_link' => new \Twig_Function_Method($this, 'renderStoredReportLink', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_report_link' => new \Twig_Function_Method($this, 'renderReportLink', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_home' => new \Twig_Function_Method($this, 'renderReportHome', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_uri' => new \Twig_Function_Method($this, 'renderReportURI', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_direct_link' => new \Twig_Function_Method($this, 'renderDirectReportLink', array('is_safe' => array('html')))
);
} | php | public function getFunctions()
{
//Function definition
return array(
'mesd_jasper_reportviewer_stored_report_link' => new \Twig_Function_Method($this, 'renderStoredReportLink', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_report_link' => new \Twig_Function_Method($this, 'renderReportLink', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_home' => new \Twig_Function_Method($this, 'renderReportHome', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_uri' => new \Twig_Function_Method($this, 'renderReportURI', array('is_safe' => array('html'))),
'mesd_jasper_reportviewer_direct_link' => new \Twig_Function_Method($this, 'renderDirectReportLink', array('is_safe' => array('html')))
);
} | [
"public",
"function",
"getFunctions",
"(",
")",
"{",
"//Function definition",
"return",
"array",
"(",
"'mesd_jasper_reportviewer_stored_report_link'",
"=>",
"new",
"\\",
"Twig_Function_Method",
"(",
"$",
"this",
",",
"'renderStoredReportLink'",
",",
"array",
"(",
"'is_safe'",
"=>",
"array",
"(",
"'html'",
")",
")",
")",
",",
"'mesd_jasper_reportviewer_report_link'",
"=>",
"new",
"\\",
"Twig_Function_Method",
"(",
"$",
"this",
",",
"'renderReportLink'",
",",
"array",
"(",
"'is_safe'",
"=>",
"array",
"(",
"'html'",
")",
")",
")",
",",
"'mesd_jasper_reportviewer_home'",
"=>",
"new",
"\\",
"Twig_Function_Method",
"(",
"$",
"this",
",",
"'renderReportHome'",
",",
"array",
"(",
"'is_safe'",
"=>",
"array",
"(",
"'html'",
")",
")",
")",
",",
"'mesd_jasper_reportviewer_uri'",
"=>",
"new",
"\\",
"Twig_Function_Method",
"(",
"$",
"this",
",",
"'renderReportURI'",
",",
"array",
"(",
"'is_safe'",
"=>",
"array",
"(",
"'html'",
")",
")",
")",
",",
"'mesd_jasper_reportviewer_direct_link'",
"=>",
"new",
"\\",
"Twig_Function_Method",
"(",
"$",
"this",
",",
"'renderDirectReportLink'",
",",
"array",
"(",
"'is_safe'",
"=>",
"array",
"(",
"'html'",
")",
")",
")",
")",
";",
"}"
] | Get functions lists the functions in this class | [
"Get",
"functions",
"lists",
"the",
"functions",
"in",
"this",
"class"
] | d51ff079ba79b35c549a7ac472a305d416060d86 | https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Twig/Extension/ReportViewerExtension.php#L21-L31 |
3,518 | MESD/JasperReportViewerBundle | Twig/Extension/ReportViewerExtension.php | ReportViewerExtension.renderReportHome | public function renderReportHome($linkText, $classes = ' ', $openInNewTab = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:reportHome.html.twig',
array(
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab));
} | php | public function renderReportHome($linkText, $classes = ' ', $openInNewTab = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:reportHome.html.twig',
array(
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab));
} | [
"public",
"function",
"renderReportHome",
"(",
"$",
"linkText",
",",
"$",
"classes",
"=",
"' '",
",",
"$",
"openInNewTab",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"environment",
"->",
"render",
"(",
"'MesdJasperReportViewerBundle:Partials:reportHome.html.twig'",
",",
"array",
"(",
"'linkText'",
"=>",
"$",
"linkText",
",",
"'classes'",
"=>",
"$",
"classes",
",",
"'openInNewTab'",
"=>",
"$",
"openInNewTab",
")",
")",
";",
"}"
] | Render a link to the report viewer home
@param [type] $linkText [description]
@param string $class [description]
@param boolean $optionInNewTab [description]
@return [type] [description] | [
"Render",
"a",
"link",
"to",
"the",
"report",
"viewer",
"home"
] | d51ff079ba79b35c549a7ac472a305d416060d86 | https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Twig/Extension/ReportViewerExtension.php#L72-L80 |
3,519 | MESD/JasperReportViewerBundle | Twig/Extension/ReportViewerExtension.php | ReportViewerExtension.renderReportLink | public function renderReportLink($reportUri, $linkText, $classes = ' ', $openInNewTab = true, $hideHome = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:reportLink.html.twig',
array(
'reportUri' => $reportUri,
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab,
'hideHome' => $hideHome));
} | php | public function renderReportLink($reportUri, $linkText, $classes = ' ', $openInNewTab = true, $hideHome = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:reportLink.html.twig',
array(
'reportUri' => $reportUri,
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab,
'hideHome' => $hideHome));
} | [
"public",
"function",
"renderReportLink",
"(",
"$",
"reportUri",
",",
"$",
"linkText",
",",
"$",
"classes",
"=",
"' '",
",",
"$",
"openInNewTab",
"=",
"true",
",",
"$",
"hideHome",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"environment",
"->",
"render",
"(",
"'MesdJasperReportViewerBundle:Partials:reportLink.html.twig'",
",",
"array",
"(",
"'reportUri'",
"=>",
"$",
"reportUri",
",",
"'linkText'",
"=>",
"$",
"linkText",
",",
"'classes'",
"=>",
"$",
"classes",
",",
"'openInNewTab'",
"=>",
"$",
"openInNewTab",
",",
"'hideHome'",
"=>",
"$",
"hideHome",
")",
")",
";",
"}"
] | Renders a link to a report
@param string $reportUri The uri of the report
@param string $linkText The text to display for the link
@param string $classes The classes to have for the anchor tag
@param boolean $openInNewTab Whether to open in a new tab or not
@param boolean $hideHome Whether to hide the home and history nav links
@return string The final link tag | [
"Renders",
"a",
"link",
"to",
"a",
"report"
] | d51ff079ba79b35c549a7ac472a305d416060d86 | https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Twig/Extension/ReportViewerExtension.php#L93-L103 |
3,520 | MESD/JasperReportViewerBundle | Twig/Extension/ReportViewerExtension.php | ReportViewerExtension.renderStoredReportLink | public function renderStoredReportLink($reportUri, $requestId, $linkText, $classes = ' ', $openInNewTab = true, $hideHome = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:storedReportLink.html.twig',
array(
'reportUri' => $reportUri,
'requestId' => $requestId,
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab,
'hideHome' => $hideHome));
} | php | public function renderStoredReportLink($reportUri, $requestId, $linkText, $classes = ' ', $openInNewTab = true, $hideHome = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:storedReportLink.html.twig',
array(
'reportUri' => $reportUri,
'requestId' => $requestId,
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab,
'hideHome' => $hideHome));
} | [
"public",
"function",
"renderStoredReportLink",
"(",
"$",
"reportUri",
",",
"$",
"requestId",
",",
"$",
"linkText",
",",
"$",
"classes",
"=",
"' '",
",",
"$",
"openInNewTab",
"=",
"true",
",",
"$",
"hideHome",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"environment",
"->",
"render",
"(",
"'MesdJasperReportViewerBundle:Partials:storedReportLink.html.twig'",
",",
"array",
"(",
"'reportUri'",
"=>",
"$",
"reportUri",
",",
"'requestId'",
"=>",
"$",
"requestId",
",",
"'linkText'",
"=>",
"$",
"linkText",
",",
"'classes'",
"=>",
"$",
"classes",
",",
"'openInNewTab'",
"=>",
"$",
"openInNewTab",
",",
"'hideHome'",
"=>",
"$",
"hideHome",
")",
")",
";",
"}"
] | Renders a link to a stored report
@param string $reportUri The uri of the report the request id is for
@param string $requestId The request id of the stored report
@param string $linkText The text to display for the link
@param string $classes The classes to have for the anchor tag
@param boolean $openInNewTab Whether to open in a new tab or not
@param boolean $hideHome Whether to hide the home and history nav links
@return string The final link tag | [
"Renders",
"a",
"link",
"to",
"a",
"stored",
"report"
] | d51ff079ba79b35c549a7ac472a305d416060d86 | https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Twig/Extension/ReportViewerExtension.php#L118-L129 |
3,521 | MESD/JasperReportViewerBundle | Twig/Extension/ReportViewerExtension.php | ReportViewerExtension.renderDirectReportLink | public function renderDirectReportLink(ReportInstance $reportInstance, $linkText, $classes = ' ', $openInNewTab = true, $hideHome = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:directReportLink.html.twig',
array(
'reportUri' => $reportInstance->getReportUri(),
'parameters' => urlencode(serialize($reportInstance->getParameters())),
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab,
'hideHome' => $hideHome));
} | php | public function renderDirectReportLink(ReportInstance $reportInstance, $linkText, $classes = ' ', $openInNewTab = true, $hideHome = true)
{
return $this->environment->render(
'MesdJasperReportViewerBundle:Partials:directReportLink.html.twig',
array(
'reportUri' => $reportInstance->getReportUri(),
'parameters' => urlencode(serialize($reportInstance->getParameters())),
'linkText' => $linkText,
'classes' => $classes,
'openInNewTab' => $openInNewTab,
'hideHome' => $hideHome));
} | [
"public",
"function",
"renderDirectReportLink",
"(",
"ReportInstance",
"$",
"reportInstance",
",",
"$",
"linkText",
",",
"$",
"classes",
"=",
"' '",
",",
"$",
"openInNewTab",
"=",
"true",
",",
"$",
"hideHome",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"environment",
"->",
"render",
"(",
"'MesdJasperReportViewerBundle:Partials:directReportLink.html.twig'",
",",
"array",
"(",
"'reportUri'",
"=>",
"$",
"reportInstance",
"->",
"getReportUri",
"(",
")",
",",
"'parameters'",
"=>",
"urlencode",
"(",
"serialize",
"(",
"$",
"reportInstance",
"->",
"getParameters",
"(",
")",
")",
")",
",",
"'linkText'",
"=>",
"$",
"linkText",
",",
"'classes'",
"=>",
"$",
"classes",
",",
"'openInNewTab'",
"=>",
"$",
"openInNewTab",
",",
"'hideHome'",
"=>",
"$",
"hideHome",
")",
")",
";",
"}"
] | Renders a report immediately in the viewer with the parameters from the report instance object
@param ReportInstance $reportInstance The instance of a report to run
@param string $linkText THe text to place in the link
@param string $classes The classes to add to the link
@param boolean $openInNewTab Whether the report viewer would open in a new tab
@param boolean $hideHome Whether the report home should be shown
@return string The rendered link html | [
"Renders",
"a",
"report",
"immediately",
"in",
"the",
"viewer",
"with",
"the",
"parameters",
"from",
"the",
"report",
"instance",
"object"
] | d51ff079ba79b35c549a7ac472a305d416060d86 | https://github.com/MESD/JasperReportViewerBundle/blob/d51ff079ba79b35c549a7ac472a305d416060d86/Twig/Extension/ReportViewerExtension.php#L143-L154 |
3,522 | narrowspark/automatic-common | Package.php | Package.createFromLock | public static function createFromLock(string $name, array $packageData): PackageContract
{
$keyToFunctionMappers = [
'parent' => 'setParentName',
'is-dev' => 'setIsDev',
'url' => 'setUrl',
'operation' => 'setOperation',
'type' => 'setType',
'requires' => 'setRequires',
'automatic-extra' => 'setConfig',
'autoload' => 'setAutoload',
'created' => 'setTime',
];
$package = new static($name, $packageData['version']);
foreach ($packageData as $key => $data) {
if ($data !== null && isset($keyToFunctionMappers[$key])) {
$package->{$keyToFunctionMappers[$key]}($data);
}
}
return $package;
} | php | public static function createFromLock(string $name, array $packageData): PackageContract
{
$keyToFunctionMappers = [
'parent' => 'setParentName',
'is-dev' => 'setIsDev',
'url' => 'setUrl',
'operation' => 'setOperation',
'type' => 'setType',
'requires' => 'setRequires',
'automatic-extra' => 'setConfig',
'autoload' => 'setAutoload',
'created' => 'setTime',
];
$package = new static($name, $packageData['version']);
foreach ($packageData as $key => $data) {
if ($data !== null && isset($keyToFunctionMappers[$key])) {
$package->{$keyToFunctionMappers[$key]}($data);
}
}
return $package;
} | [
"public",
"static",
"function",
"createFromLock",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"packageData",
")",
":",
"PackageContract",
"{",
"$",
"keyToFunctionMappers",
"=",
"[",
"'parent'",
"=>",
"'setParentName'",
",",
"'is-dev'",
"=>",
"'setIsDev'",
",",
"'url'",
"=>",
"'setUrl'",
",",
"'operation'",
"=>",
"'setOperation'",
",",
"'type'",
"=>",
"'setType'",
",",
"'requires'",
"=>",
"'setRequires'",
",",
"'automatic-extra'",
"=>",
"'setConfig'",
",",
"'autoload'",
"=>",
"'setAutoload'",
",",
"'created'",
"=>",
"'setTime'",
",",
"]",
";",
"$",
"package",
"=",
"new",
"static",
"(",
"$",
"name",
",",
"$",
"packageData",
"[",
"'version'",
"]",
")",
";",
"foreach",
"(",
"$",
"packageData",
"as",
"$",
"key",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"keyToFunctionMappers",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"package",
"->",
"{",
"$",
"keyToFunctionMappers",
"[",
"$",
"key",
"]",
"}",
"(",
"$",
"data",
")",
";",
"}",
"}",
"return",
"$",
"package",
";",
"}"
] | Create a automatic package from the lock data.
@param string $name
@param array $packageData
@return \Narrowspark\Automatic\Common\Contract\Package | [
"Create",
"a",
"automatic",
"package",
"from",
"the",
"lock",
"data",
"."
] | 415f0d566932847c3ca799e06f27e588bd244881 | https://github.com/narrowspark/automatic-common/blob/415f0d566932847c3ca799e06f27e588bd244881/Package.php#L285-L308 |
3,523 | samurai-fw/samurai | src/Samurai/Component/Spec/Helper.php | Helper.getRunner | public function getRunner()
{
if ($this->runner)
return $this->runner;
$runner = new Runner\PHPSpecRunner();
$this->application->getContainer()->injectDependency($runner);
$runner->initialize();
return $this->runner = $runner;
} | php | public function getRunner()
{
if ($this->runner)
return $this->runner;
$runner = new Runner\PHPSpecRunner();
$this->application->getContainer()->injectDependency($runner);
$runner->initialize();
return $this->runner = $runner;
} | [
"public",
"function",
"getRunner",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"runner",
")",
"return",
"$",
"this",
"->",
"runner",
";",
"$",
"runner",
"=",
"new",
"Runner",
"\\",
"PHPSpecRunner",
"(",
")",
";",
"$",
"this",
"->",
"application",
"->",
"getContainer",
"(",
")",
"->",
"injectDependency",
"(",
"$",
"runner",
")",
";",
"$",
"runner",
"->",
"initialize",
"(",
")",
";",
"return",
"$",
"this",
"->",
"runner",
"=",
"$",
"runner",
";",
"}"
] | get runner.
@access public
@return Samurai\Samurai\Component\Spec\Runner
@todo support other runner (ex: phpUnit, behat, etc...) | [
"get",
"runner",
"."
] | 7ca3847b13f86e2847a17ab5e8e4e20893021d5a | https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Spec/Helper.php#L66-L77 |
3,524 | HeroicTeam/m | Html/Element.php | Element.renderAttributes | protected function renderAttributes()
{
$output = '';
foreach($this->_attr as $key => $value) {
$output .= $key.' = "'.$value.'" ';
}
return $output;
} | php | protected function renderAttributes()
{
$output = '';
foreach($this->_attr as $key => $value) {
$output .= $key.' = "'.$value.'" ';
}
return $output;
} | [
"protected",
"function",
"renderAttributes",
"(",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"_attr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
".=",
"$",
"key",
".",
"' = \"'",
".",
"$",
"value",
".",
"'\" '",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Renders the attribute string for the element.
@return string | [
"Renders",
"the",
"attribute",
"string",
"for",
"the",
"element",
"."
] | daa6d5956ee6c989379fe5fae39feccc59cf4add | https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Element.php#L24-L33 |
3,525 | HeroicTeam/m | Html/Element.php | Element.getAttribute | public function getAttribute($key)
{
return isset($this->_attr[$key]) ? $this->_attr[$key] : null;
} | php | public function getAttribute($key)
{
return isset($this->_attr[$key]) ? $this->_attr[$key] : null;
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"key",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_attr",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"this",
"->",
"_attr",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
] | Returns the requested attribute if it exists.
@param string $key
@return mixed|null | [
"Returns",
"the",
"requested",
"attribute",
"if",
"it",
"exists",
"."
] | daa6d5956ee6c989379fe5fae39feccc59cf4add | https://github.com/HeroicTeam/m/blob/daa6d5956ee6c989379fe5fae39feccc59cf4add/Html/Element.php#L68-L71 |
3,526 | Jinxes/layton | Layton/Library/Http/Stream.php | Stream.isPipe | public function isPipe()
{
if (\is_null($this->isPipe)) {
$this->isPipe = false;
if ($this->isAttached()) {
$mode = fstat($this->stream)['mode'];
$this->isPipe = ($mode & 0010000) !== 0;
}
}
return $this->isPipe;
} | php | public function isPipe()
{
if (\is_null($this->isPipe)) {
$this->isPipe = false;
if ($this->isAttached()) {
$mode = fstat($this->stream)['mode'];
$this->isPipe = ($mode & 0010000) !== 0;
}
}
return $this->isPipe;
} | [
"public",
"function",
"isPipe",
"(",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"this",
"->",
"isPipe",
")",
")",
"{",
"$",
"this",
"->",
"isPipe",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isAttached",
"(",
")",
")",
"{",
"$",
"mode",
"=",
"fstat",
"(",
"$",
"this",
"->",
"stream",
")",
"[",
"'mode'",
"]",
";",
"$",
"this",
"->",
"isPipe",
"=",
"(",
"$",
"mode",
"&",
"0010000",
")",
"!==",
"0",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"isPipe",
";",
"}"
] | Is the stream is a pipe?
@return bool | [
"Is",
"the",
"stream",
"is",
"a",
"pipe?"
] | 27b8eab2c59b9887eb93e40a533eb77cc5690584 | https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Stream.php#L176-L186 |
3,527 | osflab/view | Component/Jquery.php | Jquery.enableAutofocus | public function enableAutofocus()
{
static $enabled = false;
if (!$enabled) {
$script = "$(document).ready(function(){"
. "\$(this).find('[autofocus]:first').focus();"
. "});";
$this->registerScript($script);
$enabled = true;
}
return $this;
} | php | public function enableAutofocus()
{
static $enabled = false;
if (!$enabled) {
$script = "$(document).ready(function(){"
. "\$(this).find('[autofocus]:first').focus();"
. "});";
$this->registerScript($script);
$enabled = true;
}
return $this;
} | [
"public",
"function",
"enableAutofocus",
"(",
")",
"{",
"static",
"$",
"enabled",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"enabled",
")",
"{",
"$",
"script",
"=",
"\"$(document).ready(function(){\"",
".",
"\"\\$(this).find('[autofocus]:first').focus();\"",
".",
"\"});\"",
";",
"$",
"this",
"->",
"registerScript",
"(",
"$",
"script",
")",
";",
"$",
"enabled",
"=",
"true",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Activate focus on elements with the attribute "autofocus"
@staticvar boolean $activated
@return $this | [
"Activate",
"focus",
"on",
"elements",
"with",
"the",
"attribute",
"autofocus"
] | e06601013e8ec86dc2055e000e58dffd963c78e2 | https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Component/Jquery.php#L53-L66 |
3,528 | gliverphp/helpers | src/Redirect/Redirect.php | Redirect.to | public static function to($path, array $data = null )
{
//compose query string if data was set
($data !== null) ? self::with($data) : '';
//compose full url
$path = (self::$query_string === null) ? Url::link($path) : Url::link($path) . '?' . self::$query_string;
//redirect to path
header('Location: ' . $path);
//stop any further html output
exit();
} | php | public static function to($path, array $data = null )
{
//compose query string if data was set
($data !== null) ? self::with($data) : '';
//compose full url
$path = (self::$query_string === null) ? Url::link($path) : Url::link($path) . '?' . self::$query_string;
//redirect to path
header('Location: ' . $path);
//stop any further html output
exit();
} | [
"public",
"static",
"function",
"to",
"(",
"$",
"path",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"//compose query string if data was set",
"(",
"$",
"data",
"!==",
"null",
")",
"?",
"self",
"::",
"with",
"(",
"$",
"data",
")",
":",
"''",
";",
"//compose full url",
"$",
"path",
"=",
"(",
"self",
"::",
"$",
"query_string",
"===",
"null",
")",
"?",
"Url",
"::",
"link",
"(",
"$",
"path",
")",
":",
"Url",
"::",
"link",
"(",
"$",
"path",
")",
".",
"'?'",
".",
"self",
"::",
"$",
"query_string",
";",
"//redirect to path",
"header",
"(",
"'Location: '",
".",
"$",
"path",
")",
";",
"//stop any further html output",
"exit",
"(",
")",
";",
"}"
] | This method redirect to the specified page
@param string $path The path to redirect to
@param mixed $data The data with which to do redirect | [
"This",
"method",
"redirect",
"to",
"the",
"specified",
"page"
] | c5204df8169fad55f5b273422e45f56164373ab8 | https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/Redirect/Redirect.php#L48-L62 |
3,529 | znframework/package-language | Update.php | Update.do | public function do(String $app = NULL, $key, String $data = NULL) : Bool
{
return (new Insert)->do($app, $key, $data);
} | php | public function do(String $app = NULL, $key, String $data = NULL) : Bool
{
return (new Insert)->do($app, $key, $data);
} | [
"public",
"function",
"do",
"(",
"String",
"$",
"app",
"=",
"NULL",
",",
"$",
"key",
",",
"String",
"$",
"data",
"=",
"NULL",
")",
":",
"Bool",
"{",
"return",
"(",
"new",
"Insert",
")",
"->",
"do",
"(",
"$",
"app",
",",
"$",
"key",
",",
"$",
"data",
")",
";",
"}"
] | Updates language key
@param string $app = NULL
@param mixed $key
@param string $data = NULL
@return bool | [
"Updates",
"language",
"key"
] | f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09 | https://github.com/znframework/package-language/blob/f0fe3b9ec2ba1a69838da9af58ced5398ea9fb09/Update.php#L23-L26 |
3,530 | cityware/city-snmp | src/MIBS/Cisco/VlanMembership.php | VlanMembership.vlanTypes | public function vlanTypes($translate = false)
{
$states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_VLAN_TYPE);
if (!$translate) {
return $states;
}
return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_VLAN_TYPES);
} | php | public function vlanTypes($translate = false)
{
$states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_VLAN_TYPE);
if (!$translate) {
return $states;
}
return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_VLAN_TYPES);
} | [
"public",
"function",
"vlanTypes",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"walk1d",
"(",
"self",
"::",
"OID_VLAN_MEMBERSHIP_VLAN_TYPE",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"{",
"return",
"$",
"states",
";",
"}",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"states",
",",
"self",
"::",
"$",
"VLAN_MEMBERSHIP_VLAN_TYPES",
")",
";",
"}"
] | Get an array of the type of VLAN membership of each device port.
E.g. the follow SNMP output yields the shown array:
.1.3.6.1.4.1.9.9.68.1.2.2.1.1.10128 = INTEGER: static(1)
.1.3.6.1.4.1.9.9.68.1.2.2.1.1.10129 = INTEGER: dynamic(2)
...
[10128] => 1
[10129] => 2
@return array | [
"Get",
"an",
"array",
"of",
"the",
"type",
"of",
"VLAN",
"membership",
"of",
"each",
"device",
"port",
"."
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Cisco/VlanMembership.php#L62-L71 |
3,531 | cityware/city-snmp | src/MIBS/Cisco/VlanMembership.php | VlanMembership.portStatus | public function portStatus($translate = false)
{
$states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_PORT_STATUS);
if (!$translate) {
return $states;
}
return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_PORT_STATUS);
} | php | public function portStatus($translate = false)
{
$states = $this->getSNMP()->walk1d(self::OID_VLAN_MEMBERSHIP_PORT_STATUS);
if (!$translate) {
return $states;
}
return $this->getSNMP()->translate($states, self::$VLAN_MEMBERSHIP_PORT_STATUS);
} | [
"public",
"function",
"portStatus",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"walk1d",
"(",
"self",
"::",
"OID_VLAN_MEMBERSHIP_PORT_STATUS",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"{",
"return",
"$",
"states",
";",
"}",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"states",
",",
"self",
"::",
"$",
"VLAN_MEMBERSHIP_PORT_STATUS",
")",
";",
"}"
] | Get an array of the current status of VLAN in each device port.
.1.3.6.1.4.1.9.9.68.1.2.2.1.1.10128 = INTEGER: inactive(1)
.1.3.6.1.4.1.9.9.68.1.2.2.1.1.10129 = INTEGER: active(2)
...
[10128] => 1
[10129] => 2
@param bool $translate If true, return the string representation.
@return array An array with the current VLAN status of ports. | [
"Get",
"an",
"array",
"of",
"the",
"current",
"status",
"of",
"VLAN",
"in",
"each",
"device",
"port",
"."
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Cisco/VlanMembership.php#L138-L147 |
3,532 | nicmart/DSQExpression | src/Builder/FilterProcess.php | FilterProcess.getSubtree | private function getSubtree(TreeExpression $expr)
{
foreach ($expr->getChildren() as $child) {
if ($child->getType() == $this->operator)
return $child;
}
$expr->addChild($subtree = new TreeExpression($this->operator));
return $subtree;
} | php | private function getSubtree(TreeExpression $expr)
{
foreach ($expr->getChildren() as $child) {
if ($child->getType() == $this->operator)
return $child;
}
$expr->addChild($subtree = new TreeExpression($this->operator));
return $subtree;
} | [
"private",
"function",
"getSubtree",
"(",
"TreeExpression",
"$",
"expr",
")",
"{",
"foreach",
"(",
"$",
"expr",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"getType",
"(",
")",
"==",
"$",
"this",
"->",
"operator",
")",
"return",
"$",
"child",
";",
"}",
"$",
"expr",
"->",
"addChild",
"(",
"$",
"subtree",
"=",
"new",
"TreeExpression",
"(",
"$",
"this",
"->",
"operator",
")",
")",
";",
"return",
"$",
"subtree",
";",
"}"
] | Retrieve or create the first subtree that matches with the operator
@param TreeExpression $expr
@return \DSQ\Expression\Expression|TreeExpression | [
"Retrieve",
"or",
"create",
"the",
"first",
"subtree",
"that",
"matches",
"with",
"the",
"operator"
] | f46f18cabdbc59347424b3b6669e380f24943be3 | https://github.com/nicmart/DSQExpression/blob/f46f18cabdbc59347424b3b6669e380f24943be3/src/Builder/FilterProcess.php#L61-L70 |
3,533 | yongtiger/yii2-theme | src/Bootstrap.php | Bootstrap.filterThemesBootstrap | public static function filterThemesBootstrap($themesRootPath = 'themes', $bootstrapPathFile = 'src\\Bootstrap', $bootstrapPathPattern = '{theme-path}\\{bootstrap-path-file}') {
if (static::$_themeBootstraps === null) {
static::$_themeBootstraps = static::findThemeBootstraps($themesRootPath, $bootstrapPathFile, $bootstrapPathPattern);
}
foreach (ThemeManager::getThemes() as $theme) {
///theme bootstrap class
$themeBootstrapClass = $theme['namespace'] . '\\Bootstrap';
///If the current theme exist in `Yii::$app->bootstrap`, remove out.
///In other words, if a theme has been registered in the setting table `theme/thems`, you do not need to perform bootstrap.
$key = array_search($themeBootstrapClass, static::$_themeBootstraps);
if ($key !== false) {
array_splice(static::$_themeBootstraps, $key, 1);
}
}
Yii::$app->bootstrap = array_merge(Yii::$app->bootstrap, static::$_themeBootstraps);
} | php | public static function filterThemesBootstrap($themesRootPath = 'themes', $bootstrapPathFile = 'src\\Bootstrap', $bootstrapPathPattern = '{theme-path}\\{bootstrap-path-file}') {
if (static::$_themeBootstraps === null) {
static::$_themeBootstraps = static::findThemeBootstraps($themesRootPath, $bootstrapPathFile, $bootstrapPathPattern);
}
foreach (ThemeManager::getThemes() as $theme) {
///theme bootstrap class
$themeBootstrapClass = $theme['namespace'] . '\\Bootstrap';
///If the current theme exist in `Yii::$app->bootstrap`, remove out.
///In other words, if a theme has been registered in the setting table `theme/thems`, you do not need to perform bootstrap.
$key = array_search($themeBootstrapClass, static::$_themeBootstraps);
if ($key !== false) {
array_splice(static::$_themeBootstraps, $key, 1);
}
}
Yii::$app->bootstrap = array_merge(Yii::$app->bootstrap, static::$_themeBootstraps);
} | [
"public",
"static",
"function",
"filterThemesBootstrap",
"(",
"$",
"themesRootPath",
"=",
"'themes'",
",",
"$",
"bootstrapPathFile",
"=",
"'src\\\\Bootstrap'",
",",
"$",
"bootstrapPathPattern",
"=",
"'{theme-path}\\\\{bootstrap-path-file}'",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"_themeBootstraps",
"===",
"null",
")",
"{",
"static",
"::",
"$",
"_themeBootstraps",
"=",
"static",
"::",
"findThemeBootstraps",
"(",
"$",
"themesRootPath",
",",
"$",
"bootstrapPathFile",
",",
"$",
"bootstrapPathPattern",
")",
";",
"}",
"foreach",
"(",
"ThemeManager",
"::",
"getThemes",
"(",
")",
"as",
"$",
"theme",
")",
"{",
"///theme bootstrap class",
"$",
"themeBootstrapClass",
"=",
"$",
"theme",
"[",
"'namespace'",
"]",
".",
"'\\\\Bootstrap'",
";",
"///If the current theme exist in `Yii::$app->bootstrap`, remove out.",
"///In other words, if a theme has been registered in the setting table `theme/thems`, you do not need to perform bootstrap.",
"$",
"key",
"=",
"array_search",
"(",
"$",
"themeBootstrapClass",
",",
"static",
"::",
"$",
"_themeBootstraps",
")",
";",
"if",
"(",
"$",
"key",
"!==",
"false",
")",
"{",
"array_splice",
"(",
"static",
"::",
"$",
"_themeBootstraps",
",",
"$",
"key",
",",
"1",
")",
";",
"}",
"}",
"Yii",
"::",
"$",
"app",
"->",
"bootstrap",
"=",
"array_merge",
"(",
"Yii",
"::",
"$",
"app",
"->",
"bootstrap",
",",
"static",
"::",
"$",
"_themeBootstraps",
")",
";",
"}"
] | Filters bootstraps in `themes` folder.
If the current theme exist in `Yii::$app->extensions`, remove out.
In other words, if a theme has been registered in the themes table `theme/thems`, you do not need to perform bootstrap.
@param string $themesRootPath e.g. `themes`
@param string $bootstrapPathFile e.g. `src\Bootstrap`
@param string $bootstrapPathPattern e.g. `{theme-path}\{bootstrap-path-file}` | [
"Filters",
"bootstraps",
"in",
"themes",
"folder",
"."
] | b51fbf66fe51d16b3061b5ffc26f05eb64c3ea40 | https://github.com/yongtiger/yii2-theme/blob/b51fbf66fe51d16b3061b5ffc26f05eb64c3ea40/src/Bootstrap.php#L86-L107 |
3,534 | yongtiger/yii2-theme | src/Bootstrap.php | Bootstrap.findThemeBootstraps | public static function findThemeBootstraps($themesRootPath, $bootstrapPathFile, $bootstrapPathPattern) {
$dir = Yii::getAlias('@' . $themesRootPath);
if (!is_dir($dir)) {
throw new InvalidParamException("The dir argument must be a directory: $dir");
}
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$list = [];
$handle = opendir($dir);
if ($handle === false) {
throw new InvalidParamException("Unable to open directory: $dir");
}
while (($file = readdir($handle)) !== false) {
if ($file === '.' || $file === '..') {
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($path)) {
list($r, $p) = static::formatBootstrapPath($bootstrapPathPattern, $file, $bootstrapPathFile);
if (is_file($dir . DIRECTORY_SEPARATOR . $p)) {
$list[] = $themesRootPath . '\\' . $r;
continue;
}
}
}
closedir($handle);
return $list;
} | php | public static function findThemeBootstraps($themesRootPath, $bootstrapPathFile, $bootstrapPathPattern) {
$dir = Yii::getAlias('@' . $themesRootPath);
if (!is_dir($dir)) {
throw new InvalidParamException("The dir argument must be a directory: $dir");
}
$dir = rtrim($dir, DIRECTORY_SEPARATOR);
$list = [];
$handle = opendir($dir);
if ($handle === false) {
throw new InvalidParamException("Unable to open directory: $dir");
}
while (($file = readdir($handle)) !== false) {
if ($file === '.' || $file === '..') {
continue;
}
$path = $dir . DIRECTORY_SEPARATOR . $file;
if (is_dir($path)) {
list($r, $p) = static::formatBootstrapPath($bootstrapPathPattern, $file, $bootstrapPathFile);
if (is_file($dir . DIRECTORY_SEPARATOR . $p)) {
$list[] = $themesRootPath . '\\' . $r;
continue;
}
}
}
closedir($handle);
return $list;
} | [
"public",
"static",
"function",
"findThemeBootstraps",
"(",
"$",
"themesRootPath",
",",
"$",
"bootstrapPathFile",
",",
"$",
"bootstrapPathPattern",
")",
"{",
"$",
"dir",
"=",
"Yii",
"::",
"getAlias",
"(",
"'@'",
".",
"$",
"themesRootPath",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"\"The dir argument must be a directory: $dir\"",
")",
";",
"}",
"$",
"dir",
"=",
"rtrim",
"(",
"$",
"dir",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"$",
"list",
"=",
"[",
"]",
";",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"$",
"handle",
"===",
"false",
")",
"{",
"throw",
"new",
"InvalidParamException",
"(",
"\"Unable to open directory: $dir\"",
")",
";",
"}",
"while",
"(",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"$",
"file",
"===",
"'.'",
"||",
"$",
"file",
"===",
"'..'",
")",
"{",
"continue",
";",
"}",
"$",
"path",
"=",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"file",
";",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"list",
"(",
"$",
"r",
",",
"$",
"p",
")",
"=",
"static",
"::",
"formatBootstrapPath",
"(",
"$",
"bootstrapPathPattern",
",",
"$",
"file",
",",
"$",
"bootstrapPathFile",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"p",
")",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"themesRootPath",
".",
"'\\\\'",
".",
"$",
"r",
";",
"continue",
";",
"}",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"return",
"$",
"list",
";",
"}"
] | Finds all `Bootstrap` class files in the given themes root path.
@param string $themesRootPath e.g. `themes`
@param string $bootstrapPathFile e.g. `src\Bootstrap`
@param string $bootstrapPathPattern e.g. `{theme-path}\{bootstrap-path-file}`
@return array e.g. ['themes\yii2themeyii\src\Bootstrap'] | [
"Finds",
"all",
"Bootstrap",
"class",
"files",
"in",
"the",
"given",
"themes",
"root",
"path",
"."
] | b51fbf66fe51d16b3061b5ffc26f05eb64c3ea40 | https://github.com/yongtiger/yii2-theme/blob/b51fbf66fe51d16b3061b5ffc26f05eb64c3ea40/src/Bootstrap.php#L117-L144 |
3,535 | atelierspierrot/library | src/Library/HttpFundamental/Request.php | Request.guessFromCurrent | public function guessFromCurrent()
{
$this
->setUrl(UrlHelper::getRequestUrl())
->setProtocol(UrlHelper::getHttpProtocol())
->setMethod($_SERVER['REQUEST_METHOD'])
->setHeaders($this->getallheaders())
->setArguments(isset($_GET) ? $_GET : array())
->setData(isset($_POST) ? $_POST : array())
->setSession(isset($_SESSION) ? $_SESSION : array())
->setFiles(isset($_FILES) ? $_FILES : array())
->setCookies(isset($_COOKIE) ? $_COOKIE : array())
->setAuthenticationUser(isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null)
->setAuthenticationPassword(isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null)
->setAuthenticationType(!empty($_SERVER['PHP_AUTH_DIGEST']) ? 'digest' : 'basic')
;
return $this;
} | php | public function guessFromCurrent()
{
$this
->setUrl(UrlHelper::getRequestUrl())
->setProtocol(UrlHelper::getHttpProtocol())
->setMethod($_SERVER['REQUEST_METHOD'])
->setHeaders($this->getallheaders())
->setArguments(isset($_GET) ? $_GET : array())
->setData(isset($_POST) ? $_POST : array())
->setSession(isset($_SESSION) ? $_SESSION : array())
->setFiles(isset($_FILES) ? $_FILES : array())
->setCookies(isset($_COOKIE) ? $_COOKIE : array())
->setAuthenticationUser(isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null)
->setAuthenticationPassword(isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null)
->setAuthenticationType(!empty($_SERVER['PHP_AUTH_DIGEST']) ? 'digest' : 'basic')
;
return $this;
} | [
"public",
"function",
"guessFromCurrent",
"(",
")",
"{",
"$",
"this",
"->",
"setUrl",
"(",
"UrlHelper",
"::",
"getRequestUrl",
"(",
")",
")",
"->",
"setProtocol",
"(",
"UrlHelper",
"::",
"getHttpProtocol",
"(",
")",
")",
"->",
"setMethod",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
"->",
"setHeaders",
"(",
"$",
"this",
"->",
"getallheaders",
"(",
")",
")",
"->",
"setArguments",
"(",
"isset",
"(",
"$",
"_GET",
")",
"?",
"$",
"_GET",
":",
"array",
"(",
")",
")",
"->",
"setData",
"(",
"isset",
"(",
"$",
"_POST",
")",
"?",
"$",
"_POST",
":",
"array",
"(",
")",
")",
"->",
"setSession",
"(",
"isset",
"(",
"$",
"_SESSION",
")",
"?",
"$",
"_SESSION",
":",
"array",
"(",
")",
")",
"->",
"setFiles",
"(",
"isset",
"(",
"$",
"_FILES",
")",
"?",
"$",
"_FILES",
":",
"array",
"(",
")",
")",
"->",
"setCookies",
"(",
"isset",
"(",
"$",
"_COOKIE",
")",
"?",
"$",
"_COOKIE",
":",
"array",
"(",
")",
")",
"->",
"setAuthenticationUser",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_USER'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'PHP_AUTH_USER'",
"]",
":",
"null",
")",
"->",
"setAuthenticationPassword",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_PW'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'PHP_AUTH_PW'",
"]",
":",
"null",
")",
"->",
"setAuthenticationType",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'PHP_AUTH_DIGEST'",
"]",
")",
"?",
"'digest'",
":",
"'basic'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Populate the request object with current HTTP request values
@return $this
@see \Library\Helper\Url::getRequestUrl() | [
"Populate",
"the",
"request",
"object",
"with",
"current",
"HTTP",
"request",
"values"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/HttpFundamental/Request.php#L167-L184 |
3,536 | atelierspierrot/library | src/Library/HttpFundamental/Request.php | Request._extractSegments | protected function _extractSegments(&$arguments)
{
if (is_string($arguments)) $this->_extractArguments($arguments);
foreach ($arguments as $var=>$val) {
if (empty($val) && strpos($var, '/')!==false) {
$parts = explode('/', $var);
unset($arguments[$var]);
$index = null;
foreach ($parts as $part) {
if (is_null($index)) {
$index = $part;
} else {
$arguments[$index] = $part;
$index = null;
}
}
}
}
} | php | protected function _extractSegments(&$arguments)
{
if (is_string($arguments)) $this->_extractArguments($arguments);
foreach ($arguments as $var=>$val) {
if (empty($val) && strpos($var, '/')!==false) {
$parts = explode('/', $var);
unset($arguments[$var]);
$index = null;
foreach ($parts as $part) {
if (is_null($index)) {
$index = $part;
} else {
$arguments[$index] = $part;
$index = null;
}
}
}
}
} | [
"protected",
"function",
"_extractSegments",
"(",
"&",
"$",
"arguments",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"arguments",
")",
")",
"$",
"this",
"->",
"_extractArguments",
"(",
"$",
"arguments",
")",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"var",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"val",
")",
"&&",
"strpos",
"(",
"$",
"var",
",",
"'/'",
")",
"!==",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"var",
")",
";",
"unset",
"(",
"$",
"arguments",
"[",
"$",
"var",
"]",
")",
";",
"$",
"index",
"=",
"null",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"index",
")",
")",
"{",
"$",
"index",
"=",
"$",
"part",
";",
"}",
"else",
"{",
"$",
"arguments",
"[",
"$",
"index",
"]",
"=",
"$",
"part",
";",
"$",
"index",
"=",
"null",
";",
"}",
"}",
"}",
"}",
"}"
] | Extract the table of "var=>val" arguments pairs from a slashed route
@param array|string $arguments (passed and transformed by reference) | [
"Extract",
"the",
"table",
"of",
"var",
"=",
">",
"val",
"arguments",
"pairs",
"from",
"a",
"slashed",
"route"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/HttpFundamental/Request.php#L661-L679 |
3,537 | atelierspierrot/library | src/Library/HttpFundamental/Request.php | Request.cleanArgument | public static function cleanArgument($arg_value, $flags = ENT_COMPAT, $encoding = 'UTF-8')
{
if (is_string($arg_value)) {
$result = stripslashes( htmlspecialchars($arg_value, ENT_COMPAT, $encoding) );
} elseif (is_array($arg_value)) {
$result = array();
foreach($arg_value as $arg=>$value) {
$result[$arg] = self::cleanArgument($value, $flags, $encoding);
}
}
return $result;
} | php | public static function cleanArgument($arg_value, $flags = ENT_COMPAT, $encoding = 'UTF-8')
{
if (is_string($arg_value)) {
$result = stripslashes( htmlspecialchars($arg_value, ENT_COMPAT, $encoding) );
} elseif (is_array($arg_value)) {
$result = array();
foreach($arg_value as $arg=>$value) {
$result[$arg] = self::cleanArgument($value, $flags, $encoding);
}
}
return $result;
} | [
"public",
"static",
"function",
"cleanArgument",
"(",
"$",
"arg_value",
",",
"$",
"flags",
"=",
"ENT_COMPAT",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"arg_value",
")",
")",
"{",
"$",
"result",
"=",
"stripslashes",
"(",
"htmlspecialchars",
"(",
"$",
"arg_value",
",",
"ENT_COMPAT",
",",
"$",
"encoding",
")",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"arg_value",
")",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arg_value",
"as",
"$",
"arg",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"$",
"arg",
"]",
"=",
"self",
"::",
"cleanArgument",
"(",
"$",
"value",
",",
"$",
"flags",
",",
"$",
"encoding",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Clean the value taken from request arguments or data
@param string $arg_value The parameter name if so, or 'args' to get all parameters values
@param int $flags The PHP flags used with htmlspecialchars() (default is ENT_COMPAT)
@param string $encoding The encoding used with htmlspecialchars() (default is UTF-8)
@return string The cleaned value | [
"Clean",
"the",
"value",
"taken",
"from",
"request",
"arguments",
"or",
"data"
] | a2988a11370d13c7e0dc47f9d2d81c664c30b8dd | https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/HttpFundamental/Request.php#L693-L704 |
3,538 | glendmaatita/Tolkien | src/Tolkien/BuildPost.php | BuildPost.find_all_files | public function find_all_files($dir)
{
$root = array_reverse(scandir($dir));
if(count($root) == 0) return;
foreach($root as $value)
{
if($value === '.' || $value === '..')
{
continue;
}
if(is_file("$dir/$value"))
{
$result[] = "$dir/$value";
$this->posts[] = $this->read( "$dir/$value", $value );
continue;
}
foreach($this->find_all_files("$dir/$value") as $value)
{
$result[] = $value;
}
}
return $result;
} | php | public function find_all_files($dir)
{
$root = array_reverse(scandir($dir));
if(count($root) == 0) return;
foreach($root as $value)
{
if($value === '.' || $value === '..')
{
continue;
}
if(is_file("$dir/$value"))
{
$result[] = "$dir/$value";
$this->posts[] = $this->read( "$dir/$value", $value );
continue;
}
foreach($this->find_all_files("$dir/$value") as $value)
{
$result[] = $value;
}
}
return $result;
} | [
"public",
"function",
"find_all_files",
"(",
"$",
"dir",
")",
"{",
"$",
"root",
"=",
"array_reverse",
"(",
"scandir",
"(",
"$",
"dir",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"root",
")",
"==",
"0",
")",
"return",
";",
"foreach",
"(",
"$",
"root",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"'.'",
"||",
"$",
"value",
"===",
"'..'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_file",
"(",
"\"$dir/$value\"",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\"$dir/$value\"",
";",
"$",
"this",
"->",
"posts",
"[",
"]",
"=",
"$",
"this",
"->",
"read",
"(",
"\"$dir/$value\"",
",",
"$",
"value",
")",
";",
"continue",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"find_all_files",
"(",
"\"$dir/$value\"",
")",
"as",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Find All file on asset dir and create array of Model\Post
@param string $dir
@return recursive | [
"Find",
"All",
"file",
"on",
"asset",
"dir",
"and",
"create",
"array",
"of",
"Model",
"\\",
"Post"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/BuildPost.php#L64-L87 |
3,539 | glendmaatita/Tolkien | src/Tolkien/BuildPost.php | BuildPost.defineAuthor | public function defineAuthor($header)
{
$author = $this->config['authors'][$header['author']];
return new Author($header['author'], $author['name'], $author['email'], $author['signature'], $author['facebook'], $author['twitter'], $author['github']);
} | php | public function defineAuthor($header)
{
$author = $this->config['authors'][$header['author']];
return new Author($header['author'], $author['name'], $author['email'], $author['signature'], $author['facebook'], $author['twitter'], $author['github']);
} | [
"public",
"function",
"defineAuthor",
"(",
"$",
"header",
")",
"{",
"$",
"author",
"=",
"$",
"this",
"->",
"config",
"[",
"'authors'",
"]",
"[",
"$",
"header",
"[",
"'author'",
"]",
"]",
";",
"return",
"new",
"Author",
"(",
"$",
"header",
"[",
"'author'",
"]",
",",
"$",
"author",
"[",
"'name'",
"]",
",",
"$",
"author",
"[",
"'email'",
"]",
",",
"$",
"author",
"[",
"'signature'",
"]",
",",
"$",
"author",
"[",
"'facebook'",
"]",
",",
"$",
"author",
"[",
"'twitter'",
"]",
",",
"$",
"author",
"[",
"'github'",
"]",
")",
";",
"}"
] | Create new Author object instance for Post object
@param array $header Metadata
@return Model\Author | [
"Create",
"new",
"Author",
"object",
"instance",
"for",
"Post",
"object"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/BuildPost.php#L202-L206 |
3,540 | glendmaatita/Tolkien | src/Tolkien/BuildPost.php | BuildPost.defineCategories | public function defineCategories($header)
{
$categories = array();
$cats = explode(',', $header['categories']);
foreach ($cats as $category)
{
$categories[] = new Category(trim($category));
}
return $categories;
} | php | public function defineCategories($header)
{
$categories = array();
$cats = explode(',', $header['categories']);
foreach ($cats as $category)
{
$categories[] = new Category(trim($category));
}
return $categories;
} | [
"public",
"function",
"defineCategories",
"(",
"$",
"header",
")",
"{",
"$",
"categories",
"=",
"array",
"(",
")",
";",
"$",
"cats",
"=",
"explode",
"(",
"','",
",",
"$",
"header",
"[",
"'categories'",
"]",
")",
";",
"foreach",
"(",
"$",
"cats",
"as",
"$",
"category",
")",
"{",
"$",
"categories",
"[",
"]",
"=",
"new",
"Category",
"(",
"trim",
"(",
"$",
"category",
")",
")",
";",
"}",
"return",
"$",
"categories",
";",
"}"
] | Create a list of category from header metadata
@param array $header
@return array(Model\Category) | [
"Create",
"a",
"list",
"of",
"category",
"from",
"header",
"metadata"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/BuildPost.php#L214-L223 |
3,541 | loopsframework/base | src/Loops/Application/WebApplication.php | WebApplication.run | public function run() {
try {
$request = $this->getLoops()->getService("request");
$response = $this->getLoops()->getService("response");
$web_core = $this->getLoops()->getService("web_core");
//dispatch request
echo $web_core->dispatch($this->url, $request, $response);
}
catch(Throwable $exception) {
http_response_code(500);
try {
$renderer = $this->getLoops()->getService("renderer");
echo $renderer->render($exception);
}
catch(Throwable $render_exception) {
Misc::displayException($exception);
}
}
} | php | public function run() {
try {
$request = $this->getLoops()->getService("request");
$response = $this->getLoops()->getService("response");
$web_core = $this->getLoops()->getService("web_core");
//dispatch request
echo $web_core->dispatch($this->url, $request, $response);
}
catch(Throwable $exception) {
http_response_code(500);
try {
$renderer = $this->getLoops()->getService("renderer");
echo $renderer->render($exception);
}
catch(Throwable $render_exception) {
Misc::displayException($exception);
}
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"try",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getLoops",
"(",
")",
"->",
"getService",
"(",
"\"request\"",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getLoops",
"(",
")",
"->",
"getService",
"(",
"\"response\"",
")",
";",
"$",
"web_core",
"=",
"$",
"this",
"->",
"getLoops",
"(",
")",
"->",
"getService",
"(",
"\"web_core\"",
")",
";",
"//dispatch request",
"echo",
"$",
"web_core",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"url",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"exception",
")",
"{",
"http_response_code",
"(",
"500",
")",
";",
"try",
"{",
"$",
"renderer",
"=",
"$",
"this",
"->",
"getLoops",
"(",
")",
"->",
"getService",
"(",
"\"renderer\"",
")",
";",
"echo",
"$",
"renderer",
"->",
"render",
"(",
"$",
"exception",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"render_exception",
")",
"{",
"Misc",
"::",
"displayException",
"(",
"$",
"exception",
")",
";",
"}",
"}",
"}"
] | Runs the request by by dispaching the request via the web core service.
This method will print the resulting output and set http status codes accordingly.
Exceptions will be caught and rendered. | [
"Runs",
"the",
"request",
"by",
"by",
"dispaching",
"the",
"request",
"via",
"the",
"web",
"core",
"service",
".",
"This",
"method",
"will",
"print",
"the",
"resulting",
"output",
"and",
"set",
"http",
"status",
"codes",
"accordingly",
".",
"Exceptions",
"will",
"be",
"caught",
"and",
"rendered",
"."
] | 5a15172ed4e543d7d5ecd8bd65e31f26bab3d192 | https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Application/WebApplication.php#L87-L107 |
3,542 | noordawod/php-util | src/Base64.php | Base64.encode | public static function encode(
/*string*/ $string,
/*boolean*/ $oneLine = true
) {
if(!self::isEncoded($string)) {
$string = base64_encode($string);
}
if($string && $oneLine) {
$string = str_replace(["\r", "\n"], '', $string);
}
return $string;
} | php | public static function encode(
/*string*/ $string,
/*boolean*/ $oneLine = true
) {
if(!self::isEncoded($string)) {
$string = base64_encode($string);
}
if($string && $oneLine) {
$string = str_replace(["\r", "\n"], '', $string);
}
return $string;
} | [
"public",
"static",
"function",
"encode",
"(",
"/*string*/",
"$",
"string",
",",
"/*boolean*/",
"$",
"oneLine",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isEncoded",
"(",
"$",
"string",
")",
")",
"{",
"$",
"string",
"=",
"base64_encode",
"(",
"$",
"string",
")",
";",
"}",
"if",
"(",
"$",
"string",
"&&",
"$",
"oneLine",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"[",
"\"\\r\"",
",",
"\"\\n\"",
"]",
",",
"''",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] | Encodes the specified string as Base64. Note that a previously-encoded
string will not be re-encoded.
@param string $string to encode
@param boolean $oneLine TRUE to return result as a single, long line
@return string Base64-encoded string | [
"Encodes",
"the",
"specified",
"string",
"as",
"Base64",
".",
"Note",
"that",
"a",
"previously",
"-",
"encoded",
"string",
"will",
"not",
"be",
"re",
"-",
"encoded",
"."
] | 6458690cc2c8457914a2aa74b131451d4a8e5797 | https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/Base64.php#L58-L69 |
3,543 | mvccore/ext-form | src/MvcCore/Ext/Form.php | Form.throwNewInvalidArgumentException | protected function throwNewInvalidArgumentException ($errorMsg) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
$str = '['.$selfClass.'] ' . $errorMsg . ' ('
. 'form id: `'.$this->id . '`, '
. 'form type: `'.get_class($this->form).'`'
.')';
throw new \InvalidArgumentException($str);
} | php | protected function throwNewInvalidArgumentException ($errorMsg) {
$selfClass = version_compare(PHP_VERSION, '5.5', '>') ? self::class : __CLASS__;
$str = '['.$selfClass.'] ' . $errorMsg . ' ('
. 'form id: `'.$this->id . '`, '
. 'form type: `'.get_class($this->form).'`'
.')';
throw new \InvalidArgumentException($str);
} | [
"protected",
"function",
"throwNewInvalidArgumentException",
"(",
"$",
"errorMsg",
")",
"{",
"$",
"selfClass",
"=",
"version_compare",
"(",
"PHP_VERSION",
",",
"'5.5'",
",",
"'>'",
")",
"?",
"self",
"::",
"class",
":",
"__CLASS__",
";",
"$",
"str",
"=",
"'['",
".",
"$",
"selfClass",
".",
"'] '",
".",
"$",
"errorMsg",
".",
"' ('",
".",
"'form id: `'",
".",
"$",
"this",
"->",
"id",
".",
"'`, '",
".",
"'form type: `'",
".",
"get_class",
"(",
"$",
"this",
"->",
"form",
")",
".",
"'`'",
".",
"')'",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"str",
")",
";",
"}"
] | Throw new `\InvalidArgumentException` with given
error message and append automatically current class name,
current form id and form class type.
@param string $errorMsg
@throws \InvalidArgumentException | [
"Throw",
"new",
"\\",
"InvalidArgumentException",
"with",
"given",
"error",
"message",
"and",
"append",
"automatically",
"current",
"class",
"name",
"current",
"form",
"id",
"and",
"form",
"class",
"type",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form.php#L86-L93 |
3,544 | mvccore/ext-form | src/MvcCore/Ext/Form.php | Form.PreDispatch | public function PreDispatch () {
if ($this->dispatchState > 1) return $this;
parent::PreDispatch(); // code: `if ($this->dispatchState < 1) $this->Init();` is executed by parent
foreach ($this->fields as $field)
// translate fields if necessary and do any rendering preparation stuff
$field->PreDispatch();
$session = & $this->getSession();
foreach ($session->errors as $errorMsgAndFieldNames) {
list($errorMsg, $fieldNames) = array_merge([], $errorMsgAndFieldNames);
$this->AddError($errorMsg, $fieldNames);
}
if ($session->values) {
foreach ($session->values as $fieldName => $fieldValue) {
$field = $this->fields[$fieldName];
if ($field->GetValue() === NULL)
$field->SetValue($fieldValue);
}
}
$viewClass = $this->viewClass;
$this->view = $viewClass::CreateInstance()
->SetForm($this);
if ($this->viewScript)
$this->view
->SetController($this->parentController)
->SetView($this->parentController->GetView());
$this->dispatchState = 2;
return $this;
} | php | public function PreDispatch () {
if ($this->dispatchState > 1) return $this;
parent::PreDispatch(); // code: `if ($this->dispatchState < 1) $this->Init();` is executed by parent
foreach ($this->fields as $field)
// translate fields if necessary and do any rendering preparation stuff
$field->PreDispatch();
$session = & $this->getSession();
foreach ($session->errors as $errorMsgAndFieldNames) {
list($errorMsg, $fieldNames) = array_merge([], $errorMsgAndFieldNames);
$this->AddError($errorMsg, $fieldNames);
}
if ($session->values) {
foreach ($session->values as $fieldName => $fieldValue) {
$field = $this->fields[$fieldName];
if ($field->GetValue() === NULL)
$field->SetValue($fieldValue);
}
}
$viewClass = $this->viewClass;
$this->view = $viewClass::CreateInstance()
->SetForm($this);
if ($this->viewScript)
$this->view
->SetController($this->parentController)
->SetView($this->parentController->GetView());
$this->dispatchState = 2;
return $this;
} | [
"public",
"function",
"PreDispatch",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dispatchState",
">",
"1",
")",
"return",
"$",
"this",
";",
"parent",
"::",
"PreDispatch",
"(",
")",
";",
"// code: `if ($this->dispatchState < 1) $this->Init();` is executed by parent",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"// translate fields if necessary and do any rendering preparation stuff",
"$",
"field",
"->",
"PreDispatch",
"(",
")",
";",
"$",
"session",
"=",
"&",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"foreach",
"(",
"$",
"session",
"->",
"errors",
"as",
"$",
"errorMsgAndFieldNames",
")",
"{",
"list",
"(",
"$",
"errorMsg",
",",
"$",
"fieldNames",
")",
"=",
"array_merge",
"(",
"[",
"]",
",",
"$",
"errorMsgAndFieldNames",
")",
";",
"$",
"this",
"->",
"AddError",
"(",
"$",
"errorMsg",
",",
"$",
"fieldNames",
")",
";",
"}",
"if",
"(",
"$",
"session",
"->",
"values",
")",
"{",
"foreach",
"(",
"$",
"session",
"->",
"values",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldValue",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"fields",
"[",
"$",
"fieldName",
"]",
";",
"if",
"(",
"$",
"field",
"->",
"GetValue",
"(",
")",
"===",
"NULL",
")",
"$",
"field",
"->",
"SetValue",
"(",
"$",
"fieldValue",
")",
";",
"}",
"}",
"$",
"viewClass",
"=",
"$",
"this",
"->",
"viewClass",
";",
"$",
"this",
"->",
"view",
"=",
"$",
"viewClass",
"::",
"CreateInstance",
"(",
")",
"->",
"SetForm",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"this",
"->",
"viewScript",
")",
"$",
"this",
"->",
"view",
"->",
"SetController",
"(",
"$",
"this",
"->",
"parentController",
")",
"->",
"SetView",
"(",
"$",
"this",
"->",
"parentController",
"->",
"GetView",
"(",
")",
")",
";",
"$",
"this",
"->",
"dispatchState",
"=",
"2",
";",
"return",
"$",
"this",
";",
"}"
] | Prepare form and it's fields for rendering.
This function is called automatically by rendering process if necessary.
But if you need to operate with fields in your controller before rendering
with real session values and initialized session errors, you can call this
method anytime to prepare form for rendering and operate with anything inside.
- Process all defined fields and call `$field->PreDispatch();`
to prepare all fields for rendering process.
- Load any possible error from session and set up
errors into fields and into form object to render them properly.
- Load any possible previously submitted and/or stored values
from session and set up form fields with them.
- Set initialized state to 2, which means - prepared, pre-dispatched for rendering.
@return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm | [
"Prepare",
"form",
"and",
"it",
"s",
"fields",
"for",
"rendering",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form.php#L140-L168 |
3,545 | FiveLab/ResourceBundle | src/Resource/EventListener/SymfonyGrantedRelationListener.php | SymfonyGrantedRelationListener.onBeforeNormalization | public function onBeforeNormalization(BeforeNormalizationEvent $event): void
{
$resource = $event->getResource();
if (!$resource instanceof RelatedResourceInterface) {
return;
}
$relations = $resource->getRelations();
foreach ($relations as $relation) {
if (!$relation instanceof SymfonyGrantedRelation) {
continue;
}
if (!$this->authorizationChecker->isGranted($relation->getAttribute(), $relation->getObject())) {
$resource->removeRelation($relation);
}
}
} | php | public function onBeforeNormalization(BeforeNormalizationEvent $event): void
{
$resource = $event->getResource();
if (!$resource instanceof RelatedResourceInterface) {
return;
}
$relations = $resource->getRelations();
foreach ($relations as $relation) {
if (!$relation instanceof SymfonyGrantedRelation) {
continue;
}
if (!$this->authorizationChecker->isGranted($relation->getAttribute(), $relation->getObject())) {
$resource->removeRelation($relation);
}
}
} | [
"public",
"function",
"onBeforeNormalization",
"(",
"BeforeNormalizationEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"resource",
"=",
"$",
"event",
"->",
"getResource",
"(",
")",
";",
"if",
"(",
"!",
"$",
"resource",
"instanceof",
"RelatedResourceInterface",
")",
"{",
"return",
";",
"}",
"$",
"relations",
"=",
"$",
"resource",
"->",
"getRelations",
"(",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"if",
"(",
"!",
"$",
"relation",
"instanceof",
"SymfonyGrantedRelation",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGranted",
"(",
"$",
"relation",
"->",
"getAttribute",
"(",
")",
",",
"$",
"relation",
"->",
"getObject",
"(",
")",
")",
")",
"{",
"$",
"resource",
"->",
"removeRelation",
"(",
"$",
"relation",
")",
";",
"}",
"}",
"}"
] | Check the grants to relations
@param BeforeNormalizationEvent $event | [
"Check",
"the",
"grants",
"to",
"relations"
] | 048fce7be5357dc23fef1402ef8ca213489e8154 | https://github.com/FiveLab/ResourceBundle/blob/048fce7be5357dc23fef1402ef8ca213489e8154/src/Resource/EventListener/SymfonyGrantedRelationListener.php#L48-L67 |
3,546 | ekyna/Characteristics | Schema/Schema.php | Schema.addGroup | public function addGroup(Group $group)
{
if ($this->hasGroup($group)) {
throw new \InvalidArgumentException(sprintf('Group "%s" is allready defined.', $group->getName()));
}
$this->groups[$group->getName()] = $group;
return $this;
} | php | public function addGroup(Group $group)
{
if ($this->hasGroup($group)) {
throw new \InvalidArgumentException(sprintf('Group "%s" is allready defined.', $group->getName()));
}
$this->groups[$group->getName()] = $group;
return $this;
} | [
"public",
"function",
"addGroup",
"(",
"Group",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasGroup",
"(",
"$",
"group",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Group \"%s\" is allready defined.'",
",",
"$",
"group",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"groups",
"[",
"$",
"group",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"group",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the group.
@param Group $group
@throws \InvalidArgumentException
@return Schema | [
"Adds",
"the",
"group",
"."
] | 118a349fd98a7c28721d3cbaba67ce79d1cffada | https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Schema.php#L111-L120 |
3,547 | ekyna/Characteristics | Schema/Schema.php | Schema.getGroupByName | public function getGroupByName($name)
{
if (!array_key_exists($name, $this->groups)) {
throw new \InvalidArgumentException(sprintf('Can\'t find "%s" group.', $name));
}
return $this->groups[$name];
} | php | public function getGroupByName($name)
{
if (!array_key_exists($name, $this->groups)) {
throw new \InvalidArgumentException(sprintf('Can\'t find "%s" group.', $name));
}
return $this->groups[$name];
} | [
"public",
"function",
"getGroupByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"groups",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Can\\'t find \"%s\" group.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"groups",
"[",
"$",
"name",
"]",
";",
"}"
] | Returns a group by his name.
@param string $name
@throws \InvalidArgumentException
@return Group | [
"Returns",
"a",
"group",
"by",
"his",
"name",
"."
] | 118a349fd98a7c28721d3cbaba67ce79d1cffada | https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Schema.php#L131-L138 |
3,548 | ekyna/Characteristics | Schema/Schema.php | Schema.getDefinitionByIdentifier | public function getDefinitionByIdentifier($identifier)
{
foreach($this->groups as $group) {
foreach($group->getDefinitions() as $definition) {
if ($definition->getIdentifier() === $identifier) {
return $definition;
}
}
}
return null;
} | php | public function getDefinitionByIdentifier($identifier)
{
foreach($this->groups as $group) {
foreach($group->getDefinitions() as $definition) {
if ($definition->getIdentifier() === $identifier) {
return $definition;
}
}
}
return null;
} | [
"public",
"function",
"getDefinitionByIdentifier",
"(",
"$",
"identifier",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"groups",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"group",
"->",
"getDefinitions",
"(",
")",
"as",
"$",
"definition",
")",
"{",
"if",
"(",
"$",
"definition",
"->",
"getIdentifier",
"(",
")",
"===",
"$",
"identifier",
")",
"{",
"return",
"$",
"definition",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns a characteristic definition by his identifier.
@param $identifier
@return Definition|null | [
"Returns",
"a",
"characteristic",
"definition",
"by",
"his",
"identifier",
"."
] | 118a349fd98a7c28721d3cbaba67ce79d1cffada | https://github.com/ekyna/Characteristics/blob/118a349fd98a7c28721d3cbaba67ce79d1cffada/Schema/Schema.php#L155-L165 |
3,549 | lucidphp/xml | src/Normalizer/Normalizer.php | Normalizer.convertValue | protected function convertValue($data)
{
if ($this->isTraversable($data)) {
return $this->recursiveConvertArray($data);
}
if (is_object($data)) {
return $this->convertObject($data) ?: null;
}
return $data;
} | php | protected function convertValue($data)
{
if ($this->isTraversable($data)) {
return $this->recursiveConvertArray($data);
}
if (is_object($data)) {
return $this->convertObject($data) ?: null;
}
return $data;
} | [
"protected",
"function",
"convertValue",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isTraversable",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"recursiveConvertArray",
"(",
"$",
"data",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"convertObject",
"(",
"$",
"data",
")",
"?",
":",
"null",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Conversts a given value into a traversable one.
@param mixed $data
@return mixed | [
"Conversts",
"a",
"given",
"value",
"into",
"a",
"traversable",
"one",
"."
] | 4ff1e92c4071887c2802eb7ee3f3c46632ad7db2 | https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/Normalizer/Normalizer.php#L157-L168 |
3,550 | lucidphp/xml | src/Normalizer/Normalizer.php | Normalizer.recursiveConvertArray | protected function recursiveConvertArray($data)
{
$out = [];
foreach ($data as $key => $value) {
$nkey = $this->normalize($key);
if (in_array($nkey, $this->ignoredAttributes)) {
continue;
}
$out[$nkey] = is_scalar($value) ? $value : $this->convertValue($value);
}
return $out;
} | php | protected function recursiveConvertArray($data)
{
$out = [];
foreach ($data as $key => $value) {
$nkey = $this->normalize($key);
if (in_array($nkey, $this->ignoredAttributes)) {
continue;
}
$out[$nkey] = is_scalar($value) ? $value : $this->convertValue($value);
}
return $out;
} | [
"protected",
"function",
"recursiveConvertArray",
"(",
"$",
"data",
")",
"{",
"$",
"out",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"nkey",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"key",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"nkey",
",",
"$",
"this",
"->",
"ignoredAttributes",
")",
")",
"{",
"continue",
";",
"}",
"$",
"out",
"[",
"$",
"nkey",
"]",
"=",
"is_scalar",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"$",
"this",
"->",
"convertValue",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | Recursivly converts a given value to an array.
@param array $data
@return array | [
"Recursivly",
"converts",
"a",
"given",
"value",
"to",
"an",
"array",
"."
] | 4ff1e92c4071887c2802eb7ee3f3c46632ad7db2 | https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/Normalizer/Normalizer.php#L189-L204 |
3,551 | lucidphp/xml | src/Normalizer/Normalizer.php | Normalizer.setObjectProperties | protected function setObjectProperties(array $properties, $data, array &$out = [])
{
foreach ($properties as $property) {
$prop = $property->getName();
if (in_array($name = $this->normalize($prop), $this->ignoredAttributes)) {
continue;
}
$out[$prop] = $this->getObjectPropertyValue($property, $prop, $data);
}
} | php | protected function setObjectProperties(array $properties, $data, array &$out = [])
{
foreach ($properties as $property) {
$prop = $property->getName();
if (in_array($name = $this->normalize($prop), $this->ignoredAttributes)) {
continue;
}
$out[$prop] = $this->getObjectPropertyValue($property, $prop, $data);
}
} | [
"protected",
"function",
"setObjectProperties",
"(",
"array",
"$",
"properties",
",",
"$",
"data",
",",
"array",
"&",
"$",
"out",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"prop",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"normalize",
"(",
"$",
"prop",
")",
",",
"$",
"this",
"->",
"ignoredAttributes",
")",
")",
"{",
"continue",
";",
"}",
"$",
"out",
"[",
"$",
"prop",
"]",
"=",
"$",
"this",
"->",
"getObjectPropertyValue",
"(",
"$",
"property",
",",
"$",
"prop",
",",
"$",
"data",
")",
";",
"}",
"}"
] | Set opbject properties to an output array.
@param array $properties
@param mixed $data
@param array $out
@return void | [
"Set",
"opbject",
"properties",
"to",
"an",
"output",
"array",
"."
] | 4ff1e92c4071887c2802eb7ee3f3c46632ad7db2 | https://github.com/lucidphp/xml/blob/4ff1e92c4071887c2802eb7ee3f3c46632ad7db2/src/Normalizer/Normalizer.php#L325-L336 |
3,552 | eghojansu/nutrition | src/Utils/CommonUtil.php | CommonUtil.dateSQL | public static function dateSQL($date, $format = 'd-m-Y')
{
if (empty($date)) {
return null;
}
$obj = DateTime::createFromFormat('Y-m-d H:i:s', $date);
if (empty($obj)) {
return null;
}
return $obj->format($format);
} | php | public static function dateSQL($date, $format = 'd-m-Y')
{
if (empty($date)) {
return null;
}
$obj = DateTime::createFromFormat('Y-m-d H:i:s', $date);
if (empty($obj)) {
return null;
}
return $obj->format($format);
} | [
"public",
"static",
"function",
"dateSQL",
"(",
"$",
"date",
",",
"$",
"format",
"=",
"'d-m-Y'",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"date",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"obj",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"date",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"obj",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"obj",
"->",
"format",
"(",
"$",
"format",
")",
";",
"}"
] | SQL timestamp to date format
@param string $date
@param string $format
@return string | [
"SQL",
"timestamp",
"to",
"date",
"format"
] | 3941c62aeb6dafda55349a38dd4107d521f8964a | https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/CommonUtil.php#L27-L39 |
3,553 | eghojansu/nutrition | src/Utils/CommonUtil.php | CommonUtil.random | public static function random($len = 6)
{
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$random = '';
for ($p = 0; $p < $len; $p++) {
$random .= $chars[mt_rand(0, 61)];
}
return $random;
} | php | public static function random($len = 6)
{
$chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$random = '';
for ($p = 0; $p < $len; $p++) {
$random .= $chars[mt_rand(0, 61)];
}
return $random;
} | [
"public",
"static",
"function",
"random",
"(",
"$",
"len",
"=",
"6",
")",
"{",
"$",
"chars",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'",
";",
"$",
"random",
"=",
"''",
";",
"for",
"(",
"$",
"p",
"=",
"0",
";",
"$",
"p",
"<",
"$",
"len",
";",
"$",
"p",
"++",
")",
"{",
"$",
"random",
".=",
"$",
"chars",
"[",
"mt_rand",
"(",
"0",
",",
"61",
")",
"]",
";",
"}",
"return",
"$",
"random",
";",
"}"
] | Get random string
@param integer $len
@return string | [
"Get",
"random",
"string"
] | 3941c62aeb6dafda55349a38dd4107d521f8964a | https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/CommonUtil.php#L85-L94 |
3,554 | eghojansu/nutrition | src/Utils/CommonUtil.php | CommonUtil.lowerLabel | public static function lowerLabel($value, array $labels)
{
ksort($labels);
foreach ($labels as $max => $label) {
if ($value <= $max) {
return $label;
}
}
return end($labels);
} | php | public static function lowerLabel($value, array $labels)
{
ksort($labels);
foreach ($labels as $max => $label) {
if ($value <= $max) {
return $label;
}
}
return end($labels);
} | [
"public",
"static",
"function",
"lowerLabel",
"(",
"$",
"value",
",",
"array",
"$",
"labels",
")",
"{",
"ksort",
"(",
"$",
"labels",
")",
";",
"foreach",
"(",
"$",
"labels",
"as",
"$",
"max",
"=>",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"value",
"<=",
"$",
"max",
")",
"{",
"return",
"$",
"label",
";",
"}",
"}",
"return",
"end",
"(",
"$",
"labels",
")",
";",
"}"
] | Get label that key is lower than value
@param numeric $value
@param string[] $labels with numeric key
@return string | [
"Get",
"label",
"that",
"key",
"is",
"lower",
"than",
"value"
] | 3941c62aeb6dafda55349a38dd4107d521f8964a | https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/CommonUtil.php#L152-L163 |
3,555 | eghojansu/nutrition | src/Utils/CommonUtil.php | CommonUtil.majorVersion | public static function majorVersion($version)
{
$components = explode('.', $version);
foreach ($components as $key => $value) {
if ($key > 0 && is_numeric($value)) {
$components[$key] = '0';
}
}
return implode('.', $components);
} | php | public static function majorVersion($version)
{
$components = explode('.', $version);
foreach ($components as $key => $value) {
if ($key > 0 && is_numeric($value)) {
$components[$key] = '0';
}
}
return implode('.', $components);
} | [
"public",
"static",
"function",
"majorVersion",
"(",
"$",
"version",
")",
"{",
"$",
"components",
"=",
"explode",
"(",
"'.'",
",",
"$",
"version",
")",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
">",
"0",
"&&",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"$",
"components",
"[",
"$",
"key",
"]",
"=",
"'0'",
";",
"}",
"}",
"return",
"implode",
"(",
"'.'",
",",
"$",
"components",
")",
";",
"}"
] | Get major version
@param string $version
@return string | [
"Get",
"major",
"version"
] | 3941c62aeb6dafda55349a38dd4107d521f8964a | https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/Utils/CommonUtil.php#L239-L249 |
3,556 | encorephp/error | src/Handler.php | Handler.setDisplayer | public function setDisplayer(DisplayerInterface $displayer)
{
$this->displayer = $displayer;
if ( ! isset($this->exceptionHandler)) return;
$this->exceptionHandler->setDisplayer($displayer);
} | php | public function setDisplayer(DisplayerInterface $displayer)
{
$this->displayer = $displayer;
if ( ! isset($this->exceptionHandler)) return;
$this->exceptionHandler->setDisplayer($displayer);
} | [
"public",
"function",
"setDisplayer",
"(",
"DisplayerInterface",
"$",
"displayer",
")",
"{",
"$",
"this",
"->",
"displayer",
"=",
"$",
"displayer",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"exceptionHandler",
")",
")",
"return",
";",
"$",
"this",
"->",
"exceptionHandler",
"->",
"setDisplayer",
"(",
"$",
"displayer",
")",
";",
"}"
] | Set the exception displayer
@param DisplayerInterface $displayer | [
"Set",
"the",
"exception",
"displayer"
] | 1e411efa4389412fa2727973a60841bdefb0102b | https://github.com/encorephp/error/blob/1e411efa4389412fa2727973a60841bdefb0102b/src/Handler.php#L29-L36 |
3,557 | encorephp/error | src/Handler.php | Handler.registerExceptionHandler | protected function registerExceptionHandler()
{
$this->exceptionHandler = ExceptionHandler::register(true);
$this->exceptionHandler->setDisplayer($this->displayer);
} | php | protected function registerExceptionHandler()
{
$this->exceptionHandler = ExceptionHandler::register(true);
$this->exceptionHandler->setDisplayer($this->displayer);
} | [
"protected",
"function",
"registerExceptionHandler",
"(",
")",
"{",
"$",
"this",
"->",
"exceptionHandler",
"=",
"ExceptionHandler",
"::",
"register",
"(",
"true",
")",
";",
"$",
"this",
"->",
"exceptionHandler",
"->",
"setDisplayer",
"(",
"$",
"this",
"->",
"displayer",
")",
";",
"}"
] | Register the Symfony exception handler
@return void | [
"Register",
"the",
"Symfony",
"exception",
"handler"
] | 1e411efa4389412fa2727973a60841bdefb0102b | https://github.com/encorephp/error/blob/1e411efa4389412fa2727973a60841bdefb0102b/src/Handler.php#L64-L68 |
3,558 | FiveLab/Resource | src/Assembler/Resolver/ResourceAssemblerResolver.php | ResourceAssemblerResolver.add | public function add(ResourceAssemblerSupportableInterface $supportable, ResourceAssemblerInterface $assembler): void
{
$this->map[] = [$supportable, $assembler];
} | php | public function add(ResourceAssemblerSupportableInterface $supportable, ResourceAssemblerInterface $assembler): void
{
$this->map[] = [$supportable, $assembler];
} | [
"public",
"function",
"add",
"(",
"ResourceAssemblerSupportableInterface",
"$",
"supportable",
",",
"ResourceAssemblerInterface",
"$",
"assembler",
")",
":",
"void",
"{",
"$",
"this",
"->",
"map",
"[",
"]",
"=",
"[",
"$",
"supportable",
",",
"$",
"assembler",
"]",
";",
"}"
] | Add the resource assembler to registry
@param ResourceAssemblerSupportableInterface $supportable
@param ResourceAssemblerInterface $assembler | [
"Add",
"the",
"resource",
"assembler",
"to",
"registry"
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Assembler/Resolver/ResourceAssemblerResolver.php#L36-L39 |
3,559 | 10usb/css-lib | src/PropertySet.php | PropertySet.setProperty | public function setProperty($key, $value = null){
if($key instanceof Property){
$value = $key;
$key = $key->getName();
}elseif(!$value instanceof Property){
$value = new Property($key, $value);
}
foreach($this->properties as $index=>$property){
if($property->getName() == $key){
unset($this->properties[$index]);
}
}
$this->properties[] = $value;
return $this;
} | php | public function setProperty($key, $value = null){
if($key instanceof Property){
$value = $key;
$key = $key->getName();
}elseif(!$value instanceof Property){
$value = new Property($key, $value);
}
foreach($this->properties as $index=>$property){
if($property->getName() == $key){
unset($this->properties[$index]);
}
}
$this->properties[] = $value;
return $this;
} | [
"public",
"function",
"setProperty",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"instanceof",
"Property",
")",
"{",
"$",
"value",
"=",
"$",
"key",
";",
"$",
"key",
"=",
"$",
"key",
"->",
"getName",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"value",
"instanceof",
"Property",
")",
"{",
"$",
"value",
"=",
"new",
"Property",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"properties",
"as",
"$",
"index",
"=>",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
"==",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"properties",
"[",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Appending a property at the end and cleaning up any property with the same name
@param string $key Name of the property
@param string $value String representation of the values | [
"Appending",
"a",
"property",
"at",
"the",
"end",
"and",
"cleaning",
"up",
"any",
"property",
"with",
"the",
"same",
"name"
] | 6370b1404bae3eecb44c214ed4eaaf33113858dd | https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/PropertySet.php#L27-L43 |
3,560 | 10usb/css-lib | src/PropertySet.php | PropertySet.getProperty | public function getProperty($key, &$match = false){
if(is_array($key)){
foreach(array_reverse($this->properties) as $property){
if(in_array($property->getName(), $key)){
$match = $property->getName();
return $property;
}
}
}else{
foreach(array_reverse($this->properties) as $property){
if($property->getName()==$key){
$match = $key;
return $property;
}
}
}
return false;
} | php | public function getProperty($key, &$match = false){
if(is_array($key)){
foreach(array_reverse($this->properties) as $property){
if(in_array($property->getName(), $key)){
$match = $property->getName();
return $property;
}
}
}else{
foreach(array_reverse($this->properties) as $property){
if($property->getName()==$key){
$match = $key;
return $property;
}
}
}
return false;
} | [
"public",
"function",
"getProperty",
"(",
"$",
"key",
",",
"&",
"$",
"match",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"properties",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"key",
")",
")",
"{",
"$",
"match",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"property",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"this",
"->",
"properties",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"$",
"property",
"->",
"getName",
"(",
")",
"==",
"$",
"key",
")",
"{",
"$",
"match",
"=",
"$",
"key",
";",
"return",
"$",
"property",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Return the property if it is within this set otherwise retuns false
@param string|string[] $key Name or array of names of the property to obtain
@param string|bool $match Name of the matched property
@return \csslib\Property|boolean | [
"Return",
"the",
"property",
"if",
"it",
"is",
"within",
"this",
"set",
"otherwise",
"retuns",
"false"
] | 6370b1404bae3eecb44c214ed4eaaf33113858dd | https://github.com/10usb/css-lib/blob/6370b1404bae3eecb44c214ed4eaaf33113858dd/src/PropertySet.php#L51-L68 |
3,561 | extendsframework/extends-application | src/Framework/ServiceLocator/Factory/ApplicationFactory.php | ApplicationFactory.getHttpApplication | protected function getHttpApplication(ServiceLocatorInterface $serviceLocator): HttpApplication
{
$chain = $serviceLocator->getService(MiddlewareChainInterface::class);
$request = $serviceLocator->getService(RequestInterface::class);
/**
* @var MiddlewareChainInterface $chain
* @var RequestInterface $request
*/
return new HttpApplication(
$chain,
$request,
$serviceLocator,
$extra['modules'] ?? []
);
} | php | protected function getHttpApplication(ServiceLocatorInterface $serviceLocator): HttpApplication
{
$chain = $serviceLocator->getService(MiddlewareChainInterface::class);
$request = $serviceLocator->getService(RequestInterface::class);
/**
* @var MiddlewareChainInterface $chain
* @var RequestInterface $request
*/
return new HttpApplication(
$chain,
$request,
$serviceLocator,
$extra['modules'] ?? []
);
} | [
"protected",
"function",
"getHttpApplication",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
":",
"HttpApplication",
"{",
"$",
"chain",
"=",
"$",
"serviceLocator",
"->",
"getService",
"(",
"MiddlewareChainInterface",
"::",
"class",
")",
";",
"$",
"request",
"=",
"$",
"serviceLocator",
"->",
"getService",
"(",
"RequestInterface",
"::",
"class",
")",
";",
"/**\n * @var MiddlewareChainInterface $chain\n * @var RequestInterface $request\n */",
"return",
"new",
"HttpApplication",
"(",
"$",
"chain",
",",
"$",
"request",
",",
"$",
"serviceLocator",
",",
"$",
"extra",
"[",
"'modules'",
"]",
"??",
"[",
"]",
")",
";",
"}"
] | Get HTTP application.
@param ServiceLocatorInterface $serviceLocator
@return HttpApplication
@throws ServiceLocatorException | [
"Get",
"HTTP",
"application",
"."
] | 89b74594310e60542d5714e2db33ae0feb0f9d34 | https://github.com/extendsframework/extends-application/blob/89b74594310e60542d5714e2db33ae0feb0f9d34/src/Framework/ServiceLocator/Factory/ApplicationFactory.php#L58-L73 |
3,562 | liuggio/RackspaceCloudFilesStreamWrapper | src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php | RackspaceCloudFilesStreamWrapper.unregisterStreamWrapperClass | public static function unregisterStreamWrapperClass()
{
$unregisterFunction = self::getStreamWrapperUnregisterFunction();
if (!isset(self::$protocolName)) {
throw new \RuntimeException(
sprintf('Scheme name not found for %s', __CLASS__));
}
@$unregisterFunction(self::$protocolName);
} | php | public static function unregisterStreamWrapperClass()
{
$unregisterFunction = self::getStreamWrapperUnregisterFunction();
if (!isset(self::$protocolName)) {
throw new \RuntimeException(
sprintf('Scheme name not found for %s', __CLASS__));
}
@$unregisterFunction(self::$protocolName);
} | [
"public",
"static",
"function",
"unregisterStreamWrapperClass",
"(",
")",
"{",
"$",
"unregisterFunction",
"=",
"self",
"::",
"getStreamWrapperUnregisterFunction",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"protocolName",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Scheme name not found for %s'",
",",
"__CLASS__",
")",
")",
";",
"}",
"@",
"$",
"unregisterFunction",
"(",
"self",
"::",
"$",
"protocolName",
")",
";",
"}"
] | Registers the stream wrapper to handle the specified protocolName
@param string $schema Default is rscf | [
"Registers",
"the",
"stream",
"wrapper",
"to",
"handle",
"the",
"specified",
"protocolName"
] | 241fcf75062cd433eebacf9d3180ea74f5ff5f2b | https://github.com/liuggio/RackspaceCloudFilesStreamWrapper/blob/241fcf75062cd433eebacf9d3180ea74f5ff5f2b/src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php#L60-L69 |
3,563 | liuggio/RackspaceCloudFilesStreamWrapper | src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php | RackspaceCloudFilesStreamWrapper.stream_flush | public function stream_flush()
{
if (!$this->getResource()) {
return false;
}
$buffer = $this->getDataBuffer();
$bufferWritten = $buffer;
$retVal = true;
if (!empty($buffer)) {
$object = $this->getResource()->getObject();
$mimetype = $this->getService()->guessFileType($this->getResource()->getResourceName());
$object->content_type = $mimetype;
$object->setData($buffer);
$object->Create();
}
if (strlen($bufferWritten) == strlen($buffer)) {
$this->setDataBuffer(null);
} else {
$this->setDataBuffer($buffer);
}
$this->setDataBuffer(null);
return $retVal;
} | php | public function stream_flush()
{
if (!$this->getResource()) {
return false;
}
$buffer = $this->getDataBuffer();
$bufferWritten = $buffer;
$retVal = true;
if (!empty($buffer)) {
$object = $this->getResource()->getObject();
$mimetype = $this->getService()->guessFileType($this->getResource()->getResourceName());
$object->content_type = $mimetype;
$object->setData($buffer);
$object->Create();
}
if (strlen($bufferWritten) == strlen($buffer)) {
$this->setDataBuffer(null);
} else {
$this->setDataBuffer($buffer);
}
$this->setDataBuffer(null);
return $retVal;
} | [
"public",
"function",
"stream_flush",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getResource",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"buffer",
"=",
"$",
"this",
"->",
"getDataBuffer",
"(",
")",
";",
"$",
"bufferWritten",
"=",
"$",
"buffer",
";",
"$",
"retVal",
"=",
"true",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"buffer",
")",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
"->",
"getObject",
"(",
")",
";",
"$",
"mimetype",
"=",
"$",
"this",
"->",
"getService",
"(",
")",
"->",
"guessFileType",
"(",
"$",
"this",
"->",
"getResource",
"(",
")",
"->",
"getResourceName",
"(",
")",
")",
";",
"$",
"object",
"->",
"content_type",
"=",
"$",
"mimetype",
";",
"$",
"object",
"->",
"setData",
"(",
"$",
"buffer",
")",
";",
"$",
"object",
"->",
"Create",
"(",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"bufferWritten",
")",
"==",
"strlen",
"(",
"$",
"buffer",
")",
")",
"{",
"$",
"this",
"->",
"setDataBuffer",
"(",
"null",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setDataBuffer",
"(",
"$",
"buffer",
")",
";",
"}",
"$",
"this",
"->",
"setDataBuffer",
"(",
"null",
")",
";",
"return",
"$",
"retVal",
";",
"}"
] | Flush the data buffer to the CDN.
@return bool | [
"Flush",
"the",
"data",
"buffer",
"to",
"the",
"CDN",
"."
] | 241fcf75062cd433eebacf9d3180ea74f5ff5f2b | https://github.com/liuggio/RackspaceCloudFilesStreamWrapper/blob/241fcf75062cd433eebacf9d3180ea74f5ff5f2b/src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php#L201-L227 |
3,564 | liuggio/RackspaceCloudFilesStreamWrapper | src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php | RackspaceCloudFilesStreamWrapper.reset | public function reset()
{
$this->setPosition(0);
$this->setOnWriteDataMode(false);
$this->setDataBuffer(null);
$this->setResource(null);
} | php | public function reset()
{
$this->setPosition(0);
$this->setOnWriteDataMode(false);
$this->setDataBuffer(null);
$this->setResource(null);
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"setPosition",
"(",
"0",
")",
";",
"$",
"this",
"->",
"setOnWriteDataMode",
"(",
"false",
")",
";",
"$",
"this",
"->",
"setDataBuffer",
"(",
"null",
")",
";",
"$",
"this",
"->",
"setResource",
"(",
"null",
")",
";",
"}"
] | reset the variable | [
"reset",
"the",
"variable"
] | 241fcf75062cd433eebacf9d3180ea74f5ff5f2b | https://github.com/liuggio/RackspaceCloudFilesStreamWrapper/blob/241fcf75062cd433eebacf9d3180ea74f5ff5f2b/src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php#L432-L438 |
3,565 | liuggio/RackspaceCloudFilesStreamWrapper | src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php | RackspaceCloudFilesStreamWrapper.initFromPath | public function initFromPath($path)
{
$this->setPosition(0);
$this->setDataBuffer(null);
$resource = $this->getService()->createResourceFromPath($path);
if (!$resource) {
return false;
}
$this->setResource($resource);
return $this;
} | php | public function initFromPath($path)
{
$this->setPosition(0);
$this->setDataBuffer(null);
$resource = $this->getService()->createResourceFromPath($path);
if (!$resource) {
return false;
}
$this->setResource($resource);
return $this;
} | [
"public",
"function",
"initFromPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"setPosition",
"(",
"0",
")",
";",
"$",
"this",
"->",
"setDataBuffer",
"(",
"null",
")",
";",
"$",
"resource",
"=",
"$",
"this",
"->",
"getService",
"(",
")",
"->",
"createResourceFromPath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"resource",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setResource",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"this",
";",
"}"
] | creates the resource, the container and the object by the path given
@param string $path
@return bool|RackspaceCloudFilesStreamWrapper | [
"creates",
"the",
"resource",
"the",
"container",
"and",
"the",
"object",
"by",
"the",
"path",
"given"
] | 241fcf75062cd433eebacf9d3180ea74f5ff5f2b | https://github.com/liuggio/RackspaceCloudFilesStreamWrapper/blob/241fcf75062cd433eebacf9d3180ea74f5ff5f2b/src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php#L446-L458 |
3,566 | liuggio/RackspaceCloudFilesStreamWrapper | src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php | RackspaceCloudFilesStreamWrapper.appendDataBuffer | public function appendDataBuffer($data)
{
if (is_null($this->dataBuffer)) {
$this->dataBuffer = $data;
} else {
$this->dataBuffer .= $data;
}
return $this;
} | php | public function appendDataBuffer($data)
{
if (is_null($this->dataBuffer)) {
$this->dataBuffer = $data;
} else {
$this->dataBuffer .= $data;
}
return $this;
} | [
"public",
"function",
"appendDataBuffer",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"dataBuffer",
")",
")",
"{",
"$",
"this",
"->",
"dataBuffer",
"=",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"dataBuffer",
".=",
"$",
"data",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Append some data to the current property data
@param string $data
@return RackspaceCloudFilesStreamWrapper | [
"Append",
"some",
"data",
"to",
"the",
"current",
"property",
"data"
] | 241fcf75062cd433eebacf9d3180ea74f5ff5f2b | https://github.com/liuggio/RackspaceCloudFilesStreamWrapper/blob/241fcf75062cd433eebacf9d3180ea74f5ff5f2b/src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php#L575-L583 |
3,567 | liuggio/RackspaceCloudFilesStreamWrapper | src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php | RackspaceCloudFilesStreamWrapper.appendPosition | public function appendPosition($length)
{
$this->dataPosition = (int) $this->dataPosition;
$this->dataPosition += (int) $length;
return $this;
} | php | public function appendPosition($length)
{
$this->dataPosition = (int) $this->dataPosition;
$this->dataPosition += (int) $length;
return $this;
} | [
"public",
"function",
"appendPosition",
"(",
"$",
"length",
")",
"{",
"$",
"this",
"->",
"dataPosition",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"dataPosition",
";",
"$",
"this",
"->",
"dataPosition",
"+=",
"(",
"int",
")",
"$",
"length",
";",
"return",
"$",
"this",
";",
"}"
] | sum the int of the position to the var given
@param int $length
@return RackspaceCloudFilesStreamWrapper | [
"sum",
"the",
"int",
"of",
"the",
"position",
"to",
"the",
"var",
"given"
] | 241fcf75062cd433eebacf9d3180ea74f5ff5f2b | https://github.com/liuggio/RackspaceCloudFilesStreamWrapper/blob/241fcf75062cd433eebacf9d3180ea74f5ff5f2b/src/Liuggio/RackspaceCloudFilesStreamWrapper/StreamWrapper/RackspaceCloudFilesStreamWrapper.php#L591-L596 |
3,568 | konservs/brilliant.framework | libraries/MVC/BController.php | BController.field_get | public function field_get($type,$com=''){
if(empty($com)){
$fn=BLIBRARIESFRAMEWORKPATH.'mvc'.DIRECTORY_SEPARATOR.'field'.DIRECTORY_SEPARATOR.$type.'.php';
$class='BControllerField_'.$type;
} else {
$fn=BCOMPONENTSAPPLICATIONPATH.$com.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR.$type.'.php';
if(!file_exists($fn)){
$fn=BCOMPONENTSFRAMEWORKPATH.$com.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR.$type.'.php';
}
$class='BControllerField_'.$com.'_'.$type;
}
if(!file_exists($fn)){
if(DEBUG_MODE){
BDebug::error('File "'.$fn.'" does not exist! type='.$type.', com='.$com);
}
return NULL;
}
require_once($fn);
$field=new $class;
$field->controller=$this;
$field->com=$com;
return $field;
} | php | public function field_get($type,$com=''){
if(empty($com)){
$fn=BLIBRARIESFRAMEWORKPATH.'mvc'.DIRECTORY_SEPARATOR.'field'.DIRECTORY_SEPARATOR.$type.'.php';
$class='BControllerField_'.$type;
} else {
$fn=BCOMPONENTSAPPLICATIONPATH.$com.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR.$type.'.php';
if(!file_exists($fn)){
$fn=BCOMPONENTSFRAMEWORKPATH.$com.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR.$type.'.php';
}
$class='BControllerField_'.$com.'_'.$type;
}
if(!file_exists($fn)){
if(DEBUG_MODE){
BDebug::error('File "'.$fn.'" does not exist! type='.$type.', com='.$com);
}
return NULL;
}
require_once($fn);
$field=new $class;
$field->controller=$this;
$field->com=$com;
return $field;
} | [
"public",
"function",
"field_get",
"(",
"$",
"type",
",",
"$",
"com",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"com",
")",
")",
"{",
"$",
"fn",
"=",
"BLIBRARIESFRAMEWORKPATH",
".",
"'mvc'",
".",
"DIRECTORY_SEPARATOR",
".",
"'field'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"type",
".",
"'.php'",
";",
"$",
"class",
"=",
"'BControllerField_'",
".",
"$",
"type",
";",
"}",
"else",
"{",
"$",
"fn",
"=",
"BCOMPONENTSAPPLICATIONPATH",
".",
"$",
"com",
".",
"DIRECTORY_SEPARATOR",
".",
"'fields'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"type",
".",
"'.php'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fn",
")",
")",
"{",
"$",
"fn",
"=",
"BCOMPONENTSFRAMEWORKPATH",
".",
"$",
"com",
".",
"DIRECTORY_SEPARATOR",
".",
"'fields'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"type",
".",
"'.php'",
";",
"}",
"$",
"class",
"=",
"'BControllerField_'",
".",
"$",
"com",
".",
"'_'",
".",
"$",
"type",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fn",
")",
")",
"{",
"if",
"(",
"DEBUG_MODE",
")",
"{",
"BDebug",
"::",
"error",
"(",
"'File \"'",
".",
"$",
"fn",
".",
"'\" does not exist! type='",
".",
"$",
"type",
".",
"', com='",
".",
"$",
"com",
")",
";",
"}",
"return",
"NULL",
";",
"}",
"require_once",
"(",
"$",
"fn",
")",
";",
"$",
"field",
"=",
"new",
"$",
"class",
";",
"$",
"field",
"->",
"controller",
"=",
"$",
"this",
";",
"$",
"field",
"->",
"com",
"=",
"$",
"com",
";",
"return",
"$",
"field",
";",
"}"
] | Load fields objects by component & field type
@return null|\BControllerField | [
"Load",
"fields",
"objects",
"by",
"component",
"&",
"field",
"type"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/MVC/BController.php#L43-L65 |
3,569 | konservs/brilliant.framework | libraries/MVC/BController.php | BController.softmodule_fields_list | public function softmodule_fields_list($fview,$fcontroller=NULL){
$mylist=$this->softmodules_list();
$myitm=NULL;
//Search the necessary softmodule...
foreach($mylist as $itm){
if($itm->view==$fview){
$myitm=$itm;
}
}
if(empty($myitm)){
return false;
}
$params=array();
foreach($myitm->params as $p){
$fld=$this->field_get($p->fieldtype,$p->com);
if(empty($fld)){
continue;
}
$fld->controller=empty($fcontroller)?$this:$fcontroller;
$fld->name=$p->name;
$fld->id=$p->id;
$fld->fieldtype=$p->fieldtype;
$fld->params=$p->params;
$fld->prepare();
$params[]=$fld;
}
return $params;
} | php | public function softmodule_fields_list($fview,$fcontroller=NULL){
$mylist=$this->softmodules_list();
$myitm=NULL;
//Search the necessary softmodule...
foreach($mylist as $itm){
if($itm->view==$fview){
$myitm=$itm;
}
}
if(empty($myitm)){
return false;
}
$params=array();
foreach($myitm->params as $p){
$fld=$this->field_get($p->fieldtype,$p->com);
if(empty($fld)){
continue;
}
$fld->controller=empty($fcontroller)?$this:$fcontroller;
$fld->name=$p->name;
$fld->id=$p->id;
$fld->fieldtype=$p->fieldtype;
$fld->params=$p->params;
$fld->prepare();
$params[]=$fld;
}
return $params;
} | [
"public",
"function",
"softmodule_fields_list",
"(",
"$",
"fview",
",",
"$",
"fcontroller",
"=",
"NULL",
")",
"{",
"$",
"mylist",
"=",
"$",
"this",
"->",
"softmodules_list",
"(",
")",
";",
"$",
"myitm",
"=",
"NULL",
";",
"//Search the necessary softmodule...",
"foreach",
"(",
"$",
"mylist",
"as",
"$",
"itm",
")",
"{",
"if",
"(",
"$",
"itm",
"->",
"view",
"==",
"$",
"fview",
")",
"{",
"$",
"myitm",
"=",
"$",
"itm",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"myitm",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"myitm",
"->",
"params",
"as",
"$",
"p",
")",
"{",
"$",
"fld",
"=",
"$",
"this",
"->",
"field_get",
"(",
"$",
"p",
"->",
"fieldtype",
",",
"$",
"p",
"->",
"com",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fld",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fld",
"->",
"controller",
"=",
"empty",
"(",
"$",
"fcontroller",
")",
"?",
"$",
"this",
":",
"$",
"fcontroller",
";",
"$",
"fld",
"->",
"name",
"=",
"$",
"p",
"->",
"name",
";",
"$",
"fld",
"->",
"id",
"=",
"$",
"p",
"->",
"id",
";",
"$",
"fld",
"->",
"fieldtype",
"=",
"$",
"p",
"->",
"fieldtype",
";",
"$",
"fld",
"->",
"params",
"=",
"$",
"p",
"->",
"params",
";",
"$",
"fld",
"->",
"prepare",
"(",
")",
";",
"$",
"params",
"[",
"]",
"=",
"$",
"fld",
";",
"}",
"return",
"$",
"params",
";",
"}"
] | Load fields objects list...
@return array soft modules list for current component | [
"Load",
"fields",
"objects",
"list",
"..."
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/MVC/BController.php#L70-L97 |
3,570 | konservs/brilliant.framework | libraries/MVC/BController.php | BController.LoadModel | public function LoadModel($mdlname=''){
if(empty($mdlname)){
bimport('mvc.model');
return new BModel();
}
$fn=BCOMPONENTSAPPLICATIONPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
if(!file_exists($fn)){
$fn=BCOMPONENTSFRAMEWORKPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
}
$class='Model_'.$this->componentname.'_'.$mdlname;
if(!file_exists($fn)){
echo('File "'.$fn.'" does not exist!');
return NULL;
}
require_once($fn);
$model=new $class;
$model->controller=$this;
return $model;
} | php | public function LoadModel($mdlname=''){
if(empty($mdlname)){
bimport('mvc.model');
return new BModel();
}
$fn=BCOMPONENTSAPPLICATIONPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
if(!file_exists($fn)){
$fn=BCOMPONENTSFRAMEWORKPATH.$this->componentname.DIRECTORY_SEPARATOR.'models'.DIRECTORY_SEPARATOR.$mdlname.'.php';
}
$class='Model_'.$this->componentname.'_'.$mdlname;
if(!file_exists($fn)){
echo('File "'.$fn.'" does not exist!');
return NULL;
}
require_once($fn);
$model=new $class;
$model->controller=$this;
return $model;
} | [
"public",
"function",
"LoadModel",
"(",
"$",
"mdlname",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"mdlname",
")",
")",
"{",
"bimport",
"(",
"'mvc.model'",
")",
";",
"return",
"new",
"BModel",
"(",
")",
";",
"}",
"$",
"fn",
"=",
"BCOMPONENTSAPPLICATIONPATH",
".",
"$",
"this",
"->",
"componentname",
".",
"DIRECTORY_SEPARATOR",
".",
"'models'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"mdlname",
".",
"'.php'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fn",
")",
")",
"{",
"$",
"fn",
"=",
"BCOMPONENTSFRAMEWORKPATH",
".",
"$",
"this",
"->",
"componentname",
".",
"DIRECTORY_SEPARATOR",
".",
"'models'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"mdlname",
".",
"'.php'",
";",
"}",
"$",
"class",
"=",
"'Model_'",
".",
"$",
"this",
"->",
"componentname",
".",
"'_'",
".",
"$",
"mdlname",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fn",
")",
")",
"{",
"echo",
"(",
"'File \"'",
".",
"$",
"fn",
".",
"'\" does not exist!'",
")",
";",
"return",
"NULL",
";",
"}",
"require_once",
"(",
"$",
"fn",
")",
";",
"$",
"model",
"=",
"new",
"$",
"class",
";",
"$",
"model",
"->",
"controller",
"=",
"$",
"this",
";",
"return",
"$",
"model",
";",
"}"
] | Load the model of current component by alias
@param type $mdlname
@return null|\BModel | [
"Load",
"the",
"model",
"of",
"current",
"component",
"by",
"alias"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/MVC/BController.php#L111-L129 |
3,571 | konservs/brilliant.framework | libraries/MVC/BController.php | BController.LoadView | public function LoadView($viewname){
$fn=BCOMPONENTSAPPLICATIONPATH.$this->componentname.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$viewname.'.php';
if(!file_exists($fn)){
$fn=BCOMPONENTSFRAMEWORKPATH.$this->componentname.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$viewname.'.php';
}
$class='View_'.$this->componentname.'_'.$viewname;
if(!file_exists($fn)){
return NULL;
}
require_once($fn);
$view=new $class;
$view->controller=$this;
$view->componentname=$this->componentname;
$view->templatename=$this->templatename;
$view->viewname=$viewname;
$view->init();
return $view;
} | php | public function LoadView($viewname){
$fn=BCOMPONENTSAPPLICATIONPATH.$this->componentname.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$viewname.'.php';
if(!file_exists($fn)){
$fn=BCOMPONENTSFRAMEWORKPATH.$this->componentname.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$viewname.'.php';
}
$class='View_'.$this->componentname.'_'.$viewname;
if(!file_exists($fn)){
return NULL;
}
require_once($fn);
$view=new $class;
$view->controller=$this;
$view->componentname=$this->componentname;
$view->templatename=$this->templatename;
$view->viewname=$viewname;
$view->init();
return $view;
} | [
"public",
"function",
"LoadView",
"(",
"$",
"viewname",
")",
"{",
"$",
"fn",
"=",
"BCOMPONENTSAPPLICATIONPATH",
".",
"$",
"this",
"->",
"componentname",
".",
"DIRECTORY_SEPARATOR",
".",
"'views'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"viewname",
".",
"'.php'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fn",
")",
")",
"{",
"$",
"fn",
"=",
"BCOMPONENTSFRAMEWORKPATH",
".",
"$",
"this",
"->",
"componentname",
".",
"DIRECTORY_SEPARATOR",
".",
"'views'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"viewname",
".",
"'.php'",
";",
"}",
"$",
"class",
"=",
"'View_'",
".",
"$",
"this",
"->",
"componentname",
".",
"'_'",
".",
"$",
"viewname",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fn",
")",
")",
"{",
"return",
"NULL",
";",
"}",
"require_once",
"(",
"$",
"fn",
")",
";",
"$",
"view",
"=",
"new",
"$",
"class",
";",
"$",
"view",
"->",
"controller",
"=",
"$",
"this",
";",
"$",
"view",
"->",
"componentname",
"=",
"$",
"this",
"->",
"componentname",
";",
"$",
"view",
"->",
"templatename",
"=",
"$",
"this",
"->",
"templatename",
";",
"$",
"view",
"->",
"viewname",
"=",
"$",
"viewname",
";",
"$",
"view",
"->",
"init",
"(",
")",
";",
"return",
"$",
"view",
";",
"}"
] | Load the view of current component by alias
@param string $viewname
@return null|\BView | [
"Load",
"the",
"view",
"of",
"current",
"component",
"by",
"alias"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/MVC/BController.php#L136-L153 |
3,572 | lower-speck/lower-speck-php | src/Specification.php | Specification.idIsDuplicate | public function idIsDuplicate(string $id) : bool
{
$id = strtolower($id);
return isset($this->byId[$id]) && count($this->byId[$id]) > 1;
} | php | public function idIsDuplicate(string $id) : bool
{
$id = strtolower($id);
return isset($this->byId[$id]) && count($this->byId[$id]) > 1;
} | [
"public",
"function",
"idIsDuplicate",
"(",
"string",
"$",
"id",
")",
":",
"bool",
"{",
"$",
"id",
"=",
"strtolower",
"(",
"$",
"id",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"byId",
"[",
"$",
"id",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"byId",
"[",
"$",
"id",
"]",
")",
">",
"1",
";",
"}"
] | Tells whether there is more than one requirement identified by the id.
If there are none, this returns false.
@param string $id
@return bool | [
"Tells",
"whether",
"there",
"is",
"more",
"than",
"one",
"requirement",
"identified",
"by",
"the",
"id",
".",
"If",
"there",
"are",
"none",
"this",
"returns",
"false",
"."
] | 21fcb38d9773b17fe293e86f8a5d2c59a0b0ae6c | https://github.com/lower-speck/lower-speck-php/blob/21fcb38d9773b17fe293e86f8a5d2c59a0b0ae6c/src/Specification.php#L61-L65 |
3,573 | thecodingmachine/html.utils.weblibrarymanager | src/InlineWebLibrary.php | InlineWebLibrary.setJSFromFile | public function setJSFromFile(string $filename, Scopable $scope = null, bool $relativeToRootPath = true): void
{
$this->jsElement = new HtmlFromFile($filename, $scope, $relativeToRootPath);
} | php | public function setJSFromFile(string $filename, Scopable $scope = null, bool $relativeToRootPath = true): void
{
$this->jsElement = new HtmlFromFile($filename, $scope, $relativeToRootPath);
} | [
"public",
"function",
"setJSFromFile",
"(",
"string",
"$",
"filename",
",",
"Scopable",
"$",
"scope",
"=",
"null",
",",
"bool",
"$",
"relativeToRootPath",
"=",
"true",
")",
":",
"void",
"{",
"$",
"this",
"->",
"jsElement",
"=",
"new",
"HtmlFromFile",
"(",
"$",
"filename",
",",
"$",
"scope",
",",
"$",
"relativeToRootPath",
")",
";",
"}"
] | Sets the script outputed in the JS section
@param string $filename
@param Scopable $scope
@param bool $relativeToRootPath | [
"Sets",
"the",
"script",
"outputed",
"in",
"the",
"JS",
"section"
] | e1e5e06d7221a4e77196798ca8bdc3908025eb51 | https://github.com/thecodingmachine/html.utils.weblibrarymanager/blob/e1e5e06d7221a4e77196798ca8bdc3908025eb51/src/InlineWebLibrary.php#L138-L141 |
3,574 | thecodingmachine/html.utils.weblibrarymanager | src/InlineWebLibrary.php | InlineWebLibrary.setCSSFromFile | public function setCSSFromFile(string $filename, Scopable $scope = null, bool $relativeToRootPath = true): void
{
$this->cssElement = new HtmlFromFile($filename, $scope, $relativeToRootPath);
} | php | public function setCSSFromFile(string $filename, Scopable $scope = null, bool $relativeToRootPath = true): void
{
$this->cssElement = new HtmlFromFile($filename, $scope, $relativeToRootPath);
} | [
"public",
"function",
"setCSSFromFile",
"(",
"string",
"$",
"filename",
",",
"Scopable",
"$",
"scope",
"=",
"null",
",",
"bool",
"$",
"relativeToRootPath",
"=",
"true",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cssElement",
"=",
"new",
"HtmlFromFile",
"(",
"$",
"filename",
",",
"$",
"scope",
",",
"$",
"relativeToRootPath",
")",
";",
"}"
] | Sets the script outputed in the CSS section
@param string $filename
@param Scopable $scope
@param bool $relativeToRootPath | [
"Sets",
"the",
"script",
"outputed",
"in",
"the",
"CSS",
"section"
] | e1e5e06d7221a4e77196798ca8bdc3908025eb51 | https://github.com/thecodingmachine/html.utils.weblibrarymanager/blob/e1e5e06d7221a4e77196798ca8bdc3908025eb51/src/InlineWebLibrary.php#L159-L162 |
3,575 | thecodingmachine/html.utils.weblibrarymanager | src/InlineWebLibrary.php | InlineWebLibrary.setAdditionalElementFromFile | public function setAdditionalElementFromFile(string $filename, Scopable $scope = null, bool $relativeToRootPath = true): void
{
$this->additionalElement = new HtmlFromFile($filename, $scope, $relativeToRootPath);
} | php | public function setAdditionalElementFromFile(string $filename, Scopable $scope = null, bool $relativeToRootPath = true): void
{
$this->additionalElement = new HtmlFromFile($filename, $scope, $relativeToRootPath);
} | [
"public",
"function",
"setAdditionalElementFromFile",
"(",
"string",
"$",
"filename",
",",
"Scopable",
"$",
"scope",
"=",
"null",
",",
"bool",
"$",
"relativeToRootPath",
"=",
"true",
")",
":",
"void",
"{",
"$",
"this",
"->",
"additionalElement",
"=",
"new",
"HtmlFromFile",
"(",
"$",
"filename",
",",
"$",
"scope",
",",
"$",
"relativeToRootPath",
")",
";",
"}"
] | Sets the additional items outputed below the JS and CSS sections
@param string $filename
@param Scopable $scope
@param bool $relativeToRootPath | [
"Sets",
"the",
"additional",
"items",
"outputed",
"below",
"the",
"JS",
"and",
"CSS",
"sections"
] | e1e5e06d7221a4e77196798ca8bdc3908025eb51 | https://github.com/thecodingmachine/html.utils.weblibrarymanager/blob/e1e5e06d7221a4e77196798ca8bdc3908025eb51/src/InlineWebLibrary.php#L180-L183 |
3,576 | phpthinktank/blast-config | src/Loader/JsonLoader.php | JsonLoader.load | public function load(FilesystemResource $resource)
{
if(!$this->validateExtension($resource)){
return false;
}
return $this->transform($resource);
} | php | public function load(FilesystemResource $resource)
{
if(!$this->validateExtension($resource)){
return false;
}
return $this->transform($resource);
} | [
"public",
"function",
"load",
"(",
"FilesystemResource",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateExtension",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"transform",
"(",
"$",
"resource",
")",
";",
"}"
] | Load config as Array from resource
@param FilesystemResource $resource
@return array | [
"Load",
"config",
"as",
"Array",
"from",
"resource"
] | ffa9645425091c7f0da115f1181c195dce2a5393 | https://github.com/phpthinktank/blast-config/blob/ffa9645425091c7f0da115f1181c195dce2a5393/src/Loader/JsonLoader.php#L33-L41 |
3,577 | railsphp/framework | src/Rails/ActionController/Rendering.php | Rendering.setAssigns | protected function setAssigns(array &$options)
{
$assigns = $this->controller->assigns();
if (isset($options['assigns']) && is_array($options['assigns'])) {
foreach ($options['assigns'] as $name => $value) {
$assigns->set($name, $value);
}
}
$options['assigns'] = $assigns;
} | php | protected function setAssigns(array &$options)
{
$assigns = $this->controller->assigns();
if (isset($options['assigns']) && is_array($options['assigns'])) {
foreach ($options['assigns'] as $name => $value) {
$assigns->set($name, $value);
}
}
$options['assigns'] = $assigns;
} | [
"protected",
"function",
"setAssigns",
"(",
"array",
"&",
"$",
"options",
")",
"{",
"$",
"assigns",
"=",
"$",
"this",
"->",
"controller",
"->",
"assigns",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'assigns'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"options",
"[",
"'assigns'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"[",
"'assigns'",
"]",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"assigns",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"$",
"options",
"[",
"'assigns'",
"]",
"=",
"$",
"assigns",
";",
"}"
] | Set assigns for template
Checks if the 'assigns' value was passed as option, and
sets all the assigns set there to the Assigns object.
If the value for 'assigns' isn't an array, it is ignored.
Then the 'assigns' value is set to the Assigns object, which
will be used when rendering the template.
@return void | [
"Set",
"assigns",
"for",
"template",
"Checks",
"if",
"the",
"assigns",
"value",
"was",
"passed",
"as",
"option",
"and",
"sets",
"all",
"the",
"assigns",
"set",
"there",
"to",
"the",
"Assigns",
"object",
".",
"If",
"the",
"value",
"for",
"assigns",
"isn",
"t",
"an",
"array",
"it",
"is",
"ignored",
".",
"Then",
"the",
"assigns",
"value",
"is",
"set",
"to",
"the",
"Assigns",
"object",
"which",
"will",
"be",
"used",
"when",
"rendering",
"the",
"template",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionController/Rendering.php#L169-L178 |
3,578 | railsphp/framework | src/Rails/ActionController/Rendering.php | Rendering.generateRenderOptions | protected function generateRenderOptions(array &$options)
{
$i18n = $this->controller->getService('i18n');
$defaultLocales = $i18n->fallbacks();
array_unshift($defaultLocales, $i18n->defaultLocale());
$format = $this->controller->request() ?
$this->controller->request()->format() :
null;
if (isset($options['details'])) {
$details = $options['details'];
} else {
$details = [];
}
if (!isset($details['formats'])) {
$details['formats'] = [];
}
if ($format) {
$details['formats'][] = $format;
}
if (!isset($details['handlers'])) {
$details['handlers'] = [];
}
$details['handlers'] = array_merge(
array_keys($this->actionView()->handlers()),
$details['handlers']
);
if (!isset($details['locale'])) {
$details['locale'] = [];
}
$details['locale'] = array_merge($defaultLocales, $details['locale']);
$options['details'] = $details;
$layout = $this->controller->layout();
if ($layout === null) {
$options['layout'] = 'application';
} elseif (is_string($layout)) {
$options['layout'] = $layout;
}
} | php | protected function generateRenderOptions(array &$options)
{
$i18n = $this->controller->getService('i18n');
$defaultLocales = $i18n->fallbacks();
array_unshift($defaultLocales, $i18n->defaultLocale());
$format = $this->controller->request() ?
$this->controller->request()->format() :
null;
if (isset($options['details'])) {
$details = $options['details'];
} else {
$details = [];
}
if (!isset($details['formats'])) {
$details['formats'] = [];
}
if ($format) {
$details['formats'][] = $format;
}
if (!isset($details['handlers'])) {
$details['handlers'] = [];
}
$details['handlers'] = array_merge(
array_keys($this->actionView()->handlers()),
$details['handlers']
);
if (!isset($details['locale'])) {
$details['locale'] = [];
}
$details['locale'] = array_merge($defaultLocales, $details['locale']);
$options['details'] = $details;
$layout = $this->controller->layout();
if ($layout === null) {
$options['layout'] = 'application';
} elseif (is_string($layout)) {
$options['layout'] = $layout;
}
} | [
"protected",
"function",
"generateRenderOptions",
"(",
"array",
"&",
"$",
"options",
")",
"{",
"$",
"i18n",
"=",
"$",
"this",
"->",
"controller",
"->",
"getService",
"(",
"'i18n'",
")",
";",
"$",
"defaultLocales",
"=",
"$",
"i18n",
"->",
"fallbacks",
"(",
")",
";",
"array_unshift",
"(",
"$",
"defaultLocales",
",",
"$",
"i18n",
"->",
"defaultLocale",
"(",
")",
")",
";",
"$",
"format",
"=",
"$",
"this",
"->",
"controller",
"->",
"request",
"(",
")",
"?",
"$",
"this",
"->",
"controller",
"->",
"request",
"(",
")",
"->",
"format",
"(",
")",
":",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'details'",
"]",
")",
")",
"{",
"$",
"details",
"=",
"$",
"options",
"[",
"'details'",
"]",
";",
"}",
"else",
"{",
"$",
"details",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"details",
"[",
"'formats'",
"]",
")",
")",
"{",
"$",
"details",
"[",
"'formats'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"format",
")",
"{",
"$",
"details",
"[",
"'formats'",
"]",
"[",
"]",
"=",
"$",
"format",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"details",
"[",
"'handlers'",
"]",
")",
")",
"{",
"$",
"details",
"[",
"'handlers'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"details",
"[",
"'handlers'",
"]",
"=",
"array_merge",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"actionView",
"(",
")",
"->",
"handlers",
"(",
")",
")",
",",
"$",
"details",
"[",
"'handlers'",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"details",
"[",
"'locale'",
"]",
")",
")",
"{",
"$",
"details",
"[",
"'locale'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"details",
"[",
"'locale'",
"]",
"=",
"array_merge",
"(",
"$",
"defaultLocales",
",",
"$",
"details",
"[",
"'locale'",
"]",
")",
";",
"$",
"options",
"[",
"'details'",
"]",
"=",
"$",
"details",
";",
"$",
"layout",
"=",
"$",
"this",
"->",
"controller",
"->",
"layout",
"(",
")",
";",
"if",
"(",
"$",
"layout",
"===",
"null",
")",
"{",
"$",
"options",
"[",
"'layout'",
"]",
"=",
"'application'",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"layout",
")",
")",
"{",
"$",
"options",
"[",
"'layout'",
"]",
"=",
"$",
"layout",
";",
"}",
"}"
] | Generate render options
Sets the default 'details' for template rendering. | [
"Generate",
"render",
"options",
"Sets",
"the",
"default",
"details",
"for",
"template",
"rendering",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionController/Rendering.php#L184-L228 |
3,579 | synga-nl/inheritance-finder | src/Parser/Visitors/ClassNodeVisitor.php | ClassNodeVisitor.leaveNode | public function leaveNode(Node $node) {
if ($this->phpClass instanceof PhpClass) {
if ($node instanceof Class_) {
if (!empty($node->extends) && count($node->extends->parts) > 0) {
$this->phpClass->setExtends(implode('\\', $node->extends->parts));
}
if (!empty($node->implements) && is_array($node->implements)) {
foreach ($node->implements as $implements) {
$this->phpClass->setImplements(implode('\\', $implements->parts));
}
}
if ($node->type === 0) {
$this->phpClass->setClassType(PhpClass::TYPE_CLASS);
} elseif ($node->type === 16) {
$this->phpClass->setClassType(PhpClass::TYPE_ABSTRACT_CLASS);
} elseif ($node->type === 32) {
$this->phpClass->setClassType(PhpClass::TYPE_FINAL_CLASS);
}
$this->phpClass->setClass($node->name);
} elseif ($node instanceof Interface_) {
if (!empty($node->extends) && is_array($node->extends)) {
foreach ($node->extends as $implements) {
$this->phpClass->setImplements(implode('\\', $implements->parts));
}
}
$this->phpClass->setClassType(PhpClass::TYPE_INTERFACE);
$this->phpClass->setClass($node->name);
} elseif ($node instanceof Trait_) {
$this->phpClass->setClassType(PhpClass::TYPE_TRAIT);
$this->phpClass->setClass($node->name);
} elseif ($node instanceof Namespace_) {
$this->phpClass->setNamespace(implode('\\', $node->name->parts));
} elseif ($node instanceof TraitUse) {
if (!empty($node->traits) && is_array($node->traits)) {
foreach ($node->traits as $trait) {
$this->phpClass->setTraits(implode('\\', $trait->parts));
}
}
}
}
} | php | public function leaveNode(Node $node) {
if ($this->phpClass instanceof PhpClass) {
if ($node instanceof Class_) {
if (!empty($node->extends) && count($node->extends->parts) > 0) {
$this->phpClass->setExtends(implode('\\', $node->extends->parts));
}
if (!empty($node->implements) && is_array($node->implements)) {
foreach ($node->implements as $implements) {
$this->phpClass->setImplements(implode('\\', $implements->parts));
}
}
if ($node->type === 0) {
$this->phpClass->setClassType(PhpClass::TYPE_CLASS);
} elseif ($node->type === 16) {
$this->phpClass->setClassType(PhpClass::TYPE_ABSTRACT_CLASS);
} elseif ($node->type === 32) {
$this->phpClass->setClassType(PhpClass::TYPE_FINAL_CLASS);
}
$this->phpClass->setClass($node->name);
} elseif ($node instanceof Interface_) {
if (!empty($node->extends) && is_array($node->extends)) {
foreach ($node->extends as $implements) {
$this->phpClass->setImplements(implode('\\', $implements->parts));
}
}
$this->phpClass->setClassType(PhpClass::TYPE_INTERFACE);
$this->phpClass->setClass($node->name);
} elseif ($node instanceof Trait_) {
$this->phpClass->setClassType(PhpClass::TYPE_TRAIT);
$this->phpClass->setClass($node->name);
} elseif ($node instanceof Namespace_) {
$this->phpClass->setNamespace(implode('\\', $node->name->parts));
} elseif ($node instanceof TraitUse) {
if (!empty($node->traits) && is_array($node->traits)) {
foreach ($node->traits as $trait) {
$this->phpClass->setTraits(implode('\\', $trait->parts));
}
}
}
}
} | [
"public",
"function",
"leaveNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"phpClass",
"instanceof",
"PhpClass",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Class_",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"->",
"extends",
")",
"&&",
"count",
"(",
"$",
"node",
"->",
"extends",
"->",
"parts",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setExtends",
"(",
"implode",
"(",
"'\\\\'",
",",
"$",
"node",
"->",
"extends",
"->",
"parts",
")",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"->",
"implements",
")",
"&&",
"is_array",
"(",
"$",
"node",
"->",
"implements",
")",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"implements",
"as",
"$",
"implements",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setImplements",
"(",
"implode",
"(",
"'\\\\'",
",",
"$",
"implements",
"->",
"parts",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"node",
"->",
"type",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setClassType",
"(",
"PhpClass",
"::",
"TYPE_CLASS",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"->",
"type",
"===",
"16",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setClassType",
"(",
"PhpClass",
"::",
"TYPE_ABSTRACT_CLASS",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"->",
"type",
"===",
"32",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setClassType",
"(",
"PhpClass",
"::",
"TYPE_FINAL_CLASS",
")",
";",
"}",
"$",
"this",
"->",
"phpClass",
"->",
"setClass",
"(",
"$",
"node",
"->",
"name",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"instanceof",
"Interface_",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"->",
"extends",
")",
"&&",
"is_array",
"(",
"$",
"node",
"->",
"extends",
")",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"extends",
"as",
"$",
"implements",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setImplements",
"(",
"implode",
"(",
"'\\\\'",
",",
"$",
"implements",
"->",
"parts",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"phpClass",
"->",
"setClassType",
"(",
"PhpClass",
"::",
"TYPE_INTERFACE",
")",
";",
"$",
"this",
"->",
"phpClass",
"->",
"setClass",
"(",
"$",
"node",
"->",
"name",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"instanceof",
"Trait_",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setClassType",
"(",
"PhpClass",
"::",
"TYPE_TRAIT",
")",
";",
"$",
"this",
"->",
"phpClass",
"->",
"setClass",
"(",
"$",
"node",
"->",
"name",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"instanceof",
"Namespace_",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setNamespace",
"(",
"implode",
"(",
"'\\\\'",
",",
"$",
"node",
"->",
"name",
"->",
"parts",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"node",
"instanceof",
"TraitUse",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"->",
"traits",
")",
"&&",
"is_array",
"(",
"$",
"node",
"->",
"traits",
")",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"traits",
"as",
"$",
"trait",
")",
"{",
"$",
"this",
"->",
"phpClass",
"->",
"setTraits",
"(",
"implode",
"(",
"'\\\\'",
",",
"$",
"trait",
"->",
"parts",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] | This code can evaluate the data from the parser. It sorts out which object type we are dealing with and passes
this to the PhpClass
@param Node $node
@return false|null|Node|\PhpParser\Node[]|void | [
"This",
"code",
"can",
"evaluate",
"the",
"data",
"from",
"the",
"parser",
".",
"It",
"sorts",
"out",
"which",
"object",
"type",
"we",
"are",
"dealing",
"with",
"and",
"passes",
"this",
"to",
"the",
"PhpClass"
] | 52669ac662b58dfeb6142b2e1bffbfba6f17d4b0 | https://github.com/synga-nl/inheritance-finder/blob/52669ac662b58dfeb6142b2e1bffbfba6f17d4b0/src/Parser/Visitors/ClassNodeVisitor.php#L45-L89 |
3,580 | Puzzlout/FrameworkMvcLegacy | src/Core/ResourceManagers/ControllerResxBase.php | ControllerResxBase.GetValue | public function GetValue($key) {
$resources = $this->GetList();
$actionLower = strtolower($this->ActionValue);
$keyLower = strtolower($key);
$actionExists = array_key_exists($actionLower, $resources);
$keyExist = $actionExists ?
array_key_exists($keyLower, $resources[$actionLower]) :
false;
if ($keyExist) {
return $resources[$actionLower][$keyLower][F_controller_resource::F_CONTROLLER_RESOURCE_VALUE];
} else {
// $errMsg =
// "The resource value doesn't exist. Module => " .
// $this->ModuleValue .
// " ; Action => " .
// $this->ActionValue .
// "; Key => " . $key;
// throw new Classes\ResourceNotFoundException($errMsg, ResourceErrors::RESOURCE_VALUE_NOT_FOUND, null);
return "???";
}
} | php | public function GetValue($key) {
$resources = $this->GetList();
$actionLower = strtolower($this->ActionValue);
$keyLower = strtolower($key);
$actionExists = array_key_exists($actionLower, $resources);
$keyExist = $actionExists ?
array_key_exists($keyLower, $resources[$actionLower]) :
false;
if ($keyExist) {
return $resources[$actionLower][$keyLower][F_controller_resource::F_CONTROLLER_RESOURCE_VALUE];
} else {
// $errMsg =
// "The resource value doesn't exist. Module => " .
// $this->ModuleValue .
// " ; Action => " .
// $this->ActionValue .
// "; Key => " . $key;
// throw new Classes\ResourceNotFoundException($errMsg, ResourceErrors::RESOURCE_VALUE_NOT_FOUND, null);
return "???";
}
} | [
"public",
"function",
"GetValue",
"(",
"$",
"key",
")",
"{",
"$",
"resources",
"=",
"$",
"this",
"->",
"GetList",
"(",
")",
";",
"$",
"actionLower",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"ActionValue",
")",
";",
"$",
"keyLower",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"$",
"actionExists",
"=",
"array_key_exists",
"(",
"$",
"actionLower",
",",
"$",
"resources",
")",
";",
"$",
"keyExist",
"=",
"$",
"actionExists",
"?",
"array_key_exists",
"(",
"$",
"keyLower",
",",
"$",
"resources",
"[",
"$",
"actionLower",
"]",
")",
":",
"false",
";",
"if",
"(",
"$",
"keyExist",
")",
"{",
"return",
"$",
"resources",
"[",
"$",
"actionLower",
"]",
"[",
"$",
"keyLower",
"]",
"[",
"F_controller_resource",
"::",
"F_CONTROLLER_RESOURCE_VALUE",
"]",
";",
"}",
"else",
"{",
"// $errMsg = ",
"// \"The resource value doesn't exist. Module => \" . ",
"// $this->ModuleValue . ",
"// \" ; Action => \" . ",
"// $this->ActionValue .",
"// \"; Key => \" . $key;",
"// throw new Classes\\ResourceNotFoundException($errMsg, ResourceErrors::RESOURCE_VALUE_NOT_FOUND, null);",
"return",
"\"???\"",
";",
"}",
"}"
] | Get the resource by module, action and key.
@param string $key the resource key to find
@return string the resource value
@todo activate the exception? | [
"Get",
"the",
"resource",
"by",
"module",
"action",
"and",
"key",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/ResourceManagers/ControllerResxBase.php#L43-L63 |
3,581 | Puzzlout/FrameworkMvcLegacy | src/Core/ResourceManagers/ControllerResxBase.php | ControllerResxBase.GetComment | public function GetComment($key) {
$resources = $this->GetList();
$actionExists = array_key_exists($this->ActionValue, $resources);
$keyExist = $actionExists ?
array_key_exists($key, $resources[$this->ActionValue]) :
false;
if ($keyExist) {
return $resources[$this->ActionValue][$key][F_controller_resource::F_CONTROLLER_RESOURCE_COMMENT];
} else {
// $errMsg =
// "The resource comment doesn't exist. Module => " .
// $this->ModuleValue .
// " ; Action => " .
// $this->ActionValue .
// "; Key => " . $key;
// throw new Classes\ResourceNotFoundException($errMsg, ResourceErrors::RESOURCE_COMMENT_NOT_FOUND, null);
return "???";
}
} | php | public function GetComment($key) {
$resources = $this->GetList();
$actionExists = array_key_exists($this->ActionValue, $resources);
$keyExist = $actionExists ?
array_key_exists($key, $resources[$this->ActionValue]) :
false;
if ($keyExist) {
return $resources[$this->ActionValue][$key][F_controller_resource::F_CONTROLLER_RESOURCE_COMMENT];
} else {
// $errMsg =
// "The resource comment doesn't exist. Module => " .
// $this->ModuleValue .
// " ; Action => " .
// $this->ActionValue .
// "; Key => " . $key;
// throw new Classes\ResourceNotFoundException($errMsg, ResourceErrors::RESOURCE_COMMENT_NOT_FOUND, null);
return "???";
}
} | [
"public",
"function",
"GetComment",
"(",
"$",
"key",
")",
"{",
"$",
"resources",
"=",
"$",
"this",
"->",
"GetList",
"(",
")",
";",
"$",
"actionExists",
"=",
"array_key_exists",
"(",
"$",
"this",
"->",
"ActionValue",
",",
"$",
"resources",
")",
";",
"$",
"keyExist",
"=",
"$",
"actionExists",
"?",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"resources",
"[",
"$",
"this",
"->",
"ActionValue",
"]",
")",
":",
"false",
";",
"if",
"(",
"$",
"keyExist",
")",
"{",
"return",
"$",
"resources",
"[",
"$",
"this",
"->",
"ActionValue",
"]",
"[",
"$",
"key",
"]",
"[",
"F_controller_resource",
"::",
"F_CONTROLLER_RESOURCE_COMMENT",
"]",
";",
"}",
"else",
"{",
"// $errMsg = ",
"// \"The resource comment doesn't exist. Module => \" . ",
"// $this->ModuleValue . ",
"// \" ; Action => \" . ",
"// $this->ActionValue .",
"// \"; Key => \" . $key;",
"// throw new Classes\\ResourceNotFoundException($errMsg, ResourceErrors::RESOURCE_COMMENT_NOT_FOUND, null);",
"return",
"\"???\"",
";",
"}",
"}"
] | Get the resource comment by module, action and key.
@param string $key the resource key to find
@return string the resource comment
@todo activate the exception? | [
"Get",
"the",
"resource",
"comment",
"by",
"module",
"action",
"and",
"key",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/ResourceManagers/ControllerResxBase.php#L72-L90 |
3,582 | dotfilesphp/core | Util/Filesystem.php | Filesystem.removeDir | public function removeDir($dir, ?callable $onRemoveCallback = null): void
{
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ('.' != $object && '..' != $object) {
if ('dir' == filetype($dir.DIRECTORY_SEPARATOR.$object)) {
$this->removeDir($dir.DIRECTORY_SEPARATOR.$object, $onRemoveCallback);
} else {
unlink($pathName = $dir.DIRECTORY_SEPARATOR.$object);
if (null !== $onRemoveCallback) {
call_user_func($onRemoveCallback, $pathName);
}
}
}
}
reset($objects);
rmdir($dir);
if (null !== $onRemoveCallback) {
call_user_func($onRemoveCallback, $dir);
}
}
} | php | public function removeDir($dir, ?callable $onRemoveCallback = null): void
{
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ('.' != $object && '..' != $object) {
if ('dir' == filetype($dir.DIRECTORY_SEPARATOR.$object)) {
$this->removeDir($dir.DIRECTORY_SEPARATOR.$object, $onRemoveCallback);
} else {
unlink($pathName = $dir.DIRECTORY_SEPARATOR.$object);
if (null !== $onRemoveCallback) {
call_user_func($onRemoveCallback, $pathName);
}
}
}
}
reset($objects);
rmdir($dir);
if (null !== $onRemoveCallback) {
call_user_func($onRemoveCallback, $dir);
}
}
} | [
"public",
"function",
"removeDir",
"(",
"$",
"dir",
",",
"?",
"callable",
"$",
"onRemoveCallback",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"objects",
"=",
"scandir",
"(",
"$",
"dir",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"'.'",
"!=",
"$",
"object",
"&&",
"'..'",
"!=",
"$",
"object",
")",
"{",
"if",
"(",
"'dir'",
"==",
"filetype",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"object",
")",
")",
"{",
"$",
"this",
"->",
"removeDir",
"(",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"object",
",",
"$",
"onRemoveCallback",
")",
";",
"}",
"else",
"{",
"unlink",
"(",
"$",
"pathName",
"=",
"$",
"dir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"object",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"onRemoveCallback",
")",
"{",
"call_user_func",
"(",
"$",
"onRemoveCallback",
",",
"$",
"pathName",
")",
";",
"}",
"}",
"}",
"}",
"reset",
"(",
"$",
"objects",
")",
";",
"rmdir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"onRemoveCallback",
")",
"{",
"call_user_func",
"(",
"$",
"onRemoveCallback",
",",
"$",
"dir",
")",
";",
"}",
"}",
"}"
] | Remove directory recursively.
@param $dir
@param callable|null $onRemoveCallback | [
"Remove",
"directory",
"recursively",
"."
] | d55e44449cf67e9d56a22863447fd782c88d9b2d | https://github.com/dotfilesphp/core/blob/d55e44449cf67e9d56a22863447fd782c88d9b2d/Util/Filesystem.php#L48-L70 |
3,583 | glendmaatita/Tolkien | src/Tolkien/Factories/GenerateFactory.php | GenerateFactory.generate | public function generate()
{
switch ($this->properties['node']) {
case 'post':
return new GeneratePost($this->prepareConfig($this->config), $this->properties);
break;
case 'page':
return new GeneratePage($this->prepareConfig($this->config), $this->properties);
break;
default:
return;
break;
}
} | php | public function generate()
{
switch ($this->properties['node']) {
case 'post':
return new GeneratePost($this->prepareConfig($this->config), $this->properties);
break;
case 'page':
return new GeneratePage($this->prepareConfig($this->config), $this->properties);
break;
default:
return;
break;
}
} | [
"public",
"function",
"generate",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"properties",
"[",
"'node'",
"]",
")",
"{",
"case",
"'post'",
":",
"return",
"new",
"GeneratePost",
"(",
"$",
"this",
"->",
"prepareConfig",
"(",
"$",
"this",
"->",
"config",
")",
",",
"$",
"this",
"->",
"properties",
")",
";",
"break",
";",
"case",
"'page'",
":",
"return",
"new",
"GeneratePage",
"(",
"$",
"this",
"->",
"prepareConfig",
"(",
"$",
"this",
"->",
"config",
")",
",",
"$",
"this",
"->",
"properties",
")",
";",
"break",
";",
"default",
":",
"return",
";",
"break",
";",
"}",
"}"
] | Create class instance of GenerateNode | [
"Create",
"class",
"instance",
"of",
"GenerateNode"
] | e7c27a103f1a87411dfb8eef626cba381b27d233 | https://github.com/glendmaatita/Tolkien/blob/e7c27a103f1a87411dfb8eef626cba381b27d233/src/Tolkien/Factories/GenerateFactory.php#L39-L54 |
3,584 | maestrano/maestrano-php | lib/Util/Cache.php | Maestrano_Util_Cache.get_cached_file | public function get_cached_file($label)
{
$filename = $this->cache_path . $this->safe_filename($label) . $this->cache_extension;
if(file_exists($filename))
return file_get_contents($filename);
return false;
} | php | public function get_cached_file($label)
{
$filename = $this->cache_path . $this->safe_filename($label) . $this->cache_extension;
if(file_exists($filename))
return file_get_contents($filename);
return false;
} | [
"public",
"function",
"get_cached_file",
"(",
"$",
"label",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"cache_path",
".",
"$",
"this",
"->",
"safe_filename",
"(",
"$",
"label",
")",
".",
"$",
"this",
"->",
"cache_extension",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"return",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"return",
"false",
";",
"}"
] | Non-existing method in SimpleCache
Fetch the cache without regarding its expiry
@param $label
@return bool|string | [
"Non",
"-",
"existing",
"method",
"in",
"SimpleCache",
"Fetch",
"the",
"cache",
"without",
"regarding",
"its",
"expiry"
] | 757cbefb0f0bf07cb35ea7442041d9bfdcce1558 | https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Util/Cache.php#L11-L19 |
3,585 | mattjs/mlib | src/Mlib/Model/User.php | User.details | public function details() {
return array_intersect_key(count($this->_details)?$this->_details:array(), array_flip($this->_public_details));
} | php | public function details() {
return array_intersect_key(count($this->_details)?$this->_details:array(), array_flip($this->_public_details));
} | [
"public",
"function",
"details",
"(",
")",
"{",
"return",
"array_intersect_key",
"(",
"count",
"(",
"$",
"this",
"->",
"_details",
")",
"?",
"$",
"this",
"->",
"_details",
":",
"array",
"(",
")",
",",
"array_flip",
"(",
"$",
"this",
"->",
"_public_details",
")",
")",
";",
"}"
] | Return public user details | [
"Return",
"public",
"user",
"details"
] | da5437b23f5bd094b9ed4232b3bffa665ffbcb50 | https://github.com/mattjs/mlib/blob/da5437b23f5bd094b9ed4232b3bffa665ffbcb50/src/Mlib/Model/User.php#L171-L173 |
3,586 | gliverphp/helpers | src/Url/Url.php | Url.base | public static function base()
{
//get the server name from global $_SERVER[] array()
$base = $_SERVER['SERVER_NAME'];
$url = Registry::getUrl();
//check if there is a uri string
if ( ! empty($url) )
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
}
//there is no query string,
else
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0);
}
//use https if its defined in the $_SERVER global variable
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";
//compose the url string
return $protocol . '://' . $base;
} | php | public static function base()
{
//get the server name from global $_SERVER[] array()
$base = $_SERVER['SERVER_NAME'];
$url = Registry::getUrl();
//check if there is a uri string
if ( ! empty($url) )
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
}
//there is no query string,
else
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0);
}
//use https if its defined in the $_SERVER global variable
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";
//compose the url string
return $protocol . '://' . $base;
} | [
"public",
"static",
"function",
"base",
"(",
")",
"{",
"//get the server name from global $_SERVER[] array()",
"$",
"base",
"=",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
";",
"$",
"url",
"=",
"Registry",
"::",
"getUrl",
"(",
")",
";",
"//check if there is a uri string",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"//prepend installation folder to server name",
"$",
"base",
".=",
"substr",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"0",
",",
"strpos",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"Registry",
"::",
"getUrl",
"(",
")",
")",
")",
";",
"}",
"//there is no query string, ",
"else",
"{",
"//prepend installation folder to server name",
"$",
"base",
".=",
"substr",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"0",
")",
";",
"}",
"//use https if its defined in the $_SERVER global variable",
"$",
"protocol",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!=",
"\"off\"",
")",
"?",
"\"https\"",
":",
"\"http\"",
";",
"//compose the url string",
"return",
"$",
"protocol",
".",
"'://'",
".",
"$",
"base",
";",
"}"
] | This method returns the base url
@param null
@return string $url the base url for this application
@throws this method does not throw an error | [
"This",
"method",
"returns",
"the",
"base",
"url"
] | c5204df8169fad55f5b273422e45f56164373ab8 | https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/Url/Url.php#L45-L74 |
3,587 | gliverphp/helpers | src/Url/Url.php | Url.assets | public static function assets($assetName = null)
{
//get the server name from global $_SERVER[] array()
$base = $_SERVER['SERVER_NAME'];
$url = Registry::getUrl();
//check if there is a uri string
if ( ! empty($url) )
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
}
//there is no query string,
else
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0);
}
//use https if its defined in the $_SERVER global variable
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";
//compose the url string
return $protocol . '://' . $base . 'public/' . $assetName;
} | php | public static function assets($assetName = null)
{
//get the server name from global $_SERVER[] array()
$base = $_SERVER['SERVER_NAME'];
$url = Registry::getUrl();
//check if there is a uri string
if ( ! empty($url) )
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
}
//there is no query string,
else
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0);
}
//use https if its defined in the $_SERVER global variable
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";
//compose the url string
return $protocol . '://' . $base . 'public/' . $assetName;
} | [
"public",
"static",
"function",
"assets",
"(",
"$",
"assetName",
"=",
"null",
")",
"{",
"//get the server name from global $_SERVER[] array()",
"$",
"base",
"=",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
";",
"$",
"url",
"=",
"Registry",
"::",
"getUrl",
"(",
")",
";",
"//check if there is a uri string",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"//prepend installation folder to server name",
"$",
"base",
".=",
"substr",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"0",
",",
"strpos",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"Registry",
"::",
"getUrl",
"(",
")",
")",
")",
";",
"}",
"//there is no query string, ",
"else",
"{",
"//prepend installation folder to server name",
"$",
"base",
".=",
"substr",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"0",
")",
";",
"}",
"//use https if its defined in the $_SERVER global variable",
"$",
"protocol",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!=",
"\"off\"",
")",
"?",
"\"https\"",
":",
"\"http\"",
";",
"//compose the url string",
"return",
"$",
"protocol",
".",
"'://'",
".",
"$",
"base",
".",
"'public/'",
".",
"$",
"assetName",
";",
"}"
] | This method returns the assets url
@param null
@return string $url the assets url for this application
@throws this method does not throw an error | [
"This",
"method",
"returns",
"the",
"assets",
"url"
] | c5204df8169fad55f5b273422e45f56164373ab8 | https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/Url/Url.php#L84-L113 |
3,588 | gliverphp/helpers | src/Url/Url.php | Url.link | public static function link($linkParams = null)
{
if($linkParams === null){
$link_params = null;
}
elseif(is_array($linkParams)){
$link_params = join(Registry::getConfig()['url_component_separator'], $linkParams);
}
else{
$params = func_get_args();
$link_params = join(Registry::getConfig()['url_component_separator'], $params);
}
//get the server name from global $_SERVER[] array()
$base = $_SERVER['SERVER_NAME'];
$url = Registry::getUrl();
//check if there is a uri string
if ( ! empty($url) )
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
}
//there is no query string,
else
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0);
}
//use https if its defined in the $_SERVER global variable
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";
//compose the url string
return $protocol . '://' . $base . $link_params;
} | php | public static function link($linkParams = null)
{
if($linkParams === null){
$link_params = null;
}
elseif(is_array($linkParams)){
$link_params = join(Registry::getConfig()['url_component_separator'], $linkParams);
}
else{
$params = func_get_args();
$link_params = join(Registry::getConfig()['url_component_separator'], $params);
}
//get the server name from global $_SERVER[] array()
$base = $_SERVER['SERVER_NAME'];
$url = Registry::getUrl();
//check if there is a uri string
if ( ! empty($url) )
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));
}
//there is no query string,
else
{
//prepend installation folder to server name
$base .= substr($_SERVER['REQUEST_URI'], 0);
}
//use https if its defined in the $_SERVER global variable
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";
//compose the url string
return $protocol . '://' . $base . $link_params;
} | [
"public",
"static",
"function",
"link",
"(",
"$",
"linkParams",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"linkParams",
"===",
"null",
")",
"{",
"$",
"link_params",
"=",
"null",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"linkParams",
")",
")",
"{",
"$",
"link_params",
"=",
"join",
"(",
"Registry",
"::",
"getConfig",
"(",
")",
"[",
"'url_component_separator'",
"]",
",",
"$",
"linkParams",
")",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"$",
"link_params",
"=",
"join",
"(",
"Registry",
"::",
"getConfig",
"(",
")",
"[",
"'url_component_separator'",
"]",
",",
"$",
"params",
")",
";",
"}",
"//get the server name from global $_SERVER[] array()",
"$",
"base",
"=",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
";",
"$",
"url",
"=",
"Registry",
"::",
"getUrl",
"(",
")",
";",
"//check if there is a uri string",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"//prepend installation folder to server name",
"$",
"base",
".=",
"substr",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"0",
",",
"strpos",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"Registry",
"::",
"getUrl",
"(",
")",
")",
")",
";",
"}",
"//there is no query string, ",
"else",
"{",
"//prepend installation folder to server name",
"$",
"base",
".=",
"substr",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
",",
"0",
")",
";",
"}",
"//use https if its defined in the $_SERVER global variable",
"$",
"protocol",
"=",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!=",
"\"off\"",
")",
"?",
"\"https\"",
":",
"\"http\"",
";",
"//compose the url string",
"return",
"$",
"protocol",
".",
"'://'",
".",
"$",
"base",
".",
"$",
"link_params",
";",
"}"
] | This method returns the url string.
@param mixed $linkParams The params to add to the link to generate
@return string $url the base url for this application
@throws this method does not throw an error | [
"This",
"method",
"returns",
"the",
"url",
"string",
"."
] | c5204df8169fad55f5b273422e45f56164373ab8 | https://github.com/gliverphp/helpers/blob/c5204df8169fad55f5b273422e45f56164373ab8/src/Url/Url.php#L121-L166 |
3,589 | donbidon/core | src/Event/Manager.php | Manager.addHandler | public function addHandler($name, $handler, $priority = self::PRIORITY_DEFAULT)
{
$priority = (int)$priority;
if ($priority >= self::PRIORITY_MIN || $priority < self::PRIORITY_MAX) {
throw new InvalidArgumentException("Invalid event priority");
}
$isObject = false;
if (is_array($handler)) {
$isObject = is_object($handler[0]);
$key = sprintf(
"%s%s%s",
$isObject ? get_class($handler[0]) : $handler[0],
$isObject ? "->" : "::",
$handler[1]
);
} else {
$key = $handler;
}
$addHandler = true;
if (empty($this->handlers[$name])) {
$this->handlers[$name] = [];
} else if (isset($this->handlers[$name][$key])) {
if ($isObject) {
// Detect different instances and try to add handler.
$this->key = $key . " ";
$handlers = array_filter(
$this->handlers[$name],
[$this, 'filterHandlers'],
ARRAY_FILTER_USE_KEY
);
$handlers[$key] = $this->handlers[$name][$key];
foreach ($handlers as $existing) {
if ($handler[0] === $existing[1][0]) {
$addHandler = false;
break;
}
if ($addHandler) {
$key = sprintf("%s #%d", $key, sizeof($handlers) + 1);
}
}
} else {
$addHandler = false;
}
}
if ($addHandler) {
$this->handlers[$name][$key] = [$priority, $handler];
unset($this->orderedHandlers[$name]);
}
if ($this->debug && !in_array($name, self::$debugEvents)) {
$debugArgs = new Args([
'name' => $name,
'handler' => $handler,
'added' => $addHandler,
'source' => 'core:event:debug',
'level' => $addHandler ? E_NOTICE : E_WARNING,
]);
$this->fire(':onAddHandler:', $debugArgs);
}
} | php | public function addHandler($name, $handler, $priority = self::PRIORITY_DEFAULT)
{
$priority = (int)$priority;
if ($priority >= self::PRIORITY_MIN || $priority < self::PRIORITY_MAX) {
throw new InvalidArgumentException("Invalid event priority");
}
$isObject = false;
if (is_array($handler)) {
$isObject = is_object($handler[0]);
$key = sprintf(
"%s%s%s",
$isObject ? get_class($handler[0]) : $handler[0],
$isObject ? "->" : "::",
$handler[1]
);
} else {
$key = $handler;
}
$addHandler = true;
if (empty($this->handlers[$name])) {
$this->handlers[$name] = [];
} else if (isset($this->handlers[$name][$key])) {
if ($isObject) {
// Detect different instances and try to add handler.
$this->key = $key . " ";
$handlers = array_filter(
$this->handlers[$name],
[$this, 'filterHandlers'],
ARRAY_FILTER_USE_KEY
);
$handlers[$key] = $this->handlers[$name][$key];
foreach ($handlers as $existing) {
if ($handler[0] === $existing[1][0]) {
$addHandler = false;
break;
}
if ($addHandler) {
$key = sprintf("%s #%d", $key, sizeof($handlers) + 1);
}
}
} else {
$addHandler = false;
}
}
if ($addHandler) {
$this->handlers[$name][$key] = [$priority, $handler];
unset($this->orderedHandlers[$name]);
}
if ($this->debug && !in_array($name, self::$debugEvents)) {
$debugArgs = new Args([
'name' => $name,
'handler' => $handler,
'added' => $addHandler,
'source' => 'core:event:debug',
'level' => $addHandler ? E_NOTICE : E_WARNING,
]);
$this->fire(':onAddHandler:', $debugArgs);
}
} | [
"public",
"function",
"addHandler",
"(",
"$",
"name",
",",
"$",
"handler",
",",
"$",
"priority",
"=",
"self",
"::",
"PRIORITY_DEFAULT",
")",
"{",
"$",
"priority",
"=",
"(",
"int",
")",
"$",
"priority",
";",
"if",
"(",
"$",
"priority",
">=",
"self",
"::",
"PRIORITY_MIN",
"||",
"$",
"priority",
"<",
"self",
"::",
"PRIORITY_MAX",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Invalid event priority\"",
")",
";",
"}",
"$",
"isObject",
"=",
"false",
";",
"if",
"(",
"is_array",
"(",
"$",
"handler",
")",
")",
"{",
"$",
"isObject",
"=",
"is_object",
"(",
"$",
"handler",
"[",
"0",
"]",
")",
";",
"$",
"key",
"=",
"sprintf",
"(",
"\"%s%s%s\"",
",",
"$",
"isObject",
"?",
"get_class",
"(",
"$",
"handler",
"[",
"0",
"]",
")",
":",
"$",
"handler",
"[",
"0",
"]",
",",
"$",
"isObject",
"?",
"\"->\"",
":",
"\"::\"",
",",
"$",
"handler",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"handler",
";",
"}",
"$",
"addHandler",
"=",
"true",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"$",
"isObject",
")",
"{",
"// Detect different instances and try to add handler.\r",
"$",
"this",
"->",
"key",
"=",
"$",
"key",
".",
"\" \"",
";",
"$",
"handlers",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
",",
"[",
"$",
"this",
",",
"'filterHandlers'",
"]",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"$",
"handlers",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"[",
"$",
"key",
"]",
";",
"foreach",
"(",
"$",
"handlers",
"as",
"$",
"existing",
")",
"{",
"if",
"(",
"$",
"handler",
"[",
"0",
"]",
"===",
"$",
"existing",
"[",
"1",
"]",
"[",
"0",
"]",
")",
"{",
"$",
"addHandler",
"=",
"false",
";",
"break",
";",
"}",
"if",
"(",
"$",
"addHandler",
")",
"{",
"$",
"key",
"=",
"sprintf",
"(",
"\"%s #%d\"",
",",
"$",
"key",
",",
"sizeof",
"(",
"$",
"handlers",
")",
"+",
"1",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"addHandler",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"addHandler",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"[",
"$",
"key",
"]",
"=",
"[",
"$",
"priority",
",",
"$",
"handler",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"orderedHandlers",
"[",
"$",
"name",
"]",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"debug",
"&&",
"!",
"in_array",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"debugEvents",
")",
")",
"{",
"$",
"debugArgs",
"=",
"new",
"Args",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'handler'",
"=>",
"$",
"handler",
",",
"'added'",
"=>",
"$",
"addHandler",
",",
"'source'",
"=>",
"'core:event:debug'",
",",
"'level'",
"=>",
"$",
"addHandler",
"?",
"E_NOTICE",
":",
"E_WARNING",
",",
"]",
")",
";",
"$",
"this",
"->",
"fire",
"(",
"':onAddHandler:'",
",",
"$",
"debugArgs",
")",
";",
"}",
"}"
] | Adds event handler.
To break event handling handler must call $args->set(':break:', true).<br /><br />
@param string $name Event name
@param callback $handler Event handler callback
@param int $priority Event priority:
Manager::PRIORITY_LOW, Manager::PRIORITY_DEFAULT or
Manager::PRIORITY_HIGH, lower number means higher priority
@return void
@throws InvalidArgumentException In case of invalid priority. | [
"Adds",
"event",
"handler",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L228-L286 |
3,590 | donbidon/core | src/Event/Manager.php | Manager.dropHandlers | public function dropHandlers($name = '', $handler = null)
{
if (in_array($name, self::$debugEvents)) {
throw new InvalidArgumentException("Cannot drop debug event");
}
if ($this->debug) {
$debugArgs = new Args([
'name' => $name,
'handler' => $handler,
'source' => 'core:event:debug',
'level' => E_NOTICE,
]);
$this->fire(':onDropHandlers:', $debugArgs);
}
$this->runByHandler($name, $handler, [$this, 'deleteHandler']);
} | php | public function dropHandlers($name = '', $handler = null)
{
if (in_array($name, self::$debugEvents)) {
throw new InvalidArgumentException("Cannot drop debug event");
}
if ($this->debug) {
$debugArgs = new Args([
'name' => $name,
'handler' => $handler,
'source' => 'core:event:debug',
'level' => E_NOTICE,
]);
$this->fire(':onDropHandlers:', $debugArgs);
}
$this->runByHandler($name, $handler, [$this, 'deleteHandler']);
} | [
"public",
"function",
"dropHandlers",
"(",
"$",
"name",
"=",
"''",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"debugEvents",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Cannot drop debug event\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"$",
"debugArgs",
"=",
"new",
"Args",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'handler'",
"=>",
"$",
"handler",
",",
"'source'",
"=>",
"'core:event:debug'",
",",
"'level'",
"=>",
"E_NOTICE",
",",
"]",
")",
";",
"$",
"this",
"->",
"fire",
"(",
"':onDropHandlers:'",
",",
"$",
"debugArgs",
")",
";",
"}",
"$",
"this",
"->",
"runByHandler",
"(",
"$",
"name",
",",
"$",
"handler",
",",
"[",
"$",
"this",
",",
"'deleteHandler'",
"]",
")",
";",
"}"
] | Drops event handlers.
Example:
```
// drop all 'someEventName' event handlers
Manager::dropHandler('someEventName');
// drop all 'someEventName' event handlers processing by $object methods only
Manager::dropHandler('someEventName', $object);
```
@param string $name Event name
@param mixed $handler Handler or its part criteria
@return void
@throws InvalidArgumentException In case of dropping debug event. | [
"Drops",
"event",
"handlers",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L305-L320 |
3,591 | donbidon/core | src/Event/Manager.php | Manager.disableHandler | public function disableHandler($name)
{
if (in_array($name, self::$debugEvents)) {
throw new InvalidArgumentException("Cannot disable debug event");
}
if ($this->debug) {
$debugArgs = new Args([
'name' => $name,
'source' => 'core:event:debug',
'level' => E_NOTICE,
]);
$this->fire(':onDisableHandler:', $debugArgs);
}
$this->disabledEvents[$name] = true;
} | php | public function disableHandler($name)
{
if (in_array($name, self::$debugEvents)) {
throw new InvalidArgumentException("Cannot disable debug event");
}
if ($this->debug) {
$debugArgs = new Args([
'name' => $name,
'source' => 'core:event:debug',
'level' => E_NOTICE,
]);
$this->fire(':onDisableHandler:', $debugArgs);
}
$this->disabledEvents[$name] = true;
} | [
"public",
"function",
"disableHandler",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"debugEvents",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Cannot disable debug event\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"$",
"debugArgs",
"=",
"new",
"Args",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'source'",
"=>",
"'core:event:debug'",
",",
"'level'",
"=>",
"E_NOTICE",
",",
"]",
")",
";",
"$",
"this",
"->",
"fire",
"(",
"':onDisableHandler:'",
",",
"$",
"debugArgs",
")",
";",
"}",
"$",
"this",
"->",
"disabledEvents",
"[",
"$",
"name",
"]",
"=",
"true",
";",
"}"
] | Disables handler.
@param string $name Event name
@return void
@throws InvalidArgumentException In case of disabling debug event. | [
"Disables",
"handler",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L329-L343 |
3,592 | donbidon/core | src/Event/Manager.php | Manager.enableHandler | public function enableHandler($name)
{
if ($this->debug) {
$debugArgs = new Args([
'name' => $name,
'source' => 'core:event:debug',
'level' => E_NOTICE,
]);
$this->fire(':onEnableHandler:', $debugArgs);
}
unset($this->disabledEvents[$name]);
} | php | public function enableHandler($name)
{
if ($this->debug) {
$debugArgs = new Args([
'name' => $name,
'source' => 'core:event:debug',
'level' => E_NOTICE,
]);
$this->fire(':onEnableHandler:', $debugArgs);
}
unset($this->disabledEvents[$name]);
} | [
"public",
"function",
"enableHandler",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"$",
"debugArgs",
"=",
"new",
"Args",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'source'",
"=>",
"'core:event:debug'",
",",
"'level'",
"=>",
"E_NOTICE",
",",
"]",
")",
";",
"$",
"this",
"->",
"fire",
"(",
"':onEnableHandler:'",
",",
"$",
"debugArgs",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"disabledEvents",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Enables handler.
@param string $name Event name
@return void | [
"Enables",
"handler",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L351-L362 |
3,593 | donbidon/core | src/Event/Manager.php | Manager.hasHandlers | public function hasHandlers($name, $handler = null)
{
$args = new Args;
$this->runByHandler($name, $handler, [$this, 'hasHandler'], $args);
$result = $args->get('hasHandler');
return $result;
} | php | public function hasHandlers($name, $handler = null)
{
$args = new Args;
$this->runByHandler($name, $handler, [$this, 'hasHandler'], $args);
$result = $args->get('hasHandler');
return $result;
} | [
"public",
"function",
"hasHandlers",
"(",
"$",
"name",
",",
"$",
"handler",
"=",
"null",
")",
"{",
"$",
"args",
"=",
"new",
"Args",
";",
"$",
"this",
"->",
"runByHandler",
"(",
"$",
"name",
",",
"$",
"handler",
",",
"[",
"$",
"this",
",",
"'hasHandler'",
"]",
",",
"$",
"args",
")",
";",
"$",
"result",
"=",
"$",
"args",
"->",
"get",
"(",
"'hasHandler'",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns true if there are any handlers for specified event.
@param string $name Event name
@param mixed $handler Handler or its part criteria
@return bool | [
"Returns",
"true",
"if",
"there",
"are",
"any",
"handlers",
"for",
"specified",
"event",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L371-L378 |
3,594 | donbidon/core | src/Event/Manager.php | Manager.getHandlers | public function getHandlers($name = null)
{
$result = is_null($name) ? $this->handlers : $this->handlers[$name];
return $result;
} | php | public function getHandlers($name = null)
{
$result = is_null($name) ? $this->handlers : $this->handlers[$name];
return $result;
} | [
"public",
"function",
"getHandlers",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"is_null",
"(",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"handlers",
":",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
";",
"return",
"$",
"result",
";",
"}"
] | Returns handlers for passed event or all.
@param string $name Event name
@return array | [
"Returns",
"handlers",
"for",
"passed",
"event",
"or",
"all",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L386-L391 |
3,595 | donbidon/core | src/Event/Manager.php | Manager.deleteHandler | protected function deleteHandler(/** @noinspection PhpUnusedParameterInspection */ I_Registry $args, $name, $index = null)
{
$cleanupAllHandlers = is_null($index);
if (!$cleanupAllHandlers) {
unset($this->handlers[$name][$index]);
if (sizeof($this->handlers[$name])) {
ksort($this->handlers[$name]);
unset($this->orderedHandlers[$name]);
} else {
$cleanupAllHandlers = true;
}
}
if ($cleanupAllHandlers) {
// Cleanup all handlers with specified name
unset($this->handlers[$name], $this->orderedHandlers[$name]);
}
} | php | protected function deleteHandler(/** @noinspection PhpUnusedParameterInspection */ I_Registry $args, $name, $index = null)
{
$cleanupAllHandlers = is_null($index);
if (!$cleanupAllHandlers) {
unset($this->handlers[$name][$index]);
if (sizeof($this->handlers[$name])) {
ksort($this->handlers[$name]);
unset($this->orderedHandlers[$name]);
} else {
$cleanupAllHandlers = true;
}
}
if ($cleanupAllHandlers) {
// Cleanup all handlers with specified name
unset($this->handlers[$name], $this->orderedHandlers[$name]);
}
} | [
"protected",
"function",
"deleteHandler",
"(",
"/** @noinspection PhpUnusedParameterInspection */",
"I_Registry",
"$",
"args",
",",
"$",
"name",
",",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"cleanupAllHandlers",
"=",
"is_null",
"(",
"$",
"index",
")",
";",
"if",
"(",
"!",
"$",
"cleanupAllHandlers",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
"[",
"$",
"index",
"]",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"orderedHandlers",
"[",
"$",
"name",
"]",
")",
";",
"}",
"else",
"{",
"$",
"cleanupAllHandlers",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"cleanupAllHandlers",
")",
"{",
"// Cleanup all handlers with specified name\r",
"unset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
",",
"$",
"this",
"->",
"orderedHandlers",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}"
] | Deletes handler.
@param I_Registry $args Any arguments, can be used to return something
@param string $name Event name
@param int $index Index in self::$handlers[$name] array or null
if $handler parameter not callback or its part
@return void
@see Manager::dropHandler()
@internal | [
"Deletes",
"handler",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L638-L654 |
3,596 | donbidon/core | src/Event/Manager.php | Manager.hasHandler | protected function hasHandler(I_Registry $args, $name, $index = null)
{
$result = is_null($index) ? !empty($this->handlers[$name]) : true;
$args->set('hasHandler', $result);
return $result;
} | php | protected function hasHandler(I_Registry $args, $name, $index = null)
{
$result = is_null($index) ? !empty($this->handlers[$name]) : true;
$args->set('hasHandler', $result);
return $result;
} | [
"protected",
"function",
"hasHandler",
"(",
"I_Registry",
"$",
"args",
",",
"$",
"name",
",",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"is_null",
"(",
"$",
"index",
")",
"?",
"!",
"empty",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
")",
":",
"true",
";",
"$",
"args",
"->",
"set",
"(",
"'hasHandler'",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Sets up 'hasHandler' flag.
@param I_Registry $args Call $args->get('hasHandler') to detect result
@param string $name Event name
@param int $index Index in self::$handlers[$name] array or null
if $handler parameter not callback or its part
@return bool true to continue, false to interrupt execution
@see self::hasHandlers()
@internal | [
"Sets",
"up",
"hasHandler",
"flag",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L667-L673 |
3,597 | donbidon/core | src/Event/Manager.php | Manager.sortEvents | protected function sortEvents($name)
{
$priorities = [];
foreach ($this->orderedHandlers[$name] as $key => $row) {
if (is_array($row)) {
$priorities[$key] = $row[0];
}
}
Arrays::adaptOrderCol($priorities);
foreach ($priorities as $key => $priority) {
$this->orderedHandlers[$name][$key][0] = $priority;
}
Arrays::sortByCol(
$this->orderedHandlers[$name],
0,
SORT_NUMERIC,
SORT_ASC
);
} | php | protected function sortEvents($name)
{
$priorities = [];
foreach ($this->orderedHandlers[$name] as $key => $row) {
if (is_array($row)) {
$priorities[$key] = $row[0];
}
}
Arrays::adaptOrderCol($priorities);
foreach ($priorities as $key => $priority) {
$this->orderedHandlers[$name][$key][0] = $priority;
}
Arrays::sortByCol(
$this->orderedHandlers[$name],
0,
SORT_NUMERIC,
SORT_ASC
);
} | [
"protected",
"function",
"sortEvents",
"(",
"$",
"name",
")",
"{",
"$",
"priorities",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"orderedHandlers",
"[",
"$",
"name",
"]",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"row",
")",
")",
"{",
"$",
"priorities",
"[",
"$",
"key",
"]",
"=",
"$",
"row",
"[",
"0",
"]",
";",
"}",
"}",
"Arrays",
"::",
"adaptOrderCol",
"(",
"$",
"priorities",
")",
";",
"foreach",
"(",
"$",
"priorities",
"as",
"$",
"key",
"=>",
"$",
"priority",
")",
"{",
"$",
"this",
"->",
"orderedHandlers",
"[",
"$",
"name",
"]",
"[",
"$",
"key",
"]",
"[",
"0",
"]",
"=",
"$",
"priority",
";",
"}",
"Arrays",
"::",
"sortByCol",
"(",
"$",
"this",
"->",
"orderedHandlers",
"[",
"$",
"name",
"]",
",",
"0",
",",
"SORT_NUMERIC",
",",
"SORT_ASC",
")",
";",
"}"
] | Modifies priorities and sorts events.
@param string $name Event name
@return void
@see self::fire()
@internal | [
"Modifies",
"priorities",
"and",
"sorts",
"events",
"."
] | a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe | https://github.com/donbidon/core/blob/a22030c98ffb2dcbb8eb7a12f0498d88fb7531fe/src/Event/Manager.php#L696-L717 |
3,598 | fabsgc/framework | Core/Helper/Pagination/Pagination.php | Pagination.show | public function show($template = '.app/system/helper/pagination/default') {
$rand = rand(0, 2);
$tpl = new Template($template, 'pagination_' . $rand, 0);
$tpl->assign(['paginationFirst' => $this->_buttonFirst, 'paginationLast' => $this->_buttonLast, 'paginationBefore' => $this->_buttonBefore, 'paginationAfter' => $this->_buttonAfter, 'currentPage' => $this->_currentPage, 'paginationFirstBefore' => $this->_paginationFirstBefore, 'paginationLastAfter' => $this->_paginationLastAfter, 'urlFirst' => preg_replace('#\{page\}#isU', 1, $this->_url), 'urlLast' => preg_replace('#\{page\}#isU', $this->_nbrPage, $this->_url), 'urlBefore' => preg_replace('#\{page\}#isU', $this->_currentPage - 1, $this->_url), 'urlAfter' => preg_replace('#\{page\}#isU', $this->_currentPage + 1, $this->_url), 'pagination' => $this->_paginationList, 'totalPage' => $this->_paginationTotalPage, 'nbrPage' => $this->_nbrPage]);
return $tpl->show();
} | php | public function show($template = '.app/system/helper/pagination/default') {
$rand = rand(0, 2);
$tpl = new Template($template, 'pagination_' . $rand, 0);
$tpl->assign(['paginationFirst' => $this->_buttonFirst, 'paginationLast' => $this->_buttonLast, 'paginationBefore' => $this->_buttonBefore, 'paginationAfter' => $this->_buttonAfter, 'currentPage' => $this->_currentPage, 'paginationFirstBefore' => $this->_paginationFirstBefore, 'paginationLastAfter' => $this->_paginationLastAfter, 'urlFirst' => preg_replace('#\{page\}#isU', 1, $this->_url), 'urlLast' => preg_replace('#\{page\}#isU', $this->_nbrPage, $this->_url), 'urlBefore' => preg_replace('#\{page\}#isU', $this->_currentPage - 1, $this->_url), 'urlAfter' => preg_replace('#\{page\}#isU', $this->_currentPage + 1, $this->_url), 'pagination' => $this->_paginationList, 'totalPage' => $this->_paginationTotalPage, 'nbrPage' => $this->_nbrPage]);
return $tpl->show();
} | [
"public",
"function",
"show",
"(",
"$",
"template",
"=",
"'.app/system/helper/pagination/default'",
")",
"{",
"$",
"rand",
"=",
"rand",
"(",
"0",
",",
"2",
")",
";",
"$",
"tpl",
"=",
"new",
"Template",
"(",
"$",
"template",
",",
"'pagination_'",
".",
"$",
"rand",
",",
"0",
")",
";",
"$",
"tpl",
"->",
"assign",
"(",
"[",
"'paginationFirst'",
"=>",
"$",
"this",
"->",
"_buttonFirst",
",",
"'paginationLast'",
"=>",
"$",
"this",
"->",
"_buttonLast",
",",
"'paginationBefore'",
"=>",
"$",
"this",
"->",
"_buttonBefore",
",",
"'paginationAfter'",
"=>",
"$",
"this",
"->",
"_buttonAfter",
",",
"'currentPage'",
"=>",
"$",
"this",
"->",
"_currentPage",
",",
"'paginationFirstBefore'",
"=>",
"$",
"this",
"->",
"_paginationFirstBefore",
",",
"'paginationLastAfter'",
"=>",
"$",
"this",
"->",
"_paginationLastAfter",
",",
"'urlFirst'",
"=>",
"preg_replace",
"(",
"'#\\{page\\}#isU'",
",",
"1",
",",
"$",
"this",
"->",
"_url",
")",
",",
"'urlLast'",
"=>",
"preg_replace",
"(",
"'#\\{page\\}#isU'",
",",
"$",
"this",
"->",
"_nbrPage",
",",
"$",
"this",
"->",
"_url",
")",
",",
"'urlBefore'",
"=>",
"preg_replace",
"(",
"'#\\{page\\}#isU'",
",",
"$",
"this",
"->",
"_currentPage",
"-",
"1",
",",
"$",
"this",
"->",
"_url",
")",
",",
"'urlAfter'",
"=>",
"preg_replace",
"(",
"'#\\{page\\}#isU'",
",",
"$",
"this",
"->",
"_currentPage",
"+",
"1",
",",
"$",
"this",
"->",
"_url",
")",
",",
"'pagination'",
"=>",
"$",
"this",
"->",
"_paginationList",
",",
"'totalPage'",
"=>",
"$",
"this",
"->",
"_paginationTotalPage",
",",
"'nbrPage'",
"=>",
"$",
"this",
"->",
"_nbrPage",
"]",
")",
";",
"return",
"$",
"tpl",
"->",
"show",
"(",
")",
";",
"}"
] | display the pagination
@access public
@return string
@param $template string : template path
@since 3.0
@package helper\Pagination | [
"display",
"the",
"pagination"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Helper/Pagination/Pagination.php#L250-L256 |
3,599 | fabsgc/framework | Core/Helper/Pagination/Pagination.php | Pagination.getData | public function getData($data = []) {
for ($i = ((($this->_byPage * $this->_currentPage) - $this->_byPage)); $i <= (($this->_byPage * $this->_currentPage) - 1); $i++) {
if (isset($data[$i])) {
array_push($this->_data, $data[$i]);
}
}
return $this->_data;
} | php | public function getData($data = []) {
for ($i = ((($this->_byPage * $this->_currentPage) - $this->_byPage)); $i <= (($this->_byPage * $this->_currentPage) - 1); $i++) {
if (isset($data[$i])) {
array_push($this->_data, $data[$i]);
}
}
return $this->_data;
} | [
"public",
"function",
"getData",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"(",
"(",
"(",
"$",
"this",
"->",
"_byPage",
"*",
"$",
"this",
"->",
"_currentPage",
")",
"-",
"$",
"this",
"->",
"_byPage",
")",
")",
";",
"$",
"i",
"<=",
"(",
"(",
"$",
"this",
"->",
"_byPage",
"*",
"$",
"this",
"->",
"_currentPage",
")",
"-",
"1",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"_data",
",",
"$",
"data",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_data",
";",
"}"
] | get the data to be displayed from all data
@access public
@return array
@param $data : array of data
@return array
@since 3.0
@package helper\Pagination | [
"get",
"the",
"data",
"to",
"be",
"displayed",
"from",
"all",
"data"
] | 45e58182aba6a3c6381970a1fd3c17662cff2168 | https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Helper/Pagination/Pagination.php#L297-L305 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.