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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
39,600 | mcaskill/charcoal-support | src/Cms/ContextualTemplateTrait.php | ContextualTemplateTrait.contextObject | public function contextObject()
{
if ($this->contextObject === null) {
$this->contextObject = $this->createGenericContext();
}
return $this->contextObject;
} | php | public function contextObject()
{
if ($this->contextObject === null) {
$this->contextObject = $this->createGenericContext();
}
return $this->contextObject;
} | [
"public",
"function",
"contextObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contextObject",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"contextObject",
"=",
"$",
"this",
"->",
"createGenericContext",
"(",
")",
";",
"}",
"return",
"$",
"this",
... | Retrieve the current object relative to the context.
This method is meant to be reimplemented in a child template controller
to return the resolved object that the module considers "the context".
@return ModelInterface|null | [
"Retrieve",
"the",
"current",
"object",
"relative",
"to",
"the",
"context",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/ContextualTemplateTrait.php#L107-L114 |
39,601 | mcaskill/charcoal-support | src/Cms/ContextualTemplateTrait.php | ContextualTemplateTrait.createGenericContext | protected function createGenericContext()
{
if ($this->isCreatingContext) {
return null;
}
$this->isCreatingContext = true;
$obj = $this->modelFactory()->create($this->genericContextClass());
$baseUrl = $this->baseUrl();
if ($this->routeEndpoint) {
$endpoint = $this->translator()->translation($this->routeEndpoint);
foreach ($this->translator()->availableLocales() as $lang) {
$uri = $baseUrl->withPath($endpoint[$lang]);
if ($this->routeGroup) {
$uri = $uri->withBasePath($this->routeGroup[$lang]);
}
$base = $uri->getBasePath();
$path = $uri->getPath();
$path = $base . '/' . ltrim($path, '/');
$endpoint[$lang] = $path;
}
} else {
$endpoint = null;
}
$obj['url'] = $endpoint;
$obj['title'] = $this->title();
$this->isCreatingContext = false;
return $obj;
} | php | protected function createGenericContext()
{
if ($this->isCreatingContext) {
return null;
}
$this->isCreatingContext = true;
$obj = $this->modelFactory()->create($this->genericContextClass());
$baseUrl = $this->baseUrl();
if ($this->routeEndpoint) {
$endpoint = $this->translator()->translation($this->routeEndpoint);
foreach ($this->translator()->availableLocales() as $lang) {
$uri = $baseUrl->withPath($endpoint[$lang]);
if ($this->routeGroup) {
$uri = $uri->withBasePath($this->routeGroup[$lang]);
}
$base = $uri->getBasePath();
$path = $uri->getPath();
$path = $base . '/' . ltrim($path, '/');
$endpoint[$lang] = $path;
}
} else {
$endpoint = null;
}
$obj['url'] = $endpoint;
$obj['title'] = $this->title();
$this->isCreatingContext = false;
return $obj;
} | [
"protected",
"function",
"createGenericContext",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isCreatingContext",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"isCreatingContext",
"=",
"true",
";",
"$",
"obj",
"=",
"$",
"this",
"->",
"modelF... | Create a generic object relative to the context.
@return ModelInterface|null | [
"Create",
"a",
"generic",
"object",
"relative",
"to",
"the",
"context",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/ContextualTemplateTrait.php#L121-L157 |
39,602 | mcaskill/charcoal-support | src/Cms/ContextualTemplateTrait.php | ContextualTemplateTrait.setRouteGroup | public function setRouteGroup($path)
{
$group = $this->translator()->translation($path);
foreach ($this->translator()->availableLocales() as $lang) {
$group[$lang] = trim($group[$lang], '/');
}
$this->routeGroup = $group;
return $this;
} | php | public function setRouteGroup($path)
{
$group = $this->translator()->translation($path);
foreach ($this->translator()->availableLocales() as $lang) {
$group[$lang] = trim($group[$lang], '/');
}
$this->routeGroup = $group;
return $this;
} | [
"public",
"function",
"setRouteGroup",
"(",
"$",
"path",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"translation",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"availa... | Append a path to the base URI.
@param string $path The base path.
@return self | [
"Append",
"a",
"path",
"to",
"the",
"base",
"URI",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/ContextualTemplateTrait.php#L181-L192 |
39,603 | mcaskill/charcoal-support | src/Cms/ContextualTemplateTrait.php | ContextualTemplateTrait.setRouteEndpoint | public function setRouteEndpoint($path)
{
$endpoint = $this->translator()->translation($path);
foreach ($this->translator()->availableLocales() as $lang) {
$endpoint[$lang] = trim($endpoint[$lang], '/');
}
$this->routeEndpoint = $endpoint;
return $this;
} | php | public function setRouteEndpoint($path)
{
$endpoint = $this->translator()->translation($path);
foreach ($this->translator()->availableLocales() as $lang) {
$endpoint[$lang] = trim($endpoint[$lang], '/');
}
$this->routeEndpoint = $endpoint;
return $this;
} | [
"public",
"function",
"setRouteEndpoint",
"(",
"$",
"path",
")",
"{",
"$",
"endpoint",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"translation",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"... | Append a path to the URI.
@param string $path The main path.
@return self | [
"Append",
"a",
"path",
"to",
"the",
"URI",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/ContextualTemplateTrait.php#L200-L211 |
39,604 | mcaskill/charcoal-support | src/Model/Collection.php | Collection.only | public function only($keys)
{
if ($keys === null) {
return new static($this->objects);
}
$keys = is_array($keys) ? $keys : func_get_args();
return new static(array_intersect_key($this->objects, array_flip($keys)));
} | php | public function only($keys)
{
if ($keys === null) {
return new static($this->objects);
}
$keys = is_array($keys) ? $keys : func_get_args();
return new static(array_intersect_key($this->objects, array_flip($keys)));
} | [
"public",
"function",
"only",
"(",
"$",
"keys",
")",
"{",
"if",
"(",
"$",
"keys",
"===",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"this",
"->",
"objects",
")",
";",
"}",
"$",
"keys",
"=",
"is_array",
"(",
"$",
"keys",
")",
"?",
"$... | Extract the objects with the specified keys.
@param mixed $keys One or more object primary keys.
@return static | [
"Extract",
"the",
"objects",
"with",
"the",
"specified",
"keys",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Model/Collection.php#L170-L179 |
39,605 | mcaskill/charcoal-support | src/Model/Collection.php | Collection.slice | public function slice($offset, $length = null)
{
return new static(array_slice($this->objects, $offset, $length, true));
} | php | public function slice($offset, $length = null)
{
return new static(array_slice($this->objects, $offset, $length, true));
} | [
"public",
"function",
"slice",
"(",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"array_slice",
"(",
"$",
"this",
"->",
"objects",
",",
"$",
"offset",
",",
"$",
"length",
",",
"true",
")",
")",
";",
"}"
... | Extract a slice of the collection.
@param integer $offset See {@see array_slice()} for a description of $offset.
@param integer $length See {@see array_slice()} for a description of $length.
@return static | [
"Extract",
"a",
"slice",
"of",
"the",
"collection",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Model/Collection.php#L188-L191 |
39,606 | mcaskill/charcoal-support | src/Model/Collection.php | Collection.sortBy | public function sortBy($sortBy, $options = SORT_REGULAR, $descending = false)
{
$results = [];
if (is_string($sortBy)) {
$callback = function ($obj) use ($sortBy) {
return $obj[$sortBy];
};
} elseif (is_callable($sortBy)) {
$callback = $sortBy;
} else {
throw new InvalidArgumentException(sprintf(
'The comparator must be a property key or a function, received %s',
(is_object($sortBy) ? get_class($sortBy) : gettype($sortBy))
));
}
// First we will loop through the items and get the comparator from a callback
// function which we were given. Then, we will sort the returned values and
// and grab the corresponding values for the sorted keys from this array.
foreach ($this->objects as $key => $obj) {
$results[$key] = $callback($obj, $key);
}
if ($descending) {
arsort($results, $options);
} else {
asort($results, $options);
}
// Once we have sorted all of the keys in the array, we will loop through them
// and grab the corresponding model so we can set the underlying items list
// to the sorted version. Then we'll just return the collection instance.
foreach (array_keys($results) as $key) {
$results[$key] = $this->objects[$key];
}
$this->objects = $results;
return $this;
} | php | public function sortBy($sortBy, $options = SORT_REGULAR, $descending = false)
{
$results = [];
if (is_string($sortBy)) {
$callback = function ($obj) use ($sortBy) {
return $obj[$sortBy];
};
} elseif (is_callable($sortBy)) {
$callback = $sortBy;
} else {
throw new InvalidArgumentException(sprintf(
'The comparator must be a property key or a function, received %s',
(is_object($sortBy) ? get_class($sortBy) : gettype($sortBy))
));
}
// First we will loop through the items and get the comparator from a callback
// function which we were given. Then, we will sort the returned values and
// and grab the corresponding values for the sorted keys from this array.
foreach ($this->objects as $key => $obj) {
$results[$key] = $callback($obj, $key);
}
if ($descending) {
arsort($results, $options);
} else {
asort($results, $options);
}
// Once we have sorted all of the keys in the array, we will loop through them
// and grab the corresponding model so we can set the underlying items list
// to the sorted version. Then we'll just return the collection instance.
foreach (array_keys($results) as $key) {
$results[$key] = $this->objects[$key];
}
$this->objects = $results;
return $this;
} | [
"public",
"function",
"sortBy",
"(",
"$",
"sortBy",
",",
"$",
"options",
"=",
"SORT_REGULAR",
",",
"$",
"descending",
"=",
"false",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"if",
"(",
"is_string",
"(",
"$",
"sortBy",
")",
")",
"{",
"$",
"callb... | Sort the collection by the given callback or object property.
If a {@see \Closure} is passed, it accepts two parameters.
The collection's object first, and its primary key second.
```
mixed callback ( ModelInterface $obj, integer|string $key )
```
@param callable|string $sortBy Sort by a property or a callback.
@param integer $options See {@see sort()} for a description of $sort_flags.
@param boolean $descending If TRUE, the collection is sorted in reverse order.
@throws InvalidArgumentException If the comparator is not a string or callback.
@return self | [
"Sort",
"the",
"collection",
"by",
"the",
"given",
"callback",
"or",
"object",
"property",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Model/Collection.php#L236-L276 |
39,607 | paulbunyannet/bandolier | src/Bandolier/Type/Arrays.php | Arrays.doDefaultAttributes | public function doDefaultAttributes()
{
foreach ((array)$this->attribute as $name => $value) {
if (array_key_exists($name, $this->data)) {
$this->data[$name] = $value;
}
}
return ($this->data) ? $this->data : false;
} | php | public function doDefaultAttributes()
{
foreach ((array)$this->attribute as $name => $value) {
if (array_key_exists($name, $this->data)) {
$this->data[$name] = $value;
}
}
return ($this->data) ? $this->data : false;
} | [
"public",
"function",
"doDefaultAttributes",
"(",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"attribute",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"... | From default attribute list, overwrite if key is found
@return array|boolean | [
"From",
"default",
"attribute",
"list",
"overwrite",
"if",
"key",
"is",
"found"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Arrays.php#L57-L65 |
39,608 | paulbunyannet/bandolier | src/Bandolier/Type/Arrays.php | Arrays.doGetAttribute | public function doGetAttribute()
{
return array_key_exists($this->attribute, $this->data) ? $this->data[$this->attribute] : $this->default;
} | php | public function doGetAttribute()
{
return array_key_exists($this->attribute, $this->data) ? $this->data[$this->attribute] : $this->default;
} | [
"public",
"function",
"doGetAttribute",
"(",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"this",
"->",
"attribute",
",",
"$",
"this",
"->",
"data",
")",
"?",
"$",
"this",
"->",
"data",
"[",
"$",
"this",
"->",
"attribute",
"]",
":",
"$",
"this",
... | Check for key in array, return default is not found
@return mixed | [
"Check",
"for",
"key",
"in",
"array",
"return",
"default",
"is",
"not",
"found"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Arrays.php#L82-L85 |
39,609 | gregorybesson/PlaygroundReward | src/Controller/Frontend/IndexController.php | IndexController.getObjectService | public function getObjectService()
{
if (!$this->objectService) {
$this->objectService = $this->getServiceLocator()->get('playgroundflow_object_service');
}
return $this->objectService;
} | php | public function getObjectService()
{
if (!$this->objectService) {
$this->objectService = $this->getServiceLocator()->get('playgroundflow_object_service');
}
return $this->objectService;
} | [
"public",
"function",
"getObjectService",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"objectService",
")",
"{",
"$",
"this",
"->",
"objectService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'playgroundflow_object_servic... | retrieve object service
@return Service/Object $objectService | [
"retrieve",
"object",
"service"
] | 313ba96f530f27066ebaec6613f78c9bfe257862 | https://github.com/gregorybesson/PlaygroundReward/blob/313ba96f530f27066ebaec6613f78c9bfe257862/src/Controller/Frontend/IndexController.php#L249-L255 |
39,610 | gregorybesson/PlaygroundReward | src/Controller/Frontend/IndexController.php | IndexController.getLeaderboardService | public function getLeaderboardService()
{
if (!$this->leaderboardService) {
$this->leaderboardService = $this->getServiceLocator()->get(\PlaygroundReward\Service\LeaderBoard::class);
}
return $this->leaderboardService;
} | php | public function getLeaderboardService()
{
if (!$this->leaderboardService) {
$this->leaderboardService = $this->getServiceLocator()->get(\PlaygroundReward\Service\LeaderBoard::class);
}
return $this->leaderboardService;
} | [
"public",
"function",
"getLeaderboardService",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"leaderboardService",
")",
"{",
"$",
"this",
"->",
"leaderboardService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"\\",
"Playgr... | retrieve leaderboard service
@return Service/leaderboard $leaderboardService | [
"retrieve",
"leaderboard",
"service"
] | 313ba96f530f27066ebaec6613f78c9bfe257862 | https://github.com/gregorybesson/PlaygroundReward/blob/313ba96f530f27066ebaec6613f78c9bfe257862/src/Controller/Frontend/IndexController.php#L262-L269 |
39,611 | gregorybesson/PlaygroundReward | src/Controller/Frontend/IndexController.php | IndexController.getStoryTellingService | public function getStoryTellingService()
{
if (!$this->storyTellingService) {
$this->storyTellingService = $this->getServiceLocator()->get('playgroundflow_storytelling_service');
}
return $this->storyTellingService;
} | php | public function getStoryTellingService()
{
if (!$this->storyTellingService) {
$this->storyTellingService = $this->getServiceLocator()->get('playgroundflow_storytelling_service');
}
return $this->storyTellingService;
} | [
"public",
"function",
"getStoryTellingService",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"storyTellingService",
")",
"{",
"$",
"this",
"->",
"storyTellingService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'playground... | retrieve storyTelling service
@return Service/storyTelling $storyTellingService | [
"retrieve",
"storyTelling",
"service"
] | 313ba96f530f27066ebaec6613f78c9bfe257862 | https://github.com/gregorybesson/PlaygroundReward/blob/313ba96f530f27066ebaec6613f78c9bfe257862/src/Controller/Frontend/IndexController.php#L316-L323 |
39,612 | mcaskill/charcoal-support | src/Cms/HasTemplateOptionsTrait.php | HasTemplateOptionsTrait.getTemplateOptions | protected function getTemplateOptions($key = null, $default = null)
{
if ($this->templateOptions === null) {
$this->templateOptions = $this->buildTemplateOptions();
}
if ($key) {
if (isset($this->templateOptions[$key])) {
return $this->templateOptions[$key];
} else {
if (!is_string($default) && is_callable($default)) {
return $default();
} else {
return $default;
}
}
}
return $this->templateOptions;
} | php | protected function getTemplateOptions($key = null, $default = null)
{
if ($this->templateOptions === null) {
$this->templateOptions = $this->buildTemplateOptions();
}
if ($key) {
if (isset($this->templateOptions[$key])) {
return $this->templateOptions[$key];
} else {
if (!is_string($default) && is_callable($default)) {
return $default();
} else {
return $default;
}
}
}
return $this->templateOptions;
} | [
"protected",
"function",
"getTemplateOptions",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"templateOptions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"templateOptions",
"=",
"$",
"this",
"... | Retrieve the template options from the current context.
@param string|null $key Optional data key to retrieve from the configset.
@param mixed|null $default The default value to return if data key does not exist.
@return mixed|array | [
"Retrieve",
"the",
"template",
"options",
"from",
"the",
"current",
"context",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/HasTemplateOptionsTrait.php#L27-L46 |
39,613 | mcaskill/charcoal-support | src/Cms/HasTemplateOptionsTrait.php | HasTemplateOptionsTrait.hasTemplateOption | protected function hasTemplateOption($key)
{
if ($this->templateOptions === null) {
$this->templateOptions = $this->buildTemplateOptions();
}
return isset($this->templateOptions[$key]);
} | php | protected function hasTemplateOption($key)
{
if ($this->templateOptions === null) {
$this->templateOptions = $this->buildTemplateOptions();
}
return isset($this->templateOptions[$key]);
} | [
"protected",
"function",
"hasTemplateOption",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"templateOptions",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"templateOptions",
"=",
"$",
"this",
"->",
"buildTemplateOptions",
"(",
")",
";",
"}",
"... | Determine if the template option exists.
@param string $key Data key to check.
@return boolean | [
"Determine",
"if",
"the",
"template",
"option",
"exists",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Cms/HasTemplateOptionsTrait.php#L54-L61 |
39,614 | cmsgears/module-core | common/models/base/Follower.php | Follower.findByFollower | public static function findByFollower( $modelId, $parentId, $type = self::TYPE_FOLLOW ) {
return self::find()->where( 'modelId=:mid AND parentId=:pid AND type =:type', [ ':mid' => $modelId, ':pid' => $parentId, ':type' => $type ] )->one();
} | php | public static function findByFollower( $modelId, $parentId, $type = self::TYPE_FOLLOW ) {
return self::find()->where( 'modelId=:mid AND parentId=:pid AND type =:type', [ ':mid' => $modelId, ':pid' => $parentId, ':type' => $type ] )->one();
} | [
"public",
"static",
"function",
"findByFollower",
"(",
"$",
"modelId",
",",
"$",
"parentId",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_FOLLOW",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'modelId=:mid AND parentId=:pid AND type =... | Find and return the follower using given follower id, parent id and type.
@param integer $modelId
@param integer $followerId
@param integer $type
@return Follower | [
"Find",
"and",
"return",
"the",
"follower",
"using",
"given",
"follower",
"id",
"parent",
"id",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Follower.php#L291-L294 |
39,615 | cmsgears/module-core | common/models/base/Follower.php | Follower.isExistByFollower | public static function isExistByFollower( $modelId, $parentId, $type = self::TYPE_FOLLOW ) {
$follower = self::findByFollower( $modelId, $parentId, $type );
return isset( $follower );
} | php | public static function isExistByFollower( $modelId, $parentId, $type = self::TYPE_FOLLOW ) {
$follower = self::findByFollower( $modelId, $parentId, $type );
return isset( $follower );
} | [
"public",
"static",
"function",
"isExistByFollower",
"(",
"$",
"modelId",
",",
"$",
"parentId",
",",
"$",
"type",
"=",
"self",
"::",
"TYPE_FOLLOW",
")",
"{",
"$",
"follower",
"=",
"self",
"::",
"findByFollower",
"(",
"$",
"modelId",
",",
"$",
"parentId",
... | Check whether follower exist using given follower id, parent id and type.
@param integer $modelId
@param integer $parentId
@param integer $type
@return boolean | [
"Check",
"whether",
"follower",
"exist",
"using",
"given",
"follower",
"id",
"parent",
"id",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/Follower.php#L304-L309 |
39,616 | cmsgears/module-core | common/base/PageWidget.php | PageWidget.initPaging | public function initPaging( $config = [] ) {
// Init Pagination
if( $this->pagination && $this->paging && isset( $this->dataProvider ) ) {
$pagination = $this->dataProvider->getPagination();
$this->pageInfo = CodeGenUtil::getPaginationDetail( $this->dataProvider );
if( isset( $this->route ) ) {
$pagination->route = $this->route;
}
if( count( $this->excludeParams ) > 0 ) {
$pagination->excludeParams = $this->excludeParams;
}
$this->pageLinks = LinkPager::widget([
'pagination' => $pagination, 'disabledPageCssClass' => 'link-disabled',
'nextPageLabel' => $this->nextLabel, 'prevPageLabel' => $this->prevLabel
]);
}
} | php | public function initPaging( $config = [] ) {
// Init Pagination
if( $this->pagination && $this->paging && isset( $this->dataProvider ) ) {
$pagination = $this->dataProvider->getPagination();
$this->pageInfo = CodeGenUtil::getPaginationDetail( $this->dataProvider );
if( isset( $this->route ) ) {
$pagination->route = $this->route;
}
if( count( $this->excludeParams ) > 0 ) {
$pagination->excludeParams = $this->excludeParams;
}
$this->pageLinks = LinkPager::widget([
'pagination' => $pagination, 'disabledPageCssClass' => 'link-disabled',
'nextPageLabel' => $this->nextLabel, 'prevPageLabel' => $this->prevLabel
]);
}
} | [
"public",
"function",
"initPaging",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"// Init Pagination",
"if",
"(",
"$",
"this",
"->",
"pagination",
"&&",
"$",
"this",
"->",
"paging",
"&&",
"isset",
"(",
"$",
"this",
"->",
"dataProvider",
")",
")",
"{",
... | Initialise paging if applicable. | [
"Initialise",
"paging",
"if",
"applicable",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/base/PageWidget.php#L193-L217 |
39,617 | cmsgears/module-core | common/services/resources/ModelCommentService.php | ModelCommentService.getPageForApproved | public function getPageForApproved( $config = [] ) {
$modelTable = $this->getModelTable();
$topLevel = isset( $config[ 'topLevel' ] ) ? $config[ 'topLevel' ] : true;
if( $topLevel ) {
$config[ 'conditions' ][ 'baseId' ] = null;
}
$config[ 'conditions' ][ "$modelTable.status" ] = ModelComment::STATUS_APPROVED;
return $this->getPage( $config );
} | php | public function getPageForApproved( $config = [] ) {
$modelTable = $this->getModelTable();
$topLevel = isset( $config[ 'topLevel' ] ) ? $config[ 'topLevel' ] : true;
if( $topLevel ) {
$config[ 'conditions' ][ 'baseId' ] = null;
}
$config[ 'conditions' ][ "$modelTable.status" ] = ModelComment::STATUS_APPROVED;
return $this->getPage( $config );
} | [
"public",
"function",
"getPageForApproved",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelTable",
"=",
"$",
"this",
"->",
"getModelTable",
"(",
")",
";",
"$",
"topLevel",
"=",
"isset",
"(",
"$",
"config",
"[",
"'topLevel'",
"]",
")",
"?",
"... | We can pass parentType as condition to utilize the classification. | [
"We",
"can",
"pass",
"parentType",
"as",
"condition",
"to",
"utilize",
"the",
"classification",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/resources/ModelCommentService.php#L313-L326 |
39,618 | cmsgears/module-core | common/services/resources/ModelCommentService.php | ModelCommentService.getByBaseId | public function getByBaseId( $baseId, $config = [] ) {
$modelClass = self::$modelClass;
return $modelClass::queryByBaseId( $baseId, $config )->all();
} | php | public function getByBaseId( $baseId, $config = [] ) {
$modelClass = self::$modelClass;
return $modelClass::queryByBaseId( $baseId, $config )->all();
} | [
"public",
"function",
"getByBaseId",
"(",
"$",
"baseId",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"modelClass",
"=",
"self",
"::",
"$",
"modelClass",
";",
"return",
"$",
"modelClass",
"::",
"queryByBaseId",
"(",
"$",
"baseId",
",",
"$",
"confi... | It returns immediate child comments for given base id. | [
"It",
"returns",
"immediate",
"child",
"comments",
"for",
"given",
"base",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/resources/ModelCommentService.php#L335-L340 |
39,619 | cmsgears/module-core | common/models/base/ModelResource.php | ModelResource.queryByParent | public static function queryByParent( $parentId, $parentType, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'parentId=:pid AND parentType=:ptype AND siteId=:siteId', [ ':pid' => $parentId, ':ptype' => $parentType, ':siteId' => $siteId ] );
}
else {
return static::find()->where( 'parentId=:pid AND parentType=:ptype', [ ':pid' => $parentId, ':ptype' => $parentType ] );
}
} | php | public static function queryByParent( $parentId, $parentType, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'parentId=:pid AND parentType=:ptype AND siteId=:siteId', [ ':pid' => $parentId, ':ptype' => $parentType, ':siteId' => $siteId ] );
}
else {
return static::find()->where( 'parentId=:pid AND parentType=:ptype', [ ':pid' => $parentId, ':ptype' => $parentType ] );
}
} | [
"public",
"static",
"function",
"queryByParent",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"... | Return query to find the models by given parent id and parent type.
@param integer $parentId
@param string $parentType
@param array $config
@return \yii\db\ActiveQuery to query by parent id and parent type. | [
"Return",
"query",
"to",
"find",
"the",
"models",
"by",
"given",
"parent",
"id",
"and",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelResource.php#L104-L118 |
39,620 | cmsgears/module-core | common/models/base/ModelResource.php | ModelResource.findByParent | public static function findByParent( $parentId, $parentType, $config = [] ) {
return self::queryByParent( $parentId, $parentType, $config )->all();
} | php | public static function findByParent( $parentId, $parentType, $config = [] ) {
return self::queryByParent( $parentId, $parentType, $config )->all();
} | [
"public",
"static",
"function",
"findByParent",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"queryByParent",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"config",
")",
"... | Find and return models using given parent id and parent type.
@param string $parentId
@param string $parentType
@param array $config
@return \cmsgears\core\common\models\base\ActiveRecord[] | [
"Find",
"and",
"return",
"models",
"using",
"given",
"parent",
"id",
"and",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelResource.php#L130-L133 |
39,621 | cmsgears/module-core | common/models/base/ModelResource.php | ModelResource.findFirstByParent | public static function findFirstByParent( $parentId, $parentType, $config = [] ) {
return self::queryByParent( $parentId, $parentType, $config )->one();
} | php | public static function findFirstByParent( $parentId, $parentType, $config = [] ) {
return self::queryByParent( $parentId, $parentType, $config )->one();
} | [
"public",
"static",
"function",
"findFirstByParent",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"queryByParent",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"config",
")"... | Find and return first model using given parent id and parent type.
@param string $parentId
@param string $parentType
@param array $config
@return \cmsgears\core\common\models\base\ActiveRecord | [
"Find",
"and",
"return",
"first",
"model",
"using",
"given",
"parent",
"id",
"and",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelResource.php#L143-L146 |
39,622 | cmsgears/module-core | common/models/base/ModelResource.php | ModelResource.findByParentId | public static function findByParentId( $parentId, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'parentId=:pid AND siteId=:siteId', [ ':pid' => $parentId, ':siteId' => $siteId ] )->all();
}
else {
return static::find()->where( 'parentId=:pid', [ ':pid' => $parentId ] )->all();
}
} | php | public static function findByParentId( $parentId, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'parentId=:pid AND siteId=:siteId', [ ':pid' => $parentId, ':siteId' => $siteId ] )->all();
}
else {
return static::find()->where( 'parentId=:pid', [ ':pid' => $parentId ] )->all();
}
} | [
"public",
"static",
"function",
"findByParentId",
"(",
"$",
"parentId",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"'ignoreSite'",
"]",
":",
... | Find and return models using given parent id. It's useful in cases where only
single parent type is allowed.
@param string $parentId
@param array $config
@return \cmsgears\core\common\models\base\ActiveRecord[] | [
"Find",
"and",
"return",
"models",
"using",
"given",
"parent",
"id",
".",
"It",
"s",
"useful",
"in",
"cases",
"where",
"only",
"single",
"parent",
"type",
"is",
"allowed",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelResource.php#L156-L170 |
39,623 | cmsgears/module-core | common/models/base/ModelResource.php | ModelResource.findByParentType | public static function findByParentType( $parentType, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'parentType=:ptype AND siteId=:siteId', [ ':ptype' => $parentType, ':siteId' => $siteId ] )->all();
}
else {
return static::find()->where( 'parentType=:ptype', [ ':ptype' => $parentType ] )->all();
}
} | php | public static function findByParentType( $parentType, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'parentType=:ptype AND siteId=:siteId', [ ':ptype' => $parentType, ':siteId' => $siteId ] )->all();
}
else {
return static::find()->where( 'parentType=:ptype', [ ':ptype' => $parentType ] )->all();
}
} | [
"public",
"static",
"function",
"findByParentType",
"(",
"$",
"parentType",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"'ignoreSite'",
"]",
"... | Find and return models using given parent type.
@param string $parentType
@param array $config
@return \cmsgears\core\common\models\base\ActiveRecord[] | [
"Find",
"and",
"return",
"models",
"using",
"given",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ModelResource.php#L179-L193 |
39,624 | cmsgears/module-core | common/models/forms/Binder.php | Binder.mergeWithBinded | public function mergeWithBinded( $data, $csv = false ) {
$merge = [];
if( $csv && strlen( $merge ) > 1 ) {
$merge = preg_split( '/,/', $data );
}
$this->binded = ArrayHelper::merge( $this->binded, $merge );
} | php | public function mergeWithBinded( $data, $csv = false ) {
$merge = [];
if( $csv && strlen( $merge ) > 1 ) {
$merge = preg_split( '/,/', $data );
}
$this->binded = ArrayHelper::merge( $this->binded, $merge );
} | [
"public",
"function",
"mergeWithBinded",
"(",
"$",
"data",
",",
"$",
"csv",
"=",
"false",
")",
"{",
"$",
"merge",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"csv",
"&&",
"strlen",
"(",
"$",
"merge",
")",
">",
"1",
")",
"{",
"$",
"merge",
"=",
"preg_sp... | Merge the given data either in csv format or as array.
@param array|string $merge
@param boolean $csv | [
"Merge",
"the",
"given",
"data",
"either",
"in",
"csv",
"format",
"or",
"as",
"array",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Binder.php#L101-L111 |
39,625 | cmsgears/module-core | common/models/forms/Binder.php | Binder.getValueMap | public function getValueMap() {
$count = count( $this->binded );
$map = [];
for( $i = 0; $i < $count; $i++ ) {
$map[ $this->binded[ $i ] ] = $this->value[ $i ];
}
return $map;
} | php | public function getValueMap() {
$count = count( $this->binded );
$map = [];
for( $i = 0; $i < $count; $i++ ) {
$map[ $this->binded[ $i ] ] = $this->value[ $i ];
}
return $map;
} | [
"public",
"function",
"getValueMap",
"(",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"binded",
")",
";",
"$",
"map",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++... | Generate and return an array having id as key and value.
@return array | [
"Generate",
"and",
"return",
"an",
"array",
"having",
"id",
"as",
"key",
"and",
"value",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Binder.php#L118-L129 |
39,626 | cmsgears/module-core | common/models/forms/Binder.php | Binder.mergeMapWithBinded | public function mergeMapWithBinded( $map ) {
foreach( $map as $key => $value ) {
if( !in_array( $key, $this->binded ) ) {
$this->binded[] = $key;
$this->value[] = $value;
}
}
} | php | public function mergeMapWithBinded( $map ) {
foreach( $map as $key => $value ) {
if( !in_array( $key, $this->binded ) ) {
$this->binded[] = $key;
$this->value[] = $value;
}
}
} | [
"public",
"function",
"mergeMapWithBinded",
"(",
"$",
"map",
")",
"{",
"foreach",
"(",
"$",
"map",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"binded",
")",
")",
"{",
"$",
... | Analyze and merge the key and value from given map with the binder.
@param array $map | [
"Analyze",
"and",
"merge",
"the",
"key",
"and",
"value",
"from",
"given",
"map",
"with",
"the",
"binder",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/forms/Binder.php#L136-L146 |
39,627 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.setMimetype | public function setMimetype($type)
{
if ($type === null || $type === false) {
$this->mimetype = null;
return $this;
}
if (!is_string($type)) {
throw new InvalidArgumentException(
'Mimetype must be a string'
);
}
$this->mimetype = $type;
return $this;
} | php | public function setMimetype($type)
{
if ($type === null || $type === false) {
$this->mimetype = null;
return $this;
}
if (!is_string($type)) {
throw new InvalidArgumentException(
'Mimetype must be a string'
);
}
$this->mimetype = $type;
return $this;
} | [
"public",
"function",
"setMimetype",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"null",
"||",
"$",
"type",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"mimetype",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",... | Set the MIME type.
@param mixed $type The file MIME type.
@throws InvalidArgumentException If the MIME type argument is not a string.
@return FileProperty Chainable | [
"Set",
"the",
"MIME",
"type",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L216-L233 |
39,628 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.mimetype | public function mimetype()
{
if (!$this->mimetype) {
$val = $this->val();
if (!$val) {
return '';
}
$this->setMimetype($this->mimetypeFor(strval($val)));
}
return $this->mimetype;
} | php | public function mimetype()
{
if (!$this->mimetype) {
$val = $this->val();
if (!$val) {
return '';
}
$this->setMimetype($this->mimetypeFor(strval($val)));
}
return $this->mimetype;
} | [
"public",
"function",
"mimetype",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mimetype",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"val",
"(",
")",
";",
"if",
"(",
"!",
"$",
"val",
")",
"{",
"return",
"''",
";",
"}",
"$",
"this",
... | Retrieve the MIME type.
@return string | [
"Retrieve",
"the",
"MIME",
"type",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L240-L253 |
39,629 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.dataUpload | public function dataUpload($fileData)
{
$filename = null;
if (is_array($fileData)) {
// retrieve tmp file from temp dir
$tmpDir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$tmpFile = $tmpDir.$fileData['id'];
if (!file_exists($tmpFile)) {
throw new Exception(
'File does not exists.'
);
}
$fileContent = file_get_contents($tmpFile);
$filename = (!empty($fileData['name'])) ? $fileData['name'] : null;
// delete tmp file
unlink($tmpFile);
} else {
$fileContent = file_get_contents($fileData);
}
if ($fileContent === false) {
throw new Exception(
'File content could not be decoded.'
);
}
$info = new finfo(FILEINFO_MIME_TYPE);
$this->setMimetype($info->buffer($fileContent));
$this->setFilesize(strlen($fileContent));
if (!$this->validateAcceptedMimetypes() || !$this->validateMaxFilesize()) {
return '';
}
$target = $this->uploadTarget($filename);
$ret = file_put_contents($target, $fileContent);
if ($ret === false) {
return '';
} else {
$basePath = $this->basePath();
$target = str_replace($basePath, '', $target);
return $target;
}
} | php | public function dataUpload($fileData)
{
$filename = null;
if (is_array($fileData)) {
// retrieve tmp file from temp dir
$tmpDir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
$tmpFile = $tmpDir.$fileData['id'];
if (!file_exists($tmpFile)) {
throw new Exception(
'File does not exists.'
);
}
$fileContent = file_get_contents($tmpFile);
$filename = (!empty($fileData['name'])) ? $fileData['name'] : null;
// delete tmp file
unlink($tmpFile);
} else {
$fileContent = file_get_contents($fileData);
}
if ($fileContent === false) {
throw new Exception(
'File content could not be decoded.'
);
}
$info = new finfo(FILEINFO_MIME_TYPE);
$this->setMimetype($info->buffer($fileContent));
$this->setFilesize(strlen($fileContent));
if (!$this->validateAcceptedMimetypes() || !$this->validateMaxFilesize()) {
return '';
}
$target = $this->uploadTarget($filename);
$ret = file_put_contents($target, $fileContent);
if ($ret === false) {
return '';
} else {
$basePath = $this->basePath();
$target = str_replace($basePath, '', $target);
return $target;
}
} | [
"public",
"function",
"dataUpload",
"(",
"$",
"fileData",
")",
"{",
"$",
"filename",
"=",
"null",
";",
"if",
"(",
"is_array",
"(",
"$",
"fileData",
")",
")",
"{",
"// retrieve tmp file from temp dir",
"$",
"tmpDir",
"=",
"rtrim",
"(",
"sys_get_temp_dir",
"("... | Upload to filesystem, from data URI.
@param string $fileData The file data, raw.
@throws Exception If data content decoding fails.
@return string | [
"Upload",
"to",
"filesystem",
"from",
"data",
"URI",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L573-L618 |
39,630 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.renderFileRenamePattern | public function renderFileRenamePattern($from, $to, $args = null)
{
if (!is_string($from)) {
throw new InvalidArgumentException(sprintf(
'The target to rename must be a string, received %s',
(is_object($from) ? get_class($from) : gettype($from))
));
}
if (!is_string($to)) {
throw new InvalidArgumentException(sprintf(
'The rename pattern must be a string, received %s',
(is_object($to) ? get_class($to) : gettype($to))
));
}
$info = pathinfo($from);
$args = $this->renamePatternArgs($info, $args);
$to = strtr($to, $args);
if (strpos($to, '{{') !== false) {
preg_match_all('~\{\{\s*(.*?)\s*\}\}~i', $to, $matches);
throw new UnexpectedValueException(sprintf(
'The rename pattern failed. Leftover tokens found: %s',
implode(', ', $matches[1])
));
}
$to = str_replace($info['basename'], $to, $from);
return $to;
} | php | public function renderFileRenamePattern($from, $to, $args = null)
{
if (!is_string($from)) {
throw new InvalidArgumentException(sprintf(
'The target to rename must be a string, received %s',
(is_object($from) ? get_class($from) : gettype($from))
));
}
if (!is_string($to)) {
throw new InvalidArgumentException(sprintf(
'The rename pattern must be a string, received %s',
(is_object($to) ? get_class($to) : gettype($to))
));
}
$info = pathinfo($from);
$args = $this->renamePatternArgs($info, $args);
$to = strtr($to, $args);
if (strpos($to, '{{') !== false) {
preg_match_all('~\{\{\s*(.*?)\s*\}\}~i', $to, $matches);
throw new UnexpectedValueException(sprintf(
'The rename pattern failed. Leftover tokens found: %s',
implode(', ', $matches[1])
));
}
$to = str_replace($info['basename'], $to, $from);
return $to;
} | [
"public",
"function",
"renderFileRenamePattern",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"args",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"from",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"... | Render the given file to the given pattern.
This method does not rename the given path.
@uses strtr() To replace tokens in the form `{{foobar}}`.
@param string $from The string being rendered.
@param string $to The pattern replacing $from.
@param array|callable $args Extra rename tokens.
@throws InvalidArgumentException If the given arguments are invalid.
@throws UnexpectedValueException If the renaming failed.
@return string Returns the rendered target. | [
"Render",
"the",
"given",
"file",
"to",
"the",
"given",
"pattern",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L772-L804 |
39,631 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.generateFilename | public function generateFilename()
{
$filename = $this->label().' '.date('Y-m-d H-i-s');
$extension = $this->generateExtension();
if ($extension) {
return $filename.'.'.$extension;
} else {
return $filename;
}
} | php | public function generateFilename()
{
$filename = $this->label().' '.date('Y-m-d H-i-s');
$extension = $this->generateExtension();
if ($extension) {
return $filename.'.'.$extension;
} else {
return $filename;
}
} | [
"public",
"function",
"generateFilename",
"(",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"label",
"(",
")",
".",
"' '",
".",
"date",
"(",
"'Y-m-d H-i-s'",
")",
";",
"$",
"extension",
"=",
"$",
"this",
"->",
"generateExtension",
"(",
")",
";",
... | Generate a new filename from the property.
@return string | [
"Generate",
"a",
"new",
"filename",
"from",
"the",
"property",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L811-L821 |
39,632 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.parseIniSize | protected function parseIniSize($size)
{
if (is_numeric($size)) {
return $size;
}
if (!is_string($size)) {
throw new InvalidArgumentException(
'Size must be an integer (in bytes, e.g.: 1024) or a string (e.g.: 1M).'
);
}
$quant = 'bkmgtpezy';
$unit = preg_replace('/[^'.$quant.']/i', '', $size);
$size = preg_replace('/[^0-9\.]/', '', $size);
if ($unit) {
$size = ($size * pow(1024, stripos($quant, $unit[0])));
}
return round($size);
} | php | protected function parseIniSize($size)
{
if (is_numeric($size)) {
return $size;
}
if (!is_string($size)) {
throw new InvalidArgumentException(
'Size must be an integer (in bytes, e.g.: 1024) or a string (e.g.: 1M).'
);
}
$quant = 'bkmgtpezy';
$unit = preg_replace('/[^'.$quant.']/i', '', $size);
$size = preg_replace('/[^0-9\.]/', '', $size);
if ($unit) {
$size = ($size * pow(1024, stripos($quant, $unit[0])));
}
return round($size);
} | [
"protected",
"function",
"parseIniSize",
"(",
"$",
"size",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"size",
")",
")",
"{",
"return",
"$",
"size",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"size",
")",
")",
"{",
"throw",
"new",
"InvalidAr... | Converts a php.ini notation for size to an integer.
@param mixed $size A php.ini notation for size.
@throws InvalidArgumentException If the given parameter is invalid.
@return integer Returns the size in bytes. | [
"Converts",
"a",
"php",
".",
"ini",
"notation",
"for",
"size",
"to",
"an",
"integer",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L928-L949 |
39,633 | locomotivemtl/charcoal-property | src/Charcoal/Property/FileProperty.php | FileProperty.renamePatternArgs | private function renamePatternArgs($path, $args = null)
{
if (!is_string($path) && !is_array($path)) {
throw new InvalidArgumentException(sprintf(
'The target must be a string or an array from [pathfino()], received %s',
(is_object($path) ? get_class($path) : gettype($path))
));
}
if (is_string($path)) {
$info = pathinfo($path);
} else {
$info = $path;
}
if (!isset($info['basename']) || $info['basename'] === '') {
throw new UnexpectedValueException(
'The basename is missing from the target'
);
}
if (!isset($info['filename']) || $info['filename'] === '') {
throw new UnexpectedValueException(
'The filename is missing from the target'
);
}
$defaults = [
'{{property}}' => $this->ident(),
'{{label}}' => $this->label(),
'{{extension}}' => $info['extension'],
'{{basename}}' => $info['basename'],
'{{filename}}' => $info['filename']
];
if ($args === null) {
$args = $defaults;
} else {
if (is_callable($args)) {
/**
* Rename Arguments Callback Routine
*
* @param array $info Information about the file path from {@see pathinfo()}.
* @param PropertyInterface $prop The related image property.
* @return array
*/
$args = $args($info, $this);
}
if (is_array($args)) {
$args = array_replace($defaults, $args);
} else {
throw new InvalidArgumentException(sprintf(
'Arguments must be an array or a callable that returns an array, received %s',
(is_object($args) ? get_class($args) : gettype($args))
));
}
}
return $args;
} | php | private function renamePatternArgs($path, $args = null)
{
if (!is_string($path) && !is_array($path)) {
throw new InvalidArgumentException(sprintf(
'The target must be a string or an array from [pathfino()], received %s',
(is_object($path) ? get_class($path) : gettype($path))
));
}
if (is_string($path)) {
$info = pathinfo($path);
} else {
$info = $path;
}
if (!isset($info['basename']) || $info['basename'] === '') {
throw new UnexpectedValueException(
'The basename is missing from the target'
);
}
if (!isset($info['filename']) || $info['filename'] === '') {
throw new UnexpectedValueException(
'The filename is missing from the target'
);
}
$defaults = [
'{{property}}' => $this->ident(),
'{{label}}' => $this->label(),
'{{extension}}' => $info['extension'],
'{{basename}}' => $info['basename'],
'{{filename}}' => $info['filename']
];
if ($args === null) {
$args = $defaults;
} else {
if (is_callable($args)) {
/**
* Rename Arguments Callback Routine
*
* @param array $info Information about the file path from {@see pathinfo()}.
* @param PropertyInterface $prop The related image property.
* @return array
*/
$args = $args($info, $this);
}
if (is_array($args)) {
$args = array_replace($defaults, $args);
} else {
throw new InvalidArgumentException(sprintf(
'Arguments must be an array or a callable that returns an array, received %s',
(is_object($args) ? get_class($args) : gettype($args))
));
}
}
return $args;
} | [
"private",
"function",
"renamePatternArgs",
"(",
"$",
"path",
",",
"$",
"args",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
"&&",
"!",
"is_array",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException... | Retrieve the rename pattern tokens for the given file.
@param string|array $path The string to be parsed or an associative array of information about the file.
@param array|callable $args Extra rename tokens.
@throws InvalidArgumentException If the given arguments are invalid.
@throws UnexpectedValueException If the given path is invalid.
@return string Returns the rendered target. | [
"Retrieve",
"the",
"rename",
"pattern",
"tokens",
"for",
"the",
"given",
"file",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/FileProperty.php#L992-L1052 |
39,634 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.build | public function build($cacheDriver, $poolOptions = null)
{
if (!($cacheDriver instanceof DriverInterface)) {
$cacheDriver = $this->resolveDriver($cacheDriver);
}
$poolOptions = $this->parsePoolOptions($poolOptions);
$poolInstance = new $poolOptions['pool_class']($cacheDriver);
$this->applyPoolOptions($poolInstance, $poolOptions);
return $poolInstance;
} | php | public function build($cacheDriver, $poolOptions = null)
{
if (!($cacheDriver instanceof DriverInterface)) {
$cacheDriver = $this->resolveDriver($cacheDriver);
}
$poolOptions = $this->parsePoolOptions($poolOptions);
$poolInstance = new $poolOptions['pool_class']($cacheDriver);
$this->applyPoolOptions($poolInstance, $poolOptions);
return $poolInstance;
} | [
"public",
"function",
"build",
"(",
"$",
"cacheDriver",
",",
"$",
"poolOptions",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"cacheDriver",
"instanceof",
"DriverInterface",
")",
")",
"{",
"$",
"cacheDriver",
"=",
"$",
"this",
"->",
"resolveDriver",
... | Create a new cache pool.
@param mixed $cacheDriver The name of a registered cache driver,
the class name or instance of a {@see DriverInterface cache driver}.
An array may be used to designate fallback drivers.
@param mixed $poolOptions Optional settings for the new pool.
If a string is specified, it is used as the namespace for the new pool.
If an array is specified, it is assumed to be associative and is merged with the default settings.
Otherwise, the default settings are used.
@return PoolInterface | [
"Create",
"a",
"new",
"cache",
"pool",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L109-L121 |
39,635 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.parsePoolOptions | private function parsePoolOptions($options)
{
$defaults = [
'pool_class' => $this->poolClass,
'item_class' => $this->itemClass,
'namespace' => $this->namespace,
'logger' => $this->logger,
];
if ($options === null) {
return $defaults;
}
if (is_string($options)) {
$options = [
'namespace' => $options
];
}
if (!is_array($options)) {
return $defaults;
}
return array_replace($defaults, $options);
} | php | private function parsePoolOptions($options)
{
$defaults = [
'pool_class' => $this->poolClass,
'item_class' => $this->itemClass,
'namespace' => $this->namespace,
'logger' => $this->logger,
];
if ($options === null) {
return $defaults;
}
if (is_string($options)) {
$options = [
'namespace' => $options
];
}
if (!is_array($options)) {
return $defaults;
}
return array_replace($defaults, $options);
} | [
"private",
"function",
"parsePoolOptions",
"(",
"$",
"options",
")",
"{",
"$",
"defaults",
"=",
"[",
"'pool_class'",
"=>",
"$",
"this",
"->",
"poolClass",
",",
"'item_class'",
"=>",
"$",
"this",
"->",
"itemClass",
",",
"'namespace'",
"=>",
"$",
"this",
"->... | Prepare any pool options for the new pool object.
@param mixed $options Settings for the new pool.
@return array | [
"Prepare",
"any",
"pool",
"options",
"for",
"the",
"new",
"pool",
"object",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L129-L153 |
39,636 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.applyPoolOptions | private function applyPoolOptions(PoolInterface $pool, array $options)
{
if (isset($options['logger'])) {
$pool->setLogger($options['logger']);
}
if (isset($options['item_class'])) {
$pool->setItemClass($options['item_class']);
}
if (isset($options['namespace'])) {
$pool->setNamespace($options['namespace']);
}
} | php | private function applyPoolOptions(PoolInterface $pool, array $options)
{
if (isset($options['logger'])) {
$pool->setLogger($options['logger']);
}
if (isset($options['item_class'])) {
$pool->setItemClass($options['item_class']);
}
if (isset($options['namespace'])) {
$pool->setNamespace($options['namespace']);
}
} | [
"private",
"function",
"applyPoolOptions",
"(",
"PoolInterface",
"$",
"pool",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'logger'",
"]",
")",
")",
"{",
"$",
"pool",
"->",
"setLogger",
"(",
"$",
"options",
"["... | Apply any pool options on the new pool object.
@param PoolInterface $pool The new pool.
@param array $options Settings for the new pool.
@return void | [
"Apply",
"any",
"pool",
"options",
"on",
"the",
"new",
"pool",
"object",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L162-L175 |
39,637 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.resolveDriver | private function resolveDriver($driver)
{
if ($this->isIterable($driver)) {
foreach ($driver as $drv) {
try {
return $this->resolveOneDriver($drv);
} catch (InvalidArgumentException $e) {
continue;
}
}
throw new InvalidArgumentException(
'Drivers cannot be resolved'
);
}
return $this->resolveOneDriver($driver);
} | php | private function resolveDriver($driver)
{
if ($this->isIterable($driver)) {
foreach ($driver as $drv) {
try {
return $this->resolveOneDriver($drv);
} catch (InvalidArgumentException $e) {
continue;
}
}
throw new InvalidArgumentException(
'Drivers cannot be resolved'
);
}
return $this->resolveOneDriver($driver);
} | [
"private",
"function",
"resolveDriver",
"(",
"$",
"driver",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isIterable",
"(",
"$",
"driver",
")",
")",
"{",
"foreach",
"(",
"$",
"driver",
"as",
"$",
"drv",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",... | Resolve one or many cache drivers, if available.
@param mixed $driver The name of a registered cache driver,
the class name or instance of a {@see DriverInterface cache driver}.
An array may be used to designate fallback drivers.
@throws InvalidArgumentException When an array of drivers cannot be resolved.
@return DriverInterface | [
"Resolve",
"one",
"or",
"many",
"cache",
"drivers",
"if",
"available",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L186-L203 |
39,638 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.resolveOneDriver | private function resolveOneDriver($driver)
{
if (empty($driver)) {
throw new InvalidArgumentException(
'Driver is empty'
);
}
if (is_object($driver)) {
if ($driver instanceof DriverInterface) {
return $driver;
} else {
throw new InvalidArgumentException(sprintf(
'Driver class %s must implement %s',
get_class($driver),
DriverInterface::class
));
}
}
$name = $driver;
if (isset($this->drivers[$name])) {
$driver = $this->drivers[$name];
if (empty($driver)) {
throw new InvalidArgumentException(
sprintf('Driver "%s" does not exist', $name)
);
}
if (is_object($driver)) {
if ($driver instanceof DriverInterface) {
return $driver;
} else {
throw new InvalidArgumentException(sprintf(
'Driver "%s": Class %s must implement %s',
$name,
get_class($driver),
DriverInterface::class
));
}
}
}
if (is_a($driver, DriverInterface::class, true)) {
return new $driver();
}
throw new InvalidArgumentException(
sprintf('Driver "%s" cannot be resolved', $name)
);
} | php | private function resolveOneDriver($driver)
{
if (empty($driver)) {
throw new InvalidArgumentException(
'Driver is empty'
);
}
if (is_object($driver)) {
if ($driver instanceof DriverInterface) {
return $driver;
} else {
throw new InvalidArgumentException(sprintf(
'Driver class %s must implement %s',
get_class($driver),
DriverInterface::class
));
}
}
$name = $driver;
if (isset($this->drivers[$name])) {
$driver = $this->drivers[$name];
if (empty($driver)) {
throw new InvalidArgumentException(
sprintf('Driver "%s" does not exist', $name)
);
}
if (is_object($driver)) {
if ($driver instanceof DriverInterface) {
return $driver;
} else {
throw new InvalidArgumentException(sprintf(
'Driver "%s": Class %s must implement %s',
$name,
get_class($driver),
DriverInterface::class
));
}
}
}
if (is_a($driver, DriverInterface::class, true)) {
return new $driver();
}
throw new InvalidArgumentException(
sprintf('Driver "%s" cannot be resolved', $name)
);
} | [
"private",
"function",
"resolveOneDriver",
"(",
"$",
"driver",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"driver",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Driver is empty'",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"driver",... | Resolve the given cache driver, if available.
@param mixed $driver The name of a registered cache driver,
the class name or instance of a {@see DriverInterface cache driver}.
@throws InvalidArgumentException When passed an invalid or nonexistant driver name, class name, or object.
@return DriverInterface | [
"Resolve",
"the",
"given",
"cache",
"driver",
"if",
"available",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L213-L264 |
39,639 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.setLogger | private function setLogger($logger)
{
$psr = 'Psr\\Log\\LoggerInterface';
if (!is_a($logger, $psr)) {
throw new InvalidArgumentException(
sprintf('Expected an instance of %s', $psr)
);
}
$this->logger = $logger;
} | php | private function setLogger($logger)
{
$psr = 'Psr\\Log\\LoggerInterface';
if (!is_a($logger, $psr)) {
throw new InvalidArgumentException(
sprintf('Expected an instance of %s', $psr)
);
}
$this->logger = $logger;
} | [
"private",
"function",
"setLogger",
"(",
"$",
"logger",
")",
"{",
"$",
"psr",
"=",
"'Psr\\\\Log\\\\LoggerInterface'",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"logger",
",",
"$",
"psr",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf... | Sets the specific PSR logging client to enable the tracking of errors.
@param \Psr\Log\LoggerInterface $logger A PSR-3 logger.
@throws InvalidArgumentException If the logger is invalid PSR-3 client.
@return void | [
"Sets",
"the",
"specific",
"PSR",
"logging",
"client",
"to",
"enable",
"the",
"tracking",
"of",
"errors",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L291-L301 |
39,640 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.setPoolClass | private function setPoolClass($class)
{
if (!class_exists($class)) {
throw new InvalidArgumentException(
sprintf('Pool class %s does not exist', $class)
);
}
$interfaces = class_implements($class, true);
if (!in_array(PoolInterface::class, $interfaces)) {
throw new InvalidArgumentException(sprintf(
'Pool class %s must inherit from %s',
$class,
PoolInterface::class
));
}
$this->poolClass = $class;
} | php | private function setPoolClass($class)
{
if (!class_exists($class)) {
throw new InvalidArgumentException(
sprintf('Pool class %s does not exist', $class)
);
}
$interfaces = class_implements($class, true);
if (!in_array(PoolInterface::class, $interfaces)) {
throw new InvalidArgumentException(sprintf(
'Pool class %s must inherit from %s',
$class,
PoolInterface::class
));
}
$this->poolClass = $class;
} | [
"private",
"function",
"setPoolClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Pool class %s does not exist'",
",",
"$",
"class",
")",
"... | Sets the specific Pool class generated by the cache builder.
Using this function developers can have the builder generate custom Pool objects.
@param string $class The pool class name.
@throws InvalidArgumentException When passed an invalid or nonexistant class.
@return void | [
"Sets",
"the",
"specific",
"Pool",
"class",
"generated",
"by",
"the",
"cache",
"builder",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L332-L351 |
39,641 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/CacheBuilder.php | CacheBuilder.setItemClass | private function setItemClass($class)
{
if (!class_exists($class)) {
throw new InvalidArgumentException(
sprintf('Item class %s does not exist', $class)
);
}
$interfaces = class_implements($class, true);
if (!in_array(ItemInterface::class, $interfaces)) {
throw new InvalidArgumentException(sprintf(
'Item class %s must inherit from %s',
$class,
ItemInterface::class
));
}
$this->itemClass = $class;
} | php | private function setItemClass($class)
{
if (!class_exists($class)) {
throw new InvalidArgumentException(
sprintf('Item class %s does not exist', $class)
);
}
$interfaces = class_implements($class, true);
if (!in_array(ItemInterface::class, $interfaces)) {
throw new InvalidArgumentException(sprintf(
'Item class %s must inherit from %s',
$class,
ItemInterface::class
));
}
$this->itemClass = $class;
} | [
"private",
"function",
"setItemClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Item class %s does not exist'",
",",
"$",
"class",
")",
"... | Changes the specific Item class generated by the Pool objects.
Using this function developers can have the pool class generate custom Item objects.
@param string $class The item class name.
@throws InvalidArgumentException When passed an invalid or nonexistant class.
@return void | [
"Changes",
"the",
"specific",
"Item",
"class",
"generated",
"by",
"the",
"Pool",
"objects",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/CacheBuilder.php#L362-L381 |
39,642 | locomotivemtl/charcoal-property | src/Charcoal/Property/ObjectProperty.php | ObjectProperty.objType | public function objType()
{
if ($this->objType === null) {
throw new RuntimeException(sprintf(
'Missing object type ("obj_type"). Invalid property "%s".',
$this->ident()
));
}
return $this->objType;
} | php | public function objType()
{
if ($this->objType === null) {
throw new RuntimeException(sprintf(
'Missing object type ("obj_type"). Invalid property "%s".',
$this->ident()
));
}
return $this->objType;
} | [
"public",
"function",
"objType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"objType",
"===",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Missing object type (\"obj_type\"). Invalid property \"%s\".'",
",",
"$",
"this",
"->",
"... | Retrieve the object type to build the choices from.
@throws RuntimeException If the object type was not previously set.
@return string | [
"Retrieve",
"the",
"object",
"type",
"to",
"build",
"the",
"choices",
"from",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ObjectProperty.php#L152-L162 |
39,643 | locomotivemtl/charcoal-property | src/Charcoal/Property/ObjectProperty.php | ObjectProperty.parseChoices | protected function parseChoices($objs)
{
if (!is_array($objs) && !$objs instanceof Traversable) {
throw new InvalidArgumentException('Must be iterable');
}
$parsed = [];
foreach ($objs as $choice) {
$choice = $this->parseChoice($choice);
if ($choice !== null) {
$choiceIdent = $choice['value'];
$parsed[$choiceIdent] = $choice;
}
}
return $parsed;
} | php | protected function parseChoices($objs)
{
if (!is_array($objs) && !$objs instanceof Traversable) {
throw new InvalidArgumentException('Must be iterable');
}
$parsed = [];
foreach ($objs as $choice) {
$choice = $this->parseChoice($choice);
if ($choice !== null) {
$choiceIdent = $choice['value'];
$parsed[$choiceIdent] = $choice;
}
}
return $parsed;
} | [
"protected",
"function",
"parseChoices",
"(",
"$",
"objs",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"objs",
")",
"&&",
"!",
"$",
"objs",
"instanceof",
"Traversable",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Must be iterable'",
")",... | Parse the given objects into choice structures.
@param ModelInterface[]|Traversable $objs One or more objects to format.
@throws InvalidArgumentException If the collection of objects is not iterable.
@return array Returns a collection of choice structures. | [
"Parse",
"the",
"given",
"objects",
"into",
"choice",
"structures",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ObjectProperty.php#L656-L672 |
39,644 | locomotivemtl/charcoal-property | src/Charcoal/Property/ObjectProperty.php | ObjectProperty.collectionModelLoader | protected function collectionModelLoader()
{
$loader = $this->collectionLoader();
if (!$loader->hasModel()) {
$loader->setModel($this->proto());
$pagination = $this->pagination();
if (!empty($pagination)) {
$loader->setPagination($pagination);
}
$orders = $this->orders();
if (!empty($orders)) {
$loader->setOrders($orders);
}
$filters = $this->filters();
if (!empty($filters)) {
$loader->setFilters($filters);
}
}
return $loader;
} | php | protected function collectionModelLoader()
{
$loader = $this->collectionLoader();
if (!$loader->hasModel()) {
$loader->setModel($this->proto());
$pagination = $this->pagination();
if (!empty($pagination)) {
$loader->setPagination($pagination);
}
$orders = $this->orders();
if (!empty($orders)) {
$loader->setOrders($orders);
}
$filters = $this->filters();
if (!empty($filters)) {
$loader->setFilters($filters);
}
}
return $loader;
} | [
"protected",
"function",
"collectionModelLoader",
"(",
")",
"{",
"$",
"loader",
"=",
"$",
"this",
"->",
"collectionLoader",
"(",
")",
";",
"if",
"(",
"!",
"$",
"loader",
"->",
"hasModel",
"(",
")",
")",
"{",
"$",
"loader",
"->",
"setModel",
"(",
"$",
... | Retrieve the prepared model collection loader.
@return CollectionLoader | [
"Retrieve",
"the",
"prepared",
"model",
"collection",
"loader",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ObjectProperty.php#L721-L745 |
39,645 | locomotivemtl/charcoal-property | src/Charcoal/Property/ObjectProperty.php | ObjectProperty.loadObject | protected function loadObject($objId)
{
if ($objId instanceof ModelInterface) {
return $objId;
}
$obj = $this->modelLoader()->load($objId);
if (!$obj->id()) {
return null;
} else {
return $obj;
}
} | php | protected function loadObject($objId)
{
if ($objId instanceof ModelInterface) {
return $objId;
}
$obj = $this->modelLoader()->load($objId);
if (!$obj->id()) {
return null;
} else {
return $obj;
}
} | [
"protected",
"function",
"loadObject",
"(",
"$",
"objId",
")",
"{",
"if",
"(",
"$",
"objId",
"instanceof",
"ModelInterface",
")",
"{",
"return",
"$",
"objId",
";",
"}",
"$",
"obj",
"=",
"$",
"this",
"->",
"modelLoader",
"(",
")",
"->",
"load",
"(",
"... | Retrieve an object by its ID.
Loads the object from the cache store or from the storage source.
@param mixed $objId Object id.
@return ModelInterface | [
"Retrieve",
"an",
"object",
"by",
"its",
"ID",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ObjectProperty.php#L808-L820 |
39,646 | locomotivemtl/charcoal-property | src/Charcoal/Property/ObjectProperty.php | ObjectProperty.modelLoader | protected function modelLoader($objType = null)
{
if ($objType === null) {
$objType = $this->objType();
} elseif (!is_string($objType)) {
throw new InvalidArgumentException(
'Object type must be a string.'
);
}
if (isset(self::$modelLoaders[$objType])) {
return self::$modelLoaders[$objType];
}
self::$modelLoaders[$objType] = new ModelLoader([
'logger' => $this->logger,
'obj_type' => $objType,
'factory' => $this->modelFactory(),
'cache' => $this->cachePool()
]);
return self::$modelLoaders[$objType];
} | php | protected function modelLoader($objType = null)
{
if ($objType === null) {
$objType = $this->objType();
} elseif (!is_string($objType)) {
throw new InvalidArgumentException(
'Object type must be a string.'
);
}
if (isset(self::$modelLoaders[$objType])) {
return self::$modelLoaders[$objType];
}
self::$modelLoaders[$objType] = new ModelLoader([
'logger' => $this->logger,
'obj_type' => $objType,
'factory' => $this->modelFactory(),
'cache' => $this->cachePool()
]);
return self::$modelLoaders[$objType];
} | [
"protected",
"function",
"modelLoader",
"(",
"$",
"objType",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"objType",
"===",
"null",
")",
"{",
"$",
"objType",
"=",
"$",
"this",
"->",
"objType",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$"... | Retrieve the model loader.
@param string $objType The object type.
@throws InvalidArgumentException If the object type is invalid.
@return ModelLoader | [
"Retrieve",
"the",
"model",
"loader",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ObjectProperty.php#L829-L851 |
39,647 | cmsgears/module-core | common/models/traits/base/SlugTypeTrait.php | SlugTypeTrait.queryBySlug | public static function queryBySlug( $slug, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'slug=:slug AND siteId=:siteId', [ ':slug' => $slug, ':siteId' => $siteId ] );
}
else {
return static::find()->where( 'slug=:slug', [ ':slug' => $slug ] );
}
} | php | public static function queryBySlug( $slug, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'slug=:slug AND siteId=:siteId', [ ':slug' => $slug, ':siteId' => $siteId ] );
}
else {
return static::find()->where( 'slug=:slug', [ ':slug' => $slug ] );
}
} | [
"public",
"static",
"function",
"queryBySlug",
"(",
"$",
"slug",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"'ignoreSite'",
"]",
":",
"fals... | Return query to find the models by given slug.
@param string $slug
@param array $config
@return \yii\db\ActiveQuery to query by slug. | [
"Return",
"query",
"to",
"find",
"the",
"models",
"by",
"given",
"slug",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/SlugTypeTrait.php#L67-L81 |
39,648 | cmsgears/module-core | common/models/traits/base/SlugTypeTrait.php | SlugTypeTrait.isExistBySlugType | public static function isExistBySlugType( $slug, $type, $config = [] ) {
$model = static::findBySlugType( $slug, $type, $config );
return isset( $model );
} | php | public static function isExistBySlugType( $slug, $type, $config = [] ) {
$model = static::findBySlugType( $slug, $type, $config );
return isset( $model );
} | [
"public",
"static",
"function",
"isExistBySlugType",
"(",
"$",
"slug",
",",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"model",
"=",
"static",
"::",
"findBySlugType",
"(",
"$",
"slug",
",",
"$",
"type",
",",
"$",
"config",
")",
... | check whether model exist for given slug and type.
@param string $slug
@param string $type
@param array $config
@return boolean | [
"check",
"whether",
"model",
"exist",
"for",
"given",
"slug",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/SlugTypeTrait.php#L154-L159 |
39,649 | Innmind/CLI | src/Command/Pattern.php | Pattern.clean | public function clean(StreamInterface $arguments): StreamInterface
{
return $this->inputs->reduce(
$arguments,
static function(StreamInterface $arguments, Option $option): StreamInterface {
return $option->clean($arguments);
}
);
} | php | public function clean(StreamInterface $arguments): StreamInterface
{
return $this->inputs->reduce(
$arguments,
static function(StreamInterface $arguments, Option $option): StreamInterface {
return $option->clean($arguments);
}
);
} | [
"public",
"function",
"clean",
"(",
"StreamInterface",
"$",
"arguments",
")",
":",
"StreamInterface",
"{",
"return",
"$",
"this",
"->",
"inputs",
"->",
"reduce",
"(",
"$",
"arguments",
",",
"static",
"function",
"(",
"StreamInterface",
"$",
"arguments",
",",
... | Remove all options from the list of arguments so the arguments can be
correctly extracted
@param StreamInterface<string> $arguments
@return StreamInterface<string> | [
"Remove",
"all",
"options",
"from",
"the",
"list",
"of",
"arguments",
"so",
"the",
"arguments",
"can",
"be",
"correctly",
"extracted"
] | c15d13aa5155fef7eed24016a33b5862dae65bdd | https://github.com/Innmind/CLI/blob/c15d13aa5155fef7eed24016a33b5862dae65bdd/src/Command/Pattern.php#L123-L131 |
39,650 | ethical-jobs/ethical-jobs-foundation-php | src/Utils/RequestUtil.php | RequestUtil.getSelectFields | public static function getSelectFields()
{
if ($select = request()->input('fields')) {
$httpRequestSelectFields = explode(',', $select);
if (strpos($select, '*') !== false) {
$httpRequestSelectFields = ['*'];
}
}
return $httpRequestSelectFields ?? [];
} | php | public static function getSelectFields()
{
if ($select = request()->input('fields')) {
$httpRequestSelectFields = explode(',', $select);
if (strpos($select, '*') !== false) {
$httpRequestSelectFields = ['*'];
}
}
return $httpRequestSelectFields ?? [];
} | [
"public",
"static",
"function",
"getSelectFields",
"(",
")",
"{",
"if",
"(",
"$",
"select",
"=",
"request",
"(",
")",
"->",
"input",
"(",
"'fields'",
")",
")",
"{",
"$",
"httpRequestSelectFields",
"=",
"explode",
"(",
"','",
",",
"$",
"select",
")",
";... | Parses request select fields into an array
@return array | [
"Parses",
"request",
"select",
"fields",
"into",
"an",
"array"
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Utils/RequestUtil.php#L18-L29 |
39,651 | cmsgears/module-core | common/actions/meta/Delete.php | Delete.run | public function run( $cid ) {
$parent = $this->model;
if( isset( $parent ) ) {
$meta = $this->metaService->getById( $cid );
$belongsTo = $meta->hasAttribute( 'modelId' ) ? $meta->belongsTo( $parent ) : $meta->belongsTo( $parent, $this->modelService->getParentType() );
if( isset( $meta ) && $belongsTo ) {
$this->metaService->delete( $meta );
$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => $meta->value ];
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | php | public function run( $cid ) {
$parent = $this->model;
if( isset( $parent ) ) {
$meta = $this->metaService->getById( $cid );
$belongsTo = $meta->hasAttribute( 'modelId' ) ? $meta->belongsTo( $parent ) : $meta->belongsTo( $parent, $this->modelService->getParentType() );
if( isset( $meta ) && $belongsTo ) {
$this->metaService->delete( $meta );
$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => $meta->value ];
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | [
"public",
"function",
"run",
"(",
"$",
"cid",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"isset",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"metaService",
"->",
"getById",
"(",
"$",
"... | Delete meta for given meta id, parent slug and parent type. | [
"Delete",
"meta",
"for",
"given",
"meta",
"id",
"parent",
"slug",
"and",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/actions/meta/Delete.php#L75-L97 |
39,652 | mcaskill/charcoal-support | src/Property/ParsableValueTrait.php | ParsableValueTrait.parseAsMultiple | protected function parseAsMultiple($value, $separator = ',')
{
if (is_array($value) || $value instanceof Traversable) {
$parsed = [];
foreach ($value as $val) {
if (empty($val) && !is_numeric($val)) {
continue;
}
$parsed[] = $val;
}
return $parsed;
}
if ($separator instanceof PropertyInterface) {
$separator = $separator->multipleSeparator();
}
if (is_object($value) && method_exists($value, '__toString')) {
$value = strval($value);
}
if (empty($value) && !is_numeric($value)) {
return [];
}
/**
* This property is marked as "multiple".
* Manually handling the resolution to array
* until the property itself manages this.
*/
if (is_string($value)) {
return explode($separator, $value);
}
/**
* If the parameter isn't an array yet,
* means we might be dealing with an integer,
* an empty string, or an object.
*/
if (!is_array($value)) {
return (array)$value;
}
return $value;
} | php | protected function parseAsMultiple($value, $separator = ',')
{
if (is_array($value) || $value instanceof Traversable) {
$parsed = [];
foreach ($value as $val) {
if (empty($val) && !is_numeric($val)) {
continue;
}
$parsed[] = $val;
}
return $parsed;
}
if ($separator instanceof PropertyInterface) {
$separator = $separator->multipleSeparator();
}
if (is_object($value) && method_exists($value, '__toString')) {
$value = strval($value);
}
if (empty($value) && !is_numeric($value)) {
return [];
}
/**
* This property is marked as "multiple".
* Manually handling the resolution to array
* until the property itself manages this.
*/
if (is_string($value)) {
return explode($separator, $value);
}
/**
* If the parameter isn't an array yet,
* means we might be dealing with an integer,
* an empty string, or an object.
*/
if (!is_array($value)) {
return (array)$value;
}
return $value;
} | [
"protected",
"function",
"parseAsMultiple",
"(",
"$",
"value",
",",
"$",
"separator",
"=",
"','",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"$",
"value",
"instanceof",
"Traversable",
")",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"... | Parse the property value as a "multiple" value type.
@param mixed $value The value being converted to an array.
@param string|PropertyInterface $separator The boundary string.
@return array | [
"Parse",
"the",
"property",
"value",
"as",
"a",
"multiple",
"value",
"type",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Property/ParsableValueTrait.php#L36-L82 |
39,653 | mcaskill/charcoal-support | src/Property/ParsableValueTrait.php | ParsableValueTrait.parseAsJson | protected function parseAsJson($value)
{
if (is_string($value)) {
$value = json_decode($value, true);
$error = json_last_error();
if ($error !== JSON_ERROR_NONE) {
switch ($error) {
case JSON_ERROR_DEPTH:
$message = 'Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$message = 'Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
$message = 'Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$message = 'Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
$message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
$message = 'Unknown error';
break;
}
throw new InvalidArgumentException(sprintf(
'Value "%s" could not be parsed as JSON: "%s"',
is_object($value) ? get_class($value) : gettype($value),
$message
));
}
}
return $value;
} | php | protected function parseAsJson($value)
{
if (is_string($value)) {
$value = json_decode($value, true);
$error = json_last_error();
if ($error !== JSON_ERROR_NONE) {
switch ($error) {
case JSON_ERROR_DEPTH:
$message = 'Maximum stack depth exceeded';
break;
case JSON_ERROR_STATE_MISMATCH:
$message = 'Underflow or the modes mismatch';
break;
case JSON_ERROR_CTRL_CHAR:
$message = 'Unexpected control character found';
break;
case JSON_ERROR_SYNTAX:
$message = 'Syntax error, malformed JSON';
break;
case JSON_ERROR_UTF8:
$message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
break;
default:
$message = 'Unknown error';
break;
}
throw new InvalidArgumentException(sprintf(
'Value "%s" could not be parsed as JSON: "%s"',
is_object($value) ? get_class($value) : gettype($value),
$message
));
}
}
return $value;
} | [
"protected",
"function",
"parseAsJson",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"json_decode",
"(",
"$",
"value",
",",
"true",
")",
";",
"$",
"error",
"=",
"json_last_error",
"(",
")",... | Parse the property value as a JSON object.
@param mixed $value The JSONable value.
@throws InvalidArgumentException If the value is invalid.
@return array | [
"Parse",
"the",
"property",
"value",
"as",
"a",
"JSON",
"object",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Property/ParsableValueTrait.php#L91-L127 |
39,654 | mcaskill/charcoal-support | src/Property/ParsableValueTrait.php | ParsableValueTrait.parseAsTranslatable | protected function parseAsTranslatable($value)
{
trigger_error('parseAsTranslatable() is deprecated. Use Translator::translation() instead.', E_USER_DEPRECATED);
$value = $this->translator()->translation($value);
return $value === null ? '' : $value;
} | php | protected function parseAsTranslatable($value)
{
trigger_error('parseAsTranslatable() is deprecated. Use Translator::translation() instead.', E_USER_DEPRECATED);
$value = $this->translator()->translation($value);
return $value === null ? '' : $value;
} | [
"protected",
"function",
"parseAsTranslatable",
"(",
"$",
"value",
")",
"{",
"trigger_error",
"(",
"'parseAsTranslatable() is deprecated. Use Translator::translation() instead.'",
",",
"E_USER_DEPRECATED",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"translator",
"(",... | Parse the property value as a "L10N" value type.
@deprecated In favor of 'locomotivemtl/charcoal-translator'
@param mixed $value The value being localized.
@return Translation|string|null | [
"Parse",
"the",
"property",
"value",
"as",
"a",
"L10N",
"value",
"type",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Property/ParsableValueTrait.php#L169-L176 |
39,655 | mcaskill/charcoal-support | src/Property/ParsableValueTrait.php | ParsableValueTrait.parseAsTranslatableFallback | protected function parseAsTranslatableFallback($value, array $parameters = [])
{
$fallback = $this->translator()->translate($value, $parameters);
if (empty($fallback) && !is_numeric($fallback) && (is_array($value) || ($value instanceof ArrayAccess))) {
foreach ($this->translator()->getFallbackLocales() as $lang) {
$trans = $value[$lang];
if (!empty($trans) || is_numeric($trans)) {
$fallback = strtr($trans, $parameters);
break;
}
}
}
return $fallback;
} | php | protected function parseAsTranslatableFallback($value, array $parameters = [])
{
$fallback = $this->translator()->translate($value, $parameters);
if (empty($fallback) && !is_numeric($fallback) && (is_array($value) || ($value instanceof ArrayAccess))) {
foreach ($this->translator()->getFallbackLocales() as $lang) {
$trans = $value[$lang];
if (!empty($trans) || is_numeric($trans)) {
$fallback = strtr($trans, $parameters);
break;
}
}
}
return $fallback;
} | [
"protected",
"function",
"parseAsTranslatableFallback",
"(",
"$",
"value",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"fallback",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"translate",
"(",
"$",
"value",
",",
"$",
"paramet... | Retrieve a fallback value from a translatable value.
Note: Fallbacks are determined in your application settings, "locales.fallback_languages".
@param mixed $value A translatable value.
@param array $parameters An array of parameters for the message.
@return string|null | [
"Retrieve",
"a",
"fallback",
"value",
"from",
"a",
"translatable",
"value",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Property/ParsableValueTrait.php#L187-L201 |
39,656 | mcaskill/charcoal-support | src/Property/ParsableValueTrait.php | ParsableValueTrait.pairTranslatableArrayItems | protected function pairTranslatableArrayItems($value, $separator = ',')
{
if (empty($value) && !is_numeric($value)) {
return null;
}
if ($value instanceof Translation) {
$value = $value->data();
}
if ($separator instanceof \Closure) {
$value = $separator($value);
} else {
// Parse each locale's collection into an array
foreach ($value as $k => $v) {
$value[$k] = $this->parseAsMultiple($v, $separator);
}
}
// Retrieve the highest collection count among the locales
$count = max(array_map('count', $value));
// Pair the items across locales
$result = [];
for ($i = 0; $i < $count; $i++) {
$entry = [];
foreach ($value as $lang => $arr) {
if (isset($arr[$i])) {
$entry[$lang] = $arr[$i];
}
}
$result[] = $this->translator()->translation($entry);
}
return $result;
} | php | protected function pairTranslatableArrayItems($value, $separator = ',')
{
if (empty($value) && !is_numeric($value)) {
return null;
}
if ($value instanceof Translation) {
$value = $value->data();
}
if ($separator instanceof \Closure) {
$value = $separator($value);
} else {
// Parse each locale's collection into an array
foreach ($value as $k => $v) {
$value[$k] = $this->parseAsMultiple($v, $separator);
}
}
// Retrieve the highest collection count among the locales
$count = max(array_map('count', $value));
// Pair the items across locales
$result = [];
for ($i = 0; $i < $count; $i++) {
$entry = [];
foreach ($value as $lang => $arr) {
if (isset($arr[$i])) {
$entry[$lang] = $arr[$i];
}
}
$result[] = $this->translator()->translation($entry);
}
return $result;
} | [
"protected",
"function",
"pairTranslatableArrayItems",
"(",
"$",
"value",
",",
"$",
"separator",
"=",
"','",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
... | Pair the translatable array items.
Converts this:
```
{
"en": [ "Item A", "Item B", "Item C", "Item D" ],
"fr": [ "Élément A", "Élément B", "Élément C" ]
}
```
Into:
```
[
{
"en": "Item A",
"fr": "Élément A",
},
{
"en": "Item B",
"fr": "Élément B",
},
{
"en": "Item C",
"fr": "Élément C",
},
{
"en": "Item D",
"fr": "",
}
],
```
@param mixed $value The value being converted to an array.
@param mixed $separator The item delimiter. This can be a string or a function.
@return array | [
"Pair",
"the",
"translatable",
"array",
"items",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Property/ParsableValueTrait.php#L240-L277 |
39,657 | phPoirot/Std | src/Hydrator/HydrateGetters.php | HydrateGetters._getIgnoredByDocBlock | function _getIgnoredByDocBlock()
{
if ($this->_c_ignored_docblock)
// DocBlock Parsed To Cache Previously !!
return $this->_c_ignored_docblock;
$ignoredMethods = array();
$ref = $this->_newReflection();
$refuseIgnore = $this->getRefuseIgnore();
// ignored methods from Class DocComment:
$classDocComment = $ref->getDocComment();
if ($classDocComment !== false && preg_match_all('/.*[\n]?/', $classDocComment, $lines)) {
$lines = $lines[0];
$regex = '/.+(@method).+((?P<method_name>\b\w+)\(.*\))\s@'.self::HYDRATE_IGNORE.'\s/';
foreach($lines as $line) {
if (preg_match($regex, $line, $matches)) {
if (! in_array($matches['method_name'], $refuseIgnore) )
$ignoredMethods[] = $matches['method_name'];
}
}
}
// ignored methods from Method DocBlock
$methods = $ref->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach($methods as $m)
{
if (!(
('get' == substr($m->getName(), 0, 3) && $prefix = 'get')
|| ('is' == substr($m->getName(), 0, 2) && $prefix = 'is' )
))
// It's Not Getter Method
continue;
if (! in_array($m->getName(), $refuseIgnore) ) {
// it's not refused so check for ignore sign docblock
$mc = $m->getDocComment();
if ($mc !== false && preg_match('/@'.self::HYDRATE_IGNORE.'\s/', $mc, $matches))
$ignoredMethods[] = $m->getName();
}
}
return $this->_c_ignored_docblock = $ignoredMethods;
} | php | function _getIgnoredByDocBlock()
{
if ($this->_c_ignored_docblock)
// DocBlock Parsed To Cache Previously !!
return $this->_c_ignored_docblock;
$ignoredMethods = array();
$ref = $this->_newReflection();
$refuseIgnore = $this->getRefuseIgnore();
// ignored methods from Class DocComment:
$classDocComment = $ref->getDocComment();
if ($classDocComment !== false && preg_match_all('/.*[\n]?/', $classDocComment, $lines)) {
$lines = $lines[0];
$regex = '/.+(@method).+((?P<method_name>\b\w+)\(.*\))\s@'.self::HYDRATE_IGNORE.'\s/';
foreach($lines as $line) {
if (preg_match($regex, $line, $matches)) {
if (! in_array($matches['method_name'], $refuseIgnore) )
$ignoredMethods[] = $matches['method_name'];
}
}
}
// ignored methods from Method DocBlock
$methods = $ref->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach($methods as $m)
{
if (!(
('get' == substr($m->getName(), 0, 3) && $prefix = 'get')
|| ('is' == substr($m->getName(), 0, 2) && $prefix = 'is' )
))
// It's Not Getter Method
continue;
if (! in_array($m->getName(), $refuseIgnore) ) {
// it's not refused so check for ignore sign docblock
$mc = $m->getDocComment();
if ($mc !== false && preg_match('/@'.self::HYDRATE_IGNORE.'\s/', $mc, $matches))
$ignoredMethods[] = $m->getName();
}
}
return $this->_c_ignored_docblock = $ignoredMethods;
} | [
"function",
"_getIgnoredByDocBlock",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_c_ignored_docblock",
")",
"// DocBlock Parsed To Cache Previously !!",
"return",
"$",
"this",
"->",
"_c_ignored_docblock",
";",
"$",
"ignoredMethods",
"=",
"array",
"(",
")",
";",
... | Attain Ignored Methods From DockBlock
@ignore
@return []string | [
"Attain",
"Ignored",
"Methods",
"From",
"DockBlock"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Hydrator/HydrateGetters.php#L260-L308 |
39,658 | locomotivemtl/charcoal-property | src/Charcoal/Property/SelectablePropertyTrait.php | SelectablePropertyTrait.addChoices | public function addChoices(array $choices)
{
foreach ($choices as $choiceIdent => $choice) {
$this->addChoice($choiceIdent, $choice);
}
return $this;
} | php | public function addChoices(array $choices)
{
foreach ($choices as $choiceIdent => $choice) {
$this->addChoice($choiceIdent, $choice);
}
return $this;
} | [
"public",
"function",
"addChoices",
"(",
"array",
"$",
"choices",
")",
"{",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"choiceIdent",
"=>",
"$",
"choice",
")",
"{",
"$",
"this",
"->",
"addChoice",
"(",
"$",
"choiceIdent",
",",
"$",
"choice",
")",
";",
... | Merge the available choices.
@param array $choices One or more choice structures.
@return self | [
"Merge",
"the",
"available",
"choices",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/SelectablePropertyTrait.php#L43-L50 |
39,659 | locomotivemtl/charcoal-property | src/Charcoal/Property/SelectablePropertyTrait.php | SelectablePropertyTrait.parseChoices | protected function parseChoices(array $choices)
{
$parsed = [];
foreach ($choices as $choiceIdent => $choice) {
$choice = $this->parseChoice($choice, (string)$choiceIdent);
$choiceIdent = $choice['value'];
$parsed[$choiceIdent] = $choice;
}
return $parsed;
} | php | protected function parseChoices(array $choices)
{
$parsed = [];
foreach ($choices as $choiceIdent => $choice) {
$choice = $this->parseChoice($choice, (string)$choiceIdent);
$choiceIdent = $choice['value'];
$parsed[$choiceIdent] = $choice;
}
return $parsed;
} | [
"protected",
"function",
"parseChoices",
"(",
"array",
"$",
"choices",
")",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"choiceIdent",
"=>",
"$",
"choice",
")",
"{",
"$",
"choice",
"=",
"$",
"this",
"->",
"parse... | Parse the given values into choice structures.
@param array $choices One or more values to format.
@return array Returns a collection of choice structures. | [
"Parse",
"the",
"given",
"values",
"into",
"choice",
"structures",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/SelectablePropertyTrait.php#L163-L174 |
39,660 | Finesse/MicroDB | src/Exceptions/PDOException.php | PDOException.wrapBaseException | public static function wrapBaseException(BasePDOException $exception, string $query = null, array $values = null)
{
$newException = new static($exception->getMessage(), $exception->getCode(), $exception, $query, $values);
$newException->errorInfo = $exception->errorInfo;
return $newException;
} | php | public static function wrapBaseException(BasePDOException $exception, string $query = null, array $values = null)
{
$newException = new static($exception->getMessage(), $exception->getCode(), $exception, $query, $values);
$newException->errorInfo = $exception->errorInfo;
return $newException;
} | [
"public",
"static",
"function",
"wrapBaseException",
"(",
"BasePDOException",
"$",
"exception",
",",
"string",
"$",
"query",
"=",
"null",
",",
"array",
"$",
"values",
"=",
"null",
")",
"{",
"$",
"newException",
"=",
"new",
"static",
"(",
"$",
"exception",
... | Makes a self instance based on a base PDOException instance.
@param BasePDOException $exception Original exception
@param string|null $query SQL query which caused the error (if caused by a query)
@param array|null $values Bound values (if caused by a query)
@return self | [
"Makes",
"a",
"self",
"instance",
"based",
"on",
"a",
"base",
"PDOException",
"instance",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Exceptions/PDOException.php#L61-L66 |
39,661 | Finesse/MicroDB | src/Exceptions/PDOException.php | PDOException.valueToString | protected function valueToString($value): string
{
if ($value === false) {
return 'false';
}
if ($value === true) {
return 'true';
}
if ($value === null) {
return 'null';
}
if (is_string($value)) {
if (call_user_func(function_exists('mb_strlen') ? 'mb_strlen' : 'strlen', $value) > 100) {
$value = call_user_func(function_exists('mb_substr') ? 'mb_substr' : 'substr', $value, 0, 97).'...';
}
return '"'.$value.'"';
}
if (is_object($value)) {
return 'a '.get_class($value).' instance';
}
if (is_array($value)) {
$keys = array_keys($value);
$isAssociative = $keys !== array_keys($keys);
$valuesStrings = [];
foreach ($value as $key => $subValue) {
$valuesStrings[] = ($isAssociative ? $this->valueToString($key).' => ' : '')
. $this->valueToString($subValue);
}
return '['.implode(', ', $valuesStrings).']';
}
if (is_resource($value)) {
return 'a resource';
}
return (string)$value;
} | php | protected function valueToString($value): string
{
if ($value === false) {
return 'false';
}
if ($value === true) {
return 'true';
}
if ($value === null) {
return 'null';
}
if (is_string($value)) {
if (call_user_func(function_exists('mb_strlen') ? 'mb_strlen' : 'strlen', $value) > 100) {
$value = call_user_func(function_exists('mb_substr') ? 'mb_substr' : 'substr', $value, 0, 97).'...';
}
return '"'.$value.'"';
}
if (is_object($value)) {
return 'a '.get_class($value).' instance';
}
if (is_array($value)) {
$keys = array_keys($value);
$isAssociative = $keys !== array_keys($keys);
$valuesStrings = [];
foreach ($value as $key => $subValue) {
$valuesStrings[] = ($isAssociative ? $this->valueToString($key).' => ' : '')
. $this->valueToString($subValue);
}
return '['.implode(', ', $valuesStrings).']';
}
if (is_resource($value)) {
return 'a resource';
}
return (string)$value;
} | [
"protected",
"function",
"valueToString",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"'false'",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"return",
"'true'",
";",
"}",
... | Converts an arbitrary value to string for a debug message.
@param mixed $value
@return string | [
"Converts",
"an",
"arbitrary",
"value",
"to",
"string",
"for",
"a",
"debug",
"message",
"."
] | 839ee9b2bbf7bf9811f946325ae7a0eb03d0c063 | https://github.com/Finesse/MicroDB/blob/839ee9b2bbf7bf9811f946325ae7a0eb03d0c063/src/Exceptions/PDOException.php#L90-L126 |
39,662 | fxpio/fxp-cache | Adapter/AdapterDeferredTrait.php | AdapterDeferredTrait.clearDeferredByPrefixes | protected function clearDeferredByPrefixes(array $prefixes): void
{
$deferred = AdapterUtil::getPropertyValue($this, 'deferred');
foreach ($prefixes as $prefix) {
foreach ($deferred as $key => $value) {
if ('' === $prefix || 0 === strpos($key, $prefix)) {
unset($deferred[$key]);
}
}
}
AdapterUtil::setPropertyValue($this, 'deferred', $deferred);
} | php | protected function clearDeferredByPrefixes(array $prefixes): void
{
$deferred = AdapterUtil::getPropertyValue($this, 'deferred');
foreach ($prefixes as $prefix) {
foreach ($deferred as $key => $value) {
if ('' === $prefix || 0 === strpos($key, $prefix)) {
unset($deferred[$key]);
}
}
}
AdapterUtil::setPropertyValue($this, 'deferred', $deferred);
} | [
"protected",
"function",
"clearDeferredByPrefixes",
"(",
"array",
"$",
"prefixes",
")",
":",
"void",
"{",
"$",
"deferred",
"=",
"AdapterUtil",
"::",
"getPropertyValue",
"(",
"$",
"this",
",",
"'deferred'",
")",
";",
"foreach",
"(",
"$",
"prefixes",
"as",
"$"... | Clear the deferred by prefixes.
@param string[] $prefixes The prefixes | [
"Clear",
"the",
"deferred",
"by",
"prefixes",
"."
] | 55abf44a954890080fa2bfb080914ce7228ea769 | https://github.com/fxpio/fxp-cache/blob/55abf44a954890080fa2bfb080914ce7228ea769/Adapter/AdapterDeferredTrait.php#L26-L39 |
39,663 | tyam/bamboo | src/Engine.php | Engine.render | public function render(string $template, array $variables = null, ArrayAccess $sections = null)
{
if (is_null($sections)) {
$sections = new ArrayObject();
}
$renderer = new Renderer([$this, 'resolve'], $sections);
$output = $renderer->render($template, $variables);
return $output;
} | php | public function render(string $template, array $variables = null, ArrayAccess $sections = null)
{
if (is_null($sections)) {
$sections = new ArrayObject();
}
$renderer = new Renderer([$this, 'resolve'], $sections);
$output = $renderer->render($template, $variables);
return $output;
} | [
"public",
"function",
"render",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"variables",
"=",
"null",
",",
"ArrayAccess",
"$",
"sections",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"sections",
")",
")",
"{",
"$",
"sections",
"=",
... | Renders a specified template.
@param string $template path to the template. The path is relative from basedirs
@param array|null $variables template variables to be passed to template
@param ArrayAccess|null $sections array like object to hold section values | [
"Renders",
"a",
"specified",
"template",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Engine.php#L69-L77 |
39,664 | tyam/bamboo | src/Engine.php | Engine.resolve | public function resolve(string $template, array $variables = null)
{
return [
$this->resolvePath($template),
$this->resolveEnv($template, $variables)
];
} | php | public function resolve(string $template, array $variables = null)
{
return [
$this->resolvePath($template),
$this->resolveEnv($template, $variables)
];
} | [
"public",
"function",
"resolve",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"variables",
"=",
"null",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"resolvePath",
"(",
"$",
"template",
")",
",",
"$",
"this",
"->",
"resolveEnv",
"(",
"$",
"templat... | Resolves a template path and template variables. You should not call this method. | [
"Resolves",
"a",
"template",
"path",
"and",
"template",
"variables",
".",
"You",
"should",
"not",
"call",
"this",
"method",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Engine.php#L82-L88 |
39,665 | tyam/bamboo | src/Engine.php | Engine.resolvePath | public function resolvePath(string $template)
{
foreach ($this->basedirs as $basedir) {
$path = $basedir . self::SEPARATOR . $template . self::SUFFIX;
$path = str_replace(self::SEPARATOR, DIRECTORY_SEPARATOR, $path);
if (file_exists($path)) {
return $path;
}
}
// template not found
throw new \LogicException('template not found: '.$template);
} | php | public function resolvePath(string $template)
{
foreach ($this->basedirs as $basedir) {
$path = $basedir . self::SEPARATOR . $template . self::SUFFIX;
$path = str_replace(self::SEPARATOR, DIRECTORY_SEPARATOR, $path);
if (file_exists($path)) {
return $path;
}
}
// template not found
throw new \LogicException('template not found: '.$template);
} | [
"public",
"function",
"resolvePath",
"(",
"string",
"$",
"template",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"basedirs",
"as",
"$",
"basedir",
")",
"{",
"$",
"path",
"=",
"$",
"basedir",
".",
"self",
"::",
"SEPARATOR",
".",
"$",
"template",
".",
... | Resolves a template path. You should not call this method. | [
"Resolves",
"a",
"template",
"path",
".",
"You",
"should",
"not",
"call",
"this",
"method",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Engine.php#L93-L104 |
39,666 | tyam/bamboo | src/Engine.php | Engine.resolveEnv | public function resolveEnv(string $template, array $variables = null)
{
if (is_null($variables)) {
$variables = [];
}
$env = $this->getAutoBindings($template);
// explicit-bound variables precedes to auto-bound variables.
return array_merge($env, $variables);
} | php | public function resolveEnv(string $template, array $variables = null)
{
if (is_null($variables)) {
$variables = [];
}
$env = $this->getAutoBindings($template);
// explicit-bound variables precedes to auto-bound variables.
return array_merge($env, $variables);
} | [
"public",
"function",
"resolveEnv",
"(",
"string",
"$",
"template",
",",
"array",
"$",
"variables",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"variables",
")",
")",
"{",
"$",
"variables",
"=",
"[",
"]",
";",
"}",
"$",
"env",
"=",
"$",
... | Resolves a template variables. You should not call this method. | [
"Resolves",
"a",
"template",
"variables",
".",
"You",
"should",
"not",
"call",
"this",
"method",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Engine.php#L109-L118 |
39,667 | tyam/bamboo | src/Engine.php | Engine.getAutoBindings | protected function getAutoBindings(string $template)
{
if (is_null($this->variableProvider)) {
return [];
}
$bindings = $this->variableProvider->provideVariables($template);
return $bindings;
} | php | protected function getAutoBindings(string $template)
{
if (is_null($this->variableProvider)) {
return [];
}
$bindings = $this->variableProvider->provideVariables($template);
return $bindings;
} | [
"protected",
"function",
"getAutoBindings",
"(",
"string",
"$",
"template",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"variableProvider",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"bindings",
"=",
"$",
"this",
"->",
"variableProvide... | Pulls template variables from variableProvider, if there. | [
"Pulls",
"template",
"variables",
"from",
"variableProvider",
"if",
"there",
"."
] | cd2745cebb6376fe5e36072e265ef66ead5e6ccf | https://github.com/tyam/bamboo/blob/cd2745cebb6376fe5e36072e265ef66ead5e6ccf/src/Engine.php#L123-L132 |
39,668 | cmsgears/module-core | common/actions/meta/Update.php | Update.run | public function run( $cid ) {
$parent = $this->model;
if( isset( $parent ) ) {
$meta = $this->metaService->getById( $cid );
$belongsTo = $meta->hasAttribute( 'modelId' ) ? $meta->belongsTo( $parent ) : $meta->belongsTo( $parent, $this->modelService->getParentType() );
if( isset( $meta ) && $belongsTo ) {
if( $meta->load( Yii::$app->request->post(), $meta->getClassName() ) && $meta->validate() ) {
$this->metaService->update( $meta );
$meta->refresh();
$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => HtmlPurifier::process( $meta->value ) ];
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
// Generate Errors
$errors = AjaxUtil::generateErrorMessage( $model );
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
}
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->cmgCoreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | php | public function run( $cid ) {
$parent = $this->model;
if( isset( $parent ) ) {
$meta = $this->metaService->getById( $cid );
$belongsTo = $meta->hasAttribute( 'modelId' ) ? $meta->belongsTo( $parent ) : $meta->belongsTo( $parent, $this->modelService->getParentType() );
if( isset( $meta ) && $belongsTo ) {
if( $meta->load( Yii::$app->request->post(), $meta->getClassName() ) && $meta->validate() ) {
$this->metaService->update( $meta );
$meta->refresh();
$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => HtmlPurifier::process( $meta->value ) ];
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
// Generate Errors
$errors = AjaxUtil::generateErrorMessage( $model );
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
}
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->cmgCoreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | [
"public",
"function",
"run",
"(",
"$",
"cid",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"isset",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"metaService",
"->",
"getById",
"(",
"$",
"... | Update Meta for given Meta id, parent slug and parent type. | [
"Update",
"Meta",
"for",
"given",
"Meta",
"id",
"parent",
"slug",
"and",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/actions/meta/Update.php#L76-L109 |
39,669 | 975L/IncludeLibraryBundle | Twig/IncludeLibraryFont.php | IncludeLibraryFont.Font | public function Font(Environment $environment, $name)
{
//Returns the font code
$render = $environment->render('@c975LIncludeLibrary/fragments/font.html.twig', array(
'name' => str_replace(' ', '+', $name),
));
return str_replace(array("\n", ' ', ' ', ' ', ' ', ' '), ' ', $render);
} | php | public function Font(Environment $environment, $name)
{
//Returns the font code
$render = $environment->render('@c975LIncludeLibrary/fragments/font.html.twig', array(
'name' => str_replace(' ', '+', $name),
));
return str_replace(array("\n", ' ', ' ', ' ', ' ', ' '), ' ', $render);
} | [
"public",
"function",
"Font",
"(",
"Environment",
"$",
"environment",
",",
"$",
"name",
")",
"{",
"//Returns the font code",
"$",
"render",
"=",
"$",
"environment",
"->",
"render",
"(",
"'@c975LIncludeLibrary/fragments/font.html.twig'",
",",
"array",
"(",
"'name'",
... | Returns the font code to be included
@return string | [
"Returns",
"the",
"font",
"code",
"to",
"be",
"included"
] | 74f9140551d6f20c1308213c4c142f7fff43eb52 | https://github.com/975L/IncludeLibraryBundle/blob/74f9140551d6f20c1308213c4c142f7fff43eb52/Twig/IncludeLibraryFont.php#L40-L48 |
39,670 | cmsgears/module-core | common/models/traits/base/NameTypeTrait.php | NameTypeTrait.findByNameType | public static function findByNameType( $name, $type, $config = [] ) {
return self::queryByNameType( $name, $type, $config )->all();
} | php | public static function findByNameType( $name, $type, $config = [] ) {
return self::queryByNameType( $name, $type, $config )->all();
} | [
"public",
"static",
"function",
"findByNameType",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"queryByNameType",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"config",
")",
"->",
"all",
... | Find and return models using given name and type.
@param string $name
@param string $type
@param array $config
@return \cmsgears\core\common\models\base\ActiveRecord[] | [
"Find",
"and",
"return",
"models",
"using",
"given",
"name",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/NameTypeTrait.php#L196-L199 |
39,671 | cmsgears/module-core | common/models/traits/base/NameTypeTrait.php | NameTypeTrait.findFirstByNameType | public static function findFirstByNameType( $name, $type, $config = [] ) {
return self::queryByNameType( $name, $type, $config )->one();
} | php | public static function findFirstByNameType( $name, $type, $config = [] ) {
return self::queryByNameType( $name, $type, $config )->one();
} | [
"public",
"static",
"function",
"findFirstByNameType",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"queryByNameType",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"config",
")",
"->",
"one... | Find and return first model using given name and type.
@param string $name
@param string $type
@param array $config
@return \cmsgears\core\common\models\base\ActiveRecord | [
"Find",
"and",
"return",
"first",
"model",
"using",
"given",
"name",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/NameTypeTrait.php#L209-L212 |
39,672 | cmsgears/module-core | common/models/traits/base/NameTypeTrait.php | NameTypeTrait.isExistByNameType | public static function isExistByNameType( $name, $type, $config = [] ) {
$model = self::findByNameType( $name, $type, $config );
return isset( $model );
} | php | public static function isExistByNameType( $name, $type, $config = [] ) {
$model = self::findByNameType( $name, $type, $config );
return isset( $model );
} | [
"public",
"static",
"function",
"isExistByNameType",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"model",
"=",
"self",
"::",
"findByNameType",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"config",
")",
";... | Check whether model exist for given name and type.
@param string $name
@param string $type
@param array $config
@return boolean | [
"Check",
"whether",
"model",
"exist",
"for",
"given",
"name",
"and",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/NameTypeTrait.php#L222-L227 |
39,673 | cmsgears/module-core | common/services/traits/base/MultiSiteTrait.php | MultiSiteTrait.getSiteStats | public function getSiteStats( $config = [] ) {
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : null;
$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : null;
$limit = isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 0;
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
$query = new Query();
$query->select( [ 'siteId', 'count(id) as total' ] )
->from( $modelTable );
// Filter Status
if( isset( $status ) ) {
$query->where( "$modelTable.status=:status", [ ':status' => $status ] );
}
// Filter Type
if( isset( $type ) ) {
$query->andWhere( "$modelTable.type=:type", [ ':type' => $type ] );
}
// Limit
if( $limit > 0 ) {
$query->limit( $limit );
}
// Group and Order
$query->groupBy( 'siteId' )->orderBy( 'total DESC' );
return $query->all();
} | php | public function getSiteStats( $config = [] ) {
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : null;
$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : null;
$limit = isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 0;
$modelClass = static::$modelClass;
$modelTable = $modelClass::tableName();
$query = new Query();
$query->select( [ 'siteId', 'count(id) as total' ] )
->from( $modelTable );
// Filter Status
if( isset( $status ) ) {
$query->where( "$modelTable.status=:status", [ ':status' => $status ] );
}
// Filter Type
if( isset( $type ) ) {
$query->andWhere( "$modelTable.type=:type", [ ':type' => $type ] );
}
// Limit
if( $limit > 0 ) {
$query->limit( $limit );
}
// Group and Order
$query->groupBy( 'siteId' )->orderBy( 'total DESC' );
return $query->all();
} | [
"public",
"function",
"getSiteStats",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"status",
"=",
"isset",
"(",
"$",
"config",
"[",
"'status'",
"]",
")",
"?",
"$",
"config",
"[",
"'status'",
"]",
":",
"null",
";",
"$",
"type",
"=",
"isset",
... | Returns model count of active models.
@param type $config
@return type | [
"Returns",
"model",
"count",
"of",
"active",
"models",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/traits/base/MultiSiteTrait.php#L50-L86 |
39,674 | cmsgears/module-core | common/actions/meta/Create.php | Create.run | public function run() {
$parent = $this->model;
if( isset( $parent ) ) {
$metaClass = $this->metaService->getModelClass();
$meta = new $metaClass;
if( $meta->hasAttribute( 'modelId' ) ) {
$meta->modelId = $parent->id;
}
else {
$meta->parentId = $parent->id;
$meta->parentType = $this->modelService->getParentType();
}
if( empty( $meta->type ) ) {
$meta->type = CoreGlobal::TYPE_DEFAULT;
}
if( empty( $meta->valueType ) ) {
$meta->valueType = IMeta::VALUE_TYPE_TEXT;
}
if( $meta->load( Yii::$app->request->post(), $meta->getClassName() ) && $meta->validate() ) {
$this->metaService->create( $meta );
$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => HtmlPurifier::process( $meta->value ) ];
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
// Generate Errors
$errors = AjaxUtil::generateErrorMessage( $meta );
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | php | public function run() {
$parent = $this->model;
if( isset( $parent ) ) {
$metaClass = $this->metaService->getModelClass();
$meta = new $metaClass;
if( $meta->hasAttribute( 'modelId' ) ) {
$meta->modelId = $parent->id;
}
else {
$meta->parentId = $parent->id;
$meta->parentType = $this->modelService->getParentType();
}
if( empty( $meta->type ) ) {
$meta->type = CoreGlobal::TYPE_DEFAULT;
}
if( empty( $meta->valueType ) ) {
$meta->valueType = IMeta::VALUE_TYPE_TEXT;
}
if( $meta->load( Yii::$app->request->post(), $meta->getClassName() ) && $meta->validate() ) {
$this->metaService->create( $meta );
$data = [ 'id' => $meta->id, 'name' => $meta->name, 'value' => HtmlPurifier::process( $meta->value ) ];
// Trigger Ajax Success
return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
}
// Generate Errors
$errors = AjaxUtil::generateErrorMessage( $meta );
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_REQUEST ), $errors );
}
// Trigger Ajax Failure
return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"model",
";",
"if",
"(",
"isset",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"metaClass",
"=",
"$",
"this",
"->",
"metaService",
"->",
"getModelClass",
"(",
")",
";",
... | Create Meta for given parent slug and parent type. | [
"Create",
"Meta",
"for",
"given",
"parent",
"slug",
"and",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/actions/meta/Create.php#L78-L127 |
39,675 | rodrigoiii/skeleton-core | src/classes/App.php | App.boot | public function boot()
{
$app = $this;
$container = $this->getContainer();
if (is_api_request())
{
$this->loadDatabaseConnection();
$this->loadApiLibraries();
if (file_exists(system_path("registered-libraries-api.php")))
{
require system_path("registered-libraries-api.php");
}
if (file_exists(system_path("registered-global-middlewares-api.php")))
{
require system_path("registered-global-middlewares-api.php");
}
$app->group('/api', function() {
require base_path("routes/api.php");
});
}
else
{
$this->loadDatabaseConnection(true);
$this->loadLibraries();
require system_path("registered-libraries.php");
require system_path("registered-global-middlewares.php");
$this->loadMiddlewares($app, $container);
require base_path("routes/api.php");
require base_path("routes/web.php");
Profiler::finish("Application Done!");
}
} | php | public function boot()
{
$app = $this;
$container = $this->getContainer();
if (is_api_request())
{
$this->loadDatabaseConnection();
$this->loadApiLibraries();
if (file_exists(system_path("registered-libraries-api.php")))
{
require system_path("registered-libraries-api.php");
}
if (file_exists(system_path("registered-global-middlewares-api.php")))
{
require system_path("registered-global-middlewares-api.php");
}
$app->group('/api', function() {
require base_path("routes/api.php");
});
}
else
{
$this->loadDatabaseConnection(true);
$this->loadLibraries();
require system_path("registered-libraries.php");
require system_path("registered-global-middlewares.php");
$this->loadMiddlewares($app, $container);
require base_path("routes/api.php");
require base_path("routes/web.php");
Profiler::finish("Application Done!");
}
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
";",
"$",
"container",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
";",
"if",
"(",
"is_api_request",
"(",
")",
")",
"{",
"$",
"this",
"->",
"loadDatabaseConnection",
"("... | Boot the application.
@return void | [
"Boot",
"the",
"application",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L368-L405 |
39,676 | rodrigoiii/skeleton-core | src/classes/App.php | App.loadLibraries | private function loadLibraries()
{
/**
* Setup for 'respect/validation'
*/
Validator::with("SkeletonCore\\Validation\\Rules\\");
Validator::with(get_app_namespace() . "\\Validation\\Rules\\");
/**
* Enable tracy debug bar
*/
$debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
{
Debugger::enable(Debugger::DEVELOPMENT, storage_path('logs'));
Debugger::timer();
if (file_exists($directory = app_path("Debugbars")))
{
$debugbar_files = get_files($directory);
if (!empty($debugbar_files))
{
$debugbars = array_map(function($debugbar) use($directory) {
$new_debugbar = str_replace("{$directory}/", "", $debugbar);
return basename(str_replace("/", "\\", $new_debugbar), ".php");
}, $debugbar_files);
foreach ($debugbars as $debugbar) {
$classPanel = get_app_namespace() . "Debugbars\\{$debugbar}";
Debugger::getBar()->addPanel(new $classPanel);
}
}
}
}
} | php | private function loadLibraries()
{
/**
* Setup for 'respect/validation'
*/
Validator::with("SkeletonCore\\Validation\\Rules\\");
Validator::with(get_app_namespace() . "\\Validation\\Rules\\");
/**
* Enable tracy debug bar
*/
$debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
{
Debugger::enable(Debugger::DEVELOPMENT, storage_path('logs'));
Debugger::timer();
if (file_exists($directory = app_path("Debugbars")))
{
$debugbar_files = get_files($directory);
if (!empty($debugbar_files))
{
$debugbars = array_map(function($debugbar) use($directory) {
$new_debugbar = str_replace("{$directory}/", "", $debugbar);
return basename(str_replace("/", "\\", $new_debugbar), ".php");
}, $debugbar_files);
foreach ($debugbars as $debugbar) {
$classPanel = get_app_namespace() . "Debugbars\\{$debugbar}";
Debugger::getBar()->addPanel(new $classPanel);
}
}
}
}
} | [
"private",
"function",
"loadLibraries",
"(",
")",
"{",
"/**\n * Setup for 'respect/validation'\n */",
"Validator",
"::",
"with",
"(",
"\"SkeletonCore\\\\Validation\\\\Rules\\\\\"",
")",
";",
"Validator",
"::",
"with",
"(",
"get_app_namespace",
"(",
")",
".",... | Load the libraries of the application.
@return void | [
"Load",
"the",
"libraries",
"of",
"the",
"application",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L436-L471 |
39,677 | rodrigoiii/skeleton-core | src/classes/App.php | App.loadMiddlewares | private function loadMiddlewares($app, $container)
{
# Tracy debugbar
$debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
{
$app->add(new TracyMiddleware($app));
}
# Determine Route Before Application middleware
$app->add(new AppMiddleware($container));
# Global Error middleware
$app->add(new GlobalErrorsMiddleware($container));
# Old Input middleware
$app->add(new OldInputMiddleware($container));
# Global Csrf middleware
$app->add(new GlobalCsrfMiddleware($container));
$app->add($container->get('csrf'));
# Shared Server middleware
$app->add(new SharedServerMiddleware($container));
# Application Mode middleware
$app->add(new AppModeMiddleware($container));
# Remove Trailing Slash middleware
$app->add(new RemoveTrailingSlashMiddleware($container));
} | php | private function loadMiddlewares($app, $container)
{
# Tracy debugbar
$debugbar_enabled = filter_var(app_env('DEBUG_BAR_ON', false), FILTER_VALIDATE_BOOLEAN);
if (is_dev() && $debugbar_enabled && PHP_SAPI !== "cli")
{
$app->add(new TracyMiddleware($app));
}
# Determine Route Before Application middleware
$app->add(new AppMiddleware($container));
# Global Error middleware
$app->add(new GlobalErrorsMiddleware($container));
# Old Input middleware
$app->add(new OldInputMiddleware($container));
# Global Csrf middleware
$app->add(new GlobalCsrfMiddleware($container));
$app->add($container->get('csrf'));
# Shared Server middleware
$app->add(new SharedServerMiddleware($container));
# Application Mode middleware
$app->add(new AppModeMiddleware($container));
# Remove Trailing Slash middleware
$app->add(new RemoveTrailingSlashMiddleware($container));
} | [
"private",
"function",
"loadMiddlewares",
"(",
"$",
"app",
",",
"$",
"container",
")",
"{",
"# Tracy debugbar",
"$",
"debugbar_enabled",
"=",
"filter_var",
"(",
"app_env",
"(",
"'DEBUG_BAR_ON'",
",",
"false",
")",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
";",
"if",
... | Load the middlewares of the application.
@param SlimApp $app
@param ContainerInterface $container
@return void | [
"Load",
"the",
"middlewares",
"of",
"the",
"application",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L494-L524 |
39,678 | rodrigoiii/skeleton-core | src/classes/App.php | App.pushControllersInDefinition | private function pushControllersInDefinition($alias_namespace, $controllers_directory, &$default_definitions)
{
$controller_files = get_files($controllers_directory);
if (!empty($controller_files))
{
$controllers = array_map(function($controller) use($controllers_directory) {
$new_controller = str_replace("{$controllers_directory}/", "", $controller);
return basename(str_replace("/", "\\", $new_controller), ".php");
}, $controller_files);
$errors = [];
foreach ($controllers as $controller) {
if ($alias_namespace === "\\")
{
$controller_definition = $controller;
$controller_definition_value = get_app_namespace() . "Controllers\\{$controller}";
}
else
{
$module_name = str_replace("App\\", "", $alias_namespace);
$controller_sub_namespace = str_replace(app_path() . "/{$module_name}/Controllers", "", $controllers_directory);
$controller_sub_namespace = str_replace("/", "\\", $controller_sub_namespace);
$controller_definition = "{$alias_namespace}{$controller}";
$controller_definition_value = "{$alias_namespace}Controllers\\{$controller}";
}
if (!array_key_exists("{$controller_definition}", $default_definitions))
{
$default_definitions["{$controller_definition}"] = function(ContainerInterface $c) use ($controller_definition_value)
{
return new $controller_definition_value($c);
};
}
else
{
$errors[] = "{$controller} is already exist inside of definitions.";
}
}
if (!empty($errors))
{
exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
}
}
else
{
exit("Error: No controller found in {$controllers_directory} path.");
}
} | php | private function pushControllersInDefinition($alias_namespace, $controllers_directory, &$default_definitions)
{
$controller_files = get_files($controllers_directory);
if (!empty($controller_files))
{
$controllers = array_map(function($controller) use($controllers_directory) {
$new_controller = str_replace("{$controllers_directory}/", "", $controller);
return basename(str_replace("/", "\\", $new_controller), ".php");
}, $controller_files);
$errors = [];
foreach ($controllers as $controller) {
if ($alias_namespace === "\\")
{
$controller_definition = $controller;
$controller_definition_value = get_app_namespace() . "Controllers\\{$controller}";
}
else
{
$module_name = str_replace("App\\", "", $alias_namespace);
$controller_sub_namespace = str_replace(app_path() . "/{$module_name}/Controllers", "", $controllers_directory);
$controller_sub_namespace = str_replace("/", "\\", $controller_sub_namespace);
$controller_definition = "{$alias_namespace}{$controller}";
$controller_definition_value = "{$alias_namespace}Controllers\\{$controller}";
}
if (!array_key_exists("{$controller_definition}", $default_definitions))
{
$default_definitions["{$controller_definition}"] = function(ContainerInterface $c) use ($controller_definition_value)
{
return new $controller_definition_value($c);
};
}
else
{
$errors[] = "{$controller} is already exist inside of definitions.";
}
}
if (!empty($errors))
{
exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
}
}
else
{
exit("Error: No controller found in {$controllers_directory} path.");
}
} | [
"private",
"function",
"pushControllersInDefinition",
"(",
"$",
"alias_namespace",
",",
"$",
"controllers_directory",
",",
"&",
"$",
"default_definitions",
")",
"{",
"$",
"controller_files",
"=",
"get_files",
"(",
"$",
"controllers_directory",
")",
";",
"if",
"(",
... | Push controllers in default definition
@param string $alias_namespace
@param string $controllers_directory
@param array &$default_definitions
@return void | [
"Push",
"controllers",
"in",
"default",
"definition"
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L584-L635 |
39,679 | rodrigoiii/skeleton-core | src/classes/App.php | App.pushMiddlewaresInDefinition | private function pushMiddlewaresInDefinition($alias_namespace, $middlewares_directory, &$default_definitions)
{
$middleware_files = get_files($middlewares_directory);
if (!empty($middleware_files))
{
$middlewares = array_map(function($middleware) use($middlewares_directory) {
$new_middleware = str_replace("{$middlewares_directory}/", "", $middleware);
return basename(str_replace("/", "\\", $new_middleware), ".php");
}, $middleware_files);
$errors = [];
foreach ($middlewares as $middleware) {
if ($alias_namespace === "\\")
{
$middleware_definition = $middleware;
$middleware_definition_value = get_app_namespace() . "Middlewares\\{$middleware}";
}
else
{
$module_name = str_replace("App\\", "", $alias_namespace);
$middleware_sub_namespace = str_replace(app_path() . "/{$module_name}/Middlewares", "", $middlewares_directory);
$middleware_sub_namespace = str_replace("/", "\\", $middleware_sub_namespace);
$middleware_definition = "{$alias_namespace}{$middleware}";
$middleware_definition_value = "{$alias_namespace}Middlewares\\{$middleware}";
}
if (!array_key_exists("{$middleware_definition}", $default_definitions))
{
$default_definitions["{$middleware_definition}"] = function(ContainerInterface $c) use ($middleware_definition_value)
{
return new $middleware_definition_value($c);
};
}
else
{
$errors[] = "{$middleware} is already exist inside of definitions.";
}
}
if (!empty($errors))
{
exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
}
}
else
{
exit("Error: No middleware found in {$middlewares_directory} path.");
}
} | php | private function pushMiddlewaresInDefinition($alias_namespace, $middlewares_directory, &$default_definitions)
{
$middleware_files = get_files($middlewares_directory);
if (!empty($middleware_files))
{
$middlewares = array_map(function($middleware) use($middlewares_directory) {
$new_middleware = str_replace("{$middlewares_directory}/", "", $middleware);
return basename(str_replace("/", "\\", $new_middleware), ".php");
}, $middleware_files);
$errors = [];
foreach ($middlewares as $middleware) {
if ($alias_namespace === "\\")
{
$middleware_definition = $middleware;
$middleware_definition_value = get_app_namespace() . "Middlewares\\{$middleware}";
}
else
{
$module_name = str_replace("App\\", "", $alias_namespace);
$middleware_sub_namespace = str_replace(app_path() . "/{$module_name}/Middlewares", "", $middlewares_directory);
$middleware_sub_namespace = str_replace("/", "\\", $middleware_sub_namespace);
$middleware_definition = "{$alias_namespace}{$middleware}";
$middleware_definition_value = "{$alias_namespace}Middlewares\\{$middleware}";
}
if (!array_key_exists("{$middleware_definition}", $default_definitions))
{
$default_definitions["{$middleware_definition}"] = function(ContainerInterface $c) use ($middleware_definition_value)
{
return new $middleware_definition_value($c);
};
}
else
{
$errors[] = "{$middleware} is already exist inside of definitions.";
}
}
if (!empty($errors))
{
exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
}
}
else
{
exit("Error: No middleware found in {$middlewares_directory} path.");
}
} | [
"private",
"function",
"pushMiddlewaresInDefinition",
"(",
"$",
"alias_namespace",
",",
"$",
"middlewares_directory",
",",
"&",
"$",
"default_definitions",
")",
"{",
"$",
"middleware_files",
"=",
"get_files",
"(",
"$",
"middlewares_directory",
")",
";",
"if",
"(",
... | Push middlewares in default definition
@param string $alias_namespace
@param string $middlewares_directory
@param array &$default_definitions
@return void | [
"Push",
"middlewares",
"in",
"default",
"definition"
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L645-L696 |
39,680 | rodrigoiii/skeleton-core | src/classes/App.php | App.pushRequestsInDefinition | private function pushRequestsInDefinition($alias_namespace, $requests_directory, &$default_definitions)
{
$request_files = get_files($requests_directory);
if (!empty($request_files))
{
$requests = array_map(function($request) use($requests_directory) {
$new_request = str_replace("{$requests_directory}/", "", $request);
return basename(str_replace("/", "\\", $new_request), ".php");
}, $request_files);
$errors = [];
foreach ($requests as $request) {
if ($alias_namespace === "\\")
{
$request_definition = get_app_namespace() . "Requests\\{$request}";
}
else
{
$module_name = str_replace("App\\", "", $alias_namespace);
$request_sub_namespace = str_replace(app_path() . "/{$module_name}/Requests", "", $requests_directory);
$request_sub_namespace = str_replace("/", "\\", $request_sub_namespace);
$request_definition = "{$alias_namespace}Requests\\{$request}";
}
if (!array_key_exists("{$request_definition}", $default_definitions))
{
$default_definitions["{$request_definition}"] = function(ContainerInterface $c) use ($request_definition)
{
return new $request_definition($c->get('request'));
};
}
else
{
$errors[] = "{$request} is already exist inside of definitions.";
}
}
if (!empty($errors))
{
exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
}
}
else
{
exit("Error: No request found in {$requests_directory} path.");
}
} | php | private function pushRequestsInDefinition($alias_namespace, $requests_directory, &$default_definitions)
{
$request_files = get_files($requests_directory);
if (!empty($request_files))
{
$requests = array_map(function($request) use($requests_directory) {
$new_request = str_replace("{$requests_directory}/", "", $request);
return basename(str_replace("/", "\\", $new_request), ".php");
}, $request_files);
$errors = [];
foreach ($requests as $request) {
if ($alias_namespace === "\\")
{
$request_definition = get_app_namespace() . "Requests\\{$request}";
}
else
{
$module_name = str_replace("App\\", "", $alias_namespace);
$request_sub_namespace = str_replace(app_path() . "/{$module_name}/Requests", "", $requests_directory);
$request_sub_namespace = str_replace("/", "\\", $request_sub_namespace);
$request_definition = "{$alias_namespace}Requests\\{$request}";
}
if (!array_key_exists("{$request_definition}", $default_definitions))
{
$default_definitions["{$request_definition}"] = function(ContainerInterface $c) use ($request_definition)
{
return new $request_definition($c->get('request'));
};
}
else
{
$errors[] = "{$request} is already exist inside of definitions.";
}
}
if (!empty($errors))
{
exit("Error: Please fix the ff. before run the application: <li>" . implode("</li><li>", $errors));
}
}
else
{
exit("Error: No request found in {$requests_directory} path.");
}
} | [
"private",
"function",
"pushRequestsInDefinition",
"(",
"$",
"alias_namespace",
",",
"$",
"requests_directory",
",",
"&",
"$",
"default_definitions",
")",
"{",
"$",
"request_files",
"=",
"get_files",
"(",
"$",
"requests_directory",
")",
";",
"if",
"(",
"!",
"emp... | Push requests in default definition
@param string $alias_namespace
@param string $requests_directory
@param array &$default_definitions
@return void | [
"Push",
"requests",
"in",
"default",
"definition"
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L706-L755 |
39,681 | rodrigoiii/skeleton-core | src/classes/App.php | App.loadEnvironment | public static function loadEnvironment()
{
/**
* Application Environment
*/
$required_env = [
# application configuration
'APP_NAME', 'APP_ENV', 'APP_KEY',
# database configuration
'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME',
# debugging
'DEBUG_ON', 'DEBUG_BAR_ON',
# application mode
'APP_MODE',
# flag whether use dist or not
'USE_DIST'
];
$is_own_server = count(glob($_SERVER['DOCUMENT_ROOT'] . "/.env")) === 0;
$root = $_SERVER['DOCUMENT_ROOT'] . ($is_own_server ? "/.." : "");
if (is_api_request())
{
// remove DEBUG_BAR_ON, USE_DIST on api request
unset($required_env[array_search("DEBUG_BAR_ON", $required_env)]);
unset($required_env[array_search("USE_DIST", $required_env)]);
}
$dotenv = new \Dotenv\Dotenv($root);
$dotenv->overload();
$dotenv->required($required_env);
} | php | public static function loadEnvironment()
{
/**
* Application Environment
*/
$required_env = [
# application configuration
'APP_NAME', 'APP_ENV', 'APP_KEY',
# database configuration
'DB_HOSTNAME', 'DB_PORT', 'DB_USERNAME', 'DB_PASSWORD', 'DB_NAME',
# debugging
'DEBUG_ON', 'DEBUG_BAR_ON',
# application mode
'APP_MODE',
# flag whether use dist or not
'USE_DIST'
];
$is_own_server = count(glob($_SERVER['DOCUMENT_ROOT'] . "/.env")) === 0;
$root = $_SERVER['DOCUMENT_ROOT'] . ($is_own_server ? "/.." : "");
if (is_api_request())
{
// remove DEBUG_BAR_ON, USE_DIST on api request
unset($required_env[array_search("DEBUG_BAR_ON", $required_env)]);
unset($required_env[array_search("USE_DIST", $required_env)]);
}
$dotenv = new \Dotenv\Dotenv($root);
$dotenv->overload();
$dotenv->required($required_env);
} | [
"public",
"static",
"function",
"loadEnvironment",
"(",
")",
"{",
"/**\n * Application Environment\n */",
"$",
"required_env",
"=",
"[",
"# application configuration",
"'APP_NAME'",
",",
"'APP_ENV'",
",",
"'APP_KEY'",
",",
"# database configuration",
"'DB_HOST... | Load the environment of the application.
@return void | [
"Load",
"the",
"environment",
"of",
"the",
"application",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/App.php#L762-L797 |
39,682 | cmsgears/module-core | common/models/resources/ModelHierarchy.php | ModelHierarchy.findChild | public static function findChild( $parentId, $parentType, $childId ) {
return self::find()->where( 'parentId=:pid AND parentType=:type AND childId=:cid', [ ':pid' => $parentId, ':type' => $parentType, ':cid' => $childId ] )->one();
} | php | public static function findChild( $parentId, $parentType, $childId ) {
return self::find()->where( 'parentId=:pid AND parentType=:type AND childId=:cid', [ ':pid' => $parentId, ':type' => $parentType, ':cid' => $childId ] )->one();
} | [
"public",
"static",
"function",
"findChild",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"childId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'parentId=:pid AND parentType=:type AND childId=:cid'",
",",
"[",
"':pid'",
... | Find and return the child using parent id, parent type and child id.
@param integer $parentId
@param string $parentType
@param integer $childId
@return ModelHierarchy | [
"Find",
"and",
"return",
"the",
"child",
"using",
"parent",
"id",
"parent",
"type",
"and",
"child",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelHierarchy.php#L148-L151 |
39,683 | spiral/exceptions | src/Highlighter.php | Highlighter.highlightLines | public function highlightLines(string $source, int $line, int $around = 5): string
{
$lines = explode("\n", str_replace("\r\n", "\n", $this->highlight($source)));
$result = "";
foreach ($lines as $number => $code) {
$human = $number + 1;
if (!empty($around) && ($human < $line - $around || $human >= $line + $around + 1)) {
//Not included in a range
continue;
}
$result .= $this->r->line($human, mb_convert_encoding($code, 'utf-8'), $human === $line);
}
return $result;
} | php | public function highlightLines(string $source, int $line, int $around = 5): string
{
$lines = explode("\n", str_replace("\r\n", "\n", $this->highlight($source)));
$result = "";
foreach ($lines as $number => $code) {
$human = $number + 1;
if (!empty($around) && ($human < $line - $around || $human >= $line + $around + 1)) {
//Not included in a range
continue;
}
$result .= $this->r->line($human, mb_convert_encoding($code, 'utf-8'), $human === $line);
}
return $result;
} | [
"public",
"function",
"highlightLines",
"(",
"string",
"$",
"source",
",",
"int",
"$",
"line",
",",
"int",
"$",
"around",
"=",
"5",
")",
":",
"string",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"str_replace",
"(",
"\"\\r\\n\"",
",",
"\"\\... | Highlight PHP source and return N lines around target line.
@param string $source
@param int $line
@param int $around
@return string | [
"Highlight",
"PHP",
"source",
"and",
"return",
"N",
"lines",
"around",
"target",
"line",
"."
] | 9735a00b189ce61317cd49a9d6ec630f68cee381 | https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/Highlighter.php#L36-L52 |
39,684 | spiral/exceptions | src/Highlighter.php | Highlighter.highlight | public function highlight(string $source): string
{
$result = '';
$previous = [];
foreach ($this->getTokens($source) as $token) {
$result .= $this->r->token($token, $previous);
$previous = $token;
}
return $result;
} | php | public function highlight(string $source): string
{
$result = '';
$previous = [];
foreach ($this->getTokens($source) as $token) {
$result .= $this->r->token($token, $previous);
$previous = $token;
}
return $result;
} | [
"public",
"function",
"highlight",
"(",
"string",
"$",
"source",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"previous",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTokens",
"(",
"$",
"source",
")",
"as",
"$",
"token... | Returns highlighted PHP source.
@param string $source
@return string | [
"Returns",
"highlighted",
"PHP",
"source",
"."
] | 9735a00b189ce61317cd49a9d6ec630f68cee381 | https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/Highlighter.php#L60-L70 |
39,685 | spiral/exceptions | src/Highlighter.php | Highlighter.getTokens | private function getTokens(string $source): array
{
$tokens = [];
$line = 0;
foreach (token_get_all($source) as $token) {
if (isset($token[2])) {
$line = $token[2];
}
if (!is_array($token)) {
$token = [$token, $token, $line];
}
$tokens[] = $token;
}
return $tokens;
} | php | private function getTokens(string $source): array
{
$tokens = [];
$line = 0;
foreach (token_get_all($source) as $token) {
if (isset($token[2])) {
$line = $token[2];
}
if (!is_array($token)) {
$token = [$token, $token, $line];
}
$tokens[] = $token;
}
return $tokens;
} | [
"private",
"function",
"getTokens",
"(",
"string",
"$",
"source",
")",
":",
"array",
"{",
"$",
"tokens",
"=",
"[",
"]",
";",
"$",
"line",
"=",
"0",
";",
"foreach",
"(",
"token_get_all",
"(",
"$",
"source",
")",
"as",
"$",
"token",
")",
"{",
"if",
... | Get all tokens from PHP source normalized to always include line number.
@param string $source
@return array | [
"Get",
"all",
"tokens",
"from",
"PHP",
"source",
"normalized",
"to",
"always",
"include",
"line",
"number",
"."
] | 9735a00b189ce61317cd49a9d6ec630f68cee381 | https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/Highlighter.php#L78-L96 |
39,686 | cmsgears/module-core | common/models/entities/ObjectData.php | ObjectData.findByType | public static function findByType( $type, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'type=:type AND siteId=:siteId', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
}
else {
return static::find()->where( 'type=:type', [ ':type' => $type ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
}
} | php | public static function findByType( $type, $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
return static::find()->where( 'type=:type AND siteId=:siteId', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
}
else {
return static::find()->where( 'type=:type', [ ':type' => $type ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
}
} | [
"public",
"static",
"function",
"findByType",
"(",
"$",
"type",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"'ignoreSite'",
"]",
":",
"false... | Find and returns the objects with given type.
@param string $type
@param array $config
@return ObjectData[] | [
"Find",
"and",
"returns",
"the",
"objects",
"with",
"given",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/ObjectData.php#L420-L434 |
39,687 | cmsgears/module-core | common/models/entities/City.php | City.findUniqueByZone | public static function findUniqueByZone( $name, $countryId, $provinceId, $zone ) {
return self::find()->where( 'name=:name AND countryId=:cid AND provinceId=:pid AND zone=:zone', [ ':name' => $name, ':cid' => $countryId, ':pid' => $provinceId, ':zone' => $zone ] )->one();
} | php | public static function findUniqueByZone( $name, $countryId, $provinceId, $zone ) {
return self::find()->where( 'name=:name AND countryId=:cid AND provinceId=:pid AND zone=:zone', [ ':name' => $name, ':cid' => $countryId, ':pid' => $provinceId, ':zone' => $zone ] )->one();
} | [
"public",
"static",
"function",
"findUniqueByZone",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
",",
"$",
"zone",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'name=:name AND countryId=:cid AND provinceId=:pid AND... | Try to find out a city having unique name within zone.
@param string $name
@param integer $countryId
@param integer $provinceId
@param string $zone
@return City by name, country id, province id and zone | [
"Try",
"to",
"find",
"out",
"a",
"city",
"having",
"unique",
"name",
"within",
"zone",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/City.php#L338-L341 |
39,688 | cmsgears/module-core | common/models/entities/City.php | City.isUniqueExist | public static function isUniqueExist( $name, $countryId, $provinceId ) {
$city = self::findUnique( $name, $countryId, $provinceId );
return isset( $city );
} | php | public static function isUniqueExist( $name, $countryId, $provinceId ) {
$city = self::findUnique( $name, $countryId, $provinceId );
return isset( $city );
} | [
"public",
"static",
"function",
"isUniqueExist",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
")",
"{",
"$",
"city",
"=",
"self",
"::",
"findUnique",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
")",
";",
"return... | Check whether a city already exist using given name within province.
@param string $name
@param integer $countryId
@param integer $provinceId
@return boolean | [
"Check",
"whether",
"a",
"city",
"already",
"exist",
"using",
"given",
"name",
"within",
"province",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/City.php#L351-L356 |
39,689 | cmsgears/module-core | common/models/entities/City.php | City.isUniqueExistByZone | public static function isUniqueExistByZone( $name, $countryId, $provinceId, $zone ) {
$city = self::findUniqueByZone( $name, $countryId, $provinceId, $zone );
return isset( $city );
} | php | public static function isUniqueExistByZone( $name, $countryId, $provinceId, $zone ) {
$city = self::findUniqueByZone( $name, $countryId, $provinceId, $zone );
return isset( $city );
} | [
"public",
"static",
"function",
"isUniqueExistByZone",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
",",
"$",
"zone",
")",
"{",
"$",
"city",
"=",
"self",
"::",
"findUniqueByZone",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"... | Check whether a city already exist using given name within zone.
@param string $name
@param integer $countryId
@param integer $provinceId
@return boolean | [
"Check",
"whether",
"a",
"city",
"already",
"exist",
"using",
"given",
"name",
"within",
"zone",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/City.php#L366-L371 |
39,690 | geekwright/RegDom | src/RegisteredDomain.php | RegisteredDomain.normalizeHost | protected function normalizeHost($url)
{
$host = (false!==strpos($url, '/')) ? parse_url($url, PHP_URL_HOST) : $url;
$parts = explode('.', $host);
$utf8Host = '';
foreach ($parts as $part) {
$utf8Host = $utf8Host . (($utf8Host === '') ? '' : '.') . $this->convertPunycode($part);
}
return mb_strtolower($utf8Host);
} | php | protected function normalizeHost($url)
{
$host = (false!==strpos($url, '/')) ? parse_url($url, PHP_URL_HOST) : $url;
$parts = explode('.', $host);
$utf8Host = '';
foreach ($parts as $part) {
$utf8Host = $utf8Host . (($utf8Host === '') ? '' : '.') . $this->convertPunycode($part);
}
return mb_strtolower($utf8Host);
} | [
"protected",
"function",
"normalizeHost",
"(",
"$",
"url",
")",
"{",
"$",
"host",
"=",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"url",
",",
"'/'",
")",
")",
"?",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_HOST",
")",
":",
"$",
"url",
";",
"$",
"... | Given a URL or bare host name, return a normalized host name, converting punycode to UTF-8
and converting to lower case
@param string $url URL or host name
@return string | [
"Given",
"a",
"URL",
"or",
"bare",
"host",
"name",
"return",
"a",
"normalized",
"host",
"name",
"converting",
"punycode",
"to",
"UTF",
"-",
"8",
"and",
"converting",
"to",
"lower",
"case"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/RegisteredDomain.php#L41-L51 |
39,691 | geekwright/RegDom | src/RegisteredDomain.php | RegisteredDomain.convertPunycode | protected function convertPunycode($part)
{
if (strpos($part, 'xn--')===0) {
if (function_exists('idn_to_utf8')) {
if (defined('INTL_IDNA_VARIANT_UTS46')) { // PHP 7.2
return idn_to_utf8($part, 0, INTL_IDNA_VARIANT_UTS46);
}
return idn_to_utf8($part);
}
return $this->decodePunycode($part);
}
return $part;
} | php | protected function convertPunycode($part)
{
if (strpos($part, 'xn--')===0) {
if (function_exists('idn_to_utf8')) {
if (defined('INTL_IDNA_VARIANT_UTS46')) { // PHP 7.2
return idn_to_utf8($part, 0, INTL_IDNA_VARIANT_UTS46);
}
return idn_to_utf8($part);
}
return $this->decodePunycode($part);
}
return $part;
} | [
"protected",
"function",
"convertPunycode",
"(",
"$",
"part",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"part",
",",
"'xn--'",
")",
"===",
"0",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'idn_to_utf8'",
")",
")",
"{",
"if",
"(",
"defined",
"(",
"'I... | Convert a punycode string to UTF-8 if needed
@param string $part host component
@return string host component as UTF-8 | [
"Convert",
"a",
"punycode",
"string",
"to",
"UTF",
"-",
"8",
"if",
"needed"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/RegisteredDomain.php#L60-L72 |
39,692 | geekwright/RegDom | src/RegisteredDomain.php | RegisteredDomain.getRegisteredDomain | public function getRegisteredDomain($host)
{
$this->tree = $this->psl->getTree();
$signingDomain = $this->normalizeHost($host);
$signingDomainParts = explode('.', $signingDomain);
$result = $this->findRegisteredDomain($signingDomainParts, $this->tree);
if (empty($result)) {
// this is an invalid domain name
return null;
}
// assure there is at least 1 TLD in the stripped signing domain
if (!strpos($result, '.')) {
$cnt = count($signingDomainParts);
if ($cnt == 1 || $signingDomainParts[$cnt-2] == '') {
return null;
}
return $signingDomainParts[$cnt-2] . '.' . $signingDomainParts[$cnt-1];
}
return $result;
} | php | public function getRegisteredDomain($host)
{
$this->tree = $this->psl->getTree();
$signingDomain = $this->normalizeHost($host);
$signingDomainParts = explode('.', $signingDomain);
$result = $this->findRegisteredDomain($signingDomainParts, $this->tree);
if (empty($result)) {
// this is an invalid domain name
return null;
}
// assure there is at least 1 TLD in the stripped signing domain
if (!strpos($result, '.')) {
$cnt = count($signingDomainParts);
if ($cnt == 1 || $signingDomainParts[$cnt-2] == '') {
return null;
}
return $signingDomainParts[$cnt-2] . '.' . $signingDomainParts[$cnt-1];
}
return $result;
} | [
"public",
"function",
"getRegisteredDomain",
"(",
"$",
"host",
")",
"{",
"$",
"this",
"->",
"tree",
"=",
"$",
"this",
"->",
"psl",
"->",
"getTree",
"(",
")",
";",
"$",
"signingDomain",
"=",
"$",
"this",
"->",
"normalizeHost",
"(",
"$",
"host",
")",
"... | Determine the registered domain portion of the supplied host string
@param string $host a host name or URL containing a host name
@return string|null shortest registrable domain portion of the supplied host or null if invalid | [
"Determine",
"the",
"registered",
"domain",
"portion",
"of",
"the",
"supplied",
"host",
"string"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/RegisteredDomain.php#L168-L191 |
39,693 | geekwright/RegDom | src/RegisteredDomain.php | RegisteredDomain.findRegisteredDomain | protected function findRegisteredDomain($remainingSigningDomainParts, &$treeNode)
{
$sub = array_pop($remainingSigningDomainParts);
$result = null;
if (isset($treeNode['!'])) {
return '';
} elseif (is_array($treeNode) && array_key_exists($sub, $treeNode)) {
$result = $this->findRegisteredDomain($remainingSigningDomainParts, $treeNode[$sub]);
} elseif (is_array($treeNode) && array_key_exists('*', $treeNode)) {
$result = $this->findRegisteredDomain($remainingSigningDomainParts, $treeNode['*']);
} else {
return $sub;
}
if ($result === '') {
return $sub;
} elseif (strlen($result)>0) {
return $result . '.' . $sub;
}
return null;
} | php | protected function findRegisteredDomain($remainingSigningDomainParts, &$treeNode)
{
$sub = array_pop($remainingSigningDomainParts);
$result = null;
if (isset($treeNode['!'])) {
return '';
} elseif (is_array($treeNode) && array_key_exists($sub, $treeNode)) {
$result = $this->findRegisteredDomain($remainingSigningDomainParts, $treeNode[$sub]);
} elseif (is_array($treeNode) && array_key_exists('*', $treeNode)) {
$result = $this->findRegisteredDomain($remainingSigningDomainParts, $treeNode['*']);
} else {
return $sub;
}
if ($result === '') {
return $sub;
} elseif (strlen($result)>0) {
return $result . '.' . $sub;
}
return null;
} | [
"protected",
"function",
"findRegisteredDomain",
"(",
"$",
"remainingSigningDomainParts",
",",
"&",
"$",
"treeNode",
")",
"{",
"$",
"sub",
"=",
"array_pop",
"(",
"$",
"remainingSigningDomainParts",
")",
";",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",... | Recursive helper method to query the PSL tree
@param string[] $remainingSigningDomainParts parts of domain being queried
@param string[] $treeNode subset of tree array by reference
@return null|string | [
"Recursive",
"helper",
"method",
"to",
"query",
"the",
"PSL",
"tree"
] | f51eb343c526913f699d84c47596195a8a63ce09 | https://github.com/geekwright/RegDom/blob/f51eb343c526913f699d84c47596195a8a63ce09/src/RegisteredDomain.php#L201-L222 |
39,694 | rodrigoiii/skeleton-core | src/classes/Console/Commands/MakeCommandCommand.php | MakeCommandCommand.makeTemplate | private function makeTemplate($command)
{
$file = __DIR__ . "/../templates/command.php.dist";
try {
if (!file_exists($file)) throw new \Exception("{$file} file is not exist.", 1);
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{command}}' => $command,
'{{command_name}}' => strtolower($command)
]);
if (!file_exists(app_path("Commands")))
{
mkdir(app_path("Commands"), 0755, true);
}
$file_path = app_path("Commands/{$command}.php");
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
} catch (Exception $e) {
$output->writeln($e->getMessage());
}
return false;
} | php | private function makeTemplate($command)
{
$file = __DIR__ . "/../templates/command.php.dist";
try {
if (!file_exists($file)) throw new \Exception("{$file} file is not exist.", 1);
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{command}}' => $command,
'{{command_name}}' => strtolower($command)
]);
if (!file_exists(app_path("Commands")))
{
mkdir(app_path("Commands"), 0755, true);
}
$file_path = app_path("Commands/{$command}.php");
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
} catch (Exception $e) {
$output->writeln($e->getMessage());
}
return false;
} | [
"private",
"function",
"makeTemplate",
"(",
"$",
"command",
")",
"{",
"$",
"file",
"=",
"__DIR__",
".",
"\"/../templates/command.php.dist\"",
";",
"try",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"throw",
"new",
"\\",
"Exception",
"("... | Create the command template.
@depends handle
@param string $command
@return boolean | [
"Create",
"the",
"command",
"template",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeCommandCommand.php#L63-L94 |
39,695 | cmsgears/module-core | common/models/hierarchy/HierarchicalModel.php | HierarchicalModel.validateParentChain | public function validateParentChain( $attribute, $params ) {
if( !$this->hasErrors() ) {
if( isset( $this->parentId ) && $this->parentId > 0 && $this->parentId == $this->id ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_PARENT_CHAIN ) );
}
}
} | php | public function validateParentChain( $attribute, $params ) {
if( !$this->hasErrors() ) {
if( isset( $this->parentId ) && $this->parentId > 0 && $this->parentId == $this->id ) {
$this->addError( $attribute, Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_PARENT_CHAIN ) );
}
}
} | [
"public",
"function",
"validateParentChain",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parentId",
")",
"&&",
"$",
"this",
"-... | Validates parent to ensure that the model cannot be parent of itself.
@param type $attribute
@param type $params
@return void | [
"Validates",
"parent",
"to",
"ensure",
"that",
"the",
"model",
"cannot",
"be",
"parent",
"of",
"itself",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/hierarchy/HierarchicalModel.php#L67-L76 |
39,696 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.getRandom | public function getRandom( $config = [] ) {
$offset = $config[ 'offset' ] ?? 0;
$limit = $config[ 'limit' ] ?? 10;
$conditions = $config[ 'conditions' ] ?? null;
// model class
$modelClass = static::$modelClass;
// query generation
$results = [];
$query = $modelClass::find();
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
// Randomise -----------
$query = $query->orderBy( 'RAND()' );
// Offset --------------
if( $offset > 0 ) {
$query->offset( $offset );
}
// Limit ---------------
if( $limit > 0 ) {
$query->limit( $limit );
}
$results = $query->all();
return $results;
} | php | public function getRandom( $config = [] ) {
$offset = $config[ 'offset' ] ?? 0;
$limit = $config[ 'limit' ] ?? 10;
$conditions = $config[ 'conditions' ] ?? null;
// model class
$modelClass = static::$modelClass;
// query generation
$results = [];
$query = $modelClass::find();
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
// Randomise -----------
$query = $query->orderBy( 'RAND()' );
// Offset --------------
if( $offset > 0 ) {
$query->offset( $offset );
}
// Limit ---------------
if( $limit > 0 ) {
$query->limit( $limit );
}
$results = $query->all();
return $results;
} | [
"public",
"function",
"getRandom",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"offset",
"=",
"$",
"config",
"[",
"'offset'",
"]",
"??",
"0",
";",
"$",
"limit",
"=",
"$",
"config",
"[",
"'limit'",
"]",
"??",
"10",
";",
"$",
"conditions",
"=... | A simple method to get random ids.
It's not efficient for tables having large number of rows.
TODO: We can make this method efficient by using random offset and limit instead of going for full table scan.
Avoid using count() to get total rows. Use Stats Table to get estimated count.
Notes: Using offset is much slower as compared to start index with limit. | [
"A",
"simple",
"method",
"to",
"get",
"random",
"ids",
".",
"It",
"s",
"not",
"efficient",
"for",
"tables",
"having",
"large",
"number",
"of",
"rows",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L220-L270 |
39,697 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.delete | public function delete( $model, $config = [] ) {
$hard = $config[ 'hard' ] ?? true;
$notify = $config[ 'notify' ] ?? true;
if( isset( $model ) ) {
// Permanent Delete
if( $hard ) {
return $model->delete();
}
// Soft Delete - Useful for models using status to mark model as deleted, but keep for historic purpose.
else {
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
// Approval Trait
return $this->softDeleteNotify( $model, $notify, $config );
}
else {
return $this->softDelete( $model );
}
}
}
return false;
} | php | public function delete( $model, $config = [] ) {
$hard = $config[ 'hard' ] ?? true;
$notify = $config[ 'notify' ] ?? true;
if( isset( $model ) ) {
// Permanent Delete
if( $hard ) {
return $model->delete();
}
// Soft Delete - Useful for models using status to mark model as deleted, but keep for historic purpose.
else {
$interfaces = class_implements( static::class );
if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {
// Approval Trait
return $this->softDeleteNotify( $model, $notify, $config );
}
else {
return $this->softDelete( $model );
}
}
}
return false;
} | [
"public",
"function",
"delete",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"hard",
"=",
"$",
"config",
"[",
"'hard'",
"]",
"??",
"true",
";",
"$",
"notify",
"=",
"$",
"config",
"[",
"'notify'",
"]",
"??",
"true",
";",
... | Delete the model by deleting related resources and mapper.
@param type $model
@param type $config
@return boolean | [
"Delete",
"the",
"model",
"by",
"deleting",
"related",
"resources",
"and",
"mapper",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L497-L527 |
39,698 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.applyBulkByTargetId | public function applyBulkByTargetId( $column, $action, $target, $config = [] ) {
foreach ( $target as $id ) {
$model = $this->getById( $id );
// Bulk Conditions
if( isset( $model ) ) {
$this->applyBulk( $model, $column, $action, $target, $config );
}
}
} | php | public function applyBulkByTargetId( $column, $action, $target, $config = [] ) {
foreach ( $target as $id ) {
$model = $this->getById( $id );
// Bulk Conditions
if( isset( $model ) ) {
$this->applyBulk( $model, $column, $action, $target, $config );
}
}
} | [
"public",
"function",
"applyBulkByTargetId",
"(",
"$",
"column",
",",
"$",
"action",
",",
"$",
"target",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"target",
"as",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
... | Default method for bulk actions.
@param string $column
@param string $action
@param string $target | [
"Default",
"method",
"for",
"bulk",
"actions",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L571-L583 |
39,699 | cmsgears/module-core | common/services/base/ActiveRecordService.php | ActiveRecordService.notifyAdmin | public function notifyAdmin( $model, $config = [] ) {
$config[ 'admin' ] = true;
$config[ 'direct' ] = false;
$this->sendNotification( $model, $config );
} | php | public function notifyAdmin( $model, $config = [] ) {
$config[ 'admin' ] = true;
$config[ 'direct' ] = false;
$this->sendNotification( $model, $config );
} | [
"public",
"function",
"notifyAdmin",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"[",
"'admin'",
"]",
"=",
"true",
";",
"$",
"config",
"[",
"'direct'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"sendNotification",
... | Trigger Admin Notifications. The template settings will override.
@param \cmsgears\core\common\models\base\ActiveRecord $model
@param array $config - key elements are template(template slug), data(template data),
title(notification title), createdBy(creator id), parentId(parent model id), parentType,
link, admin(flag), adminLink and users(to notify) | [
"Trigger",
"Admin",
"Notifications",
".",
"The",
"template",
"settings",
"will",
"override",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/ActiveRecordService.php#L601-L607 |
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.