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
41,300
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.addTaskHighBackground
public function addTaskHighBackground($name, $params = '', &$context = null, $unique = null) { $this->enqueueTask($name, $params, $context, $unique, GearmanMethods::GEARMAN_METHOD_ADDTASKHIGHBACKGROUND); return $this; }
php
public function addTaskHighBackground($name, $params = '', &$context = null, $unique = null) { $this->enqueueTask($name, $params, $context, $unique, GearmanMethods::GEARMAN_METHOD_ADDTASKHIGHBACKGROUND); return $this; }
[ "public", "function", "addTaskHighBackground", "(", "$", "name", ",", "$", "params", "=", "''", ",", "&", "$", "context", "=", "null", ",", "$", "unique", "=", "null", ")", "{", "$", "this", "->", "enqueueTask", "(", "$", "name", ",", "$", "params", ...
Adds a high priority background task to be run in parallel with other tasks. Call this method for all the tasks to be run in parallel, then call GearmanClient::runTasks() to perform the work. Tasks with a high priority will be selected from the queue before those of normal or low priority. @param string $name A GermanBundle registered function to be executed @param string $params Parameters to send to task as string @param Mixed &$context Application context to associate with a task @param string $unique A unique ID used to identify a particular task @return GearmanClient Return this object
[ "Adds", "a", "high", "priority", "background", "task", "to", "be", "run", "in", "parallel", "with", "other", "tasks", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L577-L582
41,301
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.enqueueTask
protected function enqueueTask($name, $params, &$context, $unique, $method) { $contextReference = array('context' => &$context); $task = array( 'name' => $name, 'params' => $params, 'context' => $contextReference, 'unique' => $this->uniqueJobIdentifierGenerator->generateUniqueKey($name, $params, $unique, $method), 'method' => $method, ); $this->addTaskToStructure($task); return $this; }
php
protected function enqueueTask($name, $params, &$context, $unique, $method) { $contextReference = array('context' => &$context); $task = array( 'name' => $name, 'params' => $params, 'context' => $contextReference, 'unique' => $this->uniqueJobIdentifierGenerator->generateUniqueKey($name, $params, $unique, $method), 'method' => $method, ); $this->addTaskToStructure($task); return $this; }
[ "protected", "function", "enqueueTask", "(", "$", "name", ",", "$", "params", ",", "&", "$", "context", ",", "$", "unique", ",", "$", "method", ")", "{", "$", "contextReference", "=", "array", "(", "'context'", "=>", "&", "$", "context", ")", ";", "$...
Adds a task into the structure of tasks with included type of call @param string $name A GermanBundle registered function to be executed @param string $params Parameters to send to task as string @param Mixed $context Application context to associate with a task @param string $unique A unique ID used to identify a particular task @param string $method Method to perform @return GearmanClient Return this object
[ "Adds", "a", "task", "into", "the", "structure", "of", "tasks", "with", "included", "type", "of", "call" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L619-L633
41,302
mmoreram/GearmanBundle
Service/GearmanClient.php
GearmanClient.runTasks
public function runTasks() { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); if ($this->settings['callbacks']) { $this->gearmanCallbacksDispatcher->assignTaskCallbacks($gearmanClient); } foreach ($this->taskStructure as $task) { $type = $task['method']; $jobName = $task['name']; $worker = $this->getJob($jobName); if (false !== $worker) { $gearmanClient->$type( $worker['job']['realCallableName'], $task['params'], $task['context'], $task['unique'] ); } } $this->initTaskStructure(); $this->gearmanClient = null; return $gearmanClient->runTasks(); }
php
public function runTasks() { $gearmanClient = $this->getNativeClient(); $this->assignServers($gearmanClient); if ($this->settings['callbacks']) { $this->gearmanCallbacksDispatcher->assignTaskCallbacks($gearmanClient); } foreach ($this->taskStructure as $task) { $type = $task['method']; $jobName = $task['name']; $worker = $this->getJob($jobName); if (false !== $worker) { $gearmanClient->$type( $worker['job']['realCallableName'], $task['params'], $task['context'], $task['unique'] ); } } $this->initTaskStructure(); $this->gearmanClient = null; return $gearmanClient->runTasks(); }
[ "public", "function", "runTasks", "(", ")", "{", "$", "gearmanClient", "=", "$", "this", "->", "getNativeClient", "(", ")", ";", "$", "this", "->", "assignServers", "(", "$", "gearmanClient", ")", ";", "if", "(", "$", "this", "->", "settings", "[", "'c...
For a set of tasks previously added with GearmanClient::addTask(), GearmanClient::addTaskHigh(), GearmanClient::addTaskLow(), GearmanClient::addTaskBackground(), GearmanClient::addTaskHighBackground(), GearmanClient::addTaskLowBackground(), this call starts running the tasks in parallel. Note that enough workers need to be available for the tasks to all run in parallel @return boolean run tasks result
[ "For", "a", "set", "of", "tasks", "previously", "added", "with" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanClient.php#L664-L696
41,303
mmoreram/GearmanBundle
Service/GearmanCacheWrapper.php
GearmanCacheWrapper.load
public function load(Cache $cache, $cacheId) { if ($cache->contains($cacheId)) { /** * Cache contains gearman structure */ $this->workerCollection = $cache->fetch($cacheId); } else { /** * Cache is empty. * * Full structure must be generated and cached */ $this->workerCollection = $this ->getGearmanParser() ->load() ->toArray(); $cache->save($cacheId, $this->workerCollection); } return $this; }
php
public function load(Cache $cache, $cacheId) { if ($cache->contains($cacheId)) { /** * Cache contains gearman structure */ $this->workerCollection = $cache->fetch($cacheId); } else { /** * Cache is empty. * * Full structure must be generated and cached */ $this->workerCollection = $this ->getGearmanParser() ->load() ->toArray(); $cache->save($cacheId, $this->workerCollection); } return $this; }
[ "public", "function", "load", "(", "Cache", "$", "cache", ",", "$", "cacheId", ")", "{", "if", "(", "$", "cache", "->", "contains", "(", "$", "cacheId", ")", ")", "{", "/**\n * Cache contains gearman structure\n */", "$", "this", "->", ...
loads Gearman cache, only if is not loaded yet @param Cache $cache Cache instance @param string $cacheId Cache id @return GearmanCacheWrapper self Object
[ "loads", "Gearman", "cache", "only", "if", "is", "not", "loaded", "yet" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanCacheWrapper.php#L126-L151
41,304
CasperLaiTW/laravel-fb-messenger
src/Contracts/AutoTypingHandler.php
AutoTypingHandler.handle
public function handle(ReceiveMessage $message) { $typing = new Typing($message->getSender()); $this->send($typing); }
php
public function handle(ReceiveMessage $message) { $typing = new Typing($message->getSender()); $this->send($typing); }
[ "public", "function", "handle", "(", "ReceiveMessage", "$", "message", ")", "{", "$", "typing", "=", "new", "Typing", "(", "$", "message", "->", "getSender", "(", ")", ")", ";", "$", "this", "->", "send", "(", "$", "typing", ")", ";", "}" ]
Handle the chatbot message @param ReceiveMessage $message @return mixed @throws \Casperlaitw\LaravelFbMessenger\Exceptions\NotCreateBotException
[ "Handle", "the", "chatbot", "message" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/AutoTypingHandler.php#L27-L31
41,305
mmoreram/GearmanBundle
Module/WorkerClass.php
WorkerClass.createJobCollection
private function createJobCollection(ReflectionClass $reflectionClass, Reader $reader) { $jobCollection = new JobCollection; /** * For each defined method, we parse it */ foreach ($reflectionClass->getMethods() as $reflectionMethod) { $methodAnnotations = $reader->getMethodAnnotations($reflectionMethod); /** * Every annotation found is parsed */ foreach ($methodAnnotations as $methodAnnotation) { /** * Annotation is only loaded if is typeof JobAnnotation */ if ($methodAnnotation instanceof JobAnnotation) { /** * Creates new Job */ $job = new Job($methodAnnotation, $reflectionMethod, $this->callableName, $this->servers, array( 'jobPrefix' => $this->jobPrefix, 'iterations' => $this->iterations, 'method' => $this->defaultMethod, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, )); $jobCollection->add($job); } } } return $jobCollection; }
php
private function createJobCollection(ReflectionClass $reflectionClass, Reader $reader) { $jobCollection = new JobCollection; /** * For each defined method, we parse it */ foreach ($reflectionClass->getMethods() as $reflectionMethod) { $methodAnnotations = $reader->getMethodAnnotations($reflectionMethod); /** * Every annotation found is parsed */ foreach ($methodAnnotations as $methodAnnotation) { /** * Annotation is only loaded if is typeof JobAnnotation */ if ($methodAnnotation instanceof JobAnnotation) { /** * Creates new Job */ $job = new Job($methodAnnotation, $reflectionMethod, $this->callableName, $this->servers, array( 'jobPrefix' => $this->jobPrefix, 'iterations' => $this->iterations, 'method' => $this->defaultMethod, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, )); $jobCollection->add($job); } } } return $jobCollection; }
[ "private", "function", "createJobCollection", "(", "ReflectionClass", "$", "reflectionClass", ",", "Reader", "$", "reader", ")", "{", "$", "jobCollection", "=", "new", "JobCollection", ";", "/**\n * For each defined method, we parse it\n */", "foreach", "(",...
Creates job collection of worker @param ReflectionClass $reflectionClass Reflexion class @param Reader $reader ReaderAnnotation class @return WorkerClass self Object
[ "Creates", "job", "collection", "of", "worker" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/WorkerClass.php#L296-L333
41,306
mmoreram/GearmanBundle
Module/WorkerClass.php
WorkerClass.toArray
public function toArray() { return array( 'namespace' => $this->namespace, 'className' => $this->className, 'fileName' => $this->fileName, 'callableName' => $this->callableName, 'description' => $this->description, 'service' => $this->service, 'servers' => $this->servers, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'jobs' => $this->jobCollection->toArray(), ); }
php
public function toArray() { return array( 'namespace' => $this->namespace, 'className' => $this->className, 'fileName' => $this->fileName, 'callableName' => $this->callableName, 'description' => $this->description, 'service' => $this->service, 'servers' => $this->servers, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'jobs' => $this->jobCollection->toArray(), ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'namespace'", "=>", "$", "this", "->", "namespace", ",", "'className'", "=>", "$", "this", "->", "className", ",", "'fileName'", "=>", "$", "this", "->", "fileName", ",", "'callableNa...
Retrieve all Worker data in cache format @return array
[ "Retrieve", "all", "Worker", "data", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/WorkerClass.php#L340-L356
41,307
CasperLaiTW/laravel-fb-messenger
src/Contracts/WebhookHandler.php
WebhookHandler.autoTypeHandle
private function autoTypeHandle($message) { $autoTyping = $this->config->get('fb-messenger.auto_typing'); if ($autoTyping) { $handler = $this->createBot($this->app->make(AutoTypingHandler::class)); $handler->handle($message); } }
php
private function autoTypeHandle($message) { $autoTyping = $this->config->get('fb-messenger.auto_typing'); if ($autoTyping) { $handler = $this->createBot($this->app->make(AutoTypingHandler::class)); $handler->handle($message); } }
[ "private", "function", "autoTypeHandle", "(", "$", "message", ")", "{", "$", "autoTyping", "=", "$", "this", "->", "config", "->", "get", "(", "'fb-messenger.auto_typing'", ")", ";", "if", "(", "$", "autoTyping", ")", "{", "$", "handler", "=", "$", "this...
Handle auto type
[ "Handle", "auto", "type" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/WebhookHandler.php#L118-L125
41,308
CasperLaiTW/laravel-fb-messenger
src/Messages/PersistentMenuMessage.php
PersistentMenuMessage.toData
public function toData() { if ($this->type === Bot::TYPE_DELETE) { return [ 'fields' => [ 'persistent_menu', ], ]; } if ($this->type === Bot::TYPE_GET) { return [ 'fields' => 'persistent_menu', ]; } return [ 'persistent_menu' => $this->menus, ]; }
php
public function toData() { if ($this->type === Bot::TYPE_DELETE) { return [ 'fields' => [ 'persistent_menu', ], ]; } if ($this->type === Bot::TYPE_GET) { return [ 'fields' => 'persistent_menu', ]; } return [ 'persistent_menu' => $this->menus, ]; }
[ "public", "function", "toData", "(", ")", "{", "if", "(", "$", "this", "->", "type", "===", "Bot", "::", "TYPE_DELETE", ")", "{", "return", "[", "'fields'", "=>", "[", "'persistent_menu'", ",", "]", ",", "]", ";", "}", "if", "(", "$", "this", "->",...
Message to send @return array
[ "Message", "to", "send" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Messages/PersistentMenuMessage.php#L43-L62
41,309
mmoreram/GearmanBundle
Module/JobCollection.php
JobCollection.toArray
public function toArray() { $jobs = array(); foreach ($this->workerJobs as $job) { $jobs[] = $job->toArray(); } return $jobs; }
php
public function toArray() { $jobs = array(); foreach ($this->workerJobs as $job) { $jobs[] = $job->toArray(); } return $jobs; }
[ "public", "function", "toArray", "(", ")", "{", "$", "jobs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "workerJobs", "as", "$", "job", ")", "{", "$", "jobs", "[", "]", "=", "$", "job", "->", "toArray", "(", ")", ";", "}", ...
Retrieve all jobs loaded previously in cache format @return array
[ "Retrieve", "all", "jobs", "loaded", "previously", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/JobCollection.php#L62-L72
41,310
CasperLaiTW/laravel-fb-messenger
src/Providers/RouteServiceProvider.php
RouteServiceProvider.boot
public function boot(Router $router) { if (!$this->app->routesAreCached()) { $router->group([ 'namespace' => $this->namespace, ], function (Router $router) { require __DIR__.'/../routes/web.php'; }); } }
php
public function boot(Router $router) { if (!$this->app->routesAreCached()) { $router->group([ 'namespace' => $this->namespace, ], function (Router $router) { require __DIR__.'/../routes/web.php'; }); } }
[ "public", "function", "boot", "(", "Router", "$", "router", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "routesAreCached", "(", ")", ")", "{", "$", "router", "->", "group", "(", "[", "'namespace'", "=>", "$", "this", "->", "namespace", ...
Register the webhook to router @param Router $router
[ "Register", "the", "webhook", "to", "router" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Providers/RouteServiceProvider.php#L29-L38
41,311
mmoreram/GearmanBundle
Module/JobStatus.php
JobStatus.getCompletionPercent
public function getCompletionPercent() { $percent = 0; if (($this->completed > 0) && ($this->completionTotal > 0)) { $percent = $this->completed / $this->completionTotal; } return $percent; }
php
public function getCompletionPercent() { $percent = 0; if (($this->completed > 0) && ($this->completionTotal > 0)) { $percent = $this->completed / $this->completionTotal; } return $percent; }
[ "public", "function", "getCompletionPercent", "(", ")", "{", "$", "percent", "=", "0", ";", "if", "(", "(", "$", "this", "->", "completed", ">", "0", ")", "&&", "(", "$", "this", "->", "completionTotal", ">", "0", ")", ")", "{", "$", "percent", "="...
Return percent completed. 0 is not started or not known 1 is finished Between 0 and 1 is in process. Value is a float @return float Percent completed
[ "Return", "percent", "completed", "." ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/JobStatus.php#L119-L129
41,312
CasperLaiTW/laravel-fb-messenger
src/Contracts/Bot.php
Bot.send
public function send($message, $type = self::TYPE_POST) { if ($message instanceof ProfileInterface) { return $this->sendProfile($message->toData(), $type); } if ($message instanceof UserInterface) { return $this->sendUserApi($message); } if ($message instanceof CodeInterface) { return $this->sendMessengerCode($message->toData()); } return $this->sendMessage($message->toData()); }
php
public function send($message, $type = self::TYPE_POST) { if ($message instanceof ProfileInterface) { return $this->sendProfile($message->toData(), $type); } if ($message instanceof UserInterface) { return $this->sendUserApi($message); } if ($message instanceof CodeInterface) { return $this->sendMessengerCode($message->toData()); } return $this->sendMessage($message->toData()); }
[ "public", "function", "send", "(", "$", "message", ",", "$", "type", "=", "self", "::", "TYPE_POST", ")", "{", "if", "(", "$", "message", "instanceof", "ProfileInterface", ")", "{", "return", "$", "this", "->", "sendProfile", "(", "$", "message", "->", ...
Send message to API If instance of ProfileInterface, auto turn to thread_settings endpoint @param Message $message @param string $type @return HandleMessageResponse|array @throws \RuntimeException
[ "Send", "message", "to", "API" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Bot.php#L155-L170
41,313
CasperLaiTW/laravel-fb-messenger
src/Contracts/Bot.php
Bot.sendProfile
protected function sendProfile($message, $type = self::TYPE_POST) { return new HandleMessageResponse($this->call('me/messenger_profile', $message, $type)); }
php
protected function sendProfile($message, $type = self::TYPE_POST) { return new HandleMessageResponse($this->call('me/messenger_profile', $message, $type)); }
[ "protected", "function", "sendProfile", "(", "$", "message", ",", "$", "type", "=", "self", "::", "TYPE_POST", ")", "{", "return", "new", "HandleMessageResponse", "(", "$", "this", "->", "call", "(", "'me/messenger_profile'", ",", "$", "message", ",", "$", ...
Send messenger profile endpoint @param array $message @param string $type @return HandleMessageResponse @throws \RuntimeException
[ "Send", "messenger", "profile", "endpoint" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Bot.php#L191-L194
41,314
mmoreram/GearmanBundle
Generator/UniqueJobIdentifierGenerator.php
UniqueJobIdentifierGenerator.generateUniqueKey
public function generateUniqueKey($name, $params, $unique, $method) { $unique = !$unique && $this->generateUniqueKey ? md5($name . $params) : $unique; if (strlen($name . $unique) > 114) { throw new WorkerNameTooLongException; } return $unique; }
php
public function generateUniqueKey($name, $params, $unique, $method) { $unique = !$unique && $this->generateUniqueKey ? md5($name . $params) : $unique; if (strlen($name . $unique) > 114) { throw new WorkerNameTooLongException; } return $unique; }
[ "public", "function", "generateUniqueKey", "(", "$", "name", ",", "$", "params", ",", "$", "unique", ",", "$", "method", ")", "{", "$", "unique", "=", "!", "$", "unique", "&&", "$", "this", "->", "generateUniqueKey", "?", "md5", "(", "$", "name", "."...
Generate unique key if generateUniqueKey is enabled Even some parameters are not used, are passed to allow user overwrite method Also, if name and unique value exceeds 114 bytes, an exception is thrown @param string $name A GermanBundle registered function to be executed @param string $params Parameters to send to task as string @param string $unique unique ID used to identify a particular task @param string $method Method to perform @return string Generated Unique Key @throws WorkerNameTooLongException If name is too large @api
[ "Generate", "unique", "key", "if", "generateUniqueKey", "is", "enabled" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Generator/UniqueJobIdentifierGenerator.php#L63-L75
41,315
mmoreram/GearmanBundle
Module/JobClass.php
JobClass.toArray
public function toArray() { return array( 'callableName' => $this->callableName, 'methodName' => $this->methodName, 'realCallableName' => $this->realCallableName, 'jobPrefix' => $this->jobPrefix, 'realCallableNameNoPrefix' => $this->realCallableNameNoPrefix, 'description' => $this->description, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'servers' => $this->servers, 'defaultMethod' => $this->defaultMethod, ); }
php
public function toArray() { return array( 'callableName' => $this->callableName, 'methodName' => $this->methodName, 'realCallableName' => $this->realCallableName, 'jobPrefix' => $this->jobPrefix, 'realCallableNameNoPrefix' => $this->realCallableNameNoPrefix, 'description' => $this->description, 'iterations' => $this->iterations, 'minimumExecutionTime' => $this->minimumExecutionTime, 'timeout' => $this->timeout, 'servers' => $this->servers, 'defaultMethod' => $this->defaultMethod, ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array", "(", "'callableName'", "=>", "$", "this", "->", "callableName", ",", "'methodName'", "=>", "$", "this", "->", "methodName", ",", "'realCallableName'", "=>", "$", "this", "->", "realCallableName...
Retrieve all Job data in cache format @return array
[ "Retrieve", "all", "Job", "data", "in", "cache", "format" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Module/JobClass.php#L269-L285
41,316
CasperLaiTW/laravel-fb-messenger
src/PersistentMenu/Menu.php
Menu.postback
public function postback($text, $payload = '') { $this->createMenu([ 'call_to_actions' => [ (new Button(Button::TYPE_POSTBACK, $text, $payload))->toData(), ], ]); }
php
public function postback($text, $payload = '') { $this->createMenu([ 'call_to_actions' => [ (new Button(Button::TYPE_POSTBACK, $text, $payload))->toData(), ], ]); }
[ "public", "function", "postback", "(", "$", "text", ",", "$", "payload", "=", "''", ")", "{", "$", "this", "->", "createMenu", "(", "[", "'call_to_actions'", "=>", "[", "(", "new", "Button", "(", "Button", "::", "TYPE_POSTBACK", ",", "$", "text", ",", ...
Create postback menu @param $text @param string $payload @throws \Casperlaitw\LaravelFbMessenger\Exceptions\UnknownTypeException
[ "Create", "postback", "menu" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/PersistentMenu/Menu.php#L60-L67
41,317
CasperLaiTW/laravel-fb-messenger
src/PersistentMenu/Menu.php
Menu.locale
public function locale($locale, $menus) { $this->stack[] = [ 'locale' => $locale, ]; $this->loadMenus($menus); $this->menus[] = array_pop($this->stack); }
php
public function locale($locale, $menus) { $this->stack[] = [ 'locale' => $locale, ]; $this->loadMenus($menus); $this->menus[] = array_pop($this->stack); }
[ "public", "function", "locale", "(", "$", "locale", ",", "$", "menus", ")", "{", "$", "this", "->", "stack", "[", "]", "=", "[", "'locale'", "=>", "$", "locale", ",", "]", ";", "$", "this", "->", "loadMenus", "(", "$", "menus", ")", ";", "$", "...
Set locale menu @param $locale @param $menus
[ "Set", "locale", "menu" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/PersistentMenu/Menu.php#L114-L123
41,318
CasperLaiTW/laravel-fb-messenger
src/PersistentMenu/Menu.php
Menu.mergeWithLastStack
protected function mergeWithLastStack($menu) { $stack = array_pop($this->stack); $this->stack[] = array_merge_recursive($stack, $menu); }
php
protected function mergeWithLastStack($menu) { $stack = array_pop($this->stack); $this->stack[] = array_merge_recursive($stack, $menu); }
[ "protected", "function", "mergeWithLastStack", "(", "$", "menu", ")", "{", "$", "stack", "=", "array_pop", "(", "$", "this", "->", "stack", ")", ";", "$", "this", "->", "stack", "[", "]", "=", "array_merge_recursive", "(", "$", "stack", ",", "$", "menu...
Merge menus to last menu stack @param $menu
[ "Merge", "menus", "to", "last", "menu", "stack" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/PersistentMenu/Menu.php#L152-L156
41,319
CasperLaiTW/laravel-fb-messenger
src/Contracts/Messages/Attachment.php
Attachment.setAttachmentId
public function setAttachmentId($id) { $this->payload['attachment_id'] = $id; unset($this->payload['url'], $this->payload['is_reusable']); return $this; }
php
public function setAttachmentId($id) { $this->payload['attachment_id'] = $id; unset($this->payload['url'], $this->payload['is_reusable']); return $this; }
[ "public", "function", "setAttachmentId", "(", "$", "id", ")", "{", "$", "this", "->", "payload", "[", "'attachment_id'", "]", "=", "$", "id", ";", "unset", "(", "$", "this", "->", "payload", "[", "'url'", "]", ",", "$", "this", "->", "payload", "[", ...
Set attachment id @param $id @return $this
[ "Set", "attachment", "id" ]
c78b982029443e1046f9e5d3339c7fc044d2129d
https://github.com/CasperLaiTW/laravel-fb-messenger/blob/c78b982029443e1046f9e5d3339c7fc044d2129d/src/Contracts/Messages/Attachment.php#L124-L130
41,320
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.load
public function load() { list($paths, $excludedPaths) = $this->loadBundleNamespaceMap($this->kernelBundles, $this->bundles); $paths = array_merge($paths, $this->loadResourceNamespaceMap($this->rootDir, $this->resources)); return $this->parseNamespaceMap($this->finder, $this->reader, $paths, $excludedPaths); }
php
public function load() { list($paths, $excludedPaths) = $this->loadBundleNamespaceMap($this->kernelBundles, $this->bundles); $paths = array_merge($paths, $this->loadResourceNamespaceMap($this->rootDir, $this->resources)); return $this->parseNamespaceMap($this->finder, $this->reader, $paths, $excludedPaths); }
[ "public", "function", "load", "(", ")", "{", "list", "(", "$", "paths", ",", "$", "excludedPaths", ")", "=", "$", "this", "->", "loadBundleNamespaceMap", "(", "$", "this", "->", "kernelBundles", ",", "$", "this", "->", "bundles", ")", ";", "$", "paths"...
Loads Worker Collection from parsed files @return WorkerCollection collection of all info
[ "Loads", "Worker", "Collection", "from", "parsed", "files" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L136-L142
41,321
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.loadResourceNamespaceMap
public function loadResourceNamespaceMap($rootDir, array $resources) { return array_map(function($resource) use ($rootDir) { return $rootDir . '/' . trim($resource, '/') . '/'; }, $resources); }
php
public function loadResourceNamespaceMap($rootDir, array $resources) { return array_map(function($resource) use ($rootDir) { return $rootDir . '/' . trim($resource, '/') . '/'; }, $resources); }
[ "public", "function", "loadResourceNamespaceMap", "(", "$", "rootDir", ",", "array", "$", "resources", ")", "{", "return", "array_map", "(", "function", "(", "$", "resource", ")", "use", "(", "$", "rootDir", ")", "{", "return", "$", "rootDir", ".", "'/'", ...
Get resource paths @param string $rootDir @param array $resources @return array
[ "Get", "resource", "paths" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L205-L210
41,322
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.parseNamespaceMap
public function parseNamespaceMap( Finder $finder, Reader $reader, array $paths, array $excludedPaths ) { $workerCollection = new WorkerCollection; if (!empty($paths)) { $finder ->files() ->followLinks() ->exclude($excludedPaths) ->in($paths) ->name('*.php'); $this->parseFiles($finder, $reader, $workerCollection); } return $workerCollection; }
php
public function parseNamespaceMap( Finder $finder, Reader $reader, array $paths, array $excludedPaths ) { $workerCollection = new WorkerCollection; if (!empty($paths)) { $finder ->files() ->followLinks() ->exclude($excludedPaths) ->in($paths) ->name('*.php'); $this->parseFiles($finder, $reader, $workerCollection); } return $workerCollection; }
[ "public", "function", "parseNamespaceMap", "(", "Finder", "$", "finder", ",", "Reader", "$", "reader", ",", "array", "$", "paths", ",", "array", "$", "excludedPaths", ")", "{", "$", "workerCollection", "=", "new", "WorkerCollection", ";", "if", "(", "!", "...
Perform a parsing inside all namespace map Creates an empty worker collection and, if exist some parseable files parse them, filling this object @param Finder $finder Finder @param Reader $reader Reader @param array $paths Paths where to look for @param array $excludedPaths Paths to ignore @return WorkerCollection collection of all info
[ "Perform", "a", "parsing", "inside", "all", "namespace", "map" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L225-L247
41,323
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.parseFiles
public function parseFiles( Finder $finder, Reader $reader, WorkerCollection $workerCollection ) { /** * Every file found is parsed */ foreach ($finder as $file) { /** * File is accepted to be parsed */ $classNamespace = $this->getFileClassNamespace($file->getRealpath()); $reflectionClass = new ReflectionClass($classNamespace); $classAnnotations = $reader->getClassAnnotations($reflectionClass); /** * Every annotation found is parsed */ foreach ($classAnnotations as $annotation) { /** * Annotation is only laoded if is typeof WorkAnnotation */ if ($annotation instanceof WorkAnnotation) { /** * Creates new Worker element with all its Job data */ $worker = new Worker($annotation, $reflectionClass, $reader, $this->servers, $this->defaultSettings); $workerCollection->add($worker); } } } return $this; }
php
public function parseFiles( Finder $finder, Reader $reader, WorkerCollection $workerCollection ) { /** * Every file found is parsed */ foreach ($finder as $file) { /** * File is accepted to be parsed */ $classNamespace = $this->getFileClassNamespace($file->getRealpath()); $reflectionClass = new ReflectionClass($classNamespace); $classAnnotations = $reader->getClassAnnotations($reflectionClass); /** * Every annotation found is parsed */ foreach ($classAnnotations as $annotation) { /** * Annotation is only laoded if is typeof WorkAnnotation */ if ($annotation instanceof WorkAnnotation) { /** * Creates new Worker element with all its Job data */ $worker = new Worker($annotation, $reflectionClass, $reader, $this->servers, $this->defaultSettings); $workerCollection->add($worker); } } } return $this; }
[ "public", "function", "parseFiles", "(", "Finder", "$", "finder", ",", "Reader", "$", "reader", ",", "WorkerCollection", "$", "workerCollection", ")", "{", "/**\n * Every file found is parsed\n */", "foreach", "(", "$", "finder", "as", "$", "file", "...
Load all workers with their jobs @param Finder $finder Finder @param Reader $reader Reader @param WorkerCollection $workerCollection Worker collection @return GearmanParser self Object
[ "Load", "all", "workers", "with", "their", "jobs" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L258-L297
41,324
mmoreram/GearmanBundle
Service/GearmanParser.php
GearmanParser.getFileClassNamespace
public function getFileClassNamespace($file) { $filenameBlock = explode(DIRECTORY_SEPARATOR, $file); $filename = explode('.', end($filenameBlock), 2); $filename = reset($filename); preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match); return is_array($match) && isset($match[1]) ? $match[1] . '\\' . $filename : false; }
php
public function getFileClassNamespace($file) { $filenameBlock = explode(DIRECTORY_SEPARATOR, $file); $filename = explode('.', end($filenameBlock), 2); $filename = reset($filename); preg_match('/\snamespace\s+(.+?);/s', file_get_contents($file), $match); return is_array($match) && isset($match[1]) ? $match[1] . '\\' . $filename : false; }
[ "public", "function", "getFileClassNamespace", "(", "$", "file", ")", "{", "$", "filenameBlock", "=", "explode", "(", "DIRECTORY_SEPARATOR", ",", "$", "file", ")", ";", "$", "filename", "=", "explode", "(", "'.'", ",", "end", "(", "$", "filenameBlock", ")"...
Returns file class namespace, if exists @param string $file A PHP file path @return string|false Full class namespace if found, false otherwise
[ "Returns", "file", "class", "namespace", "if", "exists" ]
a394c8d19295967caa411fbceb7ee6bf7a15fc18
https://github.com/mmoreram/GearmanBundle/blob/a394c8d19295967caa411fbceb7ee6bf7a15fc18/Service/GearmanParser.php#L306-L317
41,325
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedQuery
protected function mappedQuery(Builder $query, $method, ArgumentBag $args) { $mapping = $this->getMappingForAttribute($args->get('column')); if ($this->relationMapping($mapping)) { return $this->mappedRelationQuery($query, $method, $args, $mapping); } $args->set('column', $mapping); return $query->callParent($method, $args->all()); }
php
protected function mappedQuery(Builder $query, $method, ArgumentBag $args) { $mapping = $this->getMappingForAttribute($args->get('column')); if ($this->relationMapping($mapping)) { return $this->mappedRelationQuery($query, $method, $args, $mapping); } $args->set('column', $mapping); return $query->callParent($method, $args->all()); }
[ "protected", "function", "mappedQuery", "(", "Builder", "$", "query", ",", "$", "method", ",", "ArgumentBag", "$", "args", ")", "{", "$", "mapping", "=", "$", "this", "->", "getMappingForAttribute", "(", "$", "args", "->", "get", "(", "'column'", ")", ")...
Custom query handler for querying mapped attributes. @param \Sofa\Eloquence\Builder $query @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @return mixed
[ "Custom", "query", "handler", "for", "querying", "mapped", "attributes", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L67-L78
41,326
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedSelect
protected function mappedSelect(Builder $query, ArgumentBag $args) { $columns = $args->get('columns'); foreach ($columns as $key => $column) { list($column, $as) = $this->extractColumnAlias($column); // Each mapped column will be selected appropriately. If it's alias // then prefix it with current table and use original field name // otherwise join required mapped tables and select the field. if ($this->hasMapping($column)) { $mapping = $this->getMappingForAttribute($column); if ($this->relationMapping($mapping)) { list($target, $mapped) = $this->parseMappedColumn($mapping); $table = $this->joinMapped($query, $target); } else { list($table, $mapped) = [$this->getTable(), $mapping]; } $columns[$key] = "{$table}.{$mapped}"; if ($as !== $column) { $columns[$key] .= " as {$as}"; } // For non mapped columns present on this table we will simply // add the prefix, in order to avoid any column collisions, // that are likely to happen when we are joining tables. } elseif ($this->hasColumn($column)) { $columns[$key] = "{$this->getTable()}.{$column}"; } } $args->set('columns', $columns); }
php
protected function mappedSelect(Builder $query, ArgumentBag $args) { $columns = $args->get('columns'); foreach ($columns as $key => $column) { list($column, $as) = $this->extractColumnAlias($column); // Each mapped column will be selected appropriately. If it's alias // then prefix it with current table and use original field name // otherwise join required mapped tables and select the field. if ($this->hasMapping($column)) { $mapping = $this->getMappingForAttribute($column); if ($this->relationMapping($mapping)) { list($target, $mapped) = $this->parseMappedColumn($mapping); $table = $this->joinMapped($query, $target); } else { list($table, $mapped) = [$this->getTable(), $mapping]; } $columns[$key] = "{$table}.{$mapped}"; if ($as !== $column) { $columns[$key] .= " as {$as}"; } // For non mapped columns present on this table we will simply // add the prefix, in order to avoid any column collisions, // that are likely to happen when we are joining tables. } elseif ($this->hasColumn($column)) { $columns[$key] = "{$this->getTable()}.{$column}"; } } $args->set('columns', $columns); }
[ "protected", "function", "mappedSelect", "(", "Builder", "$", "query", ",", "ArgumentBag", "$", "args", ")", "{", "$", "columns", "=", "$", "args", "->", "get", "(", "'columns'", ")", ";", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", ...
Adjust mapped columns for select statement. @param \Sofa\Eloquence\Builder $query @param \Sofa\Hookable\Contracts\ArgumentBag $args @return void
[ "Adjust", "mapped", "columns", "for", "select", "statement", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L87-L123
41,327
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedRelationQuery
protected function mappedRelationQuery($query, $method, ArgumentBag $args, $mapping) { list($target, $column) = $this->parseMappedColumn($mapping); if (in_array($method, ['pluck', 'value', 'aggregate', 'orderBy', 'lists'])) { return $this->mappedJoinQuery($query, $method, $args, $target, $column); } return $this->mappedHasQuery($query, $method, $args, $target, $column); }
php
protected function mappedRelationQuery($query, $method, ArgumentBag $args, $mapping) { list($target, $column) = $this->parseMappedColumn($mapping); if (in_array($method, ['pluck', 'value', 'aggregate', 'orderBy', 'lists'])) { return $this->mappedJoinQuery($query, $method, $args, $target, $column); } return $this->mappedHasQuery($query, $method, $args, $target, $column); }
[ "protected", "function", "mappedRelationQuery", "(", "$", "query", ",", "$", "method", ",", "ArgumentBag", "$", "args", ",", "$", "mapping", ")", "{", "list", "(", "$", "target", ",", "$", "column", ")", "=", "$", "this", "->", "parseMappedColumn", "(", ...
Handle querying relational mappings. @param \Sofa\Eloquence\Builder $query @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $mapping @return mixed
[ "Handle", "querying", "relational", "mappings", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L134-L143
41,328
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.orderByMapped
protected function orderByMapped(Builder $query, ArgumentBag $args, $table, $column, $target) { $query->with($target)->getQuery()->orderBy("{$table}.{$column}", $args->get('direction')); return $query; }
php
protected function orderByMapped(Builder $query, ArgumentBag $args, $table, $column, $target) { $query->with($target)->getQuery()->orderBy("{$table}.{$column}", $args->get('direction')); return $query; }
[ "protected", "function", "orderByMapped", "(", "Builder", "$", "query", ",", "ArgumentBag", "$", "args", ",", "$", "table", ",", "$", "column", ",", "$", "target", ")", "{", "$", "query", "->", "with", "(", "$", "target", ")", "->", "getQuery", "(", ...
Order query by mapped attribute. @param \Sofa\Eloquence\Builder $query @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $table @param string $column @param string $target @return \Sofa\Eloquence\Builder
[ "Order", "query", "by", "mapped", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L178-L183
41,329
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.pluckMapped
protected function pluckMapped(Builder $query, ArgumentBag $args, $table, $column) { $query->select("{$table}.{$column}"); if (!is_null($args->get('key'))) { $this->mappedSelectListsKey($query, $args->get('key')); } $args->set('column', $column); return $query->callParent('pluck', $args->all()); }
php
protected function pluckMapped(Builder $query, ArgumentBag $args, $table, $column) { $query->select("{$table}.{$column}"); if (!is_null($args->get('key'))) { $this->mappedSelectListsKey($query, $args->get('key')); } $args->set('column', $column); return $query->callParent('pluck', $args->all()); }
[ "protected", "function", "pluckMapped", "(", "Builder", "$", "query", ",", "ArgumentBag", "$", "args", ",", "$", "table", ",", "$", "column", ")", "{", "$", "query", "->", "select", "(", "\"{$table}.{$column}\"", ")", ";", "if", "(", "!", "is_null", "(",...
Get an array with the values of given mapped attribute. @param \Sofa\Eloquence\Builder $query @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $table @param string $column @return array
[ "Get", "an", "array", "with", "the", "values", "of", "given", "mapped", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L207-L218
41,330
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedSelectListsKey
protected function mappedSelectListsKey(Builder $query, $key) { if ($this->hasColumn($key)) { return $query->addSelect($this->getTable() . '.' . $key); } return $query->addSelect($key); }
php
protected function mappedSelectListsKey(Builder $query, $key) { if ($this->hasColumn($key)) { return $query->addSelect($this->getTable() . '.' . $key); } return $query->addSelect($key); }
[ "protected", "function", "mappedSelectListsKey", "(", "Builder", "$", "query", ",", "$", "key", ")", "{", "if", "(", "$", "this", "->", "hasColumn", "(", "$", "key", ")", ")", "{", "return", "$", "query", "->", "addSelect", "(", "$", "this", "->", "g...
Add select clause for key of the list array. @param \Sofa\Eloquence\Builder $query @param string $key @return \Sofa\Eloquence\Builder
[ "Add", "select", "clause", "for", "key", "of", "the", "list", "array", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L227-L234
41,331
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.alreadyJoined
protected function alreadyJoined(Builder $query, $table) { $joined = Arr::pluck((array) $query->getQuery()->joins, 'table'); return in_array($table, $joined); }
php
protected function alreadyJoined(Builder $query, $table) { $joined = Arr::pluck((array) $query->getQuery()->joins, 'table'); return in_array($table, $joined); }
[ "protected", "function", "alreadyJoined", "(", "Builder", "$", "query", ",", "$", "table", ")", "{", "$", "joined", "=", "Arr", "::", "pluck", "(", "(", "array", ")", "$", "query", "->", "getQuery", "(", ")", "->", "joins", ",", "'table'", ")", ";", ...
Determine whether given table has been already joined. @param \Sofa\Eloquence\Builder $query @param string $table @return boolean
[ "Determine", "whether", "given", "table", "has", "been", "already", "joined", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L299-L304
41,332
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getJoinKeys
protected function getJoinKeys(Relation $relation) { if ($relation instanceof HasOne || $relation instanceof MorphOne) { return [$relation->getQualifiedForeignKeyName(), $relation->getQualifiedParentKeyName()]; } if ($relation instanceof BelongsTo && !$relation instanceof MorphTo) { return [$relation->getQualifiedForeignKey(), $relation->getQualifiedOwnerKeyName()]; } $class = get_class($relation); throw new LogicException( "Only HasOne, MorphOne and BelongsTo mappings can be queried. {$class} given." ); }
php
protected function getJoinKeys(Relation $relation) { if ($relation instanceof HasOne || $relation instanceof MorphOne) { return [$relation->getQualifiedForeignKeyName(), $relation->getQualifiedParentKeyName()]; } if ($relation instanceof BelongsTo && !$relation instanceof MorphTo) { return [$relation->getQualifiedForeignKey(), $relation->getQualifiedOwnerKeyName()]; } $class = get_class($relation); throw new LogicException( "Only HasOne, MorphOne and BelongsTo mappings can be queried. {$class} given." ); }
[ "protected", "function", "getJoinKeys", "(", "Relation", "$", "relation", ")", "{", "if", "(", "$", "relation", "instanceof", "HasOne", "||", "$", "relation", "instanceof", "MorphOne", ")", "{", "return", "[", "$", "relation", "->", "getQualifiedForeignKeyName",...
Get the keys from relation in order to join the table. @param \Illuminate\Database\Eloquent\Relations\Relation $relation @return array @throws \LogicException
[ "Get", "the", "keys", "from", "relation", "in", "order", "to", "join", "the", "table", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L314-L329
41,333
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mappedHasQuery
protected function mappedHasQuery(Builder $query, $method, ArgumentBag $args, $target, $column) { $boolean = $this->getMappedBoolean($args); $operator = $this->getMappedOperator($method, $args); $args->set('column', $column); return $query ->has($target, $operator, 1, $boolean, $this->getMappedWhereConstraint($method, $args)) ->with($target); }
php
protected function mappedHasQuery(Builder $query, $method, ArgumentBag $args, $target, $column) { $boolean = $this->getMappedBoolean($args); $operator = $this->getMappedOperator($method, $args); $args->set('column', $column); return $query ->has($target, $operator, 1, $boolean, $this->getMappedWhereConstraint($method, $args)) ->with($target); }
[ "protected", "function", "mappedHasQuery", "(", "Builder", "$", "query", ",", "$", "method", ",", "ArgumentBag", "$", "args", ",", "$", "target", ",", "$", "column", ")", "{", "$", "boolean", "=", "$", "this", "->", "getMappedBoolean", "(", "$", "args", ...
Add whereHas subquery on the mapped attribute relation. @param \Sofa\Eloquence\Builder $query @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @param string $target @param string $column @return \Sofa\Eloquence\Builder
[ "Add", "whereHas", "subquery", "on", "the", "mapped", "attribute", "relation", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L354-L365
41,334
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getMappedWhereConstraint
protected function getMappedWhereConstraint($method, ArgumentBag $args) { return function ($query) use ($method, $args) { call_user_func_array([$query, $method], $args->all()); }; }
php
protected function getMappedWhereConstraint($method, ArgumentBag $args) { return function ($query) use ($method, $args) { call_user_func_array([$query, $method], $args->all()); }; }
[ "protected", "function", "getMappedWhereConstraint", "(", "$", "method", ",", "ArgumentBag", "$", "args", ")", "{", "return", "function", "(", "$", "query", ")", "use", "(", "$", "method", ",", "$", "args", ")", "{", "call_user_func_array", "(", "[", "$", ...
Get the relation constraint closure. @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @return \Closure
[ "Get", "the", "relation", "constraint", "closure", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L374-L379
41,335
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getMappedOperator
protected function getMappedOperator($method, ArgumentBag $args) { if ($not = $args->get('not')) { $args->set('not', false); } if ($null = $this->isWhereNull($method, $args)) { $args->set('not', true); } return ($not ^ $null) ? '<' : '>='; }
php
protected function getMappedOperator($method, ArgumentBag $args) { if ($not = $args->get('not')) { $args->set('not', false); } if ($null = $this->isWhereNull($method, $args)) { $args->set('not', true); } return ($not ^ $null) ? '<' : '>='; }
[ "protected", "function", "getMappedOperator", "(", "$", "method", ",", "ArgumentBag", "$", "args", ")", "{", "if", "(", "$", "not", "=", "$", "args", "->", "get", "(", "'not'", ")", ")", "{", "$", "args", "->", "set", "(", "'not'", ",", "false", ")...
Determine the operator for count relation query and set 'not' appropriately. @param string $method @param \Sofa\Hookable\Contracts\ArgumentBag $args @return string
[ "Determine", "the", "operator", "for", "count", "relation", "query", "and", "set", "not", "appropriately", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L403-L414
41,336
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.hasMapping
public function hasMapping($key) { if (is_null($this->mappedAttributes)) { $this->parseMappings(); } return array_key_exists((string) $key, $this->mappedAttributes); }
php
public function hasMapping($key) { if (is_null($this->mappedAttributes)) { $this->parseMappings(); } return array_key_exists((string) $key, $this->mappedAttributes); }
[ "public", "function", "hasMapping", "(", "$", "key", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "mappedAttributes", ")", ")", "{", "$", "this", "->", "parseMappings", "(", ")", ";", "}", "return", "array_key_exists", "(", "(", "string", ")...
Determine whether a mapping exists for an attribute. @param string $key @return boolean
[ "Determine", "whether", "a", "mapping", "exists", "for", "an", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L446-L453
41,337
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.parseMappings
protected function parseMappings() { $this->mappedAttributes = []; foreach ($this->getMaps() as $attribute => $mapping) { if (is_array($mapping)) { $this->parseImplicitMapping($mapping, $attribute); } else { $this->mappedAttributes[$attribute] = $mapping; } } }
php
protected function parseMappings() { $this->mappedAttributes = []; foreach ($this->getMaps() as $attribute => $mapping) { if (is_array($mapping)) { $this->parseImplicitMapping($mapping, $attribute); } else { $this->mappedAttributes[$attribute] = $mapping; } } }
[ "protected", "function", "parseMappings", "(", ")", "{", "$", "this", "->", "mappedAttributes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getMaps", "(", ")", "as", "$", "attribute", "=>", "$", "mapping", ")", "{", "if", "(", "is_array", ...
Parse defined mappings into flat array. @return void
[ "Parse", "defined", "mappings", "into", "flat", "array", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L460-L471
41,338
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.mapAttribute
protected function mapAttribute($key) { $segments = explode('.', $this->getMappingForAttribute($key)); return $this->getTarget($this, $segments); }
php
protected function mapAttribute($key) { $segments = explode('.', $this->getMappingForAttribute($key)); return $this->getTarget($this, $segments); }
[ "protected", "function", "mapAttribute", "(", "$", "key", ")", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "this", "->", "getMappingForAttribute", "(", "$", "key", ")", ")", ";", "return", "$", "this", "->", "getTarget", "(", "$", "this...
Map an attribute to a value. @param string $key @return mixed
[ "Map", "an", "attribute", "to", "a", "value", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L493-L498
41,339
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.getTarget
protected function getTarget($target, array $segments) { foreach ($segments as $segment) { if (!$target) { return; } $target = $target->{$segment}; } return $target; }
php
protected function getTarget($target, array $segments) { foreach ($segments as $segment) { if (!$target) { return; } $target = $target->{$segment}; } return $target; }
[ "protected", "function", "getTarget", "(", "$", "target", ",", "array", "$", "segments", ")", "{", "foreach", "(", "$", "segments", "as", "$", "segment", ")", "{", "if", "(", "!", "$", "target", ")", "{", "return", ";", "}", "$", "target", "=", "$"...
Get mapped value. @param \Illuminate\Database\Eloquent\Model $target @param array $segments @return mixed
[ "Get", "mapped", "value", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L507-L518
41,340
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.setMappedAttribute
protected function setMappedAttribute($key, $value) { $segments = explode('.', $this->getMappingForAttribute($key)); $attribute = array_pop($segments); if ($target = $this->getTarget($this, $segments)) { $this->addTargetToSave($target); $target->{$attribute} = $value; } }
php
protected function setMappedAttribute($key, $value) { $segments = explode('.', $this->getMappingForAttribute($key)); $attribute = array_pop($segments); if ($target = $this->getTarget($this, $segments)) { $this->addTargetToSave($target); $target->{$attribute} = $value; } }
[ "protected", "function", "setMappedAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "$", "segments", "=", "explode", "(", "'.'", ",", "$", "this", "->", "getMappingForAttribute", "(", "$", "key", ")", ")", ";", "$", "attribute", "=", "array_pop"...
Set value of a mapped attribute. @param string $key @param mixed $value
[ "Set", "value", "of", "a", "mapped", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L526-L537
41,341
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.saveMapped
protected function saveMapped() { foreach (array_unique($this->targetsToSave) as $target) { $target->save(); } $this->targetsToSave = []; }
php
protected function saveMapped() { foreach (array_unique($this->targetsToSave) as $target) { $target->save(); } $this->targetsToSave = []; }
[ "protected", "function", "saveMapped", "(", ")", "{", "foreach", "(", "array_unique", "(", "$", "this", "->", "targetsToSave", ")", "as", "$", "target", ")", "{", "$", "target", "->", "save", "(", ")", ";", "}", "$", "this", "->", "targetsToSave", "=",...
Save mapped relations. @return void
[ "Save", "mapped", "relations", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L556-L563
41,342
jarektkaczyk/eloquence-mappable
src/Mappable.php
Mappable.forget
protected function forget($key) { $mapping = $this->getMappingForAttribute($key); list($target, $attribute) = $this->parseMappedColumn($mapping); $target = $target ? $this->getTarget($this, explode('.', $target)) : $this; unset($target->{$attribute}); }
php
protected function forget($key) { $mapping = $this->getMappingForAttribute($key); list($target, $attribute) = $this->parseMappedColumn($mapping); $target = $target ? $this->getTarget($this, explode('.', $target)) : $this; unset($target->{$attribute}); }
[ "protected", "function", "forget", "(", "$", "key", ")", "{", "$", "mapping", "=", "$", "this", "->", "getMappingForAttribute", "(", "$", "key", ")", ";", "list", "(", "$", "target", ",", "$", "attribute", ")", "=", "$", "this", "->", "parseMappedColum...
Unset mapped attribute. @param string $key @return void
[ "Unset", "mapped", "attribute", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable.php#L571-L580
41,343
shevabam/recaptcha
src/reCAPTCHA.php
reCAPTCHA.setRemoteIp
public function setRemoteIp($ip = null) { if (!is_null($ip)) $this->remoteIp = $ip; else $this->remoteIp = $_SERVER['REMOTE_ADDR']; return $this; }
php
public function setRemoteIp($ip = null) { if (!is_null($ip)) $this->remoteIp = $ip; else $this->remoteIp = $_SERVER['REMOTE_ADDR']; return $this; }
[ "public", "function", "setRemoteIp", "(", "$", "ip", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "ip", ")", ")", "$", "this", "->", "remoteIp", "=", "$", "ip", ";", "else", "$", "this", "->", "remoteIp", "=", "$", "_SERVER", "[", ...
Set remote IP address @param string $ip @return object
[ "Set", "remote", "IP", "address" ]
e94090ee7237b5e4ddc34c6f26dad43d27816985
https://github.com/shevabam/recaptcha/blob/e94090ee7237b5e4ddc34c6f26dad43d27816985/src/reCAPTCHA.php#L150-L158
41,344
shevabam/recaptcha
src/reCAPTCHA.php
reCAPTCHA.getScript
public function getScript() { $data = array(); if (!is_null($this->language)) $data = array('hl' => $this->language); return '<script src="https://www.google.com/recaptcha/api.js?'.http_build_query($data).'"></script>'; }
php
public function getScript() { $data = array(); if (!is_null($this->language)) $data = array('hl' => $this->language); return '<script src="https://www.google.com/recaptcha/api.js?'.http_build_query($data).'"></script>'; }
[ "public", "function", "getScript", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "language", ")", ")", "$", "data", "=", "array", "(", "'hl'", "=>", "$", "this", "->", "language", ")",...
Generate the JS code of the captcha @return string
[ "Generate", "the", "JS", "code", "of", "the", "captcha" ]
e94090ee7237b5e4ddc34c6f26dad43d27816985
https://github.com/shevabam/recaptcha/blob/e94090ee7237b5e4ddc34c6f26dad43d27816985/src/reCAPTCHA.php#L234-L241
41,345
shevabam/recaptcha
src/reCAPTCHA.php
reCAPTCHA.getHtml
public function getHtml() { if (!empty($this->siteKey)) { $data = 'data-sitekey="'.$this->siteKey.'"'; if (!is_null($this->theme)) $data .= ' data-theme="'.$this->theme.'"'; if (!is_null($this->type)) $data .= ' data-type="'.$this->type.'"'; if (!is_null($this->size)) $data .= ' data-size="'.$this->size.'"'; return '<div class="g-recaptcha" '.$data.'></div>'; } }
php
public function getHtml() { if (!empty($this->siteKey)) { $data = 'data-sitekey="'.$this->siteKey.'"'; if (!is_null($this->theme)) $data .= ' data-theme="'.$this->theme.'"'; if (!is_null($this->type)) $data .= ' data-type="'.$this->type.'"'; if (!is_null($this->size)) $data .= ' data-size="'.$this->size.'"'; return '<div class="g-recaptcha" '.$data.'></div>'; } }
[ "public", "function", "getHtml", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "siteKey", ")", ")", "{", "$", "data", "=", "'data-sitekey=\"'", ".", "$", "this", "->", "siteKey", ".", "'\"'", ";", "if", "(", "!", "is_null", "(", ...
Generate the HTML code block for the captcha @return string
[ "Generate", "the", "HTML", "code", "block", "for", "the", "captcha" ]
e94090ee7237b5e4ddc34c6f26dad43d27816985
https://github.com/shevabam/recaptcha/blob/e94090ee7237b5e4ddc34c6f26dad43d27816985/src/reCAPTCHA.php#L248-L265
41,346
shevabam/recaptcha
src/reCAPTCHA.php
reCAPTCHA.isValid
public function isValid($response) { if (is_null($this->secretKey)) throw new \Exception('You must set your secret key'); if (empty($response)) { $this->errorCodes = array('internal-empty-response'); return false; } $params = array( 'secret' => $this->secretKey, 'response' => $response, 'remoteip' => $this->remoteIp, ); $url = self::VERIFY_URL.'?'.http_build_query($params); if (function_exists('curl_version')) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, $this->verifyTimeout); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); } else { $response = file_get_contents($url); } if (empty($response) || is_null($response) || !$response) { return false; } $json = json_decode($response, true); if (isset($json['error-codes'])) { $this->errorCodes = $json['error-codes']; } return $json['success']; }
php
public function isValid($response) { if (is_null($this->secretKey)) throw new \Exception('You must set your secret key'); if (empty($response)) { $this->errorCodes = array('internal-empty-response'); return false; } $params = array( 'secret' => $this->secretKey, 'response' => $response, 'remoteip' => $this->remoteIp, ); $url = self::VERIFY_URL.'?'.http_build_query($params); if (function_exists('curl_version')) { $curl = curl_init($url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, $this->verifyTimeout); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); } else { $response = file_get_contents($url); } if (empty($response) || is_null($response) || !$response) { return false; } $json = json_decode($response, true); if (isset($json['error-codes'])) { $this->errorCodes = $json['error-codes']; } return $json['success']; }
[ "public", "function", "isValid", "(", "$", "response", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "secretKey", ")", ")", "throw", "new", "\\", "Exception", "(", "'You must set your secret key'", ")", ";", "if", "(", "empty", "(", "$", "respo...
Checks the code given by the captcha @param string $response Response code after submitting form (usually $_POST['g-recaptcha-response']) @return bool
[ "Checks", "the", "code", "given", "by", "the", "captcha" ]
e94090ee7237b5e4ddc34c6f26dad43d27816985
https://github.com/shevabam/recaptcha/blob/e94090ee7237b5e4ddc34c6f26dad43d27816985/src/reCAPTCHA.php#L273-L320
41,347
shevabam/recaptcha
src/reCAPTCHA.php
reCAPTCHA.getErrorCodes
public function getErrorCodes() { $errors = array(); if (count($this->errorCodes) > 0) { foreach ($this->errorCodes as $error) { switch ($error) { case 'timeout-or-duplicate': $errors[] = array( 'code' => $error, 'name' => 'Timeout or duplicate.', ); break; case 'missing-input-secret': $errors[] = array( 'code' => $error, 'name' => 'The secret parameter is missing.', ); break; case 'invalid-input-secret': $errors[] = array( 'code' => $error, 'name' => 'The secret parameter is invalid or malformed.', ); break; case 'missing-input-response': $errors[] = array( 'code' => $error, 'name' => 'The response parameter is missing.', ); break; case 'invalid-input-response': $errors[] = array( 'code' => $error, 'name' => 'The response parameter is invalid or malformed.', ); break; case 'bad-request': $errors[] = array( 'code' => $error, 'name' => 'The request is invalid or malformed.', ); break; case 'internal-empty-response': $errors[] = array( 'code' => $error, 'name' => 'The recaptcha response is required.', ); break; default: $errors[] = array( 'code' => $error, 'name' => $error, ); } } } return $errors; }
php
public function getErrorCodes() { $errors = array(); if (count($this->errorCodes) > 0) { foreach ($this->errorCodes as $error) { switch ($error) { case 'timeout-or-duplicate': $errors[] = array( 'code' => $error, 'name' => 'Timeout or duplicate.', ); break; case 'missing-input-secret': $errors[] = array( 'code' => $error, 'name' => 'The secret parameter is missing.', ); break; case 'invalid-input-secret': $errors[] = array( 'code' => $error, 'name' => 'The secret parameter is invalid or malformed.', ); break; case 'missing-input-response': $errors[] = array( 'code' => $error, 'name' => 'The response parameter is missing.', ); break; case 'invalid-input-response': $errors[] = array( 'code' => $error, 'name' => 'The response parameter is invalid or malformed.', ); break; case 'bad-request': $errors[] = array( 'code' => $error, 'name' => 'The request is invalid or malformed.', ); break; case 'internal-empty-response': $errors[] = array( 'code' => $error, 'name' => 'The recaptcha response is required.', ); break; default: $errors[] = array( 'code' => $error, 'name' => $error, ); } } } return $errors; }
[ "public", "function", "getErrorCodes", "(", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "this", "->", "errorCodes", ")", ">", "0", ")", "{", "foreach", "(", "$", "this", "->", "errorCodes", "as", "$", "error"...
Returns the errors encountered @return array Errors code and name
[ "Returns", "the", "errors", "encountered" ]
e94090ee7237b5e4ddc34c6f26dad43d27816985
https://github.com/shevabam/recaptcha/blob/e94090ee7237b5e4ddc34c6f26dad43d27816985/src/reCAPTCHA.php#L327-L396
41,348
jarektkaczyk/eloquence-mappable
src/Mappable/Hooks.php
Hooks.queryHook
public function queryHook() { return function ($next, $query, $bag) { $method = $bag->get('method'); $args = $bag->get('args'); $column = $args->get('column'); if ($this->hasMapping($column)) { return call_user_func_array([$this, 'mappedQuery'], [$query, $method, $args]); } if (in_array($method, ['select', 'addSelect'])) { call_user_func_array([$this, 'mappedSelect'], [$query, $args]); } return $next($query, $bag); }; }
php
public function queryHook() { return function ($next, $query, $bag) { $method = $bag->get('method'); $args = $bag->get('args'); $column = $args->get('column'); if ($this->hasMapping($column)) { return call_user_func_array([$this, 'mappedQuery'], [$query, $method, $args]); } if (in_array($method, ['select', 'addSelect'])) { call_user_func_array([$this, 'mappedSelect'], [$query, $args]); } return $next($query, $bag); }; }
[ "public", "function", "queryHook", "(", ")", "{", "return", "function", "(", "$", "next", ",", "$", "query", ",", "$", "bag", ")", "{", "$", "method", "=", "$", "bag", "->", "get", "(", "'method'", ")", ";", "$", "args", "=", "$", "bag", "->", ...
Register hook on customWhere method. @codeCoverageIgnore @return \Closure
[ "Register", "hook", "on", "customWhere", "method", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable/Hooks.php#L20-L37
41,349
jarektkaczyk/eloquence-mappable
src/Mappable/Hooks.php
Hooks.__issetHook
public function __issetHook() { return function ($next, $isset, $args) { $key = $args->get('key'); if (!$isset && $this->hasMapping($key)) { return (bool) $this->mapAttribute($key); } return $next($isset, $args); }; }
php
public function __issetHook() { return function ($next, $isset, $args) { $key = $args->get('key'); if (!$isset && $this->hasMapping($key)) { return (bool) $this->mapAttribute($key); } return $next($isset, $args); }; }
[ "public", "function", "__issetHook", "(", ")", "{", "return", "function", "(", "$", "next", ",", "$", "isset", ",", "$", "args", ")", "{", "$", "key", "=", "$", "args", "->", "get", "(", "'key'", ")", ";", "if", "(", "!", "$", "isset", "&&", "$...
Register hook on isset call. @codeCoverageIgnore @return \Closure
[ "Register", "hook", "on", "isset", "call", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable/Hooks.php#L62-L73
41,350
jarektkaczyk/eloquence-mappable
src/Mappable/Hooks.php
Hooks.__unsetHook
public function __unsetHook() { return function ($next, $value, $args) { $key = $args->get('key'); if ($this->hasMapping($key)) { return $this->forget($key); } return $next($value, $args); }; }
php
public function __unsetHook() { return function ($next, $value, $args) { $key = $args->get('key'); if ($this->hasMapping($key)) { return $this->forget($key); } return $next($value, $args); }; }
[ "public", "function", "__unsetHook", "(", ")", "{", "return", "function", "(", "$", "next", ",", "$", "value", ",", "$", "args", ")", "{", "$", "key", "=", "$", "args", "->", "get", "(", "'key'", ")", ";", "if", "(", "$", "this", "->", "hasMappin...
Register hook on unset call. @codeCoverageIgnore @return \Closure
[ "Register", "hook", "on", "unset", "call", "." ]
eda05a2ad6483712ccdc26b3415716783305578e
https://github.com/jarektkaczyk/eloquence-mappable/blob/eda05a2ad6483712ccdc26b3415716783305578e/src/Mappable/Hooks.php#L82-L93
41,351
czim/laravel-cms-core
src/Http/Middleware/VerifyCsrfToken.php
VerifyCsrfToken.handle
public function handle($request, Closure $next) { try { return parent::handle($request, $next); } catch (TokenMismatchException $e) { if ( ! $request->ajax() && ! $request->wantsJson()) { return redirect()->back()->withInput()->with('token', csrf_token()); } return response('CSRF Token Mismatch', 500); } }
php
public function handle($request, Closure $next) { try { return parent::handle($request, $next); } catch (TokenMismatchException $e) { if ( ! $request->ajax() && ! $request->wantsJson()) { return redirect()->back()->withInput()->with('token', csrf_token()); } return response('CSRF Token Mismatch', 500); } }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ")", "{", "try", "{", "return", "parent", "::", "handle", "(", "$", "request", ",", "$", "next", ")", ";", "}", "catch", "(", "TokenMismatchException", "$", "e", ")", "...
Overridden to catch exception and redirect to login instead. {@inheritdoc}
[ "Overridden", "to", "catch", "exception", "and", "redirect", "to", "login", "instead", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Http/Middleware/VerifyCsrfToken.php#L27-L41
41,352
czim/laravel-cms-core
src/Exceptions/Handler.php
Handler.getStatusCodeFromException
protected function getStatusCodeFromException(Exception $exception) { if ($exception instanceof OAuthException) { return $exception->httpStatusCode; } if ($exception instanceof HttpResponseException) { return $exception->getResponse()->getStatusCode(); } if ($exception instanceof ValidationException) { return 422; } if (method_exists($exception, 'getStatusCode')) { return $exception->getStatusCode(); } return 500; }
php
protected function getStatusCodeFromException(Exception $exception) { if ($exception instanceof OAuthException) { return $exception->httpStatusCode; } if ($exception instanceof HttpResponseException) { return $exception->getResponse()->getStatusCode(); } if ($exception instanceof ValidationException) { return 422; } if (method_exists($exception, 'getStatusCode')) { return $exception->getStatusCode(); } return 500; }
[ "protected", "function", "getStatusCodeFromException", "(", "Exception", "$", "exception", ")", "{", "if", "(", "$", "exception", "instanceof", "OAuthException", ")", "{", "return", "$", "exception", "->", "httpStatusCode", ";", "}", "if", "(", "$", "exception",...
Returns the status code for a given exception. @param Exception $exception @return int
[ "Returns", "the", "status", "code", "for", "a", "given", "exception", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Exceptions/Handler.php#L141-L160
41,353
czim/laravel-cms-core
src/Menu/MenuRepository.php
MenuRepository.writeCache
public function writeCache() { list($layout, $index) = $this->interpretMenuData(); $this->getFileSystem()->put( $this->getCachePath(), $this->serializedInformationForCache($layout, $index) ); return $this; }
php
public function writeCache() { list($layout, $index) = $this->interpretMenuData(); $this->getFileSystem()->put( $this->getCachePath(), $this->serializedInformationForCache($layout, $index) ); return $this; }
[ "public", "function", "writeCache", "(", ")", "{", "list", "(", "$", "layout", ",", "$", "index", ")", "=", "$", "this", "->", "interpretMenuData", "(", ")", ";", "$", "this", "->", "getFileSystem", "(", ")", "->", "put", "(", "$", "this", "->", "g...
Writes menu data cache. @return $this
[ "Writes", "menu", "data", "cache", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuRepository.php#L144-L154
41,354
czim/laravel-cms-core
src/Menu/MenuRepository.php
MenuRepository.interpretMenuData
protected function interpretMenuData() { $layout = $this->configInterpreter->interpretLayout($this->core->moduleConfig('menu.layout', [])); return [ $layout, $this->permissionsFilter->buildPermissionsIndex($layout) ]; }
php
protected function interpretMenuData() { $layout = $this->configInterpreter->interpretLayout($this->core->moduleConfig('menu.layout', [])); return [ $layout, $this->permissionsFilter->buildPermissionsIndex($layout) ]; }
[ "protected", "function", "interpretMenuData", "(", ")", "{", "$", "layout", "=", "$", "this", "->", "configInterpreter", "->", "interpretLayout", "(", "$", "this", "->", "core", "->", "moduleConfig", "(", "'menu.layout'", ",", "[", "]", ")", ")", ";", "ret...
Interprets and returns menu data. @return array [ layout, permissionsIndex ]
[ "Interprets", "and", "returns", "menu", "data", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuRepository.php#L191-L199
41,355
czim/laravel-cms-core
src/Console/Commands/MigrateInstallCommand.php
MigrateInstallCommand.handle
public function handle() { $this->repository->setSource($this->determineConnection()); $this->repository->createRepository(); $this->info('CMS migration table created successfully.'); }
php
public function handle() { $this->repository->setSource($this->determineConnection()); $this->repository->createRepository(); $this->info('CMS migration table created successfully.'); }
[ "public", "function", "handle", "(", ")", "{", "$", "this", "->", "repository", "->", "setSource", "(", "$", "this", "->", "determineConnection", "(", ")", ")", ";", "$", "this", "->", "repository", "->", "createRepository", "(", ")", ";", "$", "this", ...
Overridden for setSource parameter connection only. @inheritdoc
[ "Overridden", "for", "setSource", "parameter", "connection", "only", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Console/Commands/MigrateInstallCommand.php#L39-L46
41,356
czim/laravel-cms-core
src/Providers/CmsCoreServiceProvider.php
CmsCoreServiceProvider.registerBootChecker
protected function registerBootChecker() { $this->app->singleton(Component::BOOTCHECKER, $this->getCoreConfig('bindings.' . Component::BOOTCHECKER)); $this->app->bind(BootCheckerInterface::class, Component::BOOTCHECKER); return $this; }
php
protected function registerBootChecker() { $this->app->singleton(Component::BOOTCHECKER, $this->getCoreConfig('bindings.' . Component::BOOTCHECKER)); $this->app->bind(BootCheckerInterface::class, Component::BOOTCHECKER); return $this; }
[ "protected", "function", "registerBootChecker", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "Component", "::", "BOOTCHECKER", ",", "$", "this", "->", "getCoreConfig", "(", "'bindings.'", ".", "Component", "::", "BOOTCHECKER", ")", ")", "...
Registers required checker to facilitate determining whether the CMS should be registered or booted. @return $this
[ "Registers", "required", "checker", "to", "facilitate", "determining", "whether", "the", "CMS", "should", "be", "registered", "or", "booted", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/CmsCoreServiceProvider.php#L93-L100
41,357
czim/laravel-cms-core
src/Providers/CmsCoreServiceProvider.php
CmsCoreServiceProvider.registerCoreComponents
protected function registerCoreComponents() { $this->app->singleton(Component::CORE, $this->getCoreConfig('bindings.' . Component::CORE)); $this->app->singleton(Component::AUTH, $this->getCoreConfig('bindings.' . Component::AUTH)); $this->app->singleton(Component::MODULES, $this->getCoreConfig('bindings.' . Component::MODULES)); $this->app->singleton(Component::CACHE, $this->getCoreConfig('bindings.' . Component::CACHE)); $this->app->singleton(Component::API, $this->getCoreConfig('bindings.' . Component::API)); $this->app->singleton(Component::MENU, $this->getCoreConfig('bindings.' . Component::MENU)); $this->app->singleton(Component::ACL, $this->getCoreConfig('bindings.' . Component::ACL)); $this->app->singleton(Component::NOTIFIER, $this->getCoreConfig('bindings.' . Component::NOTIFIER)); $this->app->singleton(Component::ASSETS, $this->getCoreConfig('bindings.' . Component::ASSETS, AssetManager::class)); $this->app->bind(CoreInterface::class, Component::CORE); $this->app->bind(AuthenticatorInterface::class, Component::AUTH); $this->app->bind(ModuleManagerInterface::class, Component::MODULES); $this->app->bind(CacheInterface::class, Component::CACHE); $this->app->bind(ApiCoreInterface::class, Component::API); $this->app->bind(MenuRepositoryInterface::class, Component::MENU); $this->app->bind(AclRepositoryInterface::class, Component::ACL); $this->app->bind(NotifierInterface::class, Component::NOTIFIER); $this->app->bind(AssetManagerInterface::class, Component::ASSETS); return $this; }
php
protected function registerCoreComponents() { $this->app->singleton(Component::CORE, $this->getCoreConfig('bindings.' . Component::CORE)); $this->app->singleton(Component::AUTH, $this->getCoreConfig('bindings.' . Component::AUTH)); $this->app->singleton(Component::MODULES, $this->getCoreConfig('bindings.' . Component::MODULES)); $this->app->singleton(Component::CACHE, $this->getCoreConfig('bindings.' . Component::CACHE)); $this->app->singleton(Component::API, $this->getCoreConfig('bindings.' . Component::API)); $this->app->singleton(Component::MENU, $this->getCoreConfig('bindings.' . Component::MENU)); $this->app->singleton(Component::ACL, $this->getCoreConfig('bindings.' . Component::ACL)); $this->app->singleton(Component::NOTIFIER, $this->getCoreConfig('bindings.' . Component::NOTIFIER)); $this->app->singleton(Component::ASSETS, $this->getCoreConfig('bindings.' . Component::ASSETS, AssetManager::class)); $this->app->bind(CoreInterface::class, Component::CORE); $this->app->bind(AuthenticatorInterface::class, Component::AUTH); $this->app->bind(ModuleManagerInterface::class, Component::MODULES); $this->app->bind(CacheInterface::class, Component::CACHE); $this->app->bind(ApiCoreInterface::class, Component::API); $this->app->bind(MenuRepositoryInterface::class, Component::MENU); $this->app->bind(AclRepositoryInterface::class, Component::ACL); $this->app->bind(NotifierInterface::class, Component::NOTIFIER); $this->app->bind(AssetManagerInterface::class, Component::ASSETS); return $this; }
[ "protected", "function", "registerCoreComponents", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "Component", "::", "CORE", ",", "$", "this", "->", "getCoreConfig", "(", "'bindings.'", ".", "Component", "::", "CORE", ")", ")", ";", "$", ...
Registers core components for the CMS. @return $this
[ "Registers", "core", "components", "for", "the", "CMS", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/CmsCoreServiceProvider.php#L115-L138
41,358
czim/laravel-cms-core
src/Providers/CmsCoreServiceProvider.php
CmsCoreServiceProvider.registerConfiguredAliases
protected function registerConfiguredAliases() { $aliases = $this->getCoreConfig('aliases', []); if (empty($aliases)) { // @codeCoverageIgnoreStart return $this; // @codeCoverageIgnoreEnd } $aliasLoader = AliasLoader::getInstance(); foreach ($aliases as $alias => $binding) { $aliasLoader->alias($alias, $binding); } return $this; }
php
protected function registerConfiguredAliases() { $aliases = $this->getCoreConfig('aliases', []); if (empty($aliases)) { // @codeCoverageIgnoreStart return $this; // @codeCoverageIgnoreEnd } $aliasLoader = AliasLoader::getInstance(); foreach ($aliases as $alias => $binding) { $aliasLoader->alias($alias, $binding); } return $this; }
[ "protected", "function", "registerConfiguredAliases", "(", ")", "{", "$", "aliases", "=", "$", "this", "->", "getCoreConfig", "(", "'aliases'", ",", "[", "]", ")", ";", "if", "(", "empty", "(", "$", "aliases", ")", ")", "{", "// @codeCoverageIgnoreStart", ...
Registers any aliases defined in the configuration. @return $this
[ "Registers", "any", "aliases", "defined", "in", "the", "configuration", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/CmsCoreServiceProvider.php#L187-L204
41,359
czim/laravel-cms-core
src/Providers/CmsCoreServiceProvider.php
CmsCoreServiceProvider.registerInterfaceBindings
protected function registerInterfaceBindings() { $this->app->singleton(LocaleRepositoryInterface::class, LocaleRepository::class); $this->app->singleton(MenuConfigInterpreterInterface::class, MenuConfigInterpreter::class); $this->app->singleton(MenuModulesInterpreterInterface::class, MenuModulesInterpreter::class); $this->app->singleton(MenuPermissionsFilterInterface::class, MenuPermissionsFilter::class); return $this; }
php
protected function registerInterfaceBindings() { $this->app->singleton(LocaleRepositoryInterface::class, LocaleRepository::class); $this->app->singleton(MenuConfigInterpreterInterface::class, MenuConfigInterpreter::class); $this->app->singleton(MenuModulesInterpreterInterface::class, MenuModulesInterpreter::class); $this->app->singleton(MenuPermissionsFilterInterface::class, MenuPermissionsFilter::class); return $this; }
[ "protected", "function", "registerInterfaceBindings", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "LocaleRepositoryInterface", "::", "class", ",", "LocaleRepository", "::", "class", ")", ";", "$", "this", "->", "app", "->", "singleton", "(...
Registers standard interface bindings. @return $this
[ "Registers", "standard", "interface", "bindings", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/CmsCoreServiceProvider.php#L211-L219
41,360
czim/laravel-cms-core
src/Providers/CmsCoreServiceProvider.php
CmsCoreServiceProvider.registerConsoleCommands
protected function registerConsoleCommands() { $this->app->singleton('cms.commands.core-menu-show', Commands\ShowMenu::class); $this->app->singleton('cms.commands.core-menu-cache', Commands\CacheMenu::class); $this->app->singleton('cms.commands.core-menu-clear', Commands\ClearMenuCache::class); $this->app->singleton('cms.commands.core-modules-show', Commands\ShowModules::class); $this->commands([ 'cms.commands.core-menu-show', 'cms.commands.core-menu-cache', 'cms.commands.core-menu-clear', 'cms.commands.core-modules-show', ]); return $this; }
php
protected function registerConsoleCommands() { $this->app->singleton('cms.commands.core-menu-show', Commands\ShowMenu::class); $this->app->singleton('cms.commands.core-menu-cache', Commands\CacheMenu::class); $this->app->singleton('cms.commands.core-menu-clear', Commands\ClearMenuCache::class); $this->app->singleton('cms.commands.core-modules-show', Commands\ShowModules::class); $this->commands([ 'cms.commands.core-menu-show', 'cms.commands.core-menu-cache', 'cms.commands.core-menu-clear', 'cms.commands.core-modules-show', ]); return $this; }
[ "protected", "function", "registerConsoleCommands", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'cms.commands.core-menu-show'", ",", "Commands", "\\", "ShowMenu", "::", "class", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", ...
Register CMS console commands @return $this
[ "Register", "CMS", "console", "commands" ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/CmsCoreServiceProvider.php#L271-L286
41,361
czim/laravel-cms-core
src/Providers/RouteServiceProvider.php
RouteServiceProvider.buildHomeRoute
protected function buildHomeRoute(Router $router) { $action = $this->normalizeRouteAction($this->getDefaultHomeAction()); // Guarantee that the home route has the expected name $router->get('/', array_set($action, 'as', NamedRoute::HOME)); }
php
protected function buildHomeRoute(Router $router) { $action = $this->normalizeRouteAction($this->getDefaultHomeAction()); // Guarantee that the home route has the expected name $router->get('/', array_set($action, 'as', NamedRoute::HOME)); }
[ "protected", "function", "buildHomeRoute", "(", "Router", "$", "router", ")", "{", "$", "action", "=", "$", "this", "->", "normalizeRouteAction", "(", "$", "this", "->", "getDefaultHomeAction", "(", ")", ")", ";", "// Guarantee that the home route has the expected n...
Builds up route for the home page of the CMS. @param Router $router
[ "Builds", "up", "route", "for", "the", "home", "page", "of", "the", "CMS", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/RouteServiceProvider.php#L111-L117
41,362
czim/laravel-cms-core
src/Providers/RouteServiceProvider.php
RouteServiceProvider.buildRoutesForAuth
protected function buildRoutesForAuth(Router $router) { $auth = $this->core->auth(); $router->group( [ 'prefix' => 'auth', ], function (Router $router) use ($auth) { $router->get('login', $auth->getRouteLoginAction()); $router->post('login', $auth->getRouteLoginPostAction()); $router->get('logout', $auth->getRouteLogoutAction()); $router->get('password/email', $auth->getRoutePasswordEmailGetAction()); $router->post('password/email', $auth->getRoutePasswordEmailPostAction()); $router->get('password/reset/{token?}', $auth->getRoutePasswordResetGetAction()); $router->post('password/reset', $auth->getRoutePasswordResetPostAction()); } ); }
php
protected function buildRoutesForAuth(Router $router) { $auth = $this->core->auth(); $router->group( [ 'prefix' => 'auth', ], function (Router $router) use ($auth) { $router->get('login', $auth->getRouteLoginAction()); $router->post('login', $auth->getRouteLoginPostAction()); $router->get('logout', $auth->getRouteLogoutAction()); $router->get('password/email', $auth->getRoutePasswordEmailGetAction()); $router->post('password/email', $auth->getRoutePasswordEmailPostAction()); $router->get('password/reset/{token?}', $auth->getRoutePasswordResetGetAction()); $router->post('password/reset', $auth->getRoutePasswordResetPostAction()); } ); }
[ "protected", "function", "buildRoutesForAuth", "(", "Router", "$", "router", ")", "{", "$", "auth", "=", "$", "this", "->", "core", "->", "auth", "(", ")", ";", "$", "router", "->", "group", "(", "[", "'prefix'", "=>", "'auth'", ",", "]", ",", "funct...
Builds up routes for authorization in the given router context. @param Router $router
[ "Builds", "up", "routes", "for", "authorization", "in", "the", "given", "router", "context", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/RouteServiceProvider.php#L146-L166
41,363
czim/laravel-cms-core
src/Http/Controllers/Api/MenuController.php
MenuController.transformPresencesForApi
protected function transformPresencesForApi($presences) { $response = []; foreach ($presences as $presence) { $response[] = $this->transformPresenceForApi($presence); } return $response; }
php
protected function transformPresencesForApi($presences) { $response = []; foreach ($presences as $presence) { $response[] = $this->transformPresenceForApi($presence); } return $response; }
[ "protected", "function", "transformPresencesForApi", "(", "$", "presences", ")", "{", "$", "response", "=", "[", "]", ";", "foreach", "(", "$", "presences", "as", "$", "presence", ")", "{", "$", "response", "[", "]", "=", "$", "this", "->", "transformPre...
Transforms menu presence tree for API response. @param Collection|MenuPresenceInterface[] $presences @return array
[ "Transforms", "menu", "presence", "tree", "for", "API", "response", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Http/Controllers/Api/MenuController.php#L54-L63
41,364
czim/laravel-cms-core
src/Support/Localization/LocaleRepository.php
LocaleRepository.getAvailable
public function getAvailable() { // If explicitly set in CMS config, this overrules all else $configLocales = $this->core->config('locale.available'); if (is_array($configLocales)) { return $configLocales; } // Check if the localization package is used, and get locales from it $localizationLocales = $this->getLocalesForMcamaraLocalization(); if ($localizationLocales) { return $localizationLocales; } // Alternatively, check if translatable package locales are available $localizationLocales = $this->getLocalesForTranslatable(); if ($localizationLocales) { return $localizationLocales; } // Fallback is to check whether the default locale is equal to the fallback locale // If it isn't, we still have two locales to provide, otherwise localization is disabled. return array_unique([ config('app.locale'), config('app.fallback_locale') ]); }
php
public function getAvailable() { // If explicitly set in CMS config, this overrules all else $configLocales = $this->core->config('locale.available'); if (is_array($configLocales)) { return $configLocales; } // Check if the localization package is used, and get locales from it $localizationLocales = $this->getLocalesForMcamaraLocalization(); if ($localizationLocales) { return $localizationLocales; } // Alternatively, check if translatable package locales are available $localizationLocales = $this->getLocalesForTranslatable(); if ($localizationLocales) { return $localizationLocales; } // Fallback is to check whether the default locale is equal to the fallback locale // If it isn't, we still have two locales to provide, otherwise localization is disabled. return array_unique([ config('app.locale'), config('app.fallback_locale') ]); }
[ "public", "function", "getAvailable", "(", ")", "{", "// If explicitly set in CMS config, this overrules all else", "$", "configLocales", "=", "$", "this", "->", "core", "->", "config", "(", "'locale.available'", ")", ";", "if", "(", "is_array", "(", "$", "configLoc...
Determines and returns the available locales for the application. @return string[]
[ "Determines", "and", "returns", "the", "available", "locales", "for", "the", "application", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/Localization/LocaleRepository.php#L38-L67
41,365
czim/laravel-cms-core
src/Support/Data/AclPresence.php
AclPresence.removePermission
public function removePermission($permission) { $permissions = $this->permissions(); $permissions = array_diff($permissions, [ $permission ]); $this->setAttribute('permissions', $permissions); }
php
public function removePermission($permission) { $permissions = $this->permissions(); $permissions = array_diff($permissions, [ $permission ]); $this->setAttribute('permissions', $permissions); }
[ "public", "function", "removePermission", "(", "$", "permission", ")", "{", "$", "permissions", "=", "$", "this", "->", "permissions", "(", ")", ";", "$", "permissions", "=", "array_diff", "(", "$", "permissions", ",", "[", "$", "permission", "]", ")", "...
Removes a permission from the current child permissions. @param string $permission
[ "Removes", "a", "permission", "from", "the", "current", "child", "permissions", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/Data/AclPresence.php#L112-L119
41,366
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.initialize
public function initialize(array $modules = null) { if ($this->initialized) return $this; if (is_array($modules)) { $this->moduleClasses = $modules; } else { $this->loadConfiguredModuleClasses(); } $this->populateModuleCollection() ->sortModules() ->populateAssociatedClassIndex(); $this->initialized = true; return $this; }
php
public function initialize(array $modules = null) { if ($this->initialized) return $this; if (is_array($modules)) { $this->moduleClasses = $modules; } else { $this->loadConfiguredModuleClasses(); } $this->populateModuleCollection() ->sortModules() ->populateAssociatedClassIndex(); $this->initialized = true; return $this; }
[ "public", "function", "initialize", "(", "array", "$", "modules", "=", "null", ")", "{", "if", "(", "$", "this", "->", "initialized", ")", "return", "$", "this", ";", "if", "(", "is_array", "(", "$", "modules", ")", ")", "{", "$", "this", "->", "mo...
Starts initialization, collection and registration of modules. This prepares the manager for further requests. @param string[]|null $modules optional override of config: list of module FQN's @return $this
[ "Starts", "initialization", "collection", "and", "registration", "of", "modules", ".", "This", "prepares", "the", "manager", "for", "further", "requests", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L94-L111
41,367
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.populateModuleCollection
protected function populateModuleCollection() { $this->modules = new Collection; foreach ($this->moduleClasses as $moduleClass) { $instance = $this->instantiateClass($moduleClass); if ($instance instanceof ModuleGeneratorInterface) { $this->storeModulesForGenerator($instance); continue; } // instance is a module $this->storeModule($instance); } return $this; }
php
protected function populateModuleCollection() { $this->modules = new Collection; foreach ($this->moduleClasses as $moduleClass) { $instance = $this->instantiateClass($moduleClass); if ($instance instanceof ModuleGeneratorInterface) { $this->storeModulesForGenerator($instance); continue; } // instance is a module $this->storeModule($instance); } return $this; }
[ "protected", "function", "populateModuleCollection", "(", ")", "{", "$", "this", "->", "modules", "=", "new", "Collection", ";", "foreach", "(", "$", "this", "->", "moduleClasses", "as", "$", "moduleClass", ")", "{", "$", "instance", "=", "$", "this", "->"...
Creates module instances for each registered class name and stores them in the module collection. @return $this
[ "Creates", "module", "instances", "for", "each", "registered", "class", "name", "and", "stores", "them", "in", "the", "module", "collection", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L137-L155
41,368
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.instantiateClass
protected function instantiateClass($class) { try { $instance = app($class); } catch (BindingResolutionException $e) { throw new InvalidArgumentException( "Failed to instantiate Module or ModuleGenerator instance for '{$class}'", $e->getCode(), $e ); } catch (ReflectionException $e) { throw new InvalidArgumentException( "Failed to instantiate Module or ModuleGenerator instance for '{$class}'", $e->getCode(), $e ); } if ( ! ($instance instanceof ModuleInterface) && ! ($instance instanceof ModuleGeneratorInterface) ) { throw new InvalidArgumentException( "Expected ModuleInterface or ModuleGeneratorInterface, got '{$class}'" ); } return $instance; }
php
protected function instantiateClass($class) { try { $instance = app($class); } catch (BindingResolutionException $e) { throw new InvalidArgumentException( "Failed to instantiate Module or ModuleGenerator instance for '{$class}'", $e->getCode(), $e ); } catch (ReflectionException $e) { throw new InvalidArgumentException( "Failed to instantiate Module or ModuleGenerator instance for '{$class}'", $e->getCode(), $e ); } if ( ! ($instance instanceof ModuleInterface) && ! ($instance instanceof ModuleGeneratorInterface) ) { throw new InvalidArgumentException( "Expected ModuleInterface or ModuleGeneratorInterface, got '{$class}'" ); } return $instance; }
[ "protected", "function", "instantiateClass", "(", "$", "class", ")", "{", "try", "{", "$", "instance", "=", "app", "(", "$", "class", ")", ";", "}", "catch", "(", "BindingResolutionException", "$", "e", ")", "{", "throw", "new", "InvalidArgumentException", ...
Instantiates a Module or ModuleGenerator instance. @param string $class @return ModuleInterface|ModuleGeneratorInterface
[ "Instantiates", "a", "Module", "or", "ModuleGenerator", "instance", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L187-L218
41,369
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.populateAssociatedClassIndex
protected function populateAssociatedClassIndex() { $this->associatedClassIndex = []; foreach ($this->modules as $module) { if ( ! $module->getAssociatedClass() || array_key_exists('', $this->associatedClassIndex) ) { continue; } $this->associatedClassIndex[ $module->getAssociatedClass() ] = $module->getKey(); } return $this; }
php
protected function populateAssociatedClassIndex() { $this->associatedClassIndex = []; foreach ($this->modules as $module) { if ( ! $module->getAssociatedClass() || array_key_exists('', $this->associatedClassIndex) ) { continue; } $this->associatedClassIndex[ $module->getAssociatedClass() ] = $module->getKey(); } return $this; }
[ "protected", "function", "populateAssociatedClassIndex", "(", ")", "{", "$", "this", "->", "associatedClassIndex", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "if", "(", "!", "$", "module", "->", "getA...
Populates the index by which modules may be looked up by associated class. @return $this
[ "Populates", "the", "index", "by", "which", "modules", "may", "be", "looked", "up", "by", "associated", "class", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L225-L241
41,370
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.sortModules
protected function sortModules() { $this->modules = $this->modules->sortBy(function (ModuleInterface $module) { return $module->getName(); }); return $this; }
php
protected function sortModules() { $this->modules = $this->modules->sortBy(function (ModuleInterface $module) { return $module->getName(); }); return $this; }
[ "protected", "function", "sortModules", "(", ")", "{", "$", "this", "->", "modules", "=", "$", "this", "->", "modules", "->", "sortBy", "(", "function", "(", "ModuleInterface", "$", "module", ")", "{", "return", "$", "module", "->", "getName", "(", ")", ...
Sorts the modules in an order that will suite the natural defaults for their menu presence. @return $this
[ "Sorts", "the", "modules", "in", "an", "order", "that", "will", "suite", "the", "natural", "defaults", "for", "their", "menu", "presence", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L249-L256
41,371
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.get
public function get($key) { if ( ! $this->has($key)) { return false; } return $this->modules->get($key); }
php
public function get($key) { if ( ! $this->has($key)) { return false; } return $this->modules->get($key); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "modules", "->", "get", "(", "$", "key", ")", ";", "}"...
Returns a module by key. @param string $key @return ModuleInterface|false
[ "Returns", "a", "module", "by", "key", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L285-L292
41,372
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.getByAssociatedClass
public function getByAssociatedClass($modelClass) { if ( ! array_key_exists($modelClass, $this->associatedClassIndex)) { return false; } $key = $this->associatedClassIndex[ $modelClass ]; return $this->get($key); }
php
public function getByAssociatedClass($modelClass) { if ( ! array_key_exists($modelClass, $this->associatedClassIndex)) { return false; } $key = $this->associatedClassIndex[ $modelClass ]; return $this->get($key); }
[ "public", "function", "getByAssociatedClass", "(", "$", "modelClass", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "modelClass", ",", "$", "this", "->", "associatedClassIndex", ")", ")", "{", "return", "false", ";", "}", "$", "key", "=", "$", ...
Returns a module by its associated class. This may be an Eloquent model, for instance, for modules dedicated to editing a specific class. If multiple associations for the same class exist, the first ordered will be returned. @param string $modelClass FQN of model @return ModuleInterface|false
[ "Returns", "a", "module", "by", "its", "associated", "class", ".", "This", "may", "be", "an", "Eloquent", "model", "for", "instance", "for", "modules", "dedicated", "to", "editing", "a", "specific", "class", ".", "If", "multiple", "associations", "for", "the...
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L303-L312
41,373
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.mapWebRoutes
public function mapWebRoutes(Router $router) { foreach ($this->modules as $module) { $module->mapWebRoutes($router); } }
php
public function mapWebRoutes(Router $router) { foreach ($this->modules as $module) { $module->mapWebRoutes($router); } }
[ "public", "function", "mapWebRoutes", "(", "Router", "$", "router", ")", "{", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "module", "->", "mapWebRoutes", "(", "$", "router", ")", ";", "}", "}" ]
Builds routes for all modules given a router as context. @param Router $router
[ "Builds", "routes", "for", "all", "modules", "given", "a", "router", "as", "context", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L319-L324
41,374
czim/laravel-cms-core
src/Modules/ModuleManager.php
ModuleManager.mapApiRoutes
public function mapApiRoutes(Router $router) { foreach ($this->modules as $module) { $module->mapApiRoutes($router); } }
php
public function mapApiRoutes(Router $router) { foreach ($this->modules as $module) { $module->mapApiRoutes($router); } }
[ "public", "function", "mapApiRoutes", "(", "Router", "$", "router", ")", "{", "foreach", "(", "$", "this", "->", "modules", "as", "$", "module", ")", "{", "$", "module", "->", "mapApiRoutes", "(", "$", "router", ")", ";", "}", "}" ]
Builds API routes for all modules given a router as context. @param Router $router
[ "Builds", "API", "routes", "for", "all", "modules", "given", "a", "router", "as", "context", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Modules/ModuleManager.php#L331-L336
41,375
czim/laravel-cms-core
src/Menu/MenuConfigInterpreter.php
MenuConfigInterpreter.interpretLayout
public function interpretLayout(array $layout) { $this->assignedModuleKeys = []; $modulePresences = $this->modulesInterpreter->interpret(); $layout = $this->mergeModulePresencesIntoLayout($this->interpretNestedGroupLayout($layout), $modulePresences); $layout = new LayoutData([ 'layout' => $layout, 'alternative' => $modulePresences->alternative()->toarray(), ]); $this->filterEmptyGroups($layout); return $layout; }
php
public function interpretLayout(array $layout) { $this->assignedModuleKeys = []; $modulePresences = $this->modulesInterpreter->interpret(); $layout = $this->mergeModulePresencesIntoLayout($this->interpretNestedGroupLayout($layout), $modulePresences); $layout = new LayoutData([ 'layout' => $layout, 'alternative' => $modulePresences->alternative()->toarray(), ]); $this->filterEmptyGroups($layout); return $layout; }
[ "public", "function", "interpretLayout", "(", "array", "$", "layout", ")", "{", "$", "this", "->", "assignedModuleKeys", "=", "[", "]", ";", "$", "modulePresences", "=", "$", "this", "->", "modulesInterpreter", "->", "interpret", "(", ")", ";", "$", "layou...
Interprets a configured menu layout array. @param array $layout @return MenuLayoutDataInterface
[ "Interprets", "a", "configured", "menu", "layout", "array", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuConfigInterpreter.php#L51-L67
41,376
czim/laravel-cms-core
src/Menu/MenuConfigInterpreter.php
MenuConfigInterpreter.interpretNestedGroupLayout
protected function interpretNestedGroupLayout(array $data) { foreach ($data as $key => &$value) { if ( ! is_array($value)) { continue; } // The child is a group, so make a presence object for it $children = array_get($value, 'children', []); $children = $this->interpretNestedGroupLayout($children); $value = new MenuPresence([ 'id' => $key ?: array_get($value, 'id'), 'type' => MenuPresenceType::GROUP, 'label' => array_get($value, 'label'), 'label_translated' => array_get($value, 'label_translated'), 'icon' => array_get($value, 'icon'), 'children' => $children, ]); } unset ($value); return $data; }
php
protected function interpretNestedGroupLayout(array $data) { foreach ($data as $key => &$value) { if ( ! is_array($value)) { continue; } // The child is a group, so make a presence object for it $children = array_get($value, 'children', []); $children = $this->interpretNestedGroupLayout($children); $value = new MenuPresence([ 'id' => $key ?: array_get($value, 'id'), 'type' => MenuPresenceType::GROUP, 'label' => array_get($value, 'label'), 'label_translated' => array_get($value, 'label_translated'), 'icon' => array_get($value, 'icon'), 'children' => $children, ]); } unset ($value); return $data; }
[ "protected", "function", "interpretNestedGroupLayout", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "continue", ";...
Interprets nested groups in a layout array, creating presences for them. @param array $data @return array
[ "Interprets", "nested", "groups", "in", "a", "layout", "array", "creating", "presences", "for", "them", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuConfigInterpreter.php#L75-L100
41,377
czim/laravel-cms-core
src/Menu/MenuConfigInterpreter.php
MenuConfigInterpreter.mergeModulePresencesIntoLayout
protected function mergeModulePresencesIntoLayout(array $layout, MenuConfiguredModulesDataInterface $modules) { $standard = $modules->standard(); $layout = $this->mergeModulePresencesIntoLayoutLayer($layout, $standard); // Append ungrouped presences to to the end of the layout $standard->each(function ($presences) use (&$layout) { /** @var MenuPresenceInterface[] $presences */ foreach ($presences as $presence) { $layout[] = $presence; } }); return $layout; }
php
protected function mergeModulePresencesIntoLayout(array $layout, MenuConfiguredModulesDataInterface $modules) { $standard = $modules->standard(); $layout = $this->mergeModulePresencesIntoLayoutLayer($layout, $standard); // Append ungrouped presences to to the end of the layout $standard->each(function ($presences) use (&$layout) { /** @var MenuPresenceInterface[] $presences */ foreach ($presences as $presence) { $layout[] = $presence; } }); return $layout; }
[ "protected", "function", "mergeModulePresencesIntoLayout", "(", "array", "$", "layout", ",", "MenuConfiguredModulesDataInterface", "$", "modules", ")", "{", "$", "standard", "=", "$", "modules", "->", "standard", "(", ")", ";", "$", "layout", "=", "$", "this", ...
Merges module menu presences into layout tree array. @param array $layout @param MenuConfiguredModulesDataInterface $modules @return array
[ "Merges", "module", "menu", "presences", "into", "layout", "tree", "array", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuConfigInterpreter.php#L109-L124
41,378
czim/laravel-cms-core
src/Menu/MenuConfigInterpreter.php
MenuConfigInterpreter.mergeModulePresencesIntoLayoutLayer
protected function mergeModulePresencesIntoLayoutLayer(array $layer, Collection $presencesPerModule) { $newLayer = []; foreach ($layer as $key => $value) { $stringKey = is_string($key) && ! is_numeric($key); if ($value instanceof MenuPresenceInterface && $value->type() == MenuPresenceType::GROUP) { $value->setChildren($this->mergeModulePresencesIntoLayoutLayer($value->children, $presencesPerModule)); if ($stringKey) { $newLayer[$key] = $value; } else { $newLayer[] = $value; } continue; } if ( ! is_string($value)) { throw new UnexpectedValueException( 'Module key reference in menu layout must be string module key reference, or array for layout group' ); } if (in_array($value, $this->assignedModuleKeys)) { throw new UnexpectedValueException( "Module key reference '{$value}' for menu layout is used more than once." ); } if ( ! $presencesPerModule->has($value)) { throw new UnexpectedValueException( "Unknown (or disabled) module key reference '{$value}' in menu layout." ); } $this->assignedModuleKeys[] = $value; foreach ($presences = $presencesPerModule->pull($value) as $presence) { $newLayer[] = $presence; } } return $newLayer; }
php
protected function mergeModulePresencesIntoLayoutLayer(array $layer, Collection $presencesPerModule) { $newLayer = []; foreach ($layer as $key => $value) { $stringKey = is_string($key) && ! is_numeric($key); if ($value instanceof MenuPresenceInterface && $value->type() == MenuPresenceType::GROUP) { $value->setChildren($this->mergeModulePresencesIntoLayoutLayer($value->children, $presencesPerModule)); if ($stringKey) { $newLayer[$key] = $value; } else { $newLayer[] = $value; } continue; } if ( ! is_string($value)) { throw new UnexpectedValueException( 'Module key reference in menu layout must be string module key reference, or array for layout group' ); } if (in_array($value, $this->assignedModuleKeys)) { throw new UnexpectedValueException( "Module key reference '{$value}' for menu layout is used more than once." ); } if ( ! $presencesPerModule->has($value)) { throw new UnexpectedValueException( "Unknown (or disabled) module key reference '{$value}' in menu layout." ); } $this->assignedModuleKeys[] = $value; foreach ($presences = $presencesPerModule->pull($value) as $presence) { $newLayer[] = $presence; } } return $newLayer; }
[ "protected", "function", "mergeModulePresencesIntoLayoutLayer", "(", "array", "$", "layer", ",", "Collection", "$", "presencesPerModule", ")", "{", "$", "newLayer", "=", "[", "]", ";", "foreach", "(", "$", "layer", "as", "$", "key", "=>", "$", "value", ")", ...
Merges module menu presences into layout tree layers recursively. @param array $layer @param Collection $presencesPerModule pulls presences per module if they are added to the layout @return array
[ "Merges", "module", "menu", "presences", "into", "layout", "tree", "layers", "recursively", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuConfigInterpreter.php#L133-L178
41,379
czim/laravel-cms-core
src/Menu/MenuConfigInterpreter.php
MenuConfigInterpreter.filterEmptyGroups
protected function filterEmptyGroups(LayoutData $layout) { $presences = $layout->layout; $remove = []; foreach ($presences as $key => $presence) { if ( ! $this->filterNestedEmptyGroups($presence)) { $remove[] = $key; } } array_forget($presences, $remove); $layout->layout = $presences; }
php
protected function filterEmptyGroups(LayoutData $layout) { $presences = $layout->layout; $remove = []; foreach ($presences as $key => $presence) { if ( ! $this->filterNestedEmptyGroups($presence)) { $remove[] = $key; } } array_forget($presences, $remove); $layout->layout = $presences; }
[ "protected", "function", "filterEmptyGroups", "(", "LayoutData", "$", "layout", ")", "{", "$", "presences", "=", "$", "layout", "->", "layout", ";", "$", "remove", "=", "[", "]", ";", "foreach", "(", "$", "presences", "as", "$", "key", "=>", "$", "pres...
Filters any groups from the layout that are empty. This is merely a safeguard for module presence definitions that contain empty groups to start with. @param LayoutData $layout
[ "Filters", "any", "groups", "from", "the", "layout", "that", "are", "empty", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuConfigInterpreter.php#L188-L203
41,380
czim/laravel-cms-core
src/Menu/MenuConfigInterpreter.php
MenuConfigInterpreter.filterNestedEmptyGroups
protected function filterNestedEmptyGroups(MenuPresenceInterface $presence) { if ($presence->type() !== MenuPresenceType::GROUP) { return 1; } $children = $presence->children(); if ( ! $children || ! count($children)) { return 0; } $remove = []; $nonGroupCount = 0; foreach ($children as $key => $childPresence) { if ( ! $this->filterNestedEmptyGroups($childPresence)) { $remove[] = $key; continue; } $nonGroupCount++; } foreach ($remove as $key) { unset($children[$key]); } $presence->setChildren($children); return $nonGroupCount; }
php
protected function filterNestedEmptyGroups(MenuPresenceInterface $presence) { if ($presence->type() !== MenuPresenceType::GROUP) { return 1; } $children = $presence->children(); if ( ! $children || ! count($children)) { return 0; } $remove = []; $nonGroupCount = 0; foreach ($children as $key => $childPresence) { if ( ! $this->filterNestedEmptyGroups($childPresence)) { $remove[] = $key; continue; } $nonGroupCount++; } foreach ($remove as $key) { unset($children[$key]); } $presence->setChildren($children); return $nonGroupCount; }
[ "protected", "function", "filterNestedEmptyGroups", "(", "MenuPresenceInterface", "$", "presence", ")", "{", "if", "(", "$", "presence", "->", "type", "(", ")", "!==", "MenuPresenceType", "::", "GROUP", ")", "{", "return", "1", ";", "}", "$", "children", "="...
Removes any empty group children from a tree structure, returning the number of non-group entries. @param MenuPresenceInterface $presence @return int the number of non-group children found on the levels below
[ "Removes", "any", "empty", "group", "children", "from", "a", "tree", "structure", "returning", "the", "number", "of", "non", "-", "group", "entries", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuConfigInterpreter.php#L212-L244
41,381
czim/laravel-cms-core
src/Support/Data/Menu/PermissionsIndexData.php
PermissionsIndexData.getForNode
public function getForNode(array $nodeKey) { $normalized = $this->stringifyNodeKey($nodeKey); return array_get($this->index(), $normalized, false); }
php
public function getForNode(array $nodeKey) { $normalized = $this->stringifyNodeKey($nodeKey); return array_get($this->index(), $normalized, false); }
[ "public", "function", "getForNode", "(", "array", "$", "nodeKey", ")", "{", "$", "normalized", "=", "$", "this", "->", "stringifyNodeKey", "(", "$", "nodeKey", ")", ";", "return", "array_get", "(", "$", "this", "->", "index", "(", ")", ",", "$", "norma...
Returns indexed permissions for a given menu layout node. @param array $nodeKey @return string[]|false false if the node is not present in the index
[ "Returns", "indexed", "permissions", "for", "a", "given", "menu", "layout", "node", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/Data/Menu/PermissionsIndexData.php#L53-L58
41,382
czim/laravel-cms-core
src/Support/Data/Menu/PermissionsIndexData.php
PermissionsIndexData.setForNode
public function setForNode(array $nodeKey, array $permissions = []) { $this->attributes['index'][ $this->stringifyNodeKey($nodeKey) ] = $permissions; return $this; }
php
public function setForNode(array $nodeKey, array $permissions = []) { $this->attributes['index'][ $this->stringifyNodeKey($nodeKey) ] = $permissions; return $this; }
[ "public", "function", "setForNode", "(", "array", "$", "nodeKey", ",", "array", "$", "permissions", "=", "[", "]", ")", "{", "$", "this", "->", "attributes", "[", "'index'", "]", "[", "$", "this", "->", "stringifyNodeKey", "(", "$", "nodeKey", ")", "]"...
Sets permissions for a given menu layout node. @param array $nodeKey @param string[] $permissions @return $this
[ "Sets", "permissions", "for", "a", "given", "menu", "layout", "node", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/Data/Menu/PermissionsIndexData.php#L67-L72
41,383
czim/laravel-cms-core
src/Support/Data/AbstractDataObject.php
AbstractDataObject.mergeAttribute
protected function mergeAttribute(string $key, $mergeValue) { $current = $this[$key]; if ($current instanceof DataObjectInterface && method_exists($current, 'merge')) { $class = get_class($current); if (is_array($mergeValue)) { $mergeValue = new $class($mergeValue); } // If we have nothing to merge with, don't bother if (null === $mergeValue) { return; } $mergeValue = $current->merge($mergeValue); } if (null === $mergeValue) { return; } $this[$key] = $mergeValue; }
php
protected function mergeAttribute(string $key, $mergeValue) { $current = $this[$key]; if ($current instanceof DataObjectInterface && method_exists($current, 'merge')) { $class = get_class($current); if (is_array($mergeValue)) { $mergeValue = new $class($mergeValue); } // If we have nothing to merge with, don't bother if (null === $mergeValue) { return; } $mergeValue = $current->merge($mergeValue); } if (null === $mergeValue) { return; } $this[$key] = $mergeValue; }
[ "protected", "function", "mergeAttribute", "(", "string", "$", "key", ",", "$", "mergeValue", ")", "{", "$", "current", "=", "$", "this", "[", "$", "key", "]", ";", "if", "(", "$", "current", "instanceof", "DataObjectInterface", "&&", "method_exists", "(",...
Merges a single attribute by key with a new given value. @param string $key @param mixed $mergeValue
[ "Merges", "a", "single", "attribute", "by", "key", "with", "a", "new", "given", "value", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/Data/AbstractDataObject.php#L133-L158
41,384
czim/laravel-cms-core
src/Support/Data/AbstractDataObject.php
AbstractDataObject.clear
public function clear(): DataObjectInterface { foreach ($this->getKeys() as $key) { $this->attributes[ $key ] = null; } return $this; }
php
public function clear(): DataObjectInterface { foreach ($this->getKeys() as $key) { $this->attributes[ $key ] = null; } return $this; }
[ "public", "function", "clear", "(", ")", ":", "DataObjectInterface", "{", "foreach", "(", "$", "this", "->", "getKeys", "(", ")", "as", "$", "key", ")", "{", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "null", ";", "}", "return", "$...
Clears the attributes. Note that this does not reset defaults, but clears them. @return $this
[ "Clears", "the", "attributes", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/Data/AbstractDataObject.php#L167-L174
41,385
czim/laravel-cms-core
src/Auth/AclRepository.php
AclRepository.getModulePermissions
public function getModulePermissions($key) { $this->prepareData(); if ( ! array_key_exists($key, $this->modulePermissions)) { return []; } return $this->modulePermissions[$key]; }
php
public function getModulePermissions($key) { $this->prepareData(); if ( ! array_key_exists($key, $this->modulePermissions)) { return []; } return $this->modulePermissions[$key]; }
[ "public", "function", "getModulePermissions", "(", "$", "key", ")", "{", "$", "this", "->", "prepareData", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "modulePermissions", ")", ")", "{", "return", "[", "]...
Retrieves a flat list of all permissions for a module. @param string $key @return string[]
[ "Retrieves", "a", "flat", "list", "of", "all", "permissions", "for", "a", "module", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Auth/AclRepository.php#L116-L125
41,386
czim/laravel-cms-core
src/Auth/AclRepository.php
AclRepository.loadAclModules
protected function loadAclModules() { // Gather all modules with any menu inherent or overridden presence // and store them locally according to their nature. foreach ($this->core->modules()->getModules() as $moduleKey => $module) { $presencesForModule = $module->getAclPresence(); // If a module has no presence, skip it if ( ! $presencesForModule) { continue; } if ( ! $this->modulePresences->has($moduleKey)) { $this->modulePresences->put($moduleKey, new Collection); } foreach ($this->normalizeAclPresence($presencesForModule) as $presence) { if ( ! $presence) { // @codeCoverageIgnoreStart continue; // @codeCoverageIgnoreEnd } $this->presences->push($presence); $this->modulePresences->get($moduleKey)->push($presence); } } return $this; }
php
protected function loadAclModules() { // Gather all modules with any menu inherent or overridden presence // and store them locally according to their nature. foreach ($this->core->modules()->getModules() as $moduleKey => $module) { $presencesForModule = $module->getAclPresence(); // If a module has no presence, skip it if ( ! $presencesForModule) { continue; } if ( ! $this->modulePresences->has($moduleKey)) { $this->modulePresences->put($moduleKey, new Collection); } foreach ($this->normalizeAclPresence($presencesForModule) as $presence) { if ( ! $presence) { // @codeCoverageIgnoreStart continue; // @codeCoverageIgnoreEnd } $this->presences->push($presence); $this->modulePresences->get($moduleKey)->push($presence); } } return $this; }
[ "protected", "function", "loadAclModules", "(", ")", "{", "// Gather all modules with any menu inherent or overridden presence", "// and store them locally according to their nature.", "foreach", "(", "$", "this", "->", "core", "->", "modules", "(", ")", "->", "getModules", "...
Loads the ACL presences from modules and stores it normalized in the main presences collection. @return $this
[ "Loads", "the", "ACL", "presences", "from", "modules", "and", "stores", "it", "normalized", "in", "the", "main", "presences", "collection", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Auth/AclRepository.php#L157-L189
41,387
czim/laravel-cms-core
src/Auth/AclRepository.php
AclRepository.normalizeAclPresence
protected function normalizeAclPresence($data) { if ( ! $data) { // @codeCoverageIgnoreStart return []; // @codeCoverageIgnoreEnd } if ($data instanceof AclPresenceInterface) { $data = [$data]; } elseif (is_array($data) && ! Arr::isAssoc($data)) { $presences = []; foreach ($data as $nestedData) { if (is_array($nestedData)) { $nestedData = new AclPresence($nestedData); } if ( ! ($nestedData instanceof AclPresenceInterface)) { throw new UnexpectedValueException( 'ACL presence data from array provided by module is not an array or ACL presence instance' ); } $presences[] = $nestedData; } $data = $presences; } else { $data = [ new AclPresence($data) ]; } /** @var AclPresenceInterface[] $data */ // Now normalized to an array with one or more ACL presences. // Make sure the permission children are listed as simple strings. foreach ($data as $index => $presence) { $data[ $index ]->setPermissions($presence->permissions()); } return $data; }
php
protected function normalizeAclPresence($data) { if ( ! $data) { // @codeCoverageIgnoreStart return []; // @codeCoverageIgnoreEnd } if ($data instanceof AclPresenceInterface) { $data = [$data]; } elseif (is_array($data) && ! Arr::isAssoc($data)) { $presences = []; foreach ($data as $nestedData) { if (is_array($nestedData)) { $nestedData = new AclPresence($nestedData); } if ( ! ($nestedData instanceof AclPresenceInterface)) { throw new UnexpectedValueException( 'ACL presence data from array provided by module is not an array or ACL presence instance' ); } $presences[] = $nestedData; } $data = $presences; } else { $data = [ new AclPresence($data) ]; } /** @var AclPresenceInterface[] $data */ // Now normalized to an array with one or more ACL presences. // Make sure the permission children are listed as simple strings. foreach ($data as $index => $presence) { $data[ $index ]->setPermissions($presence->permissions()); } return $data; }
[ "protected", "function", "normalizeAclPresence", "(", "$", "data", ")", "{", "if", "(", "!", "$", "data", ")", "{", "// @codeCoverageIgnoreStart", "return", "[", "]", ";", "// @codeCoverageIgnoreEnd", "}", "if", "(", "$", "data", "instanceof", "AclPresenceInterf...
Normalizes ACL presence data to an array of ACLPresence instances. @param $data @return AclPresenceInterface[]
[ "Normalizes", "ACL", "presence", "data", "to", "an", "array", "of", "ACLPresence", "instances", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Auth/AclRepository.php#L197-L245
41,388
czim/laravel-cms-core
src/Auth/AclRepository.php
AclRepository.collapsePermissions
protected function collapsePermissions() { foreach ($this->modulePresences as $moduleKey => $presences) { if ( ! array_key_exists($moduleKey, $this->modulePermissions)) { $this->modulePermissions[ $moduleKey ] = []; } /** @var AclPresenceInterface[] $presences */ foreach ($presences as $presence) { if ( ! count($presence->permissions())) { continue; } $flatPermissions = $presence->permissions(); $this->permissions = array_merge($this->permissions, $flatPermissions); $this->modulePermissions[$moduleKey] = array_merge($this->modulePermissions[$moduleKey], $flatPermissions); } } $this->permissions = array_unique($this->permissions); return $this; }
php
protected function collapsePermissions() { foreach ($this->modulePresences as $moduleKey => $presences) { if ( ! array_key_exists($moduleKey, $this->modulePermissions)) { $this->modulePermissions[ $moduleKey ] = []; } /** @var AclPresenceInterface[] $presences */ foreach ($presences as $presence) { if ( ! count($presence->permissions())) { continue; } $flatPermissions = $presence->permissions(); $this->permissions = array_merge($this->permissions, $flatPermissions); $this->modulePermissions[$moduleKey] = array_merge($this->modulePermissions[$moduleKey], $flatPermissions); } } $this->permissions = array_unique($this->permissions); return $this; }
[ "protected", "function", "collapsePermissions", "(", ")", "{", "foreach", "(", "$", "this", "->", "modulePresences", "as", "$", "moduleKey", "=>", "$", "presences", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "moduleKey", ",", "$", "this", "->"...
Collapses all permissions from presences into flat permission arrays. @return $this
[ "Collapses", "all", "permissions", "from", "presences", "into", "flat", "permission", "arrays", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Auth/AclRepository.php#L252-L277
41,389
czim/laravel-cms-core
src/Providers/ViewServiceProvider.php
ViewServiceProvider.registerBladeDirectives
protected function registerBladeDirectives() { // Set up the cms_script directive Blade::directive('cms_script', function () { return "<?php ob_start(); ?>"; }); Blade::directive('cms_endscript', function () { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScript(ob_get_clean(), false); ?>"; }); // Set up the cms_scriptonce directive Blade::directive('cms_scriptonce', function () { return "<?php ob_start(); ?>"; }); Blade::directive('cms_endscriptonce', function () { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScript(ob_get_clean(), true); ?>"; }); // Set up the cms_scriptassethead directive Blade::directive('cms_scriptassethead', function ($expression) { if ($this->isBladeArgumentStringBracketed()) { $expression = substr($expression, 1, -1); } return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScriptAsset({$expression}, true); ?>"; }); // Set up the cms_scriptasset directive Blade::directive('cms_scriptasset', function ($expression) { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScriptAsset" . ($this->isBladeArgumentStringBracketed() ? $expression : "({$expression})") . "; ?>"; }); // Set up the cms_style directive Blade::directive('cms_style', function ($expression) { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerStyleAsset" . ($this->isBladeArgumentStringBracketed() ? $expression : "({$expression})") . "; ?>"; }); }
php
protected function registerBladeDirectives() { // Set up the cms_script directive Blade::directive('cms_script', function () { return "<?php ob_start(); ?>"; }); Blade::directive('cms_endscript', function () { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScript(ob_get_clean(), false); ?>"; }); // Set up the cms_scriptonce directive Blade::directive('cms_scriptonce', function () { return "<?php ob_start(); ?>"; }); Blade::directive('cms_endscriptonce', function () { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScript(ob_get_clean(), true); ?>"; }); // Set up the cms_scriptassethead directive Blade::directive('cms_scriptassethead', function ($expression) { if ($this->isBladeArgumentStringBracketed()) { $expression = substr($expression, 1, -1); } return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScriptAsset({$expression}, true); ?>"; }); // Set up the cms_scriptasset directive Blade::directive('cms_scriptasset', function ($expression) { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerScriptAsset" . ($this->isBladeArgumentStringBracketed() ? $expression : "({$expression})") . "; ?>"; }); // Set up the cms_style directive Blade::directive('cms_style', function ($expression) { return "<?php app(Czim\\CmsCore\\Contracts\\Support\\View\\AssetManagerInterface::class)" . "->registerStyleAsset" . ($this->isBladeArgumentStringBracketed() ? $expression : "({$expression})") . "; ?>"; }); }
[ "protected", "function", "registerBladeDirectives", "(", ")", "{", "// Set up the cms_script directive", "Blade", "::", "directive", "(", "'cms_script'", ",", "function", "(", ")", "{", "return", "\"<?php ob_start(); ?>\"", ";", "}", ")", ";", "Blade", "::", "direct...
Registers blade directives for the CMS. @codeCoverageIgnore
[ "Registers", "blade", "directives", "for", "the", "CMS", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/ViewServiceProvider.php#L54-L104
41,390
czim/laravel-cms-core
src/Providers/ViewServiceProvider.php
ViewServiceProvider.isBladeArgumentStringBracketed
protected function isBladeArgumentStringBracketed() { if ( ! preg_match('#^(?<major>\d+)\.(?<minor>\d+)(?:\..*)?$#', Application::VERSION, $matches)) { return true; } $major = (int) $matches['major']; $minor = (int) $matches['minor']; return ($major < 5 || $major == 5 && $minor < 3); }
php
protected function isBladeArgumentStringBracketed() { if ( ! preg_match('#^(?<major>\d+)\.(?<minor>\d+)(?:\..*)?$#', Application::VERSION, $matches)) { return true; } $major = (int) $matches['major']; $minor = (int) $matches['minor']; return ($major < 5 || $major == 5 && $minor < 3); }
[ "protected", "function", "isBladeArgumentStringBracketed", "(", ")", "{", "if", "(", "!", "preg_match", "(", "'#^(?<major>\\d+)\\.(?<minor>\\d+)(?:\\..*)?$#'", ",", "Application", "::", "VERSION", ",", "$", "matches", ")", ")", "{", "return", "true", ";", "}", "$"...
Returns whether the blade directive argument brackets are included. This behaviour was changed with the release of Laravel 5.3. @return bool @codeCoverageIgnore
[ "Returns", "whether", "the", "blade", "directive", "argument", "brackets", "are", "included", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Providers/ViewServiceProvider.php#L114-L122
41,391
czim/laravel-cms-core
src/Support/View/AssetManager.php
AssetManager.registerStyleAsset
public function registerStyleAsset($path, $type = null, $media = null, $rel = 'stylesheet') { if ( ! array_key_exists($path, $this->styleAssets)) { $this->styleAssets[ $path ] = [ 'type' => $type, 'media' => $media, 'rel' => $rel, ]; } return $this; }
php
public function registerStyleAsset($path, $type = null, $media = null, $rel = 'stylesheet') { if ( ! array_key_exists($path, $this->styleAssets)) { $this->styleAssets[ $path ] = [ 'type' => $type, 'media' => $media, 'rel' => $rel, ]; } return $this; }
[ "public", "function", "registerStyleAsset", "(", "$", "path", ",", "$", "type", "=", "null", ",", "$", "media", "=", "null", ",", "$", "rel", "=", "'stylesheet'", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "path", ",", "$", "this", "->",...
Registers a CMS stylesheet asset. @param string $path @param null|string $type @param null|string $media @param string $rel @return $this
[ "Registers", "a", "CMS", "stylesheet", "asset", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/View/AssetManager.php#L54-L65
41,392
czim/laravel-cms-core
src/Support/View/AssetManager.php
AssetManager.registerScript
public function registerScript($script, $once = true) { if ( ! $once) { $this->scripts[] = $script; return $this; } // Make sure the script is added only once $hash = md5($script); if (array_key_exists($hash, $this->scriptHashes)) { return $this; } $this->scripts[] = $script; // Map the hash for adding the script only once end($this->scripts); $index = key($this->scripts); $this->scriptHashes[$hash] = $index; return $this; }
php
public function registerScript($script, $once = true) { if ( ! $once) { $this->scripts[] = $script; return $this; } // Make sure the script is added only once $hash = md5($script); if (array_key_exists($hash, $this->scriptHashes)) { return $this; } $this->scripts[] = $script; // Map the hash for adding the script only once end($this->scripts); $index = key($this->scripts); $this->scriptHashes[$hash] = $index; return $this; }
[ "public", "function", "registerScript", "(", "$", "script", ",", "$", "once", "=", "true", ")", "{", "if", "(", "!", "$", "once", ")", "{", "$", "this", "->", "scripts", "[", "]", "=", "$", "script", ";", "return", "$", "this", ";", "}", "// Make...
Registers CMS javascript code @param $script @param bool $once if true, only registers script with these exact contents once @return $this
[ "Registers", "CMS", "javascript", "code" ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/View/AssetManager.php#L90-L114
41,393
czim/laravel-cms-core
src/Support/View/AssetManager.php
AssetManager.renderStyleAssets
public function renderStyleAssets() { return implode( "\n", array_map( function ($asset, $parameters) { return '<link rel="' . e(array_get($parameters, 'rel')) . '" href="' . $asset . '"' . (array_get($parameters, 'type') ? ' type="' . e(array_get($parameters, 'type')) . '"' : '') . (array_get($parameters, 'media') ? ' media="' . e(array_get($parameters, 'media')) . '"' : '') . '>'; }, array_keys($this->styleAssets), array_values($this->styleAssets) ) ); }
php
public function renderStyleAssets() { return implode( "\n", array_map( function ($asset, $parameters) { return '<link rel="' . e(array_get($parameters, 'rel')) . '" href="' . $asset . '"' . (array_get($parameters, 'type') ? ' type="' . e(array_get($parameters, 'type')) . '"' : '') . (array_get($parameters, 'media') ? ' media="' . e(array_get($parameters, 'media')) . '"' : '') . '>'; }, array_keys($this->styleAssets), array_values($this->styleAssets) ) ); }
[ "public", "function", "renderStyleAssets", "(", ")", "{", "return", "implode", "(", "\"\\n\"", ",", "array_map", "(", "function", "(", "$", "asset", ",", "$", "parameters", ")", "{", "return", "'<link rel=\"'", ".", "e", "(", "array_get", "(", "$", "parame...
Returns rendered registered stylesheet asset links. @return string
[ "Returns", "rendered", "registered", "stylesheet", "asset", "links", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/View/AssetManager.php#L121-L136
41,394
czim/laravel-cms-core
src/Support/View/AssetManager.php
AssetManager.renderScriptAssets
public function renderScriptAssets() { return implode( "\n", array_map( function ($asset) { return '<script src="' . $asset . '"></script>'; }, array_keys( array_filter($this->scriptAssets, function ($head) { return ! $head; }) ) ) ); }
php
public function renderScriptAssets() { return implode( "\n", array_map( function ($asset) { return '<script src="' . $asset . '"></script>'; }, array_keys( array_filter($this->scriptAssets, function ($head) { return ! $head; }) ) ) ); }
[ "public", "function", "renderScriptAssets", "(", ")", "{", "return", "implode", "(", "\"\\n\"", ",", "array_map", "(", "function", "(", "$", "asset", ")", "{", "return", "'<script src=\"'", ".", "$", "asset", ".", "'\"></script>'", ";", "}", ",", "array_keys...
Returns rendered registered script asset links for the footer. @return string
[ "Returns", "rendered", "registered", "script", "asset", "links", "for", "the", "footer", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Support/View/AssetManager.php#L143-L156
41,395
czim/laravel-cms-core
src/Http/Middleware/SetLocale.php
SetLocale.getValidSessionLocale
protected function getValidSessionLocale() { $locale = $this->getSessionLocale(); if ( ! $locale) { return false; } if ( ! $this->repository->isAvailable($locale)) { $locale = $this->repository->getDefault(); } return $locale; }
php
protected function getValidSessionLocale() { $locale = $this->getSessionLocale(); if ( ! $locale) { return false; } if ( ! $this->repository->isAvailable($locale)) { $locale = $this->repository->getDefault(); } return $locale; }
[ "protected", "function", "getValidSessionLocale", "(", ")", "{", "$", "locale", "=", "$", "this", "->", "getSessionLocale", "(", ")", ";", "if", "(", "!", "$", "locale", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "repos...
Returns the session locale, replacing unavailable with default. @return bool|string
[ "Returns", "the", "session", "locale", "replacing", "unavailable", "with", "default", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Http/Middleware/SetLocale.php#L68-L81
41,396
czim/laravel-cms-core
src/Menu/MenuModulesInterpreter.php
MenuModulesInterpreter.interpret
public function interpret() { /** @var Collection|ModuleInterface[] $modules */ $modules = $this->sortModules( $this->core->modules()->getModules() ); foreach ($modules as $moduleKey => $module) { // If the configuration has overriding data for this module's presence, // use it. Otherwise load the menu's own presence. // Normalize single & plural presences for each module. if ($this->isConfiguredModulePresenceDisabled($module)) { continue; } if ($this->hasConfiguredModulePresence($module)) { $configuredPresencesForModule = $this->normalizeConfiguredPresence( $this->getConfiguredModulePresence($module) ); $presencesForModule = $this->mergeNormalizedMenuPresences( $this->normalizeMenuPresence($module->getMenuPresence()), $configuredPresencesForModule ); } else { // If no configuration is set, simply normalize and use the original $presencesForModule = $this->normalizeMenuPresence($module->getMenuPresence()); } // If a module has no presence, skip it if ( ! $presencesForModule) { continue; } $standard = []; $alternative = []; foreach ($presencesForModule as $presence) { // If a menu presence is deemed 'alternative', // it should not appear in the normal menu structure. if ($this->isMenuPresenceAlternative($presence)) { $alternative[] = $presence; continue; } $standard[] = $presence; } if (count($standard)) { $this->presences->standard->put($moduleKey, $standard); } if (count($alternative)) { $this->presences->alternative->put($moduleKey, $alternative); } } return $this->presences; }
php
public function interpret() { /** @var Collection|ModuleInterface[] $modules */ $modules = $this->sortModules( $this->core->modules()->getModules() ); foreach ($modules as $moduleKey => $module) { // If the configuration has overriding data for this module's presence, // use it. Otherwise load the menu's own presence. // Normalize single & plural presences for each module. if ($this->isConfiguredModulePresenceDisabled($module)) { continue; } if ($this->hasConfiguredModulePresence($module)) { $configuredPresencesForModule = $this->normalizeConfiguredPresence( $this->getConfiguredModulePresence($module) ); $presencesForModule = $this->mergeNormalizedMenuPresences( $this->normalizeMenuPresence($module->getMenuPresence()), $configuredPresencesForModule ); } else { // If no configuration is set, simply normalize and use the original $presencesForModule = $this->normalizeMenuPresence($module->getMenuPresence()); } // If a module has no presence, skip it if ( ! $presencesForModule) { continue; } $standard = []; $alternative = []; foreach ($presencesForModule as $presence) { // If a menu presence is deemed 'alternative', // it should not appear in the normal menu structure. if ($this->isMenuPresenceAlternative($presence)) { $alternative[] = $presence; continue; } $standard[] = $presence; } if (count($standard)) { $this->presences->standard->put($moduleKey, $standard); } if (count($alternative)) { $this->presences->alternative->put($moduleKey, $alternative); } } return $this->presences; }
[ "public", "function", "interpret", "(", ")", "{", "/** @var Collection|ModuleInterface[] $modules */", "$", "modules", "=", "$", "this", "->", "sortModules", "(", "$", "this", "->", "core", "->", "modules", "(", ")", "->", "getModules", "(", ")", ")", ";", "...
Interprets configured module presences and returns a normalized data object. @return MenuConfiguredModulesDataInterface
[ "Interprets", "configured", "module", "presences", "and", "returns", "a", "normalized", "data", "object", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuModulesInterpreter.php#L58-L123
41,397
czim/laravel-cms-core
src/Menu/MenuModulesInterpreter.php
MenuModulesInterpreter.sortModules
protected function sortModules(Collection $modules) { $index = 0; // Make a mapping to easily look up configured order with // Account for possibility of either 'module key' => [] or 'module key' format in config $orderMap = array_map( function ($key) { if (is_string($key)) return $key; if ( ! is_string($this->configModules[$key])) { throw new UnexpectedValueException( "cms-modules.menu.modules entry '{$key}' must be string or have a non-numeric key" ); } return $this->configModules[$key]; }, array_keys($this->configModules) ); $orderMap = array_flip($orderMap); return $modules->sortBy(function (ModuleInterface $module) use (&$index, $orderMap) { // Order by configured order first, natural modules order second. if (count($orderMap)) { $primaryOrder = (int) array_get($orderMap, $module->getKey(), -2) + 1; } else { $primaryOrder = -1; } return $primaryOrder < 0 ? ++$index : (1 - 1 / $primaryOrder); }); }
php
protected function sortModules(Collection $modules) { $index = 0; // Make a mapping to easily look up configured order with // Account for possibility of either 'module key' => [] or 'module key' format in config $orderMap = array_map( function ($key) { if (is_string($key)) return $key; if ( ! is_string($this->configModules[$key])) { throw new UnexpectedValueException( "cms-modules.menu.modules entry '{$key}' must be string or have a non-numeric key" ); } return $this->configModules[$key]; }, array_keys($this->configModules) ); $orderMap = array_flip($orderMap); return $modules->sortBy(function (ModuleInterface $module) use (&$index, $orderMap) { // Order by configured order first, natural modules order second. if (count($orderMap)) { $primaryOrder = (int) array_get($orderMap, $module->getKey(), -2) + 1; } else { $primaryOrder = -1; } return $primaryOrder < 0 ? ++$index : (1 - 1 / $primaryOrder); }); }
[ "protected", "function", "sortModules", "(", "Collection", "$", "modules", ")", "{", "$", "index", "=", "0", ";", "// Make a mapping to easily look up configured order with", "// Account for possibility of either 'module key' => [] or 'module key' format in config", "$", "orderMap"...
Sorts the modules according as configured. @param Collection $modules @return Collection
[ "Sorts", "the", "modules", "according", "as", "configured", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuModulesInterpreter.php#L131-L166
41,398
czim/laravel-cms-core
src/Menu/MenuModulesInterpreter.php
MenuModulesInterpreter.getConfiguredModulePresence
protected function getConfiguredModulePresence(ModuleInterface $module) { if ( ! array_key_exists($module->getKey(), $this->configModules) || ! $this->configModules[ $module->getKey() ] ) { // @codeCoverageIgnoreStart return false; // @codeCoverageIgnoreEnd } return $this->configModules[ $module->getKey() ] ?: []; }
php
protected function getConfiguredModulePresence(ModuleInterface $module) { if ( ! array_key_exists($module->getKey(), $this->configModules) || ! $this->configModules[ $module->getKey() ] ) { // @codeCoverageIgnoreStart return false; // @codeCoverageIgnoreEnd } return $this->configModules[ $module->getKey() ] ?: []; }
[ "protected", "function", "getConfiguredModulePresence", "(", "ModuleInterface", "$", "module", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "module", "->", "getKey", "(", ")", ",", "$", "this", "->", "configModules", ")", "||", "!", "$", "this", ...
Returns raw presence configuration data, if an overriding custom presence was set. @param ModuleInterface $module @return array|false
[ "Returns", "raw", "presence", "configuration", "data", "if", "an", "overriding", "custom", "presence", "was", "set", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuModulesInterpreter.php#L185-L196
41,399
czim/laravel-cms-core
src/Menu/MenuModulesInterpreter.php
MenuModulesInterpreter.mergeNormalizedMenuPresences
protected function mergeNormalizedMenuPresences($oldPresences, $newPresences) { if (false === $oldPresences) { // @codeCoverageIgnoreStart return $newPresences; // @codeCoverageIgnoreEnd } // Should not matter, since setting the presence to false (instead of an array) // will disable the presences entirely if (false === $newPresences) { // @codeCoverageIgnoreStart return $oldPresences; // @codeCoverageIgnoreEnd } // Since menu presences are normalized as non-associative arrays, we must // assume that overrides or modifications are intended index for index. // The first presence will be enriched or overwritten with the first presence // listed, unless it is specifically flagged to be added. // Treat additions separately, splitting them off from the overriding/modifying/deleting definitions $additions = []; $removals = []; /** @var MenuPresenceInterface[] $newPresences */ $newPresences = array_values($newPresences); $splitForAddition = []; foreach ($newPresences as $index => $presence) { if ($presence->mode() == MenuPresenceMode::ADD) { $additions[] = $presence; $splitForAddition[] = $index; } } if (count($splitForAddition)) { foreach (array_reverse($splitForAddition) as $index) { unset($newPresences[$index]); } } /** @var MenuPresenceInterface[] $oldPresences */ /** @var MenuPresenceInterface[] $newPresences */ $oldPresences = array_values($oldPresences); $newPresences = array_values($newPresences); // Perform deletions, replacements or modifications foreach ($newPresences as $index => $presence) { if ( ! array_key_exists($index, $oldPresences)) { continue; } switch ($presence->mode()) { case MenuPresenceMode::DELETE: $removals[] = $index; continue 2; case MenuPresenceMode::REPLACE: $this->enrichConfiguredPresenceData($presence); $oldPresences[ $index] = $presence; continue 2; // Modify is the default mode default: // Merge children for groups that have further nested definitions if ( $oldPresences[ $index ]->type() == MenuPresenceType::GROUP && ( $presence->type() == MenuPresenceType::GROUP || ! in_array('type', $presence->explicitKeys() ?: []) ) && count($presence->children()) ) { // Set the merged children in the new presence, so they will be merged in // for the upcoming mergeMenuPresenceData call if (count($oldPresences[ $index]->children())) { $presence->setChildren( $this->mergeNormalizedMenuPresences( $oldPresences[ $index]->children(), $presence->children() ) ); } } $oldPresences[ $index ] = $this->mergeMenuPresenceData($oldPresences[ $index ], $presence); continue 2; } } if (count($removals)) { foreach (array_reverse($removals) as $index) { unset($oldPresences[$index]); } } foreach ($additions as $presence) { $this->enrichConfiguredPresenceData($presence); $oldPresences[] = $presence; } return $oldPresences; }
php
protected function mergeNormalizedMenuPresences($oldPresences, $newPresences) { if (false === $oldPresences) { // @codeCoverageIgnoreStart return $newPresences; // @codeCoverageIgnoreEnd } // Should not matter, since setting the presence to false (instead of an array) // will disable the presences entirely if (false === $newPresences) { // @codeCoverageIgnoreStart return $oldPresences; // @codeCoverageIgnoreEnd } // Since menu presences are normalized as non-associative arrays, we must // assume that overrides or modifications are intended index for index. // The first presence will be enriched or overwritten with the first presence // listed, unless it is specifically flagged to be added. // Treat additions separately, splitting them off from the overriding/modifying/deleting definitions $additions = []; $removals = []; /** @var MenuPresenceInterface[] $newPresences */ $newPresences = array_values($newPresences); $splitForAddition = []; foreach ($newPresences as $index => $presence) { if ($presence->mode() == MenuPresenceMode::ADD) { $additions[] = $presence; $splitForAddition[] = $index; } } if (count($splitForAddition)) { foreach (array_reverse($splitForAddition) as $index) { unset($newPresences[$index]); } } /** @var MenuPresenceInterface[] $oldPresences */ /** @var MenuPresenceInterface[] $newPresences */ $oldPresences = array_values($oldPresences); $newPresences = array_values($newPresences); // Perform deletions, replacements or modifications foreach ($newPresences as $index => $presence) { if ( ! array_key_exists($index, $oldPresences)) { continue; } switch ($presence->mode()) { case MenuPresenceMode::DELETE: $removals[] = $index; continue 2; case MenuPresenceMode::REPLACE: $this->enrichConfiguredPresenceData($presence); $oldPresences[ $index] = $presence; continue 2; // Modify is the default mode default: // Merge children for groups that have further nested definitions if ( $oldPresences[ $index ]->type() == MenuPresenceType::GROUP && ( $presence->type() == MenuPresenceType::GROUP || ! in_array('type', $presence->explicitKeys() ?: []) ) && count($presence->children()) ) { // Set the merged children in the new presence, so they will be merged in // for the upcoming mergeMenuPresenceData call if (count($oldPresences[ $index]->children())) { $presence->setChildren( $this->mergeNormalizedMenuPresences( $oldPresences[ $index]->children(), $presence->children() ) ); } } $oldPresences[ $index ] = $this->mergeMenuPresenceData($oldPresences[ $index ], $presence); continue 2; } } if (count($removals)) { foreach (array_reverse($removals) as $index) { unset($oldPresences[$index]); } } foreach ($additions as $presence) { $this->enrichConfiguredPresenceData($presence); $oldPresences[] = $presence; } return $oldPresences; }
[ "protected", "function", "mergeNormalizedMenuPresences", "(", "$", "oldPresences", ",", "$", "newPresences", ")", "{", "if", "(", "false", "===", "$", "oldPresences", ")", "{", "// @codeCoverageIgnoreStart", "return", "$", "newPresences", ";", "// @codeCoverageIgnoreE...
Merges two normalized menu presences into one. @param false|MenuPresenceInterface[] $oldPresences @param false|MenuPresenceInterface[] $newPresences @return MenuPresenceInterface[]
[ "Merges", "two", "normalized", "menu", "presences", "into", "one", "." ]
55a800c73e92390b4ef8268633ac96cd888e23b3
https://github.com/czim/laravel-cms-core/blob/55a800c73e92390b4ef8268633ac96cd888e23b3/src/Menu/MenuModulesInterpreter.php#L225-L331