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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
22,800
|
jnaxo/country-codes
|
src/CountryStore.php
|
CountryStore.administrativeAreas
|
public function administrativeAreas($country_id, Request $request = null)
{
$query = AdministrativeArea::where('country_id', $country_id)
->with('country');
if ($request) {
$resource = new Collection($query, 'administrative_area', $request);
return $this->respondWithCollection($resource);
}
return $query->get();
}
|
php
|
public function administrativeAreas($country_id, Request $request = null)
{
$query = AdministrativeArea::where('country_id', $country_id)
->with('country');
if ($request) {
$resource = new Collection($query, 'administrative_area', $request);
return $this->respondWithCollection($resource);
}
return $query->get();
}
|
[
"public",
"function",
"administrativeAreas",
"(",
"$",
"country_id",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"AdministrativeArea",
"::",
"where",
"(",
"'country_id'",
",",
"$",
"country_id",
")",
"->",
"with",
"(",
"'country'",
")",
";",
"if",
"(",
"$",
"request",
")",
"{",
"$",
"resource",
"=",
"new",
"Collection",
"(",
"$",
"query",
",",
"'administrative_area'",
",",
"$",
"request",
")",
";",
"return",
"$",
"this",
"->",
"respondWithCollection",
"(",
"$",
"resource",
")",
";",
"}",
"return",
"$",
"query",
"->",
"get",
"(",
")",
";",
"}"
] |
Get Administrative areas collection of a country given
@param int $country_id
@param Illuminate\Http\Request $request
@return mixed Jnaxo\CountryCodes\AdministrativeArea collection
|
[
"Get",
"Administrative",
"areas",
"collection",
"of",
"a",
"country",
"given"
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/CountryStore.php#L132-L142
|
22,801
|
jnaxo/country-codes
|
src/CountryStore.php
|
CountryStore.city
|
public function city($city_id, Request $request = null)
{
$city = City::find($city_id);
if ($request) {
$included = [];
$query = $city->getInlcudeResources($request->include);
if ($query) {
$collection = new Collection($query, $request->include);
$included = $collection->toArray();
}
$links = $request ? ['self' => $request->url()] : [];
return $this->respondWithItem($city, 'city', $links, $included);
}
return $city;
}
|
php
|
public function city($city_id, Request $request = null)
{
$city = City::find($city_id);
if ($request) {
$included = [];
$query = $city->getInlcudeResources($request->include);
if ($query) {
$collection = new Collection($query, $request->include);
$included = $collection->toArray();
}
$links = $request ? ['self' => $request->url()] : [];
return $this->respondWithItem($city, 'city', $links, $included);
}
return $city;
}
|
[
"public",
"function",
"city",
"(",
"$",
"city_id",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"city",
"=",
"City",
"::",
"find",
"(",
"$",
"city_id",
")",
";",
"if",
"(",
"$",
"request",
")",
"{",
"$",
"included",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"$",
"city",
"->",
"getInlcudeResources",
"(",
"$",
"request",
"->",
"include",
")",
";",
"if",
"(",
"$",
"query",
")",
"{",
"$",
"collection",
"=",
"new",
"Collection",
"(",
"$",
"query",
",",
"$",
"request",
"->",
"include",
")",
";",
"$",
"included",
"=",
"$",
"collection",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"links",
"=",
"$",
"request",
"?",
"[",
"'self'",
"=>",
"$",
"request",
"->",
"url",
"(",
")",
"]",
":",
"[",
"]",
";",
"return",
"$",
"this",
"->",
"respondWithItem",
"(",
"$",
"city",
",",
"'city'",
",",
"$",
"links",
",",
"$",
"included",
")",
";",
"}",
"return",
"$",
"city",
";",
"}"
] |
Get city item, optional include administrative division.
@param int $city_id
@param Illuminate\Http\Request $request
@return mixed Jnaxo\CountryCodes\City item
|
[
"Get",
"city",
"item",
"optional",
"include",
"administrative",
"division",
"."
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/CountryStore.php#L151-L166
|
22,802
|
jnaxo/country-codes
|
src/CountryStore.php
|
CountryStore.cities
|
public function cities($country_id, Request $request = null)
{
$query = City::with([
'administrativeArea' => function ($q) use ($country_id) {
$q->where('country_id', $country_id);
}
])
->with('administrativeArea.country');
if ($request) {
$resource = new Collection($query, 'city', $request);
return $this->respondWithCollection($resource);
}
return $query->get();
}
|
php
|
public function cities($country_id, Request $request = null)
{
$query = City::with([
'administrativeArea' => function ($q) use ($country_id) {
$q->where('country_id', $country_id);
}
])
->with('administrativeArea.country');
if ($request) {
$resource = new Collection($query, 'city', $request);
return $this->respondWithCollection($resource);
}
return $query->get();
}
|
[
"public",
"function",
"cities",
"(",
"$",
"country_id",
",",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"City",
"::",
"with",
"(",
"[",
"'administrativeArea'",
"=>",
"function",
"(",
"$",
"q",
")",
"use",
"(",
"$",
"country_id",
")",
"{",
"$",
"q",
"->",
"where",
"(",
"'country_id'",
",",
"$",
"country_id",
")",
";",
"}",
"]",
")",
"->",
"with",
"(",
"'administrativeArea.country'",
")",
";",
"if",
"(",
"$",
"request",
")",
"{",
"$",
"resource",
"=",
"new",
"Collection",
"(",
"$",
"query",
",",
"'city'",
",",
"$",
"request",
")",
";",
"return",
"$",
"this",
"->",
"respondWithCollection",
"(",
"$",
"resource",
")",
";",
"}",
"return",
"$",
"query",
"->",
"get",
"(",
")",
";",
"}"
] |
Get country cities
@param int $country_id
@param Illuminate\Http\Request $request
@return mixed Jnaxo\CountryCodes\City collection
|
[
"Get",
"country",
"cities"
] |
ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9
|
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/CountryStore.php#L175-L189
|
22,803
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php
|
AreAllArgumentsValidValidator.checkArgumentInDocBlock
|
protected function checkArgumentInDocBlock()
{
$validator = new IsArgumentInDocBlockValidator();
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new IsArgumentInDocBlock);
}
|
php
|
protected function checkArgumentInDocBlock()
{
$validator = new IsArgumentInDocBlockValidator();
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new IsArgumentInDocBlock);
}
|
[
"protected",
"function",
"checkArgumentInDocBlock",
"(",
")",
"{",
"$",
"validator",
"=",
"new",
"IsArgumentInDocBlockValidator",
"(",
")",
";",
"$",
"validator",
"->",
"initialize",
"(",
"$",
"this",
"->",
"context",
")",
";",
"return",
"$",
"validator",
"->",
"validate",
"(",
"$",
"this",
"->",
"validationValue",
",",
"new",
"IsArgumentInDocBlock",
")",
";",
"}"
] |
Check if argument is inside docblock.
|
[
"Check",
"if",
"argument",
"is",
"inside",
"docblock",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php#L111-L117
|
22,804
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php
|
AreAllArgumentsValidValidator.checkArgumentNameMatchParam
|
protected function checkArgumentNameMatchParam()
{
$validator = new DoesArgumentNameMatchParamValidator;
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new DoesArgumentNameMatchParam);
}
|
php
|
protected function checkArgumentNameMatchParam()
{
$validator = new DoesArgumentNameMatchParamValidator;
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new DoesArgumentNameMatchParam);
}
|
[
"protected",
"function",
"checkArgumentNameMatchParam",
"(",
")",
"{",
"$",
"validator",
"=",
"new",
"DoesArgumentNameMatchParamValidator",
";",
"$",
"validator",
"->",
"initialize",
"(",
"$",
"this",
"->",
"context",
")",
";",
"return",
"$",
"validator",
"->",
"validate",
"(",
"$",
"this",
"->",
"validationValue",
",",
"new",
"DoesArgumentNameMatchParam",
")",
";",
"}"
] |
Check if argument matches parameter.
|
[
"Check",
"if",
"argument",
"matches",
"parameter",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php#L122-L128
|
22,805
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php
|
AreAllArgumentsValidValidator.checkArgumentTypehintMatchParam
|
protected function checkArgumentTypehintMatchParam()
{
$validator = new DoesArgumentTypehintMatchParamValidator;
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new DoesArgumentTypehintMatchParam);
}
|
php
|
protected function checkArgumentTypehintMatchParam()
{
$validator = new DoesArgumentTypehintMatchParamValidator;
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new DoesArgumentTypehintMatchParam);
}
|
[
"protected",
"function",
"checkArgumentTypehintMatchParam",
"(",
")",
"{",
"$",
"validator",
"=",
"new",
"DoesArgumentTypehintMatchParamValidator",
";",
"$",
"validator",
"->",
"initialize",
"(",
"$",
"this",
"->",
"context",
")",
";",
"return",
"$",
"validator",
"->",
"validate",
"(",
"$",
"this",
"->",
"validationValue",
",",
"new",
"DoesArgumentTypehintMatchParam",
")",
";",
"}"
] |
Check if argument typehint matches parameter.
|
[
"Check",
"if",
"argument",
"typehint",
"matches",
"parameter",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php#L133-L139
|
22,806
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php
|
AreAllArgumentsValidValidator.checkParamsExists
|
protected function checkParamsExists()
{
$validator = new DoesParamsExistsValidator();
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new DoesParamsExists);
}
|
php
|
protected function checkParamsExists()
{
$validator = new DoesParamsExistsValidator();
$validator->initialize($this->context);
return $validator->validate($this->validationValue, new DoesParamsExists);
}
|
[
"protected",
"function",
"checkParamsExists",
"(",
")",
"{",
"$",
"validator",
"=",
"new",
"DoesParamsExistsValidator",
"(",
")",
";",
"$",
"validator",
"->",
"initialize",
"(",
"$",
"this",
"->",
"context",
")",
";",
"return",
"$",
"validator",
"->",
"validate",
"(",
"$",
"this",
"->",
"validationValue",
",",
"new",
"DoesParamsExists",
")",
";",
"}"
] |
Check if parameter exists for argument.
@param Collection $params
@param Collection $arguments
|
[
"Check",
"if",
"parameter",
"exists",
"for",
"argument",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/Constraints/Functions/AreAllArgumentsValidValidator.php#L147-L153
|
22,807
|
inhere/php-librarys
|
src/Components/EnvDetector.php
|
EnvDetector.getEnvNameByHost
|
public static function getEnvNameByHost(string $defaultEnv = null, string $hostname = null): string
{
$hostname = $hostname ?: gethostname();
if (!$hostname) {
return $defaultEnv;
}
foreach (self::$host2env as $kw => $env) {
if (false !== strpos($hostname, $kw)) {
return $env;
}
}
return $defaultEnv;
}
|
php
|
public static function getEnvNameByHost(string $defaultEnv = null, string $hostname = null): string
{
$hostname = $hostname ?: gethostname();
if (!$hostname) {
return $defaultEnv;
}
foreach (self::$host2env as $kw => $env) {
if (false !== strpos($hostname, $kw)) {
return $env;
}
}
return $defaultEnv;
}
|
[
"public",
"static",
"function",
"getEnvNameByHost",
"(",
"string",
"$",
"defaultEnv",
"=",
"null",
",",
"string",
"$",
"hostname",
"=",
"null",
")",
":",
"string",
"{",
"$",
"hostname",
"=",
"$",
"hostname",
"?",
":",
"gethostname",
"(",
")",
";",
"if",
"(",
"!",
"$",
"hostname",
")",
"{",
"return",
"$",
"defaultEnv",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"host2env",
"as",
"$",
"kw",
"=>",
"$",
"env",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"hostname",
",",
"$",
"kw",
")",
")",
"{",
"return",
"$",
"env",
";",
"}",
"}",
"return",
"$",
"defaultEnv",
";",
"}"
] |
get Env Name By Host
@param null|string $hostname
@param string $defaultEnv
@return string
|
[
"get",
"Env",
"Name",
"By",
"Host"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/EnvDetector.php#L49-L64
|
22,808
|
inhere/php-librarys
|
src/Components/EnvDetector.php
|
EnvDetector.getEnvNameByDomain
|
public static function getEnvNameByDomain(string $defaultEnv = null, string $domain = null): string
{
$domain = $domain ?: PhpHelper::serverParam('HTTP_HOST');
if (!$domain) {
return $defaultEnv;
}
foreach (self::$domain2env as $kw => $env) {
if (false !== strpos($domain, $kw)) {
return $env;
}
}
return $defaultEnv;
}
|
php
|
public static function getEnvNameByDomain(string $defaultEnv = null, string $domain = null): string
{
$domain = $domain ?: PhpHelper::serverParam('HTTP_HOST');
if (!$domain) {
return $defaultEnv;
}
foreach (self::$domain2env as $kw => $env) {
if (false !== strpos($domain, $kw)) {
return $env;
}
}
return $defaultEnv;
}
|
[
"public",
"static",
"function",
"getEnvNameByDomain",
"(",
"string",
"$",
"defaultEnv",
"=",
"null",
",",
"string",
"$",
"domain",
"=",
"null",
")",
":",
"string",
"{",
"$",
"domain",
"=",
"$",
"domain",
"?",
":",
"PhpHelper",
"::",
"serverParam",
"(",
"'HTTP_HOST'",
")",
";",
"if",
"(",
"!",
"$",
"domain",
")",
"{",
"return",
"$",
"defaultEnv",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"domain2env",
"as",
"$",
"kw",
"=>",
"$",
"env",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"domain",
",",
"$",
"kw",
")",
")",
"{",
"return",
"$",
"env",
";",
"}",
"}",
"return",
"$",
"defaultEnv",
";",
"}"
] |
get Env Name By Domain
@param string $defaultEnv
@param null|string $domain
@return string
|
[
"get",
"Env",
"Name",
"By",
"Domain"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/EnvDetector.php#L72-L87
|
22,809
|
antaresproject/notifications
|
src/Processor/SidebarProcessor.php
|
SidebarProcessor.delete
|
public function delete()
{
try {
if (is_null($id = Input::get('id'))) {
throw new Exception('Invalid notification id provided');
}
$this->stack->deleteById($id);
} catch (Exception $ex) {
Log::alert($ex);
return new JsonResponse(['message' => trans('antares/notifications::messages.sidebar.unable_to_delete_notification_item')], 500);
}
}
|
php
|
public function delete()
{
try {
if (is_null($id = Input::get('id'))) {
throw new Exception('Invalid notification id provided');
}
$this->stack->deleteById($id);
} catch (Exception $ex) {
Log::alert($ex);
return new JsonResponse(['message' => trans('antares/notifications::messages.sidebar.unable_to_delete_notification_item')], 500);
}
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"is_null",
"(",
"$",
"id",
"=",
"Input",
"::",
"get",
"(",
"'id'",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid notification id provided'",
")",
";",
"}",
"$",
"this",
"->",
"stack",
"->",
"deleteById",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"Log",
"::",
"alert",
"(",
"$",
"ex",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"'message'",
"=>",
"trans",
"(",
"'antares/notifications::messages.sidebar.unable_to_delete_notification_item'",
")",
"]",
",",
"500",
")",
";",
"}",
"}"
] |
Deletes item from sidebar
@return JsonResponse
|
[
"Deletes",
"item",
"from",
"sidebar"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/SidebarProcessor.php#L65-L76
|
22,810
|
antaresproject/notifications
|
src/Processor/SidebarProcessor.php
|
SidebarProcessor.read
|
public function read()
{
try {
$this->stack->markAsRead(from_route('type', 'notifications'));
return new JsonResponse('', 200);
} catch (Exception $ex) {
Log::alert($ex);
return new JsonResponse(['message' => trans('antares/notifications::messages.sidebar.unable_to_mark_notifications_as_read')], 500);
}
}
|
php
|
public function read()
{
try {
$this->stack->markAsRead(from_route('type', 'notifications'));
return new JsonResponse('', 200);
} catch (Exception $ex) {
Log::alert($ex);
return new JsonResponse(['message' => trans('antares/notifications::messages.sidebar.unable_to_mark_notifications_as_read')], 500);
}
}
|
[
"public",
"function",
"read",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"stack",
"->",
"markAsRead",
"(",
"from_route",
"(",
"'type'",
",",
"'notifications'",
")",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"''",
",",
"200",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"Log",
"::",
"alert",
"(",
"$",
"ex",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"[",
"'message'",
"=>",
"trans",
"(",
"'antares/notifications::messages.sidebar.unable_to_mark_notifications_as_read'",
")",
"]",
",",
"500",
")",
";",
"}",
"}"
] |
Marks notification item as read
@return JsonResponse
|
[
"Marks",
"notification",
"item",
"as",
"read"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/SidebarProcessor.php#L83-L92
|
22,811
|
Danzabar/config-builder
|
src/Files/ConfigFile.php
|
ConfigFile.init
|
public function init($file)
{
try {
$this->load($file);
} catch (Exceptions\FileNotExists $e) {
$this->create($file);
}
}
|
php
|
public function init($file)
{
try {
$this->load($file);
} catch (Exceptions\FileNotExists $e) {
$this->create($file);
}
}
|
[
"public",
"function",
"init",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"file",
")",
";",
"}",
"catch",
"(",
"Exceptions",
"\\",
"FileNotExists",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"create",
"(",
"$",
"file",
")",
";",
"}",
"}"
] |
Attempts loading a file, if its not there, it create its.
@param String $file
@return ConfigFile
@author Dan Cox
|
[
"Attempts",
"loading",
"a",
"file",
"if",
"its",
"not",
"there",
"it",
"create",
"its",
"."
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L96-L106
|
22,812
|
Danzabar/config-builder
|
src/Files/ConfigFile.php
|
ConfigFile.load
|
public function load($file)
{
if(!$this->fs->exists($file))
{
throw new Exceptions\FileNotExists($file);
}
$this->file = $file;
$this->info->load($file);
$this->extension = $this->info->extension;
$this->directory = $this->info->directory;
$this->filename = $this->info->filename;
$this->extracter->load($file, $this->extension)
->extract();
$this->params = $this->extracter->params();
}
|
php
|
public function load($file)
{
if(!$this->fs->exists($file))
{
throw new Exceptions\FileNotExists($file);
}
$this->file = $file;
$this->info->load($file);
$this->extension = $this->info->extension;
$this->directory = $this->info->directory;
$this->filename = $this->info->filename;
$this->extracter->load($file, $this->extension)
->extract();
$this->params = $this->extracter->params();
}
|
[
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fs",
"->",
"exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"FileNotExists",
"(",
"$",
"file",
")",
";",
"}",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"$",
"this",
"->",
"info",
"->",
"load",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"extension",
"=",
"$",
"this",
"->",
"info",
"->",
"extension",
";",
"$",
"this",
"->",
"directory",
"=",
"$",
"this",
"->",
"info",
"->",
"directory",
";",
"$",
"this",
"->",
"filename",
"=",
"$",
"this",
"->",
"info",
"->",
"filename",
";",
"$",
"this",
"->",
"extracter",
"->",
"load",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"extension",
")",
"->",
"extract",
"(",
")",
";",
"$",
"this",
"->",
"params",
"=",
"$",
"this",
"->",
"extracter",
"->",
"params",
"(",
")",
";",
"}"
] |
Loads the file and its details
@param String $file
@return ConfigFile
@author Dan Cox
@throws Exceptions\FileNotExists
|
[
"Loads",
"the",
"file",
"and",
"its",
"details"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L131-L148
|
22,813
|
Danzabar/config-builder
|
src/Files/ConfigFile.php
|
ConfigFile.saveAs
|
public function saveAs($extension = NULL)
{
$extension = (!is_null($extension) ? $extension : $this->extension);
$converter = $this->extracter->converter();
$converter->setExtension($extension);
$data = $converter->toNative($this->params);
// We need to rename the file's extension
$this->rename(NULL, $extension);
$this->fs->dumpFile($this->file, $data);
}
|
php
|
public function saveAs($extension = NULL)
{
$extension = (!is_null($extension) ? $extension : $this->extension);
$converter = $this->extracter->converter();
$converter->setExtension($extension);
$data = $converter->toNative($this->params);
// We need to rename the file's extension
$this->rename(NULL, $extension);
$this->fs->dumpFile($this->file, $data);
}
|
[
"public",
"function",
"saveAs",
"(",
"$",
"extension",
"=",
"NULL",
")",
"{",
"$",
"extension",
"=",
"(",
"!",
"is_null",
"(",
"$",
"extension",
")",
"?",
"$",
"extension",
":",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"converter",
"=",
"$",
"this",
"->",
"extracter",
"->",
"converter",
"(",
")",
";",
"$",
"converter",
"->",
"setExtension",
"(",
"$",
"extension",
")",
";",
"$",
"data",
"=",
"$",
"converter",
"->",
"toNative",
"(",
"$",
"this",
"->",
"params",
")",
";",
"// We need to rename the file's extension",
"$",
"this",
"->",
"rename",
"(",
"NULL",
",",
"$",
"extension",
")",
";",
"$",
"this",
"->",
"fs",
"->",
"dumpFile",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"data",
")",
";",
"}"
] |
Save as a different extension
@param String $extension
@return void
@author Dan Cox
|
[
"Save",
"as",
"a",
"different",
"extension"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L168-L180
|
22,814
|
Danzabar/config-builder
|
src/Files/ConfigFile.php
|
ConfigFile.rename
|
public function rename($file = NULL, $extension = NULL)
{
$target = (!is_null($file) ? $this->filename : $this->extension);
$replacement = (!is_null($file) ? $file .'.'. $this->extension : $extension);
$this->file = str_replace($target, $replacement, $this->file);
}
|
php
|
public function rename($file = NULL, $extension = NULL)
{
$target = (!is_null($file) ? $this->filename : $this->extension);
$replacement = (!is_null($file) ? $file .'.'. $this->extension : $extension);
$this->file = str_replace($target, $replacement, $this->file);
}
|
[
"public",
"function",
"rename",
"(",
"$",
"file",
"=",
"NULL",
",",
"$",
"extension",
"=",
"NULL",
")",
"{",
"$",
"target",
"=",
"(",
"!",
"is_null",
"(",
"$",
"file",
")",
"?",
"$",
"this",
"->",
"filename",
":",
"$",
"this",
"->",
"extension",
")",
";",
"$",
"replacement",
"=",
"(",
"!",
"is_null",
"(",
"$",
"file",
")",
"?",
"$",
"file",
".",
"'.'",
".",
"$",
"this",
"->",
"extension",
":",
"$",
"extension",
")",
";",
"$",
"this",
"->",
"file",
"=",
"str_replace",
"(",
"$",
"target",
",",
"$",
"replacement",
",",
"$",
"this",
"->",
"file",
")",
";",
"}"
] |
Renames a file or changes files extension
@param String $file
@param String $extension
@return void
@author Dan Cox
|
[
"Renames",
"a",
"file",
"or",
"changes",
"files",
"extension"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L190-L196
|
22,815
|
Danzabar/config-builder
|
src/Files/ConfigFile.php
|
ConfigFile.save
|
public function save()
{
$converter = $this->extracter->converter();
$data = $converter->toNative($this->params);
$this->fs->dumpFile($this->file, $data);
}
|
php
|
public function save()
{
$converter = $this->extracter->converter();
$data = $converter->toNative($this->params);
$this->fs->dumpFile($this->file, $data);
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"$",
"converter",
"=",
"$",
"this",
"->",
"extracter",
"->",
"converter",
"(",
")",
";",
"$",
"data",
"=",
"$",
"converter",
"->",
"toNative",
"(",
"$",
"this",
"->",
"params",
")",
";",
"$",
"this",
"->",
"fs",
"->",
"dumpFile",
"(",
"$",
"this",
"->",
"file",
",",
"$",
"data",
")",
";",
"}"
] |
Saves the current params to the file
@return void
@author Dan Cox
|
[
"Saves",
"the",
"current",
"params",
"to",
"the",
"file"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Files/ConfigFile.php#L204-L210
|
22,816
|
hametuha/wpametu
|
src/WPametu/API/Rest/RestTemplate.php
|
RestTemplate.wp_title
|
public function wp_title($title, $sep, $location){
if( !empty($this->title) ){
$array = [$this->title];
$sep = ' '.trim($sep).' ';
if( 'right' == $location ){
$array[] = $sep;
}else{
array_unshift($array, $sep);
}
$title = implode('', $array);
}
return $title;
}
|
php
|
public function wp_title($title, $sep, $location){
if( !empty($this->title) ){
$array = [$this->title];
$sep = ' '.trim($sep).' ';
if( 'right' == $location ){
$array[] = $sep;
}else{
array_unshift($array, $sep);
}
$title = implode('', $array);
}
return $title;
}
|
[
"public",
"function",
"wp_title",
"(",
"$",
"title",
",",
"$",
"sep",
",",
"$",
"location",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"title",
")",
")",
"{",
"$",
"array",
"=",
"[",
"$",
"this",
"->",
"title",
"]",
";",
"$",
"sep",
"=",
"' '",
".",
"trim",
"(",
"$",
"sep",
")",
".",
"' '",
";",
"if",
"(",
"'right'",
"==",
"$",
"location",
")",
"{",
"$",
"array",
"[",
"]",
"=",
"$",
"sep",
";",
"}",
"else",
"{",
"array_unshift",
"(",
"$",
"array",
",",
"$",
"sep",
")",
";",
"}",
"$",
"title",
"=",
"implode",
"(",
"''",
",",
"$",
"array",
")",
";",
"}",
"return",
"$",
"title",
";",
"}"
] |
Filter wp title
@param string $title
@param string $sep
@param string $location
@return string
|
[
"Filter",
"wp",
"title"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/Rest/RestTemplate.php#L85-L97
|
22,817
|
dstuecken/notify
|
src/NotificationCenter.php
|
NotificationCenter.notify
|
public function notify(NotificationInterface $notification, $level = self::INFO)
{
if (!$this->handlers)
{
$this->addHandler(new NullHandler());
}
foreach ($this->getHandlers() as $handler)
{
if ($handler->shouldHandle($notification, $level))
{
if (false === $handler->handle($notification, $level))
{
return false;
}
}
}
return true;
}
|
php
|
public function notify(NotificationInterface $notification, $level = self::INFO)
{
if (!$this->handlers)
{
$this->addHandler(new NullHandler());
}
foreach ($this->getHandlers() as $handler)
{
if ($handler->shouldHandle($notification, $level))
{
if (false === $handler->handle($notification, $level))
{
return false;
}
}
}
return true;
}
|
[
"public",
"function",
"notify",
"(",
"NotificationInterface",
"$",
"notification",
",",
"$",
"level",
"=",
"self",
"::",
"INFO",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"handlers",
")",
"{",
"$",
"this",
"->",
"addHandler",
"(",
"new",
"NullHandler",
"(",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getHandlers",
"(",
")",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"shouldHandle",
"(",
"$",
"notification",
",",
"$",
"level",
")",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"handler",
"->",
"handle",
"(",
"$",
"notification",
",",
"$",
"level",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
Handles notification for every handler
@param NotificationInterface $notification the notification instanceitself
@param int $level Level of this notification
@return bool
|
[
"Handles",
"notification",
"for",
"every",
"handler"
] |
abccf0a6a272caf66baea74323f18e2212c6e11e
|
https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/NotificationCenter.php#L157-L176
|
22,818
|
dstuecken/notify
|
src/NotificationCenter.php
|
NotificationCenter.log
|
public function log($level, $message, array $context = [])
{
return $this->notify(
new DetailedNotification($message, '', $context),
$level
);
}
|
php
|
public function log($level, $message, array $context = [])
{
return $this->notify(
new DetailedNotification($message, '', $context),
$level
);
}
|
[
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"notify",
"(",
"new",
"DetailedNotification",
"(",
"$",
"message",
",",
"''",
",",
"$",
"context",
")",
",",
"$",
"level",
")",
";",
"}"
] |
Adds a new notification message to the queue as an attribute aware notification
@param mixed $level The log level
@param string $message notification message (body)
@param array $context notification parameters
@return bool record processed or not?
|
[
"Adds",
"a",
"new",
"notification",
"message",
"to",
"the",
"queue",
"as",
"an",
"attribute",
"aware",
"notification"
] |
abccf0a6a272caf66baea74323f18e2212c6e11e
|
https://github.com/dstuecken/notify/blob/abccf0a6a272caf66baea74323f18e2212c6e11e/src/NotificationCenter.php#L187-L193
|
22,819
|
ekuiter/feature-php
|
FeaturePhp/Generator/RuntimeGenerator.php
|
RuntimeGenerator._generateFiles
|
protected function _generateFiles() {
if ($this->feature && !$this->isSelectedFeature($this->feature)) {
$this->logFile->log(null, "did not add runtime information because \"$this->feature\" is not selected");
return;
}
$this->files[] = fphp\File\TemplateFile::fromSpecification(
fphp\Specification\TemplateSpecification::fromArrayAndSettings(
array(
"source" => "Runtime.php.template",
"target" => $this->target,
"rules" => array(
array("assign" => "class", "to" => $this->class),
array("assign" => "getter", "to" => $this->getter),
array("assign" => "selectedFeatures", "to" => $this->encodeFeatureNames($this->selectedArtifacts)),
array("assign" => "deselectedFeatures", "to" => $this->encodeFeatureNames($this->deselectedArtifacts))
)
), Settings::inDirectory(__DIR__))
);
}
|
php
|
protected function _generateFiles() {
if ($this->feature && !$this->isSelectedFeature($this->feature)) {
$this->logFile->log(null, "did not add runtime information because \"$this->feature\" is not selected");
return;
}
$this->files[] = fphp\File\TemplateFile::fromSpecification(
fphp\Specification\TemplateSpecification::fromArrayAndSettings(
array(
"source" => "Runtime.php.template",
"target" => $this->target,
"rules" => array(
array("assign" => "class", "to" => $this->class),
array("assign" => "getter", "to" => $this->getter),
array("assign" => "selectedFeatures", "to" => $this->encodeFeatureNames($this->selectedArtifacts)),
array("assign" => "deselectedFeatures", "to" => $this->encodeFeatureNames($this->deselectedArtifacts))
)
), Settings::inDirectory(__DIR__))
);
}
|
[
"protected",
"function",
"_generateFiles",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"feature",
"&&",
"!",
"$",
"this",
"->",
"isSelectedFeature",
"(",
"$",
"this",
"->",
"feature",
")",
")",
"{",
"$",
"this",
"->",
"logFile",
"->",
"log",
"(",
"null",
",",
"\"did not add runtime information because \\\"$this->feature\\\" is not selected\"",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"files",
"[",
"]",
"=",
"fphp",
"\\",
"File",
"\\",
"TemplateFile",
"::",
"fromSpecification",
"(",
"fphp",
"\\",
"Specification",
"\\",
"TemplateSpecification",
"::",
"fromArrayAndSettings",
"(",
"array",
"(",
"\"source\"",
"=>",
"\"Runtime.php.template\"",
",",
"\"target\"",
"=>",
"$",
"this",
"->",
"target",
",",
"\"rules\"",
"=>",
"array",
"(",
"array",
"(",
"\"assign\"",
"=>",
"\"class\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"class",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"getter\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"getter",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"selectedFeatures\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"encodeFeatureNames",
"(",
"$",
"this",
"->",
"selectedArtifacts",
")",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"deselectedFeatures\"",
",",
"\"to\"",
"=>",
"$",
"this",
"->",
"encodeFeatureNames",
"(",
"$",
"this",
"->",
"deselectedArtifacts",
")",
")",
")",
")",
",",
"Settings",
"::",
"inDirectory",
"(",
"__DIR__",
")",
")",
")",
";",
"}"
] |
Generates the runtime file.
Internally, this uses a template file and assigns the given variables.
You can override this to add runtime information for other languages.
If a feature was supplied, only generates if that feature is selected.
|
[
"Generates",
"the",
"runtime",
"file",
".",
"Internally",
"this",
"uses",
"a",
"template",
"file",
"and",
"assigns",
"the",
"given",
"variables",
".",
"You",
"can",
"override",
"this",
"to",
"add",
"runtime",
"information",
"for",
"other",
"languages",
".",
"If",
"a",
"feature",
"was",
"supplied",
"only",
"generates",
"if",
"that",
"feature",
"is",
"selected",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/RuntimeGenerator.php#L87-L106
|
22,820
|
ekuiter/feature-php
|
FeaturePhp/Generator/RuntimeGenerator.php
|
RuntimeGenerator.traceRuntimeCalls
|
public function traceRuntimeCalls($files, $productLine) {
$runtimeCalls = array();
foreach ($files as $file) {
$content = $file->getContent();
if ($content instanceof fphp\File\StoredFileContent) {
$fileSource = $content->getFileSource();
$content = file_get_contents($fileSource);
} else {
$fileSource = "(text file)";
$content = $content->getSummary();
}
foreach (explode("\n", $content) as $idx => $line)
if (strstr($line, "$this->class::$this->getter")) {
preg_match("/$this->class::$this->getter\(.*?[\"'](.*?)[\"'].*?\)/", $line, $matches);
try {
$feature = $productLine->getFeature($matches[1]);
} catch (fphp\Model\ModelException $e) {
throw new RuntimeGeneratorException("invalid runtime feature \"$matches[1]\"");
}
$runtimeCalls[] = new fphp\Artifact\TracingLink(
"runtime",
$productLine->getArtifact($feature),
new fphp\Artifact\LinePlace($fileSource, $idx + 1),
new fphp\Artifact\LinePlace($file->getTarget(), $idx + 1));
}
}
return $runtimeCalls;
}
|
php
|
public function traceRuntimeCalls($files, $productLine) {
$runtimeCalls = array();
foreach ($files as $file) {
$content = $file->getContent();
if ($content instanceof fphp\File\StoredFileContent) {
$fileSource = $content->getFileSource();
$content = file_get_contents($fileSource);
} else {
$fileSource = "(text file)";
$content = $content->getSummary();
}
foreach (explode("\n", $content) as $idx => $line)
if (strstr($line, "$this->class::$this->getter")) {
preg_match("/$this->class::$this->getter\(.*?[\"'](.*?)[\"'].*?\)/", $line, $matches);
try {
$feature = $productLine->getFeature($matches[1]);
} catch (fphp\Model\ModelException $e) {
throw new RuntimeGeneratorException("invalid runtime feature \"$matches[1]\"");
}
$runtimeCalls[] = new fphp\Artifact\TracingLink(
"runtime",
$productLine->getArtifact($feature),
new fphp\Artifact\LinePlace($fileSource, $idx + 1),
new fphp\Artifact\LinePlace($file->getTarget(), $idx + 1));
}
}
return $runtimeCalls;
}
|
[
"public",
"function",
"traceRuntimeCalls",
"(",
"$",
"files",
",",
"$",
"productLine",
")",
"{",
"$",
"runtimeCalls",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"content",
"=",
"$",
"file",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"content",
"instanceof",
"fphp",
"\\",
"File",
"\\",
"StoredFileContent",
")",
"{",
"$",
"fileSource",
"=",
"$",
"content",
"->",
"getFileSource",
"(",
")",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"fileSource",
")",
";",
"}",
"else",
"{",
"$",
"fileSource",
"=",
"\"(text file)\"",
";",
"$",
"content",
"=",
"$",
"content",
"->",
"getSummary",
"(",
")",
";",
"}",
"foreach",
"(",
"explode",
"(",
"\"\\n\"",
",",
"$",
"content",
")",
"as",
"$",
"idx",
"=>",
"$",
"line",
")",
"if",
"(",
"strstr",
"(",
"$",
"line",
",",
"\"$this->class::$this->getter\"",
")",
")",
"{",
"preg_match",
"(",
"\"/$this->class::$this->getter\\(.*?[\\\"'](.*?)[\\\"'].*?\\)/\"",
",",
"$",
"line",
",",
"$",
"matches",
")",
";",
"try",
"{",
"$",
"feature",
"=",
"$",
"productLine",
"->",
"getFeature",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"catch",
"(",
"fphp",
"\\",
"Model",
"\\",
"ModelException",
"$",
"e",
")",
"{",
"throw",
"new",
"RuntimeGeneratorException",
"(",
"\"invalid runtime feature \\\"$matches[1]\\\"\"",
")",
";",
"}",
"$",
"runtimeCalls",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLink",
"(",
"\"runtime\"",
",",
"$",
"productLine",
"->",
"getArtifact",
"(",
"$",
"feature",
")",
",",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"LinePlace",
"(",
"$",
"fileSource",
",",
"$",
"idx",
"+",
"1",
")",
",",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"LinePlace",
"(",
"$",
"file",
"->",
"getTarget",
"(",
")",
",",
"$",
"idx",
"+",
"1",
")",
")",
";",
"}",
"}",
"return",
"$",
"runtimeCalls",
";",
"}"
] |
Returns tracing links for all calls of the runtime class.
@param \FeaturePhp\File\File[] $files
@param \FeaturePhp\ProductLine\ProductLine $productLine
@return \FeaturePhp\Artifact\TracingLink[]
|
[
"Returns",
"tracing",
"links",
"for",
"all",
"calls",
"of",
"the",
"runtime",
"class",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Generator/RuntimeGenerator.php#L114-L144
|
22,821
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout.generateXml
|
public function generateXml()
{
$xml = $this->getUpdate()->asSimplexml();
$removeInstructions = $xml->xpath("//remove");
if (is_array($removeInstructions)) {
foreach ($removeInstructions as $infoNode) {
/** @var Mage_Core_Model_Layout_Element $infoNode */
if (!$this->checkConditionals($infoNode, false)) {
continue;
}
$blockName = trim((string)$infoNode['name']);
if ($blockName) {
$ignoreNodes = $xml->xpath("//block[@name='" . $blockName . "'] | //reference[@name='" . $blockName . "']");
if (is_array($ignoreNodes)) {
foreach ($ignoreNodes as $ignoreNode) {
/** @var Mage_Core_Model_Layout_Element $ignoreNode */
$ignoreNode['ignore'] = true;
}
}
}
}
}
$this->setXml($xml);
return $this;
}
|
php
|
public function generateXml()
{
$xml = $this->getUpdate()->asSimplexml();
$removeInstructions = $xml->xpath("//remove");
if (is_array($removeInstructions)) {
foreach ($removeInstructions as $infoNode) {
/** @var Mage_Core_Model_Layout_Element $infoNode */
if (!$this->checkConditionals($infoNode, false)) {
continue;
}
$blockName = trim((string)$infoNode['name']);
if ($blockName) {
$ignoreNodes = $xml->xpath("//block[@name='" . $blockName . "'] | //reference[@name='" . $blockName . "']");
if (is_array($ignoreNodes)) {
foreach ($ignoreNodes as $ignoreNode) {
/** @var Mage_Core_Model_Layout_Element $ignoreNode */
$ignoreNode['ignore'] = true;
}
}
}
}
}
$this->setXml($xml);
return $this;
}
|
[
"public",
"function",
"generateXml",
"(",
")",
"{",
"$",
"xml",
"=",
"$",
"this",
"->",
"getUpdate",
"(",
")",
"->",
"asSimplexml",
"(",
")",
";",
"$",
"removeInstructions",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"//remove\"",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"removeInstructions",
")",
")",
"{",
"foreach",
"(",
"$",
"removeInstructions",
"as",
"$",
"infoNode",
")",
"{",
"/** @var Mage_Core_Model_Layout_Element $infoNode */",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"infoNode",
",",
"false",
")",
")",
"{",
"continue",
";",
"}",
"$",
"blockName",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"infoNode",
"[",
"'name'",
"]",
")",
";",
"if",
"(",
"$",
"blockName",
")",
"{",
"$",
"ignoreNodes",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"//block[@name='\"",
".",
"$",
"blockName",
".",
"\"'] | //reference[@name='\"",
".",
"$",
"blockName",
".",
"\"']\"",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"ignoreNodes",
")",
")",
"{",
"foreach",
"(",
"$",
"ignoreNodes",
"as",
"$",
"ignoreNode",
")",
"{",
"/** @var Mage_Core_Model_Layout_Element $ignoreNode */",
"$",
"ignoreNode",
"[",
"'ignore'",
"]",
"=",
"true",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"setXml",
"(",
"$",
"xml",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Layout XML generation
@return Aoe_Layout_Model_Layout
|
[
"Layout",
"XML",
"generation"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L14-L38
|
22,822
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout.generateBlocks
|
public function generateBlocks($parent = null)
{
if ($parent instanceof Mage_Core_Model_Layout_Element) {
// This prevents processing child blocks if the parent block fails a conditional check
if (!$this->checkConditionals($parent)) {
return;
}
// This is handled here so it catches 'block' and 'reference' elements
$this->processOutputAttribute($parent);
}
parent::generateBlocks($parent);
}
|
php
|
public function generateBlocks($parent = null)
{
if ($parent instanceof Mage_Core_Model_Layout_Element) {
// This prevents processing child blocks if the parent block fails a conditional check
if (!$this->checkConditionals($parent)) {
return;
}
// This is handled here so it catches 'block' and 'reference' elements
$this->processOutputAttribute($parent);
}
parent::generateBlocks($parent);
}
|
[
"public",
"function",
"generateBlocks",
"(",
"$",
"parent",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"// This prevents processing child blocks if the parent block fails a conditional check",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"parent",
")",
")",
"{",
"return",
";",
"}",
"// This is handled here so it catches 'block' and 'reference' elements",
"$",
"this",
"->",
"processOutputAttribute",
"(",
"$",
"parent",
")",
";",
"}",
"parent",
"::",
"generateBlocks",
"(",
"$",
"parent",
")",
";",
"}"
] |
Create layout blocks hierarchy from layout xml configuration
@param Mage_Core_Model_Layout_Element|null $parent
|
[
"Create",
"layout",
"blocks",
"hierarchy",
"from",
"layout",
"xml",
"configuration"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L45-L58
|
22,823
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout._generateBlock
|
protected function _generateBlock($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
return parent::_generateBlock($node, $parent);
}
|
php
|
protected function _generateBlock($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
return parent::_generateBlock($node, $parent);
}
|
[
"protected",
"function",
"_generateBlock",
"(",
"$",
"node",
",",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"return",
"parent",
"::",
"_generateBlock",
"(",
"$",
"node",
",",
"$",
"parent",
")",
";",
"}"
] |
Add block object to layout based on xml node data
@param Varien_Simplexml_Element $node
@param Varien_Simplexml_Element $parent
@return Aoe_Layout_Model_Layout
|
[
"Add",
"block",
"object",
"to",
"layout",
"based",
"on",
"xml",
"node",
"data"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L68-L77
|
22,824
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout._generateAction
|
protected function _generateAction($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
$method = (string)$node['method'];
if (!empty($node['block'])) {
$parentName = (string)$node['block'];
} else {
$parentName = $parent->getBlockName();
}
$_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
Varien_Profiler::start($_profilerKey);
if (!empty($parentName)) {
$block = $this->getBlock($parentName);
}
if (!empty($block)) {
$args = (array)$node->children();
$jsonArgs = (isset($node['json']) ? explode(' ', (string)$node['json']) : []);
$jsonHelper = Mage::helper('core');
$translateArgs = (isset($node['translate']) ? explode(' ', (string)$node['translate']) : []);
$translateHelper = Mage::helper(isset($node['module']) ? (string)$node['module'] : 'core');
$args = $this->processActionArgs($args, $jsonArgs, $jsonHelper, $translateArgs, $translateHelper);
call_user_func_array([$block, $method], $args);
}
Varien_Profiler::stop($_profilerKey);
return $this;
}
|
php
|
protected function _generateAction($node, $parent)
{
if ($node instanceof Mage_Core_Model_Layout_Element) {
if (!$this->checkConditionals($node)) {
return $this;
}
}
$method = (string)$node['method'];
if (!empty($node['block'])) {
$parentName = (string)$node['block'];
} else {
$parentName = $parent->getBlockName();
}
$_profilerKey = 'BLOCK ACTION: ' . $parentName . ' -> ' . $method;
Varien_Profiler::start($_profilerKey);
if (!empty($parentName)) {
$block = $this->getBlock($parentName);
}
if (!empty($block)) {
$args = (array)$node->children();
$jsonArgs = (isset($node['json']) ? explode(' ', (string)$node['json']) : []);
$jsonHelper = Mage::helper('core');
$translateArgs = (isset($node['translate']) ? explode(' ', (string)$node['translate']) : []);
$translateHelper = Mage::helper(isset($node['module']) ? (string)$node['module'] : 'core');
$args = $this->processActionArgs($args, $jsonArgs, $jsonHelper, $translateArgs, $translateHelper);
call_user_func_array([$block, $method], $args);
}
Varien_Profiler::stop($_profilerKey);
return $this;
}
|
[
"protected",
"function",
"_generateAction",
"(",
"$",
"node",
",",
"$",
"parent",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Mage_Core_Model_Layout_Element",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkConditionals",
"(",
"$",
"node",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"$",
"method",
"=",
"(",
"string",
")",
"$",
"node",
"[",
"'method'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
"[",
"'block'",
"]",
")",
")",
"{",
"$",
"parentName",
"=",
"(",
"string",
")",
"$",
"node",
"[",
"'block'",
"]",
";",
"}",
"else",
"{",
"$",
"parentName",
"=",
"$",
"parent",
"->",
"getBlockName",
"(",
")",
";",
"}",
"$",
"_profilerKey",
"=",
"'BLOCK ACTION: '",
".",
"$",
"parentName",
".",
"' -> '",
".",
"$",
"method",
";",
"Varien_Profiler",
"::",
"start",
"(",
"$",
"_profilerKey",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parentName",
")",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"getBlock",
"(",
"$",
"parentName",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"block",
")",
")",
"{",
"$",
"args",
"=",
"(",
"array",
")",
"$",
"node",
"->",
"children",
"(",
")",
";",
"$",
"jsonArgs",
"=",
"(",
"isset",
"(",
"$",
"node",
"[",
"'json'",
"]",
")",
"?",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"node",
"[",
"'json'",
"]",
")",
":",
"[",
"]",
")",
";",
"$",
"jsonHelper",
"=",
"Mage",
"::",
"helper",
"(",
"'core'",
")",
";",
"$",
"translateArgs",
"=",
"(",
"isset",
"(",
"$",
"node",
"[",
"'translate'",
"]",
")",
"?",
"explode",
"(",
"' '",
",",
"(",
"string",
")",
"$",
"node",
"[",
"'translate'",
"]",
")",
":",
"[",
"]",
")",
";",
"$",
"translateHelper",
"=",
"Mage",
"::",
"helper",
"(",
"isset",
"(",
"$",
"node",
"[",
"'module'",
"]",
")",
"?",
"(",
"string",
")",
"$",
"node",
"[",
"'module'",
"]",
":",
"'core'",
")",
";",
"$",
"args",
"=",
"$",
"this",
"->",
"processActionArgs",
"(",
"$",
"args",
",",
"$",
"jsonArgs",
",",
"$",
"jsonHelper",
",",
"$",
"translateArgs",
",",
"$",
"translateHelper",
")",
";",
"call_user_func_array",
"(",
"[",
"$",
"block",
",",
"$",
"method",
"]",
",",
"$",
"args",
")",
";",
"}",
"Varien_Profiler",
"::",
"stop",
"(",
"$",
"_profilerKey",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Convert an action node into a method call on the parent block
@param Varien_Simplexml_Element $node
@param Varien_Simplexml_Element $parent
@return Aoe_Layout_Model_Layout
|
[
"Convert",
"an",
"action",
"node",
"into",
"a",
"method",
"call",
"on",
"the",
"parent",
"block"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L87-L123
|
22,825
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout.getHelperMethodValue
|
protected function getHelperMethodValue($helperMethodString, $args = null)
{
$helperName = explode('/', (string)$helperMethodString);
$helperMethod = array_pop($helperName);
$helperName = implode('/', $helperName);
$helperArgs = [];
if (!is_array($args)) {
$helperArgs[] = $args;
} else {
$helperArgs = $args;
}
return call_user_func_array([Mage::helper($helperName), $helperMethod], $helperArgs);
}
|
php
|
protected function getHelperMethodValue($helperMethodString, $args = null)
{
$helperName = explode('/', (string)$helperMethodString);
$helperMethod = array_pop($helperName);
$helperName = implode('/', $helperName);
$helperArgs = [];
if (!is_array($args)) {
$helperArgs[] = $args;
} else {
$helperArgs = $args;
}
return call_user_func_array([Mage::helper($helperName), $helperMethod], $helperArgs);
}
|
[
"protected",
"function",
"getHelperMethodValue",
"(",
"$",
"helperMethodString",
",",
"$",
"args",
"=",
"null",
")",
"{",
"$",
"helperName",
"=",
"explode",
"(",
"'/'",
",",
"(",
"string",
")",
"$",
"helperMethodString",
")",
";",
"$",
"helperMethod",
"=",
"array_pop",
"(",
"$",
"helperName",
")",
";",
"$",
"helperName",
"=",
"implode",
"(",
"'/'",
",",
"$",
"helperName",
")",
";",
"$",
"helperArgs",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"$",
"helperArgs",
"[",
"]",
"=",
"$",
"args",
";",
"}",
"else",
"{",
"$",
"helperArgs",
"=",
"$",
"args",
";",
"}",
"return",
"call_user_func_array",
"(",
"[",
"Mage",
"::",
"helper",
"(",
"$",
"helperName",
")",
",",
"$",
"helperMethod",
"]",
",",
"$",
"helperArgs",
")",
";",
"}"
] |
Gets the value of a helper method from the helper method string
@param $helperMethodString
@param array|string $args
@return mixed
|
[
"Gets",
"the",
"value",
"of",
"a",
"helper",
"method",
"from",
"the",
"helper",
"method",
"string"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L188-L202
|
22,826
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout.processOutputAttribute
|
protected function processOutputAttribute(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['output'])) {
$blockName = (string)$node['name'];
if (empty($blockName)) {
return;
}
$method = trim((string)$node['output']);
if (empty($method)) {
$this->removeOutputBlock($blockName);
} else {
$this->addOutputBlock($blockName, $method);
}
}
}
|
php
|
protected function processOutputAttribute(Mage_Core_Model_Layout_Element $node)
{
if (isset($node['output'])) {
$blockName = (string)$node['name'];
if (empty($blockName)) {
return;
}
$method = trim((string)$node['output']);
if (empty($method)) {
$this->removeOutputBlock($blockName);
} else {
$this->addOutputBlock($blockName, $method);
}
}
}
|
[
"protected",
"function",
"processOutputAttribute",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'output'",
"]",
")",
")",
"{",
"$",
"blockName",
"=",
"(",
"string",
")",
"$",
"node",
"[",
"'name'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"blockName",
")",
")",
"{",
"return",
";",
"}",
"$",
"method",
"=",
"trim",
"(",
"(",
"string",
")",
"$",
"node",
"[",
"'output'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"removeOutputBlock",
"(",
"$",
"blockName",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addOutputBlock",
"(",
"$",
"blockName",
",",
"$",
"method",
")",
";",
"}",
"}",
"}"
] |
Process the 'output' attribute of a node
This is an extension that allows the output attribute to be specified on reference elements.
It also adds the ability to disable output of the node by setting the value to an empty string.
@param Mage_Core_Model_Layout_Element $node
|
[
"Process",
"the",
"output",
"attribute",
"of",
"a",
"node"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L212-L226
|
22,827
|
AOEpeople/Aoe_Layout
|
app/code/local/Aoe/Layout/Model/Layout.php
|
Aoe_Layout_Model_Layout.checkConditionals
|
protected function checkConditionals(Mage_Core_Model_Layout_Element $node, $aclDefault = true)
{
return $this->checkConfigConditional($node)
&& ($aclDefault ? $this->checkAclConditional($node, $aclDefault) : !$this->checkAclConditional($node, $aclDefault))
&& $this->checkHelperConditional($node);
}
|
php
|
protected function checkConditionals(Mage_Core_Model_Layout_Element $node, $aclDefault = true)
{
return $this->checkConfigConditional($node)
&& ($aclDefault ? $this->checkAclConditional($node, $aclDefault) : !$this->checkAclConditional($node, $aclDefault))
&& $this->checkHelperConditional($node);
}
|
[
"protected",
"function",
"checkConditionals",
"(",
"Mage_Core_Model_Layout_Element",
"$",
"node",
",",
"$",
"aclDefault",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"checkConfigConditional",
"(",
"$",
"node",
")",
"&&",
"(",
"$",
"aclDefault",
"?",
"$",
"this",
"->",
"checkAclConditional",
"(",
"$",
"node",
",",
"$",
"aclDefault",
")",
":",
"!",
"$",
"this",
"->",
"checkAclConditional",
"(",
"$",
"node",
",",
"$",
"aclDefault",
")",
")",
"&&",
"$",
"this",
"->",
"checkHelperConditional",
"(",
"$",
"node",
")",
";",
"}"
] |
Checks all conditionals for a given layout node
@param Mage_Core_Model_Layout_Element $node
@param bool $aclDefault
@return bool
|
[
"Checks",
"all",
"conditionals",
"for",
"a",
"given",
"layout",
"node"
] |
d88ba3406cf12dbaf09548477133c3cb27d155ed
|
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Model/Layout.php#L236-L241
|
22,828
|
phpnfe/tools
|
src/XML.php
|
XML.getDup
|
public function getDup($contador)
{
$dup = $this->getElementsByTagName('dup')->item($contador);
return self::createByXml($dup->C14N());
}
|
php
|
public function getDup($contador)
{
$dup = $this->getElementsByTagName('dup')->item($contador);
return self::createByXml($dup->C14N());
}
|
[
"public",
"function",
"getDup",
"(",
"$",
"contador",
")",
"{",
"$",
"dup",
"=",
"$",
"this",
"->",
"getElementsByTagName",
"(",
"'dup'",
")",
"->",
"item",
"(",
"$",
"contador",
")",
";",
"return",
"self",
"::",
"createByXml",
"(",
"$",
"dup",
"->",
"C14N",
"(",
")",
")",
";",
"}"
] |
Pega a propriedade do Dup.
@param $contador
@return XMLGet
@deprecated
|
[
"Pega",
"a",
"propriedade",
"do",
"Dup",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/XML.php#L77-L82
|
22,829
|
netvlies/NetvliesFormBundle
|
EventListener/SuccessListener.php
|
SuccessListener.onFormSuccess
|
public function onFormSuccess(FormEvent $event)
{
$form = $event->getForm();
$result = $this->createResult($form);
if ($form->getStoreResults()) {
$this->storeResult($form, $result);
}
if ($form->getSendMail()) {
$this->sendMail($form, $result);
}
$successUrl = $form->getSuccessUrl();
if ($successUrl != null) {
$redirectResponse = new RedirectResponse($successUrl);
$redirectResponse->send();
}
}
|
php
|
public function onFormSuccess(FormEvent $event)
{
$form = $event->getForm();
$result = $this->createResult($form);
if ($form->getStoreResults()) {
$this->storeResult($form, $result);
}
if ($form->getSendMail()) {
$this->sendMail($form, $result);
}
$successUrl = $form->getSuccessUrl();
if ($successUrl != null) {
$redirectResponse = new RedirectResponse($successUrl);
$redirectResponse->send();
}
}
|
[
"public",
"function",
"onFormSuccess",
"(",
"FormEvent",
"$",
"event",
")",
"{",
"$",
"form",
"=",
"$",
"event",
"->",
"getForm",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"createResult",
"(",
"$",
"form",
")",
";",
"if",
"(",
"$",
"form",
"->",
"getStoreResults",
"(",
")",
")",
"{",
"$",
"this",
"->",
"storeResult",
"(",
"$",
"form",
",",
"$",
"result",
")",
";",
"}",
"if",
"(",
"$",
"form",
"->",
"getSendMail",
"(",
")",
")",
"{",
"$",
"this",
"->",
"sendMail",
"(",
"$",
"form",
",",
"$",
"result",
")",
";",
"}",
"$",
"successUrl",
"=",
"$",
"form",
"->",
"getSuccessUrl",
"(",
")",
";",
"if",
"(",
"$",
"successUrl",
"!=",
"null",
")",
"{",
"$",
"redirectResponse",
"=",
"new",
"RedirectResponse",
"(",
"$",
"successUrl",
")",
";",
"$",
"redirectResponse",
"->",
"send",
"(",
")",
";",
"}",
"}"
] |
Default handling for the form success event. This includes storage of
the result, sending a confirmation mail and redirecting to the success
URL, while respecting the form settings.
@param FormEvent $event
|
[
"Default",
"handling",
"for",
"the",
"form",
"success",
"event",
".",
"This",
"includes",
"storage",
"of",
"the",
"result",
"sending",
"a",
"confirmation",
"mail",
"and",
"redirecting",
"to",
"the",
"success",
"URL",
"while",
"respecting",
"the",
"form",
"settings",
"."
] |
93f9a3321d9925040111374e7c1014a6400a2d08
|
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/EventListener/SuccessListener.php#L30-L50
|
22,830
|
netvlies/NetvliesFormBundle
|
EventListener/SuccessListener.php
|
SuccessListener.createResult
|
public function createResult(Form $form)
{
$result = new Result();
$result->setDatetimeAdded(new \DateTime());
$viewData = $form->getSf2Form()->getViewData();
foreach ($form->getFields() as $field) {
$entry = new Entry();
$entry->setField($field);
$entry->setValue($viewData['field_'.$field->getId()]);
$result->addEntry($entry);
}
return $result;
}
|
php
|
public function createResult(Form $form)
{
$result = new Result();
$result->setDatetimeAdded(new \DateTime());
$viewData = $form->getSf2Form()->getViewData();
foreach ($form->getFields() as $field) {
$entry = new Entry();
$entry->setField($field);
$entry->setValue($viewData['field_'.$field->getId()]);
$result->addEntry($entry);
}
return $result;
}
|
[
"public",
"function",
"createResult",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"$",
"result",
"->",
"setDatetimeAdded",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"$",
"viewData",
"=",
"$",
"form",
"->",
"getSf2Form",
"(",
")",
"->",
"getViewData",
"(",
")",
";",
"foreach",
"(",
"$",
"form",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"entry",
"=",
"new",
"Entry",
"(",
")",
";",
"$",
"entry",
"->",
"setField",
"(",
"$",
"field",
")",
";",
"$",
"entry",
"->",
"setValue",
"(",
"$",
"viewData",
"[",
"'field_'",
".",
"$",
"field",
"->",
"getId",
"(",
")",
"]",
")",
";",
"$",
"result",
"->",
"addEntry",
"(",
"$",
"entry",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Creates the result object from the user's input.
@param $form
@return Result
|
[
"Creates",
"the",
"result",
"object",
"from",
"the",
"user",
"s",
"input",
"."
] |
93f9a3321d9925040111374e7c1014a6400a2d08
|
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/EventListener/SuccessListener.php#L59-L74
|
22,831
|
netvlies/NetvliesFormBundle
|
EventListener/SuccessListener.php
|
SuccessListener.storeResult
|
public function storeResult(Form $form, Result $result)
{
$entityManager = $this->container->get('doctrine')->getManager();
$form->addResult($result);
$entityManager->persist($form);
$entityManager->flush();
}
|
php
|
public function storeResult(Form $form, Result $result)
{
$entityManager = $this->container->get('doctrine')->getManager();
$form->addResult($result);
$entityManager->persist($form);
$entityManager->flush();
}
|
[
"public",
"function",
"storeResult",
"(",
"Form",
"$",
"form",
",",
"Result",
"$",
"result",
")",
"{",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine'",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"form",
"->",
"addResult",
"(",
"$",
"result",
")",
";",
"$",
"entityManager",
"->",
"persist",
"(",
"$",
"form",
")",
";",
"$",
"entityManager",
"->",
"flush",
"(",
")",
";",
"}"
] |
Stores the user input as a result object.
@param $form
@param $result
|
[
"Stores",
"the",
"user",
"input",
"as",
"a",
"result",
"object",
"."
] |
93f9a3321d9925040111374e7c1014a6400a2d08
|
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/EventListener/SuccessListener.php#L82-L88
|
22,832
|
netvlies/NetvliesFormBundle
|
EventListener/SuccessListener.php
|
SuccessListener.sendMail
|
public function sendMail(Form $form, Result $result)
{
$message = \Swift_Message::newInstance()
->setSubject($form->getMailSubject())
->setTo(array($form->getMailRecipientEmail() => $form->getMailRecipientName()))
->setBody($this->container->get('templating')->render('NetvliesFormBundle:Mail:result.html.twig', array(
'content' => $form->getMailBody(),
'entries' => $result->getEntries(),
)), 'text/html');
if ($form->getMailSenderName() != null && $form->getMailSenderEmail() != null) {
$message->setFrom(array($form->getMailSenderEmail() => $form->getMailSenderName()));
}
$this->container->get('mailer')->send($message);
$transport = $this->container->get('mailer')->getTransport();
if (!$transport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $transport->getSpool();
if (!$spool instanceof \Swift_MemorySpool) {
return;
}
$spool->flushQueue($this->container->get('swiftmailer.transport.real'));
}
|
php
|
public function sendMail(Form $form, Result $result)
{
$message = \Swift_Message::newInstance()
->setSubject($form->getMailSubject())
->setTo(array($form->getMailRecipientEmail() => $form->getMailRecipientName()))
->setBody($this->container->get('templating')->render('NetvliesFormBundle:Mail:result.html.twig', array(
'content' => $form->getMailBody(),
'entries' => $result->getEntries(),
)), 'text/html');
if ($form->getMailSenderName() != null && $form->getMailSenderEmail() != null) {
$message->setFrom(array($form->getMailSenderEmail() => $form->getMailSenderName()));
}
$this->container->get('mailer')->send($message);
$transport = $this->container->get('mailer')->getTransport();
if (!$transport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $transport->getSpool();
if (!$spool instanceof \Swift_MemorySpool) {
return;
}
$spool->flushQueue($this->container->get('swiftmailer.transport.real'));
}
|
[
"public",
"function",
"sendMail",
"(",
"Form",
"$",
"form",
",",
"Result",
"$",
"result",
")",
"{",
"$",
"message",
"=",
"\\",
"Swift_Message",
"::",
"newInstance",
"(",
")",
"->",
"setSubject",
"(",
"$",
"form",
"->",
"getMailSubject",
"(",
")",
")",
"->",
"setTo",
"(",
"array",
"(",
"$",
"form",
"->",
"getMailRecipientEmail",
"(",
")",
"=>",
"$",
"form",
"->",
"getMailRecipientName",
"(",
")",
")",
")",
"->",
"setBody",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"render",
"(",
"'NetvliesFormBundle:Mail:result.html.twig'",
",",
"array",
"(",
"'content'",
"=>",
"$",
"form",
"->",
"getMailBody",
"(",
")",
",",
"'entries'",
"=>",
"$",
"result",
"->",
"getEntries",
"(",
")",
",",
")",
")",
",",
"'text/html'",
")",
";",
"if",
"(",
"$",
"form",
"->",
"getMailSenderName",
"(",
")",
"!=",
"null",
"&&",
"$",
"form",
"->",
"getMailSenderEmail",
"(",
")",
"!=",
"null",
")",
"{",
"$",
"message",
"->",
"setFrom",
"(",
"array",
"(",
"$",
"form",
"->",
"getMailSenderEmail",
"(",
")",
"=>",
"$",
"form",
"->",
"getMailSenderName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mailer'",
")",
"->",
"send",
"(",
"$",
"message",
")",
";",
"$",
"transport",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'mailer'",
")",
"->",
"getTransport",
"(",
")",
";",
"if",
"(",
"!",
"$",
"transport",
"instanceof",
"\\",
"Swift_Transport_SpoolTransport",
")",
"{",
"return",
";",
"}",
"$",
"spool",
"=",
"$",
"transport",
"->",
"getSpool",
"(",
")",
";",
"if",
"(",
"!",
"$",
"spool",
"instanceof",
"\\",
"Swift_MemorySpool",
")",
"{",
"return",
";",
"}",
"$",
"spool",
"->",
"flushQueue",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'swiftmailer.transport.real'",
")",
")",
";",
"}"
] |
Sends a mail containing the form values to the contact e-mail address
specified.
@param Form $form
@param Result $result
|
[
"Sends",
"a",
"mail",
"containing",
"the",
"form",
"values",
"to",
"the",
"contact",
"e",
"-",
"mail",
"address",
"specified",
"."
] |
93f9a3321d9925040111374e7c1014a6400a2d08
|
https://github.com/netvlies/NetvliesFormBundle/blob/93f9a3321d9925040111374e7c1014a6400a2d08/EventListener/SuccessListener.php#L97-L124
|
22,833
|
SporkCode/Spork
|
src/Log/ServiceFactory.php
|
ServiceFactory.createService
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$appConfig = $serviceLocator->get('config');
$config = array_key_exists('log', $appConfig) ? $appConfig['log'] : array();
$class = array_key_exists('class', $config) ? $config['class'] : 'Zend\Log\Logger';
$logger = new $class($config);
return $logger;
}
|
php
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$appConfig = $serviceLocator->get('config');
$config = array_key_exists('log', $appConfig) ? $appConfig['log'] : array();
$class = array_key_exists('class', $config) ? $config['class'] : 'Zend\Log\Logger';
$logger = new $class($config);
return $logger;
}
|
[
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"appConfig",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'config'",
")",
";",
"$",
"config",
"=",
"array_key_exists",
"(",
"'log'",
",",
"$",
"appConfig",
")",
"?",
"$",
"appConfig",
"[",
"'log'",
"]",
":",
"array",
"(",
")",
";",
"$",
"class",
"=",
"array_key_exists",
"(",
"'class'",
",",
"$",
"config",
")",
"?",
"$",
"config",
"[",
"'class'",
"]",
":",
"'Zend\\Log\\Logger'",
";",
"$",
"logger",
"=",
"new",
"$",
"class",
"(",
"$",
"config",
")",
";",
"return",
"$",
"logger",
";",
"}"
] |
Creates a Logger service
@see \Zend\ServiceManager\FactoryInterface::createService()
@param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
@return \Zend\Log\LoggerInterface
|
[
"Creates",
"a",
"Logger",
"service"
] |
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
|
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Log/ServiceFactory.php#L34-L41
|
22,834
|
opsbears/piccolo
|
src/Module/ModuleLoader.php
|
ModuleLoader.processModules
|
private function processModules(DependencyInjectionContainer $dic, array $modules, array &$config) {
/** @noinspection PhpInternalEntityUsedInspection */
$dependencyGraph = new ModuleDependencyGraph();
$dependencyGraph->addModules($modules);
$modules = $dependencyGraph->getSortedModuleList();
foreach ($modules as $module) {
$this->loadModuleConfiguration($module, $config);
}
foreach ($modules as $module) {
$module->configureDependencyInjection($dic, $config[$module->getModuleKey()], $config);
}
}
|
php
|
private function processModules(DependencyInjectionContainer $dic, array $modules, array &$config) {
/** @noinspection PhpInternalEntityUsedInspection */
$dependencyGraph = new ModuleDependencyGraph();
$dependencyGraph->addModules($modules);
$modules = $dependencyGraph->getSortedModuleList();
foreach ($modules as $module) {
$this->loadModuleConfiguration($module, $config);
}
foreach ($modules as $module) {
$module->configureDependencyInjection($dic, $config[$module->getModuleKey()], $config);
}
}
|
[
"private",
"function",
"processModules",
"(",
"DependencyInjectionContainer",
"$",
"dic",
",",
"array",
"$",
"modules",
",",
"array",
"&",
"$",
"config",
")",
"{",
"/** @noinspection PhpInternalEntityUsedInspection */",
"$",
"dependencyGraph",
"=",
"new",
"ModuleDependencyGraph",
"(",
")",
";",
"$",
"dependencyGraph",
"->",
"addModules",
"(",
"$",
"modules",
")",
";",
"$",
"modules",
"=",
"$",
"dependencyGraph",
"->",
"getSortedModuleList",
"(",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"this",
"->",
"loadModuleConfiguration",
"(",
"$",
"module",
",",
"$",
"config",
")",
";",
"}",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"module",
"->",
"configureDependencyInjection",
"(",
"$",
"dic",
",",
"$",
"config",
"[",
"$",
"module",
"->",
"getModuleKey",
"(",
")",
"]",
",",
"$",
"config",
")",
";",
"}",
"}"
] |
Process modules after initial loading.
@param DependencyInjectionContainer $dic
@param array $modules
@param array $config
|
[
"Process",
"modules",
"after",
"initial",
"loading",
"."
] |
ebba9f892ed35965140265ba1c61b2c645eab6e0
|
https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleLoader.php#L49-L62
|
22,835
|
opsbears/piccolo
|
src/Module/ModuleLoader.php
|
ModuleLoader.loadModule
|
private function loadModule(
$moduleClass,
array &$modules,
array $moduleList,
DependencyInjectionContainer $dic) {
/**
* @var Module $module
*/
$module = $dic->make($moduleClass);
if (!$module instanceof Module) {
throw new ConfigurationException(get_class($module) .
' was configured as a module, but doesn\'t implement ' . Module::class);
}
if (!\in_array($module, $modules)) {
$dic->share($module);
$this->loadRequiredModules($module, $modules, $moduleList, $dic);
$modules[] = $module;
}
}
|
php
|
private function loadModule(
$moduleClass,
array &$modules,
array $moduleList,
DependencyInjectionContainer $dic) {
/**
* @var Module $module
*/
$module = $dic->make($moduleClass);
if (!$module instanceof Module) {
throw new ConfigurationException(get_class($module) .
' was configured as a module, but doesn\'t implement ' . Module::class);
}
if (!\in_array($module, $modules)) {
$dic->share($module);
$this->loadRequiredModules($module, $modules, $moduleList, $dic);
$modules[] = $module;
}
}
|
[
"private",
"function",
"loadModule",
"(",
"$",
"moduleClass",
",",
"array",
"&",
"$",
"modules",
",",
"array",
"$",
"moduleList",
",",
"DependencyInjectionContainer",
"$",
"dic",
")",
"{",
"/**\n\t\t * @var Module $module\n\t\t */",
"$",
"module",
"=",
"$",
"dic",
"->",
"make",
"(",
"$",
"moduleClass",
")",
";",
"if",
"(",
"!",
"$",
"module",
"instanceof",
"Module",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"get_class",
"(",
"$",
"module",
")",
".",
"' was configured as a module, but doesn\\'t implement '",
".",
"Module",
"::",
"class",
")",
";",
"}",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"module",
",",
"$",
"modules",
")",
")",
"{",
"$",
"dic",
"->",
"share",
"(",
"$",
"module",
")",
";",
"$",
"this",
"->",
"loadRequiredModules",
"(",
"$",
"module",
",",
"$",
"modules",
",",
"$",
"moduleList",
",",
"$",
"dic",
")",
";",
"$",
"modules",
"[",
"]",
"=",
"$",
"module",
";",
"}",
"}"
] |
Load a module by class name.
@param string $moduleClass The module class to load.
@param Module[] $modules The list of already loaded modules.
@param array $moduleList The complete module list.
@param DependencyInjectionContainer $dic The dependency injection container to use for the module.
@return void
@throws ConfigurationException
|
[
"Load",
"a",
"module",
"by",
"class",
"name",
"."
] |
ebba9f892ed35965140265ba1c61b2c645eab6e0
|
https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleLoader.php#L76-L98
|
22,836
|
opsbears/piccolo
|
src/Module/ModuleLoader.php
|
ModuleLoader.loadRequiredModules
|
private function loadRequiredModules(
Module $module,
&$modules,
array $moduleList,
DependencyInjectionContainer $dic) {
foreach ($module->getRequiredModules() as $requiredModule) {
if (!\in_array($requiredModule, $moduleList)) {
$this->loadModule($requiredModule, $modules, $moduleList, $dic);
if ($module instanceof RequiredModuleAwareModule) {
$module->addRequiredModule($dic->make($requiredModule));
}
}
}
}
|
php
|
private function loadRequiredModules(
Module $module,
&$modules,
array $moduleList,
DependencyInjectionContainer $dic) {
foreach ($module->getRequiredModules() as $requiredModule) {
if (!\in_array($requiredModule, $moduleList)) {
$this->loadModule($requiredModule, $modules, $moduleList, $dic);
if ($module instanceof RequiredModuleAwareModule) {
$module->addRequiredModule($dic->make($requiredModule));
}
}
}
}
|
[
"private",
"function",
"loadRequiredModules",
"(",
"Module",
"$",
"module",
",",
"&",
"$",
"modules",
",",
"array",
"$",
"moduleList",
",",
"DependencyInjectionContainer",
"$",
"dic",
")",
"{",
"foreach",
"(",
"$",
"module",
"->",
"getRequiredModules",
"(",
")",
"as",
"$",
"requiredModule",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"requiredModule",
",",
"$",
"moduleList",
")",
")",
"{",
"$",
"this",
"->",
"loadModule",
"(",
"$",
"requiredModule",
",",
"$",
"modules",
",",
"$",
"moduleList",
",",
"$",
"dic",
")",
";",
"if",
"(",
"$",
"module",
"instanceof",
"RequiredModuleAwareModule",
")",
"{",
"$",
"module",
"->",
"addRequiredModule",
"(",
"$",
"dic",
"->",
"make",
"(",
"$",
"requiredModule",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
Load the modules a certain module requires.
@param Module $module
@param Module[] $modules
@param array $moduleList
@param DependencyInjectionContainer $dic
|
[
"Load",
"the",
"modules",
"a",
"certain",
"module",
"requires",
"."
] |
ebba9f892ed35965140265ba1c61b2c645eab6e0
|
https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleLoader.php#L108-L121
|
22,837
|
opsbears/piccolo
|
src/Module/ModuleLoader.php
|
ModuleLoader.loadModuleConfiguration
|
private function loadModuleConfiguration(Module $module, array &$config) {
$key = $module->getModuleKey();
if (!isset($config[$key])) {
$config[$key] = array();
}
$module->loadConfiguration($config[$key], $config);
}
|
php
|
private function loadModuleConfiguration(Module $module, array &$config) {
$key = $module->getModuleKey();
if (!isset($config[$key])) {
$config[$key] = array();
}
$module->loadConfiguration($config[$key], $config);
}
|
[
"private",
"function",
"loadModuleConfiguration",
"(",
"Module",
"$",
"module",
",",
"array",
"&",
"$",
"config",
")",
"{",
"$",
"key",
"=",
"$",
"module",
"->",
"getModuleKey",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"config",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"module",
"->",
"loadConfiguration",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
",",
"$",
"config",
")",
";",
"}"
] |
Load the configuration for a specific module.
@param Module $module
@param array $config
@return void
|
[
"Load",
"the",
"configuration",
"for",
"a",
"specific",
"module",
"."
] |
ebba9f892ed35965140265ba1c61b2c645eab6e0
|
https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleLoader.php#L131-L137
|
22,838
|
mothership-ec/composer
|
src/Composer/DependencyResolver/Problem.php
|
Problem.addRule
|
public function addRule(Rule $rule)
{
$this->addReason($rule->getId(), array(
'rule' => $rule,
'job' => $rule->getJob(),
));
}
|
php
|
public function addRule(Rule $rule)
{
$this->addReason($rule->getId(), array(
'rule' => $rule,
'job' => $rule->getJob(),
));
}
|
[
"public",
"function",
"addRule",
"(",
"Rule",
"$",
"rule",
")",
"{",
"$",
"this",
"->",
"addReason",
"(",
"$",
"rule",
"->",
"getId",
"(",
")",
",",
"array",
"(",
"'rule'",
"=>",
"$",
"rule",
",",
"'job'",
"=>",
"$",
"rule",
"->",
"getJob",
"(",
")",
",",
")",
")",
";",
"}"
] |
Add a rule as a reason
@param Rule $rule A rule which is a reason for this problem
|
[
"Add",
"a",
"rule",
"as",
"a",
"reason"
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/Problem.php#L48-L54
|
22,839
|
mothership-ec/composer
|
src/Composer/DependencyResolver/Problem.php
|
Problem.jobToText
|
protected function jobToText($job)
{
switch ($job['cmd']) {
case 'install':
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
if (!$packages) {
return 'No package found to satisfy install request for '.$job['packageName'].$this->constraintToText($job['constraint']);
}
return 'Installation request for '.$job['packageName'].$this->constraintToText($job['constraint']).' -> satisfiable by '.$this->getPackageList($packages).'.';
case 'update':
return 'Update request for '.$job['packageName'].$this->constraintToText($job['constraint']).'.';
case 'remove':
return 'Removal request for '.$job['packageName'].$this->constraintToText($job['constraint']).'';
}
if (isset($job['constraint'])) {
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
} else {
$packages = array();
}
return 'Job(cmd='.$job['cmd'].', target='.$job['packageName'].', packages=['.$this->getPackageList($packages).'])';
}
|
php
|
protected function jobToText($job)
{
switch ($job['cmd']) {
case 'install':
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
if (!$packages) {
return 'No package found to satisfy install request for '.$job['packageName'].$this->constraintToText($job['constraint']);
}
return 'Installation request for '.$job['packageName'].$this->constraintToText($job['constraint']).' -> satisfiable by '.$this->getPackageList($packages).'.';
case 'update':
return 'Update request for '.$job['packageName'].$this->constraintToText($job['constraint']).'.';
case 'remove':
return 'Removal request for '.$job['packageName'].$this->constraintToText($job['constraint']).'';
}
if (isset($job['constraint'])) {
$packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
} else {
$packages = array();
}
return 'Job(cmd='.$job['cmd'].', target='.$job['packageName'].', packages=['.$this->getPackageList($packages).'])';
}
|
[
"protected",
"function",
"jobToText",
"(",
"$",
"job",
")",
"{",
"switch",
"(",
"$",
"job",
"[",
"'cmd'",
"]",
")",
"{",
"case",
"'install'",
":",
"$",
"packages",
"=",
"$",
"this",
"->",
"pool",
"->",
"whatProvides",
"(",
"$",
"job",
"[",
"'packageName'",
"]",
",",
"$",
"job",
"[",
"'constraint'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"packages",
")",
"{",
"return",
"'No package found to satisfy install request for '",
".",
"$",
"job",
"[",
"'packageName'",
"]",
".",
"$",
"this",
"->",
"constraintToText",
"(",
"$",
"job",
"[",
"'constraint'",
"]",
")",
";",
"}",
"return",
"'Installation request for '",
".",
"$",
"job",
"[",
"'packageName'",
"]",
".",
"$",
"this",
"->",
"constraintToText",
"(",
"$",
"job",
"[",
"'constraint'",
"]",
")",
".",
"' -> satisfiable by '",
".",
"$",
"this",
"->",
"getPackageList",
"(",
"$",
"packages",
")",
".",
"'.'",
";",
"case",
"'update'",
":",
"return",
"'Update request for '",
".",
"$",
"job",
"[",
"'packageName'",
"]",
".",
"$",
"this",
"->",
"constraintToText",
"(",
"$",
"job",
"[",
"'constraint'",
"]",
")",
".",
"'.'",
";",
"case",
"'remove'",
":",
"return",
"'Removal request for '",
".",
"$",
"job",
"[",
"'packageName'",
"]",
".",
"$",
"this",
"->",
"constraintToText",
"(",
"$",
"job",
"[",
"'constraint'",
"]",
")",
".",
"''",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"job",
"[",
"'constraint'",
"]",
")",
")",
"{",
"$",
"packages",
"=",
"$",
"this",
"->",
"pool",
"->",
"whatProvides",
"(",
"$",
"job",
"[",
"'packageName'",
"]",
",",
"$",
"job",
"[",
"'constraint'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"packages",
"=",
"array",
"(",
")",
";",
"}",
"return",
"'Job(cmd='",
".",
"$",
"job",
"[",
"'cmd'",
"]",
".",
"', target='",
".",
"$",
"job",
"[",
"'packageName'",
"]",
".",
"', packages=['",
".",
"$",
"this",
"->",
"getPackageList",
"(",
"$",
"packages",
")",
".",
"'])'",
";",
"}"
] |
Turns a job into a human readable description
@param array $job
@return string
|
[
"Turns",
"a",
"job",
"into",
"a",
"human",
"readable",
"description"
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/Problem.php#L179-L202
|
22,840
|
ShaoZeMing/laravel-merchant
|
src/Form/NestedForm.php
|
NestedForm.getTemplateHtmlAndScript
|
public function getTemplateHtmlAndScript()
{
$html = '';
$scripts = [];
/* @var Field $field */
foreach ($this->fields() as $field) {
//when field render, will push $script to Merchant
$html .= $field->render();
/*
* Get and remove the last script of Merchant::$script stack.
*/
if ($field->getScript()) {
$scripts[] = array_pop(Merchant::$script);
}
}
return [$html, implode("\r\n", $scripts)];
}
|
php
|
public function getTemplateHtmlAndScript()
{
$html = '';
$scripts = [];
/* @var Field $field */
foreach ($this->fields() as $field) {
//when field render, will push $script to Merchant
$html .= $field->render();
/*
* Get and remove the last script of Merchant::$script stack.
*/
if ($field->getScript()) {
$scripts[] = array_pop(Merchant::$script);
}
}
return [$html, implode("\r\n", $scripts)];
}
|
[
"public",
"function",
"getTemplateHtmlAndScript",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"scripts",
"=",
"[",
"]",
";",
"/* @var Field $field */",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"//when field render, will push $script to Merchant",
"$",
"html",
".=",
"$",
"field",
"->",
"render",
"(",
")",
";",
"/*\n * Get and remove the last script of Merchant::$script stack.\n */",
"if",
"(",
"$",
"field",
"->",
"getScript",
"(",
")",
")",
"{",
"$",
"scripts",
"[",
"]",
"=",
"array_pop",
"(",
"Merchant",
"::",
"$",
"script",
")",
";",
"}",
"}",
"return",
"[",
"$",
"html",
",",
"implode",
"(",
"\"\\r\\n\"",
",",
"$",
"scripts",
")",
"]",
";",
"}"
] |
Get the html and script of template.
@return array
|
[
"Get",
"the",
"html",
"and",
"script",
"of",
"template",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/NestedForm.php#L307-L327
|
22,841
|
ShaoZeMing/laravel-merchant
|
src/Form/NestedForm.php
|
NestedForm.formatField
|
protected function formatField(Field $field)
{
$column = $field->column();
$elementName = $elementClass = $errorKey = [];
$key = $this->key ?: 'new_'.static::DEFAULT_KEY_NAME;
if (is_array($column)) {
foreach ($column as $k => $name) {
$errorKey[$k] = sprintf('%s.%s.%s', $this->relationName, $key, $name);
$elementName[$k] = sprintf('%s[%s][%s]', $this->relationName, $key, $name);
$elementClass[$k] = [$this->relationName, $name];
}
} else {
$errorKey = sprintf('%s.%s.%s', $this->relationName, $key, $column);
$elementName = sprintf('%s[%s][%s]', $this->relationName, $key, $column);
$elementClass = [$this->relationName, $column];
}
return $field->setErrorKey($errorKey)
->setElementName($elementName)
->setElementClass($elementClass);
}
|
php
|
protected function formatField(Field $field)
{
$column = $field->column();
$elementName = $elementClass = $errorKey = [];
$key = $this->key ?: 'new_'.static::DEFAULT_KEY_NAME;
if (is_array($column)) {
foreach ($column as $k => $name) {
$errorKey[$k] = sprintf('%s.%s.%s', $this->relationName, $key, $name);
$elementName[$k] = sprintf('%s[%s][%s]', $this->relationName, $key, $name);
$elementClass[$k] = [$this->relationName, $name];
}
} else {
$errorKey = sprintf('%s.%s.%s', $this->relationName, $key, $column);
$elementName = sprintf('%s[%s][%s]', $this->relationName, $key, $column);
$elementClass = [$this->relationName, $column];
}
return $field->setErrorKey($errorKey)
->setElementName($elementName)
->setElementClass($elementClass);
}
|
[
"protected",
"function",
"formatField",
"(",
"Field",
"$",
"field",
")",
"{",
"$",
"column",
"=",
"$",
"field",
"->",
"column",
"(",
")",
";",
"$",
"elementName",
"=",
"$",
"elementClass",
"=",
"$",
"errorKey",
"=",
"[",
"]",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"key",
"?",
":",
"'new_'",
".",
"static",
"::",
"DEFAULT_KEY_NAME",
";",
"if",
"(",
"is_array",
"(",
"$",
"column",
")",
")",
"{",
"foreach",
"(",
"$",
"column",
"as",
"$",
"k",
"=>",
"$",
"name",
")",
"{",
"$",
"errorKey",
"[",
"$",
"k",
"]",
"=",
"sprintf",
"(",
"'%s.%s.%s'",
",",
"$",
"this",
"->",
"relationName",
",",
"$",
"key",
",",
"$",
"name",
")",
";",
"$",
"elementName",
"[",
"$",
"k",
"]",
"=",
"sprintf",
"(",
"'%s[%s][%s]'",
",",
"$",
"this",
"->",
"relationName",
",",
"$",
"key",
",",
"$",
"name",
")",
";",
"$",
"elementClass",
"[",
"$",
"k",
"]",
"=",
"[",
"$",
"this",
"->",
"relationName",
",",
"$",
"name",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"errorKey",
"=",
"sprintf",
"(",
"'%s.%s.%s'",
",",
"$",
"this",
"->",
"relationName",
",",
"$",
"key",
",",
"$",
"column",
")",
";",
"$",
"elementName",
"=",
"sprintf",
"(",
"'%s[%s][%s]'",
",",
"$",
"this",
"->",
"relationName",
",",
"$",
"key",
",",
"$",
"column",
")",
";",
"$",
"elementClass",
"=",
"[",
"$",
"this",
"->",
"relationName",
",",
"$",
"column",
"]",
";",
"}",
"return",
"$",
"field",
"->",
"setErrorKey",
"(",
"$",
"errorKey",
")",
"->",
"setElementName",
"(",
"$",
"elementName",
")",
"->",
"setElementClass",
"(",
"$",
"elementClass",
")",
";",
"}"
] |
Set `errorKey` `elementName` `elementClass` for fields inside hasmany fields.
@param Field $field
@return Field
|
[
"Set",
"errorKey",
"elementName",
"elementClass",
"for",
"fields",
"inside",
"hasmany",
"fields",
"."
] |
20801b1735e7832a6e58b37c2c391328f8d626fa
|
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/NestedForm.php#L336-L359
|
22,842
|
nabab/bbn
|
src/bbn/util/enc.php
|
enc.encryptOpenssl
|
public static function encryptOpenssl($textToEncrypt, string $secretHash = null, string $password = ''): ? string
{
if ( !$secretHash ){
$secretHash = self::$salt;
}
if ( $length = openssl_cipher_iv_length(self::$method) ){
$iv = substr(md5(self::$prefix.$password), 0, $length);
return openssl_encrypt($textToEncrypt, self::$method, $secretHash, true, $iv);
}
return null;
}
|
php
|
public static function encryptOpenssl($textToEncrypt, string $secretHash = null, string $password = ''): ? string
{
if ( !$secretHash ){
$secretHash = self::$salt;
}
if ( $length = openssl_cipher_iv_length(self::$method) ){
$iv = substr(md5(self::$prefix.$password), 0, $length);
return openssl_encrypt($textToEncrypt, self::$method, $secretHash, true, $iv);
}
return null;
}
|
[
"public",
"static",
"function",
"encryptOpenssl",
"(",
"$",
"textToEncrypt",
",",
"string",
"$",
"secretHash",
"=",
"null",
",",
"string",
"$",
"password",
"=",
"''",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"secretHash",
")",
"{",
"$",
"secretHash",
"=",
"self",
"::",
"$",
"salt",
";",
"}",
"if",
"(",
"$",
"length",
"=",
"openssl_cipher_iv_length",
"(",
"self",
"::",
"$",
"method",
")",
")",
"{",
"$",
"iv",
"=",
"substr",
"(",
"md5",
"(",
"self",
"::",
"$",
"prefix",
".",
"$",
"password",
")",
",",
"0",
",",
"$",
"length",
")",
";",
"return",
"openssl_encrypt",
"(",
"$",
"textToEncrypt",
",",
"self",
"::",
"$",
"method",
",",
"$",
"secretHash",
",",
"true",
",",
"$",
"iv",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Encrypt string using openSSL module
@param string $textToEncrypt
@param string $secretHash Any random secure SALT string for your website
@param string $password User's optional password
@return null|string
|
[
"Encrypt",
"string",
"using",
"openSSL",
"module"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/enc.php#L92-L102
|
22,843
|
nabab/bbn
|
src/bbn/util/enc.php
|
enc.decryptOpenssl
|
public static function decryptOpenssl($textToDecrypt, string $secretHash = null, string $password = ''): ? string
{
if ( !$secretHash ){
$secretHash = self::$salt;
}
if ( $length = openssl_cipher_iv_length(self::$method) ){
$iv = substr(md5(self::$prefix.$password), 0, $length);
return openssl_decrypt($textToDecrypt, self::$method, $secretHash, true, $iv);
}
return null;
}
|
php
|
public static function decryptOpenssl($textToDecrypt, string $secretHash = null, string $password = ''): ? string
{
if ( !$secretHash ){
$secretHash = self::$salt;
}
if ( $length = openssl_cipher_iv_length(self::$method) ){
$iv = substr(md5(self::$prefix.$password), 0, $length);
return openssl_decrypt($textToDecrypt, self::$method, $secretHash, true, $iv);
}
return null;
}
|
[
"public",
"static",
"function",
"decryptOpenssl",
"(",
"$",
"textToDecrypt",
",",
"string",
"$",
"secretHash",
"=",
"null",
",",
"string",
"$",
"password",
"=",
"''",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"secretHash",
")",
"{",
"$",
"secretHash",
"=",
"self",
"::",
"$",
"salt",
";",
"}",
"if",
"(",
"$",
"length",
"=",
"openssl_cipher_iv_length",
"(",
"self",
"::",
"$",
"method",
")",
")",
"{",
"$",
"iv",
"=",
"substr",
"(",
"md5",
"(",
"self",
"::",
"$",
"prefix",
".",
"$",
"password",
")",
",",
"0",
",",
"$",
"length",
")",
";",
"return",
"openssl_decrypt",
"(",
"$",
"textToDecrypt",
",",
"self",
"::",
"$",
"method",
",",
"$",
"secretHash",
",",
"true",
",",
"$",
"iv",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Decrypt string using openSSL module
@param string $textToDecrypt
@param string $secretHash Any random secure SALT string for your website
@param string $password User's optional password
@return null|string
|
[
"Decrypt",
"string",
"using",
"openSSL",
"module"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/util/enc.php#L111-L121
|
22,844
|
FriendsOfApi/phraseapp
|
src/Api/Upload.php
|
Upload.upload
|
public function upload(string $projectKey, string $ext, string $filename, array $params)
{
if (!file_exists($filename)) {
throw new Exception\InvalidArgumentException('file '.$filename.' not found');
}
if (!isset($params['locale_id'])) {
throw new Exception\InvalidArgumentException('locale_id is missing in params');
}
$postData = [
['name' => 'file', 'content' => file_get_contents($filename), 'filename' => basename($filename)],
['name' => 'file_format', 'content' => $ext],
['name' => 'locale_id', 'content' => $params['locale_id']],
];
if (isset($params['update_translations'])) {
$postData[] = ['name' => 'update_translations', 'content' => $params['update_translations']];
}
if (isset($params['tags'])) {
$postData[] = ['name' => 'tags', 'content' => $params['tags']];
}
$response = $this->httpPostRaw(sprintf('/api/v2/projects/%s/uploads', $projectKey), $postData, [
'Content-Type' => 'application/x-www-form-urlencoded',
]);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Uploaded::class);
}
|
php
|
public function upload(string $projectKey, string $ext, string $filename, array $params)
{
if (!file_exists($filename)) {
throw new Exception\InvalidArgumentException('file '.$filename.' not found');
}
if (!isset($params['locale_id'])) {
throw new Exception\InvalidArgumentException('locale_id is missing in params');
}
$postData = [
['name' => 'file', 'content' => file_get_contents($filename), 'filename' => basename($filename)],
['name' => 'file_format', 'content' => $ext],
['name' => 'locale_id', 'content' => $params['locale_id']],
];
if (isset($params['update_translations'])) {
$postData[] = ['name' => 'update_translations', 'content' => $params['update_translations']];
}
if (isset($params['tags'])) {
$postData[] = ['name' => 'tags', 'content' => $params['tags']];
}
$response = $this->httpPostRaw(sprintf('/api/v2/projects/%s/uploads', $projectKey), $postData, [
'Content-Type' => 'application/x-www-form-urlencoded',
]);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Uploaded::class);
}
|
[
"public",
"function",
"upload",
"(",
"string",
"$",
"projectKey",
",",
"string",
"$",
"ext",
",",
"string",
"$",
"filename",
",",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'file '",
".",
"$",
"filename",
".",
"' not found'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'locale_id'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'locale_id is missing in params'",
")",
";",
"}",
"$",
"postData",
"=",
"[",
"[",
"'name'",
"=>",
"'file'",
",",
"'content'",
"=>",
"file_get_contents",
"(",
"$",
"filename",
")",
",",
"'filename'",
"=>",
"basename",
"(",
"$",
"filename",
")",
"]",
",",
"[",
"'name'",
"=>",
"'file_format'",
",",
"'content'",
"=>",
"$",
"ext",
"]",
",",
"[",
"'name'",
"=>",
"'locale_id'",
",",
"'content'",
"=>",
"$",
"params",
"[",
"'locale_id'",
"]",
"]",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'update_translations'",
"]",
")",
")",
"{",
"$",
"postData",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"'update_translations'",
",",
"'content'",
"=>",
"$",
"params",
"[",
"'update_translations'",
"]",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
")",
"{",
"$",
"postData",
"[",
"]",
"=",
"[",
"'name'",
"=>",
"'tags'",
",",
"'content'",
"=>",
"$",
"params",
"[",
"'tags'",
"]",
"]",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"httpPostRaw",
"(",
"sprintf",
"(",
"'/api/v2/projects/%s/uploads'",
",",
"$",
"projectKey",
")",
",",
"$",
"postData",
",",
"[",
"'Content-Type'",
"=>",
"'application/x-www-form-urlencoded'",
",",
"]",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"201",
")",
"{",
"$",
"this",
"->",
"handleErrors",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"response",
",",
"Uploaded",
"::",
"class",
")",
";",
"}"
] |
Upload a locale.
@param string $projectKey
@param string $ext
@param string $filename
@param array $params
@throws Exception
@return Uploaded|ResponseInterface
|
[
"Upload",
"a",
"locale",
"."
] |
1553bf857eb0858f9a7eb905b085864d24f80886
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Upload.php#L33-L70
|
22,845
|
LeaseCloud/leasecloud-php-sdk
|
src/HttpClient/CurlClient.php
|
CurlClient.request
|
public function request($method, $absUrl, $params, $headers)
{
$curl = curl_init();
$method = strtolower($method);
$opts = array();
if ($method == 'get') {
$opts[CURLOPT_HTTPGET] = 1;
if (count($params) > 0) {
$encoded = self::urlEncode($params);
$absUrl = "$absUrl?$encoded";
}
} elseif ($method == 'post') {
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = json_encode($params);
} elseif ($method == 'delete') {
$opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
if (count($params) > 0) {
$encoded = self::urlEncode($params);
$absUrl = "$absUrl?$encoded";
}
} else {
throw new Error("Unrecognized method $method");
}
// Create a callback to capture HTTP headers for the response
$rheaders = array();
$headerCallback = function ($curl, $header_line) use (&$rheaders) {
// Ignore the HTTP request line (HTTP/1.1 200 OK)
if (strpos($header_line, ":") === false) {
return strlen($header_line);
}
list($key, $value) = explode(":", trim($header_line), 2);
$rheaders[trim($key)] = trim($value);
return strlen($header_line);
};
// By default for large request body sizes (> 1024 bytes), cURL will
// send a request without a body and with a `Expect: 100-continue`
// header, which gives the server a chance to respond with an error
// status code in cases where one can be determined right away (say
// on an authentication problem for example), and saves the "large"
// request body from being ever sent.
//
// Unfortunately, the bindings don't currently correctly handle the
// success case (in which the server sends back a 100 CONTINUE), so
// we'll error under that condition. To compensate for that problem
// for the time being, override cURL's behavior by simply always
// sending an empty `Expect:` header.
array_push($headers, 'Expect: ');
$opts[CURLOPT_URL] = $absUrl;
$opts[CURLOPT_RETURNTRANSFER] = true;
$opts[CURLOPT_CONNECTTIMEOUT] = 80;
$opts[CURLOPT_TIMEOUT] = 30;
$opts[CURLOPT_HEADERFUNCTION] = $headerCallback;
$opts[CURLOPT_HTTPHEADER] = $headers;
curl_setopt_array($curl, $opts);
$rbody = curl_exec($curl);
if ($rbody === false) {
$errno = curl_errno($curl);
$message = curl_error($curl);
curl_close($curl);
$this->handleCurlError($errno, $message);
}
$rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
return array(json_decode($rbody), $rcode, $rheaders);
}
|
php
|
public function request($method, $absUrl, $params, $headers)
{
$curl = curl_init();
$method = strtolower($method);
$opts = array();
if ($method == 'get') {
$opts[CURLOPT_HTTPGET] = 1;
if (count($params) > 0) {
$encoded = self::urlEncode($params);
$absUrl = "$absUrl?$encoded";
}
} elseif ($method == 'post') {
$opts[CURLOPT_POST] = 1;
$opts[CURLOPT_POSTFIELDS] = json_encode($params);
} elseif ($method == 'delete') {
$opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
if (count($params) > 0) {
$encoded = self::urlEncode($params);
$absUrl = "$absUrl?$encoded";
}
} else {
throw new Error("Unrecognized method $method");
}
// Create a callback to capture HTTP headers for the response
$rheaders = array();
$headerCallback = function ($curl, $header_line) use (&$rheaders) {
// Ignore the HTTP request line (HTTP/1.1 200 OK)
if (strpos($header_line, ":") === false) {
return strlen($header_line);
}
list($key, $value) = explode(":", trim($header_line), 2);
$rheaders[trim($key)] = trim($value);
return strlen($header_line);
};
// By default for large request body sizes (> 1024 bytes), cURL will
// send a request without a body and with a `Expect: 100-continue`
// header, which gives the server a chance to respond with an error
// status code in cases where one can be determined right away (say
// on an authentication problem for example), and saves the "large"
// request body from being ever sent.
//
// Unfortunately, the bindings don't currently correctly handle the
// success case (in which the server sends back a 100 CONTINUE), so
// we'll error under that condition. To compensate for that problem
// for the time being, override cURL's behavior by simply always
// sending an empty `Expect:` header.
array_push($headers, 'Expect: ');
$opts[CURLOPT_URL] = $absUrl;
$opts[CURLOPT_RETURNTRANSFER] = true;
$opts[CURLOPT_CONNECTTIMEOUT] = 80;
$opts[CURLOPT_TIMEOUT] = 30;
$opts[CURLOPT_HEADERFUNCTION] = $headerCallback;
$opts[CURLOPT_HTTPHEADER] = $headers;
curl_setopt_array($curl, $opts);
$rbody = curl_exec($curl);
if ($rbody === false) {
$errno = curl_errno($curl);
$message = curl_error($curl);
curl_close($curl);
$this->handleCurlError($errno, $message);
}
$rcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
return array(json_decode($rbody), $rcode, $rheaders);
}
|
[
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"absUrl",
",",
"$",
"params",
",",
"$",
"headers",
")",
"{",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"$",
"method",
"=",
"strtolower",
"(",
"$",
"method",
")",
";",
"$",
"opts",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"method",
"==",
"'get'",
")",
"{",
"$",
"opts",
"[",
"CURLOPT_HTTPGET",
"]",
"=",
"1",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
">",
"0",
")",
"{",
"$",
"encoded",
"=",
"self",
"::",
"urlEncode",
"(",
"$",
"params",
")",
";",
"$",
"absUrl",
"=",
"\"$absUrl?$encoded\"",
";",
"}",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'post'",
")",
"{",
"$",
"opts",
"[",
"CURLOPT_POST",
"]",
"=",
"1",
";",
"$",
"opts",
"[",
"CURLOPT_POSTFIELDS",
"]",
"=",
"json_encode",
"(",
"$",
"params",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'delete'",
")",
"{",
"$",
"opts",
"[",
"CURLOPT_CUSTOMREQUEST",
"]",
"=",
"'DELETE'",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
">",
"0",
")",
"{",
"$",
"encoded",
"=",
"self",
"::",
"urlEncode",
"(",
"$",
"params",
")",
";",
"$",
"absUrl",
"=",
"\"$absUrl?$encoded\"",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"\"Unrecognized method $method\"",
")",
";",
"}",
"// Create a callback to capture HTTP headers for the response",
"$",
"rheaders",
"=",
"array",
"(",
")",
";",
"$",
"headerCallback",
"=",
"function",
"(",
"$",
"curl",
",",
"$",
"header_line",
")",
"use",
"(",
"&",
"$",
"rheaders",
")",
"{",
"// Ignore the HTTP request line (HTTP/1.1 200 OK)",
"if",
"(",
"strpos",
"(",
"$",
"header_line",
",",
"\":\"",
")",
"===",
"false",
")",
"{",
"return",
"strlen",
"(",
"$",
"header_line",
")",
";",
"}",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"\":\"",
",",
"trim",
"(",
"$",
"header_line",
")",
",",
"2",
")",
";",
"$",
"rheaders",
"[",
"trim",
"(",
"$",
"key",
")",
"]",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"return",
"strlen",
"(",
"$",
"header_line",
")",
";",
"}",
";",
"// By default for large request body sizes (> 1024 bytes), cURL will",
"// send a request without a body and with a `Expect: 100-continue`",
"// header, which gives the server a chance to respond with an error",
"// status code in cases where one can be determined right away (say",
"// on an authentication problem for example), and saves the \"large\"",
"// request body from being ever sent.",
"//",
"// Unfortunately, the bindings don't currently correctly handle the",
"// success case (in which the server sends back a 100 CONTINUE), so",
"// we'll error under that condition. To compensate for that problem",
"// for the time being, override cURL's behavior by simply always",
"// sending an empty `Expect:` header.",
"array_push",
"(",
"$",
"headers",
",",
"'Expect: '",
")",
";",
"$",
"opts",
"[",
"CURLOPT_URL",
"]",
"=",
"$",
"absUrl",
";",
"$",
"opts",
"[",
"CURLOPT_RETURNTRANSFER",
"]",
"=",
"true",
";",
"$",
"opts",
"[",
"CURLOPT_CONNECTTIMEOUT",
"]",
"=",
"80",
";",
"$",
"opts",
"[",
"CURLOPT_TIMEOUT",
"]",
"=",
"30",
";",
"$",
"opts",
"[",
"CURLOPT_HEADERFUNCTION",
"]",
"=",
"$",
"headerCallback",
";",
"$",
"opts",
"[",
"CURLOPT_HTTPHEADER",
"]",
"=",
"$",
"headers",
";",
"curl_setopt_array",
"(",
"$",
"curl",
",",
"$",
"opts",
")",
";",
"$",
"rbody",
"=",
"curl_exec",
"(",
"$",
"curl",
")",
";",
"if",
"(",
"$",
"rbody",
"===",
"false",
")",
"{",
"$",
"errno",
"=",
"curl_errno",
"(",
"$",
"curl",
")",
";",
"$",
"message",
"=",
"curl_error",
"(",
"$",
"curl",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"$",
"this",
"->",
"handleCurlError",
"(",
"$",
"errno",
",",
"$",
"message",
")",
";",
"}",
"$",
"rcode",
"=",
"curl_getinfo",
"(",
"$",
"curl",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"return",
"array",
"(",
"json_decode",
"(",
"$",
"rbody",
")",
",",
"$",
"rcode",
",",
"$",
"rheaders",
")",
";",
"}"
] |
Make the request
@param string $method
@param string $absUrl
@param array $params
@param array $headers
@return array A zero indexed array.
0 => Response
1 => Response http code
2 => Array of response headers
|
[
"Make",
"the",
"request"
] |
091b073dd4f79ba915a68c0ed151bd9bfa61e7ca
|
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/HttpClient/CurlClient.php#L43-L115
|
22,846
|
LeaseCloud/leasecloud-php-sdk
|
src/HttpClient/CurlClient.php
|
CurlClient.handleCurlError
|
private function handleCurlError($errno, $message)
{
switch ($errno) {
case CURLE_COULDNT_CONNECT:
case CURLE_COULDNT_RESOLVE_HOST:
case CURLE_OPERATION_TIMEOUTED:
$msg = "Could not connect";
break;
case CURLE_SSL_CACERT:
case CURLE_SSL_PEER_CERTIFICATE:
$msg = "Could not verify SSL certificate.";
break;
default:
$msg = "Unexpected curl error.";
}
$msg .= "\n\n(Network error [errno $errno]: $message)";
throw new \LeaseCloud\Error($msg);
}
|
php
|
private function handleCurlError($errno, $message)
{
switch ($errno) {
case CURLE_COULDNT_CONNECT:
case CURLE_COULDNT_RESOLVE_HOST:
case CURLE_OPERATION_TIMEOUTED:
$msg = "Could not connect";
break;
case CURLE_SSL_CACERT:
case CURLE_SSL_PEER_CERTIFICATE:
$msg = "Could not verify SSL certificate.";
break;
default:
$msg = "Unexpected curl error.";
}
$msg .= "\n\n(Network error [errno $errno]: $message)";
throw new \LeaseCloud\Error($msg);
}
|
[
"private",
"function",
"handleCurlError",
"(",
"$",
"errno",
",",
"$",
"message",
")",
"{",
"switch",
"(",
"$",
"errno",
")",
"{",
"case",
"CURLE_COULDNT_CONNECT",
":",
"case",
"CURLE_COULDNT_RESOLVE_HOST",
":",
"case",
"CURLE_OPERATION_TIMEOUTED",
":",
"$",
"msg",
"=",
"\"Could not connect\"",
";",
"break",
";",
"case",
"CURLE_SSL_CACERT",
":",
"case",
"CURLE_SSL_PEER_CERTIFICATE",
":",
"$",
"msg",
"=",
"\"Could not verify SSL certificate.\"",
";",
"break",
";",
"default",
":",
"$",
"msg",
"=",
"\"Unexpected curl error.\"",
";",
"}",
"$",
"msg",
".=",
"\"\\n\\n(Network error [errno $errno]: $message)\"",
";",
"throw",
"new",
"\\",
"LeaseCloud",
"\\",
"Error",
"(",
"$",
"msg",
")",
";",
"}"
] |
Throw an exception with message indicating type of http error
@param number $errno
@param string $message
@throws Error
|
[
"Throw",
"an",
"exception",
"with",
"message",
"indicating",
"type",
"of",
"http",
"error"
] |
091b073dd4f79ba915a68c0ed151bd9bfa61e7ca
|
https://github.com/LeaseCloud/leasecloud-php-sdk/blob/091b073dd4f79ba915a68c0ed151bd9bfa61e7ca/src/HttpClient/CurlClient.php#L124-L142
|
22,847
|
tompedals/radish
|
src/Broker/QueueCollection.php
|
QueueCollection.pop
|
public function pop()
{
$keys = array_keys($this->queues);
for ($this->queueCounter; isset($keys[$this->queueCounter]); $this->queueCounter++) {
$queue = $this->queues[$keys[$this->queueCounter]];
$message = $queue->pop();
if ($message !== null) {
$this->queueCounter++;
$this->processedMessages++;
return $message;
}
// After the last queue has been popped
if ((count($this->queues) -1) === $this->queueCounter) {
$this->queueCounter = 0;
if ($this->processedMessages === 0) {
return null;
}
$this->processedMessages = 0;
}
}
return null;
}
|
php
|
public function pop()
{
$keys = array_keys($this->queues);
for ($this->queueCounter; isset($keys[$this->queueCounter]); $this->queueCounter++) {
$queue = $this->queues[$keys[$this->queueCounter]];
$message = $queue->pop();
if ($message !== null) {
$this->queueCounter++;
$this->processedMessages++;
return $message;
}
// After the last queue has been popped
if ((count($this->queues) -1) === $this->queueCounter) {
$this->queueCounter = 0;
if ($this->processedMessages === 0) {
return null;
}
$this->processedMessages = 0;
}
}
return null;
}
|
[
"public",
"function",
"pop",
"(",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"queues",
")",
";",
"for",
"(",
"$",
"this",
"->",
"queueCounter",
";",
"isset",
"(",
"$",
"keys",
"[",
"$",
"this",
"->",
"queueCounter",
"]",
")",
";",
"$",
"this",
"->",
"queueCounter",
"++",
")",
"{",
"$",
"queue",
"=",
"$",
"this",
"->",
"queues",
"[",
"$",
"keys",
"[",
"$",
"this",
"->",
"queueCounter",
"]",
"]",
";",
"$",
"message",
"=",
"$",
"queue",
"->",
"pop",
"(",
")",
";",
"if",
"(",
"$",
"message",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"queueCounter",
"++",
";",
"$",
"this",
"->",
"processedMessages",
"++",
";",
"return",
"$",
"message",
";",
"}",
"// After the last queue has been popped",
"if",
"(",
"(",
"count",
"(",
"$",
"this",
"->",
"queues",
")",
"-",
"1",
")",
"===",
"$",
"this",
"->",
"queueCounter",
")",
"{",
"$",
"this",
"->",
"queueCounter",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"processedMessages",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"processedMessages",
"=",
"0",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the next message from each queue until all are empty
@return Message|null
|
[
"Returns",
"the",
"next",
"message",
"from",
"each",
"queue",
"until",
"all",
"are",
"empty"
] |
7728567ae6226a5e3f627116118198b22d1b507d
|
https://github.com/tompedals/radish/blob/7728567ae6226a5e3f627116118198b22d1b507d/src/Broker/QueueCollection.php#L66-L94
|
22,848
|
thelia-modules/CustomerGroup
|
EventListener/ModuleEventListener.php
|
ModuleEventListener.loadCustomerGroupConfigFile
|
public function loadCustomerGroupConfigFile(ModuleToggleActivationEvent $event)
{
$event->setModule(ModuleQuery::create()->findPk($event->getModuleId()));
if ($event->getModule()->getActivate() === BaseModule::IS_NOT_ACTIVATED) {
$this->configurationFileHandler->loadConfigurationFile($event->getModule());
}
}
|
php
|
public function loadCustomerGroupConfigFile(ModuleToggleActivationEvent $event)
{
$event->setModule(ModuleQuery::create()->findPk($event->getModuleId()));
if ($event->getModule()->getActivate() === BaseModule::IS_NOT_ACTIVATED) {
$this->configurationFileHandler->loadConfigurationFile($event->getModule());
}
}
|
[
"public",
"function",
"loadCustomerGroupConfigFile",
"(",
"ModuleToggleActivationEvent",
"$",
"event",
")",
"{",
"$",
"event",
"->",
"setModule",
"(",
"ModuleQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"event",
"->",
"getModuleId",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"event",
"->",
"getModule",
"(",
")",
"->",
"getActivate",
"(",
")",
"===",
"BaseModule",
"::",
"IS_NOT_ACTIVATED",
")",
"{",
"$",
"this",
"->",
"configurationFileHandler",
"->",
"loadConfigurationFile",
"(",
"$",
"event",
"->",
"getModule",
"(",
")",
")",
";",
"}",
"}"
] |
Load customer group definitions
@param ModuleToggleActivationEvent $event A module toggle activation event
|
[
"Load",
"customer",
"group",
"definitions"
] |
672cc64c686812f6a95cf0d702111f93d8c0e850
|
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/EventListener/ModuleEventListener.php#L44-L51
|
22,849
|
heidelpay/PhpDoc
|
src/phpDocumentor/Compiler/Pass/MarkerFromTagsExtractor.php
|
MarkerFromTagsExtractor.getFileDescriptor
|
protected function getFileDescriptor($element)
{
$fileDescriptor = $element instanceof FileDescriptor
? $element
: $element->getFile();
if (!$fileDescriptor instanceof FileDescriptor) {
throw new \UnexpectedValueException('An element should always have a file associated with it');
}
return $fileDescriptor;
}
|
php
|
protected function getFileDescriptor($element)
{
$fileDescriptor = $element instanceof FileDescriptor
? $element
: $element->getFile();
if (!$fileDescriptor instanceof FileDescriptor) {
throw new \UnexpectedValueException('An element should always have a file associated with it');
}
return $fileDescriptor;
}
|
[
"protected",
"function",
"getFileDescriptor",
"(",
"$",
"element",
")",
"{",
"$",
"fileDescriptor",
"=",
"$",
"element",
"instanceof",
"FileDescriptor",
"?",
"$",
"element",
":",
"$",
"element",
"->",
"getFile",
"(",
")",
";",
"if",
"(",
"!",
"$",
"fileDescriptor",
"instanceof",
"FileDescriptor",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'An element should always have a file associated with it'",
")",
";",
"}",
"return",
"$",
"fileDescriptor",
";",
"}"
] |
Retrieves the File Descriptor from the given element.
@param DescriptorAbstract $element
@throws \UnexpectedValueException if the provided element does not have a file associated with it.
@return FileDescriptor
|
[
"Retrieves",
"the",
"File",
"Descriptor",
"from",
"the",
"given",
"element",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/MarkerFromTagsExtractor.php#L66-L77
|
22,850
|
gn36/phpbb-oo-posting-api
|
src/Gn36/OoPostingApi/post.php
|
post.reindex
|
function reindex($mode, $post_id, $message, $subject, $poster_id, $forum_id)
{
global $config, $phpbb_root_path, $phpEx;
// Select the search method and do some additional checks to ensure it can actually be utilised
$search_type = basename($config['search_type']);
if (!file_exists($phpbb_root_path . 'phpbb/search/' . $search_type . '.' . $phpEx))
{
trigger_error('NO_SUCH_SEARCH_MODULE', E_USER_ERROR);
}
require_once("{$phpbb_root_path}phpbb/search/$search_type.$phpEx");
$search_type = "\\phpbb\\search\\" . $search_type;
$error = false;
$search = new $search_type($error);
if ($error)
{
trigger_error($error);
}
$search->index($mode, $post_id, $message, $subject, $poster_id, $forum_id);
}
|
php
|
function reindex($mode, $post_id, $message, $subject, $poster_id, $forum_id)
{
global $config, $phpbb_root_path, $phpEx;
// Select the search method and do some additional checks to ensure it can actually be utilised
$search_type = basename($config['search_type']);
if (!file_exists($phpbb_root_path . 'phpbb/search/' . $search_type . '.' . $phpEx))
{
trigger_error('NO_SUCH_SEARCH_MODULE', E_USER_ERROR);
}
require_once("{$phpbb_root_path}phpbb/search/$search_type.$phpEx");
$search_type = "\\phpbb\\search\\" . $search_type;
$error = false;
$search = new $search_type($error);
if ($error)
{
trigger_error($error);
}
$search->index($mode, $post_id, $message, $subject, $poster_id, $forum_id);
}
|
[
"function",
"reindex",
"(",
"$",
"mode",
",",
"$",
"post_id",
",",
"$",
"message",
",",
"$",
"subject",
",",
"$",
"poster_id",
",",
"$",
"forum_id",
")",
"{",
"global",
"$",
"config",
",",
"$",
"phpbb_root_path",
",",
"$",
"phpEx",
";",
"// Select the search method and do some additional checks to ensure it can actually be utilised",
"$",
"search_type",
"=",
"basename",
"(",
"$",
"config",
"[",
"'search_type'",
"]",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"phpbb_root_path",
".",
"'phpbb/search/'",
".",
"$",
"search_type",
".",
"'.'",
".",
"$",
"phpEx",
")",
")",
"{",
"trigger_error",
"(",
"'NO_SUCH_SEARCH_MODULE'",
",",
"E_USER_ERROR",
")",
";",
"}",
"require_once",
"(",
"\"{$phpbb_root_path}phpbb/search/$search_type.$phpEx\"",
")",
";",
"$",
"search_type",
"=",
"\"\\\\phpbb\\\\search\\\\\"",
".",
"$",
"search_type",
";",
"$",
"error",
"=",
"false",
";",
"$",
"search",
"=",
"new",
"$",
"search_type",
"(",
"$",
"error",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"trigger_error",
"(",
"$",
"error",
")",
";",
"}",
"$",
"search",
"->",
"index",
"(",
"$",
"mode",
",",
"$",
"post_id",
",",
"$",
"message",
",",
"$",
"subject",
",",
"$",
"poster_id",
",",
"$",
"forum_id",
")",
";",
"}"
] |
Reindex post in search
@param string $mode
@param int $post_id
@param string $message
@param string $subject
@param int $poster_id
@param int $forum_id
|
[
"Reindex",
"post",
"in",
"search"
] |
d0e19482a9e1e93a435c1758a66df9324145381a
|
https://github.com/gn36/phpbb-oo-posting-api/blob/d0e19482a9e1e93a435c1758a66df9324145381a/src/Gn36/OoPostingApi/post.php#L384-L407
|
22,851
|
nabab/bbn
|
src/bbn/appui/imessages.php
|
imessages.from_notes
|
private function from_notes(array $messages, $simple = true){
if ( !empty($messages) ){
foreach ( $messages as $idx => $mess ){
if ( empty($mess['id_note']) ){
unset($messages[$idx]);
continue;
}
$note = $this->notes->get($mess['id_note']);
$note = [
'id' => $mess['id'],
'title' => $note['title'],
'content' => $note['content']
];
if ( $simple ){
$messages[$idx] = $note;
}
else {
$messages[$idx] = \bbn\x::merge_arrays($messages[$idx], $note);
}
}
}
return $messages;
}
|
php
|
private function from_notes(array $messages, $simple = true){
if ( !empty($messages) ){
foreach ( $messages as $idx => $mess ){
if ( empty($mess['id_note']) ){
unset($messages[$idx]);
continue;
}
$note = $this->notes->get($mess['id_note']);
$note = [
'id' => $mess['id'],
'title' => $note['title'],
'content' => $note['content']
];
if ( $simple ){
$messages[$idx] = $note;
}
else {
$messages[$idx] = \bbn\x::merge_arrays($messages[$idx], $note);
}
}
}
return $messages;
}
|
[
"private",
"function",
"from_notes",
"(",
"array",
"$",
"messages",
",",
"$",
"simple",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"messages",
")",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"idx",
"=>",
"$",
"mess",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"mess",
"[",
"'id_note'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"messages",
"[",
"$",
"idx",
"]",
")",
";",
"continue",
";",
"}",
"$",
"note",
"=",
"$",
"this",
"->",
"notes",
"->",
"get",
"(",
"$",
"mess",
"[",
"'id_note'",
"]",
")",
";",
"$",
"note",
"=",
"[",
"'id'",
"=>",
"$",
"mess",
"[",
"'id'",
"]",
",",
"'title'",
"=>",
"$",
"note",
"[",
"'title'",
"]",
",",
"'content'",
"=>",
"$",
"note",
"[",
"'content'",
"]",
"]",
";",
"if",
"(",
"$",
"simple",
")",
"{",
"$",
"messages",
"[",
"$",
"idx",
"]",
"=",
"$",
"note",
";",
"}",
"else",
"{",
"$",
"messages",
"[",
"$",
"idx",
"]",
"=",
"\\",
"bbn",
"\\",
"x",
"::",
"merge_arrays",
"(",
"$",
"messages",
"[",
"$",
"idx",
"]",
",",
"$",
"note",
")",
";",
"}",
"}",
"}",
"return",
"$",
"messages",
";",
"}"
] |
Gets internal messages' info from notes archive
@param array $messages
@param bool $simple
@return array
|
[
"Gets",
"internal",
"messages",
"info",
"from",
"notes",
"archive"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/imessages.php#L85-L107
|
22,852
|
nabab/bbn
|
src/bbn/appui/imessages.php
|
imessages.insert
|
public function insert($imess){
$cfg =& $this->class_cfg;
// Get default page if it isn't set
if ( empty($imess['id_option']) ){
$perm = new \bbn\user\permissions();
$imess['id_option'] = $perm->is(self::BBN_DEFAULT_PERM);
}
if (
!empty($imess['id_option']) &&
!empty($imess['title']) &&
!empty($imess['content']) &&
!empty($this->_id_type()) &&
// Insert the new note
($id_note = $this->notes->insert($imess['title'], $imess['content'], $this->_id_type())) &&
// Insert the new internal message
$this->db->insert($cfg['table'], [
$cfg['arch']['imessages']['id_note'] => $id_note,
$cfg['arch']['imessages']['id_option'] => $imess['id_option'],
$cfg['arch']['imessages']['id_user'] => $imess['id_user'] ?: NULL,
$cfg['arch']['imessages']['id_group'] => $imess['id_group'] ?: NULL,
$cfg['arch']['imessages']['start'] => $imess['start'] ?: NULL,
$cfg['arch']['imessages']['end'] => $imess['end'] ?: NULL
])
){
return $this->db->last_id();
}
return false;
}
|
php
|
public function insert($imess){
$cfg =& $this->class_cfg;
// Get default page if it isn't set
if ( empty($imess['id_option']) ){
$perm = new \bbn\user\permissions();
$imess['id_option'] = $perm->is(self::BBN_DEFAULT_PERM);
}
if (
!empty($imess['id_option']) &&
!empty($imess['title']) &&
!empty($imess['content']) &&
!empty($this->_id_type()) &&
// Insert the new note
($id_note = $this->notes->insert($imess['title'], $imess['content'], $this->_id_type())) &&
// Insert the new internal message
$this->db->insert($cfg['table'], [
$cfg['arch']['imessages']['id_note'] => $id_note,
$cfg['arch']['imessages']['id_option'] => $imess['id_option'],
$cfg['arch']['imessages']['id_user'] => $imess['id_user'] ?: NULL,
$cfg['arch']['imessages']['id_group'] => $imess['id_group'] ?: NULL,
$cfg['arch']['imessages']['start'] => $imess['start'] ?: NULL,
$cfg['arch']['imessages']['end'] => $imess['end'] ?: NULL
])
){
return $this->db->last_id();
}
return false;
}
|
[
"public",
"function",
"insert",
"(",
"$",
"imess",
")",
"{",
"$",
"cfg",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
";",
"// Get default page if it isn't set",
"if",
"(",
"empty",
"(",
"$",
"imess",
"[",
"'id_option'",
"]",
")",
")",
"{",
"$",
"perm",
"=",
"new",
"\\",
"bbn",
"\\",
"user",
"\\",
"permissions",
"(",
")",
";",
"$",
"imess",
"[",
"'id_option'",
"]",
"=",
"$",
"perm",
"->",
"is",
"(",
"self",
"::",
"BBN_DEFAULT_PERM",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"imess",
"[",
"'id_option'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"imess",
"[",
"'title'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"imess",
"[",
"'content'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"_id_type",
"(",
")",
")",
"&&",
"// Insert the new note",
"(",
"$",
"id_note",
"=",
"$",
"this",
"->",
"notes",
"->",
"insert",
"(",
"$",
"imess",
"[",
"'title'",
"]",
",",
"$",
"imess",
"[",
"'content'",
"]",
",",
"$",
"this",
"->",
"_id_type",
"(",
")",
")",
")",
"&&",
"// Insert the new internal message",
"$",
"this",
"->",
"db",
"->",
"insert",
"(",
"$",
"cfg",
"[",
"'table'",
"]",
",",
"[",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'imessages'",
"]",
"[",
"'id_note'",
"]",
"=>",
"$",
"id_note",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'imessages'",
"]",
"[",
"'id_option'",
"]",
"=>",
"$",
"imess",
"[",
"'id_option'",
"]",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'imessages'",
"]",
"[",
"'id_user'",
"]",
"=>",
"$",
"imess",
"[",
"'id_user'",
"]",
"?",
":",
"NULL",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'imessages'",
"]",
"[",
"'id_group'",
"]",
"=>",
"$",
"imess",
"[",
"'id_group'",
"]",
"?",
":",
"NULL",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'imessages'",
"]",
"[",
"'start'",
"]",
"=>",
"$",
"imess",
"[",
"'start'",
"]",
"?",
":",
"NULL",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'imessages'",
"]",
"[",
"'end'",
"]",
"=>",
"$",
"imess",
"[",
"'end'",
"]",
"?",
":",
"NULL",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"last_id",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Inserts a new page's internal message
@param $imess
@return bool|int
|
[
"Inserts",
"a",
"new",
"page",
"s",
"internal",
"message"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/imessages.php#L126-L153
|
22,853
|
nabab/bbn
|
src/bbn/appui/imessages.php
|
imessages.get
|
public function get(string $id_option, string $id_user, $simple = true){
$cfg =& $this->class_cfg;
// Current datetime
$now = date('Y-m-d H:i:s');
// Get the user's group
$id_group = $this->db->select_one('bbn_users', 'id_group', ['id' => $id_user]);
// Get the page's internal messages of the user
$messages = $this->db->get_rows("
SELECT {$cfg['table']}.*
FROM {$cfg['tables']['users']}
RIGHT JOIN {$cfg['table']}
ON {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']}
WHERE (
{$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ?
)
AND (
{$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ?
)
AND (
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ?
OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ?
OR (
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL
AND {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL
)
)
AND {$cfg['table']}.{$cfg['arch']['imessages']['id_option']} = ?
AND (
{$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL
OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0
)",
$now,
$now,
hex2bin($id_user),
hex2bin($id_group),
hex2bin($id_option)
);
// Get and return the imessage's content|title from notes archive
return $this->from_notes($messages, $simple);
}
|
php
|
public function get(string $id_option, string $id_user, $simple = true){
$cfg =& $this->class_cfg;
// Current datetime
$now = date('Y-m-d H:i:s');
// Get the user's group
$id_group = $this->db->select_one('bbn_users', 'id_group', ['id' => $id_user]);
// Get the page's internal messages of the user
$messages = $this->db->get_rows("
SELECT {$cfg['table']}.*
FROM {$cfg['tables']['users']}
RIGHT JOIN {$cfg['table']}
ON {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']}
WHERE (
{$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ?
)
AND (
{$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ?
)
AND (
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ?
OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ?
OR (
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL
AND {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL
)
)
AND {$cfg['table']}.{$cfg['arch']['imessages']['id_option']} = ?
AND (
{$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL
OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0
)",
$now,
$now,
hex2bin($id_user),
hex2bin($id_group),
hex2bin($id_option)
);
// Get and return the imessage's content|title from notes archive
return $this->from_notes($messages, $simple);
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"id_option",
",",
"string",
"$",
"id_user",
",",
"$",
"simple",
"=",
"true",
")",
"{",
"$",
"cfg",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
";",
"// Current datetime",
"$",
"now",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"// Get the user's group",
"$",
"id_group",
"=",
"$",
"this",
"->",
"db",
"->",
"select_one",
"(",
"'bbn_users'",
",",
"'id_group'",
",",
"[",
"'id'",
"=>",
"$",
"id_user",
"]",
")",
";",
"// Get the page's internal messages of the user",
"$",
"messages",
"=",
"$",
"this",
"->",
"db",
"->",
"get_rows",
"(",
"\"\n SELECT {$cfg['table']}.*\n FROM {$cfg['tables']['users']}\n RIGHT JOIN {$cfg['table']}\n\t ON {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']}\n WHERE (\n {$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL\n OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ?\n )\n AND (\n {$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL\n OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ?\n )\n AND (\n {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ?\n OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ?\n OR (\n {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL\n AND {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL\n )\n )\n AND {$cfg['table']}.{$cfg['arch']['imessages']['id_option']} = ?\n AND (\n {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL\n OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0\n )\"",
",",
"$",
"now",
",",
"$",
"now",
",",
"hex2bin",
"(",
"$",
"id_user",
")",
",",
"hex2bin",
"(",
"$",
"id_group",
")",
",",
"hex2bin",
"(",
"$",
"id_option",
")",
")",
";",
"// Get and return the imessage's content|title from notes archive",
"return",
"$",
"this",
"->",
"from_notes",
"(",
"$",
"messages",
",",
"$",
"simple",
")",
";",
"}"
] |
Gets the page's internal messages of an user
@param string $id_option
@param string $id_user
@param bool $simple
@return array
|
[
"Gets",
"the",
"page",
"s",
"internal",
"messages",
"of",
"an",
"user"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/imessages.php#L163-L204
|
22,854
|
nabab/bbn
|
src/bbn/appui/imessages.php
|
imessages.set_hidden
|
public function set_hidden(string $id_imess, string $id_user){
$cfg =& $this->class_cfg;
if ( !empty($id_imess) && !empty($id_user) ){
return !!$this->db->insert_update($cfg['tables']['users'], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user,
$cfg['arch']['users']['hidden'] => 1,
$cfg['arch']['users']['moment'] => date('Y-m-d H:i:s'),
], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user
]);
}
return false;
}
|
php
|
public function set_hidden(string $id_imess, string $id_user){
$cfg =& $this->class_cfg;
if ( !empty($id_imess) && !empty($id_user) ){
return !!$this->db->insert_update($cfg['tables']['users'], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user,
$cfg['arch']['users']['hidden'] => 1,
$cfg['arch']['users']['moment'] => date('Y-m-d H:i:s'),
], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user
]);
}
return false;
}
|
[
"public",
"function",
"set_hidden",
"(",
"string",
"$",
"id_imess",
",",
"string",
"$",
"id_user",
")",
"{",
"$",
"cfg",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"id_imess",
")",
"&&",
"!",
"empty",
"(",
"$",
"id_user",
")",
")",
"{",
"return",
"!",
"!",
"$",
"this",
"->",
"db",
"->",
"insert_update",
"(",
"$",
"cfg",
"[",
"'tables'",
"]",
"[",
"'users'",
"]",
",",
"[",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_imessage'",
"]",
"=>",
"$",
"id_imess",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_user'",
"]",
"=>",
"$",
"id_user",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'hidden'",
"]",
"=>",
"1",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'moment'",
"]",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
",",
"[",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_imessage'",
"]",
"=>",
"$",
"id_imess",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_user'",
"]",
"=>",
"$",
"id_user",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Sets an user's internal message as visible
@param string $id_imess
@param string $id_user
@return bool
|
[
"Sets",
"an",
"user",
"s",
"internal",
"message",
"as",
"visible"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/imessages.php#L213-L227
|
22,855
|
nabab/bbn
|
src/bbn/appui/imessages.php
|
imessages.unset_hidden
|
public function unset_hidden(string $id_imess, string $id_user){
$cfg =& $this->class_cfg;
if ( !empty($id_imess) && !empty($id_user) ){
return !!$this->db->update_ignore($cfg['tables']['users'], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user,
$cfg['arch']['users']['hidden'] => 0,
$cfg['arch']['users']['moment'] => date('Y-m-d H:i:s'),
], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user
]);
}
return false;
}
|
php
|
public function unset_hidden(string $id_imess, string $id_user){
$cfg =& $this->class_cfg;
if ( !empty($id_imess) && !empty($id_user) ){
return !!$this->db->update_ignore($cfg['tables']['users'], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user,
$cfg['arch']['users']['hidden'] => 0,
$cfg['arch']['users']['moment'] => date('Y-m-d H:i:s'),
], [
$cfg['arch']['users']['id_imessage'] => $id_imess,
$cfg['arch']['users']['id_user'] => $id_user
]);
}
return false;
}
|
[
"public",
"function",
"unset_hidden",
"(",
"string",
"$",
"id_imess",
",",
"string",
"$",
"id_user",
")",
"{",
"$",
"cfg",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"id_imess",
")",
"&&",
"!",
"empty",
"(",
"$",
"id_user",
")",
")",
"{",
"return",
"!",
"!",
"$",
"this",
"->",
"db",
"->",
"update_ignore",
"(",
"$",
"cfg",
"[",
"'tables'",
"]",
"[",
"'users'",
"]",
",",
"[",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_imessage'",
"]",
"=>",
"$",
"id_imess",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_user'",
"]",
"=>",
"$",
"id_user",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'hidden'",
"]",
"=>",
"0",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'moment'",
"]",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
",",
"[",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_imessage'",
"]",
"=>",
"$",
"id_imess",
",",
"$",
"cfg",
"[",
"'arch'",
"]",
"[",
"'users'",
"]",
"[",
"'id_user'",
"]",
"=>",
"$",
"id_user",
"]",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Sets an user's internal message as not visible
@param string $id_imess
@param string $id_user
@return bool
|
[
"Sets",
"an",
"user",
"s",
"internal",
"message",
"as",
"not",
"visible"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/imessages.php#L236-L250
|
22,856
|
nabab/bbn
|
src/bbn/appui/imessages.php
|
imessages.get_by_user
|
public function get_by_user(string $id_user){
$cfg =& $this->class_cfg;
// Current datetime
$now = date('Y-m-d H:i:s');
// Get the user's group
$id_group = $this->db->select_one('bbn_users', 'id_group', ['id' => $id_user]);
// Get all user's internal messages
$messages = $this->db->get_rows("
SELECT {$cfg['table']}.*
FROM {$cfg['tables']['users']}
RIGHT JOIN {$cfg['table']}
ON {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_user']}
AND {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']}
WHERE (
{$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ?
)
AND (
{$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ?
)
AND (
(
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ?
OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ?
)
OR (
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL
)
)
AND (
{$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL
OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0
)",
$now,
$now,
hex2bin($id_user),
hex2bin($id_group)
);
// Get and return the imessage's info from notes archive
return $this->from_notes($messages);
}
|
php
|
public function get_by_user(string $id_user){
$cfg =& $this->class_cfg;
// Current datetime
$now = date('Y-m-d H:i:s');
// Get the user's group
$id_group = $this->db->select_one('bbn_users', 'id_group', ['id' => $id_user]);
// Get all user's internal messages
$messages = $this->db->get_rows("
SELECT {$cfg['table']}.*
FROM {$cfg['tables']['users']}
RIGHT JOIN {$cfg['table']}
ON {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_user']}
AND {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']}
WHERE (
{$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ?
)
AND (
{$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ?
)
AND (
(
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ?
OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ?
)
OR (
{$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL
OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL
)
)
AND (
{$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL
OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0
)",
$now,
$now,
hex2bin($id_user),
hex2bin($id_group)
);
// Get and return the imessage's info from notes archive
return $this->from_notes($messages);
}
|
[
"public",
"function",
"get_by_user",
"(",
"string",
"$",
"id_user",
")",
"{",
"$",
"cfg",
"=",
"&",
"$",
"this",
"->",
"class_cfg",
";",
"// Current datetime",
"$",
"now",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"// Get the user's group",
"$",
"id_group",
"=",
"$",
"this",
"->",
"db",
"->",
"select_one",
"(",
"'bbn_users'",
",",
"'id_group'",
",",
"[",
"'id'",
"=>",
"$",
"id_user",
"]",
")",
";",
"// Get all user's internal messages",
"$",
"messages",
"=",
"$",
"this",
"->",
"db",
"->",
"get_rows",
"(",
"\"\n SELECT {$cfg['table']}.*\n FROM {$cfg['tables']['users']}\n RIGHT JOIN {$cfg['table']}\n\t ON {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_user']}\n\t AND {$cfg['table']}.{$cfg['arch']['imessages']['id']} = {$cfg['tables']['users']}.{$cfg['arch']['users']['id_imessage']}\n WHERE (\n {$cfg['table']}.{$cfg['arch']['imessages']['start']} IS NULL\n OR {$cfg['table']}.{$cfg['arch']['imessages']['start']} <= ?\n )\n AND (\n {$cfg['table']}.{$cfg['arch']['imessages']['end']} IS NULL\n OR {$cfg['table']}.{$cfg['arch']['imessages']['end']} > ?\n )\n AND (\n (\n {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} = ?\n OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} = ?\n )\n OR (\n {$cfg['table']}.{$cfg['arch']['imessages']['id_user']} IS NULL\n OR {$cfg['table']}.{$cfg['arch']['imessages']['id_group']} IS NULL\n )\n )\n AND (\n {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} IS NULL\n OR {$cfg['tables']['users']}.{$cfg['arch']['users']['hidden']} = 0\n )\"",
",",
"$",
"now",
",",
"$",
"now",
",",
"hex2bin",
"(",
"$",
"id_user",
")",
",",
"hex2bin",
"(",
"$",
"id_group",
")",
")",
";",
"// Get and return the imessage's info from notes archive",
"return",
"$",
"this",
"->",
"from_notes",
"(",
"$",
"messages",
")",
";",
"}"
] |
Gets all user's internal messages
@param string $id_user
@return array
|
[
"Gets",
"all",
"user",
"s",
"internal",
"messages"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/imessages.php#L271-L313
|
22,857
|
mr-luke/configuration
|
src/Schema.php
|
Schema.check
|
public function check(array $insert, bool $throw = true): bool
{
foreach ($this->schema as $key => $rules) {
// Check each key by given rules and respond
// due to required flow.
$result = $this->processRules($key, explode('|', $rules), $insert);
if (!$result['status'] && $throw) {
throw new InvalidArgumentException(
sprintf($result['message'], $key)
);
}
}
return $result['status'] ?? true;
}
|
php
|
public function check(array $insert, bool $throw = true): bool
{
foreach ($this->schema as $key => $rules) {
// Check each key by given rules and respond
// due to required flow.
$result = $this->processRules($key, explode('|', $rules), $insert);
if (!$result['status'] && $throw) {
throw new InvalidArgumentException(
sprintf($result['message'], $key)
);
}
}
return $result['status'] ?? true;
}
|
[
"public",
"function",
"check",
"(",
"array",
"$",
"insert",
",",
"bool",
"$",
"throw",
"=",
"true",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schema",
"as",
"$",
"key",
"=>",
"$",
"rules",
")",
"{",
"// Check each key by given rules and respond",
"// due to required flow.",
"$",
"result",
"=",
"$",
"this",
"->",
"processRules",
"(",
"$",
"key",
",",
"explode",
"(",
"'|'",
",",
"$",
"rules",
")",
",",
"$",
"insert",
")",
";",
"if",
"(",
"!",
"$",
"result",
"[",
"'status'",
"]",
"&&",
"$",
"throw",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"$",
"result",
"[",
"'message'",
"]",
",",
"$",
"key",
")",
")",
";",
"}",
"}",
"return",
"$",
"result",
"[",
"'status'",
"]",
"??",
"true",
";",
"}"
] |
Check if given array is matching the schema.
@param array $insert
@param bool $throw
@return bool
@throws \InvalidArgumentException
|
[
"Check",
"if",
"given",
"array",
"is",
"matching",
"the",
"schema",
"."
] |
487c90011dc15556787785ed60c60ea92655beac
|
https://github.com/mr-luke/configuration/blob/487c90011dc15556787785ed60c60ea92655beac/src/Schema.php#L51-L66
|
22,858
|
mr-luke/configuration
|
src/Schema.php
|
Schema.createFromFile
|
public static function createFromFile(string $path, bool $json = false): Schema
{
static::fileExists($path);
$schema = $json ? json_decode(file_get_contents($path), true) : include $path;
if (!is_array($schema)) {
throw new InvalidArgumentException(
'[createFromFile] method requires file that return a php array or json.'
);
}
return new static($schema);
}
|
php
|
public static function createFromFile(string $path, bool $json = false): Schema
{
static::fileExists($path);
$schema = $json ? json_decode(file_get_contents($path), true) : include $path;
if (!is_array($schema)) {
throw new InvalidArgumentException(
'[createFromFile] method requires file that return a php array or json.'
);
}
return new static($schema);
}
|
[
"public",
"static",
"function",
"createFromFile",
"(",
"string",
"$",
"path",
",",
"bool",
"$",
"json",
"=",
"false",
")",
":",
"Schema",
"{",
"static",
"::",
"fileExists",
"(",
"$",
"path",
")",
";",
"$",
"schema",
"=",
"$",
"json",
"?",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
",",
"true",
")",
":",
"include",
"$",
"path",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"schema",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'[createFromFile] method requires file that return a php array or json.'",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"schema",
")",
";",
"}"
] |
Create new Schema instance based on file.
@param string $path
@param bool $json
@return Mrluke\Configuration\Schema
|
[
"Create",
"new",
"Schema",
"instance",
"based",
"on",
"file",
"."
] |
487c90011dc15556787785ed60c60ea92655beac
|
https://github.com/mr-luke/configuration/blob/487c90011dc15556787785ed60c60ea92655beac/src/Schema.php#L75-L88
|
22,859
|
mr-luke/configuration
|
src/Schema.php
|
Schema.processRules
|
private function processRules(string $key, array $rules, array $insert): array
{
$status = true;
if (!isset($insert[$key])) {
$status = false;
$message = 'Schema key [%s] not present on insert.';
}
do {
$r = array_shift($rules);
$method = 'checkRule'. ucfirst($r);
if (!in_array($r, $this->rules)) {
// There's no rule defined and allowed.
continue;
}
if (!$this->{$method}($insert[$key])) {
// When given key is not valid we need to stop process
// and set message related to validation error.
$status = false;
$message = $this->messages()[$r];
break;
}
} while (count($rules));
return compact('status', 'message');
}
|
php
|
private function processRules(string $key, array $rules, array $insert): array
{
$status = true;
if (!isset($insert[$key])) {
$status = false;
$message = 'Schema key [%s] not present on insert.';
}
do {
$r = array_shift($rules);
$method = 'checkRule'. ucfirst($r);
if (!in_array($r, $this->rules)) {
// There's no rule defined and allowed.
continue;
}
if (!$this->{$method}($insert[$key])) {
// When given key is not valid we need to stop process
// and set message related to validation error.
$status = false;
$message = $this->messages()[$r];
break;
}
} while (count($rules));
return compact('status', 'message');
}
|
[
"private",
"function",
"processRules",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"rules",
",",
"array",
"$",
"insert",
")",
":",
"array",
"{",
"$",
"status",
"=",
"true",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"insert",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"message",
"=",
"'Schema key [%s] not present on insert.'",
";",
"}",
"do",
"{",
"$",
"r",
"=",
"array_shift",
"(",
"$",
"rules",
")",
";",
"$",
"method",
"=",
"'checkRule'",
".",
"ucfirst",
"(",
"$",
"r",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"r",
",",
"$",
"this",
"->",
"rules",
")",
")",
"{",
"// There's no rule defined and allowed.",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"insert",
"[",
"$",
"key",
"]",
")",
")",
"{",
"// When given key is not valid we need to stop process",
"// and set message related to validation error.",
"$",
"status",
"=",
"false",
";",
"$",
"message",
"=",
"$",
"this",
"->",
"messages",
"(",
")",
"[",
"$",
"r",
"]",
";",
"break",
";",
"}",
"}",
"while",
"(",
"count",
"(",
"$",
"rules",
")",
")",
";",
"return",
"compact",
"(",
"'status'",
",",
"'message'",
")",
";",
"}"
] |
Parse each rules for given key of insert.
@param string $key
@param array $rules
@param array $insert
@return array
|
[
"Parse",
"each",
"rules",
"for",
"given",
"key",
"of",
"insert",
"."
] |
487c90011dc15556787785ed60c60ea92655beac
|
https://github.com/mr-luke/configuration/blob/487c90011dc15556787785ed60c60ea92655beac/src/Schema.php#L197-L226
|
22,860
|
phpnfe/tools
|
src/XMLGet.php
|
XMLGet.value
|
public function value()
{
if (is_null($this->value)) {
if (is_null($this->elem)) {
$this->value = '';
} else {
$this->value = $this->elem->textContent;
}
}
return $this->value;
}
|
php
|
public function value()
{
if (is_null($this->value)) {
if (is_null($this->elem)) {
$this->value = '';
} else {
$this->value = $this->elem->textContent;
}
}
return $this->value;
}
|
[
"public",
"function",
"value",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"elem",
")",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"this",
"->",
"elem",
"->",
"textContent",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"value",
";",
"}"
] |
Retorna o valor.
@return string
|
[
"Retorna",
"o",
"valor",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/XMLGet.php#L33-L44
|
22,861
|
phpnfe/tools
|
src/XMLGet.php
|
XMLGet.pad
|
public function pad($num, $char = '0', $dir = STR_PAD_LEFT)
{
$this->value = str_pad($this->value(), $num, $char, $dir);
return $this;
}
|
php
|
public function pad($num, $char = '0', $dir = STR_PAD_LEFT)
{
$this->value = str_pad($this->value(), $num, $char, $dir);
return $this;
}
|
[
"public",
"function",
"pad",
"(",
"$",
"num",
",",
"$",
"char",
"=",
"'0'",
",",
"$",
"dir",
"=",
"STR_PAD_LEFT",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"str_pad",
"(",
"$",
"this",
"->",
"value",
"(",
")",
",",
"$",
"num",
",",
"$",
"char",
",",
"$",
"dir",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Aplicar PAD.
@param $num
@param string $char
@param int $dir
@return $this
|
[
"Aplicar",
"PAD",
"."
] |
303ca311989e0b345071f61b71d2b3bf7ee80454
|
https://github.com/phpnfe/tools/blob/303ca311989e0b345071f61b71d2b3bf7ee80454/src/XMLGet.php#L54-L59
|
22,862
|
blast-project/BaseEntitiesBundle
|
src/Loggable/Mapping/Driver/Xml.php
|
Xml.inspectElementForVersioned
|
private function inspectElementForVersioned(\SimpleXMLElement $element, array &$config, $meta)
{
foreach ($element as $mapping) {
$mappingDoctrine = $mapping;
/**
* @var \SimpleXmlElement
*/
$mapping = $mapping->children(self::GEDMO_NAMESPACE_URI);
$isAssoc = $this->_isAttributeSet($mappingDoctrine, 'field');
$field = $this->_getAttribute($mappingDoctrine, $isAssoc ? 'field' : 'name');
if (isset($mapping->versioned)) {
if ($isAssoc && !$meta->associationMappings[$field]['isOwningSide']) {
throw new InvalidMappingException("Cannot version [{$field}] as it is not the owning side in object - {$meta->name}");
}
$config['versioned'][] = $field;
}
}
}
|
php
|
private function inspectElementForVersioned(\SimpleXMLElement $element, array &$config, $meta)
{
foreach ($element as $mapping) {
$mappingDoctrine = $mapping;
/**
* @var \SimpleXmlElement
*/
$mapping = $mapping->children(self::GEDMO_NAMESPACE_URI);
$isAssoc = $this->_isAttributeSet($mappingDoctrine, 'field');
$field = $this->_getAttribute($mappingDoctrine, $isAssoc ? 'field' : 'name');
if (isset($mapping->versioned)) {
if ($isAssoc && !$meta->associationMappings[$field]['isOwningSide']) {
throw new InvalidMappingException("Cannot version [{$field}] as it is not the owning side in object - {$meta->name}");
}
$config['versioned'][] = $field;
}
}
}
|
[
"private",
"function",
"inspectElementForVersioned",
"(",
"\\",
"SimpleXMLElement",
"$",
"element",
",",
"array",
"&",
"$",
"config",
",",
"$",
"meta",
")",
"{",
"foreach",
"(",
"$",
"element",
"as",
"$",
"mapping",
")",
"{",
"$",
"mappingDoctrine",
"=",
"$",
"mapping",
";",
"/**\n * @var \\SimpleXmlElement\n */",
"$",
"mapping",
"=",
"$",
"mapping",
"->",
"children",
"(",
"self",
"::",
"GEDMO_NAMESPACE_URI",
")",
";",
"$",
"isAssoc",
"=",
"$",
"this",
"->",
"_isAttributeSet",
"(",
"$",
"mappingDoctrine",
",",
"'field'",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"_getAttribute",
"(",
"$",
"mappingDoctrine",
",",
"$",
"isAssoc",
"?",
"'field'",
":",
"'name'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"mapping",
"->",
"versioned",
")",
")",
"{",
"if",
"(",
"$",
"isAssoc",
"&&",
"!",
"$",
"meta",
"->",
"associationMappings",
"[",
"$",
"field",
"]",
"[",
"'isOwningSide'",
"]",
")",
"{",
"throw",
"new",
"InvalidMappingException",
"(",
"\"Cannot version [{$field}] as it is not the owning side in object - {$meta->name}\"",
")",
";",
"}",
"$",
"config",
"[",
"'versioned'",
"]",
"[",
"]",
"=",
"$",
"field",
";",
"}",
"}",
"}"
] |
Searches mappings on element for versioned fields.
@param \SimpleXMLElement $element
@param array $config
@param object $meta
|
[
"Searches",
"mappings",
"on",
"element",
"for",
"versioned",
"fields",
"."
] |
abd06891fc38922225ab7e4fcb437a286ba2c0c4
|
https://github.com/blast-project/BaseEntitiesBundle/blob/abd06891fc38922225ab7e4fcb437a286ba2c0c4/src/Loggable/Mapping/Driver/Xml.php#L102-L121
|
22,863
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.checkUserClass
|
protected function checkUserClass()
{
$userClass = $this->userClass;
if (!class_exists($userClass)) {
throw new Exception('User Class Invalid.');
}
if (!((new $userClass()) instanceof User)) {
throw new Exception('User Class(' . $userClass . ') does not inherited from `\rhosocial\user\User`.');
}
return $userClass;
}
|
php
|
protected function checkUserClass()
{
$userClass = $this->userClass;
if (!class_exists($userClass)) {
throw new Exception('User Class Invalid.');
}
if (!((new $userClass()) instanceof User)) {
throw new Exception('User Class(' . $userClass . ') does not inherited from `\rhosocial\user\User`.');
}
return $userClass;
}
|
[
"protected",
"function",
"checkUserClass",
"(",
")",
"{",
"$",
"userClass",
"=",
"$",
"this",
"->",
"userClass",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"userClass",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'User Class Invalid.'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"(",
"new",
"$",
"userClass",
"(",
")",
")",
"instanceof",
"User",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'User Class('",
".",
"$",
"userClass",
".",
"') does not inherited from `\\rhosocial\\user\\User`.'",
")",
";",
"}",
"return",
"$",
"userClass",
";",
"}"
] |
Check and get valid User.
@return User
@throws Exception throw if User is not an instance inherited from `\rhosocial\user\User`.
|
[
"Check",
"and",
"get",
"valid",
"User",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L41-L51
|
22,864
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.getUser
|
protected function getUser($user)
{
$userClass = $this->checkUserClass();
if (is_numeric($user)) {
$user = $userClass::find()->id($user)->one();
} elseif (is_string($user) && strlen($user)) {
$user = $userClass::find()->guid($user)->one();
}
if (!$user || $user->getIsNewRecord()) {
throw new Exception('User Not Registered.');
}
return $user;
}
|
php
|
protected function getUser($user)
{
$userClass = $this->checkUserClass();
if (is_numeric($user)) {
$user = $userClass::find()->id($user)->one();
} elseif (is_string($user) && strlen($user)) {
$user = $userClass::find()->guid($user)->one();
}
if (!$user || $user->getIsNewRecord()) {
throw new Exception('User Not Registered.');
}
return $user;
}
|
[
"protected",
"function",
"getUser",
"(",
"$",
"user",
")",
"{",
"$",
"userClass",
"=",
"$",
"this",
"->",
"checkUserClass",
"(",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"userClass",
"::",
"find",
"(",
")",
"->",
"id",
"(",
"$",
"user",
")",
"->",
"one",
"(",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"user",
")",
"&&",
"strlen",
"(",
"$",
"user",
")",
")",
"{",
"$",
"user",
"=",
"$",
"userClass",
"::",
"find",
"(",
")",
"->",
"guid",
"(",
"$",
"user",
")",
"->",
"one",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"user",
"||",
"$",
"user",
"->",
"getIsNewRecord",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'User Not Registered.'",
")",
";",
"}",
"return",
"$",
"user",
";",
"}"
] |
Get user from database.
@param User|string|integer $user User ID.
@return User
@throws Exception
|
[
"Get",
"user",
"from",
"database",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L59-L71
|
22,865
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionRegister
|
public function actionRegister($password, $nickname = null, $firstName = null, $lastName = null)
{
$userClass = $this->checkUserClass();
$user = new $userClass(['password' => $password]);
/* @var $user User */
$profile = $user->createProfile([
'nickname' => $nickname,
'first_name' => $firstName,
'last_name' => $lastName,
]);
/* @var $profile Profile */
try {
is_null($profile) ? $user->register(): $user->register([$profile]);
} catch (\Exception $ex) {
throw new Exception($ex->getMessage());
}
echo "User Registered:\n";
return $this->actionShow($user);
}
|
php
|
public function actionRegister($password, $nickname = null, $firstName = null, $lastName = null)
{
$userClass = $this->checkUserClass();
$user = new $userClass(['password' => $password]);
/* @var $user User */
$profile = $user->createProfile([
'nickname' => $nickname,
'first_name' => $firstName,
'last_name' => $lastName,
]);
/* @var $profile Profile */
try {
is_null($profile) ? $user->register(): $user->register([$profile]);
} catch (\Exception $ex) {
throw new Exception($ex->getMessage());
}
echo "User Registered:\n";
return $this->actionShow($user);
}
|
[
"public",
"function",
"actionRegister",
"(",
"$",
"password",
",",
"$",
"nickname",
"=",
"null",
",",
"$",
"firstName",
"=",
"null",
",",
"$",
"lastName",
"=",
"null",
")",
"{",
"$",
"userClass",
"=",
"$",
"this",
"->",
"checkUserClass",
"(",
")",
";",
"$",
"user",
"=",
"new",
"$",
"userClass",
"(",
"[",
"'password'",
"=>",
"$",
"password",
"]",
")",
";",
"/* @var $user User */",
"$",
"profile",
"=",
"$",
"user",
"->",
"createProfile",
"(",
"[",
"'nickname'",
"=>",
"$",
"nickname",
",",
"'first_name'",
"=>",
"$",
"firstName",
",",
"'last_name'",
"=>",
"$",
"lastName",
",",
"]",
")",
";",
"/* @var $profile Profile */",
"try",
"{",
"is_null",
"(",
"$",
"profile",
")",
"?",
"$",
"user",
"->",
"register",
"(",
")",
":",
"$",
"user",
"->",
"register",
"(",
"[",
"$",
"profile",
"]",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"echo",
"\"User Registered:\\n\"",
";",
"return",
"$",
"this",
"->",
"actionShow",
"(",
"$",
"user",
")",
";",
"}"
] |
Register new User.
@param string $password Password.
@param string $nickname If profile contains this property, this parameter is required.
@param string $firstName If profile contains this property, this parameter is required.
@param string $lastName If profile contains this propery, this parameter is required.
@return int
@throws Exception
|
[
"Register",
"new",
"User",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L82-L101
|
22,866
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionDeregister
|
public function actionDeregister($user)
{
$user = $this->getUser($user);
if ($user->deregister()) {
echo "User (" . $user->getID() . ") Deregistered.\n";
return static::EXIT_CODE_NORMAL;
}
return static::EXIT_CODE_ERROR;
}
|
php
|
public function actionDeregister($user)
{
$user = $this->getUser($user);
if ($user->deregister()) {
echo "User (" . $user->getID() . ") Deregistered.\n";
return static::EXIT_CODE_NORMAL;
}
return static::EXIT_CODE_ERROR;
}
|
[
"public",
"function",
"actionDeregister",
"(",
"$",
"user",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"if",
"(",
"$",
"user",
"->",
"deregister",
"(",
")",
")",
"{",
"echo",
"\"User (\"",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"\") Deregistered.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_ERROR",
";",
"}"
] |
Deregister user.
@param User|string|integer $user The user to be deregistered.
@return int
|
[
"Deregister",
"user",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L108-L116
|
22,867
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionShow
|
public function actionShow($user, $guid = false, $passHash = false, $accessToken = false, $authKey = false)
{
$user = $this->getUser($user);
echo Yii::t('app', 'User') . " (" . $user->getID() . "), " . Yii::t('app', 'registered at') . " (" . $user->getCreatedAt() . ")"
. ($user->getCreatedAt() == $user->getUpdatedAt() ? "" : ", " . Yii::t('app', 'last updated at') . " (" . $user->getUpdatedAt() . ")") .".\n";
if ($guid) {
echo "GUID: " . $user->getGUID() . "\n";
}
if ($passHash) {
echo "Password Hash: " . $user->{$user->passwordHashAttribute} . "\n";
}
if ($accessToken) {
echo "Access Token: " . $user->getAccessToken() . "\n";
}
if ($authKey) {
echo "Authentication Key: " . $user->getAuthKey() . "\n";
}
return static::EXIT_CODE_NORMAL;
}
|
php
|
public function actionShow($user, $guid = false, $passHash = false, $accessToken = false, $authKey = false)
{
$user = $this->getUser($user);
echo Yii::t('app', 'User') . " (" . $user->getID() . "), " . Yii::t('app', 'registered at') . " (" . $user->getCreatedAt() . ")"
. ($user->getCreatedAt() == $user->getUpdatedAt() ? "" : ", " . Yii::t('app', 'last updated at') . " (" . $user->getUpdatedAt() . ")") .".\n";
if ($guid) {
echo "GUID: " . $user->getGUID() . "\n";
}
if ($passHash) {
echo "Password Hash: " . $user->{$user->passwordHashAttribute} . "\n";
}
if ($accessToken) {
echo "Access Token: " . $user->getAccessToken() . "\n";
}
if ($authKey) {
echo "Authentication Key: " . $user->getAuthKey() . "\n";
}
return static::EXIT_CODE_NORMAL;
}
|
[
"public",
"function",
"actionShow",
"(",
"$",
"user",
",",
"$",
"guid",
"=",
"false",
",",
"$",
"passHash",
"=",
"false",
",",
"$",
"accessToken",
"=",
"false",
",",
"$",
"authKey",
"=",
"false",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"echo",
"Yii",
"::",
"t",
"(",
"'app'",
",",
"'User'",
")",
".",
"\" (\"",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"\"), \"",
".",
"Yii",
"::",
"t",
"(",
"'app'",
",",
"'registered at'",
")",
".",
"\" (\"",
".",
"$",
"user",
"->",
"getCreatedAt",
"(",
")",
".",
"\")\"",
".",
"(",
"$",
"user",
"->",
"getCreatedAt",
"(",
")",
"==",
"$",
"user",
"->",
"getUpdatedAt",
"(",
")",
"?",
"\"\"",
":",
"\", \"",
".",
"Yii",
"::",
"t",
"(",
"'app'",
",",
"'last updated at'",
")",
".",
"\" (\"",
".",
"$",
"user",
"->",
"getUpdatedAt",
"(",
")",
".",
"\")\"",
")",
".",
"\".\\n\"",
";",
"if",
"(",
"$",
"guid",
")",
"{",
"echo",
"\"GUID: \"",
".",
"$",
"user",
"->",
"getGUID",
"(",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"passHash",
")",
"{",
"echo",
"\"Password Hash: \"",
".",
"$",
"user",
"->",
"{",
"$",
"user",
"->",
"passwordHashAttribute",
"}",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"accessToken",
")",
"{",
"echo",
"\"Access Token: \"",
".",
"$",
"user",
"->",
"getAccessToken",
"(",
")",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"authKey",
")",
"{",
"echo",
"\"Authentication Key: \"",
".",
"$",
"user",
"->",
"getAuthKey",
"(",
")",
".",
"\"\\n\"",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}"
] |
Show User Information.
@param User|string|integer $user User ID.
@param boolean $guid Show GUID?
@param boolean $passHash Show PasswordH Hash?
@param boolean $accessToken Show Access Token?
@param boolean $authKey Show Authentication Key?
@return int
|
[
"Show",
"User",
"Information",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L127-L145
|
22,868
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionStat
|
public function actionStat($user = null)
{
if ($user === null) {
$count = User::find()->count();
echo "Total number of user(s): " . $count . "\n";
if ($count == 0) {
return static::EXIT_CODE_NORMAL;
}
$last = User::find()->orderByCreatedAt(SORT_DESC)->one();
/* @var $last User */
echo "Latest user (" . $last->getID() . ") registered at " . $last->getCreatedAt() . "\n";
return static::EXIT_CODE_NORMAL;
}
$user = $this->getUser($user);
return static::EXIT_CODE_NORMAL;
}
|
php
|
public function actionStat($user = null)
{
if ($user === null) {
$count = User::find()->count();
echo "Total number of user(s): " . $count . "\n";
if ($count == 0) {
return static::EXIT_CODE_NORMAL;
}
$last = User::find()->orderByCreatedAt(SORT_DESC)->one();
/* @var $last User */
echo "Latest user (" . $last->getID() . ") registered at " . $last->getCreatedAt() . "\n";
return static::EXIT_CODE_NORMAL;
}
$user = $this->getUser($user);
return static::EXIT_CODE_NORMAL;
}
|
[
"public",
"function",
"actionStat",
"(",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"user",
"===",
"null",
")",
"{",
"$",
"count",
"=",
"User",
"::",
"find",
"(",
")",
"->",
"count",
"(",
")",
";",
"echo",
"\"Total number of user(s): \"",
".",
"$",
"count",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"count",
"==",
"0",
")",
"{",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"$",
"last",
"=",
"User",
"::",
"find",
"(",
")",
"->",
"orderByCreatedAt",
"(",
"SORT_DESC",
")",
"->",
"one",
"(",
")",
";",
"/* @var $last User */",
"echo",
"\"Latest user (\"",
".",
"$",
"last",
"->",
"getID",
"(",
")",
".",
"\") registered at \"",
".",
"$",
"last",
"->",
"getCreatedAt",
"(",
")",
".",
"\"\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}"
] |
Show statistics.
@param User|string|integer $user User ID.
@return int
|
[
"Show",
"statistics",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L152-L167
|
22,869
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionRole
|
public function actionRole($user, $operation, $role)
{
$user = $this->getUser($user);
$role = Yii::$app->authManager->getRole($role);
if ($operation == 'assign') {
try {
$assignment = Yii::$app->authManager->assign($role, $user);
} catch (\yii\db\IntegrityException $ex) {
echo "Failed to assign `" . $role->name . "`.\n";
echo "Maybe the role has been assigned.\n";
return static::EXIT_CODE_ERROR;
}
if ($assignment) {
echo "`$role->name`" . " assigned to User (" . $user->getID() . ") successfully.\n";
} else {
echo "Failed to assign `" . $role->name . "`.\n";
}
return static::EXIT_CODE_NORMAL;
}
if ($operation == 'revoke') {
$assignment = Yii::$app->authManager->revoke($role, $user);
if ($assignment) {
echo "`$role->name`" . " revoked from User (" . $user->getID() . ").\n";
} else {
echo "Failed to revoke `" . $role->name . "`.\n";
echo "Maybe the role has not been assigned yet.\n";
}
return static::EXIT_CODE_NORMAL;
}
echo "Unrecognized operation: $operation.\n";
echo "The accepted operations are `assign` and `revoke`.\n";
return static::EXIT_CODE_ERROR;
}
|
php
|
public function actionRole($user, $operation, $role)
{
$user = $this->getUser($user);
$role = Yii::$app->authManager->getRole($role);
if ($operation == 'assign') {
try {
$assignment = Yii::$app->authManager->assign($role, $user);
} catch (\yii\db\IntegrityException $ex) {
echo "Failed to assign `" . $role->name . "`.\n";
echo "Maybe the role has been assigned.\n";
return static::EXIT_CODE_ERROR;
}
if ($assignment) {
echo "`$role->name`" . " assigned to User (" . $user->getID() . ") successfully.\n";
} else {
echo "Failed to assign `" . $role->name . "`.\n";
}
return static::EXIT_CODE_NORMAL;
}
if ($operation == 'revoke') {
$assignment = Yii::$app->authManager->revoke($role, $user);
if ($assignment) {
echo "`$role->name`" . " revoked from User (" . $user->getID() . ").\n";
} else {
echo "Failed to revoke `" . $role->name . "`.\n";
echo "Maybe the role has not been assigned yet.\n";
}
return static::EXIT_CODE_NORMAL;
}
echo "Unrecognized operation: $operation.\n";
echo "The accepted operations are `assign` and `revoke`.\n";
return static::EXIT_CODE_ERROR;
}
|
[
"public",
"function",
"actionRole",
"(",
"$",
"user",
",",
"$",
"operation",
",",
"$",
"role",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"$",
"role",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"getRole",
"(",
"$",
"role",
")",
";",
"if",
"(",
"$",
"operation",
"==",
"'assign'",
")",
"{",
"try",
"{",
"$",
"assignment",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"assign",
"(",
"$",
"role",
",",
"$",
"user",
")",
";",
"}",
"catch",
"(",
"\\",
"yii",
"\\",
"db",
"\\",
"IntegrityException",
"$",
"ex",
")",
"{",
"echo",
"\"Failed to assign `\"",
".",
"$",
"role",
"->",
"name",
".",
"\"`.\\n\"",
";",
"echo",
"\"Maybe the role has been assigned.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_ERROR",
";",
"}",
"if",
"(",
"$",
"assignment",
")",
"{",
"echo",
"\"`$role->name`\"",
".",
"\" assigned to User (\"",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"\") successfully.\\n\"",
";",
"}",
"else",
"{",
"echo",
"\"Failed to assign `\"",
".",
"$",
"role",
"->",
"name",
".",
"\"`.\\n\"",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"if",
"(",
"$",
"operation",
"==",
"'revoke'",
")",
"{",
"$",
"assignment",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"revoke",
"(",
"$",
"role",
",",
"$",
"user",
")",
";",
"if",
"(",
"$",
"assignment",
")",
"{",
"echo",
"\"`$role->name`\"",
".",
"\" revoked from User (\"",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"\").\\n\"",
";",
"}",
"else",
"{",
"echo",
"\"Failed to revoke `\"",
".",
"$",
"role",
"->",
"name",
".",
"\"`.\\n\"",
";",
"echo",
"\"Maybe the role has not been assigned yet.\\n\"",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"echo",
"\"Unrecognized operation: $operation.\\n\"",
";",
"echo",
"\"The accepted operations are `assign` and `revoke`.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_ERROR",
";",
"}"
] |
Assign a role to user or revoke a role.
@param User|string|integer $user User ID.
@param string $operation Only `assign` and `revoke` are acceptable.
@param string $role Role name.
@return int
|
[
"Assign",
"a",
"role",
"to",
"user",
"or",
"revoke",
"a",
"role",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L176-L208
|
22,870
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionPermission
|
public function actionPermission($user, $operation, $permission)
{
$user = $this->getUser($user);
$permission = Yii::$app->authManager->getPermission($permission);
if ($operation == 'assign') {
try {
$assignment = Yii::$app->authManager->assign($permission, $user);
} catch (\yii\db\IntegrityException $ex) {
echo "Failed to assign `" . $permission->name . "`.\n";
echo "Maybe the permission has been assigned.\n";
return static::EXIT_CODE_ERROR;
}
if ($assignment) {
echo "`$permission->name`" . " assigned to User (" . $user->getID() . ") successfully.\n";
} else {
echo "Failed to assign `" . $permission->name . "`.\n";
}
return static::EXIT_CODE_NORMAL;
}
if ($operation == 'revoke') {
$assignment = Yii::$app->authManager->revoke($permission, $user);
if ($assignment) {
echo "`$permission->name`" . " revoked from User (" . $user->getID() . ").\n";
} else {
echo "Failed to revoke `" . $permission->name . "`.\n";
echo "Maybe the permission has not been assigned yet.\n";
}
return static::EXIT_CODE_NORMAL;
}
echo "Unrecognized operation: $operation.\n";
echo "The accepted operations are `assign` and `revoke`.\n";
return static::EXIT_CODE_ERROR;
}
|
php
|
public function actionPermission($user, $operation, $permission)
{
$user = $this->getUser($user);
$permission = Yii::$app->authManager->getPermission($permission);
if ($operation == 'assign') {
try {
$assignment = Yii::$app->authManager->assign($permission, $user);
} catch (\yii\db\IntegrityException $ex) {
echo "Failed to assign `" . $permission->name . "`.\n";
echo "Maybe the permission has been assigned.\n";
return static::EXIT_CODE_ERROR;
}
if ($assignment) {
echo "`$permission->name`" . " assigned to User (" . $user->getID() . ") successfully.\n";
} else {
echo "Failed to assign `" . $permission->name . "`.\n";
}
return static::EXIT_CODE_NORMAL;
}
if ($operation == 'revoke') {
$assignment = Yii::$app->authManager->revoke($permission, $user);
if ($assignment) {
echo "`$permission->name`" . " revoked from User (" . $user->getID() . ").\n";
} else {
echo "Failed to revoke `" . $permission->name . "`.\n";
echo "Maybe the permission has not been assigned yet.\n";
}
return static::EXIT_CODE_NORMAL;
}
echo "Unrecognized operation: $operation.\n";
echo "The accepted operations are `assign` and `revoke`.\n";
return static::EXIT_CODE_ERROR;
}
|
[
"public",
"function",
"actionPermission",
"(",
"$",
"user",
",",
"$",
"operation",
",",
"$",
"permission",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"$",
"permission",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"getPermission",
"(",
"$",
"permission",
")",
";",
"if",
"(",
"$",
"operation",
"==",
"'assign'",
")",
"{",
"try",
"{",
"$",
"assignment",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"assign",
"(",
"$",
"permission",
",",
"$",
"user",
")",
";",
"}",
"catch",
"(",
"\\",
"yii",
"\\",
"db",
"\\",
"IntegrityException",
"$",
"ex",
")",
"{",
"echo",
"\"Failed to assign `\"",
".",
"$",
"permission",
"->",
"name",
".",
"\"`.\\n\"",
";",
"echo",
"\"Maybe the permission has been assigned.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_ERROR",
";",
"}",
"if",
"(",
"$",
"assignment",
")",
"{",
"echo",
"\"`$permission->name`\"",
".",
"\" assigned to User (\"",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"\") successfully.\\n\"",
";",
"}",
"else",
"{",
"echo",
"\"Failed to assign `\"",
".",
"$",
"permission",
"->",
"name",
".",
"\"`.\\n\"",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"if",
"(",
"$",
"operation",
"==",
"'revoke'",
")",
"{",
"$",
"assignment",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
"->",
"revoke",
"(",
"$",
"permission",
",",
"$",
"user",
")",
";",
"if",
"(",
"$",
"assignment",
")",
"{",
"echo",
"\"`$permission->name`\"",
".",
"\" revoked from User (\"",
".",
"$",
"user",
"->",
"getID",
"(",
")",
".",
"\").\\n\"",
";",
"}",
"else",
"{",
"echo",
"\"Failed to revoke `\"",
".",
"$",
"permission",
"->",
"name",
".",
"\"`.\\n\"",
";",
"echo",
"\"Maybe the permission has not been assigned yet.\\n\"",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"echo",
"\"Unrecognized operation: $operation.\\n\"",
";",
"echo",
"\"The accepted operations are `assign` and `revoke`.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_ERROR",
";",
"}"
] |
Assign a permission to user or revoke a permission.
@param User|string|integer $user User ID.
@param string $operation Only `assign` and `revoke` are acceptable.
@param string $permission Permission name.
@return int
|
[
"Assign",
"a",
"permission",
"to",
"user",
"or",
"revoke",
"a",
"permission",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L217-L249
|
22,871
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionPassword
|
public function actionPassword($user, $password)
{
$user = $this->getUser($user);
$user->applyForNewPassword();
$result = $user->resetPassword($password, $user->getPasswordResetToken());
if ($result) {
echo "Password changed.\n";
} else {
echo "Password not changed.\n";
}
return static::EXIT_CODE_NORMAL;
}
|
php
|
public function actionPassword($user, $password)
{
$user = $this->getUser($user);
$user->applyForNewPassword();
$result = $user->resetPassword($password, $user->getPasswordResetToken());
if ($result) {
echo "Password changed.\n";
} else {
echo "Password not changed.\n";
}
return static::EXIT_CODE_NORMAL;
}
|
[
"public",
"function",
"actionPassword",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"$",
"user",
"->",
"applyForNewPassword",
"(",
")",
";",
"$",
"result",
"=",
"$",
"user",
"->",
"resetPassword",
"(",
"$",
"password",
",",
"$",
"user",
"->",
"getPasswordResetToken",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"echo",
"\"Password changed.\\n\"",
";",
"}",
"else",
"{",
"echo",
"\"Password not changed.\\n\"",
";",
"}",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}"
] |
Change password directly.
@param User|string|integer $user User ID.
@param string $password Password.
@return int
|
[
"Change",
"password",
"directly",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L275-L286
|
22,872
|
rhosocial/yii2-user
|
console/controllers/UserController.php
|
UserController.actionConfirmPasswordHistory
|
public function actionConfirmPasswordHistory($user, $password)
{
$user = $this->getUser($user);
$passwordHistory = $user->passwordHistories;
$passwordInHistory = 0;
foreach ($passwordHistory as $pass) {
if ($pass->validatePassword($password)) {
$passwordInHistory++;
echo "This password was created at " . $pass->getCreatedAt() . ".\n";
}
}
if ($passwordInHistory) {
echo "$passwordInHistory matched.\n";
return static::EXIT_CODE_NORMAL;
}
echo "No password matched.\n";
return static::EXIT_CODE_ERROR;
}
|
php
|
public function actionConfirmPasswordHistory($user, $password)
{
$user = $this->getUser($user);
$passwordHistory = $user->passwordHistories;
$passwordInHistory = 0;
foreach ($passwordHistory as $pass) {
if ($pass->validatePassword($password)) {
$passwordInHistory++;
echo "This password was created at " . $pass->getCreatedAt() . ".\n";
}
}
if ($passwordInHistory) {
echo "$passwordInHistory matched.\n";
return static::EXIT_CODE_NORMAL;
}
echo "No password matched.\n";
return static::EXIT_CODE_ERROR;
}
|
[
"public",
"function",
"actionConfirmPasswordHistory",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"user",
")",
";",
"$",
"passwordHistory",
"=",
"$",
"user",
"->",
"passwordHistories",
";",
"$",
"passwordInHistory",
"=",
"0",
";",
"foreach",
"(",
"$",
"passwordHistory",
"as",
"$",
"pass",
")",
"{",
"if",
"(",
"$",
"pass",
"->",
"validatePassword",
"(",
"$",
"password",
")",
")",
"{",
"$",
"passwordInHistory",
"++",
";",
"echo",
"\"This password was created at \"",
".",
"$",
"pass",
"->",
"getCreatedAt",
"(",
")",
".",
"\".\\n\"",
";",
"}",
"}",
"if",
"(",
"$",
"passwordInHistory",
")",
"{",
"echo",
"\"$passwordInHistory matched.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_NORMAL",
";",
"}",
"echo",
"\"No password matched.\\n\"",
";",
"return",
"static",
"::",
"EXIT_CODE_ERROR",
";",
"}"
] |
Confirm password in history.
This command will list all matching passwords in reverse order.
@param User|string|integer $user User ID.
@param string $password Password.
@return int
|
[
"Confirm",
"password",
"in",
"history",
".",
"This",
"command",
"will",
"list",
"all",
"matching",
"passwords",
"in",
"reverse",
"order",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/console/controllers/UserController.php#L295-L312
|
22,873
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php
|
phpExifReader.debug
|
function debug($str, $TYPE = 0, $file = "", $line = 0)
{
if ($this->debug)
{
echo "<br>[$file:$line:" . ($this->getDiffTime()) . "]$str";
flush();
if ($TYPE == 1)
{
exit;
}
}
}
|
php
|
function debug($str, $TYPE = 0, $file = "", $line = 0)
{
if ($this->debug)
{
echo "<br>[$file:$line:" . ($this->getDiffTime()) . "]$str";
flush();
if ($TYPE == 1)
{
exit;
}
}
}
|
[
"function",
"debug",
"(",
"$",
"str",
",",
"$",
"TYPE",
"=",
"0",
",",
"$",
"file",
"=",
"\"\"",
",",
"$",
"line",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"echo",
"\"<br>[$file:$line:\"",
".",
"(",
"$",
"this",
"->",
"getDiffTime",
"(",
")",
")",
".",
"\"]$str\"",
";",
"flush",
"(",
")",
";",
"if",
"(",
"$",
"TYPE",
"==",
"1",
")",
"{",
"exit",
";",
"}",
"}",
"}"
] |
Show Debugging information
@param string $str Debugging message to display
@param int $TYPE Type of error (0 - Warning, 1 - Error)
@param string $file
@param int $line
@return void
|
[
"Show",
"Debugging",
"information"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L430-L441
|
22,874
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php
|
phpExifReader.Get32s
|
function Get32s($val1, $val2, $val3, $val4)
{
$val1 = ord($val1);
$val2 = ord($val2);
$val3 = ord($val3);
$val4 = ord($val4);
if ($this->MotorolaOrder)
{
return (($val1 << 24) | ($val2 << 16) | ($val3 << 8) | ($val4 << 0));
}
else
{
return (($val4 << 24) | ($val3 << 16) | ($val2 << 8) | ($val1 << 0));
}
}
|
php
|
function Get32s($val1, $val2, $val3, $val4)
{
$val1 = ord($val1);
$val2 = ord($val2);
$val3 = ord($val3);
$val4 = ord($val4);
if ($this->MotorolaOrder)
{
return (($val1 << 24) | ($val2 << 16) | ($val3 << 8) | ($val4 << 0));
}
else
{
return (($val4 << 24) | ($val3 << 16) | ($val2 << 8) | ($val1 << 0));
}
}
|
[
"function",
"Get32s",
"(",
"$",
"val1",
",",
"$",
"val2",
",",
"$",
"val3",
",",
"$",
"val4",
")",
"{",
"$",
"val1",
"=",
"ord",
"(",
"$",
"val1",
")",
";",
"$",
"val2",
"=",
"ord",
"(",
"$",
"val2",
")",
";",
"$",
"val3",
"=",
"ord",
"(",
"$",
"val3",
")",
";",
"$",
"val4",
"=",
"ord",
"(",
"$",
"val4",
")",
";",
"if",
"(",
"$",
"this",
"->",
"MotorolaOrder",
")",
"{",
"return",
"(",
"(",
"$",
"val1",
"<<",
"24",
")",
"|",
"(",
"$",
"val2",
"<<",
"16",
")",
"|",
"(",
"$",
"val3",
"<<",
"8",
")",
"|",
"(",
"$",
"val4",
"<<",
"0",
")",
")",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"$",
"val4",
"<<",
"24",
")",
"|",
"(",
"$",
"val3",
"<<",
"16",
")",
"|",
"(",
"$",
"val2",
"<<",
"8",
")",
"|",
"(",
"$",
"val1",
"<<",
"0",
")",
")",
";",
"}",
"}"
] |
Converts 4-byte number into its equivalent integer
@param int
@param int
@param int
@param int
@return int
|
[
"Converts",
"4",
"-",
"byte",
"number",
"into",
"its",
"equivalent",
"integer"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1666-L1681
|
22,875
|
Eresus/EresusCMS
|
src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php
|
phpExifReader.get32u
|
function get32u($val1, $val2, $val3, $val4)
{
return ($this->Get32s($val1, $val2, $val3, $val4) & 0xffffffff);
}
|
php
|
function get32u($val1, $val2, $val3, $val4)
{
return ($this->Get32s($val1, $val2, $val3, $val4) & 0xffffffff);
}
|
[
"function",
"get32u",
"(",
"$",
"val1",
",",
"$",
"val2",
",",
"$",
"val3",
",",
"$",
"val4",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"Get32s",
"(",
"$",
"val1",
",",
"$",
"val2",
",",
"$",
"val3",
",",
"$",
"val4",
")",
"&",
"0xffffffff",
")",
";",
"}"
] |
Converts 4-byte number into its equivalent integer with the help of Get32s
@param int
@param int
@param int
@param int
@return int
|
[
"Converts",
"4",
"-",
"byte",
"number",
"into",
"its",
"equivalent",
"integer",
"with",
"the",
"help",
"of",
"Get32s"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/ext-3rd/tinymce/plugins/images/connector/php/exifReader.php#L1694-L1697
|
22,876
|
zhouyl/mellivora
|
Mellivora/Events/CallQueuedHandler.php
|
CallQueuedHandler.setJobInstanceIfNecessary
|
protected function setJobInstanceIfNecessary(Job $job, $instance)
{
if (in_array(InteractsWithQueue::class, class_uses_recursive(get_class($instance)))) {
$instance->setJob($job);
}
return $instance;
}
|
php
|
protected function setJobInstanceIfNecessary(Job $job, $instance)
{
if (in_array(InteractsWithQueue::class, class_uses_recursive(get_class($instance)))) {
$instance->setJob($job);
}
return $instance;
}
|
[
"protected",
"function",
"setJobInstanceIfNecessary",
"(",
"Job",
"$",
"job",
",",
"$",
"instance",
")",
"{",
"if",
"(",
"in_array",
"(",
"InteractsWithQueue",
"::",
"class",
",",
"class_uses_recursive",
"(",
"get_class",
"(",
"$",
"instance",
")",
")",
")",
")",
"{",
"$",
"instance",
"->",
"setJob",
"(",
"$",
"job",
")",
";",
"}",
"return",
"$",
"instance",
";",
"}"
] |
Set the job instance of the given class if necessary.
@param \Mellivora\Support\Contracts\Queue\Job $job
@param mixed $instance
@return mixed
|
[
"Set",
"the",
"job",
"instance",
"of",
"the",
"given",
"class",
"if",
"necessary",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Events/CallQueuedHandler.php#L63-L70
|
22,877
|
WellCommerce/AppBundle
|
Twig/CurrencyExtension.php
|
CurrencyExtension.formatPrice
|
public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
{
return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
}
|
php
|
public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
{
return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
}
|
[
"public",
"function",
"formatPrice",
"(",
"float",
"$",
"price",
",",
"$",
"baseCurrency",
"=",
"null",
",",
"$",
"targetCurrency",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
",",
"$",
"quantity",
"=",
"1",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"convertAndFormat",
"(",
"$",
"price",
",",
"$",
"baseCurrency",
",",
"$",
"targetCurrency",
",",
"$",
"quantity",
",",
"$",
"locale",
")",
";",
"}"
] |
Formats the given amount
@param int|float $price
@param null|string $baseCurrency
@param null|string $targetCurrency
@param null|string $locale
@return string
|
[
"Formats",
"the",
"given",
"amount"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Twig/CurrencyExtension.php#L75-L78
|
22,878
|
WellCommerce/AppBundle
|
Twig/CurrencyExtension.php
|
CurrencyExtension.convertPrice
|
public function convertPrice(float $price, $baseCurrency = null, $targetCurrency = null, $quantity = 1) : string
{
return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity);
}
|
php
|
public function convertPrice(float $price, $baseCurrency = null, $targetCurrency = null, $quantity = 1) : string
{
return $this->helper->convert($price, $baseCurrency, $targetCurrency, $quantity);
}
|
[
"public",
"function",
"convertPrice",
"(",
"float",
"$",
"price",
",",
"$",
"baseCurrency",
"=",
"null",
",",
"$",
"targetCurrency",
"=",
"null",
",",
"$",
"quantity",
"=",
"1",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"helper",
"->",
"convert",
"(",
"$",
"price",
",",
"$",
"baseCurrency",
",",
"$",
"targetCurrency",
",",
"$",
"quantity",
")",
";",
"}"
] |
Converts the given amount
@param float $price
@param null|string $baseCurrency
@param null|string $targetCurrency
@param int $quantity
@return string
|
[
"Converts",
"the",
"given",
"amount"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Twig/CurrencyExtension.php#L90-L93
|
22,879
|
tttptd/laravel-responder
|
src/Transformer.php
|
Transformer.getRelations
|
public function getRelations():array
{
$relations = array_unique(array_merge($this->getAvailableIncludes(), $this->relations));
return array_filter($relations, function($relation) {
return $relation !== '*';
});
}
|
php
|
public function getRelations():array
{
$relations = array_unique(array_merge($this->getAvailableIncludes(), $this->relations));
return array_filter($relations, function($relation) {
return $relation !== '*';
});
}
|
[
"public",
"function",
"getRelations",
"(",
")",
":",
"array",
"{",
"$",
"relations",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getAvailableIncludes",
"(",
")",
",",
"$",
"this",
"->",
"relations",
")",
")",
";",
"return",
"array_filter",
"(",
"$",
"relations",
",",
"function",
"(",
"$",
"relation",
")",
"{",
"return",
"$",
"relation",
"!==",
"'*'",
";",
"}",
")",
";",
"}"
] |
Get relations set on the transformer.
@return array
|
[
"Get",
"relations",
"set",
"on",
"the",
"transformer",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L32-L39
|
22,880
|
tttptd/laravel-responder
|
src/Transformer.php
|
Transformer.setRelations
|
public function setRelations($relations)
{
$this->setAvailableIncludes(array_unique(array_merge($this->availableIncludes, (array) $relations)));
return $this;
}
|
php
|
public function setRelations($relations)
{
$this->setAvailableIncludes(array_unique(array_merge($this->availableIncludes, (array) $relations)));
return $this;
}
|
[
"public",
"function",
"setRelations",
"(",
"$",
"relations",
")",
"{",
"$",
"this",
"->",
"setAvailableIncludes",
"(",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"availableIncludes",
",",
"(",
"array",
")",
"$",
"relations",
")",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set relations on the transformer.
@param array|string $relations
@return self
|
[
"Set",
"relations",
"on",
"the",
"transformer",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L47-L52
|
22,881
|
tttptd/laravel-responder
|
src/Transformer.php
|
Transformer.includePivot
|
protected function includePivot(Pivot $pivot)
{
if (! method_exists($this, 'transformPivot')) {
return false;
}
return app(Responder::class)->transform($pivot, function ($pivot) {
return $this->transformPivot($pivot);
})->getResource();
}
|
php
|
protected function includePivot(Pivot $pivot)
{
if (! method_exists($this, 'transformPivot')) {
return false;
}
return app(Responder::class)->transform($pivot, function ($pivot) {
return $this->transformPivot($pivot);
})->getResource();
}
|
[
"protected",
"function",
"includePivot",
"(",
"Pivot",
"$",
"pivot",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"'transformPivot'",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"app",
"(",
"Responder",
"::",
"class",
")",
"->",
"transform",
"(",
"$",
"pivot",
",",
"function",
"(",
"$",
"pivot",
")",
"{",
"return",
"$",
"this",
"->",
"transformPivot",
"(",
"$",
"pivot",
")",
";",
"}",
")",
"->",
"getResource",
"(",
")",
";",
"}"
] |
Include pivot table data to the response.
@param Pivot $pivot
@return \League\Fractal\Resource\ResourceInterface|bool
|
[
"Include",
"pivot",
"table",
"data",
"to",
"the",
"response",
"."
] |
0e4a32701f0de755c1f1af458045829e1bd6caf6
|
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Transformer.php#L101-L110
|
22,882
|
nabab/bbn
|
src/bbn/cdn/config.php
|
config._set_cfg
|
private function _set_cfg(){
if ( \is_array($this->cfg) ){
$p =& $this->cfg['params'];
$components = false;
if ( !empty($p['components']) ){
$components = explode(',', $p['components']);
}
$this->cfg = bbn\x::merge_arrays($this->cfg, [
'test' => !empty($p['test']),
'lang' => empty($p['lang']) ? self::$default_language : $p['lang'],
'nocompil' => !empty($p['nocompil']),
'has_css' => !isset($p['css']) || $p['css'],
'has_dep' => !isset($p['dep']) || $p['dep'],
'latest' => isset($p['latest']) ? 1 : false,
'is_component' => !empty($p['components']),
'components' => $components
]);
}
}
|
php
|
private function _set_cfg(){
if ( \is_array($this->cfg) ){
$p =& $this->cfg['params'];
$components = false;
if ( !empty($p['components']) ){
$components = explode(',', $p['components']);
}
$this->cfg = bbn\x::merge_arrays($this->cfg, [
'test' => !empty($p['test']),
'lang' => empty($p['lang']) ? self::$default_language : $p['lang'],
'nocompil' => !empty($p['nocompil']),
'has_css' => !isset($p['css']) || $p['css'],
'has_dep' => !isset($p['dep']) || $p['dep'],
'latest' => isset($p['latest']) ? 1 : false,
'is_component' => !empty($p['components']),
'components' => $components
]);
}
}
|
[
"private",
"function",
"_set_cfg",
"(",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"cfg",
")",
")",
"{",
"$",
"p",
"=",
"&",
"$",
"this",
"->",
"cfg",
"[",
"'params'",
"]",
";",
"$",
"components",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"p",
"[",
"'components'",
"]",
")",
")",
"{",
"$",
"components",
"=",
"explode",
"(",
"','",
",",
"$",
"p",
"[",
"'components'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"cfg",
"=",
"bbn",
"\\",
"x",
"::",
"merge_arrays",
"(",
"$",
"this",
"->",
"cfg",
",",
"[",
"'test'",
"=>",
"!",
"empty",
"(",
"$",
"p",
"[",
"'test'",
"]",
")",
",",
"'lang'",
"=>",
"empty",
"(",
"$",
"p",
"[",
"'lang'",
"]",
")",
"?",
"self",
"::",
"$",
"default_language",
":",
"$",
"p",
"[",
"'lang'",
"]",
",",
"'nocompil'",
"=>",
"!",
"empty",
"(",
"$",
"p",
"[",
"'nocompil'",
"]",
")",
",",
"'has_css'",
"=>",
"!",
"isset",
"(",
"$",
"p",
"[",
"'css'",
"]",
")",
"||",
"$",
"p",
"[",
"'css'",
"]",
",",
"'has_dep'",
"=>",
"!",
"isset",
"(",
"$",
"p",
"[",
"'dep'",
"]",
")",
"||",
"$",
"p",
"[",
"'dep'",
"]",
",",
"'latest'",
"=>",
"isset",
"(",
"$",
"p",
"[",
"'latest'",
"]",
")",
"?",
"1",
":",
"false",
",",
"'is_component'",
"=>",
"!",
"empty",
"(",
"$",
"p",
"[",
"'components'",
"]",
")",
",",
"'components'",
"=>",
"$",
"components",
"]",
")",
";",
"}",
"}"
] |
Returns an array with all the - default or no - config parameters based on the sent ones
|
[
"Returns",
"an",
"array",
"with",
"all",
"the",
"-",
"default",
"or",
"no",
"-",
"config",
"parameters",
"based",
"on",
"the",
"sent",
"ones"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/cdn/config.php#L34-L52
|
22,883
|
surebert/surebert-framework
|
src/sb/XMPP/Presence.php
|
Presence.getPriority
|
public function getPriority($as_string=true)
{
$nodes = $this->doc->getElementsByTagName('priority');
$node =$nodes->item(0);
if($node){
if($as_string){
return $node->nodeValue;
} else {
return $node;
}
} else {
return '';
}
}
|
php
|
public function getPriority($as_string=true)
{
$nodes = $this->doc->getElementsByTagName('priority');
$node =$nodes->item(0);
if($node){
if($as_string){
return $node->nodeValue;
} else {
return $node;
}
} else {
return '';
}
}
|
[
"public",
"function",
"getPriority",
"(",
"$",
"as_string",
"=",
"true",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"doc",
"->",
"getElementsByTagName",
"(",
"'priority'",
")",
";",
"$",
"node",
"=",
"$",
"nodes",
"->",
"item",
"(",
"0",
")",
";",
"if",
"(",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"as_string",
")",
"{",
"return",
"$",
"node",
"->",
"nodeValue",
";",
"}",
"else",
"{",
"return",
"$",
"node",
";",
"}",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] |
Gets the priority value of a presence packet
@param boolean $as_string Determines if node is returned as xml node or string, true by default
@return string
|
[
"Gets",
"the",
"priority",
"value",
"of",
"a",
"presence",
"packet"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L99-L112
|
22,884
|
surebert/surebert-framework
|
src/sb/XMPP/Presence.php
|
Presence.setStatus
|
public function setStatus($status)
{
$node = $this->getStatus(false);
if(!$node){
$node = $this->createElement('status');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($status);
}
|
php
|
public function setStatus($status)
{
$node = $this->getStatus(false);
if(!$node){
$node = $this->createElement('status');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($status);
}
|
[
"public",
"function",
"setStatus",
"(",
"$",
"status",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getStatus",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'status'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"status",
")",
";",
"}"
] |
Set the status of the presence packet
@param string $status The status message to display in human readible format
|
[
"Set",
"the",
"status",
"of",
"the",
"presence",
"packet"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L119-L129
|
22,885
|
surebert/surebert-framework
|
src/sb/XMPP/Presence.php
|
Presence.setShow
|
public function setShow($show)
{
if($show == 'unavailable') {
$this->setType($show);
}
$node = $this->getShow(false);
if(!$node){
$node = $this->createElement('show');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($show);
}
|
php
|
public function setShow($show)
{
if($show == 'unavailable') {
$this->setType($show);
}
$node = $this->getShow(false);
if(!$node){
$node = $this->createElement('show');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($show);
}
|
[
"public",
"function",
"setShow",
"(",
"$",
"show",
")",
"{",
"if",
"(",
"$",
"show",
"==",
"'unavailable'",
")",
"{",
"$",
"this",
"->",
"setType",
"(",
"$",
"show",
")",
";",
"}",
"$",
"node",
"=",
"$",
"this",
"->",
"getShow",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'show'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"show",
")",
";",
"}"
] |
Shows the status of the bot
@param string $show A code to describe the state. see http://xmpp.org/rfcs/rfc3921.html
away - The entity or resource is temporarily away.
chat - The entity or resource is actively interested in chatting.
dnd - The entity or resource is busy (dnd = "Do Not Disturb").
xa - The entity or resource is away for an extended period (xa = "eXtended Away").
|
[
"Shows",
"the",
"status",
"of",
"the",
"bot"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L139-L154
|
22,886
|
surebert/surebert-framework
|
src/sb/XMPP/Presence.php
|
Presence.setPriority
|
public function setPriority($priority=1)
{
$node = $this->getPriority(false);
if(!$node){
$node = $this->createElement('priority');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($priority);
}
|
php
|
public function setPriority($priority=1)
{
$node = $this->getPriority(false);
if(!$node){
$node = $this->createElement('priority');
$this->doc->appendChild($node);
}
$node->nodeValue = htmlspecialchars($priority);
}
|
[
"public",
"function",
"setPriority",
"(",
"$",
"priority",
"=",
"1",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getPriority",
"(",
"false",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"createElement",
"(",
"'priority'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"node",
"->",
"nodeValue",
"=",
"htmlspecialchars",
"(",
"$",
"priority",
")",
";",
"}"
] |
Sets the priority of the presence
@param integer $priority
|
[
"Sets",
"the",
"priority",
"of",
"the",
"presence"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L160-L170
|
22,887
|
surebert/surebert-framework
|
src/sb/XMPP/Presence.php
|
Presence.setType
|
public function setType($type)
{
$attr = $this->createAttribute('type');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($type));
}
|
php
|
public function setType($type)
{
$attr = $this->createAttribute('type');
$this->doc->appendChild($attr);
$attr->appendChild($this->createTextNode($type));
}
|
[
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"$",
"attr",
"=",
"$",
"this",
"->",
"createAttribute",
"(",
"'type'",
")",
";",
"$",
"this",
"->",
"doc",
"->",
"appendChild",
"(",
"$",
"attr",
")",
";",
"$",
"attr",
"->",
"appendChild",
"(",
"$",
"this",
"->",
"createTextNode",
"(",
"$",
"type",
")",
")",
";",
"}"
] |
Sets the presence type
@param string $type see http://xmpp.org/rfcs/rfc3921.html for more info
unavailable -- Signals that the entity is no longer available for communication.
subscribe -- The sender wishes to subscribe to the recipient's presence.
subscribed -- The sender has allowed the recipient to receive their presence.
unsubscribe -- The sender is unsubscribing from another entity's presence.
unsubscribed -- The subscription request has been denied or a previously-granted subscription has been cancelled.
probe -- A request for an entity's current presence; SHOULD be generated only by a server on behalf of a user.
error -- An error has occurred regarding processing or delivery of a previously-sent presence stanza.
@return boolean If it is written or not
|
[
"Sets",
"the",
"presence",
"type"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/XMPP/Presence.php#L184-L189
|
22,888
|
eloquent/phony-kahlan
|
src/AssertionRecorder.php
|
AssertionRecorder.createFailure
|
public function createFailure(string $description)
{
$exception = new AssertionException($description);
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert([
'handler' => function () use ($exception) {
throw $exception;
},
'type' => AssertionException::class,
]);
}
|
php
|
public function createFailure(string $description)
{
$exception = new AssertionException($description);
$suiteClass = $this->suiteClass;
$suiteClass::current()->assert([
'handler' => function () use ($exception) {
throw $exception;
},
'type' => AssertionException::class,
]);
}
|
[
"public",
"function",
"createFailure",
"(",
"string",
"$",
"description",
")",
"{",
"$",
"exception",
"=",
"new",
"AssertionException",
"(",
"$",
"description",
")",
";",
"$",
"suiteClass",
"=",
"$",
"this",
"->",
"suiteClass",
";",
"$",
"suiteClass",
"::",
"current",
"(",
")",
"->",
"assert",
"(",
"[",
"'handler'",
"=>",
"function",
"(",
")",
"use",
"(",
"$",
"exception",
")",
"{",
"throw",
"$",
"exception",
";",
"}",
",",
"'type'",
"=>",
"AssertionException",
"::",
"class",
",",
"]",
")",
";",
"}"
] |
Create a new assertion failure exception.
@param string $description The failure description.
@throws AssertionException The assertion failure.
|
[
"Create",
"a",
"new",
"assertion",
"failure",
"exception",
"."
] |
a4654a7edf58268b492acc751ecbeddded9b176f
|
https://github.com/eloquent/phony-kahlan/blob/a4654a7edf58268b492acc751ecbeddded9b176f/src/AssertionRecorder.php#L81-L92
|
22,889
|
MASNathan/Parser
|
src/Type/Xml.php
|
Xml.encode
|
public static function encode($data, $prettyPrint = false, $xmlVersion = '1.0', $encoding = 'utf-8')
{
$domDocument = new DOMDocument($xmlVersion, $encoding);
$domDocument = self::loopEncode($data, $domDocument);
if ($prettyPrint) {
$domDocument->preserveWhiteSpace = false;
$domDocument->formatOutput = true;
}
$resultString = $domDocument->saveXML();
if (!$prettyPrint) {
$resultStringLines = explode(PHP_EOL, $resultString);
$documentLine = array_shift($resultStringLines);
$resultString = $documentLine . PHP_EOL . implode('', $resultStringLines);
} else {
$resultString = trim($resultString, PHP_EOL);
}
return $resultString;
}
|
php
|
public static function encode($data, $prettyPrint = false, $xmlVersion = '1.0', $encoding = 'utf-8')
{
$domDocument = new DOMDocument($xmlVersion, $encoding);
$domDocument = self::loopEncode($data, $domDocument);
if ($prettyPrint) {
$domDocument->preserveWhiteSpace = false;
$domDocument->formatOutput = true;
}
$resultString = $domDocument->saveXML();
if (!$prettyPrint) {
$resultStringLines = explode(PHP_EOL, $resultString);
$documentLine = array_shift($resultStringLines);
$resultString = $documentLine . PHP_EOL . implode('', $resultStringLines);
} else {
$resultString = trim($resultString, PHP_EOL);
}
return $resultString;
}
|
[
"public",
"static",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"prettyPrint",
"=",
"false",
",",
"$",
"xmlVersion",
"=",
"'1.0'",
",",
"$",
"encoding",
"=",
"'utf-8'",
")",
"{",
"$",
"domDocument",
"=",
"new",
"DOMDocument",
"(",
"$",
"xmlVersion",
",",
"$",
"encoding",
")",
";",
"$",
"domDocument",
"=",
"self",
"::",
"loopEncode",
"(",
"$",
"data",
",",
"$",
"domDocument",
")",
";",
"if",
"(",
"$",
"prettyPrint",
")",
"{",
"$",
"domDocument",
"->",
"preserveWhiteSpace",
"=",
"false",
";",
"$",
"domDocument",
"->",
"formatOutput",
"=",
"true",
";",
"}",
"$",
"resultString",
"=",
"$",
"domDocument",
"->",
"saveXML",
"(",
")",
";",
"if",
"(",
"!",
"$",
"prettyPrint",
")",
"{",
"$",
"resultStringLines",
"=",
"explode",
"(",
"PHP_EOL",
",",
"$",
"resultString",
")",
";",
"$",
"documentLine",
"=",
"array_shift",
"(",
"$",
"resultStringLines",
")",
";",
"$",
"resultString",
"=",
"$",
"documentLine",
".",
"PHP_EOL",
".",
"implode",
"(",
"''",
",",
"$",
"resultStringLines",
")",
";",
"}",
"else",
"{",
"$",
"resultString",
"=",
"trim",
"(",
"$",
"resultString",
",",
"PHP_EOL",
")",
";",
"}",
"return",
"$",
"resultString",
";",
"}"
] |
Encodes an array to xml strutcture
@param mixed $data Data to encode
@param boolean $prettyPrint True to output the encoded data a little bit more readable for the humans
@param string $xmlVersion XML header version
@param string $encoding XML header encoding
@return string
|
[
"Encodes",
"an",
"array",
"to",
"xml",
"strutcture"
] |
0f55402b99b1e071bdcd6277b9268f783ca25e34
|
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L19-L41
|
22,890
|
MASNathan/Parser
|
src/Type/Xml.php
|
Xml.loopEncode
|
protected static function loopEncode($data, $domElement)
{
if (is_array($data)) {
foreach ($data as $index => $mixedElement) {
if (is_int($index)) {
if ($index == 0) {
$node = $domElement;
} else {
$node = new DOMElement($domElement->tagName);
$domElement->parentNode->appendChild($node);
}
} else {
$node = new DOMElement($index);
$domElement->appendChild($node);
}
self::loopEncode($mixedElement, $node);
}
} else {
$domElement->appendChild(new DOMText($data));
}
return $domElement;
}
|
php
|
protected static function loopEncode($data, $domElement)
{
if (is_array($data)) {
foreach ($data as $index => $mixedElement) {
if (is_int($index)) {
if ($index == 0) {
$node = $domElement;
} else {
$node = new DOMElement($domElement->tagName);
$domElement->parentNode->appendChild($node);
}
} else {
$node = new DOMElement($index);
$domElement->appendChild($node);
}
self::loopEncode($mixedElement, $node);
}
} else {
$domElement->appendChild(new DOMText($data));
}
return $domElement;
}
|
[
"protected",
"static",
"function",
"loopEncode",
"(",
"$",
"data",
",",
"$",
"domElement",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"index",
"=>",
"$",
"mixedElement",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"index",
")",
")",
"{",
"if",
"(",
"$",
"index",
"==",
"0",
")",
"{",
"$",
"node",
"=",
"$",
"domElement",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"new",
"DOMElement",
"(",
"$",
"domElement",
"->",
"tagName",
")",
";",
"$",
"domElement",
"->",
"parentNode",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"}",
"else",
"{",
"$",
"node",
"=",
"new",
"DOMElement",
"(",
"$",
"index",
")",
";",
"$",
"domElement",
"->",
"appendChild",
"(",
"$",
"node",
")",
";",
"}",
"self",
"::",
"loopEncode",
"(",
"$",
"mixedElement",
",",
"$",
"node",
")",
";",
"}",
"}",
"else",
"{",
"$",
"domElement",
"->",
"appendChild",
"(",
"new",
"DOMText",
"(",
"$",
"data",
")",
")",
";",
"}",
"return",
"$",
"domElement",
";",
"}"
] |
Lets loop through our data
@param mixed $data Data to encode
@param DOMDocument|DOMElement $domElement Document to initialize and then it'll call itself with inner Element(s)
@return DOMDocument
|
[
"Lets",
"loop",
"through",
"our",
"data"
] |
0f55402b99b1e071bdcd6277b9268f783ca25e34
|
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L49-L72
|
22,891
|
MASNathan/Parser
|
src/Type/Xml.php
|
Xml.loopDecode
|
protected static function loopDecode($data)
{
if (is_array($data)) {
foreach ($data as &$value) {
$value = self::loopDecode($value);
}
} elseif (is_object($data)) {
return self::loopDecode((array) $data);
}
return $data;
}
|
php
|
protected static function loopDecode($data)
{
if (is_array($data)) {
foreach ($data as &$value) {
$value = self::loopDecode($value);
}
} elseif (is_object($data)) {
return self::loopDecode((array) $data);
}
return $data;
}
|
[
"protected",
"static",
"function",
"loopDecode",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"loopDecode",
"(",
"$",
"value",
")",
";",
"}",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"return",
"self",
"::",
"loopDecode",
"(",
"(",
"array",
")",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Turns all the objects into arrays
@param mixed $data Data
@return array
|
[
"Turns",
"all",
"the",
"objects",
"into",
"arrays"
] |
0f55402b99b1e071bdcd6277b9268f783ca25e34
|
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Type/Xml.php#L93-L103
|
22,892
|
surebert/surebert-framework
|
src/sb/Socket/StreamingClient.php
|
StreamingClient.read
|
public function read($byte_count=null)
{
$this->log('read from socket');
$buffer = '';
if(!is_null($byte_count)) {
//read the specified amount of data
$buffer .= fgets($this->socket, 1024);
} else {
//read all the data
while (!feof($this->socket)) {
$buffer .= fgets($this->socket, 1024);
}
}
return $buffer;
}
|
php
|
public function read($byte_count=null)
{
$this->log('read from socket');
$buffer = '';
if(!is_null($byte_count)) {
//read the specified amount of data
$buffer .= fgets($this->socket, 1024);
} else {
//read all the data
while (!feof($this->socket)) {
$buffer .= fgets($this->socket, 1024);
}
}
return $buffer;
}
|
[
"public",
"function",
"read",
"(",
"$",
"byte_count",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"'read from socket'",
")",
";",
"$",
"buffer",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"byte_count",
")",
")",
"{",
"//read the specified amount of data",
"$",
"buffer",
".=",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"1024",
")",
";",
"}",
"else",
"{",
"//read all the data",
"while",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"{",
"$",
"buffer",
".=",
"fgets",
"(",
"$",
"this",
"->",
"socket",
",",
"1024",
")",
";",
"}",
"}",
"return",
"$",
"buffer",
";",
"}"
] |
Read data from the socket
@param integer $byte_count The amount of data to read, if not set, it reads until feof
@return string The data read from the socket
|
[
"Read",
"data",
"from",
"the",
"socket"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Socket/StreamingClient.php#L66-L84
|
22,893
|
wenbinye/PhalconX
|
src/Annotation/Annotations.php
|
Annotations.import
|
public function import(array $classes)
{
foreach ($classes as $class => $alias) {
if (is_integer($class)) {
$class = $alias;
$alias = ClassHelper::getSimpleName($class);
}
if (isset($this->imports[$alias])) {
throw new \RuntimeException("Alias $alias for $class exists, previous is "
. $this->imports[$alias]);
}
$this->imports[$alias] = $class;
}
return $this;
}
|
php
|
public function import(array $classes)
{
foreach ($classes as $class => $alias) {
if (is_integer($class)) {
$class = $alias;
$alias = ClassHelper::getSimpleName($class);
}
if (isset($this->imports[$alias])) {
throw new \RuntimeException("Alias $alias for $class exists, previous is "
. $this->imports[$alias]);
}
$this->imports[$alias] = $class;
}
return $this;
}
|
[
"public",
"function",
"import",
"(",
"array",
"$",
"classes",
")",
"{",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
"=>",
"$",
"alias",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"$",
"alias",
";",
"$",
"alias",
"=",
"ClassHelper",
"::",
"getSimpleName",
"(",
"$",
"class",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Alias $alias for $class exists, previous is \"",
".",
"$",
"this",
"->",
"imports",
"[",
"$",
"alias",
"]",
")",
";",
"}",
"$",
"this",
"->",
"imports",
"[",
"$",
"alias",
"]",
"=",
"$",
"class",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Imports annotation classes
|
[
"Imports",
"annotation",
"classes"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L55-L69
|
22,894
|
wenbinye/PhalconX
|
src/Annotation/Annotations.php
|
Annotations.get
|
public function get($class)
{
$annotations = $this->getCache()->get('_PHX.annotations.' . $class);
if (!isset($annotations)) {
$annotations = $this->getAnnotations($class);
$this->getCache()->save('_PHX.annotations.' . $class, $annotations);
}
return $annotations;
}
|
php
|
public function get($class)
{
$annotations = $this->getCache()->get('_PHX.annotations.' . $class);
if (!isset($annotations)) {
$annotations = $this->getAnnotations($class);
$this->getCache()->save('_PHX.annotations.' . $class, $annotations);
}
return $annotations;
}
|
[
"public",
"function",
"get",
"(",
"$",
"class",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"get",
"(",
"'_PHX.annotations.'",
".",
"$",
"class",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"annotations",
")",
")",
"{",
"$",
"annotations",
"=",
"$",
"this",
"->",
"getAnnotations",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"save",
"(",
"'_PHX.annotations.'",
".",
"$",
"class",
",",
"$",
"annotations",
")",
";",
"}",
"return",
"$",
"annotations",
";",
"}"
] |
Gets all annotations in the class
@param string $class class name
@return array
|
[
"Gets",
"all",
"annotations",
"in",
"the",
"class"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L94-L102
|
22,895
|
wenbinye/PhalconX
|
src/Annotation/Annotations.php
|
Annotations.getAnnotations
|
private function getAnnotations($class)
{
$parsed = $this->getParser()->parse($class);
if (!is_array($parsed)) {
return [];
}
$context = [
'class' => $class,
'declaringClass' => $class,
'type' => Context::TYPE_CLASS,
'name' => $class
];
$annotations = [];
if (!empty($parsed['class'])) {
foreach ($parsed['class'] as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
$map = [
'methods' => Context::TYPE_METHOD,
'properties' => Context::TYPE_PROPERTY
];
$reflection = new \ReflectionClass($class);
foreach ($map as $type_name => $type) {
if (!empty($parsed[$type_name])) {
foreach ($parsed[$type_name] as $name => $values) {
$reflType = $type == 'method' ? $reflection->getMethod($name)
: $reflection->getProperty($name);
$context['type'] = $type;
$context['name'] = $name;
$context['declaringClass'] = $reflType->getDeclaringClass()->getName();
foreach ($values as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
}
}
return $annotations;
}
|
php
|
private function getAnnotations($class)
{
$parsed = $this->getParser()->parse($class);
if (!is_array($parsed)) {
return [];
}
$context = [
'class' => $class,
'declaringClass' => $class,
'type' => Context::TYPE_CLASS,
'name' => $class
];
$annotations = [];
if (!empty($parsed['class'])) {
foreach ($parsed['class'] as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
$map = [
'methods' => Context::TYPE_METHOD,
'properties' => Context::TYPE_PROPERTY
];
$reflection = new \ReflectionClass($class);
foreach ($map as $type_name => $type) {
if (!empty($parsed[$type_name])) {
foreach ($parsed[$type_name] as $name => $values) {
$reflType = $type == 'method' ? $reflection->getMethod($name)
: $reflection->getProperty($name);
$context['type'] = $type;
$context['name'] = $name;
$context['declaringClass'] = $reflType->getDeclaringClass()->getName();
foreach ($values as $value) {
$anno = $this->create($value, $context);
if ($anno) {
$annotations[] = $anno;
}
}
}
}
}
return $annotations;
}
|
[
"private",
"function",
"getAnnotations",
"(",
"$",
"class",
")",
"{",
"$",
"parsed",
"=",
"$",
"this",
"->",
"getParser",
"(",
")",
"->",
"parse",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"parsed",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"context",
"=",
"[",
"'class'",
"=>",
"$",
"class",
",",
"'declaringClass'",
"=>",
"$",
"class",
",",
"'type'",
"=>",
"Context",
"::",
"TYPE_CLASS",
",",
"'name'",
"=>",
"$",
"class",
"]",
";",
"$",
"annotations",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed",
"[",
"'class'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"parsed",
"[",
"'class'",
"]",
"as",
"$",
"value",
")",
"{",
"$",
"anno",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"value",
",",
"$",
"context",
")",
";",
"if",
"(",
"$",
"anno",
")",
"{",
"$",
"annotations",
"[",
"]",
"=",
"$",
"anno",
";",
"}",
"}",
"}",
"$",
"map",
"=",
"[",
"'methods'",
"=>",
"Context",
"::",
"TYPE_METHOD",
",",
"'properties'",
"=>",
"Context",
"::",
"TYPE_PROPERTY",
"]",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"type_name",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"parsed",
"[",
"$",
"type_name",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"parsed",
"[",
"$",
"type_name",
"]",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"$",
"reflType",
"=",
"$",
"type",
"==",
"'method'",
"?",
"$",
"reflection",
"->",
"getMethod",
"(",
"$",
"name",
")",
":",
"$",
"reflection",
"->",
"getProperty",
"(",
"$",
"name",
")",
";",
"$",
"context",
"[",
"'type'",
"]",
"=",
"$",
"type",
";",
"$",
"context",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"context",
"[",
"'declaringClass'",
"]",
"=",
"$",
"reflType",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"anno",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"value",
",",
"$",
"context",
")",
";",
"if",
"(",
"$",
"anno",
")",
"{",
"$",
"annotations",
"[",
"]",
"=",
"$",
"anno",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"annotations",
";",
"}"
] |
parse all annotations from class
|
[
"parse",
"all",
"annotations",
"from",
"class"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L129-L173
|
22,896
|
wenbinye/PhalconX
|
src/Annotation/Annotations.php
|
Annotations.create
|
private function create($annotation, $context)
{
$logger = $this->getLogger();
$name = $annotation['name'];
if (!$this->isValidName($name)) {
return null;
}
$annotationClass = $this->resolveClassName($name, $context['declaringClass']);
if (!$annotationClass) {
if (isset($this->imports[$name])) {
$annotationClass = $this->imports[$name];
} else {
$logger->warning("Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}");
return null;
}
}
if (!class_exists($annotationClass)) {
$logger->warning("Annotation class '$annotationClass' does not exist"
." at {$annotation['file']}:{$annotation['line']}");
return null;
}
if (!is_subclass_of($annotationClass, Annotation::class)) {
$logger->warning("Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}"
." is not subclass of " . Annotation::class);
return null;
}
$context['file'] = $annotation['file'];
$context['line'] = $annotation['line'];
$args = (new PhalconAnnotation($annotation))->getArguments() ?: [];
return new $annotationClass($args, new Context($context));
}
|
php
|
private function create($annotation, $context)
{
$logger = $this->getLogger();
$name = $annotation['name'];
if (!$this->isValidName($name)) {
return null;
}
$annotationClass = $this->resolveClassName($name, $context['declaringClass']);
if (!$annotationClass) {
if (isset($this->imports[$name])) {
$annotationClass = $this->imports[$name];
} else {
$logger->warning("Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}");
return null;
}
}
if (!class_exists($annotationClass)) {
$logger->warning("Annotation class '$annotationClass' does not exist"
." at {$annotation['file']}:{$annotation['line']}");
return null;
}
if (!is_subclass_of($annotationClass, Annotation::class)) {
$logger->warning("Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}"
." is not subclass of " . Annotation::class);
return null;
}
$context['file'] = $annotation['file'];
$context['line'] = $annotation['line'];
$args = (new PhalconAnnotation($annotation))->getArguments() ?: [];
return new $annotationClass($args, new Context($context));
}
|
[
"private",
"function",
"create",
"(",
"$",
"annotation",
",",
"$",
"context",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"name",
"=",
"$",
"annotation",
"[",
"'name'",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidName",
"(",
"$",
"name",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"annotationClass",
"=",
"$",
"this",
"->",
"resolveClassName",
"(",
"$",
"name",
",",
"$",
"context",
"[",
"'declaringClass'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"annotationClass",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"imports",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"annotationClass",
"=",
"$",
"this",
"->",
"imports",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Unknown annotation '$name' at {$annotation['file']}:{$annotation['line']}\"",
")",
";",
"return",
"null",
";",
"}",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"annotationClass",
")",
")",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Annotation class '$annotationClass' does not exist\"",
".",
"\" at {$annotation['file']}:{$annotation['line']}\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"annotationClass",
",",
"Annotation",
"::",
"class",
")",
")",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Annotation class '$annotationClass' at {$annotation['file']}:{$annotation['line']}\"",
".",
"\" is not subclass of \"",
".",
"Annotation",
"::",
"class",
")",
";",
"return",
"null",
";",
"}",
"$",
"context",
"[",
"'file'",
"]",
"=",
"$",
"annotation",
"[",
"'file'",
"]",
";",
"$",
"context",
"[",
"'line'",
"]",
"=",
"$",
"annotation",
"[",
"'line'",
"]",
";",
"$",
"args",
"=",
"(",
"new",
"PhalconAnnotation",
"(",
"$",
"annotation",
")",
")",
"->",
"getArguments",
"(",
")",
"?",
":",
"[",
"]",
";",
"return",
"new",
"$",
"annotationClass",
"(",
"$",
"args",
",",
"new",
"Context",
"(",
"$",
"context",
")",
")",
";",
"}"
] |
create annotation object
|
[
"create",
"annotation",
"object"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Annotation/Annotations.php#L178-L208
|
22,897
|
juskiewicz/Geolocation
|
src/Build/AddressBuild.php
|
AddressBuild.updateAddressFromComponent
|
private function updateAddressFromComponent(Address $address, $component) : Address
{
foreach ($component->types as $type) {
switch ($type) {
case 'postal_code':
$address->setPostalCode($component->long_name);
break;
case 'locality':
case 'postal_town':
$address->setLocality($component->long_name);
break;
case 'country':
$address->setCountry($component->long_name);
$address->setCountryCode($component->short_name);
break;
case 'street_number':
$address->setStreetNumber($component->long_name);
break;
case 'route':
$address->setStreetName($component->long_name);
break;
case 'administrative_area_level_1':
case 'administrative_area_level_2':
case 'administrative_area_level_3':
case 'administrative_area_level_4':
case 'administrative_area_level_5':
case 'sublocality':
case 'sublocality_level_1':
case 'sublocality_level_2':
case 'sublocality_level_3':
case 'sublocality_level_4':
case 'sublocality_level_5':
case 'street_address':
case 'intersection':
case 'political':
case 'colloquial_area':
case 'ward':
case 'neighborhood':
case 'premise':
case 'subpremise':
case 'natural_feature':
case 'airport':
case 'park':
case 'point_of_interest':
case 'establishment':
// TODO implements method
break;
default:
}
}
return $address;
}
|
php
|
private function updateAddressFromComponent(Address $address, $component) : Address
{
foreach ($component->types as $type) {
switch ($type) {
case 'postal_code':
$address->setPostalCode($component->long_name);
break;
case 'locality':
case 'postal_town':
$address->setLocality($component->long_name);
break;
case 'country':
$address->setCountry($component->long_name);
$address->setCountryCode($component->short_name);
break;
case 'street_number':
$address->setStreetNumber($component->long_name);
break;
case 'route':
$address->setStreetName($component->long_name);
break;
case 'administrative_area_level_1':
case 'administrative_area_level_2':
case 'administrative_area_level_3':
case 'administrative_area_level_4':
case 'administrative_area_level_5':
case 'sublocality':
case 'sublocality_level_1':
case 'sublocality_level_2':
case 'sublocality_level_3':
case 'sublocality_level_4':
case 'sublocality_level_5':
case 'street_address':
case 'intersection':
case 'political':
case 'colloquial_area':
case 'ward':
case 'neighborhood':
case 'premise':
case 'subpremise':
case 'natural_feature':
case 'airport':
case 'park':
case 'point_of_interest':
case 'establishment':
// TODO implements method
break;
default:
}
}
return $address;
}
|
[
"private",
"function",
"updateAddressFromComponent",
"(",
"Address",
"$",
"address",
",",
"$",
"component",
")",
":",
"Address",
"{",
"foreach",
"(",
"$",
"component",
"->",
"types",
"as",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'postal_code'",
":",
"$",
"address",
"->",
"setPostalCode",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'locality'",
":",
"case",
"'postal_town'",
":",
"$",
"address",
"->",
"setLocality",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'country'",
":",
"$",
"address",
"->",
"setCountry",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"$",
"address",
"->",
"setCountryCode",
"(",
"$",
"component",
"->",
"short_name",
")",
";",
"break",
";",
"case",
"'street_number'",
":",
"$",
"address",
"->",
"setStreetNumber",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'route'",
":",
"$",
"address",
"->",
"setStreetName",
"(",
"$",
"component",
"->",
"long_name",
")",
";",
"break",
";",
"case",
"'administrative_area_level_1'",
":",
"case",
"'administrative_area_level_2'",
":",
"case",
"'administrative_area_level_3'",
":",
"case",
"'administrative_area_level_4'",
":",
"case",
"'administrative_area_level_5'",
":",
"case",
"'sublocality'",
":",
"case",
"'sublocality_level_1'",
":",
"case",
"'sublocality_level_2'",
":",
"case",
"'sublocality_level_3'",
":",
"case",
"'sublocality_level_4'",
":",
"case",
"'sublocality_level_5'",
":",
"case",
"'street_address'",
":",
"case",
"'intersection'",
":",
"case",
"'political'",
":",
"case",
"'colloquial_area'",
":",
"case",
"'ward'",
":",
"case",
"'neighborhood'",
":",
"case",
"'premise'",
":",
"case",
"'subpremise'",
":",
"case",
"'natural_feature'",
":",
"case",
"'airport'",
":",
"case",
"'park'",
":",
"case",
"'point_of_interest'",
":",
"case",
"'establishment'",
":",
"// TODO implements method",
"break",
";",
"default",
":",
"}",
"}",
"return",
"$",
"address",
";",
"}"
] |
update address from google address component
@param Address $address
@param object $component Google address component object
@return Address
|
[
"update",
"address",
"from",
"google",
"address",
"component"
] |
5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d
|
https://github.com/juskiewicz/Geolocation/blob/5d3cd393961b92bdfbe2dfe631fbfb62c72dc36d/src/Build/AddressBuild.php#L60-L112
|
22,898
|
surebert/surebert-framework
|
src/sb/Cache/FileSystem.php
|
FileSystem.clearDir
|
protected function clearDir($dir)
{
$iterator = new \DirectoryIterator($dir);
foreach ($iterator as $file) {
if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
$this->clearDir($file->getPathname());
if (!\rmdir($file->getPathname())) {
return false;
}
} elseif ($file->isFile()) {
if (!\unlink($file->getPathname())) {
return false;
}
}
}
return true;
}
|
php
|
protected function clearDir($dir)
{
$iterator = new \DirectoryIterator($dir);
foreach ($iterator as $file) {
if ($file->isDir() && !$file->isDot() && !preg_match("~\.~", $file)) {
$this->clearDir($file->getPathname());
if (!\rmdir($file->getPathname())) {
return false;
}
} elseif ($file->isFile()) {
if (!\unlink($file->getPathname())) {
return false;
}
}
}
return true;
}
|
[
"protected",
"function",
"clearDir",
"(",
"$",
"dir",
")",
"{",
"$",
"iterator",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"dir",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"!",
"$",
"file",
"->",
"isDot",
"(",
")",
"&&",
"!",
"preg_match",
"(",
"\"~\\.~\"",
",",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"clearDir",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"if",
"(",
"!",
"\\",
"rmdir",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"elseif",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"if",
"(",
"!",
"\\",
"unlink",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
Clears out the contents of a cache directory
@param $dir
@return boolean
|
[
"Clears",
"out",
"the",
"contents",
"of",
"a",
"cache",
"directory"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L177-L195
|
22,899
|
surebert/surebert-framework
|
src/sb/Cache/FileSystem.php
|
FileSystem.catalogKeyDelete
|
protected function catalogKeyDelete($key)
{
$catalog = $this->fetch($this->catalog_key);
$catalog = \is_array($catalog) ? $catalog : Array();
if (isset($catalog[$key])) {
unset($catalog[$key]);
};
return $this->store('/sb_Cache_Catalog', $catalog);
}
|
php
|
protected function catalogKeyDelete($key)
{
$catalog = $this->fetch($this->catalog_key);
$catalog = \is_array($catalog) ? $catalog : Array();
if (isset($catalog[$key])) {
unset($catalog[$key]);
};
return $this->store('/sb_Cache_Catalog', $catalog);
}
|
[
"protected",
"function",
"catalogKeyDelete",
"(",
"$",
"key",
")",
"{",
"$",
"catalog",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"this",
"->",
"catalog_key",
")",
";",
"$",
"catalog",
"=",
"\\",
"is_array",
"(",
"$",
"catalog",
")",
"?",
"$",
"catalog",
":",
"Array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"catalog",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"catalog",
"[",
"$",
"key",
"]",
")",
";",
"}",
";",
"return",
"$",
"this",
"->",
"store",
"(",
"'/sb_Cache_Catalog'",
",",
"$",
"catalog",
")",
";",
"}"
] |
Deletes a key from the catalog
@param string $key The key to delete
@return boolean
|
[
"Deletes",
"a",
"key",
"from",
"the",
"catalog"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/FileSystem.php#L226-L235
|
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.