id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
20,400 |
expectation-php/expect
|
src/FailedMessage.php
|
FailedMessage.appendText
|
public function appendText($value)
{
$text = $this->stringify($value);
$this->message = $this->message . $text;
return $this;
}
|
php
|
public function appendText($value)
{
$text = $this->stringify($value);
$this->message = $this->message . $text;
return $this;
}
|
[
"public",
"function",
"appendText",
"(",
"$",
"value",
")",
"{",
"$",
"text",
"=",
"$",
"this",
"->",
"stringify",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
".",
"$",
"text",
";",
"return",
"$",
"this",
";",
"}"
] |
Append the text to the last.
@param mixed $value
@return $this
|
[
"Append",
"the",
"text",
"to",
"the",
"last",
"."
] |
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
|
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/FailedMessage.php#L41-L47
|
20,401 |
expectation-php/expect
|
src/FailedMessage.php
|
FailedMessage.appendSpace
|
public function appendSpace($length)
{
$paddingLength = (int) $length;
$this->message = $this->message . str_pad('', $paddingLength, ' ');
return $this;
}
|
php
|
public function appendSpace($length)
{
$paddingLength = (int) $length;
$this->message = $this->message . str_pad('', $paddingLength, ' ');
return $this;
}
|
[
"public",
"function",
"appendSpace",
"(",
"$",
"length",
")",
"{",
"$",
"paddingLength",
"=",
"(",
"int",
")",
"$",
"length",
";",
"$",
"this",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
".",
"str_pad",
"(",
"''",
",",
"$",
"paddingLength",
",",
"' '",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Append the length space.
@param int $length
@return $this
|
[
"Append",
"the",
"length",
"space",
"."
] |
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
|
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/FailedMessage.php#L56-L62
|
20,402 |
expectation-php/expect
|
src/FailedMessage.php
|
FailedMessage.appendValue
|
public function appendValue($value)
{
$appendValue = $this->formatValue($value);
$this->message = $this->message . $appendValue;
return $this;
}
|
php
|
public function appendValue($value)
{
$appendValue = $this->formatValue($value);
$this->message = $this->message . $appendValue;
return $this;
}
|
[
"public",
"function",
"appendValue",
"(",
"$",
"value",
")",
"{",
"$",
"appendValue",
"=",
"$",
"this",
"->",
"formatValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
".",
"$",
"appendValue",
";",
"return",
"$",
"this",
";",
"}"
] |
Append the value to the last.
@param mixed $value
@return $this
|
[
"Append",
"the",
"value",
"to",
"the",
"last",
"."
] |
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
|
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/FailedMessage.php#L71-L77
|
20,403 |
expectation-php/expect
|
src/FailedMessage.php
|
FailedMessage.appendValues
|
public function appendValues(array $values)
{
$appendValues = [];
foreach ($values as $value) {
$appendValues[] = $this->formatValue($value);
}
$this->message = $this->message . implode(', ', $appendValues);
return $this;
}
|
php
|
public function appendValues(array $values)
{
$appendValues = [];
foreach ($values as $value) {
$appendValues[] = $this->formatValue($value);
}
$this->message = $this->message . implode(', ', $appendValues);
return $this;
}
|
[
"public",
"function",
"appendValues",
"(",
"array",
"$",
"values",
")",
"{",
"$",
"appendValues",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"appendValues",
"[",
"]",
"=",
"$",
"this",
"->",
"formatValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"message",
"=",
"$",
"this",
"->",
"message",
".",
"implode",
"(",
"', '",
",",
"$",
"appendValues",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Append the values to the last.
@param array $values
@return $this
|
[
"Append",
"the",
"values",
"to",
"the",
"last",
"."
] |
1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139
|
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/FailedMessage.php#L86-L97
|
20,404 |
tttptd/laravel-responder
|
src/Http/ResponseBuilder.php
|
ResponseBuilder.respond
|
public function respond(int $statusCode = null, array $headers = []):JsonResponse
{
if (! is_null($statusCode)) {
$this->setStatus($statusCode);
}
$data = $this->toArray();
$data = $this->includeStatusCode($data);
$data = $this->includeSuccessFlag($data);
return $this->responseFactory->json($data, $this->statusCode, $headers);
}
|
php
|
public function respond(int $statusCode = null, array $headers = []):JsonResponse
{
if (! is_null($statusCode)) {
$this->setStatus($statusCode);
}
$data = $this->toArray();
$data = $this->includeStatusCode($data);
$data = $this->includeSuccessFlag($data);
return $this->responseFactory->json($data, $this->statusCode, $headers);
}
|
[
"public",
"function",
"respond",
"(",
"int",
"$",
"statusCode",
"=",
"null",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
":",
"JsonResponse",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"statusCode",
")",
")",
"{",
"$",
"this",
"->",
"setStatus",
"(",
"$",
"statusCode",
")",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"toArray",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"includeStatusCode",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"includeSuccessFlag",
"(",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"responseFactory",
"->",
"json",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"statusCode",
",",
"$",
"headers",
")",
";",
"}"
] |
Serialize the data and wrap it in a JSON response object.
@param int|null $statusCode
@param array $headers
@return \Illuminate\Http\JsonResponse
|
[
"Serialize",
"the",
"data",
"and",
"wrap",
"it",
"in",
"a",
"JSON",
"response",
"object",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Http/ResponseBuilder.php#L67-L78
|
20,405 |
yosymfony/ConfigServiceProvider
|
src/Yosymfony/Silex/ConfigServiceProvider/Config.php
|
Config.load
|
public function load($resource, $type = null)
{
$repository = $this->delegatingLoader->load($resource, $type);
if(!$repository instanceof ConfigRepositoryInterface)
{
throw new \UnexpectedValueException('The loader must return a repository instance');
}
return $repository;
}
|
php
|
public function load($resource, $type = null)
{
$repository = $this->delegatingLoader->load($resource, $type);
if(!$repository instanceof ConfigRepositoryInterface)
{
throw new \UnexpectedValueException('The loader must return a repository instance');
}
return $repository;
}
|
[
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"repository",
"=",
"$",
"this",
"->",
"delegatingLoader",
"->",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
")",
";",
"if",
"(",
"!",
"$",
"repository",
"instanceof",
"ConfigRepositoryInterface",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'The loader must return a repository instance'",
")",
";",
"}",
"return",
"$",
"repository",
";",
"}"
] |
Loads a resource like file or inline configuration
@param string $resource A resource
@param string $type The resource type. Don't set this argument in files case.
@return ConfigRepositoryInterface
@throws Symfony\Component\Config\Exception\FileLoaderLoadException If the loader not found.
@throws \UnexpectedValueException If the loader not return a repository instance
|
[
"Loads",
"a",
"resource",
"like",
"file",
"or",
"inline",
"configuration"
] |
f6cb9a9fc707b6c92e0d03201e5ecc17eaee3114
|
https://github.com/yosymfony/ConfigServiceProvider/blob/f6cb9a9fc707b6c92e0d03201e5ecc17eaee3114/src/Yosymfony/Silex/ConfigServiceProvider/Config.php#L60-L70
|
20,406 |
antaresproject/notifications
|
src/Widgets/NotificationSender/NotificationsWidget.php
|
NotificationsWidget.routes
|
public static function routes()
{
$area = area();
Route::post($area . '/notifications/notifications', NotificationController::class . '@index');
Route::post($area . '/notifications/widgets/send', NotificationController::class . '@send');
}
|
php
|
public static function routes()
{
$area = area();
Route::post($area . '/notifications/notifications', NotificationController::class . '@index');
Route::post($area . '/notifications/widgets/send', NotificationController::class . '@send');
}
|
[
"public",
"static",
"function",
"routes",
"(",
")",
"{",
"$",
"area",
"=",
"area",
"(",
")",
";",
"Route",
"::",
"post",
"(",
"$",
"area",
".",
"'/notifications/notifications'",
",",
"NotificationController",
"::",
"class",
".",
"'@index'",
")",
";",
"Route",
"::",
"post",
"(",
"$",
"area",
".",
"'/notifications/widgets/send'",
",",
"NotificationController",
"::",
"class",
".",
"'@send'",
")",
";",
"}"
] |
Widgets routes implementations
@return void
|
[
"Widgets",
"routes",
"implementations"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/NotificationsWidget.php#L85-L90
|
20,407 |
antaresproject/notifications
|
src/Widgets/NotificationSender/NotificationsWidget.php
|
NotificationsWidget.render
|
public function render()
{
app('antares.asset')->container('antares/foundation::application')->add('webpack_forms_basic', '/webpack/forms_basic.js', ['app_cache']);
publish('notifications', ['js/notification-widget.js']);
return view('antares/notifications::widgets.send_notification', ['form' => $this->form->get()])->render();
}
|
php
|
public function render()
{
app('antares.asset')->container('antares/foundation::application')->add('webpack_forms_basic', '/webpack/forms_basic.js', ['app_cache']);
publish('notifications', ['js/notification-widget.js']);
return view('antares/notifications::widgets.send_notification', ['form' => $this->form->get()])->render();
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"app",
"(",
"'antares.asset'",
")",
"->",
"container",
"(",
"'antares/foundation::application'",
")",
"->",
"add",
"(",
"'webpack_forms_basic'",
",",
"'/webpack/forms_basic.js'",
",",
"[",
"'app_cache'",
"]",
")",
";",
"publish",
"(",
"'notifications'",
",",
"[",
"'js/notification-widget.js'",
"]",
")",
";",
"return",
"view",
"(",
"'antares/notifications::widgets.send_notification'",
",",
"[",
"'form'",
"=>",
"$",
"this",
"->",
"form",
"->",
"get",
"(",
")",
"]",
")",
"->",
"render",
"(",
")",
";",
"}"
] |
Renders widget content
@return \Illuminate\View\View
|
[
"Renders",
"widget",
"content"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/NotificationsWidget.php#L97-L103
|
20,408 |
heidelpay/PhpDoc
|
src/phpDocumentor/Compiler/Pass/ExampleTagsEnricher.php
|
ExampleTagsEnricher.replaceInlineExamples
|
protected function replaceInlineExamples(DescriptorAbstract $element)
{
$description = $element->getDescription();
$matches = array();
if (! $description
|| ! preg_match_all('/\{@example\s(.+?)\}/', $description, $matches)
|| count($matches[0]) < 1
) {
return $description;
}
$matched = array();
foreach ($matches[0] as $index => $match) {
if (isset($matched[$match])) {
continue;
}
$matched[$match] = true;
$exampleReflector = new ExampleTag('example', $matches[1][$index]);
$example = $this->exampleAssembler->create($exampleReflector);
$replacement = '`'.$example->getExample().'`';
if ($example->getDescription()) {
$replacement = '*' . $example->getDescription() . '*' . $replacement;
}
$description = str_replace($match, $replacement, $description);
}
return $description;
}
|
php
|
protected function replaceInlineExamples(DescriptorAbstract $element)
{
$description = $element->getDescription();
$matches = array();
if (! $description
|| ! preg_match_all('/\{@example\s(.+?)\}/', $description, $matches)
|| count($matches[0]) < 1
) {
return $description;
}
$matched = array();
foreach ($matches[0] as $index => $match) {
if (isset($matched[$match])) {
continue;
}
$matched[$match] = true;
$exampleReflector = new ExampleTag('example', $matches[1][$index]);
$example = $this->exampleAssembler->create($exampleReflector);
$replacement = '`'.$example->getExample().'`';
if ($example->getDescription()) {
$replacement = '*' . $example->getDescription() . '*' . $replacement;
}
$description = str_replace($match, $replacement, $description);
}
return $description;
}
|
[
"protected",
"function",
"replaceInlineExamples",
"(",
"DescriptorAbstract",
"$",
"element",
")",
"{",
"$",
"description",
"=",
"$",
"element",
"->",
"getDescription",
"(",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"description",
"||",
"!",
"preg_match_all",
"(",
"'/\\{@example\\s(.+?)\\}/'",
",",
"$",
"description",
",",
"$",
"matches",
")",
"||",
"count",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
"<",
"1",
")",
"{",
"return",
"$",
"description",
";",
"}",
"$",
"matched",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"index",
"=>",
"$",
"match",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"matched",
"[",
"$",
"match",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"matched",
"[",
"$",
"match",
"]",
"=",
"true",
";",
"$",
"exampleReflector",
"=",
"new",
"ExampleTag",
"(",
"'example'",
",",
"$",
"matches",
"[",
"1",
"]",
"[",
"$",
"index",
"]",
")",
";",
"$",
"example",
"=",
"$",
"this",
"->",
"exampleAssembler",
"->",
"create",
"(",
"$",
"exampleReflector",
")",
";",
"$",
"replacement",
"=",
"'`'",
".",
"$",
"example",
"->",
"getExample",
"(",
")",
".",
"'`'",
";",
"if",
"(",
"$",
"example",
"->",
"getDescription",
"(",
")",
")",
"{",
"$",
"replacement",
"=",
"'*'",
".",
"$",
"example",
"->",
"getDescription",
"(",
")",
".",
"'*'",
".",
"$",
"replacement",
";",
"}",
"$",
"description",
"=",
"str_replace",
"(",
"$",
"match",
",",
"$",
"replacement",
",",
"$",
"description",
")",
";",
"}",
"return",
"$",
"description",
";",
"}"
] |
Replaces the example tags in the description with the contents of the found example.
@param DescriptorAbstract $element
@return string
|
[
"Replaces",
"the",
"example",
"tags",
"in",
"the",
"description",
"with",
"the",
"contents",
"of",
"the",
"found",
"example",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ExampleTagsEnricher.php#L69-L101
|
20,409 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_reader.php
|
ezcDbSchemaCommonSqlReader.processSchema
|
protected function processSchema( array $tables )
{
$schemaDefinition = array();
array_walk( $tables, create_function( '&$item,$key', '$item = $item[0];' ) );
// strip out the prefix and only return tables with the prefix set.
$prefix = ezcDbSchema::$options->tableNamePrefix;
foreach ( $tables as $tableName )
{
$tableNameWithoutPrefix = substr( $tableName, strlen( $prefix ) );
// Process table if there was no prefix, or when a prefix was
// found. In the latter case the prefix would be missing from
// $tableNameWithoutPrefix due to the substr() above, and hence,
// $tableName and $tableNameWithoutPrefix would be different.
if ( $prefix === '' || $tableName !== $tableNameWithoutPrefix )
{
$fields = $this->fetchTableFields( $tableName );
$indexes = $this->fetchTableIndexes( $tableName );
$schemaDefinition[$tableNameWithoutPrefix] = ezcDbSchema::createNewTable( $fields, $indexes );
}
}
return $schemaDefinition;
}
|
php
|
protected function processSchema( array $tables )
{
$schemaDefinition = array();
array_walk( $tables, create_function( '&$item,$key', '$item = $item[0];' ) );
// strip out the prefix and only return tables with the prefix set.
$prefix = ezcDbSchema::$options->tableNamePrefix;
foreach ( $tables as $tableName )
{
$tableNameWithoutPrefix = substr( $tableName, strlen( $prefix ) );
// Process table if there was no prefix, or when a prefix was
// found. In the latter case the prefix would be missing from
// $tableNameWithoutPrefix due to the substr() above, and hence,
// $tableName and $tableNameWithoutPrefix would be different.
if ( $prefix === '' || $tableName !== $tableNameWithoutPrefix )
{
$fields = $this->fetchTableFields( $tableName );
$indexes = $this->fetchTableIndexes( $tableName );
$schemaDefinition[$tableNameWithoutPrefix] = ezcDbSchema::createNewTable( $fields, $indexes );
}
}
return $schemaDefinition;
}
|
[
"protected",
"function",
"processSchema",
"(",
"array",
"$",
"tables",
")",
"{",
"$",
"schemaDefinition",
"=",
"array",
"(",
")",
";",
"array_walk",
"(",
"$",
"tables",
",",
"create_function",
"(",
"'&$item,$key'",
",",
"'$item = $item[0];'",
")",
")",
";",
"// strip out the prefix and only return tables with the prefix set.",
"$",
"prefix",
"=",
"ezcDbSchema",
"::",
"$",
"options",
"->",
"tableNamePrefix",
";",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
")",
"{",
"$",
"tableNameWithoutPrefix",
"=",
"substr",
"(",
"$",
"tableName",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
";",
"// Process table if there was no prefix, or when a prefix was",
"// found. In the latter case the prefix would be missing from",
"// $tableNameWithoutPrefix due to the substr() above, and hence,",
"// $tableName and $tableNameWithoutPrefix would be different.",
"if",
"(",
"$",
"prefix",
"===",
"''",
"||",
"$",
"tableName",
"!==",
"$",
"tableNameWithoutPrefix",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"fetchTableFields",
"(",
"$",
"tableName",
")",
";",
"$",
"indexes",
"=",
"$",
"this",
"->",
"fetchTableIndexes",
"(",
"$",
"tableName",
")",
";",
"$",
"schemaDefinition",
"[",
"$",
"tableNameWithoutPrefix",
"]",
"=",
"ezcDbSchema",
"::",
"createNewTable",
"(",
"$",
"fields",
",",
"$",
"indexes",
")",
";",
"}",
"}",
"return",
"$",
"schemaDefinition",
";",
"}"
] |
Loops over all the table names in the array and extracts schema
information.
This method extracts information about a database's schema from the
database itself and returns this schema as an ezcDbSchema object.
@param array(string) $tables
@return ezcDbSchema
|
[
"Loops",
"over",
"all",
"the",
"table",
"names",
"in",
"the",
"array",
"and",
"extracts",
"schema",
"information",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_reader.php#L58-L83
|
20,410 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_reader.php
|
ezcDbSchemaCommonSqlReader.lowercase
|
protected function lowercase( array $source )
{
$result = array();
foreach ($source as $key => $value )
$result[strtolower($key)] = $value;
return $result;
}
|
php
|
protected function lowercase( array $source )
{
$result = array();
foreach ($source as $key => $value )
$result[strtolower($key)] = $value;
return $result;
}
|
[
"protected",
"function",
"lowercase",
"(",
"array",
"$",
"source",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"source",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"result",
"[",
"strtolower",
"(",
"$",
"key",
")",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"result",
";",
"}"
] |
Lowercase all array keys to conform default Database behaviour
@param array(string=>mixed) $source
@return array
|
[
"Lowercase",
"all",
"array",
"keys",
"to",
"conform",
"default",
"Database",
"behaviour"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_reader.php#L91-L99
|
20,411 |
sabre-io/cs
|
lib/PublicVisibility.php
|
PublicVisibility.applyAttribs
|
private function applyAttribs(Tokens $tokens, $index, array $attribs)
{
$toInsert = [];
foreach ($attribs as $attrib) {
if (null !== $attrib && '' !== $attrib->getContent()) {
$toInsert[] = $attrib;
$toInsert[] = new Token([T_WHITESPACE, ' ']);
}
}
if (!empty($toInsert)) {
$tokens->insertAt($index, $toInsert);
}
}
|
php
|
private function applyAttribs(Tokens $tokens, $index, array $attribs)
{
$toInsert = [];
foreach ($attribs as $attrib) {
if (null !== $attrib && '' !== $attrib->getContent()) {
$toInsert[] = $attrib;
$toInsert[] = new Token([T_WHITESPACE, ' ']);
}
}
if (!empty($toInsert)) {
$tokens->insertAt($index, $toInsert);
}
}
|
[
"private",
"function",
"applyAttribs",
"(",
"Tokens",
"$",
"tokens",
",",
"$",
"index",
",",
"array",
"$",
"attribs",
")",
"{",
"$",
"toInsert",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attribs",
"as",
"$",
"attrib",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"attrib",
"&&",
"''",
"!==",
"$",
"attrib",
"->",
"getContent",
"(",
")",
")",
"{",
"$",
"toInsert",
"[",
"]",
"=",
"$",
"attrib",
";",
"$",
"toInsert",
"[",
"]",
"=",
"new",
"Token",
"(",
"[",
"T_WHITESPACE",
",",
"' '",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"toInsert",
")",
")",
"{",
"$",
"tokens",
"->",
"insertAt",
"(",
"$",
"index",
",",
"$",
"toInsert",
")",
";",
"}",
"}"
] |
Apply token attributes.
Token at given index is prepended by attributes.
@param Tokens $tokens Tokens collection
@param int $index token index
@param array $attribs array of token attributes
|
[
"Apply",
"token",
"attributes",
"."
] |
a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86
|
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/PublicVisibility.php#L84-L98
|
20,412 |
sabre-io/cs
|
lib/PublicVisibility.php
|
PublicVisibility.grabAttribsBeforeMethodToken
|
private function grabAttribsBeforeMethodToken(Tokens $tokens, $index)
{
static $tokenAttribsMap = [
T_PRIVATE => 'visibility',
T_PROTECTED => 'visibility',
T_PUBLIC => null, // destroy T_PUBLIC token. This is literally the only change from the original
T_ABSTRACT => 'abstract',
T_FINAL => 'final',
T_STATIC => 'static',
];
return $this->grabAttribsBeforeToken(
$tokens,
$index,
$tokenAttribsMap,
[
'abstract' => null,
'final' => null,
'visibility' => null,
'static' => null,
]
);
}
|
php
|
private function grabAttribsBeforeMethodToken(Tokens $tokens, $index)
{
static $tokenAttribsMap = [
T_PRIVATE => 'visibility',
T_PROTECTED => 'visibility',
T_PUBLIC => null, // destroy T_PUBLIC token. This is literally the only change from the original
T_ABSTRACT => 'abstract',
T_FINAL => 'final',
T_STATIC => 'static',
];
return $this->grabAttribsBeforeToken(
$tokens,
$index,
$tokenAttribsMap,
[
'abstract' => null,
'final' => null,
'visibility' => null,
'static' => null,
]
);
}
|
[
"private",
"function",
"grabAttribsBeforeMethodToken",
"(",
"Tokens",
"$",
"tokens",
",",
"$",
"index",
")",
"{",
"static",
"$",
"tokenAttribsMap",
"=",
"[",
"T_PRIVATE",
"=>",
"'visibility'",
",",
"T_PROTECTED",
"=>",
"'visibility'",
",",
"T_PUBLIC",
"=>",
"null",
",",
"// destroy T_PUBLIC token. This is literally the only change from the original",
"T_ABSTRACT",
"=>",
"'abstract'",
",",
"T_FINAL",
"=>",
"'final'",
",",
"T_STATIC",
"=>",
"'static'",
",",
"]",
";",
"return",
"$",
"this",
"->",
"grabAttribsBeforeToken",
"(",
"$",
"tokens",
",",
"$",
"index",
",",
"$",
"tokenAttribsMap",
",",
"[",
"'abstract'",
"=>",
"null",
",",
"'final'",
"=>",
"null",
",",
"'visibility'",
"=>",
"null",
",",
"'static'",
"=>",
"null",
",",
"]",
")",
";",
"}"
] |
Grab attributes before method token at given index.
It's a shorthand for grabAttribsBeforeToken method.
@param Tokens $tokens Tokens collection
@param int $index token index
@return array array of grabbed attributes
|
[
"Grab",
"attributes",
"before",
"method",
"token",
"at",
"given",
"index",
"."
] |
a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86
|
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/PublicVisibility.php#L110-L132
|
20,413 |
sabre-io/cs
|
lib/PublicVisibility.php
|
PublicVisibility.grabAttribsBeforePropertyToken
|
private function grabAttribsBeforePropertyToken(Tokens $tokens, $index)
{
static $tokenAttribsMap = [
T_VAR => null, // destroy T_VAR token!
T_PRIVATE => 'visibility',
T_PROTECTED => 'visibility',
T_PUBLIC => 'visibility',
T_STATIC => 'static',
];
$result = $this->grabAttribsBeforeToken(
$tokens,
$index,
$tokenAttribsMap,
[
'visibility' => new Token([T_PUBLIC, 'public']),
'static' => null,
]
);
if ($result['visibility'] && 'public' === $result['visibility']->getContent()) {
// If visibility is public and static is set, we remove visibility.
if ($result['static']) {
$result['visibility'] = null;
}
}
return $result;
}
|
php
|
private function grabAttribsBeforePropertyToken(Tokens $tokens, $index)
{
static $tokenAttribsMap = [
T_VAR => null, // destroy T_VAR token!
T_PRIVATE => 'visibility',
T_PROTECTED => 'visibility',
T_PUBLIC => 'visibility',
T_STATIC => 'static',
];
$result = $this->grabAttribsBeforeToken(
$tokens,
$index,
$tokenAttribsMap,
[
'visibility' => new Token([T_PUBLIC, 'public']),
'static' => null,
]
);
if ($result['visibility'] && 'public' === $result['visibility']->getContent()) {
// If visibility is public and static is set, we remove visibility.
if ($result['static']) {
$result['visibility'] = null;
}
}
return $result;
}
|
[
"private",
"function",
"grabAttribsBeforePropertyToken",
"(",
"Tokens",
"$",
"tokens",
",",
"$",
"index",
")",
"{",
"static",
"$",
"tokenAttribsMap",
"=",
"[",
"T_VAR",
"=>",
"null",
",",
"// destroy T_VAR token!",
"T_PRIVATE",
"=>",
"'visibility'",
",",
"T_PROTECTED",
"=>",
"'visibility'",
",",
"T_PUBLIC",
"=>",
"'visibility'",
",",
"T_STATIC",
"=>",
"'static'",
",",
"]",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"grabAttribsBeforeToken",
"(",
"$",
"tokens",
",",
"$",
"index",
",",
"$",
"tokenAttribsMap",
",",
"[",
"'visibility'",
"=>",
"new",
"Token",
"(",
"[",
"T_PUBLIC",
",",
"'public'",
"]",
")",
",",
"'static'",
"=>",
"null",
",",
"]",
")",
";",
"if",
"(",
"$",
"result",
"[",
"'visibility'",
"]",
"&&",
"'public'",
"===",
"$",
"result",
"[",
"'visibility'",
"]",
"->",
"getContent",
"(",
")",
")",
"{",
"// If visibility is public and static is set, we remove visibility.",
"if",
"(",
"$",
"result",
"[",
"'static'",
"]",
")",
"{",
"$",
"result",
"[",
"'visibility'",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Grab attributes before property token at given index.
It's a shorthand for grabAttribsBeforeToken method.
@param Tokens $tokens Tokens collection
@param int $index token index
@return array array of grabbed attributes
|
[
"Grab",
"attributes",
"before",
"property",
"token",
"at",
"given",
"index",
"."
] |
a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86
|
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/PublicVisibility.php#L144-L170
|
20,414 |
sabre-io/cs
|
lib/PublicVisibility.php
|
PublicVisibility.grabAttribsBeforeToken
|
private function grabAttribsBeforeToken(Tokens $tokens, $index, array $tokenAttribsMap, array $attribs)
{
while (true) {
$token = $tokens[--$index];
if (!$token->isArray()) {
if ($token->equalsAny(['{', '}', '(', ')'])) {
break;
}
continue;
}
// if token is attribute
if (array_key_exists($token->getId(), $tokenAttribsMap)) {
// set token attribute if token map defines attribute name for token
if ($tokenAttribsMap[$token->getId()]) {
$attribs[$tokenAttribsMap[$token->getId()]] = clone $token;
}
// clear the token and whitespaces after it
$tokens[$index]->clear();
$tokens[$index + 1]->clear();
continue;
}
if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
continue;
}
break;
}
return $attribs;
}
|
php
|
private function grabAttribsBeforeToken(Tokens $tokens, $index, array $tokenAttribsMap, array $attribs)
{
while (true) {
$token = $tokens[--$index];
if (!$token->isArray()) {
if ($token->equalsAny(['{', '}', '(', ')'])) {
break;
}
continue;
}
// if token is attribute
if (array_key_exists($token->getId(), $tokenAttribsMap)) {
// set token attribute if token map defines attribute name for token
if ($tokenAttribsMap[$token->getId()]) {
$attribs[$tokenAttribsMap[$token->getId()]] = clone $token;
}
// clear the token and whitespaces after it
$tokens[$index]->clear();
$tokens[$index + 1]->clear();
continue;
}
if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
continue;
}
break;
}
return $attribs;
}
|
[
"private",
"function",
"grabAttribsBeforeToken",
"(",
"Tokens",
"$",
"tokens",
",",
"$",
"index",
",",
"array",
"$",
"tokenAttribsMap",
",",
"array",
"$",
"attribs",
")",
"{",
"while",
"(",
"true",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"--",
"$",
"index",
"]",
";",
"if",
"(",
"!",
"$",
"token",
"->",
"isArray",
"(",
")",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"equalsAny",
"(",
"[",
"'{'",
",",
"'}'",
",",
"'('",
",",
"')'",
"]",
")",
")",
"{",
"break",
";",
"}",
"continue",
";",
"}",
"// if token is attribute",
"if",
"(",
"array_key_exists",
"(",
"$",
"token",
"->",
"getId",
"(",
")",
",",
"$",
"tokenAttribsMap",
")",
")",
"{",
"// set token attribute if token map defines attribute name for token",
"if",
"(",
"$",
"tokenAttribsMap",
"[",
"$",
"token",
"->",
"getId",
"(",
")",
"]",
")",
"{",
"$",
"attribs",
"[",
"$",
"tokenAttribsMap",
"[",
"$",
"token",
"->",
"getId",
"(",
")",
"]",
"]",
"=",
"clone",
"$",
"token",
";",
"}",
"// clear the token and whitespaces after it",
"$",
"tokens",
"[",
"$",
"index",
"]",
"->",
"clear",
"(",
")",
";",
"$",
"tokens",
"[",
"$",
"index",
"+",
"1",
"]",
"->",
"clear",
"(",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"token",
"->",
"isGivenKind",
"(",
"[",
"T_WHITESPACE",
",",
"T_COMMENT",
",",
"T_DOC_COMMENT",
"]",
")",
")",
"{",
"continue",
";",
"}",
"break",
";",
"}",
"return",
"$",
"attribs",
";",
"}"
] |
Grab attributes before token at given index.
Grabbed attributes are cleared by overriding them with empty string and should be manually applied with applyTokenAttribs method.
@param Tokens $tokens Tokens collection
@param int $index token index
@param array $tokenAttribsMap token to attribute name map
@param array $attribs array of token attributes
@return array array of grabbed attributes
|
[
"Grab",
"attributes",
"before",
"token",
"at",
"given",
"index",
"."
] |
a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86
|
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/PublicVisibility.php#L184-L219
|
20,415 |
Laralum/Permissions
|
src/Controllers/PermissionController.php
|
PermissionController.confirmDelete
|
public function confirmDelete(Permission $permission)
{
$this->authorize('delete', Permission::class);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'action' => route('laralum::permissions.destroy', ['permission' => $permission->id]),
]);
}
|
php
|
public function confirmDelete(Permission $permission)
{
$this->authorize('delete', Permission::class);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'action' => route('laralum::permissions.destroy', ['permission' => $permission->id]),
]);
}
|
[
"public",
"function",
"confirmDelete",
"(",
"Permission",
"$",
"permission",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"Permission",
"::",
"class",
")",
";",
"return",
"view",
"(",
"'laralum::pages.confirmation'",
",",
"[",
"'method'",
"=>",
"'DELETE'",
",",
"'action'",
"=>",
"route",
"(",
"'laralum::permissions.destroy'",
",",
"[",
"'permission'",
"=>",
"$",
"permission",
"->",
"id",
"]",
")",
",",
"]",
")",
";",
"}"
] |
Displays a view to confirm delete.
@param \Laralum\Permission\Models\Permission $permission
@return \Illuminate\Http\Response
|
[
"Displays",
"a",
"view",
"to",
"confirm",
"delete",
"."
] |
79970ee7d1bff816ad4b9adee29067faead3f756
|
https://github.com/Laralum/Permissions/blob/79970ee7d1bff816ad4b9adee29067faead3f756/src/Controllers/PermissionController.php#L116-L124
|
20,416 |
hirnsturm/typo3-exceptionhandler
|
TYPO3/ExceptionHandler/ProductionExceptionHandler.php
|
ProductionExceptionHandler.sendNotificationMail
|
protected function sendNotificationMail($exception)
{
// Build message
$message = array();
$message[] = 'Title: ' . $this->getTitle($exception);
$message[] = 'Message: ' . PHP_EOL . $this->getMessage($exception);
$message[] = 'Server name: ' . filter_input(INPUT_SERVER, 'SERVER_NAME');
$message[] = 'Request URI: ' . PHP_EOL
. filter_input(INPUT_SERVER, 'SERVER_NAME')
. filter_input(INPUT_SERVER, 'REQUEST_URI');
$message[] = 'Request-Info: ' . PHP_EOL . print_r(filter_input_array(INPUT_SERVER), true);
$message[] = 'POST: ' . PHP_EOL . print_r(filter_input_array(INPUT_POST), true);
$message[] = 'GET: ' . PHP_EOL . print_r(filter_input_array(INPUT_GET), true);
try {
/** @var \TYPO3\CMS\Core\Mail\MailMessage $mail */
$mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setFrom(MailUtility::getSystemFrom())
->setTo(array($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']))
->setSubject(MailUtility::getSystemFromName() . ' - ' . $this->getTitle($exception))
->setBody(implode(PHP_EOL . PHP_EOL, $message))
->send();
} catch (\Exception $e) {
/** @var $logger \TYPO3\CMS\Core\Log\Logger */
$logger = GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
$logger->error('Could not send exception message to system admin!', array($e->__toString()));
}
}
|
php
|
protected function sendNotificationMail($exception)
{
// Build message
$message = array();
$message[] = 'Title: ' . $this->getTitle($exception);
$message[] = 'Message: ' . PHP_EOL . $this->getMessage($exception);
$message[] = 'Server name: ' . filter_input(INPUT_SERVER, 'SERVER_NAME');
$message[] = 'Request URI: ' . PHP_EOL
. filter_input(INPUT_SERVER, 'SERVER_NAME')
. filter_input(INPUT_SERVER, 'REQUEST_URI');
$message[] = 'Request-Info: ' . PHP_EOL . print_r(filter_input_array(INPUT_SERVER), true);
$message[] = 'POST: ' . PHP_EOL . print_r(filter_input_array(INPUT_POST), true);
$message[] = 'GET: ' . PHP_EOL . print_r(filter_input_array(INPUT_GET), true);
try {
/** @var \TYPO3\CMS\Core\Mail\MailMessage $mail */
$mail = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setFrom(MailUtility::getSystemFrom())
->setTo(array($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']))
->setSubject(MailUtility::getSystemFromName() . ' - ' . $this->getTitle($exception))
->setBody(implode(PHP_EOL . PHP_EOL, $message))
->send();
} catch (\Exception $e) {
/** @var $logger \TYPO3\CMS\Core\Log\Logger */
$logger = GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
$logger->error('Could not send exception message to system admin!', array($e->__toString()));
}
}
|
[
"protected",
"function",
"sendNotificationMail",
"(",
"$",
"exception",
")",
"{",
"// Build message",
"$",
"message",
"=",
"array",
"(",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'Title: '",
".",
"$",
"this",
"->",
"getTitle",
"(",
"$",
"exception",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'Message: '",
".",
"PHP_EOL",
".",
"$",
"this",
"->",
"getMessage",
"(",
"$",
"exception",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'Server name: '",
".",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'SERVER_NAME'",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'Request URI: '",
".",
"PHP_EOL",
".",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'SERVER_NAME'",
")",
".",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'REQUEST_URI'",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'Request-Info: '",
".",
"PHP_EOL",
".",
"print_r",
"(",
"filter_input_array",
"(",
"INPUT_SERVER",
")",
",",
"true",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'POST: '",
".",
"PHP_EOL",
".",
"print_r",
"(",
"filter_input_array",
"(",
"INPUT_POST",
")",
",",
"true",
")",
";",
"$",
"message",
"[",
"]",
"=",
"'GET: '",
".",
"PHP_EOL",
".",
"print_r",
"(",
"filter_input_array",
"(",
"INPUT_GET",
")",
",",
"true",
")",
";",
"try",
"{",
"/** @var \\TYPO3\\CMS\\Core\\Mail\\MailMessage $mail */",
"$",
"mail",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"'TYPO3\\\\CMS\\\\Core\\\\Mail\\\\MailMessage'",
")",
";",
"$",
"mail",
"->",
"setFrom",
"(",
"MailUtility",
"::",
"getSystemFrom",
"(",
")",
")",
"->",
"setTo",
"(",
"array",
"(",
"$",
"GLOBALS",
"[",
"'TYPO3_CONF_VARS'",
"]",
"[",
"'BE'",
"]",
"[",
"'warning_email_addr'",
"]",
")",
")",
"->",
"setSubject",
"(",
"MailUtility",
"::",
"getSystemFromName",
"(",
")",
".",
"' - '",
".",
"$",
"this",
"->",
"getTitle",
"(",
"$",
"exception",
")",
")",
"->",
"setBody",
"(",
"implode",
"(",
"PHP_EOL",
".",
"PHP_EOL",
",",
"$",
"message",
")",
")",
"->",
"send",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"/** @var $logger \\TYPO3\\CMS\\Core\\Log\\Logger */",
"$",
"logger",
"=",
"GeneralUtility",
"::",
"makeInstance",
"(",
"'TYPO3\\CMS\\Core\\Log\\LogManager'",
")",
"->",
"getLogger",
"(",
"__CLASS__",
")",
";",
"$",
"logger",
"->",
"error",
"(",
"'Could not send exception message to system admin!'",
",",
"array",
"(",
"$",
"e",
"->",
"__toString",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Sends an exception as notification e-mail
@param $exception
|
[
"Sends",
"an",
"exception",
"as",
"notification",
"e",
"-",
"mail"
] |
268c3f3269d39b238d6fa1b39d8fbae3f0d5921d
|
https://github.com/hirnsturm/typo3-exceptionhandler/blob/268c3f3269d39b238d6fa1b39d8fbae3f0d5921d/TYPO3/ExceptionHandler/ProductionExceptionHandler.php#L33-L60
|
20,417 |
nikolaposa/ZfOpenGraph
|
src/ZfOpenGraph/View/Helper/HeadMeta.php
|
HeadMeta.isValid
|
protected function isValid($item)
{
if ((!$item instanceof stdClass)
|| !isset($item->type)
|| !isset($item->modifiers)
) {
return false;
}
if ($this->doctypeValidationEnabled) {
if (!isset($item->content)
&& (! $this->view->plugin('doctype')->isHtml5()
|| (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset'))
) {
return false;
}
// <meta itemprop= ... /> is only supported with doctype html
if (! $this->view->plugin('doctype')->isHtml5()
&& $item->type === 'itemprop'
) {
return false;
}
// <meta property= ... /> is only supported with doctype RDFa
if (!$this->view->plugin('doctype')->isRdfa()
&& $item->type === 'property'
) {
return false;
}
}
return true;
}
|
php
|
protected function isValid($item)
{
if ((!$item instanceof stdClass)
|| !isset($item->type)
|| !isset($item->modifiers)
) {
return false;
}
if ($this->doctypeValidationEnabled) {
if (!isset($item->content)
&& (! $this->view->plugin('doctype')->isHtml5()
|| (! $this->view->plugin('doctype')->isHtml5() && $item->type !== 'charset'))
) {
return false;
}
// <meta itemprop= ... /> is only supported with doctype html
if (! $this->view->plugin('doctype')->isHtml5()
&& $item->type === 'itemprop'
) {
return false;
}
// <meta property= ... /> is only supported with doctype RDFa
if (!$this->view->plugin('doctype')->isRdfa()
&& $item->type === 'property'
) {
return false;
}
}
return true;
}
|
[
"protected",
"function",
"isValid",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"!",
"$",
"item",
"instanceof",
"stdClass",
")",
"||",
"!",
"isset",
"(",
"$",
"item",
"->",
"type",
")",
"||",
"!",
"isset",
"(",
"$",
"item",
"->",
"modifiers",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"doctypeValidationEnabled",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"item",
"->",
"content",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"view",
"->",
"plugin",
"(",
"'doctype'",
")",
"->",
"isHtml5",
"(",
")",
"||",
"(",
"!",
"$",
"this",
"->",
"view",
"->",
"plugin",
"(",
"'doctype'",
")",
"->",
"isHtml5",
"(",
")",
"&&",
"$",
"item",
"->",
"type",
"!==",
"'charset'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"// <meta itemprop= ... /> is only supported with doctype html",
"if",
"(",
"!",
"$",
"this",
"->",
"view",
"->",
"plugin",
"(",
"'doctype'",
")",
"->",
"isHtml5",
"(",
")",
"&&",
"$",
"item",
"->",
"type",
"===",
"'itemprop'",
")",
"{",
"return",
"false",
";",
"}",
"// <meta property= ... /> is only supported with doctype RDFa",
"if",
"(",
"!",
"$",
"this",
"->",
"view",
"->",
"plugin",
"(",
"'doctype'",
")",
"->",
"isRdfa",
"(",
")",
"&&",
"$",
"item",
"->",
"type",
"===",
"'property'",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Determine if item is valid
@param mixed $item
@return bool
|
[
"Determine",
"if",
"item",
"is",
"valid"
] |
5e1a9b6ff8d2e149dc9d949635f39786f6acc347
|
https://github.com/nikolaposa/ZfOpenGraph/blob/5e1a9b6ff8d2e149dc9d949635f39786f6acc347/src/ZfOpenGraph/View/Helper/HeadMeta.php#L52-L85
|
20,418 |
josh-taylor/migrations-generator
|
src/Describer.php
|
Describer.describe
|
public function describe($table)
{
$schema = $this->db->connection()
->getDoctrineConnection()
->getSchemaManager();
return $this->parseSchema(
$schema->listTableColumns($table)
);
}
|
php
|
public function describe($table)
{
$schema = $this->db->connection()
->getDoctrineConnection()
->getSchemaManager();
return $this->parseSchema(
$schema->listTableColumns($table)
);
}
|
[
"public",
"function",
"describe",
"(",
"$",
"table",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"db",
"->",
"connection",
"(",
")",
"->",
"getDoctrineConnection",
"(",
")",
"->",
"getSchemaManager",
"(",
")",
";",
"return",
"$",
"this",
"->",
"parseSchema",
"(",
"$",
"schema",
"->",
"listTableColumns",
"(",
"$",
"table",
")",
")",
";",
"}"
] |
Describe all columns in a single table
@param string $table
@return array
|
[
"Describe",
"all",
"columns",
"in",
"a",
"single",
"table"
] |
bb6edc78773d11491881f12265a658bf058cb218
|
https://github.com/josh-taylor/migrations-generator/blob/bb6edc78773d11491881f12265a658bf058cb218/src/Describer.php#L32-L41
|
20,419 |
josh-taylor/migrations-generator
|
src/Describer.php
|
Describer.parseSchema
|
protected function parseSchema(array $columns)
{
$schema = [];
foreach ($columns as $name => $column) {
$schema[] = [
'name' => $column->getName(),
'type' => $column->getType()->getName()
];
}
return $schema;
}
|
php
|
protected function parseSchema(array $columns)
{
$schema = [];
foreach ($columns as $name => $column) {
$schema[] = [
'name' => $column->getName(),
'type' => $column->getType()->getName()
];
}
return $schema;
}
|
[
"protected",
"function",
"parseSchema",
"(",
"array",
"$",
"columns",
")",
"{",
"$",
"schema",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"name",
"=>",
"$",
"column",
")",
"{",
"$",
"schema",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"column",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"$",
"column",
"->",
"getType",
"(",
")",
"->",
"getName",
"(",
")",
"]",
";",
"}",
"return",
"$",
"schema",
";",
"}"
] |
Convert the DBAL schema to an assoc array.
@param array $columns
@return array
|
[
"Convert",
"the",
"DBAL",
"schema",
"to",
"an",
"assoc",
"array",
"."
] |
bb6edc78773d11491881f12265a658bf058cb218
|
https://github.com/josh-taylor/migrations-generator/blob/bb6edc78773d11491881f12265a658bf058cb218/src/Describer.php#L49-L61
|
20,420 |
traderinteractive/filter-arrays-php
|
src/Arrays.php
|
Arrays.flatten
|
public static function flatten(array $value) : array
{
$result = [];
array_walk_recursive(
$value,
function ($item) use (&$result) {
$result[] = $item;
}
);
return $result;
}
|
php
|
public static function flatten(array $value) : array
{
$result = [];
array_walk_recursive(
$value,
function ($item) use (&$result) {
$result[] = $item;
}
);
return $result;
}
|
[
"public",
"static",
"function",
"flatten",
"(",
"array",
"$",
"value",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"array_walk_recursive",
"(",
"$",
"value",
",",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"&",
"$",
"result",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"item",
";",
"}",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Given a multi-dimensional array, flatten the array to a single level.
The order of the values will be maintained, but the keys will not.
For example, given the array [[1, 2], [3, [4, 5]]], this would result in the array [1, 2, 3, 4, 5].
@param array $value The array to flatten.
@return array The single-dimension array.
|
[
"Given",
"a",
"multi",
"-",
"dimensional",
"array",
"flatten",
"the",
"array",
"to",
"a",
"single",
"level",
"."
] |
8958109f3e10e6c37fcc6c7c4830d9bcba3ed222
|
https://github.com/traderinteractive/filter-arrays-php/blob/8958109f3e10e6c37fcc6c7c4830d9bcba3ed222/src/Arrays.php#L76-L88
|
20,421 |
fabulator/fitbit-api-base
|
lib/Fabulator/Fitbit/FitbitApiBase.php
|
FitbitApiBase.requestAccessToken
|
public function requestAccessToken($code, $redirectUri, $expiresIn = null, $state = null)
{
$parameters = [
'code' => $code,
'grant_type' => 'authorization_code',
'client_id' => $this->clientId,
'redirect_uri' => $redirectUri,
];
if ($expiresIn != null) {
$parameters['expires_in'] = $expiresIn;
}
if ($state != null) {
$parameters['state'] = $state;
}
return $this->tokenRequest('oauth2/token', $parameters);
}
|
php
|
public function requestAccessToken($code, $redirectUri, $expiresIn = null, $state = null)
{
$parameters = [
'code' => $code,
'grant_type' => 'authorization_code',
'client_id' => $this->clientId,
'redirect_uri' => $redirectUri,
];
if ($expiresIn != null) {
$parameters['expires_in'] = $expiresIn;
}
if ($state != null) {
$parameters['state'] = $state;
}
return $this->tokenRequest('oauth2/token', $parameters);
}
|
[
"public",
"function",
"requestAccessToken",
"(",
"$",
"code",
",",
"$",
"redirectUri",
",",
"$",
"expiresIn",
"=",
"null",
",",
"$",
"state",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'grant_type'",
"=>",
"'authorization_code'",
",",
"'client_id'",
"=>",
"$",
"this",
"->",
"clientId",
",",
"'redirect_uri'",
"=>",
"$",
"redirectUri",
",",
"]",
";",
"if",
"(",
"$",
"expiresIn",
"!=",
"null",
")",
"{",
"$",
"parameters",
"[",
"'expires_in'",
"]",
"=",
"$",
"expiresIn",
";",
"}",
"if",
"(",
"$",
"state",
"!=",
"null",
")",
"{",
"$",
"parameters",
"[",
"'state'",
"]",
"=",
"$",
"state",
";",
"}",
"return",
"$",
"this",
"->",
"tokenRequest",
"(",
"'oauth2/token'",
",",
"$",
"parameters",
")",
";",
"}"
] |
Request new Fitbit access token.
@param string $code code from Fitbit
@param string $redirectUri redirect uri used to get code
@param int|null $expiresIn set length of token
@param string|null $state This parameter will be added to the redirect URI exactly as your application specifies.
@return ResponseInterface response from Fitbit API
|
[
"Request",
"new",
"Fitbit",
"access",
"token",
"."
] |
c2ef868796f991586fe227a659553f304994bdd9
|
https://github.com/fabulator/fitbit-api-base/blob/c2ef868796f991586fe227a659553f304994bdd9/lib/Fabulator/Fitbit/FitbitApiBase.php#L111-L129
|
20,422 |
fabulator/fitbit-api-base
|
lib/Fabulator/Fitbit/FitbitApiBase.php
|
FitbitApiBase.refreshAccessToken
|
public function refreshAccessToken($refreshToken, $expiresIn = null)
{
$parameters = [
'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken,
];
if ($expiresIn != null) {
$parameters['expires_in'] = $expiresIn;
}
return $this->tokenRequest('oauth2/token', $parameters);
}
|
php
|
public function refreshAccessToken($refreshToken, $expiresIn = null)
{
$parameters = [
'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken,
];
if ($expiresIn != null) {
$parameters['expires_in'] = $expiresIn;
}
return $this->tokenRequest('oauth2/token', $parameters);
}
|
[
"public",
"function",
"refreshAccessToken",
"(",
"$",
"refreshToken",
",",
"$",
"expiresIn",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"[",
"'grant_type'",
"=>",
"'refresh_token'",
",",
"'refresh_token'",
"=>",
"$",
"refreshToken",
",",
"]",
";",
"if",
"(",
"$",
"expiresIn",
"!=",
"null",
")",
"{",
"$",
"parameters",
"[",
"'expires_in'",
"]",
"=",
"$",
"expiresIn",
";",
"}",
"return",
"$",
"this",
"->",
"tokenRequest",
"(",
"'oauth2/token'",
",",
"$",
"parameters",
")",
";",
"}"
] |
Refresh Fitbit token.
@param string $refreshToken refresh token
@param int|null $expiresIn set length of token
@return ResponseInterface response from Fitbit API
|
[
"Refresh",
"Fitbit",
"token",
"."
] |
c2ef868796f991586fe227a659553f304994bdd9
|
https://github.com/fabulator/fitbit-api-base/blob/c2ef868796f991586fe227a659553f304994bdd9/lib/Fabulator/Fitbit/FitbitApiBase.php#L138-L150
|
20,423 |
fabulator/fitbit-api-base
|
lib/Fabulator/Fitbit/FitbitApiBase.php
|
FitbitApiBase.tokenRequest
|
private function tokenRequest($namespace, $parameters)
{
$client = new Client([
'headers' => [
'content-type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic '. base64_encode($this->clientId . ':' . $this->secret),
]
]);
return $client->post(self::FITBIT_API_URL . $namespace . '?' . http_build_query($parameters));
}
|
php
|
private function tokenRequest($namespace, $parameters)
{
$client = new Client([
'headers' => [
'content-type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Basic '. base64_encode($this->clientId . ':' . $this->secret),
]
]);
return $client->post(self::FITBIT_API_URL . $namespace . '?' . http_build_query($parameters));
}
|
[
"private",
"function",
"tokenRequest",
"(",
"$",
"namespace",
",",
"$",
"parameters",
")",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'headers'",
"=>",
"[",
"'content-type'",
"=>",
"'application/x-www-form-urlencoded'",
",",
"'Authorization'",
"=>",
"'Basic '",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"clientId",
".",
"':'",
".",
"$",
"this",
"->",
"secret",
")",
",",
"]",
"]",
")",
";",
"return",
"$",
"client",
"->",
"post",
"(",
"self",
"::",
"FITBIT_API_URL",
".",
"$",
"namespace",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"parameters",
")",
")",
";",
"}"
] |
Request token action.
@param string $namespace namespace of request
@param array $parameters request parameters
@return ResponseInterface response from Fitbit API
|
[
"Request",
"token",
"action",
"."
] |
c2ef868796f991586fe227a659553f304994bdd9
|
https://github.com/fabulator/fitbit-api-base/blob/c2ef868796f991586fe227a659553f304994bdd9/lib/Fabulator/Fitbit/FitbitApiBase.php#L174-L184
|
20,424 |
fabulator/fitbit-api-base
|
lib/Fabulator/Fitbit/FitbitApiBase.php
|
FitbitApiBase.send
|
public function send($url, $method = 'GET', $data = [])
{
$method = strtolower($method);
$settings = [
'headers' => array_merge([
'Authorization' => 'Bearer ' . $this->getToken(),
'Content-Type' => 'application/x-www-form-urlencoded',
], $this->getHeaders()),
];
if ($method == 'post') {
$settings['form_params'] = $data;
}
return $this->client
->$method($url, $settings);
}
|
php
|
public function send($url, $method = 'GET', $data = [])
{
$method = strtolower($method);
$settings = [
'headers' => array_merge([
'Authorization' => 'Bearer ' . $this->getToken(),
'Content-Type' => 'application/x-www-form-urlencoded',
], $this->getHeaders()),
];
if ($method == 'post') {
$settings['form_params'] = $data;
}
return $this->client
->$method($url, $settings);
}
|
[
"public",
"function",
"send",
"(",
"$",
"url",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"method",
"=",
"strtolower",
"(",
"$",
"method",
")",
";",
"$",
"settings",
"=",
"[",
"'headers'",
"=>",
"array_merge",
"(",
"[",
"'Authorization'",
"=>",
"'Bearer '",
".",
"$",
"this",
"->",
"getToken",
"(",
")",
",",
"'Content-Type'",
"=>",
"'application/x-www-form-urlencoded'",
",",
"]",
",",
"$",
"this",
"->",
"getHeaders",
"(",
")",
")",
",",
"]",
";",
"if",
"(",
"$",
"method",
"==",
"'post'",
")",
"{",
"$",
"settings",
"[",
"'form_params'",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"$",
"this",
"->",
"client",
"->",
"$",
"method",
"(",
"$",
"url",
",",
"$",
"settings",
")",
";",
"}"
] |
Send authorized request to Fitbit API.
@param string $url called url
@param string $method http method
@param array $data data in body
@return ResponseInterface response from Fitbit API
|
[
"Send",
"authorized",
"request",
"to",
"Fitbit",
"API",
"."
] |
c2ef868796f991586fe227a659553f304994bdd9
|
https://github.com/fabulator/fitbit-api-base/blob/c2ef868796f991586fe227a659553f304994bdd9/lib/Fabulator/Fitbit/FitbitApiBase.php#L239-L256
|
20,425 |
Danzabar/config-builder
|
src/Data/Converter.php
|
Converter.setExtension
|
public function setExtension($ext)
{
$this->extension = $ext;
if(!$this->extensionMap->has($ext))
{
throw new Exceptions\InvalidExtension($ext);
}
return $this;
}
|
php
|
public function setExtension($ext)
{
$this->extension = $ext;
if(!$this->extensionMap->has($ext))
{
throw new Exceptions\InvalidExtension($ext);
}
return $this;
}
|
[
"public",
"function",
"setExtension",
"(",
"$",
"ext",
")",
"{",
"$",
"this",
"->",
"extension",
"=",
"$",
"ext",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"extensionMap",
"->",
"has",
"(",
"$",
"ext",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidExtension",
"(",
"$",
"ext",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the extension
@param String $ext
@return Converter
@author Dan Cox
|
[
"Sets",
"the",
"extension"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/Converter.php#L63-L73
|
20,426 |
Danzabar/config-builder
|
src/Data/Converter.php
|
Converter.process
|
public function process($data = '')
{
$this->data = $data;
$ext = $this->extensionMap->get($this->extension);
$arr = $ext->load($data)->toArray();
$this->paramBag = new ParamBag($arr);
return true;
}
|
php
|
public function process($data = '')
{
$this->data = $data;
$ext = $this->extensionMap->get($this->extension);
$arr = $ext->load($data)->toArray();
$this->paramBag = new ParamBag($arr);
return true;
}
|
[
"public",
"function",
"process",
"(",
"$",
"data",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"ext",
"=",
"$",
"this",
"->",
"extensionMap",
"->",
"get",
"(",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"arr",
"=",
"$",
"ext",
"->",
"load",
"(",
"$",
"data",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"this",
"->",
"paramBag",
"=",
"new",
"ParamBag",
"(",
"$",
"arr",
")",
";",
"return",
"true",
";",
"}"
] |
Loads an extension class to convert the data to an array and pass it back as a param bag
@param String $data
@return ParamBag
@author Dan Cox
|
[
"Loads",
"an",
"extension",
"class",
"to",
"convert",
"the",
"data",
"to",
"an",
"array",
"and",
"pass",
"it",
"back",
"as",
"a",
"param",
"bag"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/Converter.php#L82-L92
|
20,427 |
Danzabar/config-builder
|
src/Data/Converter.php
|
Converter.toNative
|
public function toNative(ParamBag $paramBag)
{
// We can assume the extension exists, since it has already been used
$ext = $this->extensionMap->get($this->extension);
$native = $ext->load($paramBag->all())->toNative();
return $native;
}
|
php
|
public function toNative(ParamBag $paramBag)
{
// We can assume the extension exists, since it has already been used
$ext = $this->extensionMap->get($this->extension);
$native = $ext->load($paramBag->all())->toNative();
return $native;
}
|
[
"public",
"function",
"toNative",
"(",
"ParamBag",
"$",
"paramBag",
")",
"{",
"// We can assume the extension exists, since it has already been used",
"$",
"ext",
"=",
"$",
"this",
"->",
"extensionMap",
"->",
"get",
"(",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"native",
"=",
"$",
"ext",
"->",
"load",
"(",
"$",
"paramBag",
"->",
"all",
"(",
")",
")",
"->",
"toNative",
"(",
")",
";",
"return",
"$",
"native",
";",
"}"
] |
Converts the parambag instance of the native extension format
@param \Danzabar\Config\Data\ParamBag $paramBag
@return Mixed
@author Dan Cox
|
[
"Converts",
"the",
"parambag",
"instance",
"of",
"the",
"native",
"extension",
"format"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Data/Converter.php#L101-L108
|
20,428 |
GrupaZero/api
|
src/Gzero/Api/Transformer/LangTransformer.php
|
LangTransformer.transform
|
public function transform($lang)
{
$lang = $this->entityToArray(Lang::class, $lang);
return [
'code' => $lang['code'],
'i18n' => $lang['i18n'],
'isEnabled' => (bool) $lang['is_enabled'],
'isDefault' => (bool) $lang['is_default'],
];
}
|
php
|
public function transform($lang)
{
$lang = $this->entityToArray(Lang::class, $lang);
return [
'code' => $lang['code'],
'i18n' => $lang['i18n'],
'isEnabled' => (bool) $lang['is_enabled'],
'isDefault' => (bool) $lang['is_default'],
];
}
|
[
"public",
"function",
"transform",
"(",
"$",
"lang",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"Lang",
"::",
"class",
",",
"$",
"lang",
")",
";",
"return",
"[",
"'code'",
"=>",
"$",
"lang",
"[",
"'code'",
"]",
",",
"'i18n'",
"=>",
"$",
"lang",
"[",
"'i18n'",
"]",
",",
"'isEnabled'",
"=>",
"(",
"bool",
")",
"$",
"lang",
"[",
"'is_enabled'",
"]",
",",
"'isDefault'",
"=>",
"(",
"bool",
")",
"$",
"lang",
"[",
"'is_default'",
"]",
",",
"]",
";",
"}"
] |
Transforms lang entity
@param Lang|array $lang Lang entity
@return array
|
[
"Transforms",
"lang",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/LangTransformer.php#L26-L35
|
20,429 |
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Scrybe/Template/Twig.php
|
Twig.decorate
|
public function decorate($contents, array $options = array())
{
return $this->getTwigEnvironment()->render(
$this->getTemplateFilename(),
array_merge(array('contents' => $contents), $options)
);
}
|
php
|
public function decorate($contents, array $options = array())
{
return $this->getTwigEnvironment()->render(
$this->getTemplateFilename(),
array_merge(array('contents' => $contents), $options)
);
}
|
[
"public",
"function",
"decorate",
"(",
"$",
"contents",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getTwigEnvironment",
"(",
")",
"->",
"render",
"(",
"$",
"this",
"->",
"getTemplateFilename",
"(",
")",
",",
"array_merge",
"(",
"array",
"(",
"'contents'",
"=>",
"$",
"contents",
")",
",",
"$",
"options",
")",
")",
";",
"}"
] |
Applies the relevant template upon the given content.
This method takes the combines the template with the given contents and generates a final piece of text
from that.
The user may add additional options that are set as parameters in the template.
@param string $contents
@param string[] $options
@see getTemplateFileName() how the filename is assembled
@return string
|
[
"Applies",
"the",
"relevant",
"template",
"upon",
"the",
"given",
"content",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Template/Twig.php#L154-L160
|
20,430 |
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Scrybe/Template/Twig.php
|
Twig.getAssets
|
public function getAssets()
{
$finder = new Finder();
return iterator_to_array(
$finder->files()
->in($this->path.DIRECTORY_SEPARATOR . $this->name)
->depth('> 0')
->notName('*.twig')
->sortByName()
);
}
|
php
|
public function getAssets()
{
$finder = new Finder();
return iterator_to_array(
$finder->files()
->in($this->path.DIRECTORY_SEPARATOR . $this->name)
->depth('> 0')
->notName('*.twig')
->sortByName()
);
}
|
[
"public",
"function",
"getAssets",
"(",
")",
"{",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"return",
"iterator_to_array",
"(",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"in",
"(",
"$",
"this",
"->",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"name",
")",
"->",
"depth",
"(",
"'> 0'",
")",
"->",
"notName",
"(",
"'*.twig'",
")",
"->",
"sortByName",
"(",
")",
")",
";",
"}"
] |
Returns a list of files that need to be copied to the destination location.
Examples of assets can be:
* CSS files
* Javascript files
* Images
Assets for this template engine means every file that is contained in a subfolder of the template folder and
does not end with the extension twig.
Thus every file in the root of the template folder is ignored and files and directories having only twig
templates (considered as being includes) are not included in this list.
@return string[]
|
[
"Returns",
"a",
"list",
"of",
"files",
"that",
"need",
"to",
"be",
"copied",
"to",
"the",
"destination",
"location",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Template/Twig.php#L179-L190
|
20,431 |
jasny/codeception-module
|
src/Connector.php
|
Connector.setBaseRequest
|
public function setBaseRequest(ServerRequestInterface $request)
{
if ($request instanceof GlobalEnvironmentInterface && $request->isStale()) {
throw new \RuntimeException("Unable to set base request: ServerRequest is stale");
}
$this->baseRequest = $request;
}
|
php
|
public function setBaseRequest(ServerRequestInterface $request)
{
if ($request instanceof GlobalEnvironmentInterface && $request->isStale()) {
throw new \RuntimeException("Unable to set base request: ServerRequest is stale");
}
$this->baseRequest = $request;
}
|
[
"public",
"function",
"setBaseRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"instanceof",
"GlobalEnvironmentInterface",
"&&",
"$",
"request",
"->",
"isStale",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Unable to set base request: ServerRequest is stale\"",
")",
";",
"}",
"$",
"this",
"->",
"baseRequest",
"=",
"$",
"request",
";",
"}"
] |
Set the base request
@param ServerRequestInterface $request
|
[
"Set",
"the",
"base",
"request"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Connector.php#L77-L84
|
20,432 |
jasny/codeception-module
|
src/Connector.php
|
Connector.getBaseRequest
|
public function getBaseRequest()
{
if (!isset($this->baseRequest)) {
$this->baseRequest = new ServerRequest();
}
$request = $this->baseRequest;
if ($request instanceof GlobalEnvironmentInterface && $request->isStale() === false) {
$request = $request->withGlobalEnvironment(true); // Make sure base request is stale
}
return $request;
}
|
php
|
public function getBaseRequest()
{
if (!isset($this->baseRequest)) {
$this->baseRequest = new ServerRequest();
}
$request = $this->baseRequest;
if ($request instanceof GlobalEnvironmentInterface && $request->isStale() === false) {
$request = $request->withGlobalEnvironment(true); // Make sure base request is stale
}
return $request;
}
|
[
"public",
"function",
"getBaseRequest",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"baseRequest",
")",
")",
"{",
"$",
"this",
"->",
"baseRequest",
"=",
"new",
"ServerRequest",
"(",
")",
";",
"}",
"$",
"request",
"=",
"$",
"this",
"->",
"baseRequest",
";",
"if",
"(",
"$",
"request",
"instanceof",
"GlobalEnvironmentInterface",
"&&",
"$",
"request",
"->",
"isStale",
"(",
")",
"===",
"false",
")",
"{",
"$",
"request",
"=",
"$",
"request",
"->",
"withGlobalEnvironment",
"(",
"true",
")",
";",
"// Make sure base request is stale",
"}",
"return",
"$",
"request",
";",
"}"
] |
Get the base request
@return ServerRequestInterface
|
[
"Get",
"the",
"base",
"request"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Connector.php#L91-L104
|
20,433 |
jasny/codeception-module
|
src/Connector.php
|
Connector.setBaseResponse
|
public function setBaseResponse(ResponseInterface $response)
{
if ($response instanceof GlobalEnvironmentInterface && $response->isStale()) {
throw new \RuntimeException("Unable to set base response: Response is stale");
}
$this->baseResponse = $response;
}
|
php
|
public function setBaseResponse(ResponseInterface $response)
{
if ($response instanceof GlobalEnvironmentInterface && $response->isStale()) {
throw new \RuntimeException("Unable to set base response: Response is stale");
}
$this->baseResponse = $response;
}
|
[
"public",
"function",
"setBaseResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"instanceof",
"GlobalEnvironmentInterface",
"&&",
"$",
"response",
"->",
"isStale",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Unable to set base response: Response is stale\"",
")",
";",
"}",
"$",
"this",
"->",
"baseResponse",
"=",
"$",
"response",
";",
"}"
] |
Set the base response
@param ResponseInterface $response
|
[
"Set",
"the",
"base",
"response"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Connector.php#L112-L119
|
20,434 |
jasny/codeception-module
|
src/Connector.php
|
Connector.getBaseResponse
|
public function getBaseResponse()
{
if (!isset($this->baseResponse)) {
$this->baseResponse = new Response();
}
$response = $this->baseResponse;
if ($response instanceof GlobalEnvironmentInterface && $response->isStale() === false) {
$response = $response->withGlobalEnvironment(true); // Make sure base response is stale
}
return $response;
}
|
php
|
public function getBaseResponse()
{
if (!isset($this->baseResponse)) {
$this->baseResponse = new Response();
}
$response = $this->baseResponse;
if ($response instanceof GlobalEnvironmentInterface && $response->isStale() === false) {
$response = $response->withGlobalEnvironment(true); // Make sure base response is stale
}
return $response;
}
|
[
"public",
"function",
"getBaseResponse",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"baseResponse",
")",
")",
"{",
"$",
"this",
"->",
"baseResponse",
"=",
"new",
"Response",
"(",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"baseResponse",
";",
"if",
"(",
"$",
"response",
"instanceof",
"GlobalEnvironmentInterface",
"&&",
"$",
"response",
"->",
"isStale",
"(",
")",
"===",
"false",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"withGlobalEnvironment",
"(",
"true",
")",
";",
"// Make sure base response is stale",
"}",
"return",
"$",
"response",
";",
"}"
] |
Get the base response
@return ResponseInterface
|
[
"Get",
"the",
"base",
"response"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Connector.php#L126-L139
|
20,435 |
jasny/codeception-module
|
src/Connector.php
|
Connector.resetOutput
|
protected function resetOutput()
{
if ($this->baseResponse instanceof GlobalEnvironmentInterface) {
$this->baseResponse = $this->baseResponse->revive();
}
// Clear output buffer
if (isset($this->baseResponse) && $this->baseResponse->getBody() instanceof OutputBufferStream) {
$this->baseResponse = $this->baseResponse->withBody(clone $this->baseResponse->getBody());
}
}
|
php
|
protected function resetOutput()
{
if ($this->baseResponse instanceof GlobalEnvironmentInterface) {
$this->baseResponse = $this->baseResponse->revive();
}
// Clear output buffer
if (isset($this->baseResponse) && $this->baseResponse->getBody() instanceof OutputBufferStream) {
$this->baseResponse = $this->baseResponse->withBody(clone $this->baseResponse->getBody());
}
}
|
[
"protected",
"function",
"resetOutput",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"baseResponse",
"instanceof",
"GlobalEnvironmentInterface",
")",
"{",
"$",
"this",
"->",
"baseResponse",
"=",
"$",
"this",
"->",
"baseResponse",
"->",
"revive",
"(",
")",
";",
"}",
"// Clear output buffer",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"baseResponse",
")",
"&&",
"$",
"this",
"->",
"baseResponse",
"->",
"getBody",
"(",
")",
"instanceof",
"OutputBufferStream",
")",
"{",
"$",
"this",
"->",
"baseResponse",
"=",
"$",
"this",
"->",
"baseResponse",
"->",
"withBody",
"(",
"clone",
"$",
"this",
"->",
"baseResponse",
"->",
"getBody",
"(",
")",
")",
";",
"}",
"}"
] |
Reset the response
|
[
"Reset",
"the",
"response"
] |
5c2b12e4ab291f26424fda9fbf1618c818bc8d6e
|
https://github.com/jasny/codeception-module/blob/5c2b12e4ab291f26424fda9fbf1618c818bc8d6e/src/Connector.php#L155-L165
|
20,436 |
Eresus/EresusCMS
|
src/core/framework/core/WWW/HTTP/HttpMessage.php
|
HttpMessage.setHttpVersion
|
public function setHttpVersion($version)
{
// Version validation pattern
$pattern = '~^1\.[01]$~';
if (! preg_match($pattern, $version))
return false;
$this->httpVersion = $version;
return true;
}
|
php
|
public function setHttpVersion($version)
{
// Version validation pattern
$pattern = '~^1\.[01]$~';
if (! preg_match($pattern, $version))
return false;
$this->httpVersion = $version;
return true;
}
|
[
"public",
"function",
"setHttpVersion",
"(",
"$",
"version",
")",
"{",
"// Version validation pattern",
"$",
"pattern",
"=",
"'~^1\\.[01]$~'",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"version",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"httpVersion",
"=",
"$",
"version",
";",
"return",
"true",
";",
"}"
] |
Set the HTTP Protocol version of the Message
@param string $version
@return bool Returns TRUE on success, or FALSE if supplied version is out of range (1.0/1.1)
|
[
"Set",
"the",
"HTTP",
"Protocol",
"version",
"of",
"the",
"Message"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/WWW/HTTP/HttpMessage.php#L167-L177
|
20,437 |
Eresus/EresusCMS
|
src/core/framework/core/WWW/HTTP/HttpMessage.php
|
HttpMessage.setRequestMethod
|
public function setRequestMethod($method)
{
if ($this->getType() !== self::TYPE_REQUEST)
return false;
$method = strtoupper($method);
$REQUEST_METHODS = array('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE');
if (!in_array($method, $REQUEST_METHODS))
return false;
$this->requestMethod = $method;
return true;
}
|
php
|
public function setRequestMethod($method)
{
if ($this->getType() !== self::TYPE_REQUEST)
return false;
$method = strtoupper($method);
$REQUEST_METHODS = array('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE');
if (!in_array($method, $REQUEST_METHODS))
return false;
$this->requestMethod = $method;
return true;
}
|
[
"public",
"function",
"setRequestMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"!==",
"self",
"::",
"TYPE_REQUEST",
")",
"return",
"false",
";",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"$",
"REQUEST_METHODS",
"=",
"array",
"(",
"'OPTIONS'",
",",
"'GET'",
",",
"'HEAD'",
",",
"'POST'",
",",
"'PUT'",
",",
"'DELETE'",
",",
"'TRACE'",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"method",
",",
"$",
"REQUEST_METHODS",
")",
")",
"return",
"false",
";",
"$",
"this",
"->",
"requestMethod",
"=",
"$",
"method",
";",
"return",
"true",
";",
"}"
] |
Set the Request Method of the HTTP Message
@param string $method The request method name.
{@link http://tools.ietf.org/html/rfc2068#section-5.1.1 See RFC2068 section 5.1.1}
for list of acceptable methods
@return bool TRUE on success, or FALSE if the message is not of type
HttpMessage::TYPE_REQUEST or an invalid request method was supplied
|
[
"Set",
"the",
"Request",
"Method",
"of",
"the",
"HTTP",
"Message"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/WWW/HTTP/HttpMessage.php#L200-L213
|
20,438 |
GrupaZero/api
|
src/Gzero/Api/Transformer/OptionCategoryTransformer.php
|
OptionCategoryTransformer.transform
|
public function transform($option)
{
$options = $this->entityToArray(OptionCategory::class, $option);
$data = ['data' => []];
foreach ($options as $option) {
$data['data'][] = [
'key' => $option,
];
}
return $data;
}
|
php
|
public function transform($option)
{
$options = $this->entityToArray(OptionCategory::class, $option);
$data = ['data' => []];
foreach ($options as $option) {
$data['data'][] = [
'key' => $option,
];
}
return $data;
}
|
[
"public",
"function",
"transform",
"(",
"$",
"option",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"OptionCategory",
"::",
"class",
",",
"$",
"option",
")",
";",
"$",
"data",
"=",
"[",
"'data'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"data",
"[",
"'data'",
"]",
"[",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"option",
",",
"]",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Transforms option category entity
@param array $option OptionCategory entity
@return array
|
[
"Transforms",
"option",
"category",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/OptionCategoryTransformer.php#L26-L37
|
20,439 |
hametuha/wpametu
|
src/WPametu/API/QueryHighJack.php
|
QueryHighJack.query_vars
|
public function query_vars( array $vars ){
if( !empty($this->query_var) ){
foreach( $this->query_var as $var ){
if( false === array_search($var, $vars) ){
$vars[] = $var;
}
}
}
return $vars;
}
|
php
|
public function query_vars( array $vars ){
if( !empty($this->query_var) ){
foreach( $this->query_var as $var ){
if( false === array_search($var, $vars) ){
$vars[] = $var;
}
}
}
return $vars;
}
|
[
"public",
"function",
"query_vars",
"(",
"array",
"$",
"vars",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"query_var",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"query_var",
"as",
"$",
"var",
")",
"{",
"if",
"(",
"false",
"===",
"array_search",
"(",
"$",
"var",
",",
"$",
"vars",
")",
")",
"{",
"$",
"vars",
"[",
"]",
"=",
"$",
"var",
";",
"}",
"}",
"}",
"return",
"$",
"vars",
";",
"}"
] |
Add query var filter
@param array $vars
@return array
|
[
"Add",
"query",
"var",
"filter"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/QueryHighJack.php#L54-L63
|
20,440 |
hametuha/wpametu
|
src/WPametu/API/QueryHighJack.php
|
QueryHighJack.rewrite_rules_array
|
public function rewrite_rules_array( array $rules ){
if( !empty($this->rewrites) ){
$rules = array_merge($this->rewrites, $rules);
}
return $rules;
}
|
php
|
public function rewrite_rules_array( array $rules ){
if( !empty($this->rewrites) ){
$rules = array_merge($this->rewrites, $rules);
}
return $rules;
}
|
[
"public",
"function",
"rewrite_rules_array",
"(",
"array",
"$",
"rules",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"rewrites",
")",
")",
"{",
"$",
"rules",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"rewrites",
",",
"$",
"rules",
")",
";",
"}",
"return",
"$",
"rules",
";",
"}"
] |
Register rewrite rules
@param array $rules
@return array
|
[
"Register",
"rewrite",
"rules"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/QueryHighJack.php#L71-L76
|
20,441 |
hametuha/wpametu
|
src/WPametu/API/QueryHighJack.php
|
QueryHighJack.detect_title
|
final public function detect_title( \WP_Query &$wp_query ){
if( $wp_query->is_main_query() && $this->is_valid_query($wp_query) ){
add_filter('wp_title', [$this, 'wp_title'], 10, 3);
}
}
|
php
|
final public function detect_title( \WP_Query &$wp_query ){
if( $wp_query->is_main_query() && $this->is_valid_query($wp_query) ){
add_filter('wp_title', [$this, 'wp_title'], 10, 3);
}
}
|
[
"final",
"public",
"function",
"detect_title",
"(",
"\\",
"WP_Query",
"&",
"$",
"wp_query",
")",
"{",
"if",
"(",
"$",
"wp_query",
"->",
"is_main_query",
"(",
")",
"&&",
"$",
"this",
"->",
"is_valid_query",
"(",
"$",
"wp_query",
")",
")",
"{",
"add_filter",
"(",
"'wp_title'",
",",
"[",
"$",
"this",
",",
"'wp_title'",
"]",
",",
"10",
",",
"3",
")",
";",
"}",
"}"
] |
Add wp_title filter if required
@param \WP_Query $wp_query
|
[
"Add",
"wp_title",
"filter",
"if",
"required"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/QueryHighJack.php#L83-L87
|
20,442 |
hametuha/wpametu
|
src/WPametu/API/QueryHighJack.php
|
QueryHighJack.add_meta_query
|
protected function add_meta_query( \WP_Query &$wp_query, array $meta_query ){
$old_query = (array) $wp_query->get('meta_query');
array_push($old_query, $meta_query);
$wp_query->set('meta_query', $old_query);
}
|
php
|
protected function add_meta_query( \WP_Query &$wp_query, array $meta_query ){
$old_query = (array) $wp_query->get('meta_query');
array_push($old_query, $meta_query);
$wp_query->set('meta_query', $old_query);
}
|
[
"protected",
"function",
"add_meta_query",
"(",
"\\",
"WP_Query",
"&",
"$",
"wp_query",
",",
"array",
"$",
"meta_query",
")",
"{",
"$",
"old_query",
"=",
"(",
"array",
")",
"$",
"wp_query",
"->",
"get",
"(",
"'meta_query'",
")",
";",
"array_push",
"(",
"$",
"old_query",
",",
"$",
"meta_query",
")",
";",
"$",
"wp_query",
"->",
"set",
"(",
"'meta_query'",
",",
"$",
"old_query",
")",
";",
"}"
] |
Add meta query
@param \WP_Query $wp_query
@param array $meta_query
|
[
"Add",
"meta",
"query"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/QueryHighJack.php#L226-L230
|
20,443 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Data.php
|
Dwoo_Data.clear
|
public function clear($name = null)
{
if ($name === null) {
$this->data = array();
} elseif (is_array($name)) {
foreach ($name as $index)
unset($this->data[$index]);
} else {
unset($this->data[$name]);
}
}
|
php
|
public function clear($name = null)
{
if ($name === null) {
$this->data = array();
} elseif (is_array($name)) {
foreach ($name as $index)
unset($this->data[$index]);
} else {
unset($this->data[$name]);
}
}
|
[
"public",
"function",
"clear",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"array",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"foreach",
"(",
"$",
"name",
"as",
"$",
"index",
")",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"index",
"]",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}"
] |
clears a the entire data or only the given key
@param array|string $name clears only one value if you give a name, multiple values if
you give an array of names, or the entire data if left null
|
[
"clears",
"a",
"the",
"entire",
"data",
"or",
"only",
"the",
"given",
"key"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Data.php#L43-L53
|
20,444 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Data.php
|
Dwoo_Data.assign
|
public function assign($name, $val = null)
{
if (is_array($name)) {
reset($name);
while (list($k,$v) = each($name))
$this->data[$k] = $v;
} else {
$this->data[$name] = $val;
}
}
|
php
|
public function assign($name, $val = null)
{
if (is_array($name)) {
reset($name);
while (list($k,$v) = each($name))
$this->data[$k] = $v;
} else {
$this->data[$name] = $val;
}
}
|
[
"public",
"function",
"assign",
"(",
"$",
"name",
",",
"$",
"val",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"reset",
"(",
"$",
"name",
")",
";",
"while",
"(",
"list",
"(",
"$",
"k",
",",
"$",
"v",
")",
"=",
"each",
"(",
"$",
"name",
")",
")",
"$",
"this",
"->",
"data",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"val",
";",
"}",
"}"
] |
assigns a value or an array of values to the data object
@param array|string $name an associative array of multiple (index=>value) or a string
that is the index to use, i.e. a value assigned to "foo" will be
accessible in the template through {$foo}
@param mixed $val the value to assign, or null if $name was an array
|
[
"assigns",
"a",
"value",
"or",
"an",
"array",
"of",
"values",
"to",
"the",
"data",
"object"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Data.php#L89-L98
|
20,445 |
kusanagi/katana-sdk-php7
|
src/Api/Factory/ServiceApiFactory.php
|
ServiceApiFactory.build
|
public function build(
$action,
array $data,
CliInput $input,
Mapping $mapping
) {
$context = new ZMQContext();
$socket = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$socket->setSockOpt(ZMQ::SOCKOPT_LINGER, 0);
if ($input->getMapping() === 'compact') {
$transportMapper = new CompactTransportMapper();
$runtimeCallMapper = new CompactRuntimeCallMapper($transportMapper);
} else {
$transportMapper = new ExtendedTransportMapper();
$runtimeCallMapper = new ExtendedRuntimeCallMapper($transportMapper);
}
$caller = new ZeroMQRuntimeCaller(
new MessagePackSerializer(),
new CompactTransportMapper(),
$socket,
$runtimeCallMapper,
new Timer()
);
$transport = $this->mapper->getTransport($data);
return new ActionApi(
$this->logger->getRequestLogger($transport->getMeta()->getId()),
$this->component,
$mapping,
dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
$input->getName(),
$input->getVersion(),
$input->getFrameworkVersion(),
$input->getVariables(),
$input->isDebug(),
$action,
$caller,
$transport,
new TypeCatalog(),
$this->mapper->getParams($data)
);
}
|
php
|
public function build(
$action,
array $data,
CliInput $input,
Mapping $mapping
) {
$context = new ZMQContext();
$socket = new ZMQSocket($context, ZMQ::SOCKET_REQ);
$socket->setSockOpt(ZMQ::SOCKOPT_LINGER, 0);
if ($input->getMapping() === 'compact') {
$transportMapper = new CompactTransportMapper();
$runtimeCallMapper = new CompactRuntimeCallMapper($transportMapper);
} else {
$transportMapper = new ExtendedTransportMapper();
$runtimeCallMapper = new ExtendedRuntimeCallMapper($transportMapper);
}
$caller = new ZeroMQRuntimeCaller(
new MessagePackSerializer(),
new CompactTransportMapper(),
$socket,
$runtimeCallMapper,
new Timer()
);
$transport = $this->mapper->getTransport($data);
return new ActionApi(
$this->logger->getRequestLogger($transport->getMeta()->getId()),
$this->component,
$mapping,
dirname(realpath($_SERVER['SCRIPT_FILENAME'])),
$input->getName(),
$input->getVersion(),
$input->getFrameworkVersion(),
$input->getVariables(),
$input->isDebug(),
$action,
$caller,
$transport,
new TypeCatalog(),
$this->mapper->getParams($data)
);
}
|
[
"public",
"function",
"build",
"(",
"$",
"action",
",",
"array",
"$",
"data",
",",
"CliInput",
"$",
"input",
",",
"Mapping",
"$",
"mapping",
")",
"{",
"$",
"context",
"=",
"new",
"ZMQContext",
"(",
")",
";",
"$",
"socket",
"=",
"new",
"ZMQSocket",
"(",
"$",
"context",
",",
"ZMQ",
"::",
"SOCKET_REQ",
")",
";",
"$",
"socket",
"->",
"setSockOpt",
"(",
"ZMQ",
"::",
"SOCKOPT_LINGER",
",",
"0",
")",
";",
"if",
"(",
"$",
"input",
"->",
"getMapping",
"(",
")",
"===",
"'compact'",
")",
"{",
"$",
"transportMapper",
"=",
"new",
"CompactTransportMapper",
"(",
")",
";",
"$",
"runtimeCallMapper",
"=",
"new",
"CompactRuntimeCallMapper",
"(",
"$",
"transportMapper",
")",
";",
"}",
"else",
"{",
"$",
"transportMapper",
"=",
"new",
"ExtendedTransportMapper",
"(",
")",
";",
"$",
"runtimeCallMapper",
"=",
"new",
"ExtendedRuntimeCallMapper",
"(",
"$",
"transportMapper",
")",
";",
"}",
"$",
"caller",
"=",
"new",
"ZeroMQRuntimeCaller",
"(",
"new",
"MessagePackSerializer",
"(",
")",
",",
"new",
"CompactTransportMapper",
"(",
")",
",",
"$",
"socket",
",",
"$",
"runtimeCallMapper",
",",
"new",
"Timer",
"(",
")",
")",
";",
"$",
"transport",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getTransport",
"(",
"$",
"data",
")",
";",
"return",
"new",
"ActionApi",
"(",
"$",
"this",
"->",
"logger",
"->",
"getRequestLogger",
"(",
"$",
"transport",
"->",
"getMeta",
"(",
")",
"->",
"getId",
"(",
")",
")",
",",
"$",
"this",
"->",
"component",
",",
"$",
"mapping",
",",
"dirname",
"(",
"realpath",
"(",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
")",
")",
",",
"$",
"input",
"->",
"getName",
"(",
")",
",",
"$",
"input",
"->",
"getVersion",
"(",
")",
",",
"$",
"input",
"->",
"getFrameworkVersion",
"(",
")",
",",
"$",
"input",
"->",
"getVariables",
"(",
")",
",",
"$",
"input",
"->",
"isDebug",
"(",
")",
",",
"$",
"action",
",",
"$",
"caller",
",",
"$",
"transport",
",",
"new",
"TypeCatalog",
"(",
")",
",",
"$",
"this",
"->",
"mapper",
"->",
"getParams",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
Build an Action Api class instance
@param string $action
@param array $data
@param CliInput $input
@param Mapping $mapping
@return ActionApi
|
[
"Build",
"an",
"Action",
"Api",
"class",
"instance"
] |
91e7860a1852c3ce79a7034f8c36f41840e69e1f
|
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Api/Factory/ServiceApiFactory.php#L47-L90
|
20,446 |
artscorestudio/document-bundle
|
Repository/PostRepository.php
|
PostRepository.getLastVersion
|
public function getLastVersion($post_id)
{
$qb = $this->createQueryBuilder('p');
$qb->where('p.original=:post_id')
->orderBy('p.createdAt', 'DESC')
->setParameter(':post_id', $post_id);
$result = $qb->getQuery()->setMaxResults(1)->getResult(Query::HYDRATE_OBJECT);
if ( is_null($result) ) {
$qb2 = $this->createQueryBuilder('p');
$qb2->where('p.id=:post_id')->setParameter(':post_id', $post_id);
$result = $qb->getQuery()->getResult(Query::HYDRATE_OBJECT);
}
return $result;
}
|
php
|
public function getLastVersion($post_id)
{
$qb = $this->createQueryBuilder('p');
$qb->where('p.original=:post_id')
->orderBy('p.createdAt', 'DESC')
->setParameter(':post_id', $post_id);
$result = $qb->getQuery()->setMaxResults(1)->getResult(Query::HYDRATE_OBJECT);
if ( is_null($result) ) {
$qb2 = $this->createQueryBuilder('p');
$qb2->where('p.id=:post_id')->setParameter(':post_id', $post_id);
$result = $qb->getQuery()->getResult(Query::HYDRATE_OBJECT);
}
return $result;
}
|
[
"public",
"function",
"getLastVersion",
"(",
"$",
"post_id",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'p'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'p.original=:post_id'",
")",
"->",
"orderBy",
"(",
"'p.createdAt'",
",",
"'DESC'",
")",
"->",
"setParameter",
"(",
"':post_id'",
",",
"$",
"post_id",
")",
";",
"$",
"result",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getResult",
"(",
"Query",
"::",
"HYDRATE_OBJECT",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"result",
")",
")",
"{",
"$",
"qb2",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'p'",
")",
";",
"$",
"qb2",
"->",
"where",
"(",
"'p.id=:post_id'",
")",
"->",
"setParameter",
"(",
"':post_id'",
",",
"$",
"post_id",
")",
";",
"$",
"result",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
"Query",
"::",
"HYDRATE_OBJECT",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get last version for a post
@param integer $id AsfDocumentBundle:Page ID
|
[
"Get",
"last",
"version",
"for",
"a",
"post"
] |
3aceab0f75de8f7dd0fad0d0db83d7940bf565c8
|
https://github.com/artscorestudio/document-bundle/blob/3aceab0f75de8f7dd0fad0d0db83d7940bf565c8/Repository/PostRepository.php#L29-L47
|
20,447 |
artscorestudio/document-bundle
|
Repository/PostRepository.php
|
PostRepository.getAllLastVersion
|
public function getAllLastVersion()
{
$qb = $this->createQueryBuilder('p');
$qb->where('p.original IS NULL AND p.state=:state')
->setParameter(':state', DocumentModel::STATE_PUBLISHED);
$result = $qb->getQuery()->getResult();
$return = array();
foreach($result as $original) {
$return[] = $this->getLastVersion($original->getId());
}
return $return;
}
|
php
|
public function getAllLastVersion()
{
$qb = $this->createQueryBuilder('p');
$qb->where('p.original IS NULL AND p.state=:state')
->setParameter(':state', DocumentModel::STATE_PUBLISHED);
$result = $qb->getQuery()->getResult();
$return = array();
foreach($result as $original) {
$return[] = $this->getLastVersion($original->getId());
}
return $return;
}
|
[
"public",
"function",
"getAllLastVersion",
"(",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'p'",
")",
";",
"$",
"qb",
"->",
"where",
"(",
"'p.original IS NULL AND p.state=:state'",
")",
"->",
"setParameter",
"(",
"':state'",
",",
"DocumentModel",
"::",
"STATE_PUBLISHED",
")",
";",
"$",
"result",
"=",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"original",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"this",
"->",
"getLastVersion",
"(",
"$",
"original",
"->",
"getId",
"(",
")",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Get all posts in their last version
|
[
"Get",
"all",
"posts",
"in",
"their",
"last",
"version"
] |
3aceab0f75de8f7dd0fad0d0db83d7940bf565c8
|
https://github.com/artscorestudio/document-bundle/blob/3aceab0f75de8f7dd0fad0d0db83d7940bf565c8/Repository/PostRepository.php#L52-L64
|
20,448 |
WasabiLib/Mail
|
src/Mail.php
|
Mail.attachFiles
|
private function attachFiles(){
if (count($this->attachments) === 0) {
return;
}
// Get old message parts
$mimeMessage = $this->message->getBody();
if (is_string($mimeMessage)) {
$originalBodyPart = new Mime\Part($mimeMessage);
$originalBodyPart->type = $mimeMessage != strip_tags($mimeMessage)
? Mime\Mime::TYPE_HTML
: Mime\Mime::TYPE_TEXT;
// A Mime\Part body will be wraped into a Mime\Message, ensuring we handle a Mime\Message after this point
$this->setBody($originalBodyPart);
$mimeMessage = $this->message->getBody();;
}
$oldParts = $mimeMessage->getParts();
// Generate a new Mime\Part for each attachment
$attachmentParts = [];
$info = new \finfo(FILEINFO_MIME_TYPE);
foreach ($this->attachments as $key => $attachment) {
if (! is_file($attachment)) {
continue; // If checked file is not valid, continue to the next
}
// If the key is a string, use it as the attachment name
$basename = is_string($key) ? $key : basename($attachment);
$part = new Mime\Part(fopen($attachment, 'r'));
$part->id = $basename;
$part->filename = $basename;
$part->type = $info->file($attachment);
$part->encoding = Mime\Mime::ENCODING_BASE64;
$part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
$attachmentParts[] = $part;
}
$body = new Mime\Message();
$body->setParts(array_merge($oldParts, $attachmentParts));
$this->message->setBody($body);
}
|
php
|
private function attachFiles(){
if (count($this->attachments) === 0) {
return;
}
// Get old message parts
$mimeMessage = $this->message->getBody();
if (is_string($mimeMessage)) {
$originalBodyPart = new Mime\Part($mimeMessage);
$originalBodyPart->type = $mimeMessage != strip_tags($mimeMessage)
? Mime\Mime::TYPE_HTML
: Mime\Mime::TYPE_TEXT;
// A Mime\Part body will be wraped into a Mime\Message, ensuring we handle a Mime\Message after this point
$this->setBody($originalBodyPart);
$mimeMessage = $this->message->getBody();;
}
$oldParts = $mimeMessage->getParts();
// Generate a new Mime\Part for each attachment
$attachmentParts = [];
$info = new \finfo(FILEINFO_MIME_TYPE);
foreach ($this->attachments as $key => $attachment) {
if (! is_file($attachment)) {
continue; // If checked file is not valid, continue to the next
}
// If the key is a string, use it as the attachment name
$basename = is_string($key) ? $key : basename($attachment);
$part = new Mime\Part(fopen($attachment, 'r'));
$part->id = $basename;
$part->filename = $basename;
$part->type = $info->file($attachment);
$part->encoding = Mime\Mime::ENCODING_BASE64;
$part->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
$attachmentParts[] = $part;
}
$body = new Mime\Message();
$body->setParts(array_merge($oldParts, $attachmentParts));
$this->message->setBody($body);
}
|
[
"private",
"function",
"attachFiles",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"attachments",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"// Get old message parts",
"$",
"mimeMessage",
"=",
"$",
"this",
"->",
"message",
"->",
"getBody",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"mimeMessage",
")",
")",
"{",
"$",
"originalBodyPart",
"=",
"new",
"Mime",
"\\",
"Part",
"(",
"$",
"mimeMessage",
")",
";",
"$",
"originalBodyPart",
"->",
"type",
"=",
"$",
"mimeMessage",
"!=",
"strip_tags",
"(",
"$",
"mimeMessage",
")",
"?",
"Mime",
"\\",
"Mime",
"::",
"TYPE_HTML",
":",
"Mime",
"\\",
"Mime",
"::",
"TYPE_TEXT",
";",
"// A Mime\\Part body will be wraped into a Mime\\Message, ensuring we handle a Mime\\Message after this point",
"$",
"this",
"->",
"setBody",
"(",
"$",
"originalBodyPart",
")",
";",
"$",
"mimeMessage",
"=",
"$",
"this",
"->",
"message",
"->",
"getBody",
"(",
")",
";",
";",
"}",
"$",
"oldParts",
"=",
"$",
"mimeMessage",
"->",
"getParts",
"(",
")",
";",
"// Generate a new Mime\\Part for each attachment",
"$",
"attachmentParts",
"=",
"[",
"]",
";",
"$",
"info",
"=",
"new",
"\\",
"finfo",
"(",
"FILEINFO_MIME_TYPE",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attachments",
"as",
"$",
"key",
"=>",
"$",
"attachment",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"attachment",
")",
")",
"{",
"continue",
";",
"// If checked file is not valid, continue to the next",
"}",
"// If the key is a string, use it as the attachment name",
"$",
"basename",
"=",
"is_string",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"basename",
"(",
"$",
"attachment",
")",
";",
"$",
"part",
"=",
"new",
"Mime",
"\\",
"Part",
"(",
"fopen",
"(",
"$",
"attachment",
",",
"'r'",
")",
")",
";",
"$",
"part",
"->",
"id",
"=",
"$",
"basename",
";",
"$",
"part",
"->",
"filename",
"=",
"$",
"basename",
";",
"$",
"part",
"->",
"type",
"=",
"$",
"info",
"->",
"file",
"(",
"$",
"attachment",
")",
";",
"$",
"part",
"->",
"encoding",
"=",
"Mime",
"\\",
"Mime",
"::",
"ENCODING_BASE64",
";",
"$",
"part",
"->",
"disposition",
"=",
"Mime",
"\\",
"Mime",
"::",
"DISPOSITION_ATTACHMENT",
";",
"$",
"attachmentParts",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"$",
"body",
"=",
"new",
"Mime",
"\\",
"Message",
"(",
")",
";",
"$",
"body",
"->",
"setParts",
"(",
"array_merge",
"(",
"$",
"oldParts",
",",
"$",
"attachmentParts",
")",
")",
";",
"$",
"this",
"->",
"message",
"->",
"setBody",
"(",
"$",
"body",
")",
";",
"}"
] |
Attaches files to the message if any
|
[
"Attaches",
"files",
"to",
"the",
"message",
"if",
"any"
] |
5e6a1de480d500e380e5ecfbf633d40f87e9c8e9
|
https://github.com/WasabiLib/Mail/blob/5e6a1de480d500e380e5ecfbf633d40f87e9c8e9/src/Mail.php#L234-L270
|
20,449 |
barrelstrength/craftnet-php
|
src/CraftnetClient.php
|
CraftnetClient.post
|
public function post($endpoint, array $options = [])
{
$jsonValues = [];
if (isset($options['json'])) {
$jsonValues = $options['json'];
}
return $this->httpClient->request('POST', 'https://api.craftcms.com/v1/'.$endpoint, [
'auth' => $this->setAuth(),
'json' => $jsonValues
]);
}
|
php
|
public function post($endpoint, array $options = [])
{
$jsonValues = [];
if (isset($options['json'])) {
$jsonValues = $options['json'];
}
return $this->httpClient->request('POST', 'https://api.craftcms.com/v1/'.$endpoint, [
'auth' => $this->setAuth(),
'json' => $jsonValues
]);
}
|
[
"public",
"function",
"post",
"(",
"$",
"endpoint",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"jsonValues",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'json'",
"]",
")",
")",
"{",
"$",
"jsonValues",
"=",
"$",
"options",
"[",
"'json'",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"request",
"(",
"'POST'",
",",
"'https://api.craftcms.com/v1/'",
".",
"$",
"endpoint",
",",
"[",
"'auth'",
"=>",
"$",
"this",
"->",
"setAuth",
"(",
")",
",",
"'json'",
"=>",
"$",
"jsonValues",
"]",
")",
";",
"}"
] |
Sends a POST request to the Craftnet API
@param $endpoint
@param array $options
@return mixed|\Psr\Http\Message\ResponseInterface
@throws \GuzzleHttp\Exception\GuzzleException
|
[
"Sends",
"a",
"POST",
"request",
"to",
"the",
"Craftnet",
"API"
] |
90c9767b6bef6078bc062b3bfcdde38b24c843fc
|
https://github.com/barrelstrength/craftnet-php/blob/90c9767b6bef6078bc062b3bfcdde38b24c843fc/src/CraftnetClient.php#L98-L110
|
20,450 |
petrica/php-statsd-system
|
Config/ConfigLoader.php
|
ConfigLoader.load
|
public function load()
{
if (file_exists($this->filepath) && ($contents = file_get_contents($this->filepath))) {
$yaml = new Parser();
$config = $yaml->parse($contents);
if (null === $config) {
$config = array();
}
$processor = new Processor();
$configDefinition = new ConfigDefinition();
$processedConfiguration = $processor->processConfiguration(
$configDefinition,
$config
);
if (empty($processedConfiguration)) {
throw new Exception(
'You need to specify at least one gaguge in the configuration file'
);
}
return $processedConfiguration;
}
else {
throw new \RuntimeException(sprintf('Configuration file does not exist or is not accessible %s',
$this->filepath));
}
}
|
php
|
public function load()
{
if (file_exists($this->filepath) && ($contents = file_get_contents($this->filepath))) {
$yaml = new Parser();
$config = $yaml->parse($contents);
if (null === $config) {
$config = array();
}
$processor = new Processor();
$configDefinition = new ConfigDefinition();
$processedConfiguration = $processor->processConfiguration(
$configDefinition,
$config
);
if (empty($processedConfiguration)) {
throw new Exception(
'You need to specify at least one gaguge in the configuration file'
);
}
return $processedConfiguration;
}
else {
throw new \RuntimeException(sprintf('Configuration file does not exist or is not accessible %s',
$this->filepath));
}
}
|
[
"public",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"filepath",
")",
"&&",
"(",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"filepath",
")",
")",
")",
"{",
"$",
"yaml",
"=",
"new",
"Parser",
"(",
")",
";",
"$",
"config",
"=",
"$",
"yaml",
"->",
"parse",
"(",
"$",
"contents",
")",
";",
"if",
"(",
"null",
"===",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"}",
"$",
"processor",
"=",
"new",
"Processor",
"(",
")",
";",
"$",
"configDefinition",
"=",
"new",
"ConfigDefinition",
"(",
")",
";",
"$",
"processedConfiguration",
"=",
"$",
"processor",
"->",
"processConfiguration",
"(",
"$",
"configDefinition",
",",
"$",
"config",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"processedConfiguration",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'You need to specify at least one gaguge in the configuration file'",
")",
";",
"}",
"return",
"$",
"processedConfiguration",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Configuration file does not exist or is not accessible %s'",
",",
"$",
"this",
"->",
"filepath",
")",
")",
";",
"}",
"}"
] |
Process configuration and make sure the configuration format is as expected
@return array
|
[
"Process",
"configuration",
"and",
"make",
"sure",
"the",
"configuration",
"format",
"is",
"as",
"expected"
] |
c476be3514a631a605737888bb8f6eb096789c9d
|
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Config/ConfigLoader.php#L36-L66
|
20,451 |
oroinc/OroLayoutComponent
|
Util/BlockUtils.php
|
BlockUtils.registerPlugin
|
public static function registerPlugin(BlockView $view, $pluginName)
{
$optionsArray = $view->vars['block_prefixes'];
array_splice(
$optionsArray,
-1,
1,
[$pluginName, end($optionsArray)]
);
$view->vars['block_prefixes'] = $optionsArray;
}
|
php
|
public static function registerPlugin(BlockView $view, $pluginName)
{
$optionsArray = $view->vars['block_prefixes'];
array_splice(
$optionsArray,
-1,
1,
[$pluginName, end($optionsArray)]
);
$view->vars['block_prefixes'] = $optionsArray;
}
|
[
"public",
"static",
"function",
"registerPlugin",
"(",
"BlockView",
"$",
"view",
",",
"$",
"pluginName",
")",
"{",
"$",
"optionsArray",
"=",
"$",
"view",
"->",
"vars",
"[",
"'block_prefixes'",
"]",
";",
"array_splice",
"(",
"$",
"optionsArray",
",",
"-",
"1",
",",
"1",
",",
"[",
"$",
"pluginName",
",",
"end",
"(",
"$",
"optionsArray",
")",
"]",
")",
";",
"$",
"view",
"->",
"vars",
"[",
"'block_prefixes'",
"]",
"=",
"$",
"optionsArray",
";",
"}"
] |
Registers the plugin for the block type.
You can use this method to add the additional block prefix that allow you
to create an additional template for existing block type.
IMPORTANT: This method should be called in finishView of your block type extension
because the 'block_prefixes' array is not filled in buildView yet.
@param BlockView $view
@param string $pluginName
|
[
"Registers",
"the",
"plugin",
"for",
"the",
"block",
"type",
".",
"You",
"can",
"use",
"this",
"method",
"to",
"add",
"the",
"additional",
"block",
"prefix",
"that",
"allow",
"you",
"to",
"create",
"an",
"additional",
"template",
"for",
"existing",
"block",
"type",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Util/BlockUtils.php#L22-L32
|
20,452 |
oroinc/OroLayoutComponent
|
Util/BlockUtils.php
|
BlockUtils.normalizeTransValue
|
public static function normalizeTransValue($text, $parameters = null)
{
if (is_string($text) && !empty($text)) {
$text = ['label' => $text];
}
if (!empty($parameters) && is_array($text) && !isset($text['parameters'])) {
$text['parameters'] = $parameters;
}
return $text;
}
|
php
|
public static function normalizeTransValue($text, $parameters = null)
{
if (is_string($text) && !empty($text)) {
$text = ['label' => $text];
}
if (!empty($parameters) && is_array($text) && !isset($text['parameters'])) {
$text['parameters'] = $parameters;
}
return $text;
}
|
[
"public",
"static",
"function",
"normalizeTransValue",
"(",
"$",
"text",
",",
"$",
"parameters",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"text",
")",
"&&",
"!",
"empty",
"(",
"$",
"text",
")",
")",
"{",
"$",
"text",
"=",
"[",
"'label'",
"=>",
"$",
"text",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"text",
")",
"&&",
"!",
"isset",
"(",
"$",
"text",
"[",
"'parameters'",
"]",
")",
")",
"{",
"$",
"text",
"[",
"'parameters'",
"]",
"=",
"$",
"parameters",
";",
"}",
"return",
"$",
"text",
";",
"}"
] |
Normalizes the given value to the format that can be translated by a renderer.
@param string|array $text The text to be translated
@param array|null $parameters The parameters
@return array
|
[
"Normalizes",
"the",
"given",
"value",
"to",
"the",
"format",
"that",
"can",
"be",
"translated",
"by",
"a",
"renderer",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Util/BlockUtils.php#L42-L52
|
20,453 |
oroinc/OroLayoutComponent
|
Util/BlockUtils.php
|
BlockUtils.processUrl
|
public static function processUrl(BlockView $view, Options $options, $required = false, $prefix = null)
{
$pathName = null !== $prefix ? $prefix . '_path' : 'path';
$routeName = null !== $prefix ? $prefix . '_route_name' : 'route_name';
if ($options->isExistsAndNotEmpty($pathName)) {
$view->vars[$pathName] = $options[$pathName];
} elseif ($options->isExistsAndNotEmpty($routeName)) {
$view->vars[$routeName] = $options[$routeName];
$routeParamName = null !== $prefix ? $prefix . '_route_parameters' : 'route_parameters';
$view->vars[$routeParamName] = isset($options[$routeParamName])
? $options[$routeParamName]
: [];
} elseif ($required) {
throw new MissingOptionsException(
sprintf('Either "%s" or "%s" must be set.', $pathName, $routeName)
);
}
}
|
php
|
public static function processUrl(BlockView $view, Options $options, $required = false, $prefix = null)
{
$pathName = null !== $prefix ? $prefix . '_path' : 'path';
$routeName = null !== $prefix ? $prefix . '_route_name' : 'route_name';
if ($options->isExistsAndNotEmpty($pathName)) {
$view->vars[$pathName] = $options[$pathName];
} elseif ($options->isExistsAndNotEmpty($routeName)) {
$view->vars[$routeName] = $options[$routeName];
$routeParamName = null !== $prefix ? $prefix . '_route_parameters' : 'route_parameters';
$view->vars[$routeParamName] = isset($options[$routeParamName])
? $options[$routeParamName]
: [];
} elseif ($required) {
throw new MissingOptionsException(
sprintf('Either "%s" or "%s" must be set.', $pathName, $routeName)
);
}
}
|
[
"public",
"static",
"function",
"processUrl",
"(",
"BlockView",
"$",
"view",
",",
"Options",
"$",
"options",
",",
"$",
"required",
"=",
"false",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"pathName",
"=",
"null",
"!==",
"$",
"prefix",
"?",
"$",
"prefix",
".",
"'_path'",
":",
"'path'",
";",
"$",
"routeName",
"=",
"null",
"!==",
"$",
"prefix",
"?",
"$",
"prefix",
".",
"'_route_name'",
":",
"'route_name'",
";",
"if",
"(",
"$",
"options",
"->",
"isExistsAndNotEmpty",
"(",
"$",
"pathName",
")",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"$",
"pathName",
"]",
"=",
"$",
"options",
"[",
"$",
"pathName",
"]",
";",
"}",
"elseif",
"(",
"$",
"options",
"->",
"isExistsAndNotEmpty",
"(",
"$",
"routeName",
")",
")",
"{",
"$",
"view",
"->",
"vars",
"[",
"$",
"routeName",
"]",
"=",
"$",
"options",
"[",
"$",
"routeName",
"]",
";",
"$",
"routeParamName",
"=",
"null",
"!==",
"$",
"prefix",
"?",
"$",
"prefix",
".",
"'_route_parameters'",
":",
"'route_parameters'",
";",
"$",
"view",
"->",
"vars",
"[",
"$",
"routeParamName",
"]",
"=",
"isset",
"(",
"$",
"options",
"[",
"$",
"routeParamName",
"]",
")",
"?",
"$",
"options",
"[",
"$",
"routeParamName",
"]",
":",
"[",
"]",
";",
"}",
"elseif",
"(",
"$",
"required",
")",
"{",
"throw",
"new",
"MissingOptionsException",
"(",
"sprintf",
"(",
"'Either \"%s\" or \"%s\" must be set.'",
",",
"$",
"pathName",
",",
"$",
"routeName",
")",
")",
";",
"}",
"}"
] |
Gets the url related options and pass them to the block view.
@param BlockView $view The block view
@param Options $options The block options
@param boolean $required Specifies whether the url related options are mandatory
@param string|null $prefix The prefix for the url related options
@SuppressWarnings(PHPMD.NPathComplexity)
|
[
"Gets",
"the",
"url",
"related",
"options",
"and",
"pass",
"them",
"to",
"the",
"block",
"view",
"."
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Util/BlockUtils.php#L64-L82
|
20,454 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.removePreProcessor
|
public function removePreProcessor($callback)
{
if (($index = array_search($callback, $this->processors['pre'], true)) !== false) {
unset($this->processors['pre'][$index]);
} elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['pre'], true)) !== false) {
unset($this->processors['pre'][$index]);
} else {
$class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback);
foreach ($this->processors['pre'] as $index=>$proc) {
if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
unset($this->processors['pre'][$index]);
break;
}
}
}
}
|
php
|
public function removePreProcessor($callback)
{
if (($index = array_search($callback, $this->processors['pre'], true)) !== false) {
unset($this->processors['pre'][$index]);
} elseif (($index = array_search('Dwoo_Processor_'.str_replace('Dwoo_Processor_', '', $callback), $this->processors['pre'], true)) !== false) {
unset($this->processors['pre'][$index]);
} else {
$class = 'Dwoo_Processor_' . str_replace('Dwoo_Processor_', '', $callback);
foreach ($this->processors['pre'] as $index=>$proc) {
if (is_array($proc) && ($proc[0] instanceof $class) || (isset($proc['class']) && $proc['class'] == $class)) {
unset($this->processors['pre'][$index]);
break;
}
}
}
}
|
[
"public",
"function",
"removePreProcessor",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"(",
"$",
"index",
"=",
"array_search",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"processors",
"[",
"'pre'",
"]",
",",
"true",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"processors",
"[",
"'pre'",
"]",
"[",
"$",
"index",
"]",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"index",
"=",
"array_search",
"(",
"'Dwoo_Processor_'",
".",
"str_replace",
"(",
"'Dwoo_Processor_'",
",",
"''",
",",
"$",
"callback",
")",
",",
"$",
"this",
"->",
"processors",
"[",
"'pre'",
"]",
",",
"true",
")",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"processors",
"[",
"'pre'",
"]",
"[",
"$",
"index",
"]",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'Dwoo_Processor_'",
".",
"str_replace",
"(",
"'Dwoo_Processor_'",
",",
"''",
",",
"$",
"callback",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"processors",
"[",
"'pre'",
"]",
"as",
"$",
"index",
"=>",
"$",
"proc",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"proc",
")",
"&&",
"(",
"$",
"proc",
"[",
"0",
"]",
"instanceof",
"$",
"class",
")",
"||",
"(",
"isset",
"(",
"$",
"proc",
"[",
"'class'",
"]",
")",
"&&",
"$",
"proc",
"[",
"'class'",
"]",
"==",
"$",
"class",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"processors",
"[",
"'pre'",
"]",
"[",
"$",
"index",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
removes a preprocessor from the compiler
@param mixed $callback either a valid callback to the preprocessor or a simple name if it was autoloaded
|
[
"removes",
"a",
"preprocessor",
"from",
"the",
"compiler"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L380-L395
|
20,455 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.addPostProcessor
|
public function addPostProcessor($callback, $autoload = false)
{
if ($autoload) {
$name = str_replace('Dwoo_Processor_', '', $callback);
$class = 'Dwoo_Processor_'.$name;
if (class_exists($class, false)) {
$callback = array(new $class($this), 'process');
} elseif (function_exists($class)) {
$callback = $class;
} else {
$callback = array('autoload'=>true, 'class'=>$class, 'name'=>$name);
}
$this->processors['post'][] = $callback;
} else {
$this->processors['post'][] = $callback;
}
}
|
php
|
public function addPostProcessor($callback, $autoload = false)
{
if ($autoload) {
$name = str_replace('Dwoo_Processor_', '', $callback);
$class = 'Dwoo_Processor_'.$name;
if (class_exists($class, false)) {
$callback = array(new $class($this), 'process');
} elseif (function_exists($class)) {
$callback = $class;
} else {
$callback = array('autoload'=>true, 'class'=>$class, 'name'=>$name);
}
$this->processors['post'][] = $callback;
} else {
$this->processors['post'][] = $callback;
}
}
|
[
"public",
"function",
"addPostProcessor",
"(",
"$",
"callback",
",",
"$",
"autoload",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"autoload",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'Dwoo_Processor_'",
",",
"''",
",",
"$",
"callback",
")",
";",
"$",
"class",
"=",
"'Dwoo_Processor_'",
".",
"$",
"name",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
")",
"{",
"$",
"callback",
"=",
"array",
"(",
"new",
"$",
"class",
"(",
"$",
"this",
")",
",",
"'process'",
")",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"class",
";",
"}",
"else",
"{",
"$",
"callback",
"=",
"array",
"(",
"'autoload'",
"=>",
"true",
",",
"'class'",
"=>",
"$",
"class",
",",
"'name'",
"=>",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"processors",
"[",
"'post'",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"processors",
"[",
"'post'",
"]",
"[",
"]",
"=",
"$",
"callback",
";",
"}",
"}"
] |
adds a postprocessor to the compiler, it will be called
before the template is compiled
@param mixed $callback either a valid callback to the postprocessor or a simple name if the autoload is set to true
@param bool $autoload if set to true, the postprocessor is auto-loaded from one of the plugin directories, else you must provide a valid callback
|
[
"adds",
"a",
"postprocessor",
"to",
"the",
"compiler",
"it",
"will",
"be",
"called",
"before",
"the",
"template",
"is",
"compiled"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L404-L422
|
20,456 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.loadProcessor
|
protected function loadProcessor($class, $name)
{
if (!class_exists($class, false) && !function_exists($class)) {
try {
$this->dwoo->getLoader()->loadPlugin($name);
} catch (Dwoo_Exception $e) {
throw new Dwoo_Exception('Processor '.$name.' could not be found in your plugin directories, please ensure it is in a file named '.$name.'.php in the plugin directory');
}
}
if (class_exists($class, false)) {
return array(new $class($this), 'process');
}
if (function_exists($class)) {
return $class;
}
throw new Dwoo_Exception('Wrong processor name, when using autoload the processor must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Processor_name"');
}
|
php
|
protected function loadProcessor($class, $name)
{
if (!class_exists($class, false) && !function_exists($class)) {
try {
$this->dwoo->getLoader()->loadPlugin($name);
} catch (Dwoo_Exception $e) {
throw new Dwoo_Exception('Processor '.$name.' could not be found in your plugin directories, please ensure it is in a file named '.$name.'.php in the plugin directory');
}
}
if (class_exists($class, false)) {
return array(new $class($this), 'process');
}
if (function_exists($class)) {
return $class;
}
throw new Dwoo_Exception('Wrong processor name, when using autoload the processor must be in one of your plugin dir as "name.php" containg a class or function named "Dwoo_Processor_name"');
}
|
[
"protected",
"function",
"loadProcessor",
"(",
"$",
"class",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
"&&",
"!",
"function_exists",
"(",
"$",
"class",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"dwoo",
"->",
"getLoader",
"(",
")",
"->",
"loadPlugin",
"(",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"Dwoo_Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Processor '",
".",
"$",
"name",
".",
"' could not be found in your plugin directories, please ensure it is in a file named '",
".",
"$",
"name",
".",
"'.php in the plugin directory'",
")",
";",
"}",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
")",
"{",
"return",
"array",
"(",
"new",
"$",
"class",
"(",
"$",
"this",
")",
",",
"'process'",
")",
";",
"}",
"if",
"(",
"function_exists",
"(",
"$",
"class",
")",
")",
"{",
"return",
"$",
"class",
";",
"}",
"throw",
"new",
"Dwoo_Exception",
"(",
"'Wrong processor name, when using autoload the processor must be in one of your plugin dir as \"name.php\" containg a class or function named \"Dwoo_Processor_name\"'",
")",
";",
"}"
] |
internal function to autoload processors at runtime if required
@param string $class the class/function name
@param string $name the plugin name (without Dwoo_Plugin_ prefix)
|
[
"internal",
"function",
"to",
"autoload",
"processors",
"at",
"runtime",
"if",
"required"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L452-L471
|
20,457 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.resolveSubTemplateDependencies
|
protected function resolveSubTemplateDependencies($function)
{
$body = $this->templatePlugins[$function]['body'];
foreach ($this->templatePlugins as $func => $attr) {
if ($func !== $function && !isset($attr['called']) && strpos($body, 'Dwoo_Plugin_'.$func) !== false) {
$this->templatePlugins[$func]['called'] = true;
$this->resolveSubTemplateDependencies($func);
}
}
$this->templatePlugins[$function]['checked'] = true;
}
|
php
|
protected function resolveSubTemplateDependencies($function)
{
$body = $this->templatePlugins[$function]['body'];
foreach ($this->templatePlugins as $func => $attr) {
if ($func !== $function && !isset($attr['called']) && strpos($body, 'Dwoo_Plugin_'.$func) !== false) {
$this->templatePlugins[$func]['called'] = true;
$this->resolveSubTemplateDependencies($func);
}
}
$this->templatePlugins[$function]['checked'] = true;
}
|
[
"protected",
"function",
"resolveSubTemplateDependencies",
"(",
"$",
"function",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"templatePlugins",
"[",
"$",
"function",
"]",
"[",
"'body'",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"templatePlugins",
"as",
"$",
"func",
"=>",
"$",
"attr",
")",
"{",
"if",
"(",
"$",
"func",
"!==",
"$",
"function",
"&&",
"!",
"isset",
"(",
"$",
"attr",
"[",
"'called'",
"]",
")",
"&&",
"strpos",
"(",
"$",
"body",
",",
"'Dwoo_Plugin_'",
".",
"$",
"func",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"templatePlugins",
"[",
"$",
"func",
"]",
"[",
"'called'",
"]",
"=",
"true",
";",
"$",
"this",
"->",
"resolveSubTemplateDependencies",
"(",
"$",
"func",
")",
";",
"}",
"}",
"$",
"this",
"->",
"templatePlugins",
"[",
"$",
"function",
"]",
"[",
"'checked'",
"]",
"=",
"true",
";",
"}"
] |
checks what sub-templates are used in every sub-template so that we're sure they are all compiled
@param string $function the sub-template name
|
[
"checks",
"what",
"sub",
"-",
"templates",
"are",
"used",
"in",
"every",
"sub",
"-",
"template",
"so",
"that",
"we",
"re",
"sure",
"they",
"are",
"all",
"compiled"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L916-L926
|
20,458 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.setScope
|
public function setScope($scope, $absolute = false)
{
$old = $this->scopeTree;
if ($scope===null) {
unset($this->scope);
$this->scope = null;
}
if (is_array($scope)===false) {
$scope = explode('.', $scope);
}
if ($absolute===true) {
$this->scope =& $this->data;
$this->scopeTree = array();
}
while (($bit = array_shift($scope)) !== null) {
if ($bit === '_parent' || $bit === '_') {
array_pop($this->scopeTree);
reset($this->scopeTree);
$this->scope =& $this->data;
$cnt = count($this->scopeTree);
for ($i=0;$i<$cnt;$i++)
$this->scope =& $this->scope[$this->scopeTree[$i]];
} elseif ($bit === '_root' || $bit === '__') {
$this->scope =& $this->data;
$this->scopeTree = array();
} elseif (isset($this->scope[$bit])) {
$this->scope =& $this->scope[$bit];
$this->scopeTree[] = $bit;
} else {
$this->scope[$bit] = array();
$this->scope =& $this->scope[$bit];
$this->scopeTree[] = $bit;
}
}
return $old;
}
|
php
|
public function setScope($scope, $absolute = false)
{
$old = $this->scopeTree;
if ($scope===null) {
unset($this->scope);
$this->scope = null;
}
if (is_array($scope)===false) {
$scope = explode('.', $scope);
}
if ($absolute===true) {
$this->scope =& $this->data;
$this->scopeTree = array();
}
while (($bit = array_shift($scope)) !== null) {
if ($bit === '_parent' || $bit === '_') {
array_pop($this->scopeTree);
reset($this->scopeTree);
$this->scope =& $this->data;
$cnt = count($this->scopeTree);
for ($i=0;$i<$cnt;$i++)
$this->scope =& $this->scope[$this->scopeTree[$i]];
} elseif ($bit === '_root' || $bit === '__') {
$this->scope =& $this->data;
$this->scopeTree = array();
} elseif (isset($this->scope[$bit])) {
$this->scope =& $this->scope[$bit];
$this->scopeTree[] = $bit;
} else {
$this->scope[$bit] = array();
$this->scope =& $this->scope[$bit];
$this->scopeTree[] = $bit;
}
}
return $old;
}
|
[
"public",
"function",
"setScope",
"(",
"$",
"scope",
",",
"$",
"absolute",
"=",
"false",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"scopeTree",
";",
"if",
"(",
"$",
"scope",
"===",
"null",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"scope",
")",
";",
"$",
"this",
"->",
"scope",
"=",
"null",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"scope",
")",
"===",
"false",
")",
"{",
"$",
"scope",
"=",
"explode",
"(",
"'.'",
",",
"$",
"scope",
")",
";",
"}",
"if",
"(",
"$",
"absolute",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"$",
"this",
"->",
"scopeTree",
"=",
"array",
"(",
")",
";",
"}",
"while",
"(",
"(",
"$",
"bit",
"=",
"array_shift",
"(",
"$",
"scope",
")",
")",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"bit",
"===",
"'_parent'",
"||",
"$",
"bit",
"===",
"'_'",
")",
"{",
"array_pop",
"(",
"$",
"this",
"->",
"scopeTree",
")",
";",
"reset",
"(",
"$",
"this",
"->",
"scopeTree",
")",
";",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"$",
"cnt",
"=",
"count",
"(",
"$",
"this",
"->",
"scopeTree",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"cnt",
";",
"$",
"i",
"++",
")",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"scope",
"[",
"$",
"this",
"->",
"scopeTree",
"[",
"$",
"i",
"]",
"]",
";",
"}",
"elseif",
"(",
"$",
"bit",
"===",
"'_root'",
"||",
"$",
"bit",
"===",
"'__'",
")",
"{",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"$",
"this",
"->",
"scopeTree",
"=",
"array",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"scope",
"[",
"$",
"bit",
"]",
")",
")",
"{",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"scope",
"[",
"$",
"bit",
"]",
";",
"$",
"this",
"->",
"scopeTree",
"[",
"]",
"=",
"$",
"bit",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"scope",
"[",
"$",
"bit",
"]",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"scope",
"=",
"&",
"$",
"this",
"->",
"scope",
"[",
"$",
"bit",
"]",
";",
"$",
"this",
"->",
"scopeTree",
"[",
"]",
"=",
"$",
"bit",
";",
"}",
"}",
"return",
"$",
"old",
";",
"}"
] |
sets the scope
set to null if the scope becomes "unstable" (i.e. too variable or unknown) so that
variables are compiled in a more evaluative way than just $this->scope['key']
@param mixed $scope a string i.e. "level1.level2" or an array i.e. array("level1", "level2")
@param bool $absolute if true, the scope is set from the top level scope and not from the current scope
@return array the current scope tree
|
[
"sets",
"the",
"scope"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L964-L1004
|
20,459 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.addBlock
|
public function addBlock($type, array $params, $paramtype)
{
$class = 'Dwoo_Plugin_'.$type;
if (class_exists($class, false) === false) {
$this->dwoo->getLoader()->loadPlugin($type);
}
$params = $this->mapParams($params, array($class, 'init'), $paramtype);
$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
$this->curBlock =& $this->stack[count($this->stack)-1];
return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type);
}
|
php
|
public function addBlock($type, array $params, $paramtype)
{
$class = 'Dwoo_Plugin_'.$type;
if (class_exists($class, false) === false) {
$this->dwoo->getLoader()->loadPlugin($type);
}
$params = $this->mapParams($params, array($class, 'init'), $paramtype);
$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
$this->curBlock =& $this->stack[count($this->stack)-1];
return call_user_func(array($class,'preProcessing'), $this, $params, '', '', $type);
}
|
[
"public",
"function",
"addBlock",
"(",
"$",
"type",
",",
"array",
"$",
"params",
",",
"$",
"paramtype",
")",
"{",
"$",
"class",
"=",
"'Dwoo_Plugin_'",
".",
"$",
"type",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"dwoo",
"->",
"getLoader",
"(",
")",
"->",
"loadPlugin",
"(",
"$",
"type",
")",
";",
"}",
"$",
"params",
"=",
"$",
"this",
"->",
"mapParams",
"(",
"$",
"params",
",",
"array",
"(",
"$",
"class",
",",
"'init'",
")",
",",
"$",
"paramtype",
")",
";",
"$",
"this",
"->",
"stack",
"[",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'params'",
"=>",
"$",
"params",
",",
"'custom'",
"=>",
"false",
",",
"'class'",
"=>",
"$",
"class",
",",
"'buffer'",
"=>",
"null",
")",
";",
"$",
"this",
"->",
"curBlock",
"=",
"&",
"$",
"this",
"->",
"stack",
"[",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
"-",
"1",
"]",
";",
"return",
"call_user_func",
"(",
"array",
"(",
"$",
"class",
",",
"'preProcessing'",
")",
",",
"$",
"this",
",",
"$",
"params",
",",
"''",
",",
"''",
",",
"$",
"type",
")",
";",
"}"
] |
adds a block to the top of the block stack
@param string $type block type (name)
@param array $params the parameters array
@param int $paramtype the parameters type (see mapParams), 0, 1 or 2
@return string the preProcessing() method's output
|
[
"adds",
"a",
"block",
"to",
"the",
"top",
"of",
"the",
"block",
"stack"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L1014-L1026
|
20,460 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.injectBlock
|
public function injectBlock($type, array $params)
{
$class = 'Dwoo_Plugin_'.$type;
if (class_exists($class, false) === false) {
$this->dwoo->getLoader()->loadPlugin($type);
}
$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
$this->curBlock =& $this->stack[count($this->stack)-1];
}
|
php
|
public function injectBlock($type, array $params)
{
$class = 'Dwoo_Plugin_'.$type;
if (class_exists($class, false) === false) {
$this->dwoo->getLoader()->loadPlugin($type);
}
$this->stack[] = array('type' => $type, 'params' => $params, 'custom' => false, 'class' => $class, 'buffer' => null);
$this->curBlock =& $this->stack[count($this->stack)-1];
}
|
[
"public",
"function",
"injectBlock",
"(",
"$",
"type",
",",
"array",
"$",
"params",
")",
"{",
"$",
"class",
"=",
"'Dwoo_Plugin_'",
".",
"$",
"type",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
",",
"false",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"dwoo",
"->",
"getLoader",
"(",
")",
"->",
"loadPlugin",
"(",
"$",
"type",
")",
";",
"}",
"$",
"this",
"->",
"stack",
"[",
"]",
"=",
"array",
"(",
"'type'",
"=>",
"$",
"type",
",",
"'params'",
"=>",
"$",
"params",
",",
"'custom'",
"=>",
"false",
",",
"'class'",
"=>",
"$",
"class",
",",
"'buffer'",
"=>",
"null",
")",
";",
"$",
"this",
"->",
"curBlock",
"=",
"&",
"$",
"this",
"->",
"stack",
"[",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
"-",
"1",
"]",
";",
"}"
] |
injects a block at the top of the plugin stack without calling its preProcessing method
used by {else} blocks to re-add themselves after having closed everything up to their parent
@param string $type block type (name)
@param array $params parameters array
|
[
"injects",
"a",
"block",
"at",
"the",
"top",
"of",
"the",
"plugin",
"stack",
"without",
"calling",
"its",
"preProcessing",
"method"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L1060-L1068
|
20,461 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.removeBlock
|
public function removeBlock($type)
{
$output = '';
$pluginType = $this->getPluginType($type);
if ($pluginType & Dwoo::SMARTY_BLOCK) {
$type = 'smartyinterface';
}
while (true) {
while ($top = array_pop($this->stack)) {
if ($top['custom']) {
$class = $top['class'];
} else {
$class = 'Dwoo_Plugin_'.$top['type'];
}
if (count($this->stack)) {
$this->curBlock =& $this->stack[count($this->stack)-1];
$this->push(call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']), 0);
} else {
$null = null;
$this->curBlock =& $null;
$output = call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']);
}
if ($top['type'] === $type) {
break 2;
}
}
throw new Dwoo_Compilation_Exception($this, 'Syntax malformation, a block of type "'.$type.'" was closed but was not opened');
break;
}
return $output;
}
|
php
|
public function removeBlock($type)
{
$output = '';
$pluginType = $this->getPluginType($type);
if ($pluginType & Dwoo::SMARTY_BLOCK) {
$type = 'smartyinterface';
}
while (true) {
while ($top = array_pop($this->stack)) {
if ($top['custom']) {
$class = $top['class'];
} else {
$class = 'Dwoo_Plugin_'.$top['type'];
}
if (count($this->stack)) {
$this->curBlock =& $this->stack[count($this->stack)-1];
$this->push(call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']), 0);
} else {
$null = null;
$this->curBlock =& $null;
$output = call_user_func(array($class, 'postProcessing'), $this, $top['params'], '', '', $top['buffer']);
}
if ($top['type'] === $type) {
break 2;
}
}
throw new Dwoo_Compilation_Exception($this, 'Syntax malformation, a block of type "'.$type.'" was closed but was not opened');
break;
}
return $output;
}
|
[
"public",
"function",
"removeBlock",
"(",
"$",
"type",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"pluginType",
"=",
"$",
"this",
"->",
"getPluginType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"pluginType",
"&",
"Dwoo",
"::",
"SMARTY_BLOCK",
")",
"{",
"$",
"type",
"=",
"'smartyinterface'",
";",
"}",
"while",
"(",
"true",
")",
"{",
"while",
"(",
"$",
"top",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"if",
"(",
"$",
"top",
"[",
"'custom'",
"]",
")",
"{",
"$",
"class",
"=",
"$",
"top",
"[",
"'class'",
"]",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'Dwoo_Plugin_'",
".",
"$",
"top",
"[",
"'type'",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"$",
"this",
"->",
"curBlock",
"=",
"&",
"$",
"this",
"->",
"stack",
"[",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
"-",
"1",
"]",
";",
"$",
"this",
"->",
"push",
"(",
"call_user_func",
"(",
"array",
"(",
"$",
"class",
",",
"'postProcessing'",
")",
",",
"$",
"this",
",",
"$",
"top",
"[",
"'params'",
"]",
",",
"''",
",",
"''",
",",
"$",
"top",
"[",
"'buffer'",
"]",
")",
",",
"0",
")",
";",
"}",
"else",
"{",
"$",
"null",
"=",
"null",
";",
"$",
"this",
"->",
"curBlock",
"=",
"&",
"$",
"null",
";",
"$",
"output",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"class",
",",
"'postProcessing'",
")",
",",
"$",
"this",
",",
"$",
"top",
"[",
"'params'",
"]",
",",
"''",
",",
"''",
",",
"$",
"top",
"[",
"'buffer'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"top",
"[",
"'type'",
"]",
"===",
"$",
"type",
")",
"{",
"break",
"2",
";",
"}",
"}",
"throw",
"new",
"Dwoo_Compilation_Exception",
"(",
"$",
"this",
",",
"'Syntax malformation, a block of type \"'",
".",
"$",
"type",
".",
"'\" was closed but was not opened'",
")",
";",
"break",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
removes the closest-to-top block of the given type and all other
blocks encountered while going down the block stack
@param string $type block type (name)
@return string the output of all postProcessing() method's return values of the closed blocks
|
[
"removes",
"the",
"closest",
"-",
"to",
"-",
"top",
"block",
"of",
"the",
"given",
"type",
"and",
"all",
"other",
"blocks",
"encountered",
"while",
"going",
"down",
"the",
"block",
"stack"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L1077-L1111
|
20,462 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.&
|
public function &findBlock($type, $closeAlong = false)
{
if ($closeAlong===true) {
while ($b = end($this->stack)) {
if ($b['type']===$type) {
return $this->stack[key($this->stack)];
}
$this->push($this->removeTopBlock(), 0);
}
} else {
end($this->stack);
while ($b = current($this->stack)) {
if ($b['type']===$type) {
return $this->stack[key($this->stack)];
}
prev($this->stack);
}
}
throw new Dwoo_Compilation_Exception($this, 'A parent block of type "'.$type.'" is required and can not be found');
}
|
php
|
public function &findBlock($type, $closeAlong = false)
{
if ($closeAlong===true) {
while ($b = end($this->stack)) {
if ($b['type']===$type) {
return $this->stack[key($this->stack)];
}
$this->push($this->removeTopBlock(), 0);
}
} else {
end($this->stack);
while ($b = current($this->stack)) {
if ($b['type']===$type) {
return $this->stack[key($this->stack)];
}
prev($this->stack);
}
}
throw new Dwoo_Compilation_Exception($this, 'A parent block of type "'.$type.'" is required and can not be found');
}
|
[
"public",
"function",
"&",
"findBlock",
"(",
"$",
"type",
",",
"$",
"closeAlong",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"closeAlong",
"===",
"true",
")",
"{",
"while",
"(",
"$",
"b",
"=",
"end",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"if",
"(",
"$",
"b",
"[",
"'type'",
"]",
"===",
"$",
"type",
")",
"{",
"return",
"$",
"this",
"->",
"stack",
"[",
"key",
"(",
"$",
"this",
"->",
"stack",
")",
"]",
";",
"}",
"$",
"this",
"->",
"push",
"(",
"$",
"this",
"->",
"removeTopBlock",
"(",
")",
",",
"0",
")",
";",
"}",
"}",
"else",
"{",
"end",
"(",
"$",
"this",
"->",
"stack",
")",
";",
"while",
"(",
"$",
"b",
"=",
"current",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"if",
"(",
"$",
"b",
"[",
"'type'",
"]",
"===",
"$",
"type",
")",
"{",
"return",
"$",
"this",
"->",
"stack",
"[",
"key",
"(",
"$",
"this",
"->",
"stack",
")",
"]",
";",
"}",
"prev",
"(",
"$",
"this",
"->",
"stack",
")",
";",
"}",
"}",
"throw",
"new",
"Dwoo_Compilation_Exception",
"(",
"$",
"this",
",",
"'A parent block of type \"'",
".",
"$",
"type",
".",
"'\" is required and can not be found'",
")",
";",
"}"
] |
returns a reference to the first block of the given type encountered and
optionally closes all blocks until it finds it
this is mainly used by {else} plugins to close everything that was opened
between their parent and themselves
@param string $type the block type (name)
@param bool $closeAlong whether to close all blocks encountered while going down the block stack or not
@return &array the array is as such: array('type'=>pluginName, 'params'=>parameter array,
'custom'=>bool defining whether it's a custom plugin or not, for internal use)
|
[
"returns",
"a",
"reference",
"to",
"the",
"first",
"block",
"of",
"the",
"given",
"type",
"encountered",
"and",
"optionally",
"closes",
"all",
"blocks",
"until",
"it",
"finds",
"it"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L1125-L1145
|
20,463 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php
|
Dwoo_Compiler.replaceStringVars
|
protected function replaceStringVars($string, $first, $curBlock='')
{
$pos = 0;
if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string.'<br>';
// replace vars
while (($pos = strpos($string, '$', $pos)) !== false) {
$prev = substr($string, $pos-1, 1);
if ($prev === '\\') {
$pos++;
continue;
}
$var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
$len = $var[0];
$var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
if ($prev === '`' && substr($string, $pos+$len, 1) === '`') {
$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2);
} else {
$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len);
}
$pos += strlen($var[1]) + 2;
if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string.'<br>';
}
// handle modifiers
// TODO Obsolete?
$string = preg_replace_callback('#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array($this, 'replaceModifiers'), $string);
// replace escaped dollar operators by unescaped ones if required
if ($first==="'") {
$string = str_replace('\\$', '$', $string);
}
return $string;
}
|
php
|
protected function replaceStringVars($string, $first, $curBlock='')
{
$pos = 0;
if ($this->debug) echo 'STRING VAR REPLACEMENT : '.$string.'<br>';
// replace vars
while (($pos = strpos($string, '$', $pos)) !== false) {
$prev = substr($string, $pos-1, 1);
if ($prev === '\\') {
$pos++;
continue;
}
$var = $this->parse($string, $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
$len = $var[0];
$var = $this->parse(str_replace('\\'.$first, $first, $string), $pos, null, false, ($curBlock === 'modifier' ? 'modifier' : ($prev === '`' ? 'delimited_string':'string')));
if ($prev === '`' && substr($string, $pos+$len, 1) === '`') {
$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos-1, $len+2);
} else {
$string = substr_replace($string, $first.'.'.$var[1].'.'.$first, $pos, $len);
}
$pos += strlen($var[1]) + 2;
if ($this->debug) echo 'STRING VAR REPLACEMENT DONE : '.$string.'<br>';
}
// handle modifiers
// TODO Obsolete?
$string = preg_replace_callback('#("|\')\.(.+?)\.\1((?:\|(?:@?[a-z0-9_]+(?:(?::("|\').+?\4|:[^`]*))*))+)#i', array($this, 'replaceModifiers'), $string);
// replace escaped dollar operators by unescaped ones if required
if ($first==="'") {
$string = str_replace('\\$', '$', $string);
}
return $string;
}
|
[
"protected",
"function",
"replaceStringVars",
"(",
"$",
"string",
",",
"$",
"first",
",",
"$",
"curBlock",
"=",
"''",
")",
"{",
"$",
"pos",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"echo",
"'STRING VAR REPLACEMENT : '",
".",
"$",
"string",
".",
"'<br>'",
";",
"// replace vars",
"while",
"(",
"(",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"string",
",",
"'$'",
",",
"$",
"pos",
")",
")",
"!==",
"false",
")",
"{",
"$",
"prev",
"=",
"substr",
"(",
"$",
"string",
",",
"$",
"pos",
"-",
"1",
",",
"1",
")",
";",
"if",
"(",
"$",
"prev",
"===",
"'\\\\'",
")",
"{",
"$",
"pos",
"++",
";",
"continue",
";",
"}",
"$",
"var",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"string",
",",
"$",
"pos",
",",
"null",
",",
"false",
",",
"(",
"$",
"curBlock",
"===",
"'modifier'",
"?",
"'modifier'",
":",
"(",
"$",
"prev",
"===",
"'`'",
"?",
"'delimited_string'",
":",
"'string'",
")",
")",
")",
";",
"$",
"len",
"=",
"$",
"var",
"[",
"0",
"]",
";",
"$",
"var",
"=",
"$",
"this",
"->",
"parse",
"(",
"str_replace",
"(",
"'\\\\'",
".",
"$",
"first",
",",
"$",
"first",
",",
"$",
"string",
")",
",",
"$",
"pos",
",",
"null",
",",
"false",
",",
"(",
"$",
"curBlock",
"===",
"'modifier'",
"?",
"'modifier'",
":",
"(",
"$",
"prev",
"===",
"'`'",
"?",
"'delimited_string'",
":",
"'string'",
")",
")",
")",
";",
"if",
"(",
"$",
"prev",
"===",
"'`'",
"&&",
"substr",
"(",
"$",
"string",
",",
"$",
"pos",
"+",
"$",
"len",
",",
"1",
")",
"===",
"'`'",
")",
"{",
"$",
"string",
"=",
"substr_replace",
"(",
"$",
"string",
",",
"$",
"first",
".",
"'.'",
".",
"$",
"var",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"first",
",",
"$",
"pos",
"-",
"1",
",",
"$",
"len",
"+",
"2",
")",
";",
"}",
"else",
"{",
"$",
"string",
"=",
"substr_replace",
"(",
"$",
"string",
",",
"$",
"first",
".",
"'.'",
".",
"$",
"var",
"[",
"1",
"]",
".",
"'.'",
".",
"$",
"first",
",",
"$",
"pos",
",",
"$",
"len",
")",
";",
"}",
"$",
"pos",
"+=",
"strlen",
"(",
"$",
"var",
"[",
"1",
"]",
")",
"+",
"2",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"echo",
"'STRING VAR REPLACEMENT DONE : '",
".",
"$",
"string",
".",
"'<br>'",
";",
"}",
"// handle modifiers",
"// TODO Obsolete?",
"$",
"string",
"=",
"preg_replace_callback",
"(",
"'#(\"|\\')\\.(.+?)\\.\\1((?:\\|(?:@?[a-z0-9_]+(?:(?::(\"|\\').+?\\4|:[^`]*))*))+)#i'",
",",
"array",
"(",
"$",
"this",
",",
"'replaceModifiers'",
")",
",",
"$",
"string",
")",
";",
"// replace escaped dollar operators by unescaped ones if required",
"if",
"(",
"$",
"first",
"===",
"\"'\"",
")",
"{",
"$",
"string",
"=",
"str_replace",
"(",
"'\\\\$'",
",",
"'$'",
",",
"$",
"string",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
replaces variables within a parsed string
@param string $string the parsed string
@param string $first the first character parsed in the string, which is the string delimiter (' or ")
@param string $curBlock the current parser-block being processed
@return string the original string with variables replaced
|
[
"replaces",
"variables",
"within",
"a",
"parsed",
"string"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Compiler.php#L2545-L2580
|
20,464 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/mail.php
|
ezcMail.generateHeaders
|
public function generateHeaders()
{
// set our headers first.
if ( $this->from !== null )
{
$this->setHeader( "From", ezcMailTools::composeEmailAddress( $this->from ) );
}
if ( $this->to !== null )
{
$this->setHeader( "To", ezcMailTools::composeEmailAddresses( $this->to ) );
}
if ( count( $this->cc ) )
{
$this->setHeader( "Cc", ezcMailTools::composeEmailAddresses( $this->cc ) );
}
if ( count( $this->bcc ) && $this->options->stripBccHeader === false )
{
$this->setHeader( "Bcc", ezcMailTools::composeEmailAddresses( $this->bcc ) );
}
$this->setHeader( 'Subject', $this->subject, $this->subjectCharset );
$this->setHeader( 'MIME-Version', '1.0' );
$this->setHeader( 'User-Agent', 'eZ Components' );
$this->setHeader( 'Date', date( 'r' ) );
$idhost = $this->from != null && $this->from->email != '' ? $this->from->email : 'localhost';
if ( is_null( $this->messageId ) )
{
$this->setHeader( 'Message-Id', '<' . ezcMailTools::generateMessageId( $idhost ) . '>' );
}
else
{
$this->setHeader( 'Message-Id', $this->messageID );
}
// if we have a body part, include the headers of the body
if ( is_subclass_of( $this->body, "ezcMailPart" ) )
{
return parent::generateHeaders() . $this->body->generateHeaders();
}
return parent::generateHeaders();
}
|
php
|
public function generateHeaders()
{
// set our headers first.
if ( $this->from !== null )
{
$this->setHeader( "From", ezcMailTools::composeEmailAddress( $this->from ) );
}
if ( $this->to !== null )
{
$this->setHeader( "To", ezcMailTools::composeEmailAddresses( $this->to ) );
}
if ( count( $this->cc ) )
{
$this->setHeader( "Cc", ezcMailTools::composeEmailAddresses( $this->cc ) );
}
if ( count( $this->bcc ) && $this->options->stripBccHeader === false )
{
$this->setHeader( "Bcc", ezcMailTools::composeEmailAddresses( $this->bcc ) );
}
$this->setHeader( 'Subject', $this->subject, $this->subjectCharset );
$this->setHeader( 'MIME-Version', '1.0' );
$this->setHeader( 'User-Agent', 'eZ Components' );
$this->setHeader( 'Date', date( 'r' ) );
$idhost = $this->from != null && $this->from->email != '' ? $this->from->email : 'localhost';
if ( is_null( $this->messageId ) )
{
$this->setHeader( 'Message-Id', '<' . ezcMailTools::generateMessageId( $idhost ) . '>' );
}
else
{
$this->setHeader( 'Message-Id', $this->messageID );
}
// if we have a body part, include the headers of the body
if ( is_subclass_of( $this->body, "ezcMailPart" ) )
{
return parent::generateHeaders() . $this->body->generateHeaders();
}
return parent::generateHeaders();
}
|
[
"public",
"function",
"generateHeaders",
"(",
")",
"{",
"// set our headers first.",
"if",
"(",
"$",
"this",
"->",
"from",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"\"From\"",
",",
"ezcMailTools",
"::",
"composeEmailAddress",
"(",
"$",
"this",
"->",
"from",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"to",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"\"To\"",
",",
"ezcMailTools",
"::",
"composeEmailAddresses",
"(",
"$",
"this",
"->",
"to",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"cc",
")",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"\"Cc\"",
",",
"ezcMailTools",
"::",
"composeEmailAddresses",
"(",
"$",
"this",
"->",
"cc",
")",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"bcc",
")",
"&&",
"$",
"this",
"->",
"options",
"->",
"stripBccHeader",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"\"Bcc\"",
",",
"ezcMailTools",
"::",
"composeEmailAddresses",
"(",
"$",
"this",
"->",
"bcc",
")",
")",
";",
"}",
"$",
"this",
"->",
"setHeader",
"(",
"'Subject'",
",",
"$",
"this",
"->",
"subject",
",",
"$",
"this",
"->",
"subjectCharset",
")",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'MIME-Version'",
",",
"'1.0'",
")",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'User-Agent'",
",",
"'eZ Components'",
")",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'Date'",
",",
"date",
"(",
"'r'",
")",
")",
";",
"$",
"idhost",
"=",
"$",
"this",
"->",
"from",
"!=",
"null",
"&&",
"$",
"this",
"->",
"from",
"->",
"email",
"!=",
"''",
"?",
"$",
"this",
"->",
"from",
"->",
"email",
":",
"'localhost'",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"messageId",
")",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Message-Id'",
",",
"'<'",
".",
"ezcMailTools",
"::",
"generateMessageId",
"(",
"$",
"idhost",
")",
".",
"'>'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Message-Id'",
",",
"$",
"this",
"->",
"messageID",
")",
";",
"}",
"// if we have a body part, include the headers of the body",
"if",
"(",
"is_subclass_of",
"(",
"$",
"this",
"->",
"body",
",",
"\"ezcMailPart\"",
")",
")",
"{",
"return",
"parent",
"::",
"generateHeaders",
"(",
")",
".",
"$",
"this",
"->",
"body",
"->",
"generateHeaders",
"(",
")",
";",
"}",
"return",
"parent",
"::",
"generateHeaders",
"(",
")",
";",
"}"
] |
Returns the generated headers for the mail.
This method is called automatically when the mail message is built.
You can re-implement this method in subclasses if you wish to set
different mail headers than ezcMail.
@return string
|
[
"Returns",
"the",
"generated",
"headers",
"for",
"the",
"mail",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/mail.php#L342-L384
|
20,465 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/mail.php
|
ezcMail.fetchParts
|
public function fetchParts( $filter = null, $includeDigests = false )
{
$context = new ezcMailPartWalkContext( array( __CLASS__, 'collectPart' ) );
$context->includeDigests = $includeDigests;
$context->filter = $filter;
$context->level = 0;
$this->walkParts( $context, $this );
return $context->getParts();
}
|
php
|
public function fetchParts( $filter = null, $includeDigests = false )
{
$context = new ezcMailPartWalkContext( array( __CLASS__, 'collectPart' ) );
$context->includeDigests = $includeDigests;
$context->filter = $filter;
$context->level = 0;
$this->walkParts( $context, $this );
return $context->getParts();
}
|
[
"public",
"function",
"fetchParts",
"(",
"$",
"filter",
"=",
"null",
",",
"$",
"includeDigests",
"=",
"false",
")",
"{",
"$",
"context",
"=",
"new",
"ezcMailPartWalkContext",
"(",
"array",
"(",
"__CLASS__",
",",
"'collectPart'",
")",
")",
";",
"$",
"context",
"->",
"includeDigests",
"=",
"$",
"includeDigests",
";",
"$",
"context",
"->",
"filter",
"=",
"$",
"filter",
";",
"$",
"context",
"->",
"level",
"=",
"0",
";",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"this",
")",
";",
"return",
"$",
"context",
"->",
"getParts",
"(",
")",
";",
"}"
] |
Returns an array of mail parts from the current mail.
The array returned contains objects of classes:
- ezcMailText
- ezcMailFile
- ezcMailRfc822Digest
If the method is called with $includeDigests as true, then the returned
array will not contain ezcMailRfc822Digest objects, but instead the mail
parts inside the digests.
The parameter $filter can be used to restrict the returned mail parts,
eg. $filter = array( 'ezcMailFile' ) to return only file mail parts.
A typical use for this function is to get a list of attachments from a mail.
Example:
<code>
// $mail is an ezcMail object
$parts = $mail->fetchParts();
// after the above line is executed, $parts will contain an array of mail parts objects,
// for example one ezcMailText object ($parts[0]) and two ezcMailRfc822Digest objects ($parts[1] and $parts[2]).
// the ezcMailText object will be used to render the mail text, and the
// other two objects will be displayed as links ("view attachment")
// when user clicks on one of the two attachments, the parts of that attachment
// must be retrieved in order to render the attached digest:
$subparts = $parts[1]->mail->fetchParts();
// after the above line is executed, $subparts will contain an array of mail parts objects,
// for example one ezcMailText object and one ezcMailFile object
</code>
@param array(string) $filter
@param bool $includeDigests
@return array(ezcMailPart)
|
[
"Returns",
"an",
"array",
"of",
"mail",
"parts",
"from",
"the",
"current",
"mail",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/mail.php#L420-L428
|
20,466 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/mail.php
|
ezcMail.walkParts
|
public function walkParts( ezcMailPartWalkContext $context, ezcMailPart $mail )
{
$className = get_class( $mail );
$context->level++;
switch ( $className )
{
case 'ezcMail':
case 'ezcMailComposer':
if ( $mail->body !== null )
{
$this->walkParts( $context, $mail->body );
}
break;
case 'ezcMailMultipartMixed':
case 'ezcMailMultipartAlternative':
case 'ezcMailMultipartDigest':
case 'ezcMailMultipartReport':
foreach ( $mail->getParts() as $part )
{
$this->walkParts( $context, $part );
}
break;
case 'ezcMailMultipartRelated':
$this->walkParts( $context, $mail->getMainPart() );
foreach ( $mail->getRelatedParts() as $part )
{
$this->walkParts( $context, $part );
}
break;
case 'ezcMailRfc822Digest':
if ( $context->includeDigests )
{
$this->walkParts( $context, $mail->mail );
}
elseif ( empty( $context->filter ) || in_array( $className, $context->filter ) )
{
call_user_func( $context->callbackFunction, $context, $mail );
}
break;
case 'ezcMailText':
case 'ezcMailFile':
case 'ezcMailDeliveryStatus':
if ( empty( $context->filter ) || in_array( $className, $context->filter ) )
{
call_user_func( $context->callbackFunction, $context, $mail );
}
break;
default:
// for cases where a custom mail class has been specified with $parser->options->mailClass
if ( in_array( 'ezcMail', class_parents( $className ) ) )
{
if ( $mail->body !== null )
{
$this->walkParts( $context, $mail->body );
}
}
// for cases where a custom file class has been specified with $parser->options->fileClass
if ( in_array( 'ezcMailFile', class_parents( $className ) ) )
{
if ( empty( $context->filter ) || in_array( $className, $context->filter ) )
{
call_user_func( $context->callbackFunction, $context, $mail );
}
}
}
$context->level--;
}
|
php
|
public function walkParts( ezcMailPartWalkContext $context, ezcMailPart $mail )
{
$className = get_class( $mail );
$context->level++;
switch ( $className )
{
case 'ezcMail':
case 'ezcMailComposer':
if ( $mail->body !== null )
{
$this->walkParts( $context, $mail->body );
}
break;
case 'ezcMailMultipartMixed':
case 'ezcMailMultipartAlternative':
case 'ezcMailMultipartDigest':
case 'ezcMailMultipartReport':
foreach ( $mail->getParts() as $part )
{
$this->walkParts( $context, $part );
}
break;
case 'ezcMailMultipartRelated':
$this->walkParts( $context, $mail->getMainPart() );
foreach ( $mail->getRelatedParts() as $part )
{
$this->walkParts( $context, $part );
}
break;
case 'ezcMailRfc822Digest':
if ( $context->includeDigests )
{
$this->walkParts( $context, $mail->mail );
}
elseif ( empty( $context->filter ) || in_array( $className, $context->filter ) )
{
call_user_func( $context->callbackFunction, $context, $mail );
}
break;
case 'ezcMailText':
case 'ezcMailFile':
case 'ezcMailDeliveryStatus':
if ( empty( $context->filter ) || in_array( $className, $context->filter ) )
{
call_user_func( $context->callbackFunction, $context, $mail );
}
break;
default:
// for cases where a custom mail class has been specified with $parser->options->mailClass
if ( in_array( 'ezcMail', class_parents( $className ) ) )
{
if ( $mail->body !== null )
{
$this->walkParts( $context, $mail->body );
}
}
// for cases where a custom file class has been specified with $parser->options->fileClass
if ( in_array( 'ezcMailFile', class_parents( $className ) ) )
{
if ( empty( $context->filter ) || in_array( $className, $context->filter ) )
{
call_user_func( $context->callbackFunction, $context, $mail );
}
}
}
$context->level--;
}
|
[
"public",
"function",
"walkParts",
"(",
"ezcMailPartWalkContext",
"$",
"context",
",",
"ezcMailPart",
"$",
"mail",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"mail",
")",
";",
"$",
"context",
"->",
"level",
"++",
";",
"switch",
"(",
"$",
"className",
")",
"{",
"case",
"'ezcMail'",
":",
"case",
"'ezcMailComposer'",
":",
"if",
"(",
"$",
"mail",
"->",
"body",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"mail",
"->",
"body",
")",
";",
"}",
"break",
";",
"case",
"'ezcMailMultipartMixed'",
":",
"case",
"'ezcMailMultipartAlternative'",
":",
"case",
"'ezcMailMultipartDigest'",
":",
"case",
"'ezcMailMultipartReport'",
":",
"foreach",
"(",
"$",
"mail",
"->",
"getParts",
"(",
")",
"as",
"$",
"part",
")",
"{",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"part",
")",
";",
"}",
"break",
";",
"case",
"'ezcMailMultipartRelated'",
":",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"mail",
"->",
"getMainPart",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"mail",
"->",
"getRelatedParts",
"(",
")",
"as",
"$",
"part",
")",
"{",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"part",
")",
";",
"}",
"break",
";",
"case",
"'ezcMailRfc822Digest'",
":",
"if",
"(",
"$",
"context",
"->",
"includeDigests",
")",
"{",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"mail",
"->",
"mail",
")",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"context",
"->",
"filter",
")",
"||",
"in_array",
"(",
"$",
"className",
",",
"$",
"context",
"->",
"filter",
")",
")",
"{",
"call_user_func",
"(",
"$",
"context",
"->",
"callbackFunction",
",",
"$",
"context",
",",
"$",
"mail",
")",
";",
"}",
"break",
";",
"case",
"'ezcMailText'",
":",
"case",
"'ezcMailFile'",
":",
"case",
"'ezcMailDeliveryStatus'",
":",
"if",
"(",
"empty",
"(",
"$",
"context",
"->",
"filter",
")",
"||",
"in_array",
"(",
"$",
"className",
",",
"$",
"context",
"->",
"filter",
")",
")",
"{",
"call_user_func",
"(",
"$",
"context",
"->",
"callbackFunction",
",",
"$",
"context",
",",
"$",
"mail",
")",
";",
"}",
"break",
";",
"default",
":",
"// for cases where a custom mail class has been specified with $parser->options->mailClass",
"if",
"(",
"in_array",
"(",
"'ezcMail'",
",",
"class_parents",
"(",
"$",
"className",
")",
")",
")",
"{",
"if",
"(",
"$",
"mail",
"->",
"body",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"walkParts",
"(",
"$",
"context",
",",
"$",
"mail",
"->",
"body",
")",
";",
"}",
"}",
"// for cases where a custom file class has been specified with $parser->options->fileClass",
"if",
"(",
"in_array",
"(",
"'ezcMailFile'",
",",
"class_parents",
"(",
"$",
"className",
")",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"context",
"->",
"filter",
")",
"||",
"in_array",
"(",
"$",
"className",
",",
"$",
"context",
"->",
"filter",
")",
")",
"{",
"call_user_func",
"(",
"$",
"context",
"->",
"callbackFunction",
",",
"$",
"context",
",",
"$",
"mail",
")",
";",
"}",
"}",
"}",
"$",
"context",
"->",
"level",
"--",
";",
"}"
] |
Walks recursively through the mail parts in the specified mail object.
$context is an object of class ezcMailPartWalkContext, which must contain
a valid callback function name to be applied to all mail parts. You can use
the collectPart() method, or create your own callback function which can
for example save the mail parts to disk or to a database.
For the properties you can set to the walk context see: {@link ezcMailPartWalkContext}
Example:
<code>
class App
{
public static function saveMailPart( $context, $mailPart )
{
// code to save the $mailPart object to disk
}
}
// use the saveMailPart() function as a callback in walkParts()
// where $mail is an ezcMail object.
$context = new ezcMailPartWalkContext( array( 'App', 'saveMailPart' ) );
$context->includeDigests = true; // if you want to go through the digests in the mail
$mail->walkParts( $context, $mail );
</code>
@param ezcMailPartWalkContext $context
@param ezcMailPart $mail
|
[
"Walks",
"recursively",
"through",
"the",
"mail",
"parts",
"in",
"the",
"specified",
"mail",
"object",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/mail.php#L460-L532
|
20,467 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_parser.php
|
ezcMailMultipartParser.parseBody
|
public function parseBody( $origLine )
{
if ( $this->parserState == self::PARSE_STATE_POST_LAST )
{
return;
}
$line = rtrim( $origLine, "\r\n" );
// check if we hit any of the boundaries
$newPart = false;
$endOfMultipart = false;
if ( strlen( $line ) > 0 && $line[0] == "-" )
{
if ( strcmp( trim( $line ), '--' . $this->boundary ) === 0 )
{
$newPart = true;
}
else if ( strcmp( trim( $line ), '--' . $this->boundary . '--' ) === 0 )
{
$endOfMultipart = true;
}
}
// actions to do when starting or finishing a part
if ( $newPart || $endOfMultipart )
{
if ( $this->parserState != self::PARSE_STATE_BODY )
{
// something is b0rked, we got a new separator before getting a body
// we'll skip this part and continue to the next
$this->currentPartParser = null;
$this->currentPartHeaders = new ezcMailHeadersHolder();
$this->parserState = $newPart ? self::PARSE_STATE_HEADERS : self::PARSE_STATE_POST_LAST;
}
else
{
// complete the work on the current part if there was any
if ( $this->currentPartParser !== null )
{
$part = $this->currentPartParser->finish();
if ( $part !== null ) // parsing failed
{
$this->partDone( $part );
}
}
// prepare for a new part if any
$this->currentPartParser = null;
$this->parserState =self::PARSE_STATE_POST_LAST;
if ( $newPart )
{
$this->parserState = self::PARSE_STATE_HEADERS;
$this->currentPartHeaders = new ezcMailHeadersHolder();
}
}
}
// normal data, pass to headers or current body
else
{
if ( $this->parserState == self::PARSE_STATE_HEADERS && $line == '' )
{
$this->currentPartParser = self::createPartParserForHeaders( $this->currentPartHeaders );
$this->parserState = self::PARSE_STATE_BODY;
}
else if ( $this->parserState == self::PARSE_STATE_HEADERS )
{
$this->parseHeader( $line, $this->currentPartHeaders );
}
else if ( $this->parserState == self::PARSE_STATE_BODY )
{
if ( $this->currentPartParser ) // we may have none if the part type was unknown
{
// send body data to the part
$this->currentPartParser->parseBody( $origLine );
}
}
// we are done parsing the multipart, ignore anything else pushed to us.
}
}
|
php
|
public function parseBody( $origLine )
{
if ( $this->parserState == self::PARSE_STATE_POST_LAST )
{
return;
}
$line = rtrim( $origLine, "\r\n" );
// check if we hit any of the boundaries
$newPart = false;
$endOfMultipart = false;
if ( strlen( $line ) > 0 && $line[0] == "-" )
{
if ( strcmp( trim( $line ), '--' . $this->boundary ) === 0 )
{
$newPart = true;
}
else if ( strcmp( trim( $line ), '--' . $this->boundary . '--' ) === 0 )
{
$endOfMultipart = true;
}
}
// actions to do when starting or finishing a part
if ( $newPart || $endOfMultipart )
{
if ( $this->parserState != self::PARSE_STATE_BODY )
{
// something is b0rked, we got a new separator before getting a body
// we'll skip this part and continue to the next
$this->currentPartParser = null;
$this->currentPartHeaders = new ezcMailHeadersHolder();
$this->parserState = $newPart ? self::PARSE_STATE_HEADERS : self::PARSE_STATE_POST_LAST;
}
else
{
// complete the work on the current part if there was any
if ( $this->currentPartParser !== null )
{
$part = $this->currentPartParser->finish();
if ( $part !== null ) // parsing failed
{
$this->partDone( $part );
}
}
// prepare for a new part if any
$this->currentPartParser = null;
$this->parserState =self::PARSE_STATE_POST_LAST;
if ( $newPart )
{
$this->parserState = self::PARSE_STATE_HEADERS;
$this->currentPartHeaders = new ezcMailHeadersHolder();
}
}
}
// normal data, pass to headers or current body
else
{
if ( $this->parserState == self::PARSE_STATE_HEADERS && $line == '' )
{
$this->currentPartParser = self::createPartParserForHeaders( $this->currentPartHeaders );
$this->parserState = self::PARSE_STATE_BODY;
}
else if ( $this->parserState == self::PARSE_STATE_HEADERS )
{
$this->parseHeader( $line, $this->currentPartHeaders );
}
else if ( $this->parserState == self::PARSE_STATE_BODY )
{
if ( $this->currentPartParser ) // we may have none if the part type was unknown
{
// send body data to the part
$this->currentPartParser->parseBody( $origLine );
}
}
// we are done parsing the multipart, ignore anything else pushed to us.
}
}
|
[
"public",
"function",
"parseBody",
"(",
"$",
"origLine",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parserState",
"==",
"self",
"::",
"PARSE_STATE_POST_LAST",
")",
"{",
"return",
";",
"}",
"$",
"line",
"=",
"rtrim",
"(",
"$",
"origLine",
",",
"\"\\r\\n\"",
")",
";",
"// check if we hit any of the boundaries",
"$",
"newPart",
"=",
"false",
";",
"$",
"endOfMultipart",
"=",
"false",
";",
"if",
"(",
"strlen",
"(",
"$",
"line",
")",
">",
"0",
"&&",
"$",
"line",
"[",
"0",
"]",
"==",
"\"-\"",
")",
"{",
"if",
"(",
"strcmp",
"(",
"trim",
"(",
"$",
"line",
")",
",",
"'--'",
".",
"$",
"this",
"->",
"boundary",
")",
"===",
"0",
")",
"{",
"$",
"newPart",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"strcmp",
"(",
"trim",
"(",
"$",
"line",
")",
",",
"'--'",
".",
"$",
"this",
"->",
"boundary",
".",
"'--'",
")",
"===",
"0",
")",
"{",
"$",
"endOfMultipart",
"=",
"true",
";",
"}",
"}",
"// actions to do when starting or finishing a part",
"if",
"(",
"$",
"newPart",
"||",
"$",
"endOfMultipart",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parserState",
"!=",
"self",
"::",
"PARSE_STATE_BODY",
")",
"{",
"// something is b0rked, we got a new separator before getting a body",
"// we'll skip this part and continue to the next",
"$",
"this",
"->",
"currentPartParser",
"=",
"null",
";",
"$",
"this",
"->",
"currentPartHeaders",
"=",
"new",
"ezcMailHeadersHolder",
"(",
")",
";",
"$",
"this",
"->",
"parserState",
"=",
"$",
"newPart",
"?",
"self",
"::",
"PARSE_STATE_HEADERS",
":",
"self",
"::",
"PARSE_STATE_POST_LAST",
";",
"}",
"else",
"{",
"// complete the work on the current part if there was any",
"if",
"(",
"$",
"this",
"->",
"currentPartParser",
"!==",
"null",
")",
"{",
"$",
"part",
"=",
"$",
"this",
"->",
"currentPartParser",
"->",
"finish",
"(",
")",
";",
"if",
"(",
"$",
"part",
"!==",
"null",
")",
"// parsing failed",
"{",
"$",
"this",
"->",
"partDone",
"(",
"$",
"part",
")",
";",
"}",
"}",
"// prepare for a new part if any",
"$",
"this",
"->",
"currentPartParser",
"=",
"null",
";",
"$",
"this",
"->",
"parserState",
"=",
"self",
"::",
"PARSE_STATE_POST_LAST",
";",
"if",
"(",
"$",
"newPart",
")",
"{",
"$",
"this",
"->",
"parserState",
"=",
"self",
"::",
"PARSE_STATE_HEADERS",
";",
"$",
"this",
"->",
"currentPartHeaders",
"=",
"new",
"ezcMailHeadersHolder",
"(",
")",
";",
"}",
"}",
"}",
"// normal data, pass to headers or current body",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"parserState",
"==",
"self",
"::",
"PARSE_STATE_HEADERS",
"&&",
"$",
"line",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"currentPartParser",
"=",
"self",
"::",
"createPartParserForHeaders",
"(",
"$",
"this",
"->",
"currentPartHeaders",
")",
";",
"$",
"this",
"->",
"parserState",
"=",
"self",
"::",
"PARSE_STATE_BODY",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"parserState",
"==",
"self",
"::",
"PARSE_STATE_HEADERS",
")",
"{",
"$",
"this",
"->",
"parseHeader",
"(",
"$",
"line",
",",
"$",
"this",
"->",
"currentPartHeaders",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"parserState",
"==",
"self",
"::",
"PARSE_STATE_BODY",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentPartParser",
")",
"// we may have none if the part type was unknown",
"{",
"// send body data to the part",
"$",
"this",
"->",
"currentPartParser",
"->",
"parseBody",
"(",
"$",
"origLine",
")",
";",
"}",
"}",
"// we are done parsing the multipart, ignore anything else pushed to us.",
"}",
"}"
] |
Parses a multipart body.
@throws ezcBaseFileNotFoundException
if a neccessary temporary file could not be opened.
@param string $origLine
|
[
"Parses",
"a",
"multipart",
"body",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_parser.php#L106-L185
|
20,468 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_parser.php
|
ezcMailMultipartParser.finish
|
public function finish()
{
if ( $this->parserState != self::PARSE_STATE_POST_LAST )
{
// this should never happen
// let's give the last parser a chance to clean up after himself
if ( $this->currentPartParser !== null )
{
$part = $this->currentPartParser->finish();
$this->partDone( $part );
$this->currentPartParser = null;
}
}
$multipart = $this->finishMultipart();
ezcMailPartParser::parsePartHeaders( $this->headers, $multipart );
$multipart->boundary = $this->boundary;
return $multipart;
}
|
php
|
public function finish()
{
if ( $this->parserState != self::PARSE_STATE_POST_LAST )
{
// this should never happen
// let's give the last parser a chance to clean up after himself
if ( $this->currentPartParser !== null )
{
$part = $this->currentPartParser->finish();
$this->partDone( $part );
$this->currentPartParser = null;
}
}
$multipart = $this->finishMultipart();
ezcMailPartParser::parsePartHeaders( $this->headers, $multipart );
$multipart->boundary = $this->boundary;
return $multipart;
}
|
[
"public",
"function",
"finish",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parserState",
"!=",
"self",
"::",
"PARSE_STATE_POST_LAST",
")",
"{",
"// this should never happen",
"// let's give the last parser a chance to clean up after himself",
"if",
"(",
"$",
"this",
"->",
"currentPartParser",
"!==",
"null",
")",
"{",
"$",
"part",
"=",
"$",
"this",
"->",
"currentPartParser",
"->",
"finish",
"(",
")",
";",
"$",
"this",
"->",
"partDone",
"(",
"$",
"part",
")",
";",
"$",
"this",
"->",
"currentPartParser",
"=",
"null",
";",
"}",
"}",
"$",
"multipart",
"=",
"$",
"this",
"->",
"finishMultipart",
"(",
")",
";",
"ezcMailPartParser",
"::",
"parsePartHeaders",
"(",
"$",
"this",
"->",
"headers",
",",
"$",
"multipart",
")",
";",
"$",
"multipart",
"->",
"boundary",
"=",
"$",
"this",
"->",
"boundary",
";",
"return",
"$",
"multipart",
";",
"}"
] |
Completes the parsing of the multipart and returns the corresponding part.
This method should not be overriden. Use finishMultipart() instead.
@return ezcMailMultipart
|
[
"Completes",
"the",
"parsing",
"of",
"the",
"multipart",
"and",
"returns",
"the",
"corresponding",
"part",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_parser.php#L194-L211
|
20,469 |
antaresproject/notifications
|
src/Contents.php
|
Contents.find
|
public function find(string $operation, string $locale)
{
$model = $this->notifications->first(function ($value) use($operation, $locale) {
return $value->code === $locale && ($value->title === $operation || $value->name === $operation);
});
return $model ? $model->content : false;
}
|
php
|
public function find(string $operation, string $locale)
{
$model = $this->notifications->first(function ($value) use($operation, $locale) {
return $value->code === $locale && ($value->title === $operation || $value->name === $operation);
});
return $model ? $model->content : false;
}
|
[
"public",
"function",
"find",
"(",
"string",
"$",
"operation",
",",
"string",
"$",
"locale",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"notifications",
"->",
"first",
"(",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"$",
"operation",
",",
"$",
"locale",
")",
"{",
"return",
"$",
"value",
"->",
"code",
"===",
"$",
"locale",
"&&",
"(",
"$",
"value",
"->",
"title",
"===",
"$",
"operation",
"||",
"$",
"value",
"->",
"name",
"===",
"$",
"operation",
")",
";",
"}",
")",
";",
"return",
"$",
"model",
"?",
"$",
"model",
"->",
"content",
":",
"false",
";",
"}"
] |
Finds notification content by title and locale.
@param string $operation
@param string $locale
@return bool
|
[
"Finds",
"notification",
"content",
"by",
"title",
"and",
"locale",
"."
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Contents.php#L64-L71
|
20,470 |
sciactive/nymph-server
|
src/Drivers/PostgreSQLDriver.php
|
PostgreSQLDriver.connect
|
public function connect() {
// Check that the PostgreSQL extension is installed.
if (!is_callable('pg_connect')) {
throw new Exceptions\UnableToConnectException(
'PostgreSQL PHP extension is not available. It probably has not '.
'been installed. Please install and configure it in order to use '.
'PostgreSQL.'
);
}
$connectionType = $this->config['PostgreSQL']['connection_type'];
$host = $this->config['PostgreSQL']['host'];
$port = $this->config['PostgreSQL']['port'];
$user = $this->config['PostgreSQL']['user'];
$password = $this->config['PostgreSQL']['password'];
$database = $this->config['PostgreSQL']['database'];
// Connecting, selecting database
if (!$this->connected) {
if ($connectionType === 'host') {
$connectString = 'host=\''.addslashes($host).
'\' port=\''.addslashes($port).
'\' dbname=\''.addslashes($database).
'\' user=\''.addslashes($user).
'\' password=\''.addslashes($password).
'\' connect_timeout=5';
} else {
$connectString = 'dbname=\''.addslashes($database).
'\' user=\''.addslashes($user).
'\' password=\''.addslashes($password).
'\' connect_timeout=5';
}
if ($this->config['PostgreSQL']['allow_persistent']) {
$this->link = pg_connect(
$connectString.
' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\''
);
} else {
$this->link = pg_connect(
$connectString.
' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\'',
PGSQL_CONNECT_FORCE_NEW
);
// Don't think this is necessary, but if put in options, will guarantee
// connection is new. " -c timezone='.round(rand(10001000, 10009999)).'"
}
if ($this->link) {
$this->connected = true;
} else {
$this->connected = false;
if ($host === 'localhost'
&& $user === 'nymph'
&& $password === 'password'
&& $database === 'nymph'
&& $connectionType === 'host') {
throw new Exceptions\NotConfiguredException();
} else {
throw new Exceptions\UnableToConnectException(
'Could not connect: '.
pg_last_error()
);
}
}
}
return $this->connected;
}
|
php
|
public function connect() {
// Check that the PostgreSQL extension is installed.
if (!is_callable('pg_connect')) {
throw new Exceptions\UnableToConnectException(
'PostgreSQL PHP extension is not available. It probably has not '.
'been installed. Please install and configure it in order to use '.
'PostgreSQL.'
);
}
$connectionType = $this->config['PostgreSQL']['connection_type'];
$host = $this->config['PostgreSQL']['host'];
$port = $this->config['PostgreSQL']['port'];
$user = $this->config['PostgreSQL']['user'];
$password = $this->config['PostgreSQL']['password'];
$database = $this->config['PostgreSQL']['database'];
// Connecting, selecting database
if (!$this->connected) {
if ($connectionType === 'host') {
$connectString = 'host=\''.addslashes($host).
'\' port=\''.addslashes($port).
'\' dbname=\''.addslashes($database).
'\' user=\''.addslashes($user).
'\' password=\''.addslashes($password).
'\' connect_timeout=5';
} else {
$connectString = 'dbname=\''.addslashes($database).
'\' user=\''.addslashes($user).
'\' password=\''.addslashes($password).
'\' connect_timeout=5';
}
if ($this->config['PostgreSQL']['allow_persistent']) {
$this->link = pg_connect(
$connectString.
' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\''
);
} else {
$this->link = pg_connect(
$connectString.
' options=\'-c enable_hashjoin=off -c enable_mergejoin=off\'',
PGSQL_CONNECT_FORCE_NEW
);
// Don't think this is necessary, but if put in options, will guarantee
// connection is new. " -c timezone='.round(rand(10001000, 10009999)).'"
}
if ($this->link) {
$this->connected = true;
} else {
$this->connected = false;
if ($host === 'localhost'
&& $user === 'nymph'
&& $password === 'password'
&& $database === 'nymph'
&& $connectionType === 'host') {
throw new Exceptions\NotConfiguredException();
} else {
throw new Exceptions\UnableToConnectException(
'Could not connect: '.
pg_last_error()
);
}
}
}
return $this->connected;
}
|
[
"public",
"function",
"connect",
"(",
")",
"{",
"// Check that the PostgreSQL extension is installed.",
"if",
"(",
"!",
"is_callable",
"(",
"'pg_connect'",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"UnableToConnectException",
"(",
"'PostgreSQL PHP extension is not available. It probably has not '",
".",
"'been installed. Please install and configure it in order to use '",
".",
"'PostgreSQL.'",
")",
";",
"}",
"$",
"connectionType",
"=",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'connection_type'",
"]",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'host'",
"]",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'port'",
"]",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'user'",
"]",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'password'",
"]",
";",
"$",
"database",
"=",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'database'",
"]",
";",
"// Connecting, selecting database",
"if",
"(",
"!",
"$",
"this",
"->",
"connected",
")",
"{",
"if",
"(",
"$",
"connectionType",
"===",
"'host'",
")",
"{",
"$",
"connectString",
"=",
"'host=\\''",
".",
"addslashes",
"(",
"$",
"host",
")",
".",
"'\\' port=\\''",
".",
"addslashes",
"(",
"$",
"port",
")",
".",
"'\\' dbname=\\''",
".",
"addslashes",
"(",
"$",
"database",
")",
".",
"'\\' user=\\''",
".",
"addslashes",
"(",
"$",
"user",
")",
".",
"'\\' password=\\''",
".",
"addslashes",
"(",
"$",
"password",
")",
".",
"'\\' connect_timeout=5'",
";",
"}",
"else",
"{",
"$",
"connectString",
"=",
"'dbname=\\''",
".",
"addslashes",
"(",
"$",
"database",
")",
".",
"'\\' user=\\''",
".",
"addslashes",
"(",
"$",
"user",
")",
".",
"'\\' password=\\''",
".",
"addslashes",
"(",
"$",
"password",
")",
".",
"'\\' connect_timeout=5'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'PostgreSQL'",
"]",
"[",
"'allow_persistent'",
"]",
")",
"{",
"$",
"this",
"->",
"link",
"=",
"pg_connect",
"(",
"$",
"connectString",
".",
"' options=\\'-c enable_hashjoin=off -c enable_mergejoin=off\\''",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"link",
"=",
"pg_connect",
"(",
"$",
"connectString",
".",
"' options=\\'-c enable_hashjoin=off -c enable_mergejoin=off\\''",
",",
"PGSQL_CONNECT_FORCE_NEW",
")",
";",
"// Don't think this is necessary, but if put in options, will guarantee",
"// connection is new. \" -c timezone='.round(rand(10001000, 10009999)).'\"",
"}",
"if",
"(",
"$",
"this",
"->",
"link",
")",
"{",
"$",
"this",
"->",
"connected",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"connected",
"=",
"false",
";",
"if",
"(",
"$",
"host",
"===",
"'localhost'",
"&&",
"$",
"user",
"===",
"'nymph'",
"&&",
"$",
"password",
"===",
"'password'",
"&&",
"$",
"database",
"===",
"'nymph'",
"&&",
"$",
"connectionType",
"===",
"'host'",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"NotConfiguredException",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exceptions",
"\\",
"UnableToConnectException",
"(",
"'Could not connect: '",
".",
"pg_last_error",
"(",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"connected",
";",
"}"
] |
Connect to the PostgreSQL database.
@return bool Whether this instance is connected to a PostgreSQL database
after the method has run.
|
[
"Connect",
"to",
"the",
"PostgreSQL",
"database",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/PostgreSQLDriver.php#L54-L117
|
20,471 |
sciactive/nymph-server
|
src/Drivers/PostgreSQLDriver.php
|
PostgreSQLDriver.disconnect
|
public function disconnect() {
if ($this->connected) {
if (is_resource($this->link)) {
pg_close($this->link);
}
$this->connected = false;
}
return $this->connected;
}
|
php
|
public function disconnect() {
if ($this->connected) {
if (is_resource($this->link)) {
pg_close($this->link);
}
$this->connected = false;
}
return $this->connected;
}
|
[
"public",
"function",
"disconnect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connected",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"link",
")",
")",
"{",
"pg_close",
"(",
"$",
"this",
"->",
"link",
")",
";",
"}",
"$",
"this",
"->",
"connected",
"=",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"connected",
";",
"}"
] |
Disconnect from the PostgreSQL database.
@return bool Whether this instance is connected to a PostgreSQL database
after the method has run.
|
[
"Disconnect",
"from",
"the",
"PostgreSQL",
"database",
"."
] |
3c18dbf45c2750d07c798e14534dba87387beeba
|
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/PostgreSQLDriver.php#L125-L133
|
20,472 |
mikebarlow/html-helper
|
src/Services/CometPHP/Assets.php
|
Assets.getAsset
|
protected function getAsset($assetData)
{
try {
$Comet = \CometPHP\Comet::getInstance();
} catch (\CometPHP\Exceptions\CometNotBooted $e) {
return null;
}
if (! is_array($assetData)) {
$assetData = [$assetData];
}
$asset = $Comet['template']->getFunction('asset')->call(
$this->template,
$assetData
);
return $asset;
}
|
php
|
protected function getAsset($assetData)
{
try {
$Comet = \CometPHP\Comet::getInstance();
} catch (\CometPHP\Exceptions\CometNotBooted $e) {
return null;
}
if (! is_array($assetData)) {
$assetData = [$assetData];
}
$asset = $Comet['template']->getFunction('asset')->call(
$this->template,
$assetData
);
return $asset;
}
|
[
"protected",
"function",
"getAsset",
"(",
"$",
"assetData",
")",
"{",
"try",
"{",
"$",
"Comet",
"=",
"\\",
"CometPHP",
"\\",
"Comet",
"::",
"getInstance",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"CometPHP",
"\\",
"Exceptions",
"\\",
"CometNotBooted",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"assetData",
")",
")",
"{",
"$",
"assetData",
"=",
"[",
"$",
"assetData",
"]",
";",
"}",
"$",
"asset",
"=",
"$",
"Comet",
"[",
"'template'",
"]",
"->",
"getFunction",
"(",
"'asset'",
")",
"->",
"call",
"(",
"$",
"this",
"->",
"template",
",",
"$",
"assetData",
")",
";",
"return",
"$",
"asset",
";",
"}"
] |
base function to return assets
@param mixed asset path data received from the image method
@return string url to pass to img or css
|
[
"base",
"function",
"to",
"return",
"assets"
] |
d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65
|
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Services/CometPHP/Assets.php#L13-L31
|
20,473 |
alevilar/ristorantino-vendor
|
Product/Model/Categoria.php
|
Categoria.array_listado
|
function array_listado($categoria_id = 1){
$array_categoria = array();
$array_final = array();
$this->recursive = 1;
$this->id = $categoria_id;
// $this->contain(array(
// 'Producto',
// 'Sabor',
// ));
$array_categoria = $this->read();
if (empty($array_categoria)) {
return array();
}
$array_final = $array_categoria['Categoria'];
$array_final['Producto'] = $array_categoria['Producto'];
$array_final['Sabor'] = $array_categoria['Sabor'];
//agarro los herederos del ROOT
$resultado = $this->children($categoria_id,1);
foreach ($resultado as $r):
$hijos = $this->array_listado($r['Categoria']['id']);
if (count($hijos) > 0) {
$array_final['Hijos'][] = $hijos;
}
endforeach;
if ($array_final == false) {
$array_final = array();
}
return $array_final;
}
|
php
|
function array_listado($categoria_id = 1){
$array_categoria = array();
$array_final = array();
$this->recursive = 1;
$this->id = $categoria_id;
// $this->contain(array(
// 'Producto',
// 'Sabor',
// ));
$array_categoria = $this->read();
if (empty($array_categoria)) {
return array();
}
$array_final = $array_categoria['Categoria'];
$array_final['Producto'] = $array_categoria['Producto'];
$array_final['Sabor'] = $array_categoria['Sabor'];
//agarro los herederos del ROOT
$resultado = $this->children($categoria_id,1);
foreach ($resultado as $r):
$hijos = $this->array_listado($r['Categoria']['id']);
if (count($hijos) > 0) {
$array_final['Hijos'][] = $hijos;
}
endforeach;
if ($array_final == false) {
$array_final = array();
}
return $array_final;
}
|
[
"function",
"array_listado",
"(",
"$",
"categoria_id",
"=",
"1",
")",
"{",
"$",
"array_categoria",
"=",
"array",
"(",
")",
";",
"$",
"array_final",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"recursive",
"=",
"1",
";",
"$",
"this",
"->",
"id",
"=",
"$",
"categoria_id",
";",
"// $this->contain(array(",
"// 'Producto', ",
"// 'Sabor',",
"// ));",
"$",
"array_categoria",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"array_categoria",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"array_final",
"=",
"$",
"array_categoria",
"[",
"'Categoria'",
"]",
";",
"$",
"array_final",
"[",
"'Producto'",
"]",
"=",
"$",
"array_categoria",
"[",
"'Producto'",
"]",
";",
"$",
"array_final",
"[",
"'Sabor'",
"]",
"=",
"$",
"array_categoria",
"[",
"'Sabor'",
"]",
";",
"//agarro los herederos del ROOT",
"$",
"resultado",
"=",
"$",
"this",
"->",
"children",
"(",
"$",
"categoria_id",
",",
"1",
")",
";",
"foreach",
"(",
"$",
"resultado",
"as",
"$",
"r",
")",
":",
"$",
"hijos",
"=",
"$",
"this",
"->",
"array_listado",
"(",
"$",
"r",
"[",
"'Categoria'",
"]",
"[",
"'id'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"hijos",
")",
">",
"0",
")",
"{",
"$",
"array_final",
"[",
"'Hijos'",
"]",
"[",
"]",
"=",
"$",
"hijos",
";",
"}",
"endforeach",
";",
"if",
"(",
"$",
"array_final",
"==",
"false",
")",
"{",
"$",
"array_final",
"=",
"array",
"(",
")",
";",
"}",
"return",
"$",
"array_final",
";",
"}"
] |
Me devuelve un array lindo con sub arrays para cada subarbol
@param $categoria_id de donde yovoy a leer los hijos
@return unknown_type
|
[
"Me",
"devuelve",
"un",
"array",
"lindo",
"con",
"sub",
"arrays",
"para",
"cada",
"subarbol"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Product/Model/Categoria.php#L59-L90
|
20,474 |
rhosocial/yii2-user
|
web/admin/controllers/UserController.php
|
UserController.initMessages
|
protected function initMessages()
{
if (!is_string($this->registerSuccessMessage)) {
$this->registerSuccessMessage = Yii::t('user' ,'User Registered.');
}
if (!is_string($this->registerFailedMessage)) {
$this->registerFailedMessage = Yii::t('user', 'Register Failed.');
}
if (!is_string($this->deregisterSuccessMessage)) {
$this->deregisterSuccessMessage = Yii::t('user', 'User Deregistered.');
}
if (!is_string($this->deregisterFailedMessage)) {
$this->deregisterFailedMessage = Yii::t('user', 'Failed to Deregister User.');
}
if (!is_string($this->updateSuccessMessage)) {
$this->updateSuccessMessage = Yii::t('user', 'Updated.');
}
if (!is_string($this->updateFailedMessage)) {
$this->updateFailedMessage = Yii::t('user', 'Failed to Update.');
}
}
|
php
|
protected function initMessages()
{
if (!is_string($this->registerSuccessMessage)) {
$this->registerSuccessMessage = Yii::t('user' ,'User Registered.');
}
if (!is_string($this->registerFailedMessage)) {
$this->registerFailedMessage = Yii::t('user', 'Register Failed.');
}
if (!is_string($this->deregisterSuccessMessage)) {
$this->deregisterSuccessMessage = Yii::t('user', 'User Deregistered.');
}
if (!is_string($this->deregisterFailedMessage)) {
$this->deregisterFailedMessage = Yii::t('user', 'Failed to Deregister User.');
}
if (!is_string($this->updateSuccessMessage)) {
$this->updateSuccessMessage = Yii::t('user', 'Updated.');
}
if (!is_string($this->updateFailedMessage)) {
$this->updateFailedMessage = Yii::t('user', 'Failed to Update.');
}
}
|
[
"protected",
"function",
"initMessages",
"(",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"registerSuccessMessage",
")",
")",
"{",
"$",
"this",
"->",
"registerSuccessMessage",
"=",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'User Registered.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"registerFailedMessage",
")",
")",
"{",
"$",
"this",
"->",
"registerFailedMessage",
"=",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'Register Failed.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"deregisterSuccessMessage",
")",
")",
"{",
"$",
"this",
"->",
"deregisterSuccessMessage",
"=",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'User Deregistered.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"deregisterFailedMessage",
")",
")",
"{",
"$",
"this",
"->",
"deregisterFailedMessage",
"=",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'Failed to Deregister User.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"updateSuccessMessage",
")",
")",
"{",
"$",
"this",
"->",
"updateSuccessMessage",
"=",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'Updated.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"this",
"->",
"updateFailedMessage",
")",
")",
"{",
"$",
"this",
"->",
"updateFailedMessage",
"=",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'Failed to Update.'",
")",
";",
"}",
"}"
] |
Initialize messages.
|
[
"Initialize",
"messages",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/web/admin/controllers/UserController.php#L58-L78
|
20,475 |
rhosocial/yii2-user
|
web/admin/controllers/UserController.php
|
UserController.actionDeregister
|
public function actionDeregister($id)
{
$id = (int)$id;
if (Yii::$app->user->identity->getID() == $id) {
throw new ForbiddenHttpException(Yii::t('user', 'You cannot deregister yourself.'));
}
$user = $this->getUser($id);
try {
$result = $user->deregister();
if ($result instanceof \Exception) {
throw $result;
}
} catch (\Exception $ex) {
throw new ServerErrorHttpException($ex->getMessage());
}
if ($result !== true) {
throw new ServerErrorHttpException(Yii::t('user', 'Failed to deregister user.'));
}
Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, '(' . $user->getID() . ') ' . $this->deregisterSuccessMessage);
return $this->redirect(['index']);
}
|
php
|
public function actionDeregister($id)
{
$id = (int)$id;
if (Yii::$app->user->identity->getID() == $id) {
throw new ForbiddenHttpException(Yii::t('user', 'You cannot deregister yourself.'));
}
$user = $this->getUser($id);
try {
$result = $user->deregister();
if ($result instanceof \Exception) {
throw $result;
}
} catch (\Exception $ex) {
throw new ServerErrorHttpException($ex->getMessage());
}
if ($result !== true) {
throw new ServerErrorHttpException(Yii::t('user', 'Failed to deregister user.'));
}
Yii::$app->session->setFlash(Module::SESSION_KEY_RESULT, Module::RESULT_SUCCESS);
Yii::$app->session->setFlash(Module::SESSION_KEY_MESSAGE, '(' . $user->getID() . ') ' . $this->deregisterSuccessMessage);
return $this->redirect(['index']);
}
|
[
"public",
"function",
"actionDeregister",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
"->",
"getID",
"(",
")",
"==",
"$",
"id",
")",
"{",
"throw",
"new",
"ForbiddenHttpException",
"(",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'You cannot deregister yourself.'",
")",
")",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"id",
")",
";",
"try",
"{",
"$",
"result",
"=",
"$",
"user",
"->",
"deregister",
"(",
")",
";",
"if",
"(",
"$",
"result",
"instanceof",
"\\",
"Exception",
")",
"{",
"throw",
"$",
"result",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"ServerErrorHttpException",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"result",
"!==",
"true",
")",
"{",
"throw",
"new",
"ServerErrorHttpException",
"(",
"Yii",
"::",
"t",
"(",
"'user'",
",",
"'Failed to deregister user.'",
")",
")",
";",
"}",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"Module",
"::",
"SESSION_KEY_RESULT",
",",
"Module",
"::",
"RESULT_SUCCESS",
")",
";",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"setFlash",
"(",
"Module",
"::",
"SESSION_KEY_MESSAGE",
",",
"'('",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"') '",
".",
"$",
"this",
"->",
"deregisterSuccessMessage",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
"]",
")",
";",
"}"
] |
Deregister User.
@param string $id User ID.
@return string
@throws ServerErrorHttpException
@throws ForbiddenHttpException
|
[
"Deregister",
"User",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/web/admin/controllers/UserController.php#L216-L237
|
20,476 |
gregoryv/php-logger
|
src/ConsoleWriter.php
|
ConsoleWriter.swrite
|
public function swrite($severity, $message='')
{
if($severity <= LOG_ERR) {
fwrite(STDERR, $message . "\n");
} else {
fwrite(STDOUT, $message . "\n");
}
}
|
php
|
public function swrite($severity, $message='')
{
if($severity <= LOG_ERR) {
fwrite(STDERR, $message . "\n");
} else {
fwrite(STDOUT, $message . "\n");
}
}
|
[
"public",
"function",
"swrite",
"(",
"$",
"severity",
",",
"$",
"message",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"severity",
"<=",
"LOG_ERR",
")",
"{",
"fwrite",
"(",
"STDERR",
",",
"$",
"message",
".",
"\"\\n\"",
")",
";",
"}",
"else",
"{",
"fwrite",
"(",
"STDOUT",
",",
"$",
"message",
".",
"\"\\n\"",
")",
";",
"}",
"}"
] |
If severity is equal or lower than LOG_ERR then the message is written
to STDERR, otherwise STDOUT is used.
|
[
"If",
"severity",
"is",
"equal",
"or",
"lower",
"than",
"LOG_ERR",
"then",
"the",
"message",
"is",
"written",
"to",
"STDERR",
"otherwise",
"STDOUT",
"is",
"used",
"."
] |
0f8ffc360a0233531a9775359929af8876997862
|
https://github.com/gregoryv/php-logger/blob/0f8ffc360a0233531a9775359929af8876997862/src/ConsoleWriter.php#L17-L24
|
20,477 |
mothership-ec/composer
|
src/Composer/Package/Version/VersionSelector.php
|
VersionSelector.findBestCandidate
|
public function findBestCandidate($packageName, $targetPackageVersion = null)
{
$constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
$candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);
if (!$candidates) {
return false;
}
// select highest version if we have many
$package = reset($candidates);
foreach ($candidates as $candidate) {
if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
$package = $candidate;
}
}
return $package;
}
|
php
|
public function findBestCandidate($packageName, $targetPackageVersion = null)
{
$constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
$candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);
if (!$candidates) {
return false;
}
// select highest version if we have many
$package = reset($candidates);
foreach ($candidates as $candidate) {
if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
$package = $candidate;
}
}
return $package;
}
|
[
"public",
"function",
"findBestCandidate",
"(",
"$",
"packageName",
",",
"$",
"targetPackageVersion",
"=",
"null",
")",
"{",
"$",
"constraint",
"=",
"$",
"targetPackageVersion",
"?",
"$",
"this",
"->",
"getParser",
"(",
")",
"->",
"parseConstraints",
"(",
"$",
"targetPackageVersion",
")",
":",
"null",
";",
"$",
"candidates",
"=",
"$",
"this",
"->",
"pool",
"->",
"whatProvides",
"(",
"strtolower",
"(",
"$",
"packageName",
")",
",",
"$",
"constraint",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"candidates",
")",
"{",
"return",
"false",
";",
"}",
"// select highest version if we have many",
"$",
"package",
"=",
"reset",
"(",
"$",
"candidates",
")",
";",
"foreach",
"(",
"$",
"candidates",
"as",
"$",
"candidate",
")",
"{",
"if",
"(",
"version_compare",
"(",
"$",
"package",
"->",
"getVersion",
"(",
")",
",",
"$",
"candidate",
"->",
"getVersion",
"(",
")",
",",
"'<'",
")",
")",
"{",
"$",
"package",
"=",
"$",
"candidate",
";",
"}",
"}",
"return",
"$",
"package",
";",
"}"
] |
Given a package name and optional version, returns the latest PackageInterface
that matches.
@param string $packageName
@param string $targetPackageVersion
@return PackageInterface|bool
|
[
"Given",
"a",
"package",
"name",
"and",
"optional",
"version",
"returns",
"the",
"latest",
"PackageInterface",
"that",
"matches",
"."
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Package/Version/VersionSelector.php#L45-L63
|
20,478 |
j-d/draggy
|
src/Draggy/Autocode/Project.php
|
Project.getActualAttributeName
|
public function getActualAttributeName(Entity $entity, $name, $hint = '', $force = false)
{
if ($entity->hasAttributeByName($name) || $force) {
if (!$entity->hasAttributeByName($name . $hint)) {
return [$name, $hint];
}
$append = 1;
while ($entity->hasAttributeByName($name . $append . $hint)) {
$append++;
}
return [$name . $append, $hint];
}
return [$name, ''];
}
|
php
|
public function getActualAttributeName(Entity $entity, $name, $hint = '', $force = false)
{
if ($entity->hasAttributeByName($name) || $force) {
if (!$entity->hasAttributeByName($name . $hint)) {
return [$name, $hint];
}
$append = 1;
while ($entity->hasAttributeByName($name . $append . $hint)) {
$append++;
}
return [$name . $append, $hint];
}
return [$name, ''];
}
|
[
"public",
"function",
"getActualAttributeName",
"(",
"Entity",
"$",
"entity",
",",
"$",
"name",
",",
"$",
"hint",
"=",
"''",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"hasAttributeByName",
"(",
"$",
"name",
")",
"||",
"$",
"force",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
"->",
"hasAttributeByName",
"(",
"$",
"name",
".",
"$",
"hint",
")",
")",
"{",
"return",
"[",
"$",
"name",
",",
"$",
"hint",
"]",
";",
"}",
"$",
"append",
"=",
"1",
";",
"while",
"(",
"$",
"entity",
"->",
"hasAttributeByName",
"(",
"$",
"name",
".",
"$",
"append",
".",
"$",
"hint",
")",
")",
"{",
"$",
"append",
"++",
";",
"}",
"return",
"[",
"$",
"name",
".",
"$",
"append",
",",
"$",
"hint",
"]",
";",
"}",
"return",
"[",
"$",
"name",
",",
"''",
"]",
";",
"}"
] |
Sometimes the automatic name cannot be used because the entity already has an attribute with that name or because is linked many times.
This method gives an actual final name that will be unique.
@param Entity $entity
@param string $name
@param string $hint
@param boolean $force If it should force the use of the hint
@return array
|
[
"Sometimes",
"the",
"automatic",
"name",
"cannot",
"be",
"used",
"because",
"the",
"entity",
"already",
"has",
"an",
"attribute",
"with",
"that",
"name",
"or",
"because",
"is",
"linked",
"many",
"times",
".",
"This",
"method",
"gives",
"an",
"actual",
"final",
"name",
"that",
"will",
"be",
"unique",
"."
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Project.php#L1171-L1188
|
20,479 |
j-d/draggy
|
src/Draggy/Autocode/Project.php
|
Project.getModelFiles
|
public function getModelFiles($path)
{
$fileCollection = new FileCollection();
$namespacePath = str_replace('\\', '/', $path . $this->getNamespace() . '/');
$targetPath = $namespacePath;
foreach ($this->getEntities() as $entity) {
if ($entity->getRenderizable()) {
if ($this->getLanguage() === 'php') {
if ($entity->getNamespace() !== '') {
$targetPath = $path . str_replace('\\', '/', $entity->getNamespace()) . '/';
}
} elseif ($this->getLanguage() === 'java') {
if ($entity->getModule() !== '') {
$targetPath = $path . '/' . $this->getAutocodeConfiguration('package') . '/' . str_replace('.', '/', $entity->getModule()) . '/';
}
}
foreach ($this->getAutocodeEntityTemplates() as $template) {
$fileCollection->add($this->renderEntityTemplate($template, $entity, $targetPath));
}
}
}
if ($this->getLanguage() === 'php') {
foreach ($this->modules as $module) {
$targetPath = $path . str_replace('\\', '/', $this->moduleNamespaces[$module]) . '/';
foreach ($this->getAutocodeModuleTemplates() as $template) {
$fileCollection->add($this->renderModuleTemplate($this, $template, $module, $targetPath));
}
}
}
return $fileCollection;
}
|
php
|
public function getModelFiles($path)
{
$fileCollection = new FileCollection();
$namespacePath = str_replace('\\', '/', $path . $this->getNamespace() . '/');
$targetPath = $namespacePath;
foreach ($this->getEntities() as $entity) {
if ($entity->getRenderizable()) {
if ($this->getLanguage() === 'php') {
if ($entity->getNamespace() !== '') {
$targetPath = $path . str_replace('\\', '/', $entity->getNamespace()) . '/';
}
} elseif ($this->getLanguage() === 'java') {
if ($entity->getModule() !== '') {
$targetPath = $path . '/' . $this->getAutocodeConfiguration('package') . '/' . str_replace('.', '/', $entity->getModule()) . '/';
}
}
foreach ($this->getAutocodeEntityTemplates() as $template) {
$fileCollection->add($this->renderEntityTemplate($template, $entity, $targetPath));
}
}
}
if ($this->getLanguage() === 'php') {
foreach ($this->modules as $module) {
$targetPath = $path . str_replace('\\', '/', $this->moduleNamespaces[$module]) . '/';
foreach ($this->getAutocodeModuleTemplates() as $template) {
$fileCollection->add($this->renderModuleTemplate($this, $template, $module, $targetPath));
}
}
}
return $fileCollection;
}
|
[
"public",
"function",
"getModelFiles",
"(",
"$",
"path",
")",
"{",
"$",
"fileCollection",
"=",
"new",
"FileCollection",
"(",
")",
";",
"$",
"namespacePath",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"path",
".",
"$",
"this",
"->",
"getNamespace",
"(",
")",
".",
"'/'",
")",
";",
"$",
"targetPath",
"=",
"$",
"namespacePath",
";",
"foreach",
"(",
"$",
"this",
"->",
"getEntities",
"(",
")",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"getRenderizable",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
")",
"===",
"'php'",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"getNamespace",
"(",
")",
"!==",
"''",
")",
"{",
"$",
"targetPath",
"=",
"$",
"path",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"entity",
"->",
"getNamespace",
"(",
")",
")",
".",
"'/'",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
")",
"===",
"'java'",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"getModule",
"(",
")",
"!==",
"''",
")",
"{",
"$",
"targetPath",
"=",
"$",
"path",
".",
"'/'",
".",
"$",
"this",
"->",
"getAutocodeConfiguration",
"(",
"'package'",
")",
".",
"'/'",
".",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"entity",
"->",
"getModule",
"(",
")",
")",
".",
"'/'",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getAutocodeEntityTemplates",
"(",
")",
"as",
"$",
"template",
")",
"{",
"$",
"fileCollection",
"->",
"add",
"(",
"$",
"this",
"->",
"renderEntityTemplate",
"(",
"$",
"template",
",",
"$",
"entity",
",",
"$",
"targetPath",
")",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"getLanguage",
"(",
")",
"===",
"'php'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"targetPath",
"=",
"$",
"path",
".",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"this",
"->",
"moduleNamespaces",
"[",
"$",
"module",
"]",
")",
".",
"'/'",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAutocodeModuleTemplates",
"(",
")",
"as",
"$",
"template",
")",
"{",
"$",
"fileCollection",
"->",
"add",
"(",
"$",
"this",
"->",
"renderModuleTemplate",
"(",
"$",
"this",
",",
"$",
"template",
",",
"$",
"module",
",",
"$",
"targetPath",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"fileCollection",
";",
"}"
] |
Returns a collection of files
@param string $path The path where they would be saved
@return FileCollection
|
[
"Returns",
"a",
"collection",
"of",
"files"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Project.php#L1238-L1275
|
20,480 |
j-d/draggy
|
src/Draggy/Autocode/Project.php
|
Project.singlelise
|
public static function singlelise($string)
{
$rules = [
'ies' => 'y',
'ves' => 'f',
's' => '',
];
foreach ($rules as $ending => $replacement) {
if ($ending === substr($string, -strlen($ending))) {
return substr($string, 0, -strlen($ending)) . $replacement;
}
}
return $string . 'Single';
}
|
php
|
public static function singlelise($string)
{
$rules = [
'ies' => 'y',
'ves' => 'f',
's' => '',
];
foreach ($rules as $ending => $replacement) {
if ($ending === substr($string, -strlen($ending))) {
return substr($string, 0, -strlen($ending)) . $replacement;
}
}
return $string . 'Single';
}
|
[
"public",
"static",
"function",
"singlelise",
"(",
"$",
"string",
")",
"{",
"$",
"rules",
"=",
"[",
"'ies'",
"=>",
"'y'",
",",
"'ves'",
"=>",
"'f'",
",",
"'s'",
"=>",
"''",
",",
"]",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"ending",
"=>",
"$",
"replacement",
")",
"{",
"if",
"(",
"$",
"ending",
"===",
"substr",
"(",
"$",
"string",
",",
"-",
"strlen",
"(",
"$",
"ending",
")",
")",
")",
"{",
"return",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"-",
"strlen",
"(",
"$",
"ending",
")",
")",
".",
"$",
"replacement",
";",
"}",
"}",
"return",
"$",
"string",
".",
"'Single'",
";",
"}"
] |
Get the plural name from a singular
@param string $string
@return string
|
[
"Get",
"the",
"plural",
"name",
"from",
"a",
"singular"
] |
97ffc66e1aacb5f685d7aac5251c4abb8888d4bb
|
https://github.com/j-d/draggy/blob/97ffc66e1aacb5f685d7aac5251c4abb8888d4bb/src/Draggy/Autocode/Project.php#L1370-L1385
|
20,481 |
adrenalinkin/config-helper
|
Extension/AbstractExtension.php
|
AbstractExtension.getConfigurationsFromFile
|
protected function getConfigurationsFromFile($fileName, ContainerBuilder $container, $merge = true)
{
$configs = [];
/** @var \Symfony\Component\Finder\SplFileInfo $file */
foreach ($this->getFinder($fileName, $container) as $file) {
$currentConfiguration = Yaml::parse($file->getContents());
// skip empty files
if (empty($currentConfiguration)) {
continue;
}
// merge configurations recursively or just stack
if ($merge) {
$configs = array_merge_recursive($configs, $currentConfiguration);
} else {
$configs[] = reset($currentConfiguration);
}
}
return $configs;
}
|
php
|
protected function getConfigurationsFromFile($fileName, ContainerBuilder $container, $merge = true)
{
$configs = [];
/** @var \Symfony\Component\Finder\SplFileInfo $file */
foreach ($this->getFinder($fileName, $container) as $file) {
$currentConfiguration = Yaml::parse($file->getContents());
// skip empty files
if (empty($currentConfiguration)) {
continue;
}
// merge configurations recursively or just stack
if ($merge) {
$configs = array_merge_recursive($configs, $currentConfiguration);
} else {
$configs[] = reset($currentConfiguration);
}
}
return $configs;
}
|
[
"protected",
"function",
"getConfigurationsFromFile",
"(",
"$",
"fileName",
",",
"ContainerBuilder",
"$",
"container",
",",
"$",
"merge",
"=",
"true",
")",
"{",
"$",
"configs",
"=",
"[",
"]",
";",
"/** @var \\Symfony\\Component\\Finder\\SplFileInfo $file */",
"foreach",
"(",
"$",
"this",
"->",
"getFinder",
"(",
"$",
"fileName",
",",
"$",
"container",
")",
"as",
"$",
"file",
")",
"{",
"$",
"currentConfiguration",
"=",
"Yaml",
"::",
"parse",
"(",
"$",
"file",
"->",
"getContents",
"(",
")",
")",
";",
"// skip empty files",
"if",
"(",
"empty",
"(",
"$",
"currentConfiguration",
")",
")",
"{",
"continue",
";",
"}",
"// merge configurations recursively or just stack",
"if",
"(",
"$",
"merge",
")",
"{",
"$",
"configs",
"=",
"array_merge_recursive",
"(",
"$",
"configs",
",",
"$",
"currentConfiguration",
")",
";",
"}",
"else",
"{",
"$",
"configs",
"[",
"]",
"=",
"reset",
"(",
"$",
"currentConfiguration",
")",
";",
"}",
"}",
"return",
"$",
"configs",
";",
"}"
] |
Returns all configurations registered in the specific yaml file.
@param string $fileName Name of the file with extension
@param ContainerBuilder $container Container builder
@param bool $merge Merge configuration recursively or just stack
@return array
|
[
"Returns",
"all",
"configurations",
"registered",
"in",
"the",
"specific",
"yaml",
"file",
"."
] |
97dfdb81aa2ed1878e411f76e0d723003b80062b
|
https://github.com/adrenalinkin/config-helper/blob/97dfdb81aa2ed1878e411f76e0d723003b80062b/Extension/AbstractExtension.php#L40-L62
|
20,482 |
adrenalinkin/config-helper
|
Extension/AbstractExtension.php
|
AbstractExtension.getFinder
|
private function getFinder($fileName, ContainerBuilder $container)
{
$finder = (new Finder())->files()->name($fileName);
$resourcesDir = 'Resources'.DIRECTORY_SEPARATOR.'config';
if (self::$directoriesCache) {
return $finder->in(self::$directoriesCache);
}
foreach ($container->getParameter('kernel.bundles') as $name => $pathToBundle) {
try {
$reflector = new \ReflectionClass($pathToBundle);
} catch (\ReflectionException $e) {
continue;
}
$fileName = $reflector->getFileName();
$fileName = str_replace($name.'.php', $resourcesDir, $fileName);
try {
$finder->in($fileName);
self::$directoriesCache[$name] = $fileName;
} catch (\InvalidArgumentException $e) {
// remove invalid directories
unset(self::$directoriesCache[$name]);
}
}
return $finder;
}
|
php
|
private function getFinder($fileName, ContainerBuilder $container)
{
$finder = (new Finder())->files()->name($fileName);
$resourcesDir = 'Resources'.DIRECTORY_SEPARATOR.'config';
if (self::$directoriesCache) {
return $finder->in(self::$directoriesCache);
}
foreach ($container->getParameter('kernel.bundles') as $name => $pathToBundle) {
try {
$reflector = new \ReflectionClass($pathToBundle);
} catch (\ReflectionException $e) {
continue;
}
$fileName = $reflector->getFileName();
$fileName = str_replace($name.'.php', $resourcesDir, $fileName);
try {
$finder->in($fileName);
self::$directoriesCache[$name] = $fileName;
} catch (\InvalidArgumentException $e) {
// remove invalid directories
unset(self::$directoriesCache[$name]);
}
}
return $finder;
}
|
[
"private",
"function",
"getFinder",
"(",
"$",
"fileName",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"finder",
"=",
"(",
"new",
"Finder",
"(",
")",
")",
"->",
"files",
"(",
")",
"->",
"name",
"(",
"$",
"fileName",
")",
";",
"$",
"resourcesDir",
"=",
"'Resources'",
".",
"DIRECTORY_SEPARATOR",
".",
"'config'",
";",
"if",
"(",
"self",
"::",
"$",
"directoriesCache",
")",
"{",
"return",
"$",
"finder",
"->",
"in",
"(",
"self",
"::",
"$",
"directoriesCache",
")",
";",
"}",
"foreach",
"(",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.bundles'",
")",
"as",
"$",
"name",
"=>",
"$",
"pathToBundle",
")",
"{",
"try",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"pathToBundle",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"$",
"fileName",
"=",
"$",
"reflector",
"->",
"getFileName",
"(",
")",
";",
"$",
"fileName",
"=",
"str_replace",
"(",
"$",
"name",
".",
"'.php'",
",",
"$",
"resourcesDir",
",",
"$",
"fileName",
")",
";",
"try",
"{",
"$",
"finder",
"->",
"in",
"(",
"$",
"fileName",
")",
";",
"self",
"::",
"$",
"directoriesCache",
"[",
"$",
"name",
"]",
"=",
"$",
"fileName",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"// remove invalid directories",
"unset",
"(",
"self",
"::",
"$",
"directoriesCache",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"return",
"$",
"finder",
";",
"}"
] |
Build and return finder
@param string $fileName
@param ContainerBuilder $container
@return Finder
|
[
"Build",
"and",
"return",
"finder"
] |
97dfdb81aa2ed1878e411f76e0d723003b80062b
|
https://github.com/adrenalinkin/config-helper/blob/97dfdb81aa2ed1878e411f76e0d723003b80062b/Extension/AbstractExtension.php#L72-L101
|
20,483 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query.php
|
ezcQuery.getPrefixedTableNames
|
protected function getPrefixedTableNames($tableNames)
{
if ($this->db->options && $this->db->options->tableNamePrefix)
{
switch (true)
{
case is_string($tableNames):
$tableNames = $this->db->options->tableNamePrefix . $tableNames;
break;
case is_array($tableNames):
foreach ($tableNames as $key => $table)
$tableNames[$key] = $this->db->options->tableNamePrefix . $table;
break;
}
}
return $tableNames;
}
|
php
|
protected function getPrefixedTableNames($tableNames)
{
if ($this->db->options && $this->db->options->tableNamePrefix)
{
switch (true)
{
case is_string($tableNames):
$tableNames = $this->db->options->tableNamePrefix . $tableNames;
break;
case is_array($tableNames):
foreach ($tableNames as $key => $table)
$tableNames[$key] = $this->db->options->tableNamePrefix . $table;
break;
}
}
return $tableNames;
}
|
[
"protected",
"function",
"getPrefixedTableNames",
"(",
"$",
"tableNames",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"options",
"&&",
"$",
"this",
"->",
"db",
"->",
"options",
"->",
"tableNamePrefix",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_string",
"(",
"$",
"tableNames",
")",
":",
"$",
"tableNames",
"=",
"$",
"this",
"->",
"db",
"->",
"options",
"->",
"tableNamePrefix",
".",
"$",
"tableNames",
";",
"break",
";",
"case",
"is_array",
"(",
"$",
"tableNames",
")",
":",
"foreach",
"(",
"$",
"tableNames",
"as",
"$",
"key",
"=>",
"$",
"table",
")",
"$",
"tableNames",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"db",
"->",
"options",
"->",
"tableNamePrefix",
".",
"$",
"table",
";",
"break",
";",
"}",
"}",
"return",
"$",
"tableNames",
";",
"}"
] |
Returns prefixed table names if "tableNamePrefix" option not empty
otherwise return untouched names
@param array|string $tableNames
@return array|string
|
[
"Returns",
"prefixed",
"table",
"names",
"if",
"tableNamePrefix",
"option",
"not",
"empty",
"otherwise",
"return",
"untouched",
"names"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query.php#L290-L308
|
20,484 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query.php
|
ezcQuery.prepare
|
public function prepare()
{
$stmt = $this->db->prepare( $this->getQuery() );
$this->doBind( $stmt );
return $stmt;
}
|
php
|
public function prepare()
{
$stmt = $this->db->prepare( $this->getQuery() );
$this->doBind( $stmt );
return $stmt;
}
|
[
"public",
"function",
"prepare",
"(",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"$",
"this",
"->",
"getQuery",
"(",
")",
")",
";",
"$",
"this",
"->",
"doBind",
"(",
"$",
"stmt",
")",
";",
"return",
"$",
"stmt",
";",
"}"
] |
Returns a prepared statement from this query which can be used for execution.
The returned object is a PDOStatement for which you can find extensive
documentation in the PHP manual:
{@link http://php.net/pdostatement-bindcolumn}
prepare() automatically calls doBind() on the statement.
@return PDOStatement
|
[
"Returns",
"a",
"prepared",
"statement",
"from",
"this",
"query",
"which",
"can",
"be",
"used",
"for",
"execution",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/query.php#L459-L464
|
20,485 |
mothership-ec/composer
|
src/Composer/DependencyResolver/Request.php
|
Request.fix
|
public function fix($packageName, LinkConstraintInterface $constraint = null)
{
$this->addJob($packageName, 'install', $constraint, true);
}
|
php
|
public function fix($packageName, LinkConstraintInterface $constraint = null)
{
$this->addJob($packageName, 'install', $constraint, true);
}
|
[
"public",
"function",
"fix",
"(",
"$",
"packageName",
",",
"LinkConstraintInterface",
"$",
"constraint",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addJob",
"(",
"$",
"packageName",
",",
"'install'",
",",
"$",
"constraint",
",",
"true",
")",
";",
"}"
] |
Mark an existing package as being installed and having to remain installed
These jobs will not be tempered with by the solver
|
[
"Mark",
"an",
"existing",
"package",
"as",
"being",
"installed",
"and",
"having",
"to",
"remain",
"installed"
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/Request.php#L49-L52
|
20,486 |
hametuha/wpametu
|
src/WPametu/API/Ajax/AjaxBase.php
|
AjaxBase.ajax_url
|
protected function ajax_url(){
$url = admin_url('admin-ajax.php');
if( is_ssl() ){
$url = str_replace('http://', 'https://', $url);
}else{
$url = str_replace('https://', 'http://', $url);
}
return $url;
}
|
php
|
protected function ajax_url(){
$url = admin_url('admin-ajax.php');
if( is_ssl() ){
$url = str_replace('http://', 'https://', $url);
}else{
$url = str_replace('https://', 'http://', $url);
}
return $url;
}
|
[
"protected",
"function",
"ajax_url",
"(",
")",
"{",
"$",
"url",
"=",
"admin_url",
"(",
"'admin-ajax.php'",
")",
";",
"if",
"(",
"is_ssl",
"(",
")",
")",
"{",
"$",
"url",
"=",
"str_replace",
"(",
"'http://'",
",",
"'https://'",
",",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"str_replace",
"(",
"'https://'",
",",
"'http://'",
",",
"$",
"url",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Returns Ajax endpoint
@return string
|
[
"Returns",
"Ajax",
"endpoint"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Ajax/AjaxBase.php#L141-L149
|
20,487 |
rhosocial/yii2-user
|
forms/RegisterForm.php
|
RegisterForm.register
|
public function register()
{
if ($this->validate()) {
$class = $this->userClass;
$user = new $class(['password' => $this->password]);
/* @var $user User */
$profile = $user->createProfile(['nickname' => $this->nickname, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'gender' => $this->gender]);
$models[] = $profile;
if (is_string($this->username)) {
$username = $user->createUsername($this->username);
$models[] = $username;
}
$result = $user->register($models);
if ($result == true) {
$this->model = $user;
}
return $result;
}
return false;
}
|
php
|
public function register()
{
if ($this->validate()) {
$class = $this->userClass;
$user = new $class(['password' => $this->password]);
/* @var $user User */
$profile = $user->createProfile(['nickname' => $this->nickname, 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'gender' => $this->gender]);
$models[] = $profile;
if (is_string($this->username)) {
$username = $user->createUsername($this->username);
$models[] = $username;
}
$result = $user->register($models);
if ($result == true) {
$this->model = $user;
}
return $result;
}
return false;
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"userClass",
";",
"$",
"user",
"=",
"new",
"$",
"class",
"(",
"[",
"'password'",
"=>",
"$",
"this",
"->",
"password",
"]",
")",
";",
"/* @var $user User */",
"$",
"profile",
"=",
"$",
"user",
"->",
"createProfile",
"(",
"[",
"'nickname'",
"=>",
"$",
"this",
"->",
"nickname",
",",
"'first_name'",
"=>",
"$",
"this",
"->",
"first_name",
",",
"'last_name'",
"=>",
"$",
"this",
"->",
"last_name",
",",
"'gender'",
"=>",
"$",
"this",
"->",
"gender",
"]",
")",
";",
"$",
"models",
"[",
"]",
"=",
"$",
"profile",
";",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"username",
")",
")",
"{",
"$",
"username",
"=",
"$",
"user",
"->",
"createUsername",
"(",
"$",
"this",
"->",
"username",
")",
";",
"$",
"models",
"[",
"]",
"=",
"$",
"username",
";",
"}",
"$",
"result",
"=",
"$",
"user",
"->",
"register",
"(",
"$",
"models",
")",
";",
"if",
"(",
"$",
"result",
"==",
"true",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"user",
";",
"}",
"return",
"$",
"result",
";",
"}",
"return",
"false",
";",
"}"
] |
Register user with current model.
@return bool
|
[
"Register",
"user",
"with",
"current",
"model",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/forms/RegisterForm.php#L128-L147
|
20,488 |
oroinc/OroLayoutComponent
|
Extension/Theme/PathProvider/ThemePathProvider.php
|
ThemePathProvider.getThemesHierarchy
|
protected function getThemesHierarchy($themeName)
{
$hierarchy = [];
while (null !== $themeName) {
$theme = $this->themeManager->getTheme($themeName);
$hierarchy[] = $theme;
$themeName = $theme->getParentTheme();
}
return array_reverse($hierarchy);
}
|
php
|
protected function getThemesHierarchy($themeName)
{
$hierarchy = [];
while (null !== $themeName) {
$theme = $this->themeManager->getTheme($themeName);
$hierarchy[] = $theme;
$themeName = $theme->getParentTheme();
}
return array_reverse($hierarchy);
}
|
[
"protected",
"function",
"getThemesHierarchy",
"(",
"$",
"themeName",
")",
"{",
"$",
"hierarchy",
"=",
"[",
"]",
";",
"while",
"(",
"null",
"!==",
"$",
"themeName",
")",
"{",
"$",
"theme",
"=",
"$",
"this",
"->",
"themeManager",
"->",
"getTheme",
"(",
"$",
"themeName",
")",
";",
"$",
"hierarchy",
"[",
"]",
"=",
"$",
"theme",
";",
"$",
"themeName",
"=",
"$",
"theme",
"->",
"getParentTheme",
"(",
")",
";",
"}",
"return",
"array_reverse",
"(",
"$",
"hierarchy",
")",
";",
"}"
] |
Returns theme inheritance hierarchy with root theme as first item
@param string $themeName
@return Theme[]
|
[
"Returns",
"theme",
"inheritance",
"hierarchy",
"with",
"root",
"theme",
"as",
"first",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/Theme/PathProvider/ThemePathProvider.php#L84-L96
|
20,489 |
husccexo/php-handlersocket-core
|
src/HSCore/Driver.php
|
Driver.send
|
public function send($command)
{
$string = $command;
$timer = microtime(true);
while ($string) {
$bytes = fwrite($this->socket, $string);
if ($bytes === false) {
$this->close();
throw new HSException('Cannot write to socket');
}
if ($bytes === 0) {
return null;
}
$string = substr($string, $bytes);
}
$this->logs[] = [
'type' => 'sended',
'time' => microtime(true) - $timer,
'command' => $command
];
return $this->receive();
}
|
php
|
public function send($command)
{
$string = $command;
$timer = microtime(true);
while ($string) {
$bytes = fwrite($this->socket, $string);
if ($bytes === false) {
$this->close();
throw new HSException('Cannot write to socket');
}
if ($bytes === 0) {
return null;
}
$string = substr($string, $bytes);
}
$this->logs[] = [
'type' => 'sended',
'time' => microtime(true) - $timer,
'command' => $command
];
return $this->receive();
}
|
[
"public",
"function",
"send",
"(",
"$",
"command",
")",
"{",
"$",
"string",
"=",
"$",
"command",
";",
"$",
"timer",
"=",
"microtime",
"(",
"true",
")",
";",
"while",
"(",
"$",
"string",
")",
"{",
"$",
"bytes",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"string",
")",
";",
"if",
"(",
"$",
"bytes",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"throw",
"new",
"HSException",
"(",
"'Cannot write to socket'",
")",
";",
"}",
"if",
"(",
"$",
"bytes",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"$",
"bytes",
")",
";",
"}",
"$",
"this",
"->",
"logs",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"'sended'",
",",
"'time'",
"=>",
"microtime",
"(",
"true",
")",
"-",
"$",
"timer",
",",
"'command'",
"=>",
"$",
"command",
"]",
";",
"return",
"$",
"this",
"->",
"receive",
"(",
")",
";",
"}"
] |
Send string command to server
@param string $command
@return string
@throws HSException
|
[
"Send",
"string",
"command",
"to",
"server"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Driver.php#L78-L106
|
20,490 |
husccexo/php-handlersocket-core
|
src/HSCore/Driver.php
|
Driver.encode
|
public static function encode($string)
{
return is_null($string) ? self::NULL : strtr($string, self::$encodeMap);
}
|
php
|
public static function encode($string)
{
return is_null($string) ? self::NULL : strtr($string, self::$encodeMap);
}
|
[
"public",
"static",
"function",
"encode",
"(",
"$",
"string",
")",
"{",
"return",
"is_null",
"(",
"$",
"string",
")",
"?",
"self",
"::",
"NULL",
":",
"strtr",
"(",
"$",
"string",
",",
"self",
"::",
"$",
"encodeMap",
")",
";",
"}"
] |
Encode string for sending to server
@param $string
@return string
|
[
"Encode",
"string",
"for",
"sending",
"to",
"server"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Driver.php#L126-L129
|
20,491 |
husccexo/php-handlersocket-core
|
src/HSCore/Driver.php
|
Driver.decode
|
public static function decode($string)
{
return ($string === self::NULL) ? null : strtr($string, self::$decodeMap);
}
|
php
|
public static function decode($string)
{
return ($string === self::NULL) ? null : strtr($string, self::$decodeMap);
}
|
[
"public",
"static",
"function",
"decode",
"(",
"$",
"string",
")",
"{",
"return",
"(",
"$",
"string",
"===",
"self",
"::",
"NULL",
")",
"?",
"null",
":",
"strtr",
"(",
"$",
"string",
",",
"self",
"::",
"$",
"decodeMap",
")",
";",
"}"
] |
Decode string from server
@param $string
@return null|string
|
[
"Decode",
"string",
"from",
"server"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Driver.php#L138-L141
|
20,492 |
husccexo/php-handlersocket-core
|
src/HSCore/Driver.php
|
Driver.open
|
public function open()
{
$this->socket = stream_socket_client('tcp://'.$this->address, $errc, $errs, STREAM_CLIENT_CONNECT);
if (!$this->socket) {
throw new HSException('Connection to '.$this->address.' failed');
}
}
|
php
|
public function open()
{
$this->socket = stream_socket_client('tcp://'.$this->address, $errc, $errs, STREAM_CLIENT_CONNECT);
if (!$this->socket) {
throw new HSException('Connection to '.$this->address.' failed');
}
}
|
[
"public",
"function",
"open",
"(",
")",
"{",
"$",
"this",
"->",
"socket",
"=",
"stream_socket_client",
"(",
"'tcp://'",
".",
"$",
"this",
"->",
"address",
",",
"$",
"errc",
",",
"$",
"errs",
",",
"STREAM_CLIENT_CONNECT",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
")",
"{",
"throw",
"new",
"HSException",
"(",
"'Connection to '",
".",
"$",
"this",
"->",
"address",
".",
"' failed'",
")",
";",
"}",
"}"
] |
Open Handler Socket
@throwsHSrException
|
[
"Open",
"Handler",
"Socket"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Driver.php#L149-L156
|
20,493 |
husccexo/php-handlersocket-core
|
src/HSCore/Driver.php
|
Driver.receive
|
private function receive()
{
$timer = microtime(true);
$str = fgets($this->socket);
if ($str === false) {
$this->close();
throw new HSException('Cannot read from socket');
}
$this->logs[] = [
'type' => 'receive',
'time' => microtime(true) - $timer,
'command' => $str
];
return substr($str, 0, -1);
}
|
php
|
private function receive()
{
$timer = microtime(true);
$str = fgets($this->socket);
if ($str === false) {
$this->close();
throw new HSException('Cannot read from socket');
}
$this->logs[] = [
'type' => 'receive',
'time' => microtime(true) - $timer,
'command' => $str
];
return substr($str, 0, -1);
}
|
[
"private",
"function",
"receive",
"(",
")",
"{",
"$",
"timer",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"str",
"=",
"fgets",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"if",
"(",
"$",
"str",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"throw",
"new",
"HSException",
"(",
"'Cannot read from socket'",
")",
";",
"}",
"$",
"this",
"->",
"logs",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"'receive'",
",",
"'time'",
"=>",
"microtime",
"(",
"true",
")",
"-",
"$",
"timer",
",",
"'command'",
"=>",
"$",
"str",
"]",
";",
"return",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"-",
"1",
")",
";",
"}"
] |
Receive one string from server.
String haven't trailing \n
@return string
@throws HSException
|
[
"Receive",
"one",
"string",
"from",
"server",
".",
"String",
"haven",
"t",
"trailing",
"\\",
"n"
] |
aaeeece9c90a89bbc861a6fe390bc0c892496bf0
|
https://github.com/husccexo/php-handlersocket-core/blob/aaeeece9c90a89bbc861a6fe390bc0c892496bf0/src/HSCore/Driver.php#L203-L222
|
20,494 |
bytic/framework
|
src/Mvc/Sections/Section.php
|
Section.compilePath
|
public function compilePath($path = false)
{
$currentBasePath = $this->getManager()->getCurrent()->getPath();
$path = str_replace($currentBasePath, $this->getPath(), $path);
return $path;
}
|
php
|
public function compilePath($path = false)
{
$currentBasePath = $this->getManager()->getCurrent()->getPath();
$path = str_replace($currentBasePath, $this->getPath(), $path);
return $path;
}
|
[
"public",
"function",
"compilePath",
"(",
"$",
"path",
"=",
"false",
")",
"{",
"$",
"currentBasePath",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getCurrent",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"$",
"currentBasePath",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"path",
")",
";",
"return",
"$",
"path",
";",
"}"
] |
Compile path for this section from a given path of current section
@param bool $path
@return string
|
[
"Compile",
"path",
"for",
"this",
"section",
"from",
"a",
"given",
"path",
"of",
"current",
"section"
] |
36b4a761f4b64899f3841b0f6c8eb92887e91677
|
https://github.com/bytic/framework/blob/36b4a761f4b64899f3841b0f6c8eb92887e91677/src/Mvc/Sections/Section.php#L73-L78
|
20,495 |
ShaoZeMing/laravel-merchant
|
src/Auth/Permission.php
|
Permission.check
|
public static function check($permission)
{
if (static::isAdministrator()) {
return true;
}
if (is_array($permission)) {
collect($permission)->each(function ($permission) {
call_user_func([Permission::class, 'check'], $permission);
});
return;
}
if (Auth::guard('merchant')->user()->cannot($permission)) {
static::error();
}
}
|
php
|
public static function check($permission)
{
if (static::isAdministrator()) {
return true;
}
if (is_array($permission)) {
collect($permission)->each(function ($permission) {
call_user_func([Permission::class, 'check'], $permission);
});
return;
}
if (Auth::guard('merchant')->user()->cannot($permission)) {
static::error();
}
}
|
[
"public",
"static",
"function",
"check",
"(",
"$",
"permission",
")",
"{",
"if",
"(",
"static",
"::",
"isAdministrator",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"permission",
")",
")",
"{",
"collect",
"(",
"$",
"permission",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"permission",
")",
"{",
"call_user_func",
"(",
"[",
"Permission",
"::",
"class",
",",
"'check'",
"]",
",",
"$",
"permission",
")",
";",
"}",
")",
";",
"return",
";",
"}",
"if",
"(",
"Auth",
"::",
"guard",
"(",
"'merchant'",
")",
"->",
"user",
"(",
")",
"->",
"cannot",
"(",
"$",
"permission",
")",
")",
"{",
"static",
"::",
"error",
"(",
")",
";",
"}",
"}"
] |
Check permission.
@param $permission
@return true
|
[
"Check",
"permission",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Auth/Permission.php#L18-L35
|
20,496 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/plain.php
|
ezcCacheStorageApcPlain.fetchData
|
protected function fetchData( $identifier, $object = false )
{
$data = $this->backend->fetch( $identifier );
if ( is_object( $data ) && $object === false )
{
return $data->data;
}
if ( is_object( $data ) && $object !== false )
{
return $data;
}
else
{
return false;
}
}
|
php
|
protected function fetchData( $identifier, $object = false )
{
$data = $this->backend->fetch( $identifier );
if ( is_object( $data ) && $object === false )
{
return $data->data;
}
if ( is_object( $data ) && $object !== false )
{
return $data;
}
else
{
return false;
}
}
|
[
"protected",
"function",
"fetchData",
"(",
"$",
"identifier",
",",
"$",
"object",
"=",
"false",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"backend",
"->",
"fetch",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
"&&",
"$",
"object",
"===",
"false",
")",
"{",
"return",
"$",
"data",
"->",
"data",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
"&&",
"$",
"object",
"!==",
"false",
")",
"{",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Fetches data from the cache.
@param string $identifier The file to fetch data from
@param bool $object return the object and not the clean data
@return mixed The fetched data or false on failure
|
[
"Fetches",
"data",
"from",
"the",
"cache",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/plain.php#L30-L45
|
20,497 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/plain.php
|
ezcCacheStorageApcPlain.prepareData
|
protected function prepareData( $data )
{
if ( is_resource( $data ) )
{
throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple', 'array', 'object' ) );
}
return new ezcCacheStorageMemoryDataStruct( $data, $this->properties['location'] );
}
|
php
|
protected function prepareData( $data )
{
if ( is_resource( $data ) )
{
throw new ezcCacheInvalidDataException( gettype( $data ), array( 'simple', 'array', 'object' ) );
}
return new ezcCacheStorageMemoryDataStruct( $data, $this->properties['location'] );
}
|
[
"protected",
"function",
"prepareData",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"ezcCacheInvalidDataException",
"(",
"gettype",
"(",
"$",
"data",
")",
",",
"array",
"(",
"'simple'",
",",
"'array'",
",",
"'object'",
")",
")",
";",
"}",
"return",
"new",
"ezcCacheStorageMemoryDataStruct",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"properties",
"[",
"'location'",
"]",
")",
";",
"}"
] |
Wraps the data in an ezcCacheStorageMemoryDataStruct structure in order
to store it.
@throws ezcCacheInvalidDataException
If the data submitted can not be handled by this storage (resource).
@param mixed $data Simple type or array
@return ezcCacheStorageMemoryDataStruct Prepared data
|
[
"Wraps",
"the",
"data",
"in",
"an",
"ezcCacheStorageMemoryDataStruct",
"structure",
"in",
"order",
"to",
"store",
"it",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/apc/plain.php#L57-L64
|
20,498 |
bradcornford/Alerter
|
src/Cornford/Alerter/AlertDisplay.php
|
AlertDisplay.findDisplayViewFile
|
protected function findDisplayViewFile()
{
foreach($this->getDirectoryIterator() as $file) {
$name = $file->getFilename();
if ($this->isDisplayViewFile($name)) {
return $file->getPathname();
}
}
throw new AlertDisplayViewException('Could not locate the view file.');
}
|
php
|
protected function findDisplayViewFile()
{
foreach($this->getDirectoryIterator() as $file) {
$name = $file->getFilename();
if ($this->isDisplayViewFile($name)) {
return $file->getPathname();
}
}
throw new AlertDisplayViewException('Could not locate the view file.');
}
|
[
"protected",
"function",
"findDisplayViewFile",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getDirectoryIterator",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"name",
"=",
"$",
"file",
"->",
"getFilename",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isDisplayViewFile",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"file",
"->",
"getPathname",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"AlertDisplayViewException",
"(",
"'Could not locate the view file.'",
")",
";",
"}"
] |
Track down the display view file.
@return string
@throws \Cornford\Alerter\Exceptions\AlertDisplayViewException
|
[
"Track",
"down",
"the",
"display",
"view",
"file",
"."
] |
6533fe7afb9d1bae553385d3e687a24bda6a1333
|
https://github.com/bradcornford/Alerter/blob/6533fe7afb9d1bae553385d3e687a24bda6a1333/src/Cornford/Alerter/AlertDisplay.php#L85-L96
|
20,499 |
Innmind/neo4j-dbal
|
src/Transactions.php
|
Transactions.open
|
public function open(): Transaction
{
$response = ($this->fulfill)(
new Request(
Url::fromString('/db/data/transaction'),
Method::post(),
new ProtocolVersion(1, 1),
$this->headers,
$this->body
)
);
$body = Json::decode((string) $response->body());
$location = (string) $response
->headers()
->get('Location')
->values()
->current();
$transaction = new Transaction(
Url::fromString($location),
$this->clock->at($body['transaction']['expires']),
Url::fromString($body['commit'])
);
$this->transactions = $this->transactions->add($transaction);
return $transaction;
}
|
php
|
public function open(): Transaction
{
$response = ($this->fulfill)(
new Request(
Url::fromString('/db/data/transaction'),
Method::post(),
new ProtocolVersion(1, 1),
$this->headers,
$this->body
)
);
$body = Json::decode((string) $response->body());
$location = (string) $response
->headers()
->get('Location')
->values()
->current();
$transaction = new Transaction(
Url::fromString($location),
$this->clock->at($body['transaction']['expires']),
Url::fromString($body['commit'])
);
$this->transactions = $this->transactions->add($transaction);
return $transaction;
}
|
[
"public",
"function",
"open",
"(",
")",
":",
"Transaction",
"{",
"$",
"response",
"=",
"(",
"$",
"this",
"->",
"fulfill",
")",
"(",
"new",
"Request",
"(",
"Url",
"::",
"fromString",
"(",
"'/db/data/transaction'",
")",
",",
"Method",
"::",
"post",
"(",
")",
",",
"new",
"ProtocolVersion",
"(",
"1",
",",
"1",
")",
",",
"$",
"this",
"->",
"headers",
",",
"$",
"this",
"->",
"body",
")",
")",
";",
"$",
"body",
"=",
"Json",
"::",
"decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"body",
"(",
")",
")",
";",
"$",
"location",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"headers",
"(",
")",
"->",
"get",
"(",
"'Location'",
")",
"->",
"values",
"(",
")",
"->",
"current",
"(",
")",
";",
"$",
"transaction",
"=",
"new",
"Transaction",
"(",
"Url",
"::",
"fromString",
"(",
"$",
"location",
")",
",",
"$",
"this",
"->",
"clock",
"->",
"at",
"(",
"$",
"body",
"[",
"'transaction'",
"]",
"[",
"'expires'",
"]",
")",
",",
"Url",
"::",
"fromString",
"(",
"$",
"body",
"[",
"'commit'",
"]",
")",
")",
";",
"$",
"this",
"->",
"transactions",
"=",
"$",
"this",
"->",
"transactions",
"->",
"add",
"(",
"$",
"transaction",
")",
";",
"return",
"$",
"transaction",
";",
"}"
] |
Open a new transaction
@return Transaction
|
[
"Open",
"a",
"new",
"transaction"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Transactions.php#L66-L93
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.