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,200 | paulbunyannet/bandolier | src/Bandolier/Type/Encoded.php | Encoded.isJson | public static function isJson($string)
{
if (!is_string($string) || (is_string($string)
&& substr($string, 0, 1) !== '{'
&& substr($string, 0, 1) !== '[')
) {
return false;
}
@json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
} | php | public static function isJson($string)
{
if (!is_string($string) || (is_string($string)
&& substr($string, 0, 1) !== '{'
&& substr($string, 0, 1) !== '[')
) {
return false;
}
@json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
} | [
"public",
"static",
"function",
"isJson",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
"||",
"(",
"is_string",
"(",
"$",
"string",
")",
"&&",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"1",
")",
"!==",
"'{... | Check if string is json
@param $string
@return bool | [
"Check",
"if",
"string",
"is",
"json"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Encoded.php#L98-L108 |
39,201 | phpgithook/hello-world | src/Hooks/Committer.php | Committer.preCommit | public function preCommit(
InputInterface $input,
OutputInterface $output,
ParameterBagInterface $configuration
): bool {
// Here we can fx run phpunit on in the code
// Or we can just post something to httpbin
// As this module requires guzzle via composer, we can ofcourse utialize it
$client = new Client(
[
'base_uri' => 'http://httpbin.org',
'timeout' => 2.0,
]
);
$request = new Request('GET', '/');
$promise = $client->sendAsync($request)->then(
function (Response $response) use ($output) {
$output->writeln('I completed! '.$response->getBody());
return true;
}
);
return $promise->wait();
} | php | public function preCommit(
InputInterface $input,
OutputInterface $output,
ParameterBagInterface $configuration
): bool {
// Here we can fx run phpunit on in the code
// Or we can just post something to httpbin
// As this module requires guzzle via composer, we can ofcourse utialize it
$client = new Client(
[
'base_uri' => 'http://httpbin.org',
'timeout' => 2.0,
]
);
$request = new Request('GET', '/');
$promise = $client->sendAsync($request)->then(
function (Response $response) use ($output) {
$output->writeln('I completed! '.$response->getBody());
return true;
}
);
return $promise->wait();
} | [
"public",
"function",
"preCommit",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"ParameterBagInterface",
"$",
"configuration",
")",
":",
"bool",
"{",
"// Here we can fx run phpunit on in the code",
"// Or we can just post something to httpb... | This hook is called before obtaining the proposed commit message.
Returning false will abort the commit.
It is used to check the commit itself (rather than the message).
@param InputInterface $input
@param OutputInterface $output
@param ParameterBagInterface $configuration
@return bool | [
"This",
"hook",
"is",
"called",
"before",
"obtaining",
"the",
"proposed",
"commit",
"message",
"."
] | c01e5d57b24f5b4823c4007127d8fdf401f2f7da | https://github.com/phpgithook/hello-world/blob/c01e5d57b24f5b4823c4007127d8fdf401f2f7da/src/Hooks/Committer.php#L30-L55 |
39,202 | cmsgears/module-core | common/components/Factory.php | Factory.registerMapperAliases | public function registerMapperAliases() {
$factory = Yii::$app->factory->getContainer();
$factory->set( 'modelAddressService', 'cmsgears\core\common\services\mappers\ModelAddressService' );
$factory->set( 'modelLocationService', 'cmsgears\core\common\services\mappers\ModelLocationService' );
$factory->set( 'modelCategoryService', 'cmsgears\core\common\services\mappers\ModelCategoryService' );
$factory->set( 'modelFileService', 'cmsgears\core\common\services\mappers\ModelFileService' );
$factory->set( 'modelFormService', 'cmsgears\core\common\services\mappers\ModelFormService' );
$factory->set( 'modelGalleryService', 'cmsgears\core\common\services\mappers\ModelGalleryService' );
$factory->set( 'modelObjectService', 'cmsgears\core\common\services\mappers\ModelObjectService' );
$factory->set( 'modelOptionService', 'cmsgears\core\common\services\mappers\ModelOptionService' );
$factory->set( 'modelTagService', 'cmsgears\core\common\services\mappers\ModelTagService' );
$factory->set( 'siteMemberService', 'cmsgears\core\common\services\mappers\SiteMemberService' );
} | php | public function registerMapperAliases() {
$factory = Yii::$app->factory->getContainer();
$factory->set( 'modelAddressService', 'cmsgears\core\common\services\mappers\ModelAddressService' );
$factory->set( 'modelLocationService', 'cmsgears\core\common\services\mappers\ModelLocationService' );
$factory->set( 'modelCategoryService', 'cmsgears\core\common\services\mappers\ModelCategoryService' );
$factory->set( 'modelFileService', 'cmsgears\core\common\services\mappers\ModelFileService' );
$factory->set( 'modelFormService', 'cmsgears\core\common\services\mappers\ModelFormService' );
$factory->set( 'modelGalleryService', 'cmsgears\core\common\services\mappers\ModelGalleryService' );
$factory->set( 'modelObjectService', 'cmsgears\core\common\services\mappers\ModelObjectService' );
$factory->set( 'modelOptionService', 'cmsgears\core\common\services\mappers\ModelOptionService' );
$factory->set( 'modelTagService', 'cmsgears\core\common\services\mappers\ModelTagService' );
$factory->set( 'siteMemberService', 'cmsgears\core\common\services\mappers\SiteMemberService' );
} | [
"public",
"function",
"registerMapperAliases",
"(",
")",
"{",
"$",
"factory",
"=",
"Yii",
"::",
"$",
"app",
"->",
"factory",
"->",
"getContainer",
"(",
")",
";",
"$",
"factory",
"->",
"set",
"(",
"'modelAddressService'",
",",
"'cmsgears\\core\\common\\services\\... | Registers mapper aliases. | [
"Registers",
"mapper",
"aliases",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/components/Factory.php#L175-L189 |
39,203 | GrupaZero/admin | src/Gzero/Admin/ModuleRegistry.php | ModuleRegistry.register | public function register($name, $path)
{
if (!Str::contains($path, '.js')) {
throw new \Exception('Path should lead to javascript file');
}
$this->modules->push(compact('name', 'path'));
} | php | public function register($name, $path)
{
if (!Str::contains($path, '.js')) {
throw new \Exception('Path should lead to javascript file');
}
$this->modules->push(compact('name', 'path'));
} | [
"public",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"Str",
"::",
"contains",
"(",
"$",
"path",
",",
"'.js'",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Path should lead to javascript file'",
")",
... | Returning new admin modules
@param string $name AngularJS module name
@param string $path Path to AngularJS module file
@throws \Exception | [
"Returning",
"new",
"admin",
"modules"
] | 3463d2f9fec1bd11778d10d6763c6d8c46e23915 | https://github.com/GrupaZero/admin/blob/3463d2f9fec1bd11778d10d6763c6d8c46e23915/src/Gzero/Admin/ModuleRegistry.php#L38-L44 |
39,204 | locomotivemtl/charcoal-property | src/Charcoal/Property/SpriteProperty.php | SpriteProperty.setData | public function setData(array $data)
{
parent::setData($data);
$this->setChoices($this->buildChoicesFromSprite());
return $this;
} | php | public function setData(array $data)
{
parent::setData($data);
$this->setChoices($this->buildChoicesFromSprite());
return $this;
} | [
"public",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
"{",
"parent",
"::",
"setData",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"setChoices",
"(",
"$",
"this",
"->",
"buildChoicesFromSprite",
"(",
")",
")",
";",
"return",
"$",
"this",
... | Sets data on this entity.
@uses self::offsetSet()
@param array $data Key-value array of data to append.
@return self | [
"Sets",
"data",
"on",
"this",
"entity",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/SpriteProperty.php#L53-L60 |
39,205 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Facade/CachePoolFacade.php | CachePoolFacade.get | public function get($key, callable $resolve = null, $ttl = null)
{
$pool = $this->cachePool();
$item = $pool->getItem($key);
$data = $item->get();
if ($item->isHit()) {
return $data;
}
if (is_callable($resolve)) {
$data = $resolve($data, $item);
$this->save($item, $data, $ttl);
return $data;
}
return null;
} | php | public function get($key, callable $resolve = null, $ttl = null)
{
$pool = $this->cachePool();
$item = $pool->getItem($key);
$data = $item->get();
if ($item->isHit()) {
return $data;
}
if (is_callable($resolve)) {
$data = $resolve($data, $item);
$this->save($item, $data, $ttl);
return $data;
}
return null;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"callable",
"$",
"resolve",
"=",
"null",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"pool",
"=",
"$",
"this",
"->",
"cachePool",
"(",
")",
";",
"$",
"item",
"=",
"$",
"pool",
"->",
"getItem",
... | Retrieve the value associated with the specified key from the pool.
This method will call $lambada if the cache item representing $key resulted in a cache miss.
@param string $key The key for which to return the associated value.
@param callable|null $resolve The function to execute if the cached value does not exist
or is considered expired. The function must return a value which will be stored
in the cache before being returned by the method.
```
$resolve ( mixed $data, CacheItemInterface $item ) : mixed
```
The $resolve takes on two parameters:
1. The expired value or NULL if no value was stored.
2. The cache item of the specified key.
@param mixed $ttl An integer, interval, date, or NULL to use the facade's default value.
@return mixed The value corresponding to this cache item's $key, or NULL if not found. | [
"Retrieve",
"the",
"value",
"associated",
"with",
"the",
"specified",
"key",
"from",
"the",
"pool",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Facade/CachePoolFacade.php#L65-L82 |
39,206 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Facade/CachePoolFacade.php | CachePoolFacade.save | protected function save(CacheItemInterface $item, $value, $ttl = null)
{
if ($ttl === null) {
$ttl = $this->defaultTtl();
}
if (is_numeric($ttl) || ($ttl instanceof \DateInterval)) {
$item->expiresAfter($ttl);
} elseif ($ttl instanceof \DateTimeInterface) {
$item->expiresAt($ttl);
}
$item->set($value);
return $this->cachePool()->save($item);
} | php | protected function save(CacheItemInterface $item, $value, $ttl = null)
{
if ($ttl === null) {
$ttl = $this->defaultTtl();
}
if (is_numeric($ttl) || ($ttl instanceof \DateInterval)) {
$item->expiresAfter($ttl);
} elseif ($ttl instanceof \DateTimeInterface) {
$item->expiresAt($ttl);
}
$item->set($value);
return $this->cachePool()->save($item);
} | [
"protected",
"function",
"save",
"(",
"CacheItemInterface",
"$",
"item",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"ttl",
"===",
"null",
")",
"{",
"$",
"ttl",
"=",
"$",
"this",
"->",
"defaultTtl",
"(",
")",
";",
"... | Set a value on a cache item to be saved immediately.
@param CacheItemInterface $item The cache item to save.
@param mixed $value The serializable value to be stored.
@param mixed $ttl An integer, interval, date, or NULL to use the facade's default value.
@return boolean TRUE if the item was successfully persisted. FALSE if there was an error. | [
"Set",
"a",
"value",
"on",
"a",
"cache",
"item",
"to",
"be",
"saved",
"immediately",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Facade/CachePoolFacade.php#L118-L133 |
39,207 | locomotivemtl/charcoal-cache | src/Charcoal/Cache/Facade/CachePoolFacade.php | CachePoolFacade.delete | public function delete(...$keys)
{
$pool = $this->cachePool();
$results = true;
foreach ($keys as $key) {
$results = $pool->deleteItem($key) && $results;
}
return $results;
} | php | public function delete(...$keys)
{
$pool = $this->cachePool();
$results = true;
foreach ($keys as $key) {
$results = $pool->deleteItem($key) && $results;
}
return $results;
} | [
"public",
"function",
"delete",
"(",
"...",
"$",
"keys",
")",
"{",
"$",
"pool",
"=",
"$",
"this",
"->",
"cachePool",
"(",
")",
";",
"$",
"results",
"=",
"true",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"results",
"=",
... | Removes one or more items from the pool.
@param string[] ...$keys One or many keys to delete.
@return bool TRUE if the item was successfully removed. FALSE if there was an error. | [
"Removes",
"one",
"or",
"more",
"items",
"from",
"the",
"pool",
"."
] | 38d04f6f21c6a826c28e08a5ac48b02c37e8da85 | https://github.com/locomotivemtl/charcoal-cache/blob/38d04f6f21c6a826c28e08a5ac48b02c37e8da85/src/Charcoal/Cache/Facade/CachePoolFacade.php#L141-L151 |
39,208 | mcaskill/charcoal-support | src/App/Routing/RouteRedirectionManager.php | RouteRedirectionManager.setupRoutes | public function setupRoutes()
{
foreach ($this->paths as $oldPath => &$newPath) {
$this->addRedirection($oldPath, $newPath);
}
} | php | public function setupRoutes()
{
foreach ($this->paths as $oldPath => &$newPath) {
$this->addRedirection($oldPath, $newPath);
}
} | [
"public",
"function",
"setupRoutes",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"paths",
"as",
"$",
"oldPath",
"=>",
"&",
"$",
"newPath",
")",
"{",
"$",
"this",
"->",
"addRedirection",
"(",
"$",
"oldPath",
",",
"$",
"newPath",
")",
";",
"}",
... | Setup Route Redirections
@return void | [
"Setup",
"Route",
"Redirections"
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/App/Routing/RouteRedirectionManager.php#L93-L98 |
39,209 | mcaskill/charcoal-support | src/App/Routing/RouteRedirectionManager.php | RouteRedirectionManager.addRedirection | public function addRedirection($oldPath, $newPath)
{
if (!is_string($oldPath) && !($oldPath instanceof UriInterface)) {
throw new InvalidArgumentException(
'The deprecated path must be a string; received %s',
(is_object($oldPath) ? get_class($oldPath) : gettype($oldPath))
);
}
$newPath = $this->parseRoute($newPath);
$this->paths[$oldPath] = $newPath;
$this->app()->map(
$newPath['methods'],
$oldPath,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$newPath
) {
if ($newPath['route'] === 404) {
return $response->withStatus(404);
}
$locale = isset($args['lang']) ? $args['lang'] : null;
if ($newPath['data_key'] === null) {
if (is_array($newPath['route'])) {
$route = $this->translator()->translate($newPath['route'], [], null, $locale);
if ($route !== null) {
$newPath['route'] = $route;
} else {
$newPath['route'] = reset($newPath['route']);
}
}
return $response->withRedirect($newPath['route'], $newPath['status']);
}
if (!isset($newPath['ident'])) {
return $response->withStatus(404);
}
if (!empty($newPath[$newPath['data_key']])) {
$args = array_merge($newPath[$newPath['data_key']], $args);
}
$router = $this->get('router');
if (isset($newPath[$newPath['data_key']]['route_endpoint'])) {
$endpoint = $this->translator()->translate(
$newPath[$newPath['data_key']]['route_endpoint'],
[],
null,
$locale
);
$args['route_endpoint'] = $endpoint;
}
$uri = $router->pathFor($newPath['ident'], $args);
return $response->withRedirect($uri, $newPath['status']);
}
);
} | php | public function addRedirection($oldPath, $newPath)
{
if (!is_string($oldPath) && !($oldPath instanceof UriInterface)) {
throw new InvalidArgumentException(
'The deprecated path must be a string; received %s',
(is_object($oldPath) ? get_class($oldPath) : gettype($oldPath))
);
}
$newPath = $this->parseRoute($newPath);
$this->paths[$oldPath] = $newPath;
$this->app()->map(
$newPath['methods'],
$oldPath,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$newPath
) {
if ($newPath['route'] === 404) {
return $response->withStatus(404);
}
$locale = isset($args['lang']) ? $args['lang'] : null;
if ($newPath['data_key'] === null) {
if (is_array($newPath['route'])) {
$route = $this->translator()->translate($newPath['route'], [], null, $locale);
if ($route !== null) {
$newPath['route'] = $route;
} else {
$newPath['route'] = reset($newPath['route']);
}
}
return $response->withRedirect($newPath['route'], $newPath['status']);
}
if (!isset($newPath['ident'])) {
return $response->withStatus(404);
}
if (!empty($newPath[$newPath['data_key']])) {
$args = array_merge($newPath[$newPath['data_key']], $args);
}
$router = $this->get('router');
if (isset($newPath[$newPath['data_key']]['route_endpoint'])) {
$endpoint = $this->translator()->translate(
$newPath[$newPath['data_key']]['route_endpoint'],
[],
null,
$locale
);
$args['route_endpoint'] = $endpoint;
}
$uri = $router->pathFor($newPath['ident'], $args);
return $response->withRedirect($uri, $newPath['status']);
}
);
} | [
"public",
"function",
"addRedirection",
"(",
"$",
"oldPath",
",",
"$",
"newPath",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"oldPath",
")",
"&&",
"!",
"(",
"$",
"oldPath",
"instanceof",
"UriInterface",
")",
")",
"{",
"throw",
"new",
"InvalidArgume... | Add a redirection.
Accepted formats for $paths:
**Format #1 — Basic Usage**
The "new-path" can be a URI or a named {@see \Slim\Route}.
```
[ 'old-path' => 'new-path' ]
```
**Format #2 — Redirect to front page**
```
[
'old-path' => []
]
```
**Format #2 — Custom HTTP status code**
```
[
'old-path' => [
'route' => 'new-path',
'status' => 301
]
]
```
**Format #3 — Verbose redirection**
The target URI or route can be multilingual.
```
[
'old-path' => [
'route' => [
'en' => '/fr/new-path'
'es' => '/es/nueva-ruta'
'fr' => '/fr/nouveau-chemin'
],
'route_type' => 'templates',
'status' => 301
]
]
```
@todo Add support for explicit {@see \Slim\Route}.
@param string $oldPath The path to watch for and redirect to $newPath.
@param mixed $newPath The destination for $oldPath.
@throws InvalidArgumentException If the path is not a string.
@return void | [
"Add",
"a",
"redirection",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/App/Routing/RouteRedirectionManager.php#L156-L222 |
39,210 | cmsgears/module-core | common/models/base/ActiveRecord.php | ActiveRecord.copyForUpdateTo | public function copyForUpdateTo( $model, $attributes = [] ) {
foreach ( $attributes as $attribute ) {
$model->setAttribute( $attribute, $this->getAttribute( $attribute ) );
}
} | php | public function copyForUpdateTo( $model, $attributes = [] ) {
foreach ( $attributes as $attribute ) {
$model->setAttribute( $attribute, $this->getAttribute( $attribute ) );
}
} | [
"public",
"function",
"copyForUpdateTo",
"(",
"$",
"model",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"model",
"->",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"this... | Copy attributes to update a model for selected columns to target model.
@param ActiveRecord $model Target Model to which attributes will be copied. | [
"Copy",
"attributes",
"to",
"update",
"a",
"model",
"for",
"selected",
"columns",
"to",
"target",
"model",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ActiveRecord.php#L124-L130 |
39,211 | cmsgears/module-core | common/models/base/ActiveRecord.php | ActiveRecord.copyForUpdateFrom | public function copyForUpdateFrom( $model, $attributes = [] ) {
foreach ( $attributes as $attribute ) {
if( $this->hasAttribute( $attribute ) ) {
$this->setAttribute( $attribute, $model->$attribute );
}
else {
$this->$attribute = $model->$attribute;
}
}
} | php | public function copyForUpdateFrom( $model, $attributes = [] ) {
foreach ( $attributes as $attribute ) {
if( $this->hasAttribute( $attribute ) ) {
$this->setAttribute( $attribute, $model->$attribute );
}
else {
$this->$attribute = $model->$attribute;
}
}
} | [
"public",
"function",
"copyForUpdateFrom",
"(",
"$",
"model",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"attribute",
")"... | Copy attributes to update a model for selected columns from target model.
@param ActiveRecord $model Source Model from which attributes will be copied. | [
"Copy",
"attributes",
"to",
"update",
"a",
"model",
"for",
"selected",
"columns",
"from",
"target",
"model",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ActiveRecord.php#L137-L150 |
39,212 | cmsgears/module-core | common/models/base/ActiveRecord.php | ActiveRecord.getMediumText | public function getMediumText( $text ) {
if( strlen( $text ) > Yii::$app->core->mediumText ) {
$text = substr( $text, 0, Yii::$app->core->mediumText );
}
return HtmlPurifier::process( $text );
} | php | public function getMediumText( $text ) {
if( strlen( $text ) > Yii::$app->core->mediumText ) {
$text = substr( $text, 0, Yii::$app->core->mediumText );
}
return HtmlPurifier::process( $text );
} | [
"public",
"function",
"getMediumText",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"text",
")",
">",
"Yii",
"::",
"$",
"app",
"->",
"core",
"->",
"mediumText",
")",
"{",
"$",
"text",
"=",
"substr",
"(",
"$",
"text",
",",
"0",
",",
... | Returns cut down string having pre-defined medium length.
[[\cmsgears\core\common\config\CoreGlobal\CoreGlobal::TEXT_MEDIUM]] will be used by
default in case application property does not override it.
@param string $text to be cut down.
@return string the cut down text. | [
"Returns",
"cut",
"down",
"string",
"having",
"pre",
"-",
"defined",
"medium",
"length",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ActiveRecord.php#L161-L169 |
39,213 | cmsgears/module-core | common/models/base/ActiveRecord.php | ActiveRecord.queryWithAll | public static function queryWithAll( $config = [] ) {
// Query Config --------
$query = static::find();
$relations = isset( $config[ 'relations' ] ) ? $config[ 'relations' ] : [];
$conditions = isset( $config[ 'conditions' ] ) ? $config[ 'conditions' ] : null;
$filters = isset( $config[ 'filters' ] ) ? $config[ 'filters' ] : null;
$groups = isset( $config[ 'groups' ] ) ? $config[ 'groups' ] : null;
// Relations -----------
$eager = false;
$join = 'LEFT JOIN';
foreach ( $relations as $relation ) {
if( is_array( $relation ) && isset( $relation[ 'relation' ] ) ) {
$eager = isset( $relation[ 'eager' ] ) ? $relation[ 'eager' ] : false;
$join = isset( $relation[ 'join' ] ) ? $relation[ 'join' ] : 'LEFT JOIN';
$query->joinWith( $relation[ 'relation' ], $eager, $join );
}
else {
$query->joinWith( $relation );
}
}
// Conditions ----------
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
// Filters -------------
if( isset( $filters ) ) {
foreach ( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Grouping -------------
if( isset( $groups ) ) {
foreach ( $groups as $group ) {
$query = $query->groupBy( $group );
}
}
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
$modelTable = static::tableName();
$query = $query->andWhere( "$modelTable.siteId=:siteId", [ ':siteId' => $siteId ] );
}
return $query;
} | php | public static function queryWithAll( $config = [] ) {
// Query Config --------
$query = static::find();
$relations = isset( $config[ 'relations' ] ) ? $config[ 'relations' ] : [];
$conditions = isset( $config[ 'conditions' ] ) ? $config[ 'conditions' ] : null;
$filters = isset( $config[ 'filters' ] ) ? $config[ 'filters' ] : null;
$groups = isset( $config[ 'groups' ] ) ? $config[ 'groups' ] : null;
// Relations -----------
$eager = false;
$join = 'LEFT JOIN';
foreach ( $relations as $relation ) {
if( is_array( $relation ) && isset( $relation[ 'relation' ] ) ) {
$eager = isset( $relation[ 'eager' ] ) ? $relation[ 'eager' ] : false;
$join = isset( $relation[ 'join' ] ) ? $relation[ 'join' ] : 'LEFT JOIN';
$query->joinWith( $relation[ 'relation' ], $eager, $join );
}
else {
$query->joinWith( $relation );
}
}
// Conditions ----------
if( isset( $conditions ) ) {
foreach ( $conditions as $ckey => $condition ) {
if( is_numeric( $ckey ) ) {
$query->andWhere( $condition );
unset( $conditions[ $ckey ] );
}
}
$query->andWhere( $conditions );
}
// Filters -------------
if( isset( $filters ) ) {
foreach ( $filters as $filter ) {
$query = $query->andFilterWhere( $filter );
}
}
// Grouping -------------
if( isset( $groups ) ) {
foreach ( $groups as $group ) {
$query = $query->groupBy( $group );
}
}
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
$modelTable = static::tableName();
$query = $query->andWhere( "$modelTable.siteId=:siteId", [ ':siteId' => $siteId ] );
}
return $query;
} | [
"public",
"static",
"function",
"queryWithAll",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"// Query Config --------",
"$",
"query",
"=",
"static",
"::",
"find",
"(",
")",
";",
"$",
"relations",
"=",
"isset",
"(",
"$",
"config",
"[",
"'relations'",
"]"... | Generates and return query with model relations.
* Relations - The relations are method name without get prefix of methods returning
query generated by one-to-one(hasOne) or one-to-many(hasMany) called within the method.
* Conditions - Conditions to be applied to further filter the results of query generated
after applying all the relations.
* Filters - Filters applied on top of conditions to further filter the results.
* Groups - Group By Column applied on the query generate after applying all the
relations, conditions and filters.
The final query generated by this method will be returned to generate results.
@param array $config query configurations.
@return \yii\db\ActiveQuery to query with related models. | [
"Generates",
"and",
"return",
"query",
"with",
"model",
"relations",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/base/ActiveRecord.php#L229-L309 |
39,214 | ec-europa/oe-robo | src/Tasks.php | Tasks.projectInstallConfig | public function projectInstallConfig() {
$this->getInstallTask()
->arg('config_installer_sync_configure_form.sync_directory=' . $this->config('settings.config_directories.sync'))
->siteInstall('config_installer')
->run();
$this->projectSetupSettings();
} | php | public function projectInstallConfig() {
$this->getInstallTask()
->arg('config_installer_sync_configure_form.sync_directory=' . $this->config('settings.config_directories.sync'))
->siteInstall('config_installer')
->run();
$this->projectSetupSettings();
} | [
"public",
"function",
"projectInstallConfig",
"(",
")",
"{",
"$",
"this",
"->",
"getInstallTask",
"(",
")",
"->",
"arg",
"(",
"'config_installer_sync_configure_form.sync_directory='",
".",
"$",
"this",
"->",
"config",
"(",
"'settings.config_directories.sync'",
")",
")... | Install site from given configuration.
@command project:install-config
@aliases pic | [
"Install",
"site",
"from",
"given",
"configuration",
"."
] | ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02 | https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/Tasks.php#L51-L57 |
39,215 | ec-europa/oe-robo | src/Tasks.php | Tasks.projectSetupSettings | public function projectSetupSettings() {
$settings_file = $this->root() . '/build/sites/default/settings.php';
$processor = new SettingsProcessor(Robo::config());
$content = $processor->process($settings_file);
$this->collectionBuilder()->addTaskList([
$this->taskFilesystemStack()->chmod('build/sites', 0775, 0000, TRUE),
$this->taskWriteToFile($settings_file)->text($content),
])->run();
} | php | public function projectSetupSettings() {
$settings_file = $this->root() . '/build/sites/default/settings.php';
$processor = new SettingsProcessor(Robo::config());
$content = $processor->process($settings_file);
$this->collectionBuilder()->addTaskList([
$this->taskFilesystemStack()->chmod('build/sites', 0775, 0000, TRUE),
$this->taskWriteToFile($settings_file)->text($content),
])->run();
} | [
"public",
"function",
"projectSetupSettings",
"(",
")",
"{",
"$",
"settings_file",
"=",
"$",
"this",
"->",
"root",
"(",
")",
".",
"'/build/sites/default/settings.php'",
";",
"$",
"processor",
"=",
"new",
"SettingsProcessor",
"(",
"Robo",
"::",
"config",
"(",
"... | Setup Drupal settings.
@command project:setup-settings
@aliases pss | [
"Setup",
"Drupal",
"settings",
"."
] | ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02 | https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/Tasks.php#L65-L73 |
39,216 | ec-europa/oe-robo | src/Tasks.php | Tasks.getInstallTask | protected function getInstallTask() {
return $this->taskDrushStack($this->config('bin.drush'))
->arg("--root={$this->root()}/build")
->siteName($this->config('site.name'))
->siteMail($this->config('site.mail'))
->locale($this->config('site.locale'))
->accountMail($this->config('account.mail'))
->accountName($this->config('account.name'))
->accountPass($this->config('account.password'))
->dbPrefix($this->config('database.prefix'))
->dbUrl(sprintf("mysql://%s:%s@%s:%s/%s",
$this->config('database.user'),
$this->config('database.password'),
$this->config('database.host'),
$this->config('database.port'),
$this->config('database.name')));
} | php | protected function getInstallTask() {
return $this->taskDrushStack($this->config('bin.drush'))
->arg("--root={$this->root()}/build")
->siteName($this->config('site.name'))
->siteMail($this->config('site.mail'))
->locale($this->config('site.locale'))
->accountMail($this->config('account.mail'))
->accountName($this->config('account.name'))
->accountPass($this->config('account.password'))
->dbPrefix($this->config('database.prefix'))
->dbUrl(sprintf("mysql://%s:%s@%s:%s/%s",
$this->config('database.user'),
$this->config('database.password'),
$this->config('database.host'),
$this->config('database.port'),
$this->config('database.name')));
} | [
"protected",
"function",
"getInstallTask",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"taskDrushStack",
"(",
"$",
"this",
"->",
"config",
"(",
"'bin.drush'",
")",
")",
"->",
"arg",
"(",
"\"--root={$this->root()}/build\"",
")",
"->",
"siteName",
"(",
"$",
"t... | Get installation task.
@return \Boedah\Robo\Task\Drush\DrushStack
Drush installation task. | [
"Get",
"installation",
"task",
"."
] | ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02 | https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/Tasks.php#L81-L97 |
39,217 | mcaskill/charcoal-support | src/Property/ManufacturablePropertyInputTrait.php | ManufacturablePropertyInputTrait.propertyInputFactory | public function propertyInputFactory()
{
if (!isset($this->propertyInputFactory)) {
throw new RuntimeException(sprintf(
'Property Control Factory is not defined for [%s]',
get_class($this)
));
}
return $this->propertyInputFactory;
} | php | public function propertyInputFactory()
{
if (!isset($this->propertyInputFactory)) {
throw new RuntimeException(sprintf(
'Property Control Factory is not defined for [%s]',
get_class($this)
));
}
return $this->propertyInputFactory;
} | [
"public",
"function",
"propertyInputFactory",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"propertyInputFactory",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Property Control Factory is not defined for [%s]'",
",",
... | Retrieve the property control factory.
@throws RuntimeException If the property control factory is missing.
@return FactoryInterface | [
"Retrieve",
"the",
"property",
"control",
"factory",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/Property/ManufacturablePropertyInputTrait.php#L39-L49 |
39,218 | phPoirot/Std | src/tValidator.php | tValidator.assertValidate | final function assertValidate()
{
$exceptions = $this->doAssertValidate();
if (!is_array($exceptions))
throw new \RuntimeException(sprintf(
'Unknown Validation Assertion Value Of Type Array (%s).'
, flatten($exceptions)
));
if ( empty($exceptions) )
return;
// Chain Exception:
// TODO what if assertValidator or exceptions list has \Exception instance instead of exUnexpected
$_f__chainExceptions = function (exUnexpectedValue $ex, &$list) use (&$_f__chainExceptions)
{
if ( empty($list) )
return $ex;
/** @var exUnexpectedValue $exception */
$exception = array_pop($list);
$r = new exUnexpectedValue(
$exception->getMessage()
, $exception->getParameterName()
, $exception->getError()
, $_f__chainExceptions($ex, $list)
);
return $r;
};
$ex = $_f__chainExceptions(new exUnexpectedValue('Validation Error', null), $exceptions);
throw $ex;
} | php | final function assertValidate()
{
$exceptions = $this->doAssertValidate();
if (!is_array($exceptions))
throw new \RuntimeException(sprintf(
'Unknown Validation Assertion Value Of Type Array (%s).'
, flatten($exceptions)
));
if ( empty($exceptions) )
return;
// Chain Exception:
// TODO what if assertValidator or exceptions list has \Exception instance instead of exUnexpected
$_f__chainExceptions = function (exUnexpectedValue $ex, &$list) use (&$_f__chainExceptions)
{
if ( empty($list) )
return $ex;
/** @var exUnexpectedValue $exception */
$exception = array_pop($list);
$r = new exUnexpectedValue(
$exception->getMessage()
, $exception->getParameterName()
, $exception->getError()
, $_f__chainExceptions($ex, $list)
);
return $r;
};
$ex = $_f__chainExceptions(new exUnexpectedValue('Validation Error', null), $exceptions);
throw $ex;
} | [
"final",
"function",
"assertValidate",
"(",
")",
"{",
"$",
"exceptions",
"=",
"$",
"this",
"->",
"doAssertValidate",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"exceptions",
")",
")",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(... | Assert Validate Entity
@throws exUnexpectedValue | [
"Assert",
"Validate",
"Entity"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/tValidator.php#L22-L59 |
39,219 | datalaere/php-auth-framework | src/Auth.php | Auth.login | public function login($usernameOrEmail = null, $password = null, $remember = false)
{
if (!$this->isLoggedIn()) {
$user = $this->search($usernameOrEmail);
if ($user) {
if (Password::verify($password, $this->data()->Password)) {
// password is correct start a user session
$this->startSession();
if ($remember) {
$hash = Token::create(46);
$hashCheck = $this->db->select(
array('User_ID'),
$this->sessions,
null,
array(array('User_ID', '=', $this->data()->ID)),
array('LIMIT' => 1)
);
if (!$hashCheck->count()) {
$this->db->insert($this->sessions, array(
'User_ID' => $this->data()->ID,
'Token' => $hash
));
}
Cookie::set($this->cookieName, $hash, $this->cookieExpiry);
}
return true;
}
}
}
return false;
} | php | public function login($usernameOrEmail = null, $password = null, $remember = false)
{
if (!$this->isLoggedIn()) {
$user = $this->search($usernameOrEmail);
if ($user) {
if (Password::verify($password, $this->data()->Password)) {
// password is correct start a user session
$this->startSession();
if ($remember) {
$hash = Token::create(46);
$hashCheck = $this->db->select(
array('User_ID'),
$this->sessions,
null,
array(array('User_ID', '=', $this->data()->ID)),
array('LIMIT' => 1)
);
if (!$hashCheck->count()) {
$this->db->insert($this->sessions, array(
'User_ID' => $this->data()->ID,
'Token' => $hash
));
}
Cookie::set($this->cookieName, $hash, $this->cookieExpiry);
}
return true;
}
}
}
return false;
} | [
"public",
"function",
"login",
"(",
"$",
"usernameOrEmail",
"=",
"null",
",",
"$",
"password",
"=",
"null",
",",
"$",
"remember",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isLoggedIn",
"(",
")",
")",
"{",
"$",
"user",
"=",
"$",
... | Log users in | [
"Log",
"users",
"in"
] | 742420ffff35988556a951228172bf9418a03e28 | https://github.com/datalaere/php-auth-framework/blob/742420ffff35988556a951228172bf9418a03e28/src/Auth.php#L122-L157 |
39,220 | phpgithook/hello-world | src/Hooks/PrePush.php | PrePush.prePush | public function prePush(string $destinationName, string $destinationLocation, InputInterface $input, OutputInterface $output, ParameterBagInterface $configuration): bool
{
if ('Fail' === $destinationName) {
return false;
}
// We can write to the console, with data we got
$output->writeln([
'Destination is: '.$destinationName,
'Location is: '.$destinationLocation,
]);
return true;
} | php | public function prePush(string $destinationName, string $destinationLocation, InputInterface $input, OutputInterface $output, ParameterBagInterface $configuration): bool
{
if ('Fail' === $destinationName) {
return false;
}
// We can write to the console, with data we got
$output->writeln([
'Destination is: '.$destinationName,
'Location is: '.$destinationLocation,
]);
return true;
} | [
"public",
"function",
"prePush",
"(",
"string",
"$",
"destinationName",
",",
"string",
"$",
"destinationLocation",
",",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
",",
"ParameterBagInterface",
"$",
"configuration",
")",
":",
"bool",
"{"... | Called prior to a push to a remote.
Returning false aborts the push.
@param string $destinationName Git remote name
@param string $destinationLocation Git remote uri
@param InputInterface $input
@param OutputInterface $output
@param ParameterBagInterface $configuration
@return bool | [
"Called",
"prior",
"to",
"a",
"push",
"to",
"a",
"remote",
"."
] | c01e5d57b24f5b4823c4007127d8fdf401f2f7da | https://github.com/phpgithook/hello-world/blob/c01e5d57b24f5b4823c4007127d8fdf401f2f7da/src/Hooks/PrePush.php#L25-L38 |
39,221 | cmsgears/module-core | common/models/resources/ModelComment.php | ModelComment.queryByType | public static function queryByType( $parentId, $parentType, $type = ModelComment::TYPE_COMMENT, $config = [] ) {
//$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;
return self::queryByParent( $parentId, $parentType, $config )->andWhere( [ 'type' => $type, 'status' => $status ] );
} | php | public static function queryByType( $parentId, $parentType, $type = ModelComment::TYPE_COMMENT, $config = [] ) {
//$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;
return self::queryByParent( $parentId, $parentType, $config )->andWhere( [ 'type' => $type, 'status' => $status ] );
} | [
"public",
"static",
"function",
"queryByType",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"type",
"=",
"ModelComment",
"::",
"TYPE_COMMENT",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"//$type\t= isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::... | Return query to find the comments by type.
@param integer $parentId
@param string $parentType
@param string $type
@param array $config
@return \yii\db\ActiveQuery to query by type. | [
"Return",
"query",
"to",
"find",
"the",
"comments",
"by",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelComment.php#L316-L322 |
39,222 | cmsgears/module-core | common/models/resources/ModelComment.php | ModelComment.queryByParentType | public static function queryByParentType( $parentType, $config = [] ) {
$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;
return self::find()->where( [ 'parentType' => $parentType, 'type' => $type, 'status' => $status ] );
} | php | public static function queryByParentType( $parentType, $config = [] ) {
$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;
return self::find()->where( [ 'parentType' => $parentType, 'type' => $type, 'status' => $status ] );
} | [
"public",
"static",
"function",
"queryByParentType",
"(",
"$",
"parentType",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"type",
"=",
"isset",
"(",
"$",
"config",
"[",
"'type'",
"]",
")",
"?",
"$",
"config",
"[",
"'type'",
"]",
":",
"self",
"... | Return query to find the comments by parent type.
@param string $parentType
@param array $config
@return \yii\db\ActiveQuery to query by parent type. | [
"Return",
"query",
"to",
"find",
"the",
"comments",
"by",
"parent",
"type",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelComment.php#L331-L337 |
39,223 | cmsgears/module-core | common/models/resources/ModelComment.php | ModelComment.queryByBaseId | public static function queryByBaseId( $baseId, $config = [] ) {
$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;
return self::find()->where( [ 'baseId' => $baseId, 'type' => $type, 'status' => $status ] );
} | php | public static function queryByBaseId( $baseId, $config = [] ) {
$type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : self::TYPE_COMMENT;
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : self::STATUS_APPROVED;
return self::find()->where( [ 'baseId' => $baseId, 'type' => $type, 'status' => $status ] );
} | [
"public",
"static",
"function",
"queryByBaseId",
"(",
"$",
"baseId",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"type",
"=",
"isset",
"(",
"$",
"config",
"[",
"'type'",
"]",
")",
"?",
"$",
"config",
"[",
"'type'",
"]",
":",
"self",
"::",
"... | Return query to find the child comments.
@param integer $baseId
@param array $config
@return \yii\db\ActiveQuery to query child comments. | [
"Return",
"query",
"to",
"find",
"the",
"child",
"comments",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelComment.php#L346-L352 |
39,224 | cmsgears/module-core | common/models/resources/ModelComment.php | ModelComment.queryL0Approved | public static function queryL0Approved( $parentId, $parentType, $type = ModelComment::TYPE_COMMENT, $config = [] ) {
return self::queryByType( $parentId, $parentType, $type, $config )->andWhere( [ 'baseId' => null ] );
} | php | public static function queryL0Approved( $parentId, $parentType, $type = ModelComment::TYPE_COMMENT, $config = [] ) {
return self::queryByType( $parentId, $parentType, $type, $config )->andWhere( [ 'baseId' => null ] );
} | [
"public",
"static",
"function",
"queryL0Approved",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"type",
"=",
"ModelComment",
"::",
"TYPE_COMMENT",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"queryByType",
"(",
"$",
"p... | Return query to find top level approved comments.
@param integer $parentId
@param string $parentType
@param string $type
@param array $config
@return \yii\db\ActiveQuery to query by email. | [
"Return",
"query",
"to",
"find",
"top",
"level",
"approved",
"comments",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelComment.php#L375-L378 |
39,225 | cmsgears/module-core | common/models/resources/ModelComment.php | ModelComment.findByUser | public static function findByUser( $parentId, $parentType, $userId, $type = ModelComment::TYPE_COMMENT ) {
return static::find()->where( 'parentId=:pid AND parentType=:ptype AND createdBy=:uid AND type=:type', [ ':pid' => $parentId, ':ptype' => $parentType, ':uid' => $userId, ':type' => $type ] )->one();
} | php | public static function findByUser( $parentId, $parentType, $userId, $type = ModelComment::TYPE_COMMENT ) {
return static::find()->where( 'parentId=:pid AND parentType=:ptype AND createdBy=:uid AND type=:type', [ ':pid' => $parentId, ':ptype' => $parentType, ':uid' => $userId, ':type' => $type ] )->one();
} | [
"public",
"static",
"function",
"findByUser",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"userId",
",",
"$",
"type",
"=",
"ModelComment",
"::",
"TYPE_COMMENT",
")",
"{",
"return",
"static",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'paren... | Find and return the comment for given user id.
@param integer $parentId
@param string $parentType
@param integer $userId
@param string $type
@return ModelComment | [
"Find",
"and",
"return",
"the",
"comment",
"for",
"given",
"user",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelComment.php#L391-L394 |
39,226 | cmsgears/module-core | common/models/resources/ModelComment.php | ModelComment.isExistByUser | public static function isExistByUser( $parentId, $parentType, $userId, $type = ModelComment::TYPE_COMMENT ) {
$comment = static::findByUser( $parentId, $parentType, $userId, $type );
return isset( $comment );
} | php | public static function isExistByUser( $parentId, $parentType, $userId, $type = ModelComment::TYPE_COMMENT ) {
$comment = static::findByUser( $parentId, $parentType, $userId, $type );
return isset( $comment );
} | [
"public",
"static",
"function",
"isExistByUser",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"userId",
",",
"$",
"type",
"=",
"ModelComment",
"::",
"TYPE_COMMENT",
")",
"{",
"$",
"comment",
"=",
"static",
"::",
"findByUser",
"(",
"$",
"parentId... | Check whether comment already exist for given user id.
@param integer $parentId
@param string $parentType
@param integer $userId
@param string $type
@return boolean | [
"Check",
"whether",
"comment",
"already",
"exist",
"for",
"given",
"user",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelComment.php#L405-L410 |
39,227 | cmsgears/module-core | common/services/base/MetaService.php | MetaService.create | public function create( $model, $config = [] ) {
if( empty( $model->label ) ) {
$model->label = $model->name;
}
if( !isset( $model->valueType ) ) {
$model->valueType = Meta::VALUE_TYPE_TEXT;
}
return parent::create( $model );
} | php | public function create( $model, $config = [] ) {
if( empty( $model->label ) ) {
$model->label = $model->name;
}
if( !isset( $model->valueType ) ) {
$model->valueType = Meta::VALUE_TYPE_TEXT;
}
return parent::create( $model );
} | [
"public",
"function",
"create",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"model",
"->",
"label",
")",
")",
"{",
"$",
"model",
"->",
"label",
"=",
"$",
"model",
"->",
"name",
";",
"}",
"if",
... | It generates the label if not set and create the meta.
@param \cmsgears\core\common\models\base\Meta $model
@param array $config
@return \cmsgears\core\common\models\base\Meta | [
"It",
"generates",
"the",
"label",
"if",
"not",
"set",
"and",
"create",
"the",
"meta",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/base/MetaService.php#L319-L332 |
39,228 | nails/module-email | email/controllers/Tracker.php | Tracker.track_open | public function track_open()
{
$oUri = Factory::service('Uri');
$oEmailer = Factory::service('Emailer', 'nails/module-email');
$sRef = $oUri->segment(3);
$sGuid = $oUri->segment(4);
$sHash = $oUri->segment(5);
// --------------------------------------------------------------------------
if (!$sRef || !$oEmailer->validateHash($sRef, $sGuid, $sHash)) {
show404();
}
// --------------------------------------------------------------------------
// Fetch the email
$oEmailer->trackOpen($sRef);
// --------------------------------------------------------------------------
/**
* Render out a tiny, tiny image
* Thanks http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
*/
header('Content-Type: image/gif');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
echo base64_decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
// --------------------------------------------------------------------------
/**
* Kill script, th, th, that's all folks. Stop the output class from hijacking
* our headers and setting an incorrect Content-Type
*/
exit(0);
} | php | public function track_open()
{
$oUri = Factory::service('Uri');
$oEmailer = Factory::service('Emailer', 'nails/module-email');
$sRef = $oUri->segment(3);
$sGuid = $oUri->segment(4);
$sHash = $oUri->segment(5);
// --------------------------------------------------------------------------
if (!$sRef || !$oEmailer->validateHash($sRef, $sGuid, $sHash)) {
show404();
}
// --------------------------------------------------------------------------
// Fetch the email
$oEmailer->trackOpen($sRef);
// --------------------------------------------------------------------------
/**
* Render out a tiny, tiny image
* Thanks http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
*/
header('Content-Type: image/gif');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
echo base64_decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
// --------------------------------------------------------------------------
/**
* Kill script, th, th, that's all folks. Stop the output class from hijacking
* our headers and setting an incorrect Content-Type
*/
exit(0);
} | [
"public",
"function",
"track_open",
"(",
")",
"{",
"$",
"oUri",
"=",
"Factory",
"::",
"service",
"(",
"'Uri'",
")",
";",
"$",
"oEmailer",
"=",
"Factory",
"::",
"service",
"(",
"'Emailer'",
",",
"'nails/module-email'",
")",
";",
"$",
"sRef",
"=",
"$",
"... | Track an email open. | [
"Track",
"an",
"email",
"open",
"."
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/email/controllers/Tracker.php#L21-L65 |
39,229 | nails/module-email | email/controllers/Tracker.php | Tracker.track_link | public function track_link()
{
$oUri = Factory::service('Uri');
$oEmailer = Factory::service('Emailer', 'nails/module-email');
$sRef = $oUri->segment(4);
$sGuid = $oUri->segment(5);
$sHash = $oUri->segment(6);
$iLinkId = (int) $oUri->segment(7) ?: null;
// --------------------------------------------------------------------------
if (!$sRef || !$oEmailer->validateHash($sRef, $sGuid, $sHash)) {
show404();
}
// --------------------------------------------------------------------------
$sUrl = $oEmailer->trackLink($sRef, $iLinkId);
if ($sUrl === false) {
show404();
}
redirect($sUrl);
} | php | public function track_link()
{
$oUri = Factory::service('Uri');
$oEmailer = Factory::service('Emailer', 'nails/module-email');
$sRef = $oUri->segment(4);
$sGuid = $oUri->segment(5);
$sHash = $oUri->segment(6);
$iLinkId = (int) $oUri->segment(7) ?: null;
// --------------------------------------------------------------------------
if (!$sRef || !$oEmailer->validateHash($sRef, $sGuid, $sHash)) {
show404();
}
// --------------------------------------------------------------------------
$sUrl = $oEmailer->trackLink($sRef, $iLinkId);
if ($sUrl === false) {
show404();
}
redirect($sUrl);
} | [
"public",
"function",
"track_link",
"(",
")",
"{",
"$",
"oUri",
"=",
"Factory",
"::",
"service",
"(",
"'Uri'",
")",
";",
"$",
"oEmailer",
"=",
"Factory",
"::",
"service",
"(",
"'Emailer'",
",",
"'nails/module-email'",
")",
";",
"$",
"sRef",
"=",
"$",
"... | Track a link click and forward through | [
"Track",
"a",
"link",
"click",
"and",
"forward",
"through"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/email/controllers/Tracker.php#L72-L96 |
39,230 | paulbunyannet/bandolier | src/Bandolier/Type/Collection.php | Collection.addItem | public function addItem($obj, $key = null)
{
if ($key == null) {
$this->items[] = $obj;
} else {
if (array_key_exists($key, $this->getItems())) {
throw new KeyHasUseException("Key $key already in use.");
} else {
$this->items[$key] = $obj;
}
}
return $this;
} | php | public function addItem($obj, $key = null)
{
if ($key == null) {
$this->items[] = $obj;
} else {
if (array_key_exists($key, $this->getItems())) {
throw new KeyHasUseException("Key $key already in use.");
} else {
$this->items[$key] = $obj;
}
}
return $this;
} | [
"public",
"function",
"addItem",
"(",
"$",
"obj",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"$",
"obj",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists"... | Add an item to the collection by key
@param $obj
@param null|string|int $key
@return $this
@throws KeyHasUseException | [
"Add",
"an",
"item",
"to",
"the",
"collection",
"by",
"key"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Collection.php#L45-L58 |
39,231 | paulbunyannet/bandolier | src/Bandolier/Type/Collection.php | Collection.setItem | public function setItem($obj, $key = null)
{
if (!$key) {
throw new KeyInvalidException("A key is required.");
} elseif (!is_string($key)) {
throw new KeyInvalidException("The key should be a string.");
} else {
if (!array_key_exists($key, $this->getItems())) {
throw new KeyInvalidException("Invalid key $key.");
}
$this->items[$key] = $obj;
}
return $this;
} | php | public function setItem($obj, $key = null)
{
if (!$key) {
throw new KeyInvalidException("A key is required.");
} elseif (!is_string($key)) {
throw new KeyInvalidException("The key should be a string.");
} else {
if (!array_key_exists($key, $this->getItems())) {
throw new KeyInvalidException("Invalid key $key.");
}
$this->items[$key] = $obj;
}
return $this;
} | [
"public",
"function",
"setItem",
"(",
"$",
"obj",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"key",
")",
"{",
"throw",
"new",
"KeyInvalidException",
"(",
"\"A key is required.\"",
")",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
... | Set a collection item by key
@param $obj
@param mixed $key
@return $this
@throws KeyInvalidException | [
"Set",
"a",
"collection",
"item",
"by",
"key"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Collection.php#L89-L103 |
39,232 | paulbunyannet/bandolier | src/Bandolier/Type/Collection.php | Collection.deleteItem | public function deleteItem($key)
{
if (isset($this->items[$key])) {
unset($this->items[$key]);
} else {
throw new KeyInvalidException("Invalid key $key.");
}
return $this;
} | php | public function deleteItem($key)
{
if (isset($this->items[$key])) {
unset($this->items[$key]);
} else {
throw new KeyInvalidException("Invalid key $key.");
}
return $this;
} | [
"public",
"function",
"deleteItem",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{... | Delete a collection key
@param $key
@return $this
@throws KeyInvalidException | [
"Delete",
"a",
"collection",
"key"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Collection.php#L111-L119 |
39,233 | paulbunyannet/bandolier | src/Bandolier/Type/Collection.php | Collection.getItem | public function getItem($key)
{
if (isset($this->items[$key])) {
return $this->items[$key];
} else {
throw new KeyInvalidException("Invalid key $key.");
}
} | php | public function getItem($key)
{
if (isset($this->items[$key])) {
return $this->items[$key];
} else {
throw new KeyInvalidException("Invalid key $key.");
}
} | [
"public",
"function",
"getItem",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"throw",
... | Get a collection item
@param $key
@return mixed
@throws KeyInvalidException | [
"Get",
"a",
"collection",
"item"
] | a98cb30bf63a18a7e3fc81418bf561ac36e9cd84 | https://github.com/paulbunyannet/bandolier/blob/a98cb30bf63a18a7e3fc81418bf561ac36e9cd84/src/Bandolier/Type/Collection.php#L127-L134 |
39,234 | cmsgears/module-core | common/utilities/ContentUtil.php | ContentUtil.initModel | public static function initModel( $view, $config = [] ) {
$model = isset( $view->params[ 'model' ] ) ? $view->params[ 'model' ] : self::findModel( $config );
if( isset( $model ) ) {
$coreProperties = CoreProperties::getInstance();
$seoData = $model->getDataMeta( CoreGlobal::DATA_SEO );
// Model
$view->params[ 'model' ] = $model;
$view->params[ 'seo' ] = $seoData;
// SEO H1 - Page Summary
$view->params[ 'summary' ] = isset( $seoData ) && !empty( $seoData->summary ) ? $seoData->summary : ( isset( $model->summary ) && !empty( $model->summary ) ? $model->summary : $model->description );
// SEO Meta Tags - Description, Keywords, Robot Text
$view->params[ 'desc' ] = isset( $seoData ) && !empty( $seoData->description ) ? $seoData->description : $model->description;
$view->params[ 'keywords' ] = isset( $seoData ) && !empty( $seoData->keywords ) ? $seoData->keywords : null;
$view->params[ 'robot' ] = isset( $seoData ) && !empty( $seoData->robot ) ? $seoData->robot : null;
// SEO - Page Title
$siteTitle = $coreProperties->getSiteTitle();
$seoName = isset( $seoData ) && !empty( $seoData->name ) ? $seoData->name : $model->name;
$view->title = "$seoName | $siteTitle";
}
} | php | public static function initModel( $view, $config = [] ) {
$model = isset( $view->params[ 'model' ] ) ? $view->params[ 'model' ] : self::findModel( $config );
if( isset( $model ) ) {
$coreProperties = CoreProperties::getInstance();
$seoData = $model->getDataMeta( CoreGlobal::DATA_SEO );
// Model
$view->params[ 'model' ] = $model;
$view->params[ 'seo' ] = $seoData;
// SEO H1 - Page Summary
$view->params[ 'summary' ] = isset( $seoData ) && !empty( $seoData->summary ) ? $seoData->summary : ( isset( $model->summary ) && !empty( $model->summary ) ? $model->summary : $model->description );
// SEO Meta Tags - Description, Keywords, Robot Text
$view->params[ 'desc' ] = isset( $seoData ) && !empty( $seoData->description ) ? $seoData->description : $model->description;
$view->params[ 'keywords' ] = isset( $seoData ) && !empty( $seoData->keywords ) ? $seoData->keywords : null;
$view->params[ 'robot' ] = isset( $seoData ) && !empty( $seoData->robot ) ? $seoData->robot : null;
// SEO - Page Title
$siteTitle = $coreProperties->getSiteTitle();
$seoName = isset( $seoData ) && !empty( $seoData->name ) ? $seoData->name : $model->name;
$view->title = "$seoName | $siteTitle";
}
} | [
"public",
"static",
"function",
"initModel",
"(",
"$",
"view",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"model",
"=",
"isset",
"(",
"$",
"view",
"->",
"params",
"[",
"'model'",
"]",
")",
"?",
"$",
"view",
"->",
"params",
"[",
"'model'",
... | Generates the meta data of Model using SEO Data.
@param \yii\web\View $view The current view being rendered by controller.
@param array $config
@return array having model meta data. | [
"Generates",
"the",
"meta",
"data",
"of",
"Model",
"using",
"SEO",
"Data",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/ContentUtil.php#L35-L62 |
39,235 | cmsgears/module-core | common/models/mappers/ModelFollower.php | ModelFollower.queryByTypeParentTypeModelId | public static function queryByTypeParentTypeModelId( $type, $parentType, $modelId ) {
return self::find()->where( 'type=:type AND parentType=:ptype AND modelId=:mid', [ ':type' => $type, ':parentType' => $parentType, ':mid' => $modelId ] );
} | php | public static function queryByTypeParentTypeModelId( $type, $parentType, $modelId ) {
return self::find()->where( 'type=:type AND parentType=:ptype AND modelId=:mid', [ ':type' => $type, ':parentType' => $parentType, ':mid' => $modelId ] );
} | [
"public",
"static",
"function",
"queryByTypeParentTypeModelId",
"(",
"$",
"type",
",",
"$",
"parentType",
",",
"$",
"modelId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'type=:type AND parentType=:ptype AND modelId=:mid'",
",",
"[",
... | Return query to find the mapping by type and follower id.
@param integer $type
@param string $parentType
@param integer $modelId
@return \yii\db\ActiveQuery to query by type and follower id. | [
"Return",
"query",
"to",
"find",
"the",
"mapping",
"by",
"type",
"and",
"follower",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/mappers/ModelFollower.php#L170-L173 |
39,236 | Innmind/AMQP | src/Model/Basic/Reject.php | Reject.requeue | public static function requeue(int $deliveryTag): self
{
$self = new self($deliveryTag);
$self->requeue = true;
return $self;
} | php | public static function requeue(int $deliveryTag): self
{
$self = new self($deliveryTag);
$self->requeue = true;
return $self;
} | [
"public",
"static",
"function",
"requeue",
"(",
"int",
"$",
"deliveryTag",
")",
":",
"self",
"{",
"$",
"self",
"=",
"new",
"self",
"(",
"$",
"deliveryTag",
")",
";",
"$",
"self",
"->",
"requeue",
"=",
"true",
";",
"return",
"$",
"self",
";",
"}"
] | This will requeue unacknowledged messages meaning they may be delivered
to a different consumer that the original one | [
"This",
"will",
"requeue",
"unacknowledged",
"messages",
"meaning",
"they",
"may",
"be",
"delivered",
"to",
"a",
"different",
"consumer",
"that",
"the",
"original",
"one"
] | c22b3a8f56162f7845a13c149cb3118e5fe7cffd | https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Basic/Reject.php#L20-L26 |
39,237 | cmsgears/module-core | common/models/traits/base/FeaturedTrait.php | FeaturedTrait.queryByFeatured | public static function queryByFeatured( $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
$limit = isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10;
$query = null;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
$query = static::find()->where( 'featured=:featured AND siteId=:siteId', [ ':featured' => true, ':siteId' => $siteId ] );
}
else {
$query = static::find()->where( 'featured=:featured', [ ':featured' => true ] );
}
$query->limit( $limit );
return $query;
} | php | public static function queryByFeatured( $config = [] ) {
$ignoreSite = isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
$limit = isset( $config[ 'limit' ] ) ? $config[ 'limit' ] : 10;
$query = null;
if( static::isMultiSite() && !$ignoreSite ) {
$siteId = isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;
$query = static::find()->where( 'featured=:featured AND siteId=:siteId', [ ':featured' => true, ':siteId' => $siteId ] );
}
else {
$query = static::find()->where( 'featured=:featured', [ ':featured' => true ] );
}
$query->limit( $limit );
return $query;
} | [
"public",
"static",
"function",
"queryByFeatured",
"(",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"ignoreSite",
"=",
"isset",
"(",
"$",
"config",
"[",
"'ignoreSite'",
"]",
")",
"?",
"$",
"config",
"[",
"'ignoreSite'",
"]",
":",
"false",
";",
"$",
... | Generate and return the query to filter featured models based on multi-site configuration.
@param array $config
@return \yii\db\ActiveQuery | [
"Generate",
"and",
"return",
"the",
"query",
"to",
"filter",
"featured",
"models",
"based",
"on",
"multi",
"-",
"site",
"configuration",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/traits/base/FeaturedTrait.php#L139-L159 |
39,238 | ec-europa/oe-robo | src/SettingsProcessor.php | SettingsProcessor.process | public function process($settings_file) {
$output[] = $this->getContent($settings_file);
$output[] = '';
$output[] = self::BLOCK_START;
$output[] = '';
foreach ($this->config->get(self::CONFIG_KEY) as $variable => $settings) {
foreach ($settings as $name => $value) {
$output[] = $this->getStatement($variable, $name, $value);
}
$output[] = '';
}
$output[] = self::BLOCK_END;
return implode($output, "\n");
} | php | public function process($settings_file) {
$output[] = $this->getContent($settings_file);
$output[] = '';
$output[] = self::BLOCK_START;
$output[] = '';
foreach ($this->config->get(self::CONFIG_KEY) as $variable => $settings) {
foreach ($settings as $name => $value) {
$output[] = $this->getStatement($variable, $name, $value);
}
$output[] = '';
}
$output[] = self::BLOCK_END;
return implode($output, "\n");
} | [
"public",
"function",
"process",
"(",
"$",
"settings_file",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"this",
"->",
"getContent",
"(",
"$",
"settings_file",
")",
";",
"$",
"output",
"[",
"]",
"=",
"''",
";",
"$",
"output",
"[",
"]",
"=",
"self",... | Process settings file.
@param string $settings_file
Full path to settings file to be processed, including its name.
@return string
Processed setting file. | [
"Process",
"settings",
"file",
"."
] | ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02 | https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/SettingsProcessor.php#L52-L67 |
39,239 | ec-europa/oe-robo | src/SettingsProcessor.php | SettingsProcessor.getContent | private function getContent($settings_file) {
$content = file_get_contents($settings_file);
$regex = "/^" . preg_quote(self::BLOCK_START, '/') . ".*?" . preg_quote(self::BLOCK_END, '/') . "/sm";
return preg_replace($regex, '', $content);
} | php | private function getContent($settings_file) {
$content = file_get_contents($settings_file);
$regex = "/^" . preg_quote(self::BLOCK_START, '/') . ".*?" . preg_quote(self::BLOCK_END, '/') . "/sm";
return preg_replace($regex, '', $content);
} | [
"private",
"function",
"getContent",
"(",
"$",
"settings_file",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"settings_file",
")",
";",
"$",
"regex",
"=",
"\"/^\"",
".",
"preg_quote",
"(",
"self",
"::",
"BLOCK_START",
",",
"'/'",
")",
".",... | Get settings file content.
@param string $settings_file
Full path to settings file to be processed, including its name.
@return string
File content without setting block. | [
"Get",
"settings",
"file",
"content",
"."
] | ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02 | https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/SettingsProcessor.php#L78-L82 |
39,240 | ec-europa/oe-robo | src/SettingsProcessor.php | SettingsProcessor.getStatement | private function getStatement($variable, $name, $value) {
$output = var_export($value, TRUE);
if (is_array($value)) {
$output = str_replace(' ', '', $output);
$output = str_replace("\n", "", $output);
$output = str_replace("=>", " => ", $output);
$output = str_replace(",)", ")", $output);
$output = str_replace("),", "), ", $output);
}
return sprintf('$%s["%s"] = %s;', $variable, $name, $output);
} | php | private function getStatement($variable, $name, $value) {
$output = var_export($value, TRUE);
if (is_array($value)) {
$output = str_replace(' ', '', $output);
$output = str_replace("\n", "", $output);
$output = str_replace("=>", " => ", $output);
$output = str_replace(",)", ")", $output);
$output = str_replace("),", "), ", $output);
}
return sprintf('$%s["%s"] = %s;', $variable, $name, $output);
} | [
"private",
"function",
"getStatement",
"(",
"$",
"variable",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"output",
"=",
"var_export",
"(",
"$",
"value",
",",
"TRUE",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
... | Get variable assignment statement.
@param string $variable
Variable name.
@param string $name
Setting name.
@param mixed $value
Setting value.
@return string
Full statement. | [
"Get",
"variable",
"assignment",
"statement",
"."
] | ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02 | https://github.com/ec-europa/oe-robo/blob/ad60ad28fcd4d5afdfee0c7cbeeb245f8bc0ea02/src/SettingsProcessor.php#L97-L107 |
39,241 | cmsgears/module-core | common/services/entities/UserService.php | UserService.create | public function create( $model, $config = [] ) {
$avatar = isset( $config[ 'avatar' ] ) ? $config[ 'avatar' ] : null;
$banner = isset( $config[ 'banner' ] ) ? $config[ 'banner' ] : null;
$video = isset( $config[ 'video' ] ) ? $config[ 'video' ] : null;
// Set Attributes
$model->registeredAt = DateUtil::getDateTime();
if( empty( $model->status ) ) {
$model->status = User::STATUS_NEW;
}
if( empty( $model->type ) ) {
$model->type = CoreGlobal::TYPE_DEFAULT;
}
if( empty( $model->slug ) ) {
$model->slug = $model->username;
}
// Generate Tokens
$model->generateVerifyToken();
$model->generateAuthKey();
$model->generateOtp();
// Save Files
$this->fileService->saveFiles( $model, [ 'avatarId' => $avatar, 'bannerId' => $banner, 'videoId' => $video ] );
return parent::create( $model, $config );
} | php | public function create( $model, $config = [] ) {
$avatar = isset( $config[ 'avatar' ] ) ? $config[ 'avatar' ] : null;
$banner = isset( $config[ 'banner' ] ) ? $config[ 'banner' ] : null;
$video = isset( $config[ 'video' ] ) ? $config[ 'video' ] : null;
// Set Attributes
$model->registeredAt = DateUtil::getDateTime();
if( empty( $model->status ) ) {
$model->status = User::STATUS_NEW;
}
if( empty( $model->type ) ) {
$model->type = CoreGlobal::TYPE_DEFAULT;
}
if( empty( $model->slug ) ) {
$model->slug = $model->username;
}
// Generate Tokens
$model->generateVerifyToken();
$model->generateAuthKey();
$model->generateOtp();
// Save Files
$this->fileService->saveFiles( $model, [ 'avatarId' => $avatar, 'bannerId' => $banner, 'videoId' => $video ] );
return parent::create( $model, $config );
} | [
"public",
"function",
"create",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"avatar",
"=",
"isset",
"(",
"$",
"config",
"[",
"'avatar'",
"]",
")",
"?",
"$",
"config",
"[",
"'avatar'",
"]",
":",
"null",
";",
"$",
"banner",... | Create the user and associate avatar, banner or video.
@param User $model
@param array $config
@return User | [
"Create",
"the",
"user",
"and",
"associate",
"avatar",
"banner",
"or",
"video",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L490-L523 |
39,242 | cmsgears/module-core | common/services/entities/UserService.php | UserService.register | public function register( $model, $config = [] ) {
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : User::STATUS_NEW;
$user = isset( $config[ 'user' ] ) ? $config[ 'user' ] : $this->getModelObject();
$date = DateUtil::getDateTime();
$user->email = $model->email;
$user->username = $model->username;
$user->title = $model->title;
$user->firstName = $model->firstName;
$user->middleName = $model->middleName;
$user->lastName = $model->lastName;
$user->mobile = $model->mobile;
$user->dob = $model->dob;
$user->registeredAt = $date;
$user->status = $status;
$user->type = $model->type;
$user->generatePassword( $model->password );
$user->generateVerifyToken();
$user->generateAuthKey();
$user->generateOtp();
$user->save();
return $user;
} | php | public function register( $model, $config = [] ) {
$status = isset( $config[ 'status' ] ) ? $config[ 'status' ] : User::STATUS_NEW;
$user = isset( $config[ 'user' ] ) ? $config[ 'user' ] : $this->getModelObject();
$date = DateUtil::getDateTime();
$user->email = $model->email;
$user->username = $model->username;
$user->title = $model->title;
$user->firstName = $model->firstName;
$user->middleName = $model->middleName;
$user->lastName = $model->lastName;
$user->mobile = $model->mobile;
$user->dob = $model->dob;
$user->registeredAt = $date;
$user->status = $status;
$user->type = $model->type;
$user->generatePassword( $model->password );
$user->generateVerifyToken();
$user->generateAuthKey();
$user->generateOtp();
$user->save();
return $user;
} | [
"public",
"function",
"register",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"status",
"=",
"isset",
"(",
"$",
"config",
"[",
"'status'",
"]",
")",
"?",
"$",
"config",
"[",
"'status'",
"]",
":",
"User",
"::",
"STATUS_NEW",... | Register User - It register the user and set status to new. It also generate verification token.
@param RegisterForm $model
@return User | [
"Register",
"User",
"-",
"It",
"register",
"the",
"user",
"and",
"set",
"status",
"to",
"new",
".",
"It",
"also",
"generate",
"verification",
"token",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L531-L558 |
39,243 | cmsgears/module-core | common/services/entities/UserService.php | UserService.verify | public function verify( $user, $token ) {
// Check Token
if( $user->isVerifyTokenValid( $token ) ) {
$modelClass = static::$modelClass;
// Find existing user
$userToUpdate = $modelClass::findById( $user->id );
// User need admin approval
if( Yii::$app->core->isUserApproval() ) {
$userToUpdate->verify();
}
// Direct approval and activation
else {
$userToUpdate->status = User::STATUS_ACTIVE;
}
$userToUpdate->unsetVerifyToken();
$userToUpdate->update();
return true;
}
return false;
} | php | public function verify( $user, $token ) {
// Check Token
if( $user->isVerifyTokenValid( $token ) ) {
$modelClass = static::$modelClass;
// Find existing user
$userToUpdate = $modelClass::findById( $user->id );
// User need admin approval
if( Yii::$app->core->isUserApproval() ) {
$userToUpdate->verify();
}
// Direct approval and activation
else {
$userToUpdate->status = User::STATUS_ACTIVE;
}
$userToUpdate->unsetVerifyToken();
$userToUpdate->update();
return true;
}
return false;
} | [
"public",
"function",
"verify",
"(",
"$",
"user",
",",
"$",
"token",
")",
"{",
"// Check Token",
"if",
"(",
"$",
"user",
"->",
"isVerifyTokenValid",
"(",
"$",
"token",
")",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"// F... | Confirm User - The method verify and confirm user by accepting valid token sent via mail. It also set user status to active.
@param User $user
@param string $token
@return boolean | [
"Confirm",
"User",
"-",
"The",
"method",
"verify",
"and",
"confirm",
"user",
"by",
"accepting",
"valid",
"token",
"sent",
"via",
"mail",
".",
"It",
"also",
"set",
"user",
"status",
"to",
"active",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L603-L632 |
39,244 | cmsgears/module-core | common/services/entities/UserService.php | UserService.forgotPassword | public function forgotPassword( $user ) {
$modelClass = static::$modelClass;
// Find existing user
$userToUpdate = $modelClass::findById( $user->id );
// Generate Token
$userToUpdate->generateResetToken();
$userToUpdate->generateOtp();
// Update User
$userToUpdate->update();
return $userToUpdate;
} | php | public function forgotPassword( $user ) {
$modelClass = static::$modelClass;
// Find existing user
$userToUpdate = $modelClass::findById( $user->id );
// Generate Token
$userToUpdate->generateResetToken();
$userToUpdate->generateOtp();
// Update User
$userToUpdate->update();
return $userToUpdate;
} | [
"public",
"function",
"forgotPassword",
"(",
"$",
"user",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"// Find existing user",
"$",
"userToUpdate",
"=",
"$",
"modelClass",
"::",
"findById",
"(",
"$",
"user",
"->",
"id",
")",
"... | The method generate a new reset token which can be used later to update user password.
@param User $user
@return User | [
"The",
"method",
"generate",
"a",
"new",
"reset",
"token",
"which",
"can",
"be",
"used",
"later",
"to",
"update",
"user",
"password",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L682-L697 |
39,245 | cmsgears/module-core | common/services/entities/UserService.php | UserService.resetPassword | public function resetPassword( $user, $resetForm ) {
$modelClass = static::$modelClass;
// Find existing user
$userToUpdate = $modelClass::findById( $user->id );
// Generate Password
$userToUpdate->generatePassword( $resetForm->password );
$userToUpdate->unsetResetToken();
// User need admin approval
if( Yii::$app->core->isUserApproval() ) {
$userToUpdate->verify();
}
// Direct approval and activation
else {
$userToUpdate->status = User::STATUS_ACTIVE;
}
// Update User
$userToUpdate->update();
return $userToUpdate;
} | php | public function resetPassword( $user, $resetForm ) {
$modelClass = static::$modelClass;
// Find existing user
$userToUpdate = $modelClass::findById( $user->id );
// Generate Password
$userToUpdate->generatePassword( $resetForm->password );
$userToUpdate->unsetResetToken();
// User need admin approval
if( Yii::$app->core->isUserApproval() ) {
$userToUpdate->verify();
}
// Direct approval and activation
else {
$userToUpdate->status = User::STATUS_ACTIVE;
}
// Update User
$userToUpdate->update();
return $userToUpdate;
} | [
"public",
"function",
"resetPassword",
"(",
"$",
"user",
",",
"$",
"resetForm",
")",
"{",
"$",
"modelClass",
"=",
"static",
"::",
"$",
"modelClass",
";",
"// Find existing user",
"$",
"userToUpdate",
"=",
"$",
"modelClass",
"::",
"findById",
"(",
"$",
"user"... | The method generate a new secure password for the given password and unset the reset token. It also activate user.
@param User $user
@param ResetPasswordForm $resetForm
@param boolean $activate
@return User | [
"The",
"method",
"generate",
"a",
"new",
"secure",
"password",
"for",
"the",
"given",
"password",
"and",
"unset",
"the",
"reset",
"token",
".",
"It",
"also",
"activate",
"user",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L706-L732 |
39,246 | cmsgears/module-core | common/services/entities/UserService.php | UserService.delete | public function delete( $model, $config = [] ) {
// Delete Files
$this->fileService->deleteMultiple( [ $model->avatar, $model->banner, $model->video ] );
// Delete Notifications
Yii::$app->eventManager->deleteNotificationsByUserId( $model->id );
// Delete model
return parent::delete( $model, $config );
} | php | public function delete( $model, $config = [] ) {
// Delete Files
$this->fileService->deleteMultiple( [ $model->avatar, $model->banner, $model->video ] );
// Delete Notifications
Yii::$app->eventManager->deleteNotificationsByUserId( $model->id );
// Delete model
return parent::delete( $model, $config );
} | [
"public",
"function",
"delete",
"(",
"$",
"model",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"// Delete Files",
"$",
"this",
"->",
"fileService",
"->",
"deleteMultiple",
"(",
"[",
"$",
"model",
"->",
"avatar",
",",
"$",
"model",
"->",
"banner",
",",... | The project must extend this class to delete project specific resources associated
with the user.
@param \cmsgears\core\common\models\entities\User $model
@param array $config
@return boolean | [
"The",
"project",
"must",
"extend",
"this",
"class",
"to",
"delete",
"project",
"specific",
"resources",
"associated",
"with",
"the",
"user",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/services/entities/UserService.php#L758-L768 |
39,247 | mcaskill/charcoal-support | src/View/Mustache/DateTimeHelpers.php | DateTimeHelpers.parseDateTime | private function parseDateTime($time)
{
if (is_string($time)) {
try {
$time = new DateTimeImmutable($time);
} catch (Exception $e) {
throw new InvalidArgumentException(sprintf(
'Invalid date/time value: %s',
$e->getMessage()
), $e->getCode(), $e);
}
}
if ($time instanceof DateTime) {
try {
$time = DateTimeImmutable::createFromMutable($time);
} catch (Exception $e) {
throw new InvalidArgumentException(sprintf(
'Invalid date/time value: %s',
$e->getMessage()
), $e->getCode(), $e);
}
}
if ($time instanceof DateTimeImmutable) {
$time = $time->setTimezone(static::$now->getTimezone());
} else {
throw new InvalidArgumentException('Invalid date/time for the presenter.');
}
return $time;
} | php | private function parseDateTime($time)
{
if (is_string($time)) {
try {
$time = new DateTimeImmutable($time);
} catch (Exception $e) {
throw new InvalidArgumentException(sprintf(
'Invalid date/time value: %s',
$e->getMessage()
), $e->getCode(), $e);
}
}
if ($time instanceof DateTime) {
try {
$time = DateTimeImmutable::createFromMutable($time);
} catch (Exception $e) {
throw new InvalidArgumentException(sprintf(
'Invalid date/time value: %s',
$e->getMessage()
), $e->getCode(), $e);
}
}
if ($time instanceof DateTimeImmutable) {
$time = $time->setTimezone(static::$now->getTimezone());
} else {
throw new InvalidArgumentException('Invalid date/time for the presenter.');
}
return $time;
} | [
"private",
"function",
"parseDateTime",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"time",
")",
")",
"{",
"try",
"{",
"$",
"time",
"=",
"new",
"DateTimeImmutable",
"(",
"$",
"time",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
... | Parse the given date and time into a DateTime object.
@param DateTimeInterface|string $time A date/time string or a DateTime object.
@throws InvalidArgumentException If the date/time value is invalid.
@return DateTimeImmutable | [
"Parse",
"the",
"given",
"date",
"and",
"time",
"into",
"a",
"DateTime",
"object",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/View/Mustache/DateTimeHelpers.php#L111-L142 |
39,248 | mcaskill/charcoal-support | src/View/Mustache/DateTimeHelpers.php | DateTimeHelpers.offsetSet | public function offsetSet($key, $value)
{
if (!is_string($key)) {
throw new InvalidArgumentException('The name of the macro must be a string.');
}
if (!is_callable($value)) {
throw new InvalidArgumentException('The macro must be a callable value.');
}
$this->macros[$key] = $value;
} | php | public function offsetSet($key, $value)
{
if (!is_string($key)) {
throw new InvalidArgumentException('The name of the macro must be a string.');
}
if (!is_callable($value)) {
throw new InvalidArgumentException('The macro must be a callable value.');
}
$this->macros[$key] = $value;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The name of the macro must be a string.'",
")",
";",
"}",
"if",
... | Set the macro at a given offset.
@param mixed $key The name of the macro.
@param mixed $value The macro's effect.
@throws InvalidArgumentException If the $key or $value are invalid.
@return void | [
"Set",
"the",
"macro",
"at",
"a",
"given",
"offset",
"."
] | 2138a34463ca6865bf3a60635aa11381a9ae73c5 | https://github.com/mcaskill/charcoal-support/blob/2138a34463ca6865bf3a60635aa11381a9ae73c5/src/View/Mustache/DateTimeHelpers.php#L433-L444 |
39,249 | spiral/exceptions | src/AbstractHandler.php | AbstractHandler.getStacktrace | protected function getStacktrace(\Throwable $e): array
{
$stacktrace = $e->getTrace();
if (empty($stacktrace)) {
return [];
}
//Let's let's clarify exception location
$header = [
'file' => $e->getFile(),
'line' => $e->getLine()
] + $stacktrace[0];
if ($stacktrace[0] != $header) {
array_unshift($stacktrace, $header);
}
return $stacktrace;
} | php | protected function getStacktrace(\Throwable $e): array
{
$stacktrace = $e->getTrace();
if (empty($stacktrace)) {
return [];
}
//Let's let's clarify exception location
$header = [
'file' => $e->getFile(),
'line' => $e->getLine()
] + $stacktrace[0];
if ($stacktrace[0] != $header) {
array_unshift($stacktrace, $header);
}
return $stacktrace;
} | [
"protected",
"function",
"getStacktrace",
"(",
"\\",
"Throwable",
"$",
"e",
")",
":",
"array",
"{",
"$",
"stacktrace",
"=",
"$",
"e",
"->",
"getTrace",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"stacktrace",
")",
")",
"{",
"return",
"[",
"]",
";... | Normalized exception stacktrace.
@param \Throwable $e
@return array | [
"Normalized",
"exception",
"stacktrace",
"."
] | 9735a00b189ce61317cd49a9d6ec630f68cee381 | https://github.com/spiral/exceptions/blob/9735a00b189ce61317cd49a9d6ec630f68cee381/src/AbstractHandler.php#L31-L49 |
39,250 | nails/module-email | admin/controllers/Email.php | Email.resend | public function resend()
{
if (!userHasPermission('admin:email:email:resend')) {
unauthorised();
}
// --------------------------------------------------------------------------
$oEmailer = Factory::service('Emailer', 'nails/module-email');
// --------------------------------------------------------------------------
$oUri = Factory::service('Uri');
$iEmailId = $oUri->segment(5);
$sReturn = $this->input->get('return') ? $this->input->get('return') : 'admin/email/index';
if ($oEmailer->resend($iEmailId)) {
$sStatus = 'success';
$sMessage = 'Message was resent successfully.';
} else {
$sStatus = 'error';
$sMessage = 'Message failed to resend. ' . $oEmailer->lastError();
}
$oSession = Factory::service('Session', 'nails/module-auth');
$oSession->setFlashData($sStatus, $sMessage);
redirect($sReturn);
} | php | public function resend()
{
if (!userHasPermission('admin:email:email:resend')) {
unauthorised();
}
// --------------------------------------------------------------------------
$oEmailer = Factory::service('Emailer', 'nails/module-email');
// --------------------------------------------------------------------------
$oUri = Factory::service('Uri');
$iEmailId = $oUri->segment(5);
$sReturn = $this->input->get('return') ? $this->input->get('return') : 'admin/email/index';
if ($oEmailer->resend($iEmailId)) {
$sStatus = 'success';
$sMessage = 'Message was resent successfully.';
} else {
$sStatus = 'error';
$sMessage = 'Message failed to resend. ' . $oEmailer->lastError();
}
$oSession = Factory::service('Session', 'nails/module-auth');
$oSession->setFlashData($sStatus, $sMessage);
redirect($sReturn);
} | [
"public",
"function",
"resend",
"(",
")",
"{",
"if",
"(",
"!",
"userHasPermission",
"(",
"'admin:email:email:resend'",
")",
")",
"{",
"unauthorised",
"(",
")",
";",
"}",
"// --------------------------------------------------------------------------",
"$",
"oEmailer",
"=... | Resent an email
@return void | [
"Resent",
"an",
"email"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/admin/controllers/Email.php#L154-L181 |
39,251 | ethical-jobs/ethical-jobs-foundation-php | src/Utils/ApiResources.php | ApiResources.getTransformerFromResource | public static function getTransformerFromResource($resource)
{
if (! in_array($resource, static::getResources())) {
return '';
}
$resourceName = studly_case(str_singular($resource));
return 'App\Transformers\\'.$resourceName.'s\\'.$resourceName.'Transformer';
} | php | public static function getTransformerFromResource($resource)
{
if (! in_array($resource, static::getResources())) {
return '';
}
$resourceName = studly_case(str_singular($resource));
return 'App\Transformers\\'.$resourceName.'s\\'.$resourceName.'Transformer';
} | [
"public",
"static",
"function",
"getTransformerFromResource",
"(",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"resource",
",",
"static",
"::",
"getResources",
"(",
")",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"resourceName",
"... | Returns transformer class from a REST resource identifier
@param String $resource
@return String | [
"Returns",
"transformer",
"class",
"from",
"a",
"REST",
"resource",
"identifier"
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Utils/ApiResources.php#L53-L62 |
39,252 | rodrigoiii/skeleton-core | src/classes/BaseCommand.php | BaseCommand.configure | protected function configure()
{
$this->setName($this->name);
$this->setDescription($this->description);
foreach ($this->arguments as $argument) {
$this->getDefinition()->addArgument($argument);
}
foreach ($this->options as $option) {
$this->getDefinition()->addOption($option);
}
} | php | protected function configure()
{
$this->setName($this->name);
$this->setDescription($this->description);
foreach ($this->arguments as $argument) {
$this->getDefinition()->addArgument($argument);
}
foreach ($this->options as $option) {
$this->getDefinition()->addOption($option);
}
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"this",
"->",
"setName",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"this",
"->",
"setDescription",
"(",
"$",
"this",
"->",
"description",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"arg... | Set the name and description
@return void | [
"Set",
"the",
"name",
"and",
"description"
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/BaseCommand.php#L68-L80 |
39,253 | locomotivemtl/charcoal-property | src/Charcoal/Property/ImageProperty.php | ImageProperty.imageFactory | public function imageFactory()
{
if ($this->imageFactory === null) {
$this->imageFactory = $this->createImageFactory();
}
return $this->imageFactory;
} | php | public function imageFactory()
{
if ($this->imageFactory === null) {
$this->imageFactory = $this->createImageFactory();
}
return $this->imageFactory;
} | [
"public",
"function",
"imageFactory",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageFactory",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"imageFactory",
"=",
"$",
"this",
"->",
"createImageFactory",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->"... | Retrieve the image factory.
@return ImageFactory | [
"Retrieve",
"the",
"image",
"factory",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L74-L81 |
39,254 | locomotivemtl/charcoal-property | src/Charcoal/Property/ImageProperty.php | ImageProperty.setDriverType | public function setDriverType($type)
{
if (!is_string($type)) {
throw new InvalidArgumentException(sprintf(
'Image driver type must be a string, received %s',
(is_object($type) ? get_class($type) : gettype($type))
));
}
$this->driverType = $type;
return $this;
} | php | public function setDriverType($type)
{
if (!is_string($type)) {
throw new InvalidArgumentException(sprintf(
'Image driver type must be a string, received %s',
(is_object($type) ? get_class($type) : gettype($type))
));
}
$this->driverType = $type;
return $this;
} | [
"public",
"function",
"setDriverType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Image driver type must be a string, received %s'",
",",
"(",
"is_o... | Set the name of the property's image processing driver.
@param string $type The processing engine.
@throws InvalidArgumentException If the drive type is not a string.
@return ImageProperty Chainable | [
"Set",
"the",
"name",
"of",
"the",
"property",
"s",
"image",
"processing",
"driver",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L92-L104 |
39,255 | locomotivemtl/charcoal-property | src/Charcoal/Property/ImageProperty.php | ImageProperty.setApplyEffects | public function setApplyEffects($event)
{
if ($event === false) {
$this->applyEffects = self::EFFECTS_EVENT_NEVER;
return $this;
}
if ($event === null || $event === '') {
$this->applyEffects = self::EFFECTS_EVENT_SAVE;
return $this;
}
if (!in_array($event, $this->acceptedEffectsEvents())) {
if (!is_string($event)) {
$event = (is_object($event) ? get_class($event) : gettype($event));
}
throw new OutOfBoundsException(sprintf(
'Unsupported image property event "%s" provided',
$event
));
}
$this->applyEffects = $event;
return $this;
} | php | public function setApplyEffects($event)
{
if ($event === false) {
$this->applyEffects = self::EFFECTS_EVENT_NEVER;
return $this;
}
if ($event === null || $event === '') {
$this->applyEffects = self::EFFECTS_EVENT_SAVE;
return $this;
}
if (!in_array($event, $this->acceptedEffectsEvents())) {
if (!is_string($event)) {
$event = (is_object($event) ? get_class($event) : gettype($event));
}
throw new OutOfBoundsException(sprintf(
'Unsupported image property event "%s" provided',
$event
));
}
$this->applyEffects = $event;
return $this;
} | [
"public",
"function",
"setApplyEffects",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"applyEffects",
"=",
"self",
"::",
"EFFECTS_EVENT_NEVER",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
... | Set whether effects should be applied.
@param mixed $event When to apply affects.
@throws OutOfBoundsException If the effects event does not exist.
@return ImageProperty Chainable | [
"Set",
"whether",
"effects",
"should",
"be",
"applied",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L123-L148 |
39,256 | locomotivemtl/charcoal-property | src/Charcoal/Property/ImageProperty.php | ImageProperty.applyEffects | public function applyEffects($event = null)
{
if ($event !== null) {
if (!in_array($event, $this->acceptedEffectsEvents())) {
if (!is_string($event)) {
$event = (is_object($event) ? get_class($event) : gettype($event));
}
throw new OutOfBoundsException(sprintf(
'Unsupported image property event "%s" provided',
$event
));
}
return $this->applyEffects === $event;
}
return $this->applyEffects;
} | php | public function applyEffects($event = null)
{
if ($event !== null) {
if (!in_array($event, $this->acceptedEffectsEvents())) {
if (!is_string($event)) {
$event = (is_object($event) ? get_class($event) : gettype($event));
}
throw new OutOfBoundsException(sprintf(
'Unsupported image property event "%s" provided',
$event
));
}
return $this->applyEffects === $event;
}
return $this->applyEffects;
} | [
"public",
"function",
"applyEffects",
"(",
"$",
"event",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"event",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"event",
",",
"$",
"this",
"->",
"acceptedEffectsEvents",
"(",
")",
")",
")",
"{... | Determine if effects should be applied.
@param string|boolean $event A specific event to check or a global flag to set.
@throws OutOfBoundsException If the effects event does not exist.
@return mixed If an $event is provided, returns TRUE or FALSE if the property applies
effects for the given event. Otherwise, returns the property's condition on effects. | [
"Determine",
"if",
"effects",
"should",
"be",
"applied",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/ImageProperty.php#L158-L175 |
39,257 | rodrigoiii/skeleton-core | src/classes/Console/Commands/MakeModelCommand.php | MakeModelCommand.makeTemplate | private function makeTemplate($sub_directories, $pre_model_path, $model, $no_get_id)
{
$file = __DIR__ . "/../templates/model/";
$file .= $no_get_id ? "model.php.dist" : "model-with-get-id.php.dist";
if (file_exists($file))
{
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{sub_directories}}' => $sub_directories,
'{{model}}' => $model
]);
$file_path = "{$pre_model_path}/{$model}.php";
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
}
return false;
} | php | private function makeTemplate($sub_directories, $pre_model_path, $model, $no_get_id)
{
$file = __DIR__ . "/../templates/model/";
$file .= $no_get_id ? "model.php.dist" : "model-with-get-id.php.dist";
if (file_exists($file))
{
$template = strtr(file_get_contents($file), [
'{{namespace}}' => get_app_namespace(),
'{{sub_directories}}' => $sub_directories,
'{{model}}' => $model
]);
$file_path = "{$pre_model_path}/{$model}.php";
$file = fopen($file_path, "w");
fwrite($file, $template);
fclose($file);
return file_exists($file_path);
}
return false;
} | [
"private",
"function",
"makeTemplate",
"(",
"$",
"sub_directories",
",",
"$",
"pre_model_path",
",",
"$",
"model",
",",
"$",
"no_get_id",
")",
"{",
"$",
"file",
"=",
"__DIR__",
".",
"\"/../templates/model/\"",
";",
"$",
"file",
".=",
"$",
"no_get_id",
"?",
... | Create the model template
@depends handle
@param string $sub_directories
@param string $pre_model_path
@param string $model
@param boolean $no_get_id
@return boolean | [
"Create",
"the",
"model",
"template"
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeModelCommand.php#L85-L108 |
39,258 | apioo/psx-http | src/MediaType.php | MediaType.match | public function match(MediaType $mediaType)
{
return ($this->type == '*' && $this->subType == '*') ||
($this->type == $mediaType->getType() && $this->subType == $mediaType->getSubType()) ||
($this->type == $mediaType->getType() && $this->subType == '*');
} | php | public function match(MediaType $mediaType)
{
return ($this->type == '*' && $this->subType == '*') ||
($this->type == $mediaType->getType() && $this->subType == $mediaType->getSubType()) ||
($this->type == $mediaType->getType() && $this->subType == '*');
} | [
"public",
"function",
"match",
"(",
"MediaType",
"$",
"mediaType",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"type",
"==",
"'*'",
"&&",
"$",
"this",
"->",
"subType",
"==",
"'*'",
")",
"||",
"(",
"$",
"this",
"->",
"type",
"==",
"$",
"mediaType",
... | Checks whether the given media type would match
@param \PSX\Http\MediaType $mediaType
@return boolean | [
"Checks",
"whether",
"the",
"given",
"media",
"type",
"would",
"match"
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/MediaType.php#L121-L126 |
39,259 | phPoirot/Std | src/Struct/CollectionObject.php | CollectionObject.del | function del($hashOrObject)
{
$hash = $this->_attainHash($hashOrObject);
if (!array_key_exists($hash, $this->_objs))
return false;
unset($this->_objs[$hash]);
return true;
} | php | function del($hashOrObject)
{
$hash = $this->_attainHash($hashOrObject);
if (!array_key_exists($hash, $this->_objs))
return false;
unset($this->_objs[$hash]);
return true;
} | [
"function",
"del",
"(",
"$",
"hashOrObject",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"_attainHash",
"(",
"$",
"hashOrObject",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"hash",
",",
"$",
"this",
"->",
"_objs",
")",
")",
"return",
... | Detach By ETag Hash Or Object Match
@param string|object $hashOrObject
@return boolean Return true on detach match otherwise false | [
"Detach",
"By",
"ETag",
"Hash",
"Or",
"Object",
"Match"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L123-L131 |
39,260 | phPoirot/Std | src/Struct/CollectionObject.php | CollectionObject.getData | function getData($object)
{
if (! $this->has($object) )
throw new \Exception('Object Not Found.');
$hash = $this->genETag($object);
return $this->_objs[$hash]['data'];
} | php | function getData($object)
{
if (! $this->has($object) )
throw new \Exception('Object Not Found.');
$hash = $this->genETag($object);
return $this->_objs[$hash]['data'];
} | [
"function",
"getData",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"object",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Object Not Found.'",
")",
";",
"$",
"hash",
"=",
"$",
"this",
"->",
"genETag",
"(... | Get Tag Data Of Specific Object
note: use ETag to attain target object for
performance
@param $object
@throws \Exception Object not stored
@return array | [
"Get",
"Tag",
"Data",
"Of",
"Specific",
"Object"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L209-L217 |
39,261 | phPoirot/Std | src/Struct/CollectionObject.php | CollectionObject.setData | function setData($object, array $data)
{
if (! $this->has($object) )
throw new \Exception('Object Not Found.');
if ($data == array_values($data))
throw new \InvalidArgumentException('Data tags must be associative array.');
$hash = $this->genETag($object);
$this->_objs[$hash]['data'] = $data;
return $this;
} | php | function setData($object, array $data)
{
if (! $this->has($object) )
throw new \Exception('Object Not Found.');
if ($data == array_values($data))
throw new \InvalidArgumentException('Data tags must be associative array.');
$hash = $this->genETag($object);
$this->_objs[$hash]['data'] = $data;
return $this;
} | [
"function",
"setData",
"(",
"$",
"object",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"object",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Object Not Found.'",
")",
";",
"if",
"(",
"$",
"data",... | Set Data For Stored Object
note: use ETag to attain target object for
performance
@param object $object
@param array $data Associative Array
@throws \Exception Object not stored
@return $this | [
"Set",
"Data",
"For",
"Stored",
"Object"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L231-L243 |
39,262 | phPoirot/Std | src/Struct/CollectionObject.php | CollectionObject.genETag | function genETag($object)
{
$this->doValidateObject($object);
$hash = md5(\Poirot\Std\flatten($object));
return $hash;
} | php | function genETag($object)
{
$this->doValidateObject($object);
$hash = md5(\Poirot\Std\flatten($object));
return $hash;
} | [
"function",
"genETag",
"(",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"doValidateObject",
"(",
"$",
"object",
")",
";",
"$",
"hash",
"=",
"md5",
"(",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"flatten",
"(",
"$",
"object",
")",
")",
";",
"return",
"$",
... | Calculate a unique identifier for the contained objects
@param object $object
@return string | [
"Calculate",
"a",
"unique",
"identifier",
"for",
"the",
"contained",
"objects"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Struct/CollectionObject.php#L252-L258 |
39,263 | phPoirot/Std | src/fixes/Mixin.php | Mixin.bindTo | function bindTo($class)
{
if (!is_object($class))
throw new \Exception(sprintf(
'Given class must be an object (%s) given.'
, \Poirot\Std\flatten($class)
));
$this->_t__bindTo = $class;
return $this;
} | php | function bindTo($class)
{
if (!is_object($class))
throw new \Exception(sprintf(
'Given class must be an object (%s) given.'
, \Poirot\Std\flatten($class)
));
$this->_t__bindTo = $class;
return $this;
} | [
"function",
"bindTo",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"class",
")",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'Given class must be an object (%s) given.'",
",",
"\\",
"Poirot",
"\\",
"Std",
"\\",
"fla... | Bind Current Methods to Given Object
@param $class
@throws \Exception
@return $this | [
"Bind",
"Current",
"Methods",
"to",
"Given",
"Object"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/fixes/Mixin.php#L61-L72 |
39,264 | phPoirot/Std | src/fixes/Mixin.php | Mixin.hasMethod | function hasMethod($methodName)
{
if (isset($this->_t__methods[$methodName]))
return true;
# check bind object
$return = false;
$bind = $this->getBindTo();
if (!$bind instanceof self) {
$return = method_exists($bind, $methodName);
}
return $return;
} | php | function hasMethod($methodName)
{
if (isset($this->_t__methods[$methodName]))
return true;
# check bind object
$return = false;
$bind = $this->getBindTo();
if (!$bind instanceof self) {
$return = method_exists($bind, $methodName);
}
return $return;
} | [
"function",
"hasMethod",
"(",
"$",
"methodName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_t__methods",
"[",
"$",
"methodName",
"]",
")",
")",
"return",
"true",
";",
"# check bind object",
"$",
"return",
"=",
"false",
";",
"$",
"bind",
"=... | Has Method Name Exists?
@param string $methodName
@return bool | [
"Has",
"Method",
"Name",
"Exists?"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/fixes/Mixin.php#L109-L123 |
39,265 | nails/module-email | email/controllers/View.php | View.index | public function index()
{
$oUri = Factory::service('Uri');
$oEmailer = Factory::service('Emailer', 'nails/module-email');
$sRef = $oUri->segment(3);
$sGuid = $oUri->segment(4);
$sHash = $oUri->segment(5);
// --------------------------------------------------------------------------
// Fetch the email
if (is_numeric($sRef)) {
$oEmail = $oEmailer->getById($sRef);
} else {
$oEmail = $oEmailer->getByRef($sRef);
}
if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) {
show404();
}
if (Environment::is(Environment::ENV_DEV)) {
$oAsset = Factory::service('Asset');
$oAsset->load('debugger.min.css', 'nails/module-email');
Factory::service('View')
->setData([
'oEmail' => $oEmail,
])
->load([
'structure/header/blank',
'email/view',
'structure/footer/blank',
]);
} else {
$oOutput = Factory::service('Output');
$oOutput->set_output($oEmail->body->html);
}
} | php | public function index()
{
$oUri = Factory::service('Uri');
$oEmailer = Factory::service('Emailer', 'nails/module-email');
$sRef = $oUri->segment(3);
$sGuid = $oUri->segment(4);
$sHash = $oUri->segment(5);
// --------------------------------------------------------------------------
// Fetch the email
if (is_numeric($sRef)) {
$oEmail = $oEmailer->getById($sRef);
} else {
$oEmail = $oEmailer->getByRef($sRef);
}
if (!$oEmail || !$oEmailer->validateHash($oEmail->ref, $sGuid, $sHash)) {
show404();
}
if (Environment::is(Environment::ENV_DEV)) {
$oAsset = Factory::service('Asset');
$oAsset->load('debugger.min.css', 'nails/module-email');
Factory::service('View')
->setData([
'oEmail' => $oEmail,
])
->load([
'structure/header/blank',
'email/view',
'structure/footer/blank',
]);
} else {
$oOutput = Factory::service('Output');
$oOutput->set_output($oEmail->body->html);
}
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"oUri",
"=",
"Factory",
"::",
"service",
"(",
"'Uri'",
")",
";",
"$",
"oEmailer",
"=",
"Factory",
"::",
"service",
"(",
"'Emailer'",
",",
"'nails/module-email'",
")",
";",
"$",
"sRef",
"=",
"$",
"oUri"... | Handle view online requests | [
"Handle",
"view",
"online",
"requests"
] | 42183b33a0465ab302f66a7b4f881410275eb6a4 | https://github.com/nails/module-email/blob/42183b33a0465ab302f66a7b4f881410275eb6a4/email/controllers/View.php#L22-L62 |
39,266 | locomotivemtl/charcoal-property | src/Charcoal/Property/StorablePropertyTrait.php | StorablePropertyTrait.fields | public function fields($val)
{
if (empty($this->fields)) {
$this->generateFields($val);
} else {
$this->updatedFields($val);
}
return $this->fields;
} | php | public function fields($val)
{
if (empty($this->fields)) {
$this->generateFields($val);
} else {
$this->updatedFields($val);
}
return $this->fields;
} | [
"public",
"function",
"fields",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fields",
")",
")",
"{",
"$",
"this",
"->",
"generateFields",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"updatedFields",
... | Retrieve the property's storage fields.
@param mixed $val The value to set as field value.
@return PropertyField[] | [
"Retrieve",
"the",
"property",
"s",
"storage",
"fields",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L69-L78 |
39,267 | locomotivemtl/charcoal-property | src/Charcoal/Property/StorablePropertyTrait.php | StorablePropertyTrait.fieldNames | public function fieldNames()
{
$fields = [];
if ($this->l10n()) {
foreach ($this->translator()->availableLocales() as $langCode) {
$fields[$langCode] = $this->l10nIdent($langCode);
}
} else {
$fields[] = $this->ident();
}
return $fields;
} | php | public function fieldNames()
{
$fields = [];
if ($this->l10n()) {
foreach ($this->translator()->availableLocales() as $langCode) {
$fields[$langCode] = $this->l10nIdent($langCode);
}
} else {
$fields[] = $this->ident();
}
return $fields;
} | [
"public",
"function",
"fieldNames",
"(",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"l10n",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"availableLocales",
"(",
")",
"as",
"... | Retrieve the property's storage field names.
@return string[] | [
"Retrieve",
"the",
"property",
"s",
"storage",
"field",
"names",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L85-L97 |
39,268 | locomotivemtl/charcoal-property | src/Charcoal/Property/StorablePropertyTrait.php | StorablePropertyTrait.storageVal | public function storageVal($val)
{
if ($val === null) {
// Do not json_encode NULL values
return null;
}
if (!$this->l10n() && $val instanceof Translation) {
$val = (string)$val;
}
if ($this->multiple()) {
if (is_array($val)) {
$val = implode($this->multipleSeparator(), $val);
}
}
if (!is_scalar($val)) {
return json_encode($val, JSON_UNESCAPED_UNICODE);
}
return $val;
} | php | public function storageVal($val)
{
if ($val === null) {
// Do not json_encode NULL values
return null;
}
if (!$this->l10n() && $val instanceof Translation) {
$val = (string)$val;
}
if ($this->multiple()) {
if (is_array($val)) {
$val = implode($this->multipleSeparator(), $val);
}
}
if (!is_scalar($val)) {
return json_encode($val, JSON_UNESCAPED_UNICODE);
}
return $val;
} | [
"public",
"function",
"storageVal",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"===",
"null",
")",
"{",
"// Do not json_encode NULL values",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"l10n",
"(",
")",
"&&",
"$",
"val",
"in... | Retrieve the property's value in a format suitable for storage.
@param mixed $val The value to convert for storage.
@return mixed | [
"Retrieve",
"the",
"property",
"s",
"value",
"in",
"a",
"format",
"suitable",
"for",
"storage",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L105-L127 |
39,269 | locomotivemtl/charcoal-property | src/Charcoal/Property/StorablePropertyTrait.php | StorablePropertyTrait.updatedFields | private function updatedFields($val)
{
if (empty($this->fields)) {
return $this->generateFields($val);
}
if ($this->l10n()) {
foreach ($this->translator()->availableLocales() as $langCode) {
$this->fields[$langCode]->setVal($this->fieldVal($langCode, $val));
}
} else {
$this->fields[0]->setVal($this->storageVal($val));
}
return $this->fields;
} | php | private function updatedFields($val)
{
if (empty($this->fields)) {
return $this->generateFields($val);
}
if ($this->l10n()) {
foreach ($this->translator()->availableLocales() as $langCode) {
$this->fields[$langCode]->setVal($this->fieldVal($langCode, $val));
}
} else {
$this->fields[0]->setVal($this->storageVal($val));
}
return $this->fields;
} | [
"private",
"function",
"updatedFields",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fields",
")",
")",
"{",
"return",
"$",
"this",
"->",
"generateFields",
"(",
"$",
"val",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"... | Update the property's storage fields.
@param mixed $val The value to set as field value.
@return PropertyField[] | [
"Update",
"the",
"property",
"s",
"storage",
"fields",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L206-L221 |
39,270 | locomotivemtl/charcoal-property | src/Charcoal/Property/StorablePropertyTrait.php | StorablePropertyTrait.generateFields | private function generateFields($val)
{
$this->fields = [];
if ($this->l10n()) {
foreach ($this->translator()->availableLocales() as $langCode) {
$ident = $this->l10nIdent($langCode);
$field = $this->createPropertyField([
'ident' => $ident,
'sqlType' => $this->sqlType(),
'sqlPdoType' => $this->sqlPdoType(),
'sqlEncoding' => $this->sqlEncoding(),
'extra' => $this->sqlExtra(),
'val' => $this->fieldVal($langCode, $val),
'defaultVal' => null,
'allowNull' => $this->allowNull()
]);
$this->fields[$langCode] = $field;
}
} else {
$field = $this->createPropertyField([
'ident' => $this->ident(),
'sqlType' => $this->sqlType(),
'sqlPdoType' => $this->sqlPdoType(),
'sqlEncoding' => $this->sqlEncoding(),
'extra' => $this->sqlExtra(),
'val' => $this->storageVal($val),
'defaultVal' => null,
'allowNull' => $this->allowNull()
]);
$this->fields[] = $field;
}
return $this->fields;
} | php | private function generateFields($val)
{
$this->fields = [];
if ($this->l10n()) {
foreach ($this->translator()->availableLocales() as $langCode) {
$ident = $this->l10nIdent($langCode);
$field = $this->createPropertyField([
'ident' => $ident,
'sqlType' => $this->sqlType(),
'sqlPdoType' => $this->sqlPdoType(),
'sqlEncoding' => $this->sqlEncoding(),
'extra' => $this->sqlExtra(),
'val' => $this->fieldVal($langCode, $val),
'defaultVal' => null,
'allowNull' => $this->allowNull()
]);
$this->fields[$langCode] = $field;
}
} else {
$field = $this->createPropertyField([
'ident' => $this->ident(),
'sqlType' => $this->sqlType(),
'sqlPdoType' => $this->sqlPdoType(),
'sqlEncoding' => $this->sqlEncoding(),
'extra' => $this->sqlExtra(),
'val' => $this->storageVal($val),
'defaultVal' => null,
'allowNull' => $this->allowNull()
]);
$this->fields[] = $field;
}
return $this->fields;
} | [
"private",
"function",
"generateFields",
"(",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"fields",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"l10n",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"avail... | Reset the property's storage fields.
@param mixed $val The value to set as field value.
@return PropertyField[] | [
"Reset",
"the",
"property",
"s",
"storage",
"fields",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L229-L262 |
39,271 | locomotivemtl/charcoal-property | src/Charcoal/Property/StorablePropertyTrait.php | StorablePropertyTrait.fieldVal | private function fieldVal($fieldIdent, $val)
{
if ($val === null) {
return null;
}
if (is_scalar($val)) {
return $this->storageVal($val);
}
if (isset($val[$fieldIdent])) {
return $this->storageVal($val[$fieldIdent]);
} else {
return null;
}
} | php | private function fieldVal($fieldIdent, $val)
{
if ($val === null) {
return null;
}
if (is_scalar($val)) {
return $this->storageVal($val);
}
if (isset($val[$fieldIdent])) {
return $this->storageVal($val[$fieldIdent]);
} else {
return null;
}
} | [
"private",
"function",
"fieldVal",
"(",
"$",
"fieldIdent",
",",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_scalar",
"(",
"$",
"val",
")",
")",
"{",
"return",
"$",
"this",
"->",... | Retrieve the value of the property's given storage field.
@param string $fieldIdent The property field identifier.
@param mixed $val The value to set as field value.
@return mixed | [
"Retrieve",
"the",
"value",
"of",
"the",
"property",
"s",
"given",
"storage",
"field",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/StorablePropertyTrait.php#L271-L286 |
39,272 | apioo/psx-http | src/Server/RequestFactory.php | RequestFactory.getRequestMethod | protected function getRequestMethod()
{
if (isset($this->server['REQUEST_METHOD'])) {
// check for X-HTTP-Method-Override
if (isset($this->server['HTTP_X_HTTP_METHOD_OVERRIDE']) && in_array($this->server['HTTP_X_HTTP_METHOD_OVERRIDE'], ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'])) {
return $this->server['HTTP_X_HTTP_METHOD_OVERRIDE'];
} else {
return $this->server['REQUEST_METHOD'];
}
} else {
return 'GET';
}
} | php | protected function getRequestMethod()
{
if (isset($this->server['REQUEST_METHOD'])) {
// check for X-HTTP-Method-Override
if (isset($this->server['HTTP_X_HTTP_METHOD_OVERRIDE']) && in_array($this->server['HTTP_X_HTTP_METHOD_OVERRIDE'], ['OPTIONS', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH'])) {
return $this->server['HTTP_X_HTTP_METHOD_OVERRIDE'];
} else {
return $this->server['REQUEST_METHOD'];
}
} else {
return 'GET';
}
} | [
"protected",
"function",
"getRequestMethod",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
"'REQUEST_METHOD'",
"]",
")",
")",
"{",
"// check for X-HTTP-Method-Override",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"server",
"[",
... | Tries to detect the current request method. It considers the
X-HTTP-METHOD-OVERRIDE header.
@return string | [
"Tries",
"to",
"detect",
"the",
"current",
"request",
"method",
".",
"It",
"considers",
"the",
"X",
"-",
"HTTP",
"-",
"METHOD",
"-",
"OVERRIDE",
"header",
"."
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Server/RequestFactory.php#L136-L148 |
39,273 | apioo/psx-http | src/Server/RequestFactory.php | RequestFactory.getRequestHeaders | protected function getRequestHeaders()
{
$contentKeys = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true);
$headers = array();
foreach ($this->server as $key => $value) {
if (strpos($key, 'HTTP_') === 0) {
$headers[str_replace('_', '-', substr($key, 5))] = $value;
} elseif (isset($contentKeys[$key])) {
$headers[str_replace('_', '-', $key)] = $value;
}
}
if (!isset($headers['AUTHORIZATION'])) {
if (isset($this->server['REDIRECT_HTTP_AUTHORIZATION'])) {
$headers['AUTHORIZATION'] = $this->server['REDIRECT_HTTP_AUTHORIZATION'];
} elseif (isset($this->server['PHP_AUTH_USER'])) {
$headers['AUTHORIZATION'] = 'Basic ' . base64_encode($this->server['PHP_AUTH_USER'] . ':' . (isset($this->server['PHP_AUTH_PW']) ? $this->server['PHP_AUTH_PW'] : ''));
} elseif (isset($this->server['PHP_AUTH_DIGEST'])) {
$headers['AUTHORIZATION'] = $this->server['PHP_AUTH_DIGEST'];
}
}
return $headers;
} | php | protected function getRequestHeaders()
{
$contentKeys = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true);
$headers = array();
foreach ($this->server as $key => $value) {
if (strpos($key, 'HTTP_') === 0) {
$headers[str_replace('_', '-', substr($key, 5))] = $value;
} elseif (isset($contentKeys[$key])) {
$headers[str_replace('_', '-', $key)] = $value;
}
}
if (!isset($headers['AUTHORIZATION'])) {
if (isset($this->server['REDIRECT_HTTP_AUTHORIZATION'])) {
$headers['AUTHORIZATION'] = $this->server['REDIRECT_HTTP_AUTHORIZATION'];
} elseif (isset($this->server['PHP_AUTH_USER'])) {
$headers['AUTHORIZATION'] = 'Basic ' . base64_encode($this->server['PHP_AUTH_USER'] . ':' . (isset($this->server['PHP_AUTH_PW']) ? $this->server['PHP_AUTH_PW'] : ''));
} elseif (isset($this->server['PHP_AUTH_DIGEST'])) {
$headers['AUTHORIZATION'] = $this->server['PHP_AUTH_DIGEST'];
}
}
return $headers;
} | [
"protected",
"function",
"getRequestHeaders",
"(",
")",
"{",
"$",
"contentKeys",
"=",
"array",
"(",
"'CONTENT_LENGTH'",
"=>",
"true",
",",
"'CONTENT_MD5'",
"=>",
"true",
",",
"'CONTENT_TYPE'",
"=>",
"true",
")",
";",
"$",
"headers",
"=",
"array",
"(",
")",
... | Returns all request headers
@return array | [
"Returns",
"all",
"request",
"headers"
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Server/RequestFactory.php#L155-L179 |
39,274 | cmsgears/module-core | common/utilities/DateUtil.php | DateUtil.lessThan | public static function lessThan( $sourceDate, $targetDate, $equal = false ) {
$source = is_string( $sourceDate ) ? strtotime( $sourceDate ) : $sourceDate->getTimestamp();
$test = is_string( $targetDate ) ? strtotime( $targetDate ) : $targetDate->getTimestamp();
// Test less than
if( $equal ) {
return $test <= $source;
}
return $test < $source;
} | php | public static function lessThan( $sourceDate, $targetDate, $equal = false ) {
$source = is_string( $sourceDate ) ? strtotime( $sourceDate ) : $sourceDate->getTimestamp();
$test = is_string( $targetDate ) ? strtotime( $targetDate ) : $targetDate->getTimestamp();
// Test less than
if( $equal ) {
return $test <= $source;
}
return $test < $source;
} | [
"public",
"static",
"function",
"lessThan",
"(",
"$",
"sourceDate",
",",
"$",
"targetDate",
",",
"$",
"equal",
"=",
"false",
")",
"{",
"$",
"source",
"=",
"is_string",
"(",
"$",
"sourceDate",
")",
"?",
"strtotime",
"(",
"$",
"sourceDate",
")",
":",
"$"... | Compare the target date with source date to check whether target date is lesser than or equal to source date.
@param type $sourceDate
@param type $targetDate
@param type $equal
@return boolean | [
"Compare",
"the",
"target",
"date",
"with",
"source",
"date",
"to",
"check",
"whether",
"target",
"date",
"is",
"lesser",
"than",
"or",
"equal",
"to",
"source",
"date",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/DateUtil.php#L330-L342 |
39,275 | cmsgears/module-core | common/utilities/DateUtil.php | DateUtil.inBetween | public static function inBetween( $startDate, $endDate, $date ) {
$start = is_string( $startDate ) ? strtotime( $startDate ) : $startDate->getTimestamp();
$end = is_string( $endDate ) ? strtotime( $endDate ) : $endDate->getTimestamp();
$test = is_string( $date ) ? strtotime( $date ) : $date->getTimestamp();
// Test in between start and end
return ( ( $test >= $start ) && ( $test <= $end ) );
} | php | public static function inBetween( $startDate, $endDate, $date ) {
$start = is_string( $startDate ) ? strtotime( $startDate ) : $startDate->getTimestamp();
$end = is_string( $endDate ) ? strtotime( $endDate ) : $endDate->getTimestamp();
$test = is_string( $date ) ? strtotime( $date ) : $date->getTimestamp();
// Test in between start and end
return ( ( $test >= $start ) && ( $test <= $end ) );
} | [
"public",
"static",
"function",
"inBetween",
"(",
"$",
"startDate",
",",
"$",
"endDate",
",",
"$",
"date",
")",
"{",
"$",
"start",
"=",
"is_string",
"(",
"$",
"startDate",
")",
"?",
"strtotime",
"(",
"$",
"startDate",
")",
":",
"$",
"startDate",
"->",
... | Compare the given date and check whether it's between the start date and end date.
@param type $startDate
@param type $endDate
@param type $date
@return type | [
"Compare",
"the",
"given",
"date",
"and",
"check",
"whether",
"it",
"s",
"between",
"the",
"start",
"date",
"and",
"end",
"date",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/utilities/DateUtil.php#L352-L360 |
39,276 | tamago-db/LinkedinImporterBundle | Importer/Importer.php | Importer.resetState | public function resetState($value = null)
{
if (!$value) {
$value = md5(mt_rand(1, 1000000)
. 'IAMTHEVERYMODELOFAMODERNMAJORGENERAL' //some salt
. __CLASS__
. mt_rand(1, 1000000)
);
}
$value = (string) $value;
$session = $this->_session;
//$session->invalidate(); // @todo why were we invalidating the session?
$session->set('linkedin_state', $value);
return $this;
} | php | public function resetState($value = null)
{
if (!$value) {
$value = md5(mt_rand(1, 1000000)
. 'IAMTHEVERYMODELOFAMODERNMAJORGENERAL' //some salt
. __CLASS__
. mt_rand(1, 1000000)
);
}
$value = (string) $value;
$session = $this->_session;
//$session->invalidate(); // @todo why were we invalidating the session?
$session->set('linkedin_state', $value);
return $this;
} | [
"public",
"function",
"resetState",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"md5",
"(",
"mt_rand",
"(",
"1",
",",
"1000000",
")",
".",
"'IAMTHEVERYMODELOFAMODERNMAJORGENERAL'",
"//some salt",
"... | Reinitializes the value of linkedin_state in the session
@param string $value
@return \CCC\LinkedinImporterBundle\Importer\Importer | [
"Reinitializes",
"the",
"value",
"of",
"linkedin_state",
"in",
"the",
"session"
] | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L49-L65 |
39,277 | tamago-db/LinkedinImporterBundle | Importer/Importer.php | Importer.getAuthenticationUrl | public function getAuthenticationUrl($type = 'private')
{
if (!$this->getRedirect()) {
throw new \Exception('please set a redirect url for your permissions request');
}
$config = $this->getConfig();
if (!isset($config['dataset'][$type])) {
// @todo Is this configurable?
throw new \Exception('unknown action. please check your apiconfig.yml file for the available types');
}
$params = array();
$params['response_type'] = 'code';
$params['client_id'] = $config['api_key'];
$params['redirect_uri'] = $this->getRedirect();
$params['scope'] = $config['dataset'][$type]['scope'];
$params['state'] = $this->resetState()->getState();
$url = $config['urls']['auth'] . '?' . http_build_query($params);
return $url;
} | php | public function getAuthenticationUrl($type = 'private')
{
if (!$this->getRedirect()) {
throw new \Exception('please set a redirect url for your permissions request');
}
$config = $this->getConfig();
if (!isset($config['dataset'][$type])) {
// @todo Is this configurable?
throw new \Exception('unknown action. please check your apiconfig.yml file for the available types');
}
$params = array();
$params['response_type'] = 'code';
$params['client_id'] = $config['api_key'];
$params['redirect_uri'] = $this->getRedirect();
$params['scope'] = $config['dataset'][$type]['scope'];
$params['state'] = $this->resetState()->getState();
$url = $config['urls']['auth'] . '?' . http_build_query($params);
return $url;
} | [
"public",
"function",
"getAuthenticationUrl",
"(",
"$",
"type",
"=",
"'private'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getRedirect",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'please set a redirect url for your permissions request'",
... | Return the url of the LinkedIn authentication page | [
"Return",
"the",
"url",
"of",
"the",
"LinkedIn",
"authentication",
"page"
] | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L120-L142 |
39,278 | tamago-db/LinkedinImporterBundle | Importer/Importer.php | Importer.setPublicProfileUrl | public function setPublicProfileUrl($url)
{
// Avoids errors like: "[invalid.param.url]. Public profile URL is not correct, {url=xyz should be
// {https://www.linkedin.com/pub/[member-name/]x/y/z}. LinkedIn won't validate it's own public urls that
// have a language / country code appended
$matches = array();
preg_match('"^https?://((www|\w\w)\.)?linkedin.com/((in/[^/]+/?)|(pub/[^/]+/((\w|\d)+/?){3}))"', $url, $matches);
if (count($matches)) {
$url = current($matches);
}
$url = rtrim($url, '/');
//according to their manual and forums, all linkedin public urls should begin with 'https://www.linkedin.com'
//(they said they'd always support it even if it did ever change, which is highly unlikely)
//so just chop it off and force it to be that
$url = preg_replace('/^(.*)linkedin.com\//i', 'https://www.linkedin.com/', $url);
$this->_public_profile_url = $url;
return $this;
} | php | public function setPublicProfileUrl($url)
{
// Avoids errors like: "[invalid.param.url]. Public profile URL is not correct, {url=xyz should be
// {https://www.linkedin.com/pub/[member-name/]x/y/z}. LinkedIn won't validate it's own public urls that
// have a language / country code appended
$matches = array();
preg_match('"^https?://((www|\w\w)\.)?linkedin.com/((in/[^/]+/?)|(pub/[^/]+/((\w|\d)+/?){3}))"', $url, $matches);
if (count($matches)) {
$url = current($matches);
}
$url = rtrim($url, '/');
//according to their manual and forums, all linkedin public urls should begin with 'https://www.linkedin.com'
//(they said they'd always support it even if it did ever change, which is highly unlikely)
//so just chop it off and force it to be that
$url = preg_replace('/^(.*)linkedin.com\//i', 'https://www.linkedin.com/', $url);
$this->_public_profile_url = $url;
return $this;
} | [
"public",
"function",
"setPublicProfileUrl",
"(",
"$",
"url",
")",
"{",
"// Avoids errors like: \"[invalid.param.url]. Public profile URL is not correct, {url=xyz should be",
"// {https://www.linkedin.com/pub/[member-name/]x/y/z}. LinkedIn won't validate it's own public urls that",
"// have a l... | Sets a sanity-checked public profile url
@param string $url
@return \CCC\LinkedinImporterBundle\Importer\Importer | [
"Sets",
"a",
"sanity",
"-",
"checked",
"public",
"profile",
"url"
] | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L158-L178 |
39,279 | tamago-db/LinkedinImporterBundle | Importer/Importer.php | Importer.requestAccessToken | public function requestAccessToken()
{
$config = $this->getConfig();
$token_url = $config['urls']['token'];
$params = array();
$params['client_id'] = $config['api_key'];
$params['redirect_uri'] = $this->getRedirect();
$params['code'] = $this->getCode();
$params['grant_type'] = 'authorization_code';
$params['client_secret'] = $config['secret_key'];
//get access token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $token_url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); // @todo why post a get query?
$response = curl_exec($ch);
if (!$response) {
throw new \Exception('no response from linkedin');
}
$response = json_decode($response);
if (!isset($response->access_token) || !$response->access_token) {
throw new \Exception('no access token received from linkedin');
}
$this->setAccessToken($response->access_token);
return (string) $response->access_token;
} | php | public function requestAccessToken()
{
$config = $this->getConfig();
$token_url = $config['urls']['token'];
$params = array();
$params['client_id'] = $config['api_key'];
$params['redirect_uri'] = $this->getRedirect();
$params['code'] = $this->getCode();
$params['grant_type'] = 'authorization_code';
$params['client_secret'] = $config['secret_key'];
//get access token
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $token_url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); // @todo why post a get query?
$response = curl_exec($ch);
if (!$response) {
throw new \Exception('no response from linkedin');
}
$response = json_decode($response);
if (!isset($response->access_token) || !$response->access_token) {
throw new \Exception('no access token received from linkedin');
}
$this->setAccessToken($response->access_token);
return (string) $response->access_token;
} | [
"public",
"function",
"requestAccessToken",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"token_url",
"=",
"$",
"config",
"[",
"'urls'",
"]",
"[",
"'token'",
"]",
";",
"$",
"params",
"=",
"array",
"(",
")",
... | Gets access token from linkedin
@throws \Exception
@return string | [
"Gets",
"access",
"token",
"from",
"linkedin"
] | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L223-L258 |
39,280 | tamago-db/LinkedinImporterBundle | Importer/Importer.php | Importer.requestUserData | public function requestUserData($type = 'private', $access_token = null)
{
$config = $this->getConfig();
$access_token = ($access_token) ? $access_token : $this->getAccessToken();
$url = null;
switch ($type) {
case 'public':
//error if no profile set
if (!$this->getPublicProfileUrl()) {
throw new \Exception('please set the public profile you want to pull');
}
$url = $config['urls']['public']
. urlencode(urldecode($this->getPublicProfileUrl())) // make sure the url is encoded; avoid double encoding
. $config['dataset'][$type]['fields'];
break;
case 'private':
case 'login':
default:
$url = $config['urls']['private']
. $config['dataset'][$type]['fields'];
break;
}
//add access token to request url
$url .= '?' . http_build_query(array('oauth2_access_token' => $access_token, 'secure-urls' => 'true'));
//send it
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: en-US, ja"));
$response = curl_exec($ch);
$data = simplexml_load_string($response);
return $data;
} | php | public function requestUserData($type = 'private', $access_token = null)
{
$config = $this->getConfig();
$access_token = ($access_token) ? $access_token : $this->getAccessToken();
$url = null;
switch ($type) {
case 'public':
//error if no profile set
if (!$this->getPublicProfileUrl()) {
throw new \Exception('please set the public profile you want to pull');
}
$url = $config['urls']['public']
. urlencode(urldecode($this->getPublicProfileUrl())) // make sure the url is encoded; avoid double encoding
. $config['dataset'][$type]['fields'];
break;
case 'private':
case 'login':
default:
$url = $config['urls']['private']
. $config['dataset'][$type]['fields'];
break;
}
//add access token to request url
$url .= '?' . http_build_query(array('oauth2_access_token' => $access_token, 'secure-urls' => 'true'));
//send it
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // don't worry about bad ssl certs
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: en-US, ja"));
$response = curl_exec($ch);
$data = simplexml_load_string($response);
return $data;
} | [
"public",
"function",
"requestUserData",
"(",
"$",
"type",
"=",
"'private'",
",",
"$",
"access_token",
"=",
"null",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
";",
"$",
"access_token",
"=",
"(",
"$",
"access_token",
")",
"?... | Gets user data from linkedin.
@param string $type
@param string $access_token
@throws \Exception
@return \SimpleXMLElement | [
"Gets",
"user",
"data",
"from",
"linkedin",
"."
] | bf510a675311c181995b17744e1420fc4fbb2e60 | https://github.com/tamago-db/LinkedinImporterBundle/blob/bf510a675311c181995b17744e1420fc4fbb2e60/Importer/Importer.php#L269-L309 |
39,281 | apioo/psx-http | src/Request.php | Request.toString | public function toString()
{
$request = Parser\RequestParser::buildStatusLine($this) . Http::NEW_LINE;
$headers = Parser\RequestParser::buildHeaderFromMessage($this);
foreach ($headers as $header) {
$request.= $header . Http::NEW_LINE;
}
$request.= Http::NEW_LINE;
$request.= (string) $this->getBody();
return $request;
} | php | public function toString()
{
$request = Parser\RequestParser::buildStatusLine($this) . Http::NEW_LINE;
$headers = Parser\RequestParser::buildHeaderFromMessage($this);
foreach ($headers as $header) {
$request.= $header . Http::NEW_LINE;
}
$request.= Http::NEW_LINE;
$request.= (string) $this->getBody();
return $request;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"request",
"=",
"Parser",
"\\",
"RequestParser",
"::",
"buildStatusLine",
"(",
"$",
"this",
")",
".",
"Http",
"::",
"NEW_LINE",
";",
"$",
"headers",
"=",
"Parser",
"\\",
"RequestParser",
"::",
"buildHea... | Converts the request object to an http request string
@return string | [
"Converts",
"the",
"request",
"object",
"to",
"an",
"http",
"request",
"string"
] | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Request.php#L147-L160 |
39,282 | cmsgears/module-core | common/models/resources/ModelMessage.php | ModelMessage.findByNameTypeLocaleId | public static function findByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) {
return self::find()->where( 'parentId=:pid AND parentType=:ptype AND name=:name AND type=:type AND localeId=:lid' )
->addParams( [ ':pid' => $parentId, ':ptype' => $parentType, ':name' => $name, ':type' => $type, ':lid' => $localeId ] )
->one();
} | php | public static function findByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) {
return self::find()->where( 'parentId=:pid AND parentType=:ptype AND name=:name AND type=:type AND localeId=:lid' )
->addParams( [ ':pid' => $parentId, ':ptype' => $parentType, ':name' => $name, ':type' => $type, ':lid' => $localeId ] )
->one();
} | [
"public",
"static",
"function",
"findByNameTypeLocaleId",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"name",
",",
"$",
"type",
",",
"$",
"localeId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'parentId=:pid AND pa... | Find and return the message specific to given name, type and locale id.
@param integer $parentId
@param string $parentType
@param string $name
@param string $type
@param int $localeId
@return ModelMessage by name, type and locale id | [
"Find",
"and",
"return",
"the",
"message",
"specific",
"to",
"given",
"name",
"type",
"and",
"locale",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelMessage.php#L203-L208 |
39,283 | cmsgears/module-core | common/models/resources/ModelMessage.php | ModelMessage.isExistByNameTypeLocaleId | public static function isExistByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) {
$message = self::findByNameLocaleId( $parentId, $parentType, $name, $type, $localeId );
return isset( $message );
} | php | public static function isExistByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) {
$message = self::findByNameLocaleId( $parentId, $parentType, $name, $type, $localeId );
return isset( $message );
} | [
"public",
"static",
"function",
"isExistByNameTypeLocaleId",
"(",
"$",
"parentId",
",",
"$",
"parentType",
",",
"$",
"name",
",",
"$",
"type",
",",
"$",
"localeId",
")",
"{",
"$",
"message",
"=",
"self",
"::",
"findByNameLocaleId",
"(",
"$",
"parentId",
",... | Check whether the message exists for given name, type and locale id.
@param integer $parentId
@param string $parentType
@param string $name
@param int $localeId
@return boolean | [
"Check",
"whether",
"the",
"message",
"exists",
"for",
"given",
"name",
"type",
"and",
"locale",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/ModelMessage.php#L219-L224 |
39,284 | Innmind/AMQP | src/Model/Basic/Qos.php | Qos.global | public static function global(int $prefetchSize, int $prefetchCount): self
{
$self = new self($prefetchSize, $prefetchCount);
$self->global = true;
return $self;
} | php | public static function global(int $prefetchSize, int $prefetchCount): self
{
$self = new self($prefetchSize, $prefetchCount);
$self->global = true;
return $self;
} | [
"public",
"static",
"function",
"global",
"(",
"int",
"$",
"prefetchSize",
",",
"int",
"$",
"prefetchCount",
")",
":",
"self",
"{",
"$",
"self",
"=",
"new",
"self",
"(",
"$",
"prefetchSize",
",",
"$",
"prefetchCount",
")",
";",
"$",
"self",
"->",
"glob... | Will apply the definition for the whole connection | [
"Will",
"apply",
"the",
"definition",
"for",
"the",
"whole",
"connection"
] | c22b3a8f56162f7845a13c149cb3118e5fe7cffd | https://github.com/Innmind/AMQP/blob/c22b3a8f56162f7845a13c149cb3118e5fe7cffd/src/Model/Basic/Qos.php#L33-L39 |
39,285 | cmsgears/module-core | common/base/MessageSource.php | MessageSource.getMessage | public function getMessage( $key, $params = [], $language = null ) {
// Retrieve Message
$message = $this->messageDb[ $key ];
// Return formatted message
return $this->formatter->format( $message, $params, $language );
} | php | public function getMessage( $key, $params = [], $language = null ) {
// Retrieve Message
$message = $this->messageDb[ $key ];
// Return formatted message
return $this->formatter->format( $message, $params, $language );
} | [
"public",
"function",
"getMessage",
"(",
"$",
"key",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"language",
"=",
"null",
")",
"{",
"// Retrieve Message",
"$",
"message",
"=",
"$",
"this",
"->",
"messageDb",
"[",
"$",
"key",
"]",
";",
"// Return forma... | Find the message corresponding to given message key and returns the formatted
message using the message parameters and language.
@param string $key
@param array $params
@param string $language
@return string | [
"Find",
"the",
"message",
"corresponding",
"to",
"given",
"message",
"key",
"and",
"returns",
"the",
"formatted",
"message",
"using",
"the",
"message",
"parameters",
"and",
"language",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/base/MessageSource.php#L63-L70 |
39,286 | apioo/psx-http | src/Stream/Util.php | Util.toString | public static function toString(StreamInterface $stream)
{
if (!$stream->isReadable()) {
return '';
}
if ($stream->isSeekable()) {
$pos = $stream->tell();
$content = $stream->__toString();
$stream->seek($pos);
} else {
$content = $stream->__toString();
}
return $content;
} | php | public static function toString(StreamInterface $stream)
{
if (!$stream->isReadable()) {
return '';
}
if ($stream->isSeekable()) {
$pos = $stream->tell();
$content = $stream->__toString();
$stream->seek($pos);
} else {
$content = $stream->__toString();
}
return $content;
} | [
"public",
"static",
"function",
"toString",
"(",
"StreamInterface",
"$",
"stream",
")",
"{",
"if",
"(",
"!",
"$",
"stream",
"->",
"isReadable",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"stream",
"->",
"isSeekable",
"(",
")",
")",... | Converts an stream into an string and returns the result. The position of
the pointer will not change if the stream is seekable. Note this copies
the complete content of the stream into the memory
@param \Psr\Http\Message\StreamInterface $stream
@return string | [
"Converts",
"an",
"stream",
"into",
"an",
"string",
"and",
"returns",
"the",
"result",
".",
"The",
"position",
"of",
"the",
"pointer",
"will",
"not",
"change",
"if",
"the",
"stream",
"is",
"seekable",
".",
"Note",
"this",
"copies",
"the",
"complete",
"cont... | c54d7212cfb513df84f810429aa34c6ac9942c01 | https://github.com/apioo/psx-http/blob/c54d7212cfb513df84f810429aa34c6ac9942c01/src/Stream/Util.php#L42-L58 |
39,287 | locomotivemtl/charcoal-property | src/Charcoal/Property/DescribablePropertyTrait.php | DescribablePropertyTrait.hasProperty | public function hasProperty($propertyIdent)
{
if (!is_string($propertyIdent)) {
throw new InvalidArgumentException(
'Property identifier must be a string.'
);
}
$metadata = $this->metadata();
$properties = $metadata->properties();
return isset($properties[$propertyIdent]);
} | php | public function hasProperty($propertyIdent)
{
if (!is_string($propertyIdent)) {
throw new InvalidArgumentException(
'Property identifier must be a string.'
);
}
$metadata = $this->metadata();
$properties = $metadata->properties();
return isset($properties[$propertyIdent]);
} | [
"public",
"function",
"hasProperty",
"(",
"$",
"propertyIdent",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"propertyIdent",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Property identifier must be a string.'",
")",
";",
"}",
"$",
"meta... | Determine if the model has the given property.
@param string $propertyIdent The property identifier to lookup.
@throws InvalidArgumentException If the property identifier is not a string.
@return boolean | [
"Determine",
"if",
"the",
"model",
"has",
"the",
"given",
"property",
"."
] | 5ff339a0edb78a909537a9d2bb7f9b783255316b | https://github.com/locomotivemtl/charcoal-property/blob/5ff339a0edb78a909537a9d2bb7f9b783255316b/src/Charcoal/Property/DescribablePropertyTrait.php#L103-L115 |
39,288 | 975L/IncludeLibraryBundle | Twig/IncludeLibraryContent.php | IncludeLibraryContent.Content | public function Content($name, $type, $version = 'latest')
{
$type = strtolower($type);
//Gets type for local file
$local = false;
if ('local' == $type) {
$local = true;
$type = strtolower(substr($name, strrpos($name, '.') + 1));
}
//Gets data for local file
if ($local) {
$data = 'css' == $type ? array('href' => $name) : array('src' => $name);
//Gets data for external library
} else {
$data = $this->includeLibraryService->getData($name, $type, $version);
}
//Returns the content from href or src part
if (null != $data) {
$content = null;
if ('css' == $type) {
$content = '<style type="text/css">' . file_get_contents($data['href']) . '</style>';
} elseif ('js' == $type) {
$content = '<script type="text/javascript">' . file_get_contents($data['src']) . '</script>';
}
return $content;
}
//Throws an error if not found
throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_content()" was not found. Please check name and supported library/versions.');
} | php | public function Content($name, $type, $version = 'latest')
{
$type = strtolower($type);
//Gets type for local file
$local = false;
if ('local' == $type) {
$local = true;
$type = strtolower(substr($name, strrpos($name, '.') + 1));
}
//Gets data for local file
if ($local) {
$data = 'css' == $type ? array('href' => $name) : array('src' => $name);
//Gets data for external library
} else {
$data = $this->includeLibraryService->getData($name, $type, $version);
}
//Returns the content from href or src part
if (null != $data) {
$content = null;
if ('css' == $type) {
$content = '<style type="text/css">' . file_get_contents($data['href']) . '</style>';
} elseif ('js' == $type) {
$content = '<script type="text/javascript">' . file_get_contents($data['src']) . '</script>';
}
return $content;
}
//Throws an error if not found
throw new Error('The Library "' . $name . ' (' . $type . ') version ' . $version . '" requested via "inc_content()" was not found. Please check name and supported library/versions.');
} | [
"public",
"function",
"Content",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"version",
"=",
"'latest'",
")",
"{",
"$",
"type",
"=",
"strtolower",
"(",
"$",
"type",
")",
";",
"//Gets type for local file",
"$",
"local",
"=",
"false",
";",
"if",
"(",
... | Returns the content of the requested library
@return string
@throws Error | [
"Returns",
"the",
"content",
"of",
"the",
"requested",
"library"
] | 74f9140551d6f20c1308213c4c142f7fff43eb52 | https://github.com/975L/IncludeLibraryBundle/blob/74f9140551d6f20c1308213c4c142f7fff43eb52/Twig/IncludeLibraryContent.php#L53-L86 |
39,289 | cmsgears/module-core | common/models/resources/Option.php | Option.findByCategoryId | public static function findByCategoryId( $categoryId ) {
$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );
return self::find()->where( "$optionTable.categoryId=:id", [ ':id' => $categoryId ] )->all();
} | php | public static function findByCategoryId( $categoryId ) {
$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );
return self::find()->where( "$optionTable.categoryId=:id", [ ':id' => $categoryId ] )->all();
} | [
"public",
"static",
"function",
"findByCategoryId",
"(",
"$",
"categoryId",
")",
"{",
"$",
"optionTable",
"=",
"CoreTables",
"::",
"getTableName",
"(",
"CoreTables",
"::",
"TABLE_OPTION",
")",
";",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"("... | Return the options available for given category id.
@param integer $categoryId
@return Option[] | [
"Return",
"the",
"options",
"available",
"for",
"given",
"category",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Option.php#L202-L207 |
39,290 | cmsgears/module-core | common/models/resources/Option.php | Option.findByNameCategoryId | public static function findByNameCategoryId( $name, $categoryId ) {
$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );
return self::find()->where( "$optionTable.name=:name AND $optionTable.categoryId=:id", [ ':name' => $name, ':id' => $categoryId ] )->one();
} | php | public static function findByNameCategoryId( $name, $categoryId ) {
$optionTable = CoreTables::getTableName( CoreTables::TABLE_OPTION );
return self::find()->where( "$optionTable.name=:name AND $optionTable.categoryId=:id", [ ':name' => $name, ':id' => $categoryId ] )->one();
} | [
"public",
"static",
"function",
"findByNameCategoryId",
"(",
"$",
"name",
",",
"$",
"categoryId",
")",
"{",
"$",
"optionTable",
"=",
"CoreTables",
"::",
"getTableName",
"(",
"CoreTables",
"::",
"TABLE_OPTION",
")",
";",
"return",
"self",
"::",
"find",
"(",
"... | Return the option using given name and category id.
@param string $name
@param integer $categoryId
@return Option | [
"Return",
"the",
"option",
"using",
"given",
"name",
"and",
"category",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Option.php#L216-L221 |
39,291 | cmsgears/module-core | common/models/resources/Option.php | Option.isExistByNameCategoryId | public static function isExistByNameCategoryId( $name, $categoryId ) {
$option = self::findByNameCategoryId( $name, $categoryId );
return isset( $option );
} | php | public static function isExistByNameCategoryId( $name, $categoryId ) {
$option = self::findByNameCategoryId( $name, $categoryId );
return isset( $option );
} | [
"public",
"static",
"function",
"isExistByNameCategoryId",
"(",
"$",
"name",
",",
"$",
"categoryId",
")",
"{",
"$",
"option",
"=",
"self",
"::",
"findByNameCategoryId",
"(",
"$",
"name",
",",
"$",
"categoryId",
")",
";",
"return",
"isset",
"(",
"$",
"optio... | Check whether option exist by name and category id.
@return boolean | [
"Check",
"whether",
"option",
"exist",
"by",
"name",
"and",
"category",
"id",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/resources/Option.php#L228-L233 |
39,292 | phPoirot/Std | src/Type/StdArray.fix.php | StdArray.makeFlattenFace | function makeFlattenFace()
{
$_f_build = function($data) use (&$_f_build) {
$args = func_get_args();
$isNested = isset($args[1]);
foreach ($data as $k => $d) {
// Build PHP Array Request Params Compatible With Curl
// meta => ['name' => (string)] ---> meta['name'] = (string)
if ( is_array($d) ) {
foreach ($d as $i => $v) {
if (is_array($v)) {
// Nested Array
foreach ($d = $_f_build($v, true) as $kn => $kv) {
$kn = ( false !== strpos($kn, '[') ) ? $kn : '['.$kn.']';
$data[$k . '[' . $i . ']' . $kn] = $kv;
}
} else {
if ($isNested)
$data['[' . $k . ']' . '[' . $i . ']'] = $v;
else
$data[$k . '[' . $i . ']'] = $v;
}
}
unset($data[$k]);
}
}
return $data;
};
$data = $_f_build($this->value);
return new static($data);
} | php | function makeFlattenFace()
{
$_f_build = function($data) use (&$_f_build) {
$args = func_get_args();
$isNested = isset($args[1]);
foreach ($data as $k => $d) {
// Build PHP Array Request Params Compatible With Curl
// meta => ['name' => (string)] ---> meta['name'] = (string)
if ( is_array($d) ) {
foreach ($d as $i => $v) {
if (is_array($v)) {
// Nested Array
foreach ($d = $_f_build($v, true) as $kn => $kv) {
$kn = ( false !== strpos($kn, '[') ) ? $kn : '['.$kn.']';
$data[$k . '[' . $i . ']' . $kn] = $kv;
}
} else {
if ($isNested)
$data['[' . $k . ']' . '[' . $i . ']'] = $v;
else
$data[$k . '[' . $i . ']'] = $v;
}
}
unset($data[$k]);
}
}
return $data;
};
$data = $_f_build($this->value);
return new static($data);
} | [
"function",
"makeFlattenFace",
"(",
")",
"{",
"$",
"_f_build",
"=",
"function",
"(",
"$",
"data",
")",
"use",
"(",
"&",
"$",
"_f_build",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"isNested",
"=",
"isset",
"(",
"$",
"args",
"[... | Flatten An Array
@return static | [
"Flatten",
"An",
"Array"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdArray.fix.php#L185-L220 |
39,293 | phPoirot/Std | src/Type/StdArray.fix.php | StdArray.withMergeRecursive | function withMergeRecursive($b, $reserve = false)
{
if ($b instanceof StdArray)
$b = $b->value;
else
$b = (array) $b;
$a = $this->value;
foreach ($b as $key => $value)
{
if (! array_key_exists($key, $a)) {
// key not exists so simply add it to array
$a[$key] = $value;
continue;
}
if ( is_int($key) ) {
// [ 'value' ] if value not exists append to array!
if (! in_array($value, $a) )
$a[] = $value;
} elseif (is_array($value) && is_array($a[$key])) {
// a= [k=>[]] , b=[k=>['value']]
$m = new StdArray($a[$key]);
$a[$key] = $m->withMergeRecursive($value, $reserve)->value;
} else {
if ($reserve) {
// save old value and push them into new array list
$cv = $a[$key];
$a[$key] = array();
$pa = &$a[$key];
array_push($pa, $cv);
array_push($pa, $value);
} else {
$a[$key] = $value;
}
}
}
return new StdArray($a);
} | php | function withMergeRecursive($b, $reserve = false)
{
if ($b instanceof StdArray)
$b = $b->value;
else
$b = (array) $b;
$a = $this->value;
foreach ($b as $key => $value)
{
if (! array_key_exists($key, $a)) {
// key not exists so simply add it to array
$a[$key] = $value;
continue;
}
if ( is_int($key) ) {
// [ 'value' ] if value not exists append to array!
if (! in_array($value, $a) )
$a[] = $value;
} elseif (is_array($value) && is_array($a[$key])) {
// a= [k=>[]] , b=[k=>['value']]
$m = new StdArray($a[$key]);
$a[$key] = $m->withMergeRecursive($value, $reserve)->value;
} else {
if ($reserve) {
// save old value and push them into new array list
$cv = $a[$key];
$a[$key] = array();
$pa = &$a[$key];
array_push($pa, $cv);
array_push($pa, $value);
} else {
$a[$key] = $value;
}
}
}
return new StdArray($a);
} | [
"function",
"withMergeRecursive",
"(",
"$",
"b",
",",
"$",
"reserve",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"b",
"instanceof",
"StdArray",
")",
"$",
"b",
"=",
"$",
"b",
"->",
"value",
";",
"else",
"$",
"b",
"=",
"(",
"array",
")",
"$",
"b",
"... | Merge two arrays together, reserve previous values
@param array|StdArray $b
@return StdArray | [
"Merge",
"two",
"arrays",
"together",
"reserve",
"previous",
"values"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdArray.fix.php#L333-L376 |
39,294 | phPoirot/Std | src/Type/StdArray.fix.php | StdArray.exclude | function exclude(array $exclusionFields = [], $exclusionBehave = self::EXCLUDE_DISALLOW)
{
$exclude = [];
foreach ($this->value as $field => $term)
{
if (!empty($exclusionFields))
{
$flag = in_array($field, $exclusionFields);
($exclusionBehave != self::EXCLUDE_ALLOW) ?: $flag = !$flag;
if ($flag)
// The Field not considered as Expression Term
continue;
}
$exclude[$field] = $term;
}// end foreach
return new StdArray($exclude);
} | php | function exclude(array $exclusionFields = [], $exclusionBehave = self::EXCLUDE_DISALLOW)
{
$exclude = [];
foreach ($this->value as $field => $term)
{
if (!empty($exclusionFields))
{
$flag = in_array($field, $exclusionFields);
($exclusionBehave != self::EXCLUDE_ALLOW) ?: $flag = !$flag;
if ($flag)
// The Field not considered as Expression Term
continue;
}
$exclude[$field] = $term;
}// end foreach
return new StdArray($exclude);
} | [
"function",
"exclude",
"(",
"array",
"$",
"exclusionFields",
"=",
"[",
"]",
",",
"$",
"exclusionBehave",
"=",
"self",
"::",
"EXCLUDE_DISALLOW",
")",
"{",
"$",
"exclude",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"value",
"as",
"$",
"field"... | Exclude From Array
@param array $exclusionFields The fields that is in query string but must not used in expression
@param string $exclusionBehave allow|disallow
@return self
@throws \Exception | [
"Exclude",
"From",
"Array"
] | 67883b1b1dd2cea80fec3d98a199c403b8a23b4d | https://github.com/phPoirot/Std/blob/67883b1b1dd2cea80fec3d98a199c403b8a23b4d/src/Type/StdArray.fix.php#L387-L409 |
39,295 | ethical-jobs/ethical-jobs-foundation-php | src/Laravel/LoggingServiceProvider.php | LoggingServiceProvider.registerLogger | public function registerLogger()
{
$this->app->extend('log', function($log) {
return new Writer($log->getMonolog(), $log->getEventDispatcher());
});
} | php | public function registerLogger()
{
$this->app->extend('log', function($log) {
return new Writer($log->getMonolog(), $log->getEventDispatcher());
});
} | [
"public",
"function",
"registerLogger",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"extend",
"(",
"'log'",
",",
"function",
"(",
"$",
"log",
")",
"{",
"return",
"new",
"Writer",
"(",
"$",
"log",
"->",
"getMonolog",
"(",
")",
",",
"$",
"log",
"-... | Extend the logger.
@return \Illuminate\Log\Writer | [
"Extend",
"the",
"logger",
"."
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Laravel/LoggingServiceProvider.php#L41-L46 |
39,296 | ethical-jobs/ethical-jobs-foundation-php | src/Laravel/LoggingServiceProvider.php | LoggingServiceProvider.registerRollbar | public function registerRollbar()
{
if (in_array(App::environment(), ['production', 'staging'])) {
$this->extendConfig();
$this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
}
} | php | public function registerRollbar()
{
if (in_array(App::environment(), ['production', 'staging'])) {
$this->extendConfig();
$this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
}
} | [
"public",
"function",
"registerRollbar",
"(",
")",
"{",
"if",
"(",
"in_array",
"(",
"App",
"::",
"environment",
"(",
")",
",",
"[",
"'production'",
",",
"'staging'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"extendConfig",
"(",
")",
";",
"$",
"this",
"... | Register rollbar logger
@return \Illuminate\Log\Writer | [
"Register",
"rollbar",
"logger"
] | 35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8 | https://github.com/ethical-jobs/ethical-jobs-foundation-php/blob/35dafc2172dc8ba44c0ace4a58a7c0a9b63455a8/src/Laravel/LoggingServiceProvider.php#L53-L61 |
39,297 | rodrigoiii/skeleton-core | src/classes/Console/Commands/MakeControllerCommand.php | MakeControllerCommand.getTemplate | private function getTemplate($sub_directories, $controller, $is_resource = false)
{
$file = __DIR__ . "/../templates/controller/";
$file .= $is_resource ? "controller-with-resource.php.dist" : "controller.php.dist";
if (file_exists($file))
{
$template = file_get_contents($file);
return strtr($template, [
'{{namespace}}' => get_app_namespace(),
'{{sub_directories}}' => $sub_directories,
'{{controller}}' => $controller
]);
}
return false;
} | php | private function getTemplate($sub_directories, $controller, $is_resource = false)
{
$file = __DIR__ . "/../templates/controller/";
$file .= $is_resource ? "controller-with-resource.php.dist" : "controller.php.dist";
if (file_exists($file))
{
$template = file_get_contents($file);
return strtr($template, [
'{{namespace}}' => get_app_namespace(),
'{{sub_directories}}' => $sub_directories,
'{{controller}}' => $controller
]);
}
return false;
} | [
"private",
"function",
"getTemplate",
"(",
"$",
"sub_directories",
",",
"$",
"controller",
",",
"$",
"is_resource",
"=",
"false",
")",
"{",
"$",
"file",
"=",
"__DIR__",
".",
"\"/../templates/controller/\"",
";",
"$",
"file",
".=",
"$",
"is_resource",
"?",
"\... | Get the controller template.
@param string $sub_directories
@param string $controller
@param boolean $is_resource
@return mixed | [
"Get",
"the",
"controller",
"template",
"."
] | 5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0 | https://github.com/rodrigoiii/skeleton-core/blob/5dab0637b9cd0f55a64b1f5926d7ba6bb3f93df0/src/classes/Console/Commands/MakeControllerCommand.php#L100-L117 |
39,298 | cmsgears/module-core | common/models/entities/Region.php | Region.findUnique | public static function findUnique( $name, $countryId, $provinceId ) {
return self::find()->where( 'name=:name AND countryId=:cid AND provinceId=:pid', [ ':name' => $name, ':cid' => $countryId, ':pid' => $provinceId ] )->one();
} | php | public static function findUnique( $name, $countryId, $provinceId ) {
return self::find()->where( 'name=:name AND countryId=:cid AND provinceId=:pid', [ ':name' => $name, ':cid' => $countryId, ':pid' => $provinceId ] )->one();
} | [
"public",
"static",
"function",
"findUnique",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
")",
"{",
"return",
"self",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"'name=:name AND countryId=:cid AND provinceId=:pid'",
",",
"[",
"':name'",
"... | Try to find out a region having unique name within province.
@param string $name
@param integer $countryId
@param integer $provinceId
@return Region by name, country id and province id | [
"Try",
"to",
"find",
"out",
"a",
"region",
"having",
"unique",
"name",
"within",
"province",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Region.php#L265-L268 |
39,299 | cmsgears/module-core | common/models/entities/Region.php | Region.isUniqueExist | public static function isUniqueExist( $name, $countryId, $provinceId ) {
$region = self::findUnique( $name, $countryId, $provinceId );
return isset( $region );
} | php | public static function isUniqueExist( $name, $countryId, $provinceId ) {
$region = self::findUnique( $name, $countryId, $provinceId );
return isset( $region );
} | [
"public",
"static",
"function",
"isUniqueExist",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
")",
"{",
"$",
"region",
"=",
"self",
"::",
"findUnique",
"(",
"$",
"name",
",",
"$",
"countryId",
",",
"$",
"provinceId",
")",
";",
"retu... | Check whether a region already exist using given name within province.
@param string $name
@param integer $countryId
@param integer $provinceId
@return boolean | [
"Check",
"whether",
"a",
"region",
"already",
"exist",
"using",
"given",
"name",
"within",
"province",
"."
] | ce1b1f7afff2931847d71afa152c72355f374dc6 | https://github.com/cmsgears/module-core/blob/ce1b1f7afff2931847d71afa152c72355f374dc6/common/models/entities/Region.php#L278-L283 |
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.