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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
27,200
|
doganoo/PHPAlgorithms
|
src/Datastructure/Lists/LinkedLists/SinglyLinkedList.php
|
SinglyLinkedList.prepend
|
public function prepend(?Node $node): bool {
if ($node === null) {
return false;
}
$node->setNext($this->getHead());
$this->setHead($node);
return true;
}
|
php
|
public function prepend(?Node $node): bool {
if ($node === null) {
return false;
}
$node->setNext($this->getHead());
$this->setHead($node);
return true;
}
|
[
"public",
"function",
"prepend",
"(",
"?",
"Node",
"$",
"node",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"node",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"node",
"->",
"setNext",
"(",
"$",
"this",
"->",
"getHead",
"(",
")",
")",
";",
"$",
"this",
"->",
"setHead",
"(",
"$",
"node",
")",
";",
"return",
"true",
";",
"}"
] |
the prepend method simply checks first if the node is still valid.
If it does not equal to null, the next pointer of the new node is
set to head and the head is set to the new node in order to create
the new head.
@param \doganoo\PHPAlgorithms\Datastructure\Lists\Node $node
@return bool
|
[
"the",
"prepend",
"method",
"simply",
"checks",
"first",
"if",
"the",
"node",
"is",
"still",
"valid",
".",
"If",
"it",
"does",
"not",
"equal",
"to",
"null",
"the",
"next",
"pointer",
"of",
"the",
"new",
"node",
"is",
"set",
"to",
"head",
"and",
"the",
"head",
"is",
"set",
"to",
"the",
"new",
"node",
"in",
"order",
"to",
"create",
"the",
"new",
"head",
"."
] |
7d07d4b1970958defda3c88188b7683ec999735f
|
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/LinkedLists/SinglyLinkedList.php#L78-L85
|
27,201
|
doganoo/PHPAlgorithms
|
src/Datastructure/Graph/Tree/Trie/Trie.php
|
Trie._countWords
|
private function _countWords(?Node $node): int {
$result = 0;
if (null === $node) return $result;
if ($node->isEndOfWordNode()) $result++;
for ($i = 0; $i < self::ALPHABET_SIZE; $i++) {
if ($node->hasChild($i)) {
$child = $node->getChildNode($i);
$result += $this->_countWords($child);
}
}
return $result;
}
|
php
|
private function _countWords(?Node $node): int {
$result = 0;
if (null === $node) return $result;
if ($node->isEndOfWordNode()) $result++;
for ($i = 0; $i < self::ALPHABET_SIZE; $i++) {
if ($node->hasChild($i)) {
$child = $node->getChildNode($i);
$result += $this->_countWords($child);
}
}
return $result;
}
|
[
"private",
"function",
"_countWords",
"(",
"?",
"Node",
"$",
"node",
")",
":",
"int",
"{",
"$",
"result",
"=",
"0",
";",
"if",
"(",
"null",
"===",
"$",
"node",
")",
"return",
"$",
"result",
";",
"if",
"(",
"$",
"node",
"->",
"isEndOfWordNode",
"(",
")",
")",
"$",
"result",
"++",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"self",
"::",
"ALPHABET_SIZE",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"hasChild",
"(",
"$",
"i",
")",
")",
"{",
"$",
"child",
"=",
"$",
"node",
"->",
"getChildNode",
"(",
"$",
"i",
")",
";",
"$",
"result",
"+=",
"$",
"this",
"->",
"_countWords",
"(",
"$",
"child",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
helper method for counting number of words in the trie
@param Node $node
@return int
|
[
"helper",
"method",
"for",
"counting",
"number",
"of",
"words",
"in",
"the",
"trie"
] |
7d07d4b1970958defda3c88188b7683ec999735f
|
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/Trie/Trie.php#L136-L147
|
27,202
|
doganoo/PHPAlgorithms
|
src/Datastructure/Lists/Node.php
|
Node.size
|
public function size() {
/** @var Node $node */
$node = $this->next;
$size = 1;
while ($node !== null) {
$size++;
$node = $node->getNext();
}
return $size;
}
|
php
|
public function size() {
/** @var Node $node */
$node = $this->next;
$size = 1;
while ($node !== null) {
$size++;
$node = $node->getNext();
}
return $size;
}
|
[
"public",
"function",
"size",
"(",
")",
"{",
"/** @var Node $node */",
"$",
"node",
"=",
"$",
"this",
"->",
"next",
";",
"$",
"size",
"=",
"1",
";",
"while",
"(",
"$",
"node",
"!==",
"null",
")",
"{",
"$",
"size",
"++",
";",
"$",
"node",
"=",
"$",
"node",
"->",
"getNext",
"(",
")",
";",
"}",
"return",
"$",
"size",
";",
"}"
] |
counts the number of nodes
@return int
|
[
"counts",
"the",
"number",
"of",
"nodes"
] |
7d07d4b1970958defda3c88188b7683ec999735f
|
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/Node.php#L68-L78
|
27,203
|
doganoo/PHPAlgorithms
|
src/Datastructure/Graph/Tree/BinarySearchTree.php
|
BinarySearchTree.createFromArrayWithMinimumHeight
|
public static function createFromArrayWithMinimumHeight(?array $array): ?BinarySearchTree {
if (null === $array) {
return null;
}
$tree = new BinarySearchTree();
if (0 === \count($array)) {
return $tree;
}
$sort = new MergeSort();
$array = $sort->sort($array);
$root = BinarySearchTree::_createFromArrayWithMinimumHeight($array, 0, \count($array) - 1);
$tree = new BinarySearchTree();
$tree->setRoot($root);
return $tree;
}
|
php
|
public static function createFromArrayWithMinimumHeight(?array $array): ?BinarySearchTree {
if (null === $array) {
return null;
}
$tree = new BinarySearchTree();
if (0 === \count($array)) {
return $tree;
}
$sort = new MergeSort();
$array = $sort->sort($array);
$root = BinarySearchTree::_createFromArrayWithMinimumHeight($array, 0, \count($array) - 1);
$tree = new BinarySearchTree();
$tree->setRoot($root);
return $tree;
}
|
[
"public",
"static",
"function",
"createFromArrayWithMinimumHeight",
"(",
"?",
"array",
"$",
"array",
")",
":",
"?",
"BinarySearchTree",
"{",
"if",
"(",
"null",
"===",
"$",
"array",
")",
"{",
"return",
"null",
";",
"}",
"$",
"tree",
"=",
"new",
"BinarySearchTree",
"(",
")",
";",
"if",
"(",
"0",
"===",
"\\",
"count",
"(",
"$",
"array",
")",
")",
"{",
"return",
"$",
"tree",
";",
"}",
"$",
"sort",
"=",
"new",
"MergeSort",
"(",
")",
";",
"$",
"array",
"=",
"$",
"sort",
"->",
"sort",
"(",
"$",
"array",
")",
";",
"$",
"root",
"=",
"BinarySearchTree",
"::",
"_createFromArrayWithMinimumHeight",
"(",
"$",
"array",
",",
"0",
",",
"\\",
"count",
"(",
"$",
"array",
")",
"-",
"1",
")",
";",
"$",
"tree",
"=",
"new",
"BinarySearchTree",
"(",
")",
";",
"$",
"tree",
"->",
"setRoot",
"(",
"$",
"root",
")",
";",
"return",
"$",
"tree",
";",
"}"
] |
converts an array to a BST with minimum height.
@param array|null $array
@return BinarySearchTree|null
|
[
"converts",
"an",
"array",
"to",
"a",
"BST",
"with",
"minimum",
"height",
"."
] |
7d07d4b1970958defda3c88188b7683ec999735f
|
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/BinarySearchTree.php#L115-L129
|
27,204
|
doganoo/PHPAlgorithms
|
src/Datastructure/Graph/Tree/BinarySearchTree.php
|
BinarySearchTree.search
|
public function search($value): ?BinarySearchNode {
/** @var BinarySearchNode $node */
$node = $this->getRoot();
while (null !== $node) {
if (Comparator::equals($value, $node->getValue())) {
return $node;
} else if (Comparator::lessThan($value, $node->getValue())) {
$node = $node->getLeft();
} else if (Comparator::greaterThan($value, $node->getValue())) {
$node = $node->getRight();
} else {
throw new InvalidSearchComparisionException("no comparision returned true. Maybe you passed different data types (scalar, object)?");
}
}
return null;
}
|
php
|
public function search($value): ?BinarySearchNode {
/** @var BinarySearchNode $node */
$node = $this->getRoot();
while (null !== $node) {
if (Comparator::equals($value, $node->getValue())) {
return $node;
} else if (Comparator::lessThan($value, $node->getValue())) {
$node = $node->getLeft();
} else if (Comparator::greaterThan($value, $node->getValue())) {
$node = $node->getRight();
} else {
throw new InvalidSearchComparisionException("no comparision returned true. Maybe you passed different data types (scalar, object)?");
}
}
return null;
}
|
[
"public",
"function",
"search",
"(",
"$",
"value",
")",
":",
"?",
"BinarySearchNode",
"{",
"/** @var BinarySearchNode $node */",
"$",
"node",
"=",
"$",
"this",
"->",
"getRoot",
"(",
")",
";",
"while",
"(",
"null",
"!==",
"$",
"node",
")",
"{",
"if",
"(",
"Comparator",
"::",
"equals",
"(",
"$",
"value",
",",
"$",
"node",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"return",
"$",
"node",
";",
"}",
"else",
"if",
"(",
"Comparator",
"::",
"lessThan",
"(",
"$",
"value",
",",
"$",
"node",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"getLeft",
"(",
")",
";",
"}",
"else",
"if",
"(",
"Comparator",
"::",
"greaterThan",
"(",
"$",
"value",
",",
"$",
"node",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"getRight",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidSearchComparisionException",
"(",
"\"no comparision returned true. Maybe you passed different data types (scalar, object)?\"",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
searches a value
@param $value
@return BinarySearchNode|null
@throws InvalidSearchComparisionException
|
[
"searches",
"a",
"value"
] |
7d07d4b1970958defda3c88188b7683ec999735f
|
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/BinarySearchTree.php#L164-L179
|
27,205
|
ibrandcc/laravel-sms
|
src/Sms.php
|
Sms.checkAttempts
|
private function checkAttempts($code)
{
$maxAttempts = config('ibrand.sms.code.maxAttempts');
if ($code->expireAt > Carbon::now() && $code->attempts < $maxAttempts) {
return false;
}
return true;
}
|
php
|
private function checkAttempts($code)
{
$maxAttempts = config('ibrand.sms.code.maxAttempts');
if ($code->expireAt > Carbon::now() && $code->attempts < $maxAttempts) {
return false;
}
return true;
}
|
[
"private",
"function",
"checkAttempts",
"(",
"$",
"code",
")",
"{",
"$",
"maxAttempts",
"=",
"config",
"(",
"'ibrand.sms.code.maxAttempts'",
")",
";",
"if",
"(",
"$",
"code",
"->",
"expireAt",
">",
"Carbon",
"::",
"now",
"(",
")",
"&&",
"$",
"code",
"->",
"attempts",
"<",
"$",
"maxAttempts",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check attempt times.
@param $code
@return bool
|
[
"Check",
"attempt",
"times",
"."
] |
6fd0325128721d0096faa6557e62e64886d6f737
|
https://github.com/ibrandcc/laravel-sms/blob/6fd0325128721d0096faa6557e62e64886d6f737/src/Sms.php#L173-L182
|
27,206
|
orchestral/kernel
|
src/Database/Console/Migrations/Packages.php
|
Packages.getPackageMigrationPaths
|
protected function getPackageMigrationPaths(string $package): array
{
return collect($this->option('path') ?: 'database/migrations')
->map(function ($path) use ($package) {
return $this->packagePath.'/'.$package.'/'.$path;
})->all();
}
|
php
|
protected function getPackageMigrationPaths(string $package): array
{
return collect($this->option('path') ?: 'database/migrations')
->map(function ($path) use ($package) {
return $this->packagePath.'/'.$package.'/'.$path;
})->all();
}
|
[
"protected",
"function",
"getPackageMigrationPaths",
"(",
"string",
"$",
"package",
")",
":",
"array",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"option",
"(",
"'path'",
")",
"?",
":",
"'database/migrations'",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"path",
")",
"use",
"(",
"$",
"package",
")",
"{",
"return",
"$",
"this",
"->",
"packagePath",
".",
"'/'",
".",
"$",
"package",
".",
"'/'",
".",
"$",
"path",
";",
"}",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Get the path to the package migration directory.
@param string $package
@return array
|
[
"Get",
"the",
"path",
"to",
"the",
"package",
"migration",
"directory",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Database/Console/Migrations/Packages.php#L35-L41
|
27,207
|
melisplatform/melis-core
|
src/Controller/PlatformsController.php
|
PlatformsController.renderPlatformGenericFormAction
|
public function renderPlatformGenericFormAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what configuration in the app.tool.php that will be used.
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$platformForm = $melisTool->getForm('meliscore_platform_generic_form');
$plfId = $this->params()->fromQuery('plf_id', '');
if ($plfId)
{
$platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform');
$platform = $platformTable->getEntryById($plfId)->current();
if (!empty($platform))
{
$platformForm->bind($platform);
if (getenv('MELIS_PLATFORM') == $platform->plf_name)
{
// Deactivating the platform name if the current platform is same to the requested platform
$platformForm->get('plf_name')->setAttribute('disabled', true);
}
}
}
$view = new ViewModel();
$view->meliscore_platform_generic_form = $platformForm;
$view->melisKey = $melisKey;
$view->platformId = $plfId;
return $view;
}
|
php
|
public function renderPlatformGenericFormAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
// declare the Tool service that we will be using to completely create our tool.
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
// tell the Tool what configuration in the app.tool.php that will be used.
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$platformForm = $melisTool->getForm('meliscore_platform_generic_form');
$plfId = $this->params()->fromQuery('plf_id', '');
if ($plfId)
{
$platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform');
$platform = $platformTable->getEntryById($plfId)->current();
if (!empty($platform))
{
$platformForm->bind($platform);
if (getenv('MELIS_PLATFORM') == $platform->plf_name)
{
// Deactivating the platform name if the current platform is same to the requested platform
$platformForm->get('plf_name')->setAttribute('disabled', true);
}
}
}
$view = new ViewModel();
$view->meliscore_platform_generic_form = $platformForm;
$view->melisKey = $melisKey;
$view->platformId = $plfId;
return $view;
}
|
[
"public",
"function",
"renderPlatformGenericFormAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"// declare the Tool service that we will be using to completely create our tool.",
"$",
"melisTool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
"// tell the Tool what configuration in the app.tool.php that will be used.",
"$",
"melisTool",
"->",
"setMelisToolKey",
"(",
"self",
"::",
"TOOL_INDEX",
",",
"self",
"::",
"TOOL_KEY",
")",
";",
"$",
"platformForm",
"=",
"$",
"melisTool",
"->",
"getForm",
"(",
"'meliscore_platform_generic_form'",
")",
";",
"$",
"plfId",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'plf_id'",
",",
"''",
")",
";",
"if",
"(",
"$",
"plfId",
")",
"{",
"$",
"platformTable",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTablePlatform'",
")",
";",
"$",
"platform",
"=",
"$",
"platformTable",
"->",
"getEntryById",
"(",
"$",
"plfId",
")",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"platform",
")",
")",
"{",
"$",
"platformForm",
"->",
"bind",
"(",
"$",
"platform",
")",
";",
"if",
"(",
"getenv",
"(",
"'MELIS_PLATFORM'",
")",
"==",
"$",
"platform",
"->",
"plf_name",
")",
"{",
"// Deactivating the platform name if the current platform is same to the requested platform",
"$",
"platformForm",
"->",
"get",
"(",
"'plf_name'",
")",
"->",
"setAttribute",
"(",
"'disabled'",
",",
"true",
")",
";",
"}",
"}",
"}",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"meliscore_platform_generic_form",
"=",
"$",
"platformForm",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"$",
"view",
"->",
"platformId",
"=",
"$",
"plfId",
";",
"return",
"$",
"view",
";",
"}"
] |
Renders the Generic form of the Platform
for creating new and updating new platform
@return \Zend\View\Model\ViewModel
|
[
"Renders",
"the",
"Generic",
"form",
"of",
"the",
"Platform",
"for",
"creating",
"new",
"and",
"updating",
"new",
"platform"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformsController.php#L149-L186
|
27,208
|
melisplatform/melis-core
|
src/Controller/PlatformsController.php
|
PlatformsController.deletePlatformAction
|
public function deletePlatformAction()
{
$response = array();
$this->getEventManager()->trigger('meliscore_platform_delete_start', $this, $response);
$translator = $this->getServiceLocator()->get('translator');
$platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform');
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$textTitle = 'tr_meliscore_tool_platform_title';
$textMessage = 'tr_meliscore_tool_platform_prompts_delete_failed';
$id = 0;
$success = 0;
$platform = '';
if($this->getRequest()->isPost())
{
$id = (int) $this->getRequest()->getPost('id');
if(is_numeric($id))
{
$domainData = $platformTable->getEntryById($id);
$domainData = $domainData->current();
if(!empty($domainData))
{
$platform = $domainData->plf_name;
$platformTable->deleteById($id);
$textMessage = 'tr_meliscore_tool_platform_prompts_delete_success';
$success = 1;
}
}
}
$response = array(
'textTitle' => $textTitle,
'textMessage' => $textMessage,
'success' => $success
);
$eventData = array_merge($response, array(
'platform' => $platform,
'id' => $id,
'typeCode' => 'CORE_PLATFORM_DELETE',
'itemId' => $id
));
$this->getEventManager()->trigger('meliscore_platform_delete_end', $this, $eventData);
return new JsonModel($response);
}
|
php
|
public function deletePlatformAction()
{
$response = array();
$this->getEventManager()->trigger('meliscore_platform_delete_start', $this, $response);
$translator = $this->getServiceLocator()->get('translator');
$platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform');
$melisTool = $this->getServiceLocator()->get('MelisCoreTool');
$melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY);
$textTitle = 'tr_meliscore_tool_platform_title';
$textMessage = 'tr_meliscore_tool_platform_prompts_delete_failed';
$id = 0;
$success = 0;
$platform = '';
if($this->getRequest()->isPost())
{
$id = (int) $this->getRequest()->getPost('id');
if(is_numeric($id))
{
$domainData = $platformTable->getEntryById($id);
$domainData = $domainData->current();
if(!empty($domainData))
{
$platform = $domainData->plf_name;
$platformTable->deleteById($id);
$textMessage = 'tr_meliscore_tool_platform_prompts_delete_success';
$success = 1;
}
}
}
$response = array(
'textTitle' => $textTitle,
'textMessage' => $textMessage,
'success' => $success
);
$eventData = array_merge($response, array(
'platform' => $platform,
'id' => $id,
'typeCode' => 'CORE_PLATFORM_DELETE',
'itemId' => $id
));
$this->getEventManager()->trigger('meliscore_platform_delete_end', $this, $eventData);
return new JsonModel($response);
}
|
[
"public",
"function",
"deletePlatformAction",
"(",
")",
"{",
"$",
"response",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"'meliscore_platform_delete_start'",
",",
"$",
"this",
",",
"$",
"response",
")",
";",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"platformTable",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTablePlatform'",
")",
";",
"$",
"melisTool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
"$",
"melisTool",
"->",
"setMelisToolKey",
"(",
"self",
"::",
"TOOL_INDEX",
",",
"self",
"::",
"TOOL_KEY",
")",
";",
"$",
"textTitle",
"=",
"'tr_meliscore_tool_platform_title'",
";",
"$",
"textMessage",
"=",
"'tr_meliscore_tool_platform_prompts_delete_failed'",
";",
"$",
"id",
"=",
"0",
";",
"$",
"success",
"=",
"0",
";",
"$",
"platform",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getPost",
"(",
"'id'",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"id",
")",
")",
"{",
"$",
"domainData",
"=",
"$",
"platformTable",
"->",
"getEntryById",
"(",
"$",
"id",
")",
";",
"$",
"domainData",
"=",
"$",
"domainData",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"domainData",
")",
")",
"{",
"$",
"platform",
"=",
"$",
"domainData",
"->",
"plf_name",
";",
"$",
"platformTable",
"->",
"deleteById",
"(",
"$",
"id",
")",
";",
"$",
"textMessage",
"=",
"'tr_meliscore_tool_platform_prompts_delete_success'",
";",
"$",
"success",
"=",
"1",
";",
"}",
"}",
"}",
"$",
"response",
"=",
"array",
"(",
"'textTitle'",
"=>",
"$",
"textTitle",
",",
"'textMessage'",
"=>",
"$",
"textMessage",
",",
"'success'",
"=>",
"$",
"success",
")",
";",
"$",
"eventData",
"=",
"array_merge",
"(",
"$",
"response",
",",
"array",
"(",
"'platform'",
"=>",
"$",
"platform",
",",
"'id'",
"=>",
"$",
"id",
",",
"'typeCode'",
"=>",
"'CORE_PLATFORM_DELETE'",
",",
"'itemId'",
"=>",
"$",
"id",
")",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"'meliscore_platform_delete_end'",
",",
"$",
"this",
",",
"$",
"eventData",
")",
";",
"return",
"new",
"JsonModel",
"(",
"$",
"response",
")",
";",
"}"
] |
Deletion of the platform
@return \Zend\View\Model\JsonModel
|
[
"Deletion",
"of",
"the",
"platform"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformsController.php#L404-L453
|
27,209
|
melisplatform/melis-core
|
src/Controller/PlatformsController.php
|
PlatformsController.hasAccess
|
private function hasAccess($key): bool
{
$hasAccess = $this->getServiceLocator()->get('MelisCoreRights')->canAccess($key);
return $hasAccess;
}
|
php
|
private function hasAccess($key): bool
{
$hasAccess = $this->getServiceLocator()->get('MelisCoreRights')->canAccess($key);
return $hasAccess;
}
|
[
"private",
"function",
"hasAccess",
"(",
"$",
"key",
")",
":",
"bool",
"{",
"$",
"hasAccess",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreRights'",
")",
"->",
"canAccess",
"(",
"$",
"key",
")",
";",
"return",
"$",
"hasAccess",
";",
"}"
] |
Checks whether the user has access to this tools or not
@param $key
@return bool
|
[
"Checks",
"whether",
"the",
"user",
"has",
"access",
"to",
"this",
"tools",
"or",
"not"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformsController.php#L489-L494
|
27,210
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.checkFormAction
|
public function checkFormAction()
{
$request = $this->getRequest();
$success = 0;
$errors = [];
if ($request->isPost()) {
$formInputs = $this->getTool('meliscore', 'melis_core_gdpr_tool')->sanitizeRecursive(get_object_vars($request->getPost()), [], true);
$formConfig = $this->getFormConfig('meliscore/tools/melis_core_gdpr_tool/forms/melis_core_gdpr_search_form', 'melis_core_gdpr_search_form');
$form = $this->getForm($formConfig);
$form->setData($formInputs);
if ($form->isValid()) {
$success = 1;
}
else {
$errors = $this->getFormErrors($form->getMessages(), $formConfig);
$success = 0;
}
}
return new JsonModel ([
'success' => $success,
'errors' => $errors,
]);
}
|
php
|
public function checkFormAction()
{
$request = $this->getRequest();
$success = 0;
$errors = [];
if ($request->isPost()) {
$formInputs = $this->getTool('meliscore', 'melis_core_gdpr_tool')->sanitizeRecursive(get_object_vars($request->getPost()), [], true);
$formConfig = $this->getFormConfig('meliscore/tools/melis_core_gdpr_tool/forms/melis_core_gdpr_search_form', 'melis_core_gdpr_search_form');
$form = $this->getForm($formConfig);
$form->setData($formInputs);
if ($form->isValid()) {
$success = 1;
}
else {
$errors = $this->getFormErrors($form->getMessages(), $formConfig);
$success = 0;
}
}
return new JsonModel ([
'success' => $success,
'errors' => $errors,
]);
}
|
[
"public",
"function",
"checkFormAction",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"success",
"=",
"0",
";",
"$",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"formInputs",
"=",
"$",
"this",
"->",
"getTool",
"(",
"'meliscore'",
",",
"'melis_core_gdpr_tool'",
")",
"->",
"sanitizeRecursive",
"(",
"get_object_vars",
"(",
"$",
"request",
"->",
"getPost",
"(",
")",
")",
",",
"[",
"]",
",",
"true",
")",
";",
"$",
"formConfig",
"=",
"$",
"this",
"->",
"getFormConfig",
"(",
"'meliscore/tools/melis_core_gdpr_tool/forms/melis_core_gdpr_search_form'",
",",
"'melis_core_gdpr_search_form'",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
"$",
"formConfig",
")",
";",
"$",
"form",
"->",
"setData",
"(",
"$",
"formInputs",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"success",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"getFormErrors",
"(",
"$",
"form",
"->",
"getMessages",
"(",
")",
",",
"$",
"formConfig",
")",
";",
"$",
"success",
"=",
"0",
";",
"}",
"}",
"return",
"new",
"JsonModel",
"(",
"[",
"'success'",
"=>",
"$",
"success",
",",
"'errors'",
"=>",
"$",
"errors",
",",
"]",
")",
";",
"}"
] |
This will get the data from the service which will get
user info from modules that listens to the event.
@return JsonModel
|
[
"This",
"will",
"get",
"the",
"data",
"from",
"the",
"service",
"which",
"will",
"get",
"user",
"info",
"from",
"modules",
"that",
"listens",
"to",
"the",
"event",
"."
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L25-L50
|
27,211
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.melisCoreGdprExtractSelectedAction
|
public function melisCoreGdprExtractSelectedAction()
{
$idsToBeExtracted = $this->getRequest()->getPost('id');
/** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */
$melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
$xml = $melisCoreGdprService->extractSelected($idsToBeExtracted);
$name = "melisplatformgdpr.xml";
//$response = $this->downloadXml($name, $xml);
$response = $this->getResponse();
$headers = $response->getHeaders();
$headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
$headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$name."\"");
$headers->addHeaderLine('Accept-Ranges', 'bytes');
$headers->addHeaderLine('Content-Length', strlen($xml));
$headers->addHeaderLine('fileName', $name);
$response->setContent($xml);
$response->setStatusCode(200);
$view = new ViewModel();
$view->setTerminal(true);
$view->content = $response->getContent();
return $view;
}
|
php
|
public function melisCoreGdprExtractSelectedAction()
{
$idsToBeExtracted = $this->getRequest()->getPost('id');
/** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */
$melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
$xml = $melisCoreGdprService->extractSelected($idsToBeExtracted);
$name = "melisplatformgdpr.xml";
//$response = $this->downloadXml($name, $xml);
$response = $this->getResponse();
$headers = $response->getHeaders();
$headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
$headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$name."\"");
$headers->addHeaderLine('Accept-Ranges', 'bytes');
$headers->addHeaderLine('Content-Length', strlen($xml));
$headers->addHeaderLine('fileName', $name);
$response->setContent($xml);
$response->setStatusCode(200);
$view = new ViewModel();
$view->setTerminal(true);
$view->content = $response->getContent();
return $view;
}
|
[
"public",
"function",
"melisCoreGdprExtractSelectedAction",
"(",
")",
"{",
"$",
"idsToBeExtracted",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"getPost",
"(",
"'id'",
")",
";",
"/** @var \\MelisCore\\Service\\MelisCoreGdprService $melisCoreGdprService */",
"$",
"melisCoreGdprService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreGdprService'",
")",
";",
"$",
"xml",
"=",
"$",
"melisCoreGdprService",
"->",
"extractSelected",
"(",
"$",
"idsToBeExtracted",
")",
";",
"$",
"name",
"=",
"\"melisplatformgdpr.xml\"",
";",
"//$response = $this->downloadXml($name, $xml);",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"response",
"->",
"getHeaders",
"(",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Content-Type'",
",",
"'text/xml; charset=utf-8'",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Content-Disposition'",
",",
"\"attachment; filename=\\\"\"",
".",
"$",
"name",
".",
"\"\\\"\"",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Accept-Ranges'",
",",
"'bytes'",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Content-Length'",
",",
"strlen",
"(",
"$",
"xml",
")",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'fileName'",
",",
"$",
"name",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"xml",
")",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"200",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"setTerminal",
"(",
"true",
")",
";",
"$",
"view",
"->",
"content",
"=",
"$",
"response",
"->",
"getContent",
"(",
")",
";",
"return",
"$",
"view",
";",
"}"
] |
This will generate an xml file from the data based on the ids
@return HttpResponse
|
[
"This",
"will",
"generate",
"an",
"xml",
"file",
"from",
"the",
"data",
"based",
"on",
"the",
"ids"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L56-L83
|
27,212
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.melisCoreGdprDeleteSelectedAction
|
public function melisCoreGdprDeleteSelectedAction()
{
$request = $this->getRequest();
$success = 0;
if ($request->isPost()) {
$idsToBeDeleted = get_object_vars($request->getPost());
$melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
$finalData = $melisCoreGdprService->deleteSelected($idsToBeDeleted);
$success = 1;
foreach ($finalData as $key => $value) {
if (!$value) {
$success = 0;
}
}
}
return new JsonModel ([
'success' => $success,
]);
}
|
php
|
public function melisCoreGdprDeleteSelectedAction()
{
$request = $this->getRequest();
$success = 0;
if ($request->isPost()) {
$idsToBeDeleted = get_object_vars($request->getPost());
$melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
$finalData = $melisCoreGdprService->deleteSelected($idsToBeDeleted);
$success = 1;
foreach ($finalData as $key => $value) {
if (!$value) {
$success = 0;
}
}
}
return new JsonModel ([
'success' => $success,
]);
}
|
[
"public",
"function",
"melisCoreGdprDeleteSelectedAction",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"success",
"=",
"0",
";",
"if",
"(",
"$",
"request",
"->",
"isPost",
"(",
")",
")",
"{",
"$",
"idsToBeDeleted",
"=",
"get_object_vars",
"(",
"$",
"request",
"->",
"getPost",
"(",
")",
")",
";",
"$",
"melisCoreGdprService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreGdprService'",
")",
";",
"$",
"finalData",
"=",
"$",
"melisCoreGdprService",
"->",
"deleteSelected",
"(",
"$",
"idsToBeDeleted",
")",
";",
"$",
"success",
"=",
"1",
";",
"foreach",
"(",
"$",
"finalData",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"$",
"success",
"=",
"0",
";",
"}",
"}",
"}",
"return",
"new",
"JsonModel",
"(",
"[",
"'success'",
"=>",
"$",
"success",
",",
"]",
")",
";",
"}"
] |
This will delete the data based on the selected ids
@return JsonModel
|
[
"This",
"will",
"delete",
"the",
"data",
"based",
"on",
"the",
"selected",
"ids"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L90-L112
|
27,213
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.renderMelisCoreGdprContainerAction
|
public function renderMelisCoreGdprContainerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function renderMelisCoreGdprContainerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"renderMelisCoreGdprContainerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Container for the Gdpr page
which will call all interface
or zones inside of it which are
header and content
@return view model
|
[
"Container",
"for",
"the",
"Gdpr",
"page",
"which",
"will",
"call",
"all",
"interface",
"or",
"zones",
"inside",
"of",
"it",
"which",
"are",
"header",
"and",
"content"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L121-L129
|
27,214
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.renderMelisCoreGdprHeaderAction
|
public function renderMelisCoreGdprHeaderAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function renderMelisCoreGdprHeaderAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"renderMelisCoreGdprHeaderAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Header for the Gdpr page
displays the title and the
description of the page
@return view model
|
[
"Header",
"for",
"the",
"Gdpr",
"page",
"displays",
"the",
"title",
"and",
"the",
"description",
"of",
"the",
"page"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L137-L145
|
27,215
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.renderMelisCoreGdprContentAction
|
public function renderMelisCoreGdprContentAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function renderMelisCoreGdprContentAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"renderMelisCoreGdprContentAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Content of the Gdpr page
which will call all the interfaces
under it. which are search form
and tabs
@return ViewModel
|
[
"Content",
"of",
"the",
"Gdpr",
"page",
"which",
"will",
"call",
"all",
"the",
"interfaces",
"under",
"it",
".",
"which",
"are",
"search",
"form",
"and",
"tabs"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L154-L162
|
27,216
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.renderMelisCoreGdprSearchFormAction
|
public function renderMelisCoreGdprSearchFormAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$form = $this->getTool('meliscore', 'melis_core_gdpr_tool')->getForm('melis_core_gdpr_search_form');
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->form = $form;
return $view;
}
|
php
|
public function renderMelisCoreGdprSearchFormAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$form = $this->getTool('meliscore', 'melis_core_gdpr_tool')->getForm('melis_core_gdpr_search_form');
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->form = $form;
return $view;
}
|
[
"public",
"function",
"renderMelisCoreGdprSearchFormAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"getTool",
"(",
"'meliscore'",
",",
"'melis_core_gdpr_tool'",
")",
"->",
"getForm",
"(",
"'melis_core_gdpr_search_form'",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"$",
"view",
"->",
"form",
"=",
"$",
"form",
";",
"return",
"$",
"view",
";",
"}"
] |
Search form of the Gdpr page
which will be used for the
searching of user data
@return view model
|
[
"Search",
"form",
"of",
"the",
"Gdpr",
"page",
"which",
"will",
"be",
"used",
"for",
"the",
"searching",
"of",
"user",
"data"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L170-L181
|
27,217
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.renderMelisCoreGdprTabsAction
|
public function renderMelisCoreGdprTabsAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$show = $this->params()->fromQuery('show', false);
$formData = $this->params()->fromQuery('formData', []);
if (!empty($formData)) {
$finalData = [];
foreach ($formData as $input) {
$finalData[$input['name']] = $input['value'];
}
$melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
$modulesData = $melisCoreGdprService->getUserInfo($finalData);
}
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->show = $show;
if (isset($modulesData['results']) && !empty($modulesData['results'])) {
$view->modules = $modulesData['results'];
}
return $view;
}
|
php
|
public function renderMelisCoreGdprTabsAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$show = $this->params()->fromQuery('show', false);
$formData = $this->params()->fromQuery('formData', []);
if (!empty($formData)) {
$finalData = [];
foreach ($formData as $input) {
$finalData[$input['name']] = $input['value'];
}
$melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService');
$modulesData = $melisCoreGdprService->getUserInfo($finalData);
}
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->show = $show;
if (isset($modulesData['results']) && !empty($modulesData['results'])) {
$view->modules = $modulesData['results'];
}
return $view;
}
|
[
"public",
"function",
"renderMelisCoreGdprTabsAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"show",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'show'",
",",
"false",
")",
";",
"$",
"formData",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromQuery",
"(",
"'formData'",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"formData",
")",
")",
"{",
"$",
"finalData",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"formData",
"as",
"$",
"input",
")",
"{",
"$",
"finalData",
"[",
"$",
"input",
"[",
"'name'",
"]",
"]",
"=",
"$",
"input",
"[",
"'value'",
"]",
";",
"}",
"$",
"melisCoreGdprService",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreGdprService'",
")",
";",
"$",
"modulesData",
"=",
"$",
"melisCoreGdprService",
"->",
"getUserInfo",
"(",
"$",
"finalData",
")",
";",
"}",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"$",
"view",
"->",
"show",
"=",
"$",
"show",
";",
"if",
"(",
"isset",
"(",
"$",
"modulesData",
"[",
"'results'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"modulesData",
"[",
"'results'",
"]",
")",
")",
"{",
"$",
"view",
"->",
"modules",
"=",
"$",
"modulesData",
"[",
"'results'",
"]",
";",
"}",
"return",
"$",
"view",
";",
"}"
] |
The tabs that will show the records of user in every module
@return view model
|
[
"The",
"tabs",
"that",
"will",
"show",
"the",
"records",
"of",
"user",
"in",
"every",
"module"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L187-L212
|
27,218
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.getTool
|
private function getTool($pluginKey, $toolKey)
{
$tool = $this->getServiceLocator()->get('MelisCoreTool');
$tool->setMelisToolKey($pluginKey, $toolKey);
return $tool;
}
|
php
|
private function getTool($pluginKey, $toolKey)
{
$tool = $this->getServiceLocator()->get('MelisCoreTool');
$tool->setMelisToolKey($pluginKey, $toolKey);
return $tool;
}
|
[
"private",
"function",
"getTool",
"(",
"$",
"pluginKey",
",",
"$",
"toolKey",
")",
"{",
"$",
"tool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
"$",
"tool",
"->",
"setMelisToolKey",
"(",
"$",
"pluginKey",
",",
"$",
"toolKey",
")",
";",
"return",
"$",
"tool",
";",
"}"
] |
Gets the tool
@param plugin key
@param tool key
@return array|object
|
[
"Gets",
"the",
"tool"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L221-L227
|
27,219
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.getForm
|
private function getForm($formConfig)
{
$factory = new \Zend\Form\Factory();
$formElements = $this->serviceLocator->get('FormElementManager');
$factory->setFormElementManager($formElements);
$form = $factory->createForm($formConfig);
return $form;
}
|
php
|
private function getForm($formConfig)
{
$factory = new \Zend\Form\Factory();
$formElements = $this->serviceLocator->get('FormElementManager');
$factory->setFormElementManager($formElements);
$form = $factory->createForm($formConfig);
return $form;
}
|
[
"private",
"function",
"getForm",
"(",
"$",
"formConfig",
")",
"{",
"$",
"factory",
"=",
"new",
"\\",
"Zend",
"\\",
"Form",
"\\",
"Factory",
"(",
")",
";",
"$",
"formElements",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'FormElementManager'",
")",
";",
"$",
"factory",
"->",
"setFormElementManager",
"(",
"$",
"formElements",
")",
";",
"$",
"form",
"=",
"$",
"factory",
"->",
"createForm",
"(",
"$",
"formConfig",
")",
";",
"return",
"$",
"form",
";",
"}"
] |
Gets the form
@param formConfig
@return \Zend\Form\ElementInterface
|
[
"Gets",
"the",
"form"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L234-L242
|
27,220
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.getFormConfig
|
private function getFormConfig($formPath, $form)
{
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$appConfigForm = $melisCoreConfig->getFormMergedAndOrdered($formPath, $form);
return $appConfigForm;
}
|
php
|
private function getFormConfig($formPath, $form)
{
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$appConfigForm = $melisCoreConfig->getFormMergedAndOrdered($formPath, $form);
return $appConfigForm;
}
|
[
"private",
"function",
"getFormConfig",
"(",
"$",
"formPath",
",",
"$",
"form",
")",
"{",
"$",
"melisCoreConfig",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"appConfigForm",
"=",
"$",
"melisCoreConfig",
"->",
"getFormMergedAndOrdered",
"(",
"$",
"formPath",
",",
"$",
"form",
")",
";",
"return",
"$",
"appConfigForm",
";",
"}"
] |
This will get the form config
@param $formPath
@param $form
@return mixed
|
[
"This",
"will",
"get",
"the",
"form",
"config"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L250-L256
|
27,221
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.downloadXml
|
private function downloadXml($fileName, $xml)
{
//$response = new HttpResponse();
$response = $this->getResponse();
$headers = $response->getHeaders();
$headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
$headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$fileName."\"");
$headers->addHeaderLine('Accept-Ranges', 'bytes');
$headers->addHeaderLine('Content-Length', strlen($xml));
$headers->addHeaderLine('fileName', $fileName);
$response->setContent($xml);
$response->setStatusCode(200);
return $response;
}
|
php
|
private function downloadXml($fileName, $xml)
{
//$response = new HttpResponse();
$response = $this->getResponse();
$headers = $response->getHeaders();
$headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8');
$headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$fileName."\"");
$headers->addHeaderLine('Accept-Ranges', 'bytes');
$headers->addHeaderLine('Content-Length', strlen($xml));
$headers->addHeaderLine('fileName', $fileName);
$response->setContent($xml);
$response->setStatusCode(200);
return $response;
}
|
[
"private",
"function",
"downloadXml",
"(",
"$",
"fileName",
",",
"$",
"xml",
")",
"{",
"//$response = new HttpResponse();",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"response",
"->",
"getHeaders",
"(",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Content-Type'",
",",
"'text/xml; charset=utf-8'",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Content-Disposition'",
",",
"\"attachment; filename=\\\"\"",
".",
"$",
"fileName",
".",
"\"\\\"\"",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Accept-Ranges'",
",",
"'bytes'",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'Content-Length'",
",",
"strlen",
"(",
"$",
"xml",
")",
")",
";",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'fileName'",
",",
"$",
"fileName",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"xml",
")",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"200",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
This will download the xml as a file
@param file name
@param xml
@return HttpResponse
|
[
"This",
"will",
"download",
"the",
"xml",
"as",
"a",
"file"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L264-L279
|
27,222
|
melisplatform/melis-core
|
src/Controller/MelisCoreGdprController.php
|
MelisCoreGdprController.getFormErrors
|
private function getFormErrors($errors, $formConfig)
{
foreach ($errors as $errorKey => $errorValue) {
foreach ($formConfig['elements'] as $elementKey => $elementValue) {
if ($elementValue['spec']['name'] == $errorKey && !empty($elementValue['spec']['options']['label'])) {
$errors[$elementValue['spec']['options']['label']] = reset($errorValue);
unset($errors[$errorKey]);
}
}
}
return $errors;
}
|
php
|
private function getFormErrors($errors, $formConfig)
{
foreach ($errors as $errorKey => $errorValue) {
foreach ($formConfig['elements'] as $elementKey => $elementValue) {
if ($elementValue['spec']['name'] == $errorKey && !empty($elementValue['spec']['options']['label'])) {
$errors[$elementValue['spec']['options']['label']] = reset($errorValue);
unset($errors[$errorKey]);
}
}
}
return $errors;
}
|
[
"private",
"function",
"getFormErrors",
"(",
"$",
"errors",
",",
"$",
"formConfig",
")",
"{",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"errorKey",
"=>",
"$",
"errorValue",
")",
"{",
"foreach",
"(",
"$",
"formConfig",
"[",
"'elements'",
"]",
"as",
"$",
"elementKey",
"=>",
"$",
"elementValue",
")",
"{",
"if",
"(",
"$",
"elementValue",
"[",
"'spec'",
"]",
"[",
"'name'",
"]",
"==",
"$",
"errorKey",
"&&",
"!",
"empty",
"(",
"$",
"elementValue",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'label'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"$",
"elementValue",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'label'",
"]",
"]",
"=",
"reset",
"(",
"$",
"errorValue",
")",
";",
"unset",
"(",
"$",
"errors",
"[",
"$",
"errorKey",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
This will get the errors of the form
@param $errors
@param $formConfig
@return mixed
|
[
"This",
"will",
"get",
"the",
"errors",
"of",
"the",
"form"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L287-L299
|
27,223
|
UseMuffin/Tokenize
|
src/Model/Behavior/TokenizeBehavior.php
|
TokenizeBehavior.initialize
|
public function initialize(array $config)
{
$this->verifyConfig();
$this->_table->hasMany($this->getConfig('associationAlias'), [
'className' => 'Muffin/Tokenize.Tokens',
'foreignKey' => 'foreign_key',
'conditions' => [
'foreign_alias' => $this->_table->getAlias(),
'foreign_table' => $this->_table->getTable(),
],
'dependent' => true,
]);
}
|
php
|
public function initialize(array $config)
{
$this->verifyConfig();
$this->_table->hasMany($this->getConfig('associationAlias'), [
'className' => 'Muffin/Tokenize.Tokens',
'foreignKey' => 'foreign_key',
'conditions' => [
'foreign_alias' => $this->_table->getAlias(),
'foreign_table' => $this->_table->getTable(),
],
'dependent' => true,
]);
}
|
[
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"verifyConfig",
"(",
")",
";",
"$",
"this",
"->",
"_table",
"->",
"hasMany",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'associationAlias'",
")",
",",
"[",
"'className'",
"=>",
"'Muffin/Tokenize.Tokens'",
",",
"'foreignKey'",
"=>",
"'foreign_key'",
",",
"'conditions'",
"=>",
"[",
"'foreign_alias'",
"=>",
"$",
"this",
"->",
"_table",
"->",
"getAlias",
"(",
")",
",",
"'foreign_table'",
"=>",
"$",
"this",
"->",
"_table",
"->",
"getTable",
"(",
")",
",",
"]",
",",
"'dependent'",
"=>",
"true",
",",
"]",
")",
";",
"}"
] |
Verifies the configuration and associates the table to the
`tokenize_tokens` table.
@param array $config Config
@return void
|
[
"Verifies",
"the",
"configuration",
"and",
"associates",
"the",
"table",
"to",
"the",
"tokenize_tokens",
"table",
"."
] |
a7ecf4114782abe12b0ab36e8a32504428fe91ec
|
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Behavior/TokenizeBehavior.php#L32-L45
|
27,224
|
UseMuffin/Tokenize
|
src/Model/Behavior/TokenizeBehavior.php
|
TokenizeBehavior.tokenize
|
public function tokenize($id, array $data = [])
{
$assoc = $this->getConfig('associationAlias');
$tokenData = [
'foreign_alias' => $this->_table->getAlias(),
'foreign_table' => $this->_table->getTable(),
'foreign_key' => $id,
'foreign_data' => $data,
];
$tokenData = array_filter($tokenData);
if (!isset($tokenData['foreign_data'])) {
$tokenData['foreign_data'] = [];
}
$table = $this->_table->$assoc;
$token = $table->newEntity($tokenData);
if (!$table->save($token)) {
throw new \RuntimeException();
}
return $token;
}
|
php
|
public function tokenize($id, array $data = [])
{
$assoc = $this->getConfig('associationAlias');
$tokenData = [
'foreign_alias' => $this->_table->getAlias(),
'foreign_table' => $this->_table->getTable(),
'foreign_key' => $id,
'foreign_data' => $data,
];
$tokenData = array_filter($tokenData);
if (!isset($tokenData['foreign_data'])) {
$tokenData['foreign_data'] = [];
}
$table = $this->_table->$assoc;
$token = $table->newEntity($tokenData);
if (!$table->save($token)) {
throw new \RuntimeException();
}
return $token;
}
|
[
"public",
"function",
"tokenize",
"(",
"$",
"id",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"assoc",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'associationAlias'",
")",
";",
"$",
"tokenData",
"=",
"[",
"'foreign_alias'",
"=>",
"$",
"this",
"->",
"_table",
"->",
"getAlias",
"(",
")",
",",
"'foreign_table'",
"=>",
"$",
"this",
"->",
"_table",
"->",
"getTable",
"(",
")",
",",
"'foreign_key'",
"=>",
"$",
"id",
",",
"'foreign_data'",
"=>",
"$",
"data",
",",
"]",
";",
"$",
"tokenData",
"=",
"array_filter",
"(",
"$",
"tokenData",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"tokenData",
"[",
"'foreign_data'",
"]",
")",
")",
"{",
"$",
"tokenData",
"[",
"'foreign_data'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"table",
"=",
"$",
"this",
"->",
"_table",
"->",
"$",
"assoc",
";",
"$",
"token",
"=",
"$",
"table",
"->",
"newEntity",
"(",
"$",
"tokenData",
")",
";",
"if",
"(",
"!",
"$",
"table",
"->",
"save",
"(",
"$",
"token",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
")",
";",
"}",
"return",
"$",
"token",
";",
"}"
] |
Creates a token for a data sample.
@param int|string $id Id
@param array $data Data
@return mixed
|
[
"Creates",
"a",
"token",
"for",
"a",
"data",
"sample",
"."
] |
a7ecf4114782abe12b0ab36e8a32504428fe91ec
|
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Behavior/TokenizeBehavior.php#L96-L119
|
27,225
|
UseMuffin/Tokenize
|
src/Model/Behavior/TokenizeBehavior.php
|
TokenizeBehavior.fields
|
public function fields(EntityInterface $entity)
{
$fields = [];
foreach ((array)$this->getConfig('fields') as $field) {
if (!$entity->isDirty($field)) {
continue;
}
$fields[$field] = $entity->$field;
$entity->setDirty($field, false);
}
return $fields;
}
|
php
|
public function fields(EntityInterface $entity)
{
$fields = [];
foreach ((array)$this->getConfig('fields') as $field) {
if (!$entity->isDirty($field)) {
continue;
}
$fields[$field] = $entity->$field;
$entity->setDirty($field, false);
}
return $fields;
}
|
[
"public",
"function",
"fields",
"(",
"EntityInterface",
"$",
"entity",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getConfig",
"(",
"'fields'",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
"->",
"isDirty",
"(",
"$",
"field",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fields",
"[",
"$",
"field",
"]",
"=",
"$",
"entity",
"->",
"$",
"field",
";",
"$",
"entity",
"->",
"setDirty",
"(",
"$",
"field",
",",
"false",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Returns fields that have been marked as protected.
@param \Cake\Datasource\EntityInterface $entity Entity
@return array
|
[
"Returns",
"fields",
"that",
"have",
"been",
"marked",
"as",
"protected",
"."
] |
a7ecf4114782abe12b0ab36e8a32504428fe91ec
|
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Behavior/TokenizeBehavior.php#L127-L139
|
27,226
|
melisplatform/melis-core
|
src/Controller/DashboardController.php
|
DashboardController.leftmenuDashboardAction
|
public function leftmenuDashboardAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function leftmenuDashboardAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"leftmenuDashboardAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the leftmenu dasboard entry point
@return \Zend\View\Model\ViewModel
|
[
"Shows",
"the",
"leftmenu",
"dasboard",
"entry",
"point"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/DashboardController.php#L28-L36
|
27,227
|
melisplatform/melis-core
|
src/Service/MelisCoreGeneralService.php
|
MelisCoreGeneralService.makeArrayFromParameters
|
public function makeArrayFromParameters($class_method, $parameterValues)
{
if (empty($class_method))
return array();
// Get the class name and the method name
list($className, $methodName) = explode('::', $class_method);
if (empty($className) || empty($methodName))
return array();
/**
* Build an array from the parameters
* Parameters' name will become keys
* Values will be parameters' values or default values
*/
$parametersArray = array();
try
{
// Gets the data of class/method from Reflection object
$reflectionMethod = new \ReflectionMethod($className, $methodName);
$parameters = $reflectionMethod->getParameters();
// Loop on parameters
foreach ($parameters as $keyParameter => $parameter)
{
// Check if we have a value given
if (!empty($parameterValues[$keyParameter]))
$parametersArray[$parameter->getName()] = $parameterValues[$keyParameter];
else
// No value given, check if parameter has an optional value
if ($parameter->isOptional())
$parametersArray[$parameter->getName()] = $parameter->getDefaultValue();
else
// Else
$parametersArray[$parameter->getName()] = null;
}
}
catch (\Exception $e)
{
// Class or method were not found
return array();
}
return $parametersArray;
}
|
php
|
public function makeArrayFromParameters($class_method, $parameterValues)
{
if (empty($class_method))
return array();
// Get the class name and the method name
list($className, $methodName) = explode('::', $class_method);
if (empty($className) || empty($methodName))
return array();
/**
* Build an array from the parameters
* Parameters' name will become keys
* Values will be parameters' values or default values
*/
$parametersArray = array();
try
{
// Gets the data of class/method from Reflection object
$reflectionMethod = new \ReflectionMethod($className, $methodName);
$parameters = $reflectionMethod->getParameters();
// Loop on parameters
foreach ($parameters as $keyParameter => $parameter)
{
// Check if we have a value given
if (!empty($parameterValues[$keyParameter]))
$parametersArray[$parameter->getName()] = $parameterValues[$keyParameter];
else
// No value given, check if parameter has an optional value
if ($parameter->isOptional())
$parametersArray[$parameter->getName()] = $parameter->getDefaultValue();
else
// Else
$parametersArray[$parameter->getName()] = null;
}
}
catch (\Exception $e)
{
// Class or method were not found
return array();
}
return $parametersArray;
}
|
[
"public",
"function",
"makeArrayFromParameters",
"(",
"$",
"class_method",
",",
"$",
"parameterValues",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"class_method",
")",
")",
"return",
"array",
"(",
")",
";",
"// Get the class name and the method name",
"list",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"class_method",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"className",
")",
"||",
"empty",
"(",
"$",
"methodName",
")",
")",
"return",
"array",
"(",
")",
";",
"/**\n\t * Build an array from the parameters\n\t * Parameters' name will become keys\n\t * Values will be parameters' values or default values\n\t */",
"$",
"parametersArray",
"=",
"array",
"(",
")",
";",
"try",
"{",
"// Gets the data of class/method from Reflection object",
"$",
"reflectionMethod",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"className",
",",
"$",
"methodName",
")",
";",
"$",
"parameters",
"=",
"$",
"reflectionMethod",
"->",
"getParameters",
"(",
")",
";",
"// Loop on parameters",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"keyParameter",
"=>",
"$",
"parameter",
")",
"{",
"// Check if we have a value given",
"if",
"(",
"!",
"empty",
"(",
"$",
"parameterValues",
"[",
"$",
"keyParameter",
"]",
")",
")",
"$",
"parametersArray",
"[",
"$",
"parameter",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"parameterValues",
"[",
"$",
"keyParameter",
"]",
";",
"else",
"// No value given, check if parameter has an optional value",
"if",
"(",
"$",
"parameter",
"->",
"isOptional",
"(",
")",
")",
"$",
"parametersArray",
"[",
"$",
"parameter",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"parameter",
"->",
"getDefaultValue",
"(",
")",
";",
"else",
"// Else",
"$",
"parametersArray",
"[",
"$",
"parameter",
"->",
"getName",
"(",
")",
"]",
"=",
"null",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Class or method were not found",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"parametersArray",
";",
"}"
] |
This method creates an array from the parameters, using parameters' name as keys
and taking values or default values.
It is used to prepare args for events listening.
@param string $class_method
@param mixed[] $parameterValues
|
[
"This",
"method",
"creates",
"an",
"array",
"from",
"the",
"parameters",
"using",
"parameters",
"name",
"as",
"keys",
"and",
"taking",
"values",
"or",
"default",
"values",
".",
"It",
"is",
"used",
"to",
"prepare",
"args",
"for",
"events",
"listening",
"."
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreGeneralService.php#L56-L100
|
27,228
|
melisplatform/melis-core
|
src/Service/MelisCoreGeneralService.php
|
MelisCoreGeneralService.splitData
|
public function splitData($prefix, $haystack = array())
{
$data = array();
if($haystack) {
foreach($haystack as $key => $value) {
if(strpos($key, $prefix) !== false) {
$data[$key] = $value;
}
}
}
return $data;
}
|
php
|
public function splitData($prefix, $haystack = array())
{
$data = array();
if($haystack) {
foreach($haystack as $key => $value) {
if(strpos($key, $prefix) !== false) {
$data[$key] = $value;
}
}
}
return $data;
}
|
[
"public",
"function",
"splitData",
"(",
"$",
"prefix",
",",
"$",
"haystack",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"haystack",
")",
"{",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"prefix",
")",
"!==",
"false",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Used to split array data and return the data you need
@param String $prefix of the array data
@param array $haystack
|
[
"Used",
"to",
"split",
"array",
"data",
"and",
"return",
"the",
"data",
"you",
"need"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreGeneralService.php#L118-L134
|
27,229
|
melisplatform/melis-core
|
src/View/Helper/MelisGenericTable.php
|
MelisGenericTable.setColumns
|
public function setColumns($columnText, $css = null, $class = null)
{
$ctr = 0;
$text = '';
$colCss = array();
$dataClass = '';
$thClass = '';
foreach($columnText as $values)
{
$text .= '<th '.$dataClass.' class="'.$class.'">' . $values . '</th>';
$ctr++;
}
$this->_columns .= $text;
}
|
php
|
public function setColumns($columnText, $css = null, $class = null)
{
$ctr = 0;
$text = '';
$colCss = array();
$dataClass = '';
$thClass = '';
foreach($columnText as $values)
{
$text .= '<th '.$dataClass.' class="'.$class.'">' . $values . '</th>';
$ctr++;
}
$this->_columns .= $text;
}
|
[
"public",
"function",
"setColumns",
"(",
"$",
"columnText",
",",
"$",
"css",
"=",
"null",
",",
"$",
"class",
"=",
"null",
")",
"{",
"$",
"ctr",
"=",
"0",
";",
"$",
"text",
"=",
"''",
";",
"$",
"colCss",
"=",
"array",
"(",
")",
";",
"$",
"dataClass",
"=",
"''",
";",
"$",
"thClass",
"=",
"''",
";",
"foreach",
"(",
"$",
"columnText",
"as",
"$",
"values",
")",
"{",
"$",
"text",
".=",
"'<th '",
".",
"$",
"dataClass",
".",
"' class=\"'",
".",
"$",
"class",
".",
"'\">'",
".",
"$",
"values",
".",
"'</th>'",
";",
"$",
"ctr",
"++",
";",
"}",
"$",
"this",
"->",
"_columns",
".=",
"$",
"text",
";",
"}"
] |
Creates a configuration table column.
@param Array $columnText
@param Array $css
@param String $class
|
[
"Creates",
"a",
"configuration",
"table",
"column",
"."
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisGenericTable.php#L52-L69
|
27,230
|
orchestral/kernel
|
src/Http/Providers/VersionServiceProvider.php
|
VersionServiceProvider.registerSupportedVersions
|
protected function registerSupportedVersions(VersionControl $version): void
{
foreach ($this->versions as $code => $namespace) {
$version->addVersion($code, $namespace);
}
if (! is_null($this->defaultVersion)) {
$version->setDefaultVersion($this->defaultVersion);
}
}
|
php
|
protected function registerSupportedVersions(VersionControl $version): void
{
foreach ($this->versions as $code => $namespace) {
$version->addVersion($code, $namespace);
}
if (! is_null($this->defaultVersion)) {
$version->setDefaultVersion($this->defaultVersion);
}
}
|
[
"protected",
"function",
"registerSupportedVersions",
"(",
"VersionControl",
"$",
"version",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"versions",
"as",
"$",
"code",
"=>",
"$",
"namespace",
")",
"{",
"$",
"version",
"->",
"addVersion",
"(",
"$",
"code",
",",
"$",
"namespace",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"defaultVersion",
")",
")",
"{",
"$",
"version",
"->",
"setDefaultVersion",
"(",
"$",
"this",
"->",
"defaultVersion",
")",
";",
"}",
"}"
] |
Register supported version.
@param \Orchestra\Http\VersionControl $version
@return void
|
[
"Register",
"supported",
"version",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Providers/VersionServiceProvider.php#L45-L54
|
27,231
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.addLostPassRequest
|
public function addLostPassRequest($login, $email)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $this->getPassRequestDataByLogin($email);
$success = false;
if(!$this->isDataExists($login)) {
$table->save(array(
'rh_id' => null,
'rh_login' => $login,
'rh_email' => $email,
'rh_hash' => $this->generateHash(),
'rh_date' => date('Y-m-d H:i:s')
));
// first email
$success = $this->sendPasswordLostEmail($login, $email);
}
else {
// resend email
$table->update(array(
'rh_date' => date('Y-m-d H:i:s')
), 'rh_login', $login);
$success = $this->sendPasswordLostEmail($login, $email);
}
return $success;
}
|
php
|
public function addLostPassRequest($login, $email)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $this->getPassRequestDataByLogin($email);
$success = false;
if(!$this->isDataExists($login)) {
$table->save(array(
'rh_id' => null,
'rh_login' => $login,
'rh_email' => $email,
'rh_hash' => $this->generateHash(),
'rh_date' => date('Y-m-d H:i:s')
));
// first email
$success = $this->sendPasswordLostEmail($login, $email);
}
else {
// resend email
$table->update(array(
'rh_date' => date('Y-m-d H:i:s')
), 'rh_login', $login);
$success = $this->sendPasswordLostEmail($login, $email);
}
return $success;
}
|
[
"public",
"function",
"addLostPassRequest",
"(",
"$",
"login",
",",
"$",
"email",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisLostPasswordTable'",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getPassRequestDataByLogin",
"(",
"$",
"email",
")",
";",
"$",
"success",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isDataExists",
"(",
"$",
"login",
")",
")",
"{",
"$",
"table",
"->",
"save",
"(",
"array",
"(",
"'rh_id'",
"=>",
"null",
",",
"'rh_login'",
"=>",
"$",
"login",
",",
"'rh_email'",
"=>",
"$",
"email",
",",
"'rh_hash'",
"=>",
"$",
"this",
"->",
"generateHash",
"(",
")",
",",
"'rh_date'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
")",
")",
";",
"// first email",
"$",
"success",
"=",
"$",
"this",
"->",
"sendPasswordLostEmail",
"(",
"$",
"login",
",",
"$",
"email",
")",
";",
"}",
"else",
"{",
"// resend email",
"$",
"table",
"->",
"update",
"(",
"array",
"(",
"'rh_date'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
")",
",",
"'rh_login'",
",",
"$",
"login",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"sendPasswordLostEmail",
"(",
"$",
"login",
",",
"$",
"email",
")",
";",
"}",
"return",
"$",
"success",
";",
"}"
] |
Adds new record for lost password request
@param String $url
@param String $login
@param String $email
|
[
"Adds",
"new",
"record",
"for",
"lost",
"password",
"request"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L32-L58
|
27,232
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.processUpdatePassword
|
public function processUpdatePassword($hash, $password)
{
$data = $this->getPasswordRequestData($hash);
$login = '';
$success = false;
foreach($data as $val)
{
$login = $val->rh_login;
}
if($this->isDataExists($login))
{
$success = $this->updatePassword($login, $password);
if($success)
$this->deletePasswordRequestData($hash);
}
return $success;
}
|
php
|
public function processUpdatePassword($hash, $password)
{
$data = $this->getPasswordRequestData($hash);
$login = '';
$success = false;
foreach($data as $val)
{
$login = $val->rh_login;
}
if($this->isDataExists($login))
{
$success = $this->updatePassword($login, $password);
if($success)
$this->deletePasswordRequestData($hash);
}
return $success;
}
|
[
"public",
"function",
"processUpdatePassword",
"(",
"$",
"hash",
",",
"$",
"password",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getPasswordRequestData",
"(",
"$",
"hash",
")",
";",
"$",
"login",
"=",
"''",
";",
"$",
"success",
"=",
"false",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"val",
")",
"{",
"$",
"login",
"=",
"$",
"val",
"->",
"rh_login",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isDataExists",
"(",
"$",
"login",
")",
")",
"{",
"$",
"success",
"=",
"$",
"this",
"->",
"updatePassword",
"(",
"$",
"login",
",",
"$",
"password",
")",
";",
"if",
"(",
"$",
"success",
")",
"$",
"this",
"->",
"deletePasswordRequestData",
"(",
"$",
"hash",
")",
";",
"}",
"return",
"$",
"success",
";",
"}"
] |
Processes the password reset and deletes the existing record in the lost password table
@param String $hash
@param String $password
@return boolean
|
[
"Processes",
"the",
"password",
"reset",
"and",
"deletes",
"the",
"existing",
"record",
"in",
"the",
"lost",
"password",
"table"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L66-L85
|
27,233
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.userExists
|
public function userExists($login)
{
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$data = $userTable->getEntryByField('usr_login', $login);
$user = '';
foreach($data as $val)
{
$user = $val->usr_login;
}
if(!empty($user))
{
return true;
}
else
{
return false;
}
}
|
php
|
public function userExists($login)
{
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$data = $userTable->getEntryByField('usr_login', $login);
$user = '';
foreach($data as $val)
{
$user = $val->usr_login;
}
if(!empty($user))
{
return true;
}
else
{
return false;
}
}
|
[
"public",
"function",
"userExists",
"(",
"$",
"login",
")",
"{",
"$",
"userTable",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTableUser'",
")",
";",
"$",
"data",
"=",
"$",
"userTable",
"->",
"getEntryByField",
"(",
"'usr_login'",
",",
"$",
"login",
")",
";",
"$",
"user",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"val",
")",
"{",
"$",
"user",
"=",
"$",
"val",
"->",
"usr_login",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Checks if the user exists
@param String $login
@return boolean
|
[
"Checks",
"if",
"the",
"user",
"exists"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L92-L110
|
27,234
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.hashExists
|
public function hashExists($hash)
{
$data = $this->getPasswordRequestData($hash);
$h = '';
foreach($data as $val)
{
$h = $val->rh_login;
//echo $h;
}
if(!empty($h)) {
return true;
}
return false;
}
|
php
|
public function hashExists($hash)
{
$data = $this->getPasswordRequestData($hash);
$h = '';
foreach($data as $val)
{
$h = $val->rh_login;
//echo $h;
}
if(!empty($h)) {
return true;
}
return false;
}
|
[
"public",
"function",
"hashExists",
"(",
"$",
"hash",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getPasswordRequestData",
"(",
"$",
"hash",
")",
";",
"$",
"h",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"val",
")",
"{",
"$",
"h",
"=",
"$",
"val",
"->",
"rh_login",
";",
"//echo $h;",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"h",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if the provided hash exists
@param String $hash
@return boolean
|
[
"Check",
"if",
"the",
"provided",
"hash",
"exists"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L117-L132
|
27,235
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.isDataExists
|
public function isDataExists($login)
{
$data = $this->getPassRequestDataByLogin($login);
$login = '';
foreach($data as $val)
{
$login = $val->rh_login;
}
if(!empty($login)) {
return true;
}
return false;
}
|
php
|
public function isDataExists($login)
{
$data = $this->getPassRequestDataByLogin($login);
$login = '';
foreach($data as $val)
{
$login = $val->rh_login;
}
if(!empty($login)) {
return true;
}
return false;
}
|
[
"public",
"function",
"isDataExists",
"(",
"$",
"login",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getPassRequestDataByLogin",
"(",
"$",
"login",
")",
";",
"$",
"login",
"=",
"''",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"val",
")",
"{",
"$",
"login",
"=",
"$",
"val",
"->",
"rh_login",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"login",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the username exists in the lost password table
@param String $login
@return boolean
|
[
"Checks",
"if",
"the",
"username",
"exists",
"in",
"the",
"lost",
"password",
"table"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L139-L153
|
27,236
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.getPassRequestDataByLogin
|
public function getPassRequestDataByLogin($login)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $table->getEntryByField('rh_login', $login);
if($data)
return $data;
}
|
php
|
public function getPassRequestDataByLogin($login)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $table->getEntryByField('rh_login', $login);
if($data)
return $data;
}
|
[
"public",
"function",
"getPassRequestDataByLogin",
"(",
"$",
"login",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisLostPasswordTable'",
")",
";",
"$",
"data",
"=",
"$",
"table",
"->",
"getEntryByField",
"(",
"'rh_login'",
",",
"$",
"login",
")",
";",
"if",
"(",
"$",
"data",
")",
"return",
"$",
"data",
";",
"}"
] |
Returns the data of the provided username
@param String $login
@return boolean
|
[
"Returns",
"the",
"data",
"of",
"the",
"provided",
"username"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L160-L167
|
27,237
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.getPasswordRequestData
|
public function getPasswordRequestData($hash)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $table->getEntryByField('rh_hash', $hash);
if($data)
return $data;
}
|
php
|
public function getPasswordRequestData($hash)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $table->getEntryByField('rh_hash', $hash);
if($data)
return $data;
}
|
[
"public",
"function",
"getPasswordRequestData",
"(",
"$",
"hash",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisLostPasswordTable'",
")",
";",
"$",
"data",
"=",
"$",
"table",
"->",
"getEntryByField",
"(",
"'rh_hash'",
",",
"$",
"hash",
")",
";",
"if",
"(",
"$",
"data",
")",
"return",
"$",
"data",
";",
"}"
] |
Returns the data of the provided hash
@param String $login
@return boolean
|
[
"Returns",
"the",
"data",
"of",
"the",
"provided",
"hash"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L174-L181
|
27,238
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.updatePassword
|
protected function updatePassword($login, $newPass)
{
$success = false;
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
if($this->isDataExists($login))
{
$userTable->update(array(
'usr_password' => $melisCoreAuth->encryptPassword($newPass)
),'usr_login', $login);
$success = true;
}
return $success;
}
|
php
|
protected function updatePassword($login, $newPass)
{
$success = false;
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
if($this->isDataExists($login))
{
$userTable->update(array(
'usr_password' => $melisCoreAuth->encryptPassword($newPass)
),'usr_login', $login);
$success = true;
}
return $success;
}
|
[
"protected",
"function",
"updatePassword",
"(",
"$",
"login",
",",
"$",
"newPass",
")",
"{",
"$",
"success",
"=",
"false",
";",
"$",
"userTable",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTableUser'",
")",
";",
"$",
"melisCoreAuth",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'MelisCoreAuth'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isDataExists",
"(",
"$",
"login",
")",
")",
"{",
"$",
"userTable",
"->",
"update",
"(",
"array",
"(",
"'usr_password'",
"=>",
"$",
"melisCoreAuth",
"->",
"encryptPassword",
"(",
"$",
"newPass",
")",
")",
",",
"'usr_login'",
",",
"$",
"login",
")",
";",
"$",
"success",
"=",
"true",
";",
"}",
"return",
"$",
"success",
";",
"}"
] |
Updates the user's password
@param String $login
@param String $newPass
|
[
"Updates",
"the",
"user",
"s",
"password"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L188-L204
|
27,239
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.deletePasswordRequestData
|
protected function deletePasswordRequestData($hash)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $this->getPasswordRequestData($hash);
if($data)
$table->deleteByField('rh_hash', $hash);
}
|
php
|
protected function deletePasswordRequestData($hash)
{
$table = $this->getServiceLocator()->get('MelisLostPasswordTable');
$data = $this->getPasswordRequestData($hash);
if($data)
$table->deleteByField('rh_hash', $hash);
}
|
[
"protected",
"function",
"deletePasswordRequestData",
"(",
"$",
"hash",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisLostPasswordTable'",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getPasswordRequestData",
"(",
"$",
"hash",
")",
";",
"if",
"(",
"$",
"data",
")",
"$",
"table",
"->",
"deleteByField",
"(",
"'rh_hash'",
",",
"$",
"hash",
")",
";",
"}"
] |
Deletes a specific record in the lost password table
@param unknown $hash
|
[
"Deletes",
"a",
"specific",
"record",
"in",
"the",
"lost",
"password",
"table"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L210-L217
|
27,240
|
melisplatform/melis-core
|
src/Service/MelisCoreLostPasswordService.php
|
MelisCoreLostPasswordService.sendPasswordLostEmail
|
protected function sendPasswordLostEmail($login, $email)
{
$datas = array();
foreach($this->getPassRequestDataByLogin($login) as $data) {
$datas['rh_login'] = $data->rh_login;
$datas['rh_hash'] = $data->rh_hash;
}
$login = $datas['rh_login'];
$hash = $datas['rh_hash'];
$configPath = 'meliscore/datas';
$melisConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$cfg = $melisConfig->getItem('meliscore/datas/'.getenv('MELIS_PLATFORM'));
if (empty($cfg))
$cfg = $melisConfig->getItem('meliscore/datas/default');
$isActive = false;
if (!empty($cfg['emails']))
if (!empty($cfg['emails']['active']))
$isActive = true;
$url = $cfg['host'].'/melis/reset-password/'.$hash;
if($isActive){
// Tags to be replace at email content with the corresponding value
$tags = array(
'USER_Login' => $login,
'URL' => $url
);
$name_to = $login;
$email_to = $email;
// Fetching user language Id
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$userData = $userTable->getDataByLoginAndEmail($login, $email);
$userData = $userData->current();
$langId = $userData->usr_lang_id;
$melisEmailBO = $this->getServiceLocator()->get('MelisCoreBOEmailService');
$emailResult = $melisEmailBO->sendBoEmailByCode('LOSTPASSWORD', $tags, $email_to, $name_to, $langId);
if ($emailResult){
return true;
}else{
return false;
}
}else{
return false;
}
}
|
php
|
protected function sendPasswordLostEmail($login, $email)
{
$datas = array();
foreach($this->getPassRequestDataByLogin($login) as $data) {
$datas['rh_login'] = $data->rh_login;
$datas['rh_hash'] = $data->rh_hash;
}
$login = $datas['rh_login'];
$hash = $datas['rh_hash'];
$configPath = 'meliscore/datas';
$melisConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$cfg = $melisConfig->getItem('meliscore/datas/'.getenv('MELIS_PLATFORM'));
if (empty($cfg))
$cfg = $melisConfig->getItem('meliscore/datas/default');
$isActive = false;
if (!empty($cfg['emails']))
if (!empty($cfg['emails']['active']))
$isActive = true;
$url = $cfg['host'].'/melis/reset-password/'.$hash;
if($isActive){
// Tags to be replace at email content with the corresponding value
$tags = array(
'USER_Login' => $login,
'URL' => $url
);
$name_to = $login;
$email_to = $email;
// Fetching user language Id
$userTable = $this->getServiceLocator()->get('MelisCoreTableUser');
$userData = $userTable->getDataByLoginAndEmail($login, $email);
$userData = $userData->current();
$langId = $userData->usr_lang_id;
$melisEmailBO = $this->getServiceLocator()->get('MelisCoreBOEmailService');
$emailResult = $melisEmailBO->sendBoEmailByCode('LOSTPASSWORD', $tags, $email_to, $name_to, $langId);
if ($emailResult){
return true;
}else{
return false;
}
}else{
return false;
}
}
|
[
"protected",
"function",
"sendPasswordLostEmail",
"(",
"$",
"login",
",",
"$",
"email",
")",
"{",
"$",
"datas",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPassRequestDataByLogin",
"(",
"$",
"login",
")",
"as",
"$",
"data",
")",
"{",
"$",
"datas",
"[",
"'rh_login'",
"]",
"=",
"$",
"data",
"->",
"rh_login",
";",
"$",
"datas",
"[",
"'rh_hash'",
"]",
"=",
"$",
"data",
"->",
"rh_hash",
";",
"}",
"$",
"login",
"=",
"$",
"datas",
"[",
"'rh_login'",
"]",
";",
"$",
"hash",
"=",
"$",
"datas",
"[",
"'rh_hash'",
"]",
";",
"$",
"configPath",
"=",
"'meliscore/datas'",
";",
"$",
"melisConfig",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"cfg",
"=",
"$",
"melisConfig",
"->",
"getItem",
"(",
"'meliscore/datas/'",
".",
"getenv",
"(",
"'MELIS_PLATFORM'",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"cfg",
")",
")",
"$",
"cfg",
"=",
"$",
"melisConfig",
"->",
"getItem",
"(",
"'meliscore/datas/default'",
")",
";",
"$",
"isActive",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'emails'",
"]",
")",
")",
"if",
"(",
"!",
"empty",
"(",
"$",
"cfg",
"[",
"'emails'",
"]",
"[",
"'active'",
"]",
")",
")",
"$",
"isActive",
"=",
"true",
";",
"$",
"url",
"=",
"$",
"cfg",
"[",
"'host'",
"]",
".",
"'/melis/reset-password/'",
".",
"$",
"hash",
";",
"if",
"(",
"$",
"isActive",
")",
"{",
"// Tags to be replace at email content with the corresponding value",
"$",
"tags",
"=",
"array",
"(",
"'USER_Login'",
"=>",
"$",
"login",
",",
"'URL'",
"=>",
"$",
"url",
")",
";",
"$",
"name_to",
"=",
"$",
"login",
";",
"$",
"email_to",
"=",
"$",
"email",
";",
"// Fetching user language Id",
"$",
"userTable",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTableUser'",
")",
";",
"$",
"userData",
"=",
"$",
"userTable",
"->",
"getDataByLoginAndEmail",
"(",
"$",
"login",
",",
"$",
"email",
")",
";",
"$",
"userData",
"=",
"$",
"userData",
"->",
"current",
"(",
")",
";",
"$",
"langId",
"=",
"$",
"userData",
"->",
"usr_lang_id",
";",
"$",
"melisEmailBO",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreBOEmailService'",
")",
";",
"$",
"emailResult",
"=",
"$",
"melisEmailBO",
"->",
"sendBoEmailByCode",
"(",
"'LOSTPASSWORD'",
",",
"$",
"tags",
",",
"$",
"email_to",
",",
"$",
"name_to",
",",
"$",
"langId",
")",
";",
"if",
"(",
"$",
"emailResult",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Sends an email together with the link to the user
@param String $url
@param String $login
@param String $email
|
[
"Sends",
"an",
"email",
"together",
"with",
"the",
"link",
"to",
"the",
"user"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L226-L279
|
27,241
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.toolContainerAction
|
public function toolContainerAction()
{
$form = $this->getForm();
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $this->getMelisKey();
$view->hasAccess = $this->hasAccess($melisKey);
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme();
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if ($colors) {
$form->setData($colors);
}
}
$view->setVariable('form', $form);
$view->schemes = $schemeData;
return $view;
}
|
php
|
public function toolContainerAction()
{
$form = $this->getForm();
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $this->getMelisKey();
$view->hasAccess = $this->hasAccess($melisKey);
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme();
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if ($colors) {
$form->setData($colors);
}
}
$view->setVariable('form', $form);
$view->schemes = $schemeData;
return $view;
}
|
[
"public",
"function",
"toolContainerAction",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"this",
"->",
"getMelisKey",
"(",
")",
";",
"$",
"view",
"->",
"hasAccess",
"=",
"$",
"this",
"->",
"hasAccess",
"(",
"$",
"melisKey",
")",
";",
"$",
"schemeData",
"=",
"$",
"this",
"->",
"getPlatformSchemeSvc",
"(",
")",
"->",
"getCurrentScheme",
"(",
")",
";",
"if",
"(",
"$",
"schemeData",
")",
"{",
"$",
"colors",
"=",
"json_decode",
"(",
"$",
"schemeData",
"->",
"getColors",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"$",
"colors",
")",
"{",
"$",
"form",
"->",
"setData",
"(",
"$",
"colors",
")",
";",
"}",
"}",
"$",
"view",
"->",
"setVariable",
"(",
"'form'",
",",
"$",
"form",
")",
";",
"$",
"view",
"->",
"schemes",
"=",
"$",
"schemeData",
";",
"return",
"$",
"view",
";",
"}"
] |
Tool display container
@return ViewModel
|
[
"Tool",
"display",
"container"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L34-L57
|
27,242
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.getStyleColorCssAction
|
public function getStyleColorCssAction()
{
$primaryColor = null;
$secondaryColor = null;
$view = new ViewModel();
$response = $this->getResponse();
$view->setTerminal(true);
$response->getHeaders()
->addHeaderLine('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
->addHeaderLine('Pragma' , 'no-cache')
->addHeaderLine('Content-Type' , 'text/css;charset=UTF-8');
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme(true);
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if (is_array($colors)) {
foreach ($colors as $colorKey => $colorValue) {
$view->$colorKey = $colorValue;
}
}
}
return $view;
}
|
php
|
public function getStyleColorCssAction()
{
$primaryColor = null;
$secondaryColor = null;
$view = new ViewModel();
$response = $this->getResponse();
$view->setTerminal(true);
$response->getHeaders()
->addHeaderLine('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0')
->addHeaderLine('Pragma' , 'no-cache')
->addHeaderLine('Content-Type' , 'text/css;charset=UTF-8');
$schemeData = $this->getPlatformSchemeSvc()->getCurrentScheme(true);
if ($schemeData) {
$colors = json_decode($schemeData->getColors(), true);
if (is_array($colors)) {
foreach ($colors as $colorKey => $colorValue) {
$view->$colorKey = $colorValue;
}
}
}
return $view;
}
|
[
"public",
"function",
"getStyleColorCssAction",
"(",
")",
"{",
"$",
"primaryColor",
"=",
"null",
";",
"$",
"secondaryColor",
"=",
"null",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
";",
"$",
"view",
"->",
"setTerminal",
"(",
"true",
")",
";",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"->",
"addHeaderLine",
"(",
"'Cache-Control'",
",",
"'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'",
")",
"->",
"addHeaderLine",
"(",
"'Pragma'",
",",
"'no-cache'",
")",
"->",
"addHeaderLine",
"(",
"'Content-Type'",
",",
"'text/css;charset=UTF-8'",
")",
";",
"$",
"schemeData",
"=",
"$",
"this",
"->",
"getPlatformSchemeSvc",
"(",
")",
"->",
"getCurrentScheme",
"(",
"true",
")",
";",
"if",
"(",
"$",
"schemeData",
")",
"{",
"$",
"colors",
"=",
"json_decode",
"(",
"$",
"schemeData",
"->",
"getColors",
"(",
")",
",",
"true",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"colors",
")",
")",
"{",
"foreach",
"(",
"$",
"colors",
"as",
"$",
"colorKey",
"=>",
"$",
"colorValue",
")",
"{",
"$",
"view",
"->",
"$",
"colorKey",
"=",
"$",
"colorValue",
";",
"}",
"}",
"}",
"return",
"$",
"view",
";",
"}"
] |
Generates a dynamic CSS virtual file that will be rendered
in the platform
@return ViewModel
|
[
"Generates",
"a",
"dynamic",
"CSS",
"virtual",
"file",
"that",
"will",
"be",
"rendered",
"in",
"the",
"platform"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L406-L434
|
27,243
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.formatErrorMessage
|
private function formatErrorMessage($errors = array())
{
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$appConfigForm = $melisMelisCoreConfig->getItem('meliscore/forms/melis_core_platform_scheme_form');
$appConfigForm = $appConfigForm['elements'];
foreach ($errors as $keyError => $valueError) {
foreach ($appConfigForm as $keyForm => $valueForm) {
if ($valueForm['spec']['name'] == $keyError &&
!empty($valueForm['spec']['options']['label'])
)
$errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
}
}
return $errors;
}
|
php
|
private function formatErrorMessage($errors = array())
{
$melisMelisCoreConfig = $this->serviceLocator->get('MelisCoreConfig');
$appConfigForm = $melisMelisCoreConfig->getItem('meliscore/forms/melis_core_platform_scheme_form');
$appConfigForm = $appConfigForm['elements'];
foreach ($errors as $keyError => $valueError) {
foreach ($appConfigForm as $keyForm => $valueForm) {
if ($valueForm['spec']['name'] == $keyError &&
!empty($valueForm['spec']['options']['label'])
)
$errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
}
}
return $errors;
}
|
[
"private",
"function",
"formatErrorMessage",
"(",
"$",
"errors",
"=",
"array",
"(",
")",
")",
"{",
"$",
"melisMelisCoreConfig",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"appConfigForm",
"=",
"$",
"melisMelisCoreConfig",
"->",
"getItem",
"(",
"'meliscore/forms/melis_core_platform_scheme_form'",
")",
";",
"$",
"appConfigForm",
"=",
"$",
"appConfigForm",
"[",
"'elements'",
"]",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"keyError",
"=>",
"$",
"valueError",
")",
"{",
"foreach",
"(",
"$",
"appConfigForm",
"as",
"$",
"keyForm",
"=>",
"$",
"valueForm",
")",
"{",
"if",
"(",
"$",
"valueForm",
"[",
"'spec'",
"]",
"[",
"'name'",
"]",
"==",
"$",
"keyError",
"&&",
"!",
"empty",
"(",
"$",
"valueForm",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'label'",
"]",
")",
")",
"$",
"errors",
"[",
"$",
"keyError",
"]",
"[",
"'label'",
"]",
"=",
"$",
"valueForm",
"[",
"'spec'",
"]",
"[",
"'options'",
"]",
"[",
"'label'",
"]",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Returns the a formatted error messages with its labels
@param array $errors
@return array
|
[
"Returns",
"the",
"a",
"formatted",
"error",
"messages",
"with",
"its",
"labels"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L473-L489
|
27,244
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.getSchemeFolder
|
private function getSchemeFolder()
{
$uriPath = '/media/platform-scheme/';
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
if($path) {
$uriPath = isset($path['datas']['platform_scheme_dir']) ? $path['datas']['platform_scheme_dir'] : '/media/platform-scheme/';
}
$docRoot = $_SERVER['DOCUMENT_ROOT'] . '';
$schemeFolder = $docRoot.$uriPath;
// check if the folder exists
if(!file_exists($schemeFolder)) {
mkdir($schemeFolder, self::SCHEME_FOLDER_PERMISSION,true);
}
else {
// check writable permission
if(!is_writable($schemeFolder)) {
chmod($schemeFolder, self::SCHEME_FOLDER_PERMISSION);
}
}
return $uriPath;
}
|
php
|
private function getSchemeFolder()
{
$uriPath = '/media/platform-scheme/';
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
if($path) {
$uriPath = isset($path['datas']['platform_scheme_dir']) ? $path['datas']['platform_scheme_dir'] : '/media/platform-scheme/';
}
$docRoot = $_SERVER['DOCUMENT_ROOT'] . '';
$schemeFolder = $docRoot.$uriPath;
// check if the folder exists
if(!file_exists($schemeFolder)) {
mkdir($schemeFolder, self::SCHEME_FOLDER_PERMISSION,true);
}
else {
// check writable permission
if(!is_writable($schemeFolder)) {
chmod($schemeFolder, self::SCHEME_FOLDER_PERMISSION);
}
}
return $uriPath;
}
|
[
"private",
"function",
"getSchemeFolder",
"(",
")",
"{",
"$",
"uriPath",
"=",
"'/media/platform-scheme/'",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"path",
"=",
"$",
"config",
"->",
"getItem",
"(",
"'meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme'",
")",
";",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"uriPath",
"=",
"isset",
"(",
"$",
"path",
"[",
"'datas'",
"]",
"[",
"'platform_scheme_dir'",
"]",
")",
"?",
"$",
"path",
"[",
"'datas'",
"]",
"[",
"'platform_scheme_dir'",
"]",
":",
"'/media/platform-scheme/'",
";",
"}",
"$",
"docRoot",
"=",
"$",
"_SERVER",
"[",
"'DOCUMENT_ROOT'",
"]",
".",
"''",
";",
"$",
"schemeFolder",
"=",
"$",
"docRoot",
".",
"$",
"uriPath",
";",
"// check if the folder exists",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"schemeFolder",
")",
")",
"{",
"mkdir",
"(",
"$",
"schemeFolder",
",",
"self",
"::",
"SCHEME_FOLDER_PERMISSION",
",",
"true",
")",
";",
"}",
"else",
"{",
"// check writable permission",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"schemeFolder",
")",
")",
"{",
"chmod",
"(",
"$",
"schemeFolder",
",",
"self",
"::",
"SCHEME_FOLDER_PERMISSION",
")",
";",
"}",
"}",
"return",
"$",
"uriPath",
";",
"}"
] |
Returns the URI path of the platform scheme folder inside media folder
@return string
|
[
"Returns",
"the",
"URI",
"path",
"of",
"the",
"platform",
"scheme",
"folder",
"inside",
"media",
"folder"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L504-L529
|
27,245
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.convertWithBytes
|
private function convertWithBytes($size)
{
$precision = 2;
$base = log($size, 1024);
$suffixes = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
return $bytes;
}
|
php
|
private function convertWithBytes($size)
{
$precision = 2;
$base = log($size, 1024);
$suffixes = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
return $bytes;
}
|
[
"private",
"function",
"convertWithBytes",
"(",
"$",
"size",
")",
"{",
"$",
"precision",
"=",
"2",
";",
"$",
"base",
"=",
"log",
"(",
"$",
"size",
",",
"1024",
")",
";",
"$",
"suffixes",
"=",
"array",
"(",
"'B'",
",",
"'KB'",
",",
"'MB'",
",",
"'GB'",
",",
"'TB'",
")",
";",
"$",
"bytes",
"=",
"round",
"(",
"pow",
"(",
"1024",
",",
"$",
"base",
"-",
"floor",
"(",
"$",
"base",
")",
")",
",",
"$",
"precision",
")",
".",
"$",
"suffixes",
"[",
"floor",
"(",
"$",
"base",
")",
"]",
";",
"return",
"$",
"bytes",
";",
"}"
] |
Returns the formatted byte size
@param $size
@return string
|
[
"Returns",
"the",
"formatted",
"byte",
"size"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L559-L567
|
27,246
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.getMaxImageSize
|
private function getMaxImageSize()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$imagesize = null;
if($path) {
$imageSize = isset($path['datas']['image_size_limit']) ? $path['datas']['image_size_limit'] : null;
}
return $imageSize;
}
|
php
|
private function getMaxImageSize()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$imagesize = null;
if($path) {
$imageSize = isset($path['datas']['image_size_limit']) ? $path['datas']['image_size_limit'] : null;
}
return $imageSize;
}
|
[
"private",
"function",
"getMaxImageSize",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"path",
"=",
"$",
"config",
"->",
"getItem",
"(",
"'meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme'",
")",
";",
"$",
"imagesize",
"=",
"null",
";",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"imageSize",
"=",
"isset",
"(",
"$",
"path",
"[",
"'datas'",
"]",
"[",
"'image_size_limit'",
"]",
")",
"?",
"$",
"path",
"[",
"'datas'",
"]",
"[",
"'image_size_limit'",
"]",
":",
"null",
";",
"}",
"return",
"$",
"imageSize",
";",
"}"
] |
Returns the maximum file image size from the configuration
@return null|long
|
[
"Returns",
"the",
"maximum",
"file",
"image",
"size",
"from",
"the",
"configuration"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L573-L585
|
27,247
|
melisplatform/melis-core
|
src/Controller/PlatformSchemeController.php
|
PlatformSchemeController.getAllowedUploadableExtension
|
public function getAllowedUploadableExtension()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$ext = null;
if($path) {
$ext = isset($path['datas']['allowed_file_extension']) ? $path['datas']['allowed_file_extension'] : 'jpeg,jpg,png,svg,ico,gif';
}
return $ext;
}
|
php
|
public function getAllowedUploadableExtension()
{
$config = $this->getServiceLocator()->get('MelisCoreConfig');
$path = $config->getItem('meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme');
$ext = null;
if($path) {
$ext = isset($path['datas']['allowed_file_extension']) ? $path['datas']['allowed_file_extension'] : 'jpeg,jpg,png,svg,ico,gif';
}
return $ext;
}
|
[
"public",
"function",
"getAllowedUploadableExtension",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"path",
"=",
"$",
"config",
"->",
"getItem",
"(",
"'meliscore/interface/meliscore_leftmenu/interface/meliscore_toolstree_section/interface/meliscore_tool_system_config/interface/meliscore_tool_platform_scheme'",
")",
";",
"$",
"ext",
"=",
"null",
";",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"ext",
"=",
"isset",
"(",
"$",
"path",
"[",
"'datas'",
"]",
"[",
"'allowed_file_extension'",
"]",
")",
"?",
"$",
"path",
"[",
"'datas'",
"]",
"[",
"'allowed_file_extension'",
"]",
":",
"'jpeg,jpg,png,svg,ico,gif'",
";",
"}",
"return",
"$",
"ext",
";",
"}"
] |
Returns the allowed extensions that can be uploaded
@return null|string
|
[
"Returns",
"the",
"allowed",
"extensions",
"that",
"can",
"be",
"uploaded"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformSchemeController.php#L591-L603
|
27,248
|
melisplatform/melis-core
|
src/Service/MelisCoreTranslationService.php
|
MelisCoreTranslationService.getTranslationMessages
|
public function getTranslationMessages($locale = 'en_EN', $textDomain = 'default')
{
// Get the translation service, so we would be able to fetch the current configs
$translator = $this->getServiceLocator()->get('translator');
$translation = $translator->getTranslator();
$messages = array();
// process to access the private properties of translation service
$reflector = new \ReflectionObject($translation);
$property = $reflector->getProperty('files');
$property->setAccessible(true);
$files = (array)$property->getValue($translation);
if($files) {
// re-add translation file to a new Translation Class Object
if(isset($files['default']['*'])) {
foreach($files['default']['*'] as $transKey => $transValues)
{
$this->addTranslationFile('phparray', $transValues['filename'], 'default', $locale);
}
// Load Translation Messages
if (!isset($this->messages[$textDomain][$locale])) {
$this->loadMessages($textDomain, $locale);
}
// This is where the translated mesage are stored
$translatedMessages = (array)$this->messages[$textDomain][$locale];
$messages = array();
$key = '';
foreach($translatedMessages as $translationKey => $translationValues) {
$key = str_replace("'", "\'", $translationKey);
$messages[$key] = str_replace("'", "\'", $translationValues);
}
}
}
return $messages;
}
|
php
|
public function getTranslationMessages($locale = 'en_EN', $textDomain = 'default')
{
// Get the translation service, so we would be able to fetch the current configs
$translator = $this->getServiceLocator()->get('translator');
$translation = $translator->getTranslator();
$messages = array();
// process to access the private properties of translation service
$reflector = new \ReflectionObject($translation);
$property = $reflector->getProperty('files');
$property->setAccessible(true);
$files = (array)$property->getValue($translation);
if($files) {
// re-add translation file to a new Translation Class Object
if(isset($files['default']['*'])) {
foreach($files['default']['*'] as $transKey => $transValues)
{
$this->addTranslationFile('phparray', $transValues['filename'], 'default', $locale);
}
// Load Translation Messages
if (!isset($this->messages[$textDomain][$locale])) {
$this->loadMessages($textDomain, $locale);
}
// This is where the translated mesage are stored
$translatedMessages = (array)$this->messages[$textDomain][$locale];
$messages = array();
$key = '';
foreach($translatedMessages as $translationKey => $translationValues) {
$key = str_replace("'", "\'", $translationKey);
$messages[$key] = str_replace("'", "\'", $translationValues);
}
}
}
return $messages;
}
|
[
"public",
"function",
"getTranslationMessages",
"(",
"$",
"locale",
"=",
"'en_EN'",
",",
"$",
"textDomain",
"=",
"'default'",
")",
"{",
"// Get the translation service, so we would be able to fetch the current configs",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"translation",
"=",
"$",
"translator",
"->",
"getTranslator",
"(",
")",
";",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"// process to access the private properties of translation service",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"translation",
")",
";",
"$",
"property",
"=",
"$",
"reflector",
"->",
"getProperty",
"(",
"'files'",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"files",
"=",
"(",
"array",
")",
"$",
"property",
"->",
"getValue",
"(",
"$",
"translation",
")",
";",
"if",
"(",
"$",
"files",
")",
"{",
"// re-add translation file to a new Translation Class Object",
"if",
"(",
"isset",
"(",
"$",
"files",
"[",
"'default'",
"]",
"[",
"'*'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"files",
"[",
"'default'",
"]",
"[",
"'*'",
"]",
"as",
"$",
"transKey",
"=>",
"$",
"transValues",
")",
"{",
"$",
"this",
"->",
"addTranslationFile",
"(",
"'phparray'",
",",
"$",
"transValues",
"[",
"'filename'",
"]",
",",
"'default'",
",",
"$",
"locale",
")",
";",
"}",
"// Load Translation Messages",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"messages",
"[",
"$",
"textDomain",
"]",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"$",
"this",
"->",
"loadMessages",
"(",
"$",
"textDomain",
",",
"$",
"locale",
")",
";",
"}",
"// This is where the translated mesage are stored",
"$",
"translatedMessages",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"messages",
"[",
"$",
"textDomain",
"]",
"[",
"$",
"locale",
"]",
";",
"$",
"messages",
"=",
"array",
"(",
")",
";",
"$",
"key",
"=",
"''",
";",
"foreach",
"(",
"$",
"translatedMessages",
"as",
"$",
"translationKey",
"=>",
"$",
"translationValues",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"translationKey",
")",
";",
"$",
"messages",
"[",
"$",
"key",
"]",
"=",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"translationValues",
")",
";",
"}",
"}",
"}",
"return",
"$",
"messages",
";",
"}"
] |
Re-imports translation files from all the modules and re-writes it
so it can be used in Javascript or any other scripts that would like
to use translation on their messages
@param String $locale
@param string $textDomain
@return Array
|
[
"Re",
"-",
"imports",
"translation",
"files",
"from",
"all",
"the",
"modules",
"and",
"re",
"-",
"writes",
"it",
"so",
"it",
"can",
"be",
"used",
"in",
"Javascript",
"or",
"any",
"other",
"scripts",
"that",
"would",
"like",
"to",
"use",
"translation",
"on",
"their",
"messages"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L54-L98
|
27,249
|
melisplatform/melis-core
|
src/Service/MelisCoreTranslationService.php
|
MelisCoreTranslationService.checkLanguageDirectory
|
private function checkLanguageDirectory($dir, $modulePath)
{
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$confLanguage = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_files');
$defaultTransInterface = $confLanguage['defaultTransInterface'];
$defaultTransForms = $confLanguage['defaultTransForms'];
$result = true;
if (!file_exists($dir)) {
$result = mkdir($dir, 0777, true);
if(file_exists($modulePath.$defaultTransInterface)){
copy($modulePath.$defaultTransInterface, $dir.'/'.$defaultTransInterface);
}
if(file_exists($modulePath.$defaultTransForms)){
copy($modulePath.$defaultTransForms, $dir.'/'.$defaultTransForms);
}
}
return $result;
}
|
php
|
private function checkLanguageDirectory($dir, $modulePath)
{
$melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$confLanguage = $melisCoreConfig->getItem('meliscore/datas/default/langauges/default_trans_files');
$defaultTransInterface = $confLanguage['defaultTransInterface'];
$defaultTransForms = $confLanguage['defaultTransForms'];
$result = true;
if (!file_exists($dir)) {
$result = mkdir($dir, 0777, true);
if(file_exists($modulePath.$defaultTransInterface)){
copy($modulePath.$defaultTransInterface, $dir.'/'.$defaultTransInterface);
}
if(file_exists($modulePath.$defaultTransForms)){
copy($modulePath.$defaultTransForms, $dir.'/'.$defaultTransForms);
}
}
return $result;
}
|
[
"private",
"function",
"checkLanguageDirectory",
"(",
"$",
"dir",
",",
"$",
"modulePath",
")",
"{",
"$",
"melisCoreConfig",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"confLanguage",
"=",
"$",
"melisCoreConfig",
"->",
"getItem",
"(",
"'meliscore/datas/default/langauges/default_trans_files'",
")",
";",
"$",
"defaultTransInterface",
"=",
"$",
"confLanguage",
"[",
"'defaultTransInterface'",
"]",
";",
"$",
"defaultTransForms",
"=",
"$",
"confLanguage",
"[",
"'defaultTransForms'",
"]",
";",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"result",
"=",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"modulePath",
".",
"$",
"defaultTransInterface",
")",
")",
"{",
"copy",
"(",
"$",
"modulePath",
".",
"$",
"defaultTransInterface",
",",
"$",
"dir",
".",
"'/'",
".",
"$",
"defaultTransInterface",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"modulePath",
".",
"$",
"defaultTransForms",
")",
")",
"{",
"copy",
"(",
"$",
"modulePath",
".",
"$",
"defaultTransForms",
",",
"$",
"dir",
".",
"'/'",
".",
"$",
"defaultTransForms",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Checks the language directory if the path exist, creates a directory if with english translations if not existing
@param string $dir The directory path of the language directory
@param string $modulePath The directory path of melis english translations
@return boolean true if existing, otherwise false if failed to create
|
[
"Checks",
"the",
"language",
"directory",
"if",
"the",
"path",
"exist",
"creates",
"a",
"directory",
"if",
"with",
"english",
"translations",
"if",
"not",
"existing"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L374-L393
|
27,250
|
melisplatform/melis-core
|
src/Service/MelisCoreTranslationService.php
|
MelisCoreTranslationService.checkTranslationsDiff
|
public function checkTranslationsDiff($melisTrans, $currentTrans)
{
$new = include $melisTrans;
$new = is_array($new)? $new : array();
$current = include $currentTrans;
$current = is_array($current)? $current : array();
return array_diff_key($new, $current);
}
|
php
|
public function checkTranslationsDiff($melisTrans, $currentTrans)
{
$new = include $melisTrans;
$new = is_array($new)? $new : array();
$current = include $currentTrans;
$current = is_array($current)? $current : array();
return array_diff_key($new, $current);
}
|
[
"public",
"function",
"checkTranslationsDiff",
"(",
"$",
"melisTrans",
",",
"$",
"currentTrans",
")",
"{",
"$",
"new",
"=",
"include",
"$",
"melisTrans",
";",
"$",
"new",
"=",
"is_array",
"(",
"$",
"new",
")",
"?",
"$",
"new",
":",
"array",
"(",
")",
";",
"$",
"current",
"=",
"include",
"$",
"currentTrans",
";",
"$",
"current",
"=",
"is_array",
"(",
"$",
"current",
")",
"?",
"$",
"current",
":",
"array",
"(",
")",
";",
"return",
"array_diff_key",
"(",
"$",
"new",
",",
"$",
"current",
")",
";",
"}"
] |
Checks if melis translations have new updates and returns the missing translations
@param string $melisTrans The path of the module translation
@param string $currentTrans The path of the current translation
returns array() Returns an array of missing translations with the keys and values
|
[
"Checks",
"if",
"melis",
"translations",
"have",
"new",
"updates",
"and",
"returns",
"the",
"missing",
"translations"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L502-L511
|
27,251
|
melisplatform/melis-core
|
src/Service/MelisCoreTranslationService.php
|
MelisCoreTranslationService.updateTranslations
|
public function updateTranslations($currentTrans, $transDiff)
{
$status = false;
$current = include $currentTrans;
$current = is_array($current)? $current : array();
$transUpdate = array_merge($current, $transDiff);
$content = "<?php". PHP_EOL . "\t return array(" . PHP_EOL;
foreach($transUpdate as $key => $value){
$content .= "\t\t'". addslashes($key) . "' => '" . addslashes($value) ."'," .PHP_EOL;
}
$content .= "\t );" . PHP_EOL;
if(file_put_contents($currentTrans, $content, LOCK_EX)){
$status = true;
}
return $status;
}
|
php
|
public function updateTranslations($currentTrans, $transDiff)
{
$status = false;
$current = include $currentTrans;
$current = is_array($current)? $current : array();
$transUpdate = array_merge($current, $transDiff);
$content = "<?php". PHP_EOL . "\t return array(" . PHP_EOL;
foreach($transUpdate as $key => $value){
$content .= "\t\t'". addslashes($key) . "' => '" . addslashes($value) ."'," .PHP_EOL;
}
$content .= "\t );" . PHP_EOL;
if(file_put_contents($currentTrans, $content, LOCK_EX)){
$status = true;
}
return $status;
}
|
[
"public",
"function",
"updateTranslations",
"(",
"$",
"currentTrans",
",",
"$",
"transDiff",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"current",
"=",
"include",
"$",
"currentTrans",
";",
"$",
"current",
"=",
"is_array",
"(",
"$",
"current",
")",
"?",
"$",
"current",
":",
"array",
"(",
")",
";",
"$",
"transUpdate",
"=",
"array_merge",
"(",
"$",
"current",
",",
"$",
"transDiff",
")",
";",
"$",
"content",
"=",
"\"<?php\"",
".",
"PHP_EOL",
".",
"\"\\t return array(\"",
".",
"PHP_EOL",
";",
"foreach",
"(",
"$",
"transUpdate",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"content",
".=",
"\"\\t\\t'\"",
".",
"addslashes",
"(",
"$",
"key",
")",
".",
"\"' => '\"",
".",
"addslashes",
"(",
"$",
"value",
")",
".",
"\"',\"",
".",
"PHP_EOL",
";",
"}",
"$",
"content",
".=",
"\"\\t );\"",
".",
"PHP_EOL",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"currentTrans",
",",
"$",
"content",
",",
"LOCK_EX",
")",
")",
"{",
"$",
"status",
"=",
"true",
";",
"}",
"return",
"$",
"status",
";",
"}"
] |
Updates the translation files
@param string $currentTrans The path of the current translation
@param array $transDiff array of translations to be added
@return boolean
|
[
"Updates",
"the",
"translation",
"files"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreTranslationService.php#L521-L540
|
27,252
|
orchestral/kernel
|
src/Notifications/ChannelManager.php
|
ChannelManager.createMailDriver
|
protected function createMailDriver()
{
$mailer = $this->app->make('orchestra.mail');
return $this->app->make(MailChannel::class, [$mailer->getMailer()]);
}
|
php
|
protected function createMailDriver()
{
$mailer = $this->app->make('orchestra.mail');
return $this->app->make(MailChannel::class, [$mailer->getMailer()]);
}
|
[
"protected",
"function",
"createMailDriver",
"(",
")",
"{",
"$",
"mailer",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'orchestra.mail'",
")",
";",
"return",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"MailChannel",
"::",
"class",
",",
"[",
"$",
"mailer",
"->",
"getMailer",
"(",
")",
"]",
")",
";",
"}"
] |
Create an instance of the mail driver.
@return \Illuminate\Notifications\Channels\MailChannel
|
[
"Create",
"an",
"instance",
"of",
"the",
"mail",
"driver",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Notifications/ChannelManager.php#L15-L20
|
27,253
|
melisplatform/melis-core
|
src/Model/Tables/MelisGenericTable.php
|
MelisGenericTable.getTableColumns
|
public function getTableColumns()
{
$metadata = new MetaData($this->tableGateway->getAdapter());
$columns = $metadata->getColumnNames($this->tableGateway->getTable());
return $columns;
}
|
php
|
public function getTableColumns()
{
$metadata = new MetaData($this->tableGateway->getAdapter());
$columns = $metadata->getColumnNames($this->tableGateway->getTable());
return $columns;
}
|
[
"public",
"function",
"getTableColumns",
"(",
")",
"{",
"$",
"metadata",
"=",
"new",
"MetaData",
"(",
"$",
"this",
"->",
"tableGateway",
"->",
"getAdapter",
"(",
")",
")",
";",
"$",
"columns",
"=",
"$",
"metadata",
"->",
"getColumnNames",
"(",
"$",
"this",
"->",
"tableGateway",
"->",
"getTable",
"(",
")",
")",
";",
"return",
"$",
"columns",
";",
"}"
] |
Returns the columns of the table
@param Array $table
|
[
"Returns",
"the",
"columns",
"of",
"the",
"table"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisGenericTable.php#L128-L134
|
27,254
|
melisplatform/melis-core
|
src/Model/Tables/MelisGenericTable.php
|
MelisGenericTable.getTotalData
|
public function getTotalData($field = null, $idValue = null)
{
$select = $this->tableGateway->getSql()->select();
if (!empty($field) && !empty($idValue))
{
$select->where(array($field => (int) $idValue));
}
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet->count();
}
|
php
|
public function getTotalData($field = null, $idValue = null)
{
$select = $this->tableGateway->getSql()->select();
if (!empty($field) && !empty($idValue))
{
$select->where(array($field => (int) $idValue));
}
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet->count();
}
|
[
"public",
"function",
"getTotalData",
"(",
"$",
"field",
"=",
"null",
",",
"$",
"idValue",
"=",
"null",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"field",
")",
"&&",
"!",
"empty",
"(",
"$",
"idValue",
")",
")",
"{",
"$",
"select",
"->",
"where",
"(",
"array",
"(",
"$",
"field",
"=>",
"(",
"int",
")",
"$",
"idValue",
")",
")",
";",
"}",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"selectWith",
"(",
"$",
"select",
")",
";",
"return",
"$",
"resultSet",
"->",
"count",
"(",
")",
";",
"}"
] |
Returns the total rows of the selected table
@return int
|
[
"Returns",
"the",
"total",
"rows",
"of",
"the",
"selected",
"table"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisGenericTable.php#L303-L315
|
27,255
|
melisplatform/melis-core
|
src/Model/Tables/MelisGenericTable.php
|
MelisGenericTable.getDataForExport
|
public function getDataForExport($filter, $columns = array())
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('*'));
$w = new Where();
$filters = array();
$likes = array();
foreach($columns as $columnKeys)
{
$likes[] = new Like($columnKeys, '%'.$filter.'%');
}
$filters = array(new PredicateSet($likes, PredicateSet::COMBINED_BY_OR));
$select->where($filters);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
php
|
public function getDataForExport($filter, $columns = array())
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('*'));
$w = new Where();
$filters = array();
$likes = array();
foreach($columns as $columnKeys)
{
$likes[] = new Like($columnKeys, '%'.$filter.'%');
}
$filters = array(new PredicateSet($likes, PredicateSet::COMBINED_BY_OR));
$select->where($filters);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
[
"public",
"function",
"getDataForExport",
"(",
"$",
"filter",
",",
"$",
"columns",
"=",
"array",
"(",
")",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"$",
"select",
"->",
"columns",
"(",
"array",
"(",
"'*'",
")",
")",
";",
"$",
"w",
"=",
"new",
"Where",
"(",
")",
";",
"$",
"filters",
"=",
"array",
"(",
")",
";",
"$",
"likes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"columnKeys",
")",
"{",
"$",
"likes",
"[",
"]",
"=",
"new",
"Like",
"(",
"$",
"columnKeys",
",",
"'%'",
".",
"$",
"filter",
".",
"'%'",
")",
";",
"}",
"$",
"filters",
"=",
"array",
"(",
"new",
"PredicateSet",
"(",
"$",
"likes",
",",
"PredicateSet",
"::",
"COMBINED_BY_OR",
")",
")",
";",
"$",
"select",
"->",
"where",
"(",
"$",
"filters",
")",
";",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"selectWith",
"(",
"$",
"select",
")",
";",
"return",
"$",
"resultSet",
";",
"}"
] |
Returns all the data from the selected column
@param String $filter
@param array $columns
@return Array
|
[
"Returns",
"all",
"the",
"data",
"from",
"the",
"selected",
"column"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisGenericTable.php#L332-L354
|
27,256
|
orchestral/kernel
|
src/Http/VersionControl.php
|
VersionControl.addVersion
|
public function addVersion(string $code, string $namespace, bool $default = false)
{
$this->supportedVersions[$code] = $namespace;
if (is_null($this->defaultVersion) || $default === true) {
$this->setDefaultVersion($code);
}
return $this;
}
|
php
|
public function addVersion(string $code, string $namespace, bool $default = false)
{
$this->supportedVersions[$code] = $namespace;
if (is_null($this->defaultVersion) || $default === true) {
$this->setDefaultVersion($code);
}
return $this;
}
|
[
"public",
"function",
"addVersion",
"(",
"string",
"$",
"code",
",",
"string",
"$",
"namespace",
",",
"bool",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"supportedVersions",
"[",
"$",
"code",
"]",
"=",
"$",
"namespace",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"defaultVersion",
")",
"||",
"$",
"default",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"setDefaultVersion",
"(",
"$",
"code",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add version.
@param string $code
@param string $namespace
@param bool $default
@return $this
|
[
"Add",
"version",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/VersionControl.php#L32-L41
|
27,257
|
orchestral/kernel
|
src/Http/VersionControl.php
|
VersionControl.setDefaultVersion
|
public function setDefaultVersion(string $code)
{
if (! array_key_exists($code, $this->supportedVersions)) {
throw new InvalidArgumentException("Unable to set [{$code}] as default version!");
}
$this->defaultVersion = $code;
return $this;
}
|
php
|
public function setDefaultVersion(string $code)
{
if (! array_key_exists($code, $this->supportedVersions)) {
throw new InvalidArgumentException("Unable to set [{$code}] as default version!");
}
$this->defaultVersion = $code;
return $this;
}
|
[
"public",
"function",
"setDefaultVersion",
"(",
"string",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"supportedVersions",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unable to set [{$code}] as default version!\"",
")",
";",
"}",
"$",
"this",
"->",
"defaultVersion",
"=",
"$",
"code",
";",
"return",
"$",
"this",
";",
"}"
] |
Set default version.
@param string $code
@throws \InvalidArgumentException
@return $this
|
[
"Set",
"default",
"version",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/VersionControl.php#L52-L61
|
27,258
|
orchestral/kernel
|
src/Http/VersionControl.php
|
VersionControl.resolve
|
public function resolve(string $namespace, string $version, string $name): string
{
$class = str_replace('.', '\\', $name);
if (! array_key_exists($version, $this->supportedVersions)) {
$version = $this->defaultVersion;
}
return sprintf('%s\%s\%s\%s', $namespace, $this->supportedVersions[$version], $class);
}
|
php
|
public function resolve(string $namespace, string $version, string $name): string
{
$class = str_replace('.', '\\', $name);
if (! array_key_exists($version, $this->supportedVersions)) {
$version = $this->defaultVersion;
}
return sprintf('%s\%s\%s\%s', $namespace, $this->supportedVersions[$version], $class);
}
|
[
"public",
"function",
"resolve",
"(",
"string",
"$",
"namespace",
",",
"string",
"$",
"version",
",",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"class",
"=",
"str_replace",
"(",
"'.'",
",",
"'\\\\'",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"supportedVersions",
")",
")",
"{",
"$",
"version",
"=",
"$",
"this",
"->",
"defaultVersion",
";",
"}",
"return",
"sprintf",
"(",
"'%s\\%s\\%s\\%s'",
",",
"$",
"namespace",
",",
"$",
"this",
"->",
"supportedVersions",
"[",
"$",
"version",
"]",
",",
"$",
"class",
")",
";",
"}"
] |
Resolve version for requested class.
@param string $namespace
@param string $version
@param string $group
@param string $name
@return string
|
[
"Resolve",
"version",
"for",
"requested",
"class",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/VersionControl.php#L73-L82
|
27,259
|
melisplatform/melis-core
|
src/Service/MelisCorePlatformSchemeService.php
|
MelisCorePlatformSchemeService.getCurrentScheme
|
public function getCurrentScheme($colorsOnly = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = null;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_start', $arrayParameters);
$table = $this->schemeTable();
$schemeData = $table->getActiveScheme($colorsOnly)->current();
if(!$schemeData) {
$schemeData = $table->getDefaultScheme($colorsOnly)->current();
}
// check if scheme has data
if($schemeData) {
$entScheme = new MelisCorePlatformScheme();
$entScheme->setId($schemeData->pscheme_id);
$entScheme->setName($schemeData->pscheme_name);
$entScheme->setColors($schemeData->pscheme_colors);
if(!$colorsOnly) {
$entScheme->setSidebarHeaderLogo($schemeData->pscheme_sidebar_header_logo);
$entScheme->setSidebarHeaderText($schemeData->pscheme_sidebar_header_text);
$entScheme->setLoginLogo($schemeData->pscheme_login_logo);
$entScheme->setLoginBackground($schemeData->pscheme_login_background);
$entScheme->setFavicon($schemeData->pscheme_favicon);
}
$entScheme->setIsActive($schemeData->pscheme_is_active);
$results = $entScheme;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_end', $arrayParameters);
return $arrayParameters['results'];
}
|
php
|
public function getCurrentScheme($colorsOnly = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = null;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_start', $arrayParameters);
$table = $this->schemeTable();
$schemeData = $table->getActiveScheme($colorsOnly)->current();
if(!$schemeData) {
$schemeData = $table->getDefaultScheme($colorsOnly)->current();
}
// check if scheme has data
if($schemeData) {
$entScheme = new MelisCorePlatformScheme();
$entScheme->setId($schemeData->pscheme_id);
$entScheme->setName($schemeData->pscheme_name);
$entScheme->setColors($schemeData->pscheme_colors);
if(!$colorsOnly) {
$entScheme->setSidebarHeaderLogo($schemeData->pscheme_sidebar_header_logo);
$entScheme->setSidebarHeaderText($schemeData->pscheme_sidebar_header_text);
$entScheme->setLoginLogo($schemeData->pscheme_login_logo);
$entScheme->setLoginBackground($schemeData->pscheme_login_background);
$entScheme->setFavicon($schemeData->pscheme_favicon);
}
$entScheme->setIsActive($schemeData->pscheme_is_active);
$results = $entScheme;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_get_current_scheme_end', $arrayParameters);
return $arrayParameters['results'];
}
|
[
"public",
"function",
"getCurrentScheme",
"(",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"// Event parameters prepare",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"makeArrayFromParameters",
"(",
"__METHOD__",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"results",
"=",
"null",
";",
"// Sending service start event",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"sendEvent",
"(",
"'melis_core_package_scheme_get_current_scheme_start'",
",",
"$",
"arrayParameters",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"schemeTable",
"(",
")",
";",
"$",
"schemeData",
"=",
"$",
"table",
"->",
"getActiveScheme",
"(",
"$",
"colorsOnly",
")",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"$",
"schemeData",
")",
"{",
"$",
"schemeData",
"=",
"$",
"table",
"->",
"getDefaultScheme",
"(",
"$",
"colorsOnly",
")",
"->",
"current",
"(",
")",
";",
"}",
"// check if scheme has data",
"if",
"(",
"$",
"schemeData",
")",
"{",
"$",
"entScheme",
"=",
"new",
"MelisCorePlatformScheme",
"(",
")",
";",
"$",
"entScheme",
"->",
"setId",
"(",
"$",
"schemeData",
"->",
"pscheme_id",
")",
";",
"$",
"entScheme",
"->",
"setName",
"(",
"$",
"schemeData",
"->",
"pscheme_name",
")",
";",
"$",
"entScheme",
"->",
"setColors",
"(",
"$",
"schemeData",
"->",
"pscheme_colors",
")",
";",
"if",
"(",
"!",
"$",
"colorsOnly",
")",
"{",
"$",
"entScheme",
"->",
"setSidebarHeaderLogo",
"(",
"$",
"schemeData",
"->",
"pscheme_sidebar_header_logo",
")",
";",
"$",
"entScheme",
"->",
"setSidebarHeaderText",
"(",
"$",
"schemeData",
"->",
"pscheme_sidebar_header_text",
")",
";",
"$",
"entScheme",
"->",
"setLoginLogo",
"(",
"$",
"schemeData",
"->",
"pscheme_login_logo",
")",
";",
"$",
"entScheme",
"->",
"setLoginBackground",
"(",
"$",
"schemeData",
"->",
"pscheme_login_background",
")",
";",
"$",
"entScheme",
"->",
"setFavicon",
"(",
"$",
"schemeData",
"->",
"pscheme_favicon",
")",
";",
"}",
"$",
"entScheme",
"->",
"setIsActive",
"(",
"$",
"schemeData",
"->",
"pscheme_is_active",
")",
";",
"$",
"results",
"=",
"$",
"entScheme",
";",
"}",
"// Adding results to parameters for events treatment if needed",
"$",
"arrayParameters",
"[",
"'results'",
"]",
"=",
"$",
"results",
";",
"// Sending service end event",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"sendEvent",
"(",
"'melis_core_package_scheme_get_current_scheme_end'",
",",
"$",
"arrayParameters",
")",
";",
"return",
"$",
"arrayParameters",
"[",
"'results'",
"]",
";",
"}"
] |
Returns the currently active scheme, if there's none active
it returns the Melis default scheme
@param bool $colorsOnly : true|false - if true it returns only the colors that will be used in the platform
@return MelisCorePlatformScheme|null
|
[
"Returns",
"the",
"currently",
"active",
"scheme",
"if",
"there",
"s",
"none",
"active",
"it",
"returns",
"the",
"Melis",
"default",
"scheme"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCorePlatformSchemeService.php#L37-L83
|
27,260
|
melisplatform/melis-core
|
src/Service/MelisCorePlatformSchemeService.php
|
MelisCorePlatformSchemeService.saveScheme
|
public function saveScheme($data, $id, $setAsActive = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_start', $arrayParameters);
$data = $arrayParameters['data'];
$id = (int) $arrayParameters['id'];
$setAsActive = (bool) $arrayParameters['setAsActive'];
$success = $this->schemeTable()->save(array_merge($data, array('pscheme_is_active' => $setAsActive)), $id);
if($success) {
$results = true;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_end', $arrayParameters);
return $arrayParameters['results'];
}
|
php
|
public function saveScheme($data, $id, $setAsActive = false)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_start', $arrayParameters);
$data = $arrayParameters['data'];
$id = (int) $arrayParameters['id'];
$setAsActive = (bool) $arrayParameters['setAsActive'];
$success = $this->schemeTable()->save(array_merge($data, array('pscheme_is_active' => $setAsActive)), $id);
if($success) {
$results = true;
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_save_end', $arrayParameters);
return $arrayParameters['results'];
}
|
[
"public",
"function",
"saveScheme",
"(",
"$",
"data",
",",
"$",
"id",
",",
"$",
"setAsActive",
"=",
"false",
")",
"{",
"// Event parameters prepare",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"makeArrayFromParameters",
"(",
"__METHOD__",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"results",
"=",
"false",
";",
"// Sending service start event",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"sendEvent",
"(",
"'melis_core_package_scheme_save_start'",
",",
"$",
"arrayParameters",
")",
";",
"$",
"data",
"=",
"$",
"arrayParameters",
"[",
"'data'",
"]",
";",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"arrayParameters",
"[",
"'id'",
"]",
";",
"$",
"setAsActive",
"=",
"(",
"bool",
")",
"$",
"arrayParameters",
"[",
"'setAsActive'",
"]",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"schemeTable",
"(",
")",
"->",
"save",
"(",
"array_merge",
"(",
"$",
"data",
",",
"array",
"(",
"'pscheme_is_active'",
"=>",
"$",
"setAsActive",
")",
")",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"$",
"results",
"=",
"true",
";",
"}",
"// Adding results to parameters for events treatment if needed",
"$",
"arrayParameters",
"[",
"'results'",
"]",
"=",
"$",
"results",
";",
"// Sending service end event",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"sendEvent",
"(",
"'melis_core_package_scheme_save_end'",
",",
"$",
"arrayParameters",
")",
";",
"return",
"$",
"arrayParameters",
"[",
"'results'",
"]",
";",
"}"
] |
Handles the saving of the platform scheme
@param $data
@param $id
@param bool $setAsActive
@return mixed
|
[
"Handles",
"the",
"saving",
"of",
"the",
"platform",
"scheme"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCorePlatformSchemeService.php#L92-L117
|
27,261
|
melisplatform/melis-core
|
src/Service/MelisCorePlatformSchemeService.php
|
MelisCorePlatformSchemeService.resetScheme
|
public function resetScheme($id)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_start', $arrayParameters);
$defaultSchemeData = $this->schemeTable()->getDefaultScheme()->current();
if($defaultSchemeData) {
$data = array(
'pscheme_colors' => $defaultSchemeData->pscheme_colors,
'pscheme_sidebar_header_logo' => $defaultSchemeData->pscheme_sidebar_header_logo,
'pscheme_sidebar_header_text' => $defaultSchemeData->pscheme_sidebar_header_text,
'pscheme_login_logo' => $defaultSchemeData->pscheme_login_logo,
'pscheme_login_background' => $defaultSchemeData->pscheme_login_background,
'pscheme_favicon' => $defaultSchemeData->pscheme_favicon,
'pscheme_is_active' => 1,
);
$success = $this->schemeTable()->save($data, $id);
if($success) {
$results = true;
}
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_end', $arrayParameters);
return $arrayParameters['results'];
}
|
php
|
public function resetScheme($id)
{
// Event parameters prepare
$arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
$results = false;
// Sending service start event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_start', $arrayParameters);
$defaultSchemeData = $this->schemeTable()->getDefaultScheme()->current();
if($defaultSchemeData) {
$data = array(
'pscheme_colors' => $defaultSchemeData->pscheme_colors,
'pscheme_sidebar_header_logo' => $defaultSchemeData->pscheme_sidebar_header_logo,
'pscheme_sidebar_header_text' => $defaultSchemeData->pscheme_sidebar_header_text,
'pscheme_login_logo' => $defaultSchemeData->pscheme_login_logo,
'pscheme_login_background' => $defaultSchemeData->pscheme_login_background,
'pscheme_favicon' => $defaultSchemeData->pscheme_favicon,
'pscheme_is_active' => 1,
);
$success = $this->schemeTable()->save($data, $id);
if($success) {
$results = true;
}
}
// Adding results to parameters for events treatment if needed
$arrayParameters['results'] = $results;
// Sending service end event
$arrayParameters = $this->sendEvent('melis_core_package_scheme_reset_end', $arrayParameters);
return $arrayParameters['results'];
}
|
[
"public",
"function",
"resetScheme",
"(",
"$",
"id",
")",
"{",
"// Event parameters prepare",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"makeArrayFromParameters",
"(",
"__METHOD__",
",",
"func_get_args",
"(",
")",
")",
";",
"$",
"results",
"=",
"false",
";",
"// Sending service start event",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"sendEvent",
"(",
"'melis_core_package_scheme_reset_start'",
",",
"$",
"arrayParameters",
")",
";",
"$",
"defaultSchemeData",
"=",
"$",
"this",
"->",
"schemeTable",
"(",
")",
"->",
"getDefaultScheme",
"(",
")",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"defaultSchemeData",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'pscheme_colors'",
"=>",
"$",
"defaultSchemeData",
"->",
"pscheme_colors",
",",
"'pscheme_sidebar_header_logo'",
"=>",
"$",
"defaultSchemeData",
"->",
"pscheme_sidebar_header_logo",
",",
"'pscheme_sidebar_header_text'",
"=>",
"$",
"defaultSchemeData",
"->",
"pscheme_sidebar_header_text",
",",
"'pscheme_login_logo'",
"=>",
"$",
"defaultSchemeData",
"->",
"pscheme_login_logo",
",",
"'pscheme_login_background'",
"=>",
"$",
"defaultSchemeData",
"->",
"pscheme_login_background",
",",
"'pscheme_favicon'",
"=>",
"$",
"defaultSchemeData",
"->",
"pscheme_favicon",
",",
"'pscheme_is_active'",
"=>",
"1",
",",
")",
";",
"$",
"success",
"=",
"$",
"this",
"->",
"schemeTable",
"(",
")",
"->",
"save",
"(",
"$",
"data",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"success",
")",
"{",
"$",
"results",
"=",
"true",
";",
"}",
"}",
"// Adding results to parameters for events treatment if needed",
"$",
"arrayParameters",
"[",
"'results'",
"]",
"=",
"$",
"results",
";",
"// Sending service end event",
"$",
"arrayParameters",
"=",
"$",
"this",
"->",
"sendEvent",
"(",
"'melis_core_package_scheme_reset_end'",
",",
"$",
"arrayParameters",
")",
";",
"return",
"$",
"arrayParameters",
"[",
"'results'",
"]",
";",
"}"
] |
Handles the event for resetting the whole scheme of the selected template
@param $id
@return mixed
|
[
"Handles",
"the",
"event",
"for",
"resetting",
"the",
"whole",
"scheme",
"of",
"the",
"selected",
"template"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCorePlatformSchemeService.php#L124-L158
|
27,262
|
melisplatform/melis-core
|
src/Controller/IndexController.php
|
IndexController.headerAction
|
public function headerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
if ($melisCoreAuth->hasIdentity())
{
$melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$appsConfigCenter = $melisAppConfig->getItem('/meliscore/interface/meliscore_center/');
$melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
$xmlRights = $melisCoreAuth->getAuthRights();
if (!empty($appsConfigCenter['interface']))
{
foreach ($appsConfigCenter['interface'] as $keyInterface => $interface)
{
if (!empty($interface['conf']) && !empty($interface['conf']['type']))
$keyTempInterface = $interface['conf']['type'];
else
$keyTempInterface = $keyInterface;
$isAccessible = $melisCoreRights->isAccessible($xmlRights, MelisCoreRightsService::MELISCORE_PREFIX_INTERFACE, $keyTempInterface);
if (!$isAccessible)
{
unset($appsConfigCenter['interface'][$keyInterface]);
}
}
}
}
else
$appsConfigCenter = array();
$schemeSvc = $this->getServiceLocator()->get('MelisCorePlatformSchemeService');
$schemeData = $schemeSvc->getCurrentScheme();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->appsConfigCenter = $appsConfigCenter;
$view->schemes = $schemeData;
return $view;
}
|
php
|
public function headerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth');
if ($melisCoreAuth->hasIdentity())
{
$melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');
$appsConfigCenter = $melisAppConfig->getItem('/meliscore/interface/meliscore_center/');
$melisCoreRights = $this->getServiceLocator()->get('MelisCoreRights');
$xmlRights = $melisCoreAuth->getAuthRights();
if (!empty($appsConfigCenter['interface']))
{
foreach ($appsConfigCenter['interface'] as $keyInterface => $interface)
{
if (!empty($interface['conf']) && !empty($interface['conf']['type']))
$keyTempInterface = $interface['conf']['type'];
else
$keyTempInterface = $keyInterface;
$isAccessible = $melisCoreRights->isAccessible($xmlRights, MelisCoreRightsService::MELISCORE_PREFIX_INTERFACE, $keyTempInterface);
if (!$isAccessible)
{
unset($appsConfigCenter['interface'][$keyInterface]);
}
}
}
}
else
$appsConfigCenter = array();
$schemeSvc = $this->getServiceLocator()->get('MelisCorePlatformSchemeService');
$schemeData = $schemeSvc->getCurrentScheme();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->appsConfigCenter = $appsConfigCenter;
$view->schemes = $schemeData;
return $view;
}
|
[
"public",
"function",
"headerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"melisCoreAuth",
"=",
"$",
"this",
"->",
"serviceLocator",
"->",
"get",
"(",
"'MelisCoreAuth'",
")",
";",
"if",
"(",
"$",
"melisCoreAuth",
"->",
"hasIdentity",
"(",
")",
")",
"{",
"$",
"melisAppConfig",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreConfig'",
")",
";",
"$",
"appsConfigCenter",
"=",
"$",
"melisAppConfig",
"->",
"getItem",
"(",
"'/meliscore/interface/meliscore_center/'",
")",
";",
"$",
"melisCoreRights",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreRights'",
")",
";",
"$",
"xmlRights",
"=",
"$",
"melisCoreAuth",
"->",
"getAuthRights",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"appsConfigCenter",
"[",
"'interface'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"appsConfigCenter",
"[",
"'interface'",
"]",
"as",
"$",
"keyInterface",
"=>",
"$",
"interface",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"interface",
"[",
"'conf'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"interface",
"[",
"'conf'",
"]",
"[",
"'type'",
"]",
")",
")",
"$",
"keyTempInterface",
"=",
"$",
"interface",
"[",
"'conf'",
"]",
"[",
"'type'",
"]",
";",
"else",
"$",
"keyTempInterface",
"=",
"$",
"keyInterface",
";",
"$",
"isAccessible",
"=",
"$",
"melisCoreRights",
"->",
"isAccessible",
"(",
"$",
"xmlRights",
",",
"MelisCoreRightsService",
"::",
"MELISCORE_PREFIX_INTERFACE",
",",
"$",
"keyTempInterface",
")",
";",
"if",
"(",
"!",
"$",
"isAccessible",
")",
"{",
"unset",
"(",
"$",
"appsConfigCenter",
"[",
"'interface'",
"]",
"[",
"$",
"keyInterface",
"]",
")",
";",
"}",
"}",
"}",
"}",
"else",
"$",
"appsConfigCenter",
"=",
"array",
"(",
")",
";",
"$",
"schemeSvc",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCorePlatformSchemeService'",
")",
";",
"$",
"schemeData",
"=",
"$",
"schemeSvc",
"->",
"getCurrentScheme",
"(",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"$",
"view",
"->",
"appsConfigCenter",
"=",
"$",
"appsConfigCenter",
";",
"$",
"view",
"->",
"schemes",
"=",
"$",
"schemeData",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the header section of Melis Platform
@return \Zend\View\Model\ViewModel
|
[
"Shows",
"the",
"header",
"section",
"of",
"Melis",
"Platform"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L53-L93
|
27,263
|
melisplatform/melis-core
|
src/Controller/IndexController.php
|
IndexController.leftMenuAction
|
public function leftMenuAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function leftMenuAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"leftMenuAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the left menu of the Melis Platform interface
@return \Zend\View\Model\ViewModel
|
[
"Shows",
"the",
"left",
"menu",
"of",
"the",
"Melis",
"Platform",
"interface"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L108-L116
|
27,264
|
melisplatform/melis-core
|
src/Controller/IndexController.php
|
IndexController.footerAction
|
public function footerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$coreTool = $this->getServiceLocator()->get('MelisCoreTool');
$modules = $moduleSvc->getAllModules();
$platformVersion = $moduleSvc->getModulesAndVersions('MelisCore');
$request = $this->getRequest();
$uri = $request->getUri();
$domain = $uri->getHost();
$scheme = $uri->getScheme();
$netConnection = $coreTool->isConnected();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->platformVersion = $platformVersion['version'];
$view->modules = serialize($modules);
$view->scheme = $scheme;
$view->domain = $domain;
$view->netConn = $netConnection;
return $view;
}
|
php
|
public function footerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$moduleSvc = $this->getServiceLocator()->get('ModulesService');
$coreTool = $this->getServiceLocator()->get('MelisCoreTool');
$modules = $moduleSvc->getAllModules();
$platformVersion = $moduleSvc->getModulesAndVersions('MelisCore');
$request = $this->getRequest();
$uri = $request->getUri();
$domain = $uri->getHost();
$scheme = $uri->getScheme();
$netConnection = $coreTool->isConnected();
$view = new ViewModel();
$view->melisKey = $melisKey;
$view->platformVersion = $platformVersion['version'];
$view->modules = serialize($modules);
$view->scheme = $scheme;
$view->domain = $domain;
$view->netConn = $netConnection;
return $view;
}
|
[
"public",
"function",
"footerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"moduleSvc",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'ModulesService'",
")",
";",
"$",
"coreTool",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisCoreTool'",
")",
";",
"$",
"modules",
"=",
"$",
"moduleSvc",
"->",
"getAllModules",
"(",
")",
";",
"$",
"platformVersion",
"=",
"$",
"moduleSvc",
"->",
"getModulesAndVersions",
"(",
"'MelisCore'",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"getRequest",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"domain",
"=",
"$",
"uri",
"->",
"getHost",
"(",
")",
";",
"$",
"scheme",
"=",
"$",
"uri",
"->",
"getScheme",
"(",
")",
";",
"$",
"netConnection",
"=",
"$",
"coreTool",
"->",
"isConnected",
"(",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"$",
"view",
"->",
"platformVersion",
"=",
"$",
"platformVersion",
"[",
"'version'",
"]",
";",
"$",
"view",
"->",
"modules",
"=",
"serialize",
"(",
"$",
"modules",
")",
";",
"$",
"view",
"->",
"scheme",
"=",
"$",
"scheme",
";",
"$",
"view",
"->",
"domain",
"=",
"$",
"domain",
";",
"$",
"view",
"->",
"netConn",
"=",
"$",
"netConnection",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the footer of the Melis Platform interface
@return \Zend\View\Model\ViewModel
|
[
"Shows",
"the",
"footer",
"of",
"the",
"Melis",
"Platform",
"interface"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L123-L147
|
27,265
|
melisplatform/melis-core
|
src/Controller/IndexController.php
|
IndexController.centerAction
|
public function centerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function centerAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"centerAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the center zone of the Melis Platform interface
@return \Zend\View\Model\ViewModel
|
[
"Shows",
"the",
"center",
"zone",
"of",
"the",
"Melis",
"Platform",
"interface"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L154-L162
|
27,266
|
melisplatform/melis-core
|
src/Controller/IndexController.php
|
IndexController.headerLanguageAction
|
public function headerLanguageAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function headerLanguageAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"headerLanguageAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the language select to change the language
@return \Zend\View\Model\ViewModel
|
[
"Shows",
"the",
"language",
"select",
"to",
"change",
"the",
"language"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L169-L176
|
27,267
|
melisplatform/melis-core
|
src/Controller/IndexController.php
|
IndexController.closeAllTabsAction
|
public function closeAllTabsAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
php
|
public function closeAllTabsAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
}
|
[
"public",
"function",
"closeAllTabsAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view",
"->",
"melisKey",
"=",
"$",
"melisKey",
";",
"return",
"$",
"view",
";",
"}"
] |
Shows the close button for closing of tabs
|
[
"Shows",
"the",
"close",
"button",
"for",
"closing",
"of",
"tabs"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/IndexController.php#L181-L188
|
27,268
|
ublaboo/mailing
|
src/MailLogger.php
|
MailLogger.log
|
public function log($type, Message $mail): void
{
$timestamp = date('Y-m-d H:i:s');
$type .= '.' . time();
$file = $this->getLogFile($type, $timestamp);
if (file_exists($file) && filesize($file)) {
$file = str_replace(
static::LOG_EXTENSION,
'.' . uniqid() . static::LOG_EXTENSION,
$file
);
}
file_put_contents($file, $mail->generateMessage());
}
|
php
|
public function log($type, Message $mail): void
{
$timestamp = date('Y-m-d H:i:s');
$type .= '.' . time();
$file = $this->getLogFile($type, $timestamp);
if (file_exists($file) && filesize($file)) {
$file = str_replace(
static::LOG_EXTENSION,
'.' . uniqid() . static::LOG_EXTENSION,
$file
);
}
file_put_contents($file, $mail->generateMessage());
}
|
[
"public",
"function",
"log",
"(",
"$",
"type",
",",
"Message",
"$",
"mail",
")",
":",
"void",
"{",
"$",
"timestamp",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"type",
".=",
"'.'",
".",
"time",
"(",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"getLogFile",
"(",
"$",
"type",
",",
"$",
"timestamp",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"filesize",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"str_replace",
"(",
"static",
"::",
"LOG_EXTENSION",
",",
"'.'",
".",
"uniqid",
"(",
")",
".",
"static",
"::",
"LOG_EXTENSION",
",",
"$",
"file",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"file",
",",
"$",
"mail",
"->",
"generateMessage",
"(",
")",
")",
";",
"}"
] |
Log mail messages to eml file
|
[
"Log",
"mail",
"messages",
"to",
"eml",
"file"
] |
1dc7751ceae2c5042f8017910c2c406ad8695740
|
https://github.com/ublaboo/mailing/blob/1dc7751ceae2c5042f8017910c2c406ad8695740/src/MailLogger.php#L35-L50
|
27,269
|
ublaboo/mailing
|
src/MailLogger.php
|
MailLogger.getLogFile
|
public function getLogFile(string $type, string $timestamp): string
{
preg_match('/^((([0-9]{4})-[0-9]{2})-[0-9]{2}).*/', $timestamp, $fragments);
$yearDir = $this->logDirectory . '/' . $fragments[3];
$monthDir = $yearDir . '/' . $fragments[2];
$dayDir = $monthDir . '/' . $fragments[1];
$file = $dayDir . '/' . $type . static::LOG_EXTENSION;
if (!file_exists($dayDir)) {
mkdir($dayDir, 0777, true);
}
if (!file_exists($file)) {
touch($file);
}
return $file;
}
|
php
|
public function getLogFile(string $type, string $timestamp): string
{
preg_match('/^((([0-9]{4})-[0-9]{2})-[0-9]{2}).*/', $timestamp, $fragments);
$yearDir = $this->logDirectory . '/' . $fragments[3];
$monthDir = $yearDir . '/' . $fragments[2];
$dayDir = $monthDir . '/' . $fragments[1];
$file = $dayDir . '/' . $type . static::LOG_EXTENSION;
if (!file_exists($dayDir)) {
mkdir($dayDir, 0777, true);
}
if (!file_exists($file)) {
touch($file);
}
return $file;
}
|
[
"public",
"function",
"getLogFile",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"timestamp",
")",
":",
"string",
"{",
"preg_match",
"(",
"'/^((([0-9]{4})-[0-9]{2})-[0-9]{2}).*/'",
",",
"$",
"timestamp",
",",
"$",
"fragments",
")",
";",
"$",
"yearDir",
"=",
"$",
"this",
"->",
"logDirectory",
".",
"'/'",
".",
"$",
"fragments",
"[",
"3",
"]",
";",
"$",
"monthDir",
"=",
"$",
"yearDir",
".",
"'/'",
".",
"$",
"fragments",
"[",
"2",
"]",
";",
"$",
"dayDir",
"=",
"$",
"monthDir",
".",
"'/'",
".",
"$",
"fragments",
"[",
"1",
"]",
";",
"$",
"file",
"=",
"$",
"dayDir",
".",
"'/'",
".",
"$",
"type",
".",
"static",
"::",
"LOG_EXTENSION",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dayDir",
")",
")",
"{",
"mkdir",
"(",
"$",
"dayDir",
",",
"0777",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"touch",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
If not already created, create a directory path that sticks to the standard described above
|
[
"If",
"not",
"already",
"created",
"create",
"a",
"directory",
"path",
"that",
"sticks",
"to",
"the",
"standard",
"described",
"above"
] |
1dc7751ceae2c5042f8017910c2c406ad8695740
|
https://github.com/ublaboo/mailing/blob/1dc7751ceae2c5042f8017910c2c406ad8695740/src/MailLogger.php#L56-L74
|
27,270
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Route/RouteManager.php
|
RouteManager.setupRoutes
|
public function setupRoutes()
{
$routes = $this->config();
if (PHP_SAPI == 'cli') {
$scripts = ( isset($routes['scripts']) ? $routes['scripts'] : [] );
foreach ($scripts as $scriptIdent => $scriptConfig) {
$this->setupScript($scriptIdent, $scriptConfig);
}
} else {
$templates = ( isset($routes['templates']) ? $routes['templates'] : [] );
foreach ($templates as $routeIdent => $templateConfig) {
$this->setupTemplate($routeIdent, $templateConfig);
}
$actions = ( isset($routes['actions']) ? $routes['actions'] : [] );
foreach ($actions as $actionIdent => $actionConfig) {
$this->setupAction($actionIdent, $actionConfig);
}
}
}
|
php
|
public function setupRoutes()
{
$routes = $this->config();
if (PHP_SAPI == 'cli') {
$scripts = ( isset($routes['scripts']) ? $routes['scripts'] : [] );
foreach ($scripts as $scriptIdent => $scriptConfig) {
$this->setupScript($scriptIdent, $scriptConfig);
}
} else {
$templates = ( isset($routes['templates']) ? $routes['templates'] : [] );
foreach ($templates as $routeIdent => $templateConfig) {
$this->setupTemplate($routeIdent, $templateConfig);
}
$actions = ( isset($routes['actions']) ? $routes['actions'] : [] );
foreach ($actions as $actionIdent => $actionConfig) {
$this->setupAction($actionIdent, $actionConfig);
}
}
}
|
[
"public",
"function",
"setupRoutes",
"(",
")",
"{",
"$",
"routes",
"=",
"$",
"this",
"->",
"config",
"(",
")",
";",
"if",
"(",
"PHP_SAPI",
"==",
"'cli'",
")",
"{",
"$",
"scripts",
"=",
"(",
"isset",
"(",
"$",
"routes",
"[",
"'scripts'",
"]",
")",
"?",
"$",
"routes",
"[",
"'scripts'",
"]",
":",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"scripts",
"as",
"$",
"scriptIdent",
"=>",
"$",
"scriptConfig",
")",
"{",
"$",
"this",
"->",
"setupScript",
"(",
"$",
"scriptIdent",
",",
"$",
"scriptConfig",
")",
";",
"}",
"}",
"else",
"{",
"$",
"templates",
"=",
"(",
"isset",
"(",
"$",
"routes",
"[",
"'templates'",
"]",
")",
"?",
"$",
"routes",
"[",
"'templates'",
"]",
":",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"templates",
"as",
"$",
"routeIdent",
"=>",
"$",
"templateConfig",
")",
"{",
"$",
"this",
"->",
"setupTemplate",
"(",
"$",
"routeIdent",
",",
"$",
"templateConfig",
")",
";",
"}",
"$",
"actions",
"=",
"(",
"isset",
"(",
"$",
"routes",
"[",
"'actions'",
"]",
")",
"?",
"$",
"routes",
"[",
"'actions'",
"]",
":",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"actionIdent",
"=>",
"$",
"actionConfig",
")",
"{",
"$",
"this",
"->",
"setupAction",
"(",
"$",
"actionIdent",
",",
"$",
"actionConfig",
")",
";",
"}",
"}",
"}"
] |
Set up the routes.
There are 3 types of routes:
- Templates
- Actions
- Scripts
@return void
|
[
"Set",
"up",
"the",
"routes",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L48-L68
|
27,271
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Route/RouteManager.php
|
RouteManager.setupTemplate
|
private function setupTemplate($routeIdent, $templateConfig)
{
$routePattern = isset($templateConfig['route'])
? $templateConfig['route']
: '/'.ltrim($routeIdent, '/');
$templateConfig['route'] = $routePattern;
$methods = isset($templateConfig['methods'])
? $templateConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$templateConfig
) {
if (!isset($templateConfig['ident'])) {
$templateConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded template route: %s', $templateConfig['ident']),
$templateConfig
);
if (!isset($templateConfig['template_data'])) {
$templateConfig['template_data'] = [];
}
if (count($args)) {
$templateConfig['template_data'] = array_merge(
$templateConfig['template_data'],
$args
);
}
$defaultController = $this['route/controller/template/class'];
$routeController = isset($templateConfig['route_controller'])
? $templateConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $templateConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($templateConfig['ident'])) {
$routeHandler->setName($templateConfig['ident']);
}
return $routeHandler;
}
|
php
|
private function setupTemplate($routeIdent, $templateConfig)
{
$routePattern = isset($templateConfig['route'])
? $templateConfig['route']
: '/'.ltrim($routeIdent, '/');
$templateConfig['route'] = $routePattern;
$methods = isset($templateConfig['methods'])
? $templateConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$templateConfig
) {
if (!isset($templateConfig['ident'])) {
$templateConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded template route: %s', $templateConfig['ident']),
$templateConfig
);
if (!isset($templateConfig['template_data'])) {
$templateConfig['template_data'] = [];
}
if (count($args)) {
$templateConfig['template_data'] = array_merge(
$templateConfig['template_data'],
$args
);
}
$defaultController = $this['route/controller/template/class'];
$routeController = isset($templateConfig['route_controller'])
? $templateConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $templateConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($templateConfig['ident'])) {
$routeHandler->setName($templateConfig['ident']);
}
return $routeHandler;
}
|
[
"private",
"function",
"setupTemplate",
"(",
"$",
"routeIdent",
",",
"$",
"templateConfig",
")",
"{",
"$",
"routePattern",
"=",
"isset",
"(",
"$",
"templateConfig",
"[",
"'route'",
"]",
")",
"?",
"$",
"templateConfig",
"[",
"'route'",
"]",
":",
"'/'",
".",
"ltrim",
"(",
"$",
"routeIdent",
",",
"'/'",
")",
";",
"$",
"templateConfig",
"[",
"'route'",
"]",
"=",
"$",
"routePattern",
";",
"$",
"methods",
"=",
"isset",
"(",
"$",
"templateConfig",
"[",
"'methods'",
"]",
")",
"?",
"$",
"templateConfig",
"[",
"'methods'",
"]",
":",
"[",
"'GET'",
"]",
";",
"$",
"routeHandler",
"=",
"$",
"this",
"->",
"app",
"->",
"map",
"(",
"$",
"methods",
",",
"$",
"routePattern",
",",
"function",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"use",
"(",
"$",
"routeIdent",
",",
"$",
"templateConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"templateConfig",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"templateConfig",
"[",
"'ident'",
"]",
"=",
"ltrim",
"(",
"$",
"routeIdent",
",",
"'/'",
")",
";",
"}",
"$",
"this",
"[",
"'logger'",
"]",
"->",
"debug",
"(",
"sprintf",
"(",
"'Loaded template route: %s'",
",",
"$",
"templateConfig",
"[",
"'ident'",
"]",
")",
",",
"$",
"templateConfig",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"templateConfig",
"[",
"'template_data'",
"]",
")",
")",
"{",
"$",
"templateConfig",
"[",
"'template_data'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"templateConfig",
"[",
"'template_data'",
"]",
"=",
"array_merge",
"(",
"$",
"templateConfig",
"[",
"'template_data'",
"]",
",",
"$",
"args",
")",
";",
"}",
"$",
"defaultController",
"=",
"$",
"this",
"[",
"'route/controller/template/class'",
"]",
";",
"$",
"routeController",
"=",
"isset",
"(",
"$",
"templateConfig",
"[",
"'route_controller'",
"]",
")",
"?",
"$",
"templateConfig",
"[",
"'route_controller'",
"]",
":",
"$",
"defaultController",
";",
"$",
"routeFactory",
"=",
"$",
"this",
"[",
"'route/factory'",
"]",
";",
"$",
"routeFactory",
"->",
"setDefaultClass",
"(",
"$",
"defaultController",
")",
";",
"$",
"route",
"=",
"$",
"routeFactory",
"->",
"create",
"(",
"$",
"routeController",
",",
"[",
"'config'",
"=>",
"$",
"templateConfig",
",",
"'logger'",
"=>",
"$",
"this",
"[",
"'logger'",
"]",
"]",
")",
";",
"return",
"$",
"route",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"templateConfig",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"routeHandler",
"->",
"setName",
"(",
"$",
"templateConfig",
"[",
"'ident'",
"]",
")",
";",
"}",
"return",
"$",
"routeHandler",
";",
"}"
] |
Add template route.
Typically for a GET request, the route will render a template.
@param string $routeIdent The template's route identifier.
@param array|\ArrayAccess $templateConfig The template's config for the route.
@return \Slim\Interfaces\RouteInterface
|
[
"Add",
"template",
"route",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L79-L144
|
27,272
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Route/RouteManager.php
|
RouteManager.setupAction
|
private function setupAction($routeIdent, $actionConfig)
{
$routePattern = isset($actionConfig['route'])
? $actionConfig['route']
: '/'.ltrim($routeIdent, '/');
$actionConfig['route'] = $routePattern;
$methods = isset($actionConfig['methods'])
? $actionConfig['methods']
: [ 'POST' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$actionConfig
) {
if (!isset($actionConfig['ident'])) {
$actionConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded action route: %s', $actionConfig['ident']),
$actionConfig
);
if (!isset($actionConfig['action_data'])) {
$actionConfig['action_data'] = [];
}
if (count($args)) {
$actionConfig['action_data'] = array_merge(
$actionConfig['action_data'],
$args
);
}
$defaultController = $this['route/controller/action/class'];
$routeController = isset($actionConfig['route_controller'])
? $actionConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $actionConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($actionConfig['ident'])) {
$routeHandler->setName($actionConfig['ident']);
}
return $routeHandler;
}
|
php
|
private function setupAction($routeIdent, $actionConfig)
{
$routePattern = isset($actionConfig['route'])
? $actionConfig['route']
: '/'.ltrim($routeIdent, '/');
$actionConfig['route'] = $routePattern;
$methods = isset($actionConfig['methods'])
? $actionConfig['methods']
: [ 'POST' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$actionConfig
) {
if (!isset($actionConfig['ident'])) {
$actionConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded action route: %s', $actionConfig['ident']),
$actionConfig
);
if (!isset($actionConfig['action_data'])) {
$actionConfig['action_data'] = [];
}
if (count($args)) {
$actionConfig['action_data'] = array_merge(
$actionConfig['action_data'],
$args
);
}
$defaultController = $this['route/controller/action/class'];
$routeController = isset($actionConfig['route_controller'])
? $actionConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $actionConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($actionConfig['ident'])) {
$routeHandler->setName($actionConfig['ident']);
}
return $routeHandler;
}
|
[
"private",
"function",
"setupAction",
"(",
"$",
"routeIdent",
",",
"$",
"actionConfig",
")",
"{",
"$",
"routePattern",
"=",
"isset",
"(",
"$",
"actionConfig",
"[",
"'route'",
"]",
")",
"?",
"$",
"actionConfig",
"[",
"'route'",
"]",
":",
"'/'",
".",
"ltrim",
"(",
"$",
"routeIdent",
",",
"'/'",
")",
";",
"$",
"actionConfig",
"[",
"'route'",
"]",
"=",
"$",
"routePattern",
";",
"$",
"methods",
"=",
"isset",
"(",
"$",
"actionConfig",
"[",
"'methods'",
"]",
")",
"?",
"$",
"actionConfig",
"[",
"'methods'",
"]",
":",
"[",
"'POST'",
"]",
";",
"$",
"routeHandler",
"=",
"$",
"this",
"->",
"app",
"->",
"map",
"(",
"$",
"methods",
",",
"$",
"routePattern",
",",
"function",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"use",
"(",
"$",
"routeIdent",
",",
"$",
"actionConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"actionConfig",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"actionConfig",
"[",
"'ident'",
"]",
"=",
"ltrim",
"(",
"$",
"routeIdent",
",",
"'/'",
")",
";",
"}",
"$",
"this",
"[",
"'logger'",
"]",
"->",
"debug",
"(",
"sprintf",
"(",
"'Loaded action route: %s'",
",",
"$",
"actionConfig",
"[",
"'ident'",
"]",
")",
",",
"$",
"actionConfig",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"actionConfig",
"[",
"'action_data'",
"]",
")",
")",
"{",
"$",
"actionConfig",
"[",
"'action_data'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"actionConfig",
"[",
"'action_data'",
"]",
"=",
"array_merge",
"(",
"$",
"actionConfig",
"[",
"'action_data'",
"]",
",",
"$",
"args",
")",
";",
"}",
"$",
"defaultController",
"=",
"$",
"this",
"[",
"'route/controller/action/class'",
"]",
";",
"$",
"routeController",
"=",
"isset",
"(",
"$",
"actionConfig",
"[",
"'route_controller'",
"]",
")",
"?",
"$",
"actionConfig",
"[",
"'route_controller'",
"]",
":",
"$",
"defaultController",
";",
"$",
"routeFactory",
"=",
"$",
"this",
"[",
"'route/factory'",
"]",
";",
"$",
"routeFactory",
"->",
"setDefaultClass",
"(",
"$",
"defaultController",
")",
";",
"$",
"route",
"=",
"$",
"routeFactory",
"->",
"create",
"(",
"$",
"routeController",
",",
"[",
"'config'",
"=>",
"$",
"actionConfig",
",",
"'logger'",
"=>",
"$",
"this",
"[",
"'logger'",
"]",
"]",
")",
";",
"return",
"$",
"route",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"actionConfig",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"routeHandler",
"->",
"setName",
"(",
"$",
"actionConfig",
"[",
"'ident'",
"]",
")",
";",
"}",
"return",
"$",
"routeHandler",
";",
"}"
] |
Add action route.
Typically for a POST request, the route will execute an action (returns JSON).
@param string $routeIdent The action's route identifier.
@param array|\ArrayAccess $actionConfig The action's config for the route.
@return \Slim\Interfaces\RouteInterface
|
[
"Add",
"action",
"route",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L155-L220
|
27,273
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Route/RouteManager.php
|
RouteManager.setupScript
|
private function setupScript($routeIdent, $scriptConfig)
{
$routePattern = isset($scriptConfig['route'])
? $scriptConfig['route']
: '/'.ltrim($routeIdent, '/');
$scriptConfig['route'] = $routePattern;
$methods = isset($scriptConfig['methods'])
? $scriptConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$scriptConfig
) {
if (!isset($scriptConfig['ident'])) {
$scriptConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded script route: %s', $scriptConfig['ident']),
$scriptConfig
);
if (!isset($scriptConfig['script_data'])) {
$scriptConfig['script_data'] = [];
}
if (count($args)) {
$scriptConfig['script_data'] = array_merge(
$scriptConfig['script_data'],
$args
);
}
$defaultController = $this['route/controller/script/class'];
$routeController = isset($scriptConfig['route_controller'])
? $scriptConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $scriptConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($scriptConfig['ident'])) {
$routeHandler->setName($scriptConfig['ident']);
}
return $routeHandler;
}
|
php
|
private function setupScript($routeIdent, $scriptConfig)
{
$routePattern = isset($scriptConfig['route'])
? $scriptConfig['route']
: '/'.ltrim($routeIdent, '/');
$scriptConfig['route'] = $routePattern;
$methods = isset($scriptConfig['methods'])
? $scriptConfig['methods']
: [ 'GET' ];
$routeHandler = $this->app->map(
$methods,
$routePattern,
function (
RequestInterface $request,
ResponseInterface $response,
array $args = []
) use (
$routeIdent,
$scriptConfig
) {
if (!isset($scriptConfig['ident'])) {
$scriptConfig['ident'] = ltrim($routeIdent, '/');
}
$this['logger']->debug(
sprintf('Loaded script route: %s', $scriptConfig['ident']),
$scriptConfig
);
if (!isset($scriptConfig['script_data'])) {
$scriptConfig['script_data'] = [];
}
if (count($args)) {
$scriptConfig['script_data'] = array_merge(
$scriptConfig['script_data'],
$args
);
}
$defaultController = $this['route/controller/script/class'];
$routeController = isset($scriptConfig['route_controller'])
? $scriptConfig['route_controller']
: $defaultController;
$routeFactory = $this['route/factory'];
$routeFactory->setDefaultClass($defaultController);
$route = $routeFactory->create($routeController, [
'config' => $scriptConfig,
'logger' => $this['logger']
]);
return $route($this, $request, $response);
}
);
if (isset($scriptConfig['ident'])) {
$routeHandler->setName($scriptConfig['ident']);
}
return $routeHandler;
}
|
[
"private",
"function",
"setupScript",
"(",
"$",
"routeIdent",
",",
"$",
"scriptConfig",
")",
"{",
"$",
"routePattern",
"=",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'route'",
"]",
")",
"?",
"$",
"scriptConfig",
"[",
"'route'",
"]",
":",
"'/'",
".",
"ltrim",
"(",
"$",
"routeIdent",
",",
"'/'",
")",
";",
"$",
"scriptConfig",
"[",
"'route'",
"]",
"=",
"$",
"routePattern",
";",
"$",
"methods",
"=",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'methods'",
"]",
")",
"?",
"$",
"scriptConfig",
"[",
"'methods'",
"]",
":",
"[",
"'GET'",
"]",
";",
"$",
"routeHandler",
"=",
"$",
"this",
"->",
"app",
"->",
"map",
"(",
"$",
"methods",
",",
"$",
"routePattern",
",",
"function",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"use",
"(",
"$",
"routeIdent",
",",
"$",
"scriptConfig",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"scriptConfig",
"[",
"'ident'",
"]",
"=",
"ltrim",
"(",
"$",
"routeIdent",
",",
"'/'",
")",
";",
"}",
"$",
"this",
"[",
"'logger'",
"]",
"->",
"debug",
"(",
"sprintf",
"(",
"'Loaded script route: %s'",
",",
"$",
"scriptConfig",
"[",
"'ident'",
"]",
")",
",",
"$",
"scriptConfig",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'script_data'",
"]",
")",
")",
"{",
"$",
"scriptConfig",
"[",
"'script_data'",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"scriptConfig",
"[",
"'script_data'",
"]",
"=",
"array_merge",
"(",
"$",
"scriptConfig",
"[",
"'script_data'",
"]",
",",
"$",
"args",
")",
";",
"}",
"$",
"defaultController",
"=",
"$",
"this",
"[",
"'route/controller/script/class'",
"]",
";",
"$",
"routeController",
"=",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'route_controller'",
"]",
")",
"?",
"$",
"scriptConfig",
"[",
"'route_controller'",
"]",
":",
"$",
"defaultController",
";",
"$",
"routeFactory",
"=",
"$",
"this",
"[",
"'route/factory'",
"]",
";",
"$",
"routeFactory",
"->",
"setDefaultClass",
"(",
"$",
"defaultController",
")",
";",
"$",
"route",
"=",
"$",
"routeFactory",
"->",
"create",
"(",
"$",
"routeController",
",",
"[",
"'config'",
"=>",
"$",
"scriptConfig",
",",
"'logger'",
"=>",
"$",
"this",
"[",
"'logger'",
"]",
"]",
")",
";",
"return",
"$",
"route",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"scriptConfig",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"routeHandler",
"->",
"setName",
"(",
"$",
"scriptConfig",
"[",
"'ident'",
"]",
")",
";",
"}",
"return",
"$",
"routeHandler",
";",
"}"
] |
Add script route.
Typically used for a CLI interface, the route will execute a script.
@param string $routeIdent The script's route identifier.
@param array|\ArrayAccess $scriptConfig The script's config for the route.
@return \Slim\Interfaces\RouteInterface
|
[
"Add",
"script",
"route",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteManager.php#L231-L296
|
27,274
|
melisplatform/melis-core
|
src/Service/MelisCoreConfigService.php
|
MelisCoreConfigService.setFormFieldRequired
|
public function setFormFieldRequired($array, $fieldName, $isRequired = false)
{
if (!empty($array['input_filter'])) {
foreach ($array['input_filter'] as $keyElement => $element) {
if ($keyElement == $fieldName) {
$array['input_filter'][$keyElement]['required'] = $isRequired;
}
}
}
return $array;
}
|
php
|
public function setFormFieldRequired($array, $fieldName, $isRequired = false)
{
if (!empty($array['input_filter'])) {
foreach ($array['input_filter'] as $keyElement => $element) {
if ($keyElement == $fieldName) {
$array['input_filter'][$keyElement]['required'] = $isRequired;
}
}
}
return $array;
}
|
[
"public",
"function",
"setFormFieldRequired",
"(",
"$",
"array",
",",
"$",
"fieldName",
",",
"$",
"isRequired",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
"[",
"'input_filter'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"array",
"[",
"'input_filter'",
"]",
"as",
"$",
"keyElement",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"keyElement",
"==",
"$",
"fieldName",
")",
"{",
"$",
"array",
"[",
"'input_filter'",
"]",
"[",
"$",
"keyElement",
"]",
"[",
"'required'",
"]",
"=",
"$",
"isRequired",
";",
"}",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Set a required field in input filters from the the config form array
@param array $array
@param string $fieldName
@param boolean $isRequired
@return array
|
[
"Set",
"a",
"required",
"field",
"in",
"input",
"filters",
"from",
"the",
"the",
"config",
"form",
"array"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreConfigService.php#L69-L80
|
27,275
|
orchestral/kernel
|
src/Http/Concerns/Transformable.php
|
Transformable.options
|
public function options(array $options = [])
{
$this->options = $options;
foreach ($this->meta as $name) {
$this->filterMetaType($name);
}
return $this;
}
|
php
|
public function options(array $options = [])
{
$this->options = $options;
foreach ($this->meta as $name) {
$this->filterMetaType($name);
}
return $this;
}
|
[
"public",
"function",
"options",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"foreach",
"(",
"$",
"this",
"->",
"meta",
"as",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"filterMetaType",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add options.
@param array $options
@return $this
|
[
"Add",
"options",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L38-L47
|
27,276
|
orchestral/kernel
|
src/Http/Concerns/Transformable.php
|
Transformable.getRequest
|
public function getRequest()
{
if (is_null($this->request)) {
$this->setRequest(app()->refresh('request', $this, 'setRequest'));
}
return $this->request;
}
|
php
|
public function getRequest()
{
if (is_null($this->request)) {
$this->setRequest(app()->refresh('request', $this, 'setRequest'));
}
return $this->request;
}
|
[
"public",
"function",
"getRequest",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"request",
")",
")",
"{",
"$",
"this",
"->",
"setRequest",
"(",
"app",
"(",
")",
"->",
"refresh",
"(",
"'request'",
",",
"$",
"this",
",",
"'setRequest'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"request",
";",
"}"
] |
Get request instance.
@return \Illuminate\Http\Request
|
[
"Get",
"request",
"instance",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L54-L61
|
27,277
|
orchestral/kernel
|
src/Http/Concerns/Transformable.php
|
Transformable.merge
|
protected function merge($meta, array $options = []): array
{
if (is_array($meta) && empty($options)) {
$options = $meta;
$meta = null;
}
$options = array_merge(['includes' => [], 'excludes' => []], $options);
foreach ($options as $key => $value) {
$filtered = Arr::expand(array_flip($value));
$parent = Arr::get($this->options, is_null($meta) ? $key : "{$key}.{$meta}", []);
$options[$key] = array_keys(Arr::dot(array_merge_recursive($filtered, $parent)));
}
return $options;
}
|
php
|
protected function merge($meta, array $options = []): array
{
if (is_array($meta) && empty($options)) {
$options = $meta;
$meta = null;
}
$options = array_merge(['includes' => [], 'excludes' => []], $options);
foreach ($options as $key => $value) {
$filtered = Arr::expand(array_flip($value));
$parent = Arr::get($this->options, is_null($meta) ? $key : "{$key}.{$meta}", []);
$options[$key] = array_keys(Arr::dot(array_merge_recursive($filtered, $parent)));
}
return $options;
}
|
[
"protected",
"function",
"merge",
"(",
"$",
"meta",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"is_array",
"(",
"$",
"meta",
")",
"&&",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"options",
"=",
"$",
"meta",
";",
"$",
"meta",
"=",
"null",
";",
"}",
"$",
"options",
"=",
"array_merge",
"(",
"[",
"'includes'",
"=>",
"[",
"]",
",",
"'excludes'",
"=>",
"[",
"]",
"]",
",",
"$",
"options",
")",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"filtered",
"=",
"Arr",
"::",
"expand",
"(",
"array_flip",
"(",
"$",
"value",
")",
")",
";",
"$",
"parent",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"options",
",",
"is_null",
"(",
"$",
"meta",
")",
"?",
"$",
"key",
":",
"\"{$key}.{$meta}\"",
",",
"[",
"]",
")",
";",
"$",
"options",
"[",
"$",
"key",
"]",
"=",
"array_keys",
"(",
"Arr",
"::",
"dot",
"(",
"array_merge_recursive",
"(",
"$",
"filtered",
",",
"$",
"parent",
")",
")",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] |
Merge meta options.
@param string|array $meta
@param array $options
@return array
|
[
"Merge",
"meta",
"options",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L85-L102
|
27,278
|
orchestral/kernel
|
src/Http/Concerns/Transformable.php
|
Transformable.transformByMeta
|
protected function transformByMeta(string $meta, array $data, ...$parameters): array
{
$name = Str::singular($meta);
$types = $this->options[$meta];
if (empty($types)) {
return $data;
}
foreach ($types as $type => $index) {
if (is_array($type)) {
continue;
}
$method = $name.Str::studly($type);
if (method_exists($this, $method)) {
$data = $this->{$method}($data, ...$parameters);
}
}
return $data;
}
|
php
|
protected function transformByMeta(string $meta, array $data, ...$parameters): array
{
$name = Str::singular($meta);
$types = $this->options[$meta];
if (empty($types)) {
return $data;
}
foreach ($types as $type => $index) {
if (is_array($type)) {
continue;
}
$method = $name.Str::studly($type);
if (method_exists($this, $method)) {
$data = $this->{$method}($data, ...$parameters);
}
}
return $data;
}
|
[
"protected",
"function",
"transformByMeta",
"(",
"string",
"$",
"meta",
",",
"array",
"$",
"data",
",",
"...",
"$",
"parameters",
")",
":",
"array",
"{",
"$",
"name",
"=",
"Str",
"::",
"singular",
"(",
"$",
"meta",
")",
";",
"$",
"types",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"meta",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"types",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
"=>",
"$",
"index",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"type",
")",
")",
"{",
"continue",
";",
"}",
"$",
"method",
"=",
"$",
"name",
".",
"Str",
"::",
"studly",
"(",
"$",
"type",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"data",
",",
"...",
"$",
"parameters",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Resolve includes for transformer.
@param string $group
@param array $data
@param mixed $parameters
@return array
|
[
"Resolve",
"includes",
"for",
"transformer",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L113-L135
|
27,279
|
orchestral/kernel
|
src/Http/Concerns/Transformable.php
|
Transformable.filterMetaType
|
protected function filterMetaType(string $name): void
{
$types = $this->options[$name] ?? $this->getRequest()->input($name);
if (is_string($types)) {
$types = explode(',', $types);
}
$this->options[$name] = is_array($types) ? Arr::expand(array_flip($types)) : [];
}
|
php
|
protected function filterMetaType(string $name): void
{
$types = $this->options[$name] ?? $this->getRequest()->input($name);
if (is_string($types)) {
$types = explode(',', $types);
}
$this->options[$name] = is_array($types) ? Arr::expand(array_flip($types)) : [];
}
|
[
"protected",
"function",
"filterMetaType",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"??",
"$",
"this",
"->",
"getRequest",
"(",
")",
"->",
"input",
"(",
"$",
"name",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"{",
"$",
"types",
"=",
"explode",
"(",
"','",
",",
"$",
"types",
")",
";",
"}",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
"=",
"is_array",
"(",
"$",
"types",
")",
"?",
"Arr",
"::",
"expand",
"(",
"array_flip",
"(",
"$",
"types",
")",
")",
":",
"[",
"]",
";",
"}"
] |
Get option by group.
@param string $name
@return void
|
[
"Get",
"option",
"by",
"group",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Concerns/Transformable.php#L144-L153
|
27,280
|
melisplatform/melis-core
|
public/js/filemanager/include/php_image_magician.php
|
imageLib.gd_filter_monopin
|
public function gd_filter_monopin()
{
if ($this->imageResized)
{
imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100);
}
}
|
php
|
public function gd_filter_monopin()
{
if ($this->imageResized)
{
imagefilter($this->imageResized, IMG_FILTER_GRAYSCALE);
imagefilter($this->imageResized, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($this->imageResized, IMG_FILTER_CONTRAST, -15);
$this->imageResized = $this->gd_apply_overlay($this->imageResized, 'vignette', 100);
}
}
|
[
"public",
"function",
"gd_filter_monopin",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageResized",
")",
"{",
"imagefilter",
"(",
"$",
"this",
"->",
"imageResized",
",",
"IMG_FILTER_GRAYSCALE",
")",
";",
"imagefilter",
"(",
"$",
"this",
"->",
"imageResized",
",",
"IMG_FILTER_BRIGHTNESS",
",",
"-",
"15",
")",
";",
"imagefilter",
"(",
"$",
"this",
"->",
"imageResized",
",",
"IMG_FILTER_CONTRAST",
",",
"-",
"15",
")",
";",
"$",
"this",
"->",
"imageResized",
"=",
"$",
"this",
"->",
"gd_apply_overlay",
"(",
"$",
"this",
"->",
"imageResized",
",",
"'vignette'",
",",
"100",
")",
";",
"}",
"}"
] |
Apply 'Monopin' preset
|
[
"Apply",
"Monopin",
"preset"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/php_image_magician.php#L1201-L1211
|
27,281
|
melisplatform/melis-core
|
public/js/filemanager/include/php_image_magician.php
|
imageLib.gd_apply_overlay
|
private function gd_apply_overlay($im, $type, $amount)
#
# Original Author: Marc Hibbins
# License: Attribution-ShareAlike 3.0
# Purpose:
# Params in:
# Params out:
# Notes:
#
{
$width = imagesx($im);
$height = imagesy($im);
$filter = imagecreatetruecolor($width, $height);
imagealphablending($filter, false);
imagesavealpha($filter, true);
$transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127);
imagefilledrectangle($filter, 0, 0, $width, $height, $transparent);
// *** Resize overlay
$overlay = $this->filterOverlayPath . '/' . $type . '.png';
$png = imagecreatefrompng($overlay);
imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png));
$comp = imagecreatetruecolor($width, $height);
imagecopy($comp, $im, 0, 0, 0, 0, $width, $height);
imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height);
imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($comp);
return $im;
}
|
php
|
private function gd_apply_overlay($im, $type, $amount)
#
# Original Author: Marc Hibbins
# License: Attribution-ShareAlike 3.0
# Purpose:
# Params in:
# Params out:
# Notes:
#
{
$width = imagesx($im);
$height = imagesy($im);
$filter = imagecreatetruecolor($width, $height);
imagealphablending($filter, false);
imagesavealpha($filter, true);
$transparent = imagecolorallocatealpha($filter, 255, 255, 255, 127);
imagefilledrectangle($filter, 0, 0, $width, $height, $transparent);
// *** Resize overlay
$overlay = $this->filterOverlayPath . '/' . $type . '.png';
$png = imagecreatefrompng($overlay);
imagecopyresampled($filter, $png, 0, 0, 0, 0, $width, $height, imagesx($png), imagesy($png));
$comp = imagecreatetruecolor($width, $height);
imagecopy($comp, $im, 0, 0, 0, 0, $width, $height);
imagecopy($comp, $filter, 0, 0, 0, 0, $width, $height);
imagecopymerge($im, $comp, 0, 0, 0, 0, $width, $height, $amount);
imagedestroy($comp);
return $im;
}
|
[
"private",
"function",
"gd_apply_overlay",
"(",
"$",
"im",
",",
"$",
"type",
",",
"$",
"amount",
")",
"#",
"# Original Author: Marc Hibbins",
"# License: Attribution-ShareAlike 3.0",
"# Purpose:",
"# Params in:",
"# Params out:",
"# Notes:",
"#",
"{",
"$",
"width",
"=",
"imagesx",
"(",
"$",
"im",
")",
";",
"$",
"height",
"=",
"imagesy",
"(",
"$",
"im",
")",
";",
"$",
"filter",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagealphablending",
"(",
"$",
"filter",
",",
"false",
")",
";",
"imagesavealpha",
"(",
"$",
"filter",
",",
"true",
")",
";",
"$",
"transparent",
"=",
"imagecolorallocatealpha",
"(",
"$",
"filter",
",",
"255",
",",
"255",
",",
"255",
",",
"127",
")",
";",
"imagefilledrectangle",
"(",
"$",
"filter",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"transparent",
")",
";",
"// *** Resize overlay",
"$",
"overlay",
"=",
"$",
"this",
"->",
"filterOverlayPath",
".",
"'/'",
".",
"$",
"type",
".",
"'.png'",
";",
"$",
"png",
"=",
"imagecreatefrompng",
"(",
"$",
"overlay",
")",
";",
"imagecopyresampled",
"(",
"$",
"filter",
",",
"$",
"png",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"imagesx",
"(",
"$",
"png",
")",
",",
"imagesy",
"(",
"$",
"png",
")",
")",
";",
"$",
"comp",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagecopy",
"(",
"$",
"comp",
",",
"$",
"im",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagecopy",
"(",
"$",
"comp",
",",
"$",
"filter",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagecopymerge",
"(",
"$",
"im",
",",
"$",
"comp",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"amount",
")",
";",
"imagedestroy",
"(",
"$",
"comp",
")",
";",
"return",
"$",
"im",
";",
"}"
] |
Apply a PNG overlay
|
[
"Apply",
"a",
"PNG",
"overlay"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/public/js/filemanager/include/php_image_magician.php#L1231-L1264
|
27,282
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/AppConfig.php
|
AppConfig.setBasePath
|
public function setBasePath($path)
{
if ($path === null) {
throw new InvalidArgumentException(
'The base path is required.'
);
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The base path must be a string'
);
}
$this->basePath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
}
|
php
|
public function setBasePath($path)
{
if ($path === null) {
throw new InvalidArgumentException(
'The base path is required.'
);
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The base path must be a string'
);
}
$this->basePath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
}
|
[
"public",
"function",
"setBasePath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The base path is required.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The base path must be a string'",
")",
";",
"}",
"$",
"this",
"->",
"basePath",
"=",
"rtrim",
"(",
"realpath",
"(",
"$",
"path",
")",
",",
"'\\\\/'",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the application's absolute root path.
Resolves symlinks with realpath() and ensure trailing slash.
@param string $path The absolute path to the application's root directory.
@throws InvalidArgumentException If the argument is not a string.
@return self
|
[
"Set",
"the",
"application",
"s",
"absolute",
"root",
"path",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L188-L204
|
27,283
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/AppConfig.php
|
AppConfig.setPublicPath
|
public function setPublicPath($path)
{
if ($path === null) {
$this->publicPath = null;
return $this;
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The public path must be a string'
);
}
$this->publicPath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
}
|
php
|
public function setPublicPath($path)
{
if ($path === null) {
$this->publicPath = null;
return $this;
}
if (!is_string($path)) {
throw new InvalidArgumentException(
'The public path must be a string'
);
}
$this->publicPath = rtrim(realpath($path), '\\/').DIRECTORY_SEPARATOR;
return $this;
}
|
[
"public",
"function",
"setPublicPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"publicPath",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The public path must be a string'",
")",
";",
"}",
"$",
"this",
"->",
"publicPath",
"=",
"rtrim",
"(",
"realpath",
"(",
"$",
"path",
")",
",",
"'\\\\/'",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the application's absolute path to the public web directory.
@param string $path The path to the application's public directory.
@throws InvalidArgumentException If the argument is not a string.
@return self
|
[
"Set",
"the",
"application",
"s",
"absolute",
"path",
"to",
"the",
"public",
"web",
"directory",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L223-L238
|
27,284
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/AppConfig.php
|
AppConfig.publicPath
|
public function publicPath()
{
if (!isset($this->publicPath)) {
$this->publicPath = $this->basePath().'www'.DIRECTORY_SEPARATOR;
}
return $this->publicPath;
}
|
php
|
public function publicPath()
{
if (!isset($this->publicPath)) {
$this->publicPath = $this->basePath().'www'.DIRECTORY_SEPARATOR;
}
return $this->publicPath;
}
|
[
"public",
"function",
"publicPath",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"publicPath",
")",
")",
"{",
"$",
"this",
"->",
"publicPath",
"=",
"$",
"this",
"->",
"basePath",
"(",
")",
".",
"'www'",
".",
"DIRECTORY_SEPARATOR",
";",
"}",
"return",
"$",
"this",
"->",
"publicPath",
";",
"}"
] |
Retrieve the application's absolute path to the public web directory.
@return string The absolute path to the application's public directory.
|
[
"Retrieve",
"the",
"application",
"s",
"absolute",
"path",
"to",
"the",
"public",
"web",
"directory",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L245-L252
|
27,285
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/AppConfig.php
|
AppConfig.setBaseUrl
|
public function setBaseUrl($uri)
{
if (is_string($uri)) {
$this->baseUrl = Uri::createFromString($uri);
} else {
$this->baseUrl = $uri;
}
return $this;
}
|
php
|
public function setBaseUrl($uri)
{
if (is_string($uri)) {
$this->baseUrl = Uri::createFromString($uri);
} else {
$this->baseUrl = $uri;
}
return $this;
}
|
[
"public",
"function",
"setBaseUrl",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"this",
"->",
"baseUrl",
"=",
"Uri",
"::",
"createFromString",
"(",
"$",
"uri",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"baseUrl",
"=",
"$",
"uri",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the application's fully qualified base URL to the public web directory.
@param UriInterface|string $uri The base URI to the application's web directory.
@return self
|
[
"Set",
"the",
"application",
"s",
"fully",
"qualified",
"base",
"URL",
"to",
"the",
"public",
"web",
"directory",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L260-L268
|
27,286
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/AppConfig.php
|
AppConfig.setProjectName
|
public function setProjectName($projectName)
{
if ($projectName === null) {
$this->projectName = null;
return $this;
}
if (!is_string($projectName)) {
throw new InvalidArgumentException(
'Project name must be a string'
);
}
$this->projectName = $projectName;
return $this;
}
|
php
|
public function setProjectName($projectName)
{
if ($projectName === null) {
$this->projectName = null;
return $this;
}
if (!is_string($projectName)) {
throw new InvalidArgumentException(
'Project name must be a string'
);
}
$this->projectName = $projectName;
return $this;
}
|
[
"public",
"function",
"setProjectName",
"(",
"$",
"projectName",
")",
"{",
"if",
"(",
"$",
"projectName",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"projectName",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"projectName",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Project name must be a string'",
")",
";",
"}",
"$",
"this",
"->",
"projectName",
"=",
"$",
"projectName",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the project name.
@param string|null $projectName The project name.
@throws InvalidArgumentException If the project argument is not a string (or null).
@return self
|
[
"Sets",
"the",
"project",
"name",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/AppConfig.php#L322-L336
|
27,287
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Route/RouteConfig.php
|
RouteConfig.setHeaders
|
public function setHeaders(array $headers)
{
$this->headers = [];
foreach ($headers as $name => $val) {
$this->addHeader($name, $val);
}
return $this;
}
|
php
|
public function setHeaders(array $headers)
{
$this->headers = [];
foreach ($headers as $name => $val) {
$this->addHeader($name, $val);
}
return $this;
}
|
[
"public",
"function",
"setHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"this",
"->",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"addHeader",
"(",
"$",
"name",
",",
"$",
"val",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add custom headers
@param array $headers The custom headers, in key=>val pairs.
@return self
|
[
"Add",
"custom",
"headers"
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteConfig.php#L186-L193
|
27,288
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Route/RouteConfig.php
|
RouteConfig.addMethod
|
public function addMethod($method)
{
if (!is_string($method)) {
throw new InvalidArgumentException(
sprintf(
'Unsupported HTTP method; must be a string, received %s',
(is_object($method) ? get_class($method) : gettype($method))
)
);
}
// According to RFC, methods are defined in uppercase (See RFC 7231)
$method = strtoupper($method);
$validHttpMethods = [
'CONNECT',
'DELETE',
'GET',
'HEAD',
'OPTIONS',
'PATCH',
'POST',
'PUT',
'TRACE',
];
if (!in_array($method, $validHttpMethods)) {
throw new InvalidArgumentException(sprintf(
'Unsupported HTTP method; must be one of "%s", received "%s"',
implode('","', $validHttpMethods),
$method
));
}
$this->methods[] = $method;
return $this;
}
|
php
|
public function addMethod($method)
{
if (!is_string($method)) {
throw new InvalidArgumentException(
sprintf(
'Unsupported HTTP method; must be a string, received %s',
(is_object($method) ? get_class($method) : gettype($method))
)
);
}
// According to RFC, methods are defined in uppercase (See RFC 7231)
$method = strtoupper($method);
$validHttpMethods = [
'CONNECT',
'DELETE',
'GET',
'HEAD',
'OPTIONS',
'PATCH',
'POST',
'PUT',
'TRACE',
];
if (!in_array($method, $validHttpMethods)) {
throw new InvalidArgumentException(sprintf(
'Unsupported HTTP method; must be one of "%s", received "%s"',
implode('","', $validHttpMethods),
$method
));
}
$this->methods[] = $method;
return $this;
}
|
[
"public",
"function",
"addMethod",
"(",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unsupported HTTP method; must be a string, received %s'",
",",
"(",
"is_object",
"(",
"$",
"method",
")",
"?",
"get_class",
"(",
"$",
"method",
")",
":",
"gettype",
"(",
"$",
"method",
")",
")",
")",
")",
";",
"}",
"// According to RFC, methods are defined in uppercase (See RFC 7231)",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"$",
"validHttpMethods",
"=",
"[",
"'CONNECT'",
",",
"'DELETE'",
",",
"'GET'",
",",
"'HEAD'",
",",
"'OPTIONS'",
",",
"'PATCH'",
",",
"'POST'",
",",
"'PUT'",
",",
"'TRACE'",
",",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"method",
",",
"$",
"validHttpMethods",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unsupported HTTP method; must be one of \"%s\", received \"%s\"'",
",",
"implode",
"(",
"'\",\"'",
",",
"$",
"validHttpMethods",
")",
",",
"$",
"method",
")",
")",
";",
"}",
"$",
"this",
"->",
"methods",
"[",
"]",
"=",
"$",
"method",
";",
"return",
"$",
"this",
";",
"}"
] |
Add route HTTP method.
@param string $method The route's supported HTTP method.
@throws InvalidArgumentException If the HTTP method is invalid.
@return self
|
[
"Add",
"route",
"HTTP",
"method",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Route/RouteConfig.php#L287-L324
|
27,289
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/ServiceProvider/AppServiceProvider.php
|
AppServiceProvider.registerViewServices
|
protected function registerViewServices(Container $container)
{
if (!isset($container['view/mustache/helpers'])) {
$container['view/mustache/helpers'] = function () {
return [];
};
}
/**
* Extend helpers for the Mustache Engine
*
* @return array
*/
$container->extend('view/mustache/helpers', function (array $helpers, Container $container) {
$baseUrl = $container['base-url'];
$urls = [
/**
* Application debug mode.
*
* @return boolean
*/
'debug' => ($container['config']['debug'] || $container['config']['dev_mode']),
/**
* Retrieve the base URI of the project.
*
* @return UriInterface|null
*/
'siteUrl' => $baseUrl,
/**
* Alias of "siteUrl"
*
* @return UriInterface|null
*/
'baseUrl' => $baseUrl,
/**
* Prepend the base URI to the given path.
*
* @param string $uri A URI path to wrap.
* @return UriInterface|null
*/
'withBaseUrl' => function ($uri, LambdaHelper $helper = null) use ($baseUrl) {
if ($helper) {
$uri = $helper->render($uri);
}
$uri = strval($uri);
if ($uri === '') {
$uri = $baseUrl->withPath('');
} else {
$parts = parse_url($uri);
if (!isset($parts['scheme'])) {
if (!in_array($uri[0], [ '/', '#', '?' ])) {
$path = isset($parts['path']) ? $parts['path'] : '';
$query = isset($parts['query']) ? $parts['query'] : '';
$hash = isset($parts['fragment']) ? $parts['fragment'] : '';
$uri = $baseUrl->withPath($path)
->withQuery($query)
->withFragment($hash);
}
}
}
return $uri;
},
'renderContext' => function ($text, LambdaHelper $helper = null) {
return $helper->render('{{>'.$helper->render($text).'}}');
}
];
return array_merge($helpers, $urls);
});
}
|
php
|
protected function registerViewServices(Container $container)
{
if (!isset($container['view/mustache/helpers'])) {
$container['view/mustache/helpers'] = function () {
return [];
};
}
/**
* Extend helpers for the Mustache Engine
*
* @return array
*/
$container->extend('view/mustache/helpers', function (array $helpers, Container $container) {
$baseUrl = $container['base-url'];
$urls = [
/**
* Application debug mode.
*
* @return boolean
*/
'debug' => ($container['config']['debug'] || $container['config']['dev_mode']),
/**
* Retrieve the base URI of the project.
*
* @return UriInterface|null
*/
'siteUrl' => $baseUrl,
/**
* Alias of "siteUrl"
*
* @return UriInterface|null
*/
'baseUrl' => $baseUrl,
/**
* Prepend the base URI to the given path.
*
* @param string $uri A URI path to wrap.
* @return UriInterface|null
*/
'withBaseUrl' => function ($uri, LambdaHelper $helper = null) use ($baseUrl) {
if ($helper) {
$uri = $helper->render($uri);
}
$uri = strval($uri);
if ($uri === '') {
$uri = $baseUrl->withPath('');
} else {
$parts = parse_url($uri);
if (!isset($parts['scheme'])) {
if (!in_array($uri[0], [ '/', '#', '?' ])) {
$path = isset($parts['path']) ? $parts['path'] : '';
$query = isset($parts['query']) ? $parts['query'] : '';
$hash = isset($parts['fragment']) ? $parts['fragment'] : '';
$uri = $baseUrl->withPath($path)
->withQuery($query)
->withFragment($hash);
}
}
}
return $uri;
},
'renderContext' => function ($text, LambdaHelper $helper = null) {
return $helper->render('{{>'.$helper->render($text).'}}');
}
];
return array_merge($helpers, $urls);
});
}
|
[
"protected",
"function",
"registerViewServices",
"(",
"Container",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"container",
"[",
"'view/mustache/helpers'",
"]",
")",
")",
"{",
"$",
"container",
"[",
"'view/mustache/helpers'",
"]",
"=",
"function",
"(",
")",
"{",
"return",
"[",
"]",
";",
"}",
";",
"}",
"/**\n * Extend helpers for the Mustache Engine\n *\n * @return array\n */",
"$",
"container",
"->",
"extend",
"(",
"'view/mustache/helpers'",
",",
"function",
"(",
"array",
"$",
"helpers",
",",
"Container",
"$",
"container",
")",
"{",
"$",
"baseUrl",
"=",
"$",
"container",
"[",
"'base-url'",
"]",
";",
"$",
"urls",
"=",
"[",
"/**\n * Application debug mode.\n *\n * @return boolean\n */",
"'debug'",
"=>",
"(",
"$",
"container",
"[",
"'config'",
"]",
"[",
"'debug'",
"]",
"||",
"$",
"container",
"[",
"'config'",
"]",
"[",
"'dev_mode'",
"]",
")",
",",
"/**\n * Retrieve the base URI of the project.\n *\n * @return UriInterface|null\n */",
"'siteUrl'",
"=>",
"$",
"baseUrl",
",",
"/**\n * Alias of \"siteUrl\"\n *\n * @return UriInterface|null\n */",
"'baseUrl'",
"=>",
"$",
"baseUrl",
",",
"/**\n * Prepend the base URI to the given path.\n *\n * @param string $uri A URI path to wrap.\n * @return UriInterface|null\n */",
"'withBaseUrl'",
"=>",
"function",
"(",
"$",
"uri",
",",
"LambdaHelper",
"$",
"helper",
"=",
"null",
")",
"use",
"(",
"$",
"baseUrl",
")",
"{",
"if",
"(",
"$",
"helper",
")",
"{",
"$",
"uri",
"=",
"$",
"helper",
"->",
"render",
"(",
"$",
"uri",
")",
";",
"}",
"$",
"uri",
"=",
"strval",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"uri",
"===",
"''",
")",
"{",
"$",
"uri",
"=",
"$",
"baseUrl",
"->",
"withPath",
"(",
"''",
")",
";",
"}",
"else",
"{",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"uri",
"[",
"0",
"]",
",",
"[",
"'/'",
",",
"'#'",
",",
"'?'",
"]",
")",
")",
"{",
"$",
"path",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'path'",
"]",
")",
"?",
"$",
"parts",
"[",
"'path'",
"]",
":",
"''",
";",
"$",
"query",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'query'",
"]",
")",
"?",
"$",
"parts",
"[",
"'query'",
"]",
":",
"''",
";",
"$",
"hash",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'fragment'",
"]",
")",
"?",
"$",
"parts",
"[",
"'fragment'",
"]",
":",
"''",
";",
"$",
"uri",
"=",
"$",
"baseUrl",
"->",
"withPath",
"(",
"$",
"path",
")",
"->",
"withQuery",
"(",
"$",
"query",
")",
"->",
"withFragment",
"(",
"$",
"hash",
")",
";",
"}",
"}",
"}",
"return",
"$",
"uri",
";",
"}",
",",
"'renderContext'",
"=>",
"function",
"(",
"$",
"text",
",",
"LambdaHelper",
"$",
"helper",
"=",
"null",
")",
"{",
"return",
"$",
"helper",
"->",
"render",
"(",
"'{{>'",
".",
"$",
"helper",
"->",
"render",
"(",
"$",
"text",
")",
".",
"'}}'",
")",
";",
"}",
"]",
";",
"return",
"array_merge",
"(",
"$",
"helpers",
",",
"$",
"urls",
")",
";",
"}",
")",
";",
"}"
] |
Add helpers to the view services.
@param Container $container A container instance.
@return void
|
[
"Add",
"helpers",
"to",
"the",
"view",
"services",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/ServiceProvider/AppServiceProvider.php#L456-L528
|
27,290
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/App.php
|
App.setup
|
private function setup()
{
$config = $this->config();
date_default_timezone_set($config['timezone']);
// Setup routes
$this->routeManager()->setupRoutes();
// Setup modules
$this->setupModules();
// Setup routable (if not running CLI mode)
if (PHP_SAPI !== 'cli') {
$this->setupRoutables();
}
// Setup middlewares
$this->setupMiddlewares();
}
|
php
|
private function setup()
{
$config = $this->config();
date_default_timezone_set($config['timezone']);
// Setup routes
$this->routeManager()->setupRoutes();
// Setup modules
$this->setupModules();
// Setup routable (if not running CLI mode)
if (PHP_SAPI !== 'cli') {
$this->setupRoutables();
}
// Setup middlewares
$this->setupMiddlewares();
}
|
[
"private",
"function",
"setup",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
"(",
")",
";",
"date_default_timezone_set",
"(",
"$",
"config",
"[",
"'timezone'",
"]",
")",
";",
"// Setup routes",
"$",
"this",
"->",
"routeManager",
"(",
")",
"->",
"setupRoutes",
"(",
")",
";",
"// Setup modules",
"$",
"this",
"->",
"setupModules",
"(",
")",
";",
"// Setup routable (if not running CLI mode)",
"if",
"(",
"PHP_SAPI",
"!==",
"'cli'",
")",
"{",
"$",
"this",
"->",
"setupRoutables",
"(",
")",
";",
"}",
"// Setup middlewares",
"$",
"this",
"->",
"setupMiddlewares",
"(",
")",
";",
"}"
] |
Registers the default services and features that Charcoal needs to work.
@return void
|
[
"Registers",
"the",
"default",
"services",
"and",
"features",
"that",
"Charcoal",
"needs",
"to",
"work",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/App.php#L126-L144
|
27,291
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/App.php
|
App.setupRoutables
|
private function setupRoutables()
{
$app = $this;
// For now, need to rely on a catch-all...
$this->get(
'{catchall:.*}',
function (
RequestInterface $request,
ResponseInterface $response,
array $args
) use ($app) {
$config = $app->config();
$routables = $config['routables'];
if ($routables === null || count($routables) === 0) {
return $this['notFoundHandler']($request, $response);
}
$routeFactory = $this['route/factory'];
foreach ($routables as $routableType => $routableOptions) {
$route = $routeFactory->create($routableType, [
'path' => $args['catchall'],
'config' => $routableOptions
]);
if ($route->pathResolvable($this)) {
$this['logger']->debug(
sprintf('Loaded routable "%s" for path %s', $routableType, $args['catchall'])
);
return $route($this, $request, $response);
}
}
// If this point is reached, no routable has provided a callback. 404.
return $this['notFoundHandler']($request, $response);
}
);
}
|
php
|
private function setupRoutables()
{
$app = $this;
// For now, need to rely on a catch-all...
$this->get(
'{catchall:.*}',
function (
RequestInterface $request,
ResponseInterface $response,
array $args
) use ($app) {
$config = $app->config();
$routables = $config['routables'];
if ($routables === null || count($routables) === 0) {
return $this['notFoundHandler']($request, $response);
}
$routeFactory = $this['route/factory'];
foreach ($routables as $routableType => $routableOptions) {
$route = $routeFactory->create($routableType, [
'path' => $args['catchall'],
'config' => $routableOptions
]);
if ($route->pathResolvable($this)) {
$this['logger']->debug(
sprintf('Loaded routable "%s" for path %s', $routableType, $args['catchall'])
);
return $route($this, $request, $response);
}
}
// If this point is reached, no routable has provided a callback. 404.
return $this['notFoundHandler']($request, $response);
}
);
}
|
[
"private",
"function",
"setupRoutables",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
";",
"// For now, need to rely on a catch-all...",
"$",
"this",
"->",
"get",
"(",
"'{catchall:.*}'",
",",
"function",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"array",
"$",
"args",
")",
"use",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"->",
"config",
"(",
")",
";",
"$",
"routables",
"=",
"$",
"config",
"[",
"'routables'",
"]",
";",
"if",
"(",
"$",
"routables",
"===",
"null",
"||",
"count",
"(",
"$",
"routables",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"[",
"'notFoundHandler'",
"]",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"$",
"routeFactory",
"=",
"$",
"this",
"[",
"'route/factory'",
"]",
";",
"foreach",
"(",
"$",
"routables",
"as",
"$",
"routableType",
"=>",
"$",
"routableOptions",
")",
"{",
"$",
"route",
"=",
"$",
"routeFactory",
"->",
"create",
"(",
"$",
"routableType",
",",
"[",
"'path'",
"=>",
"$",
"args",
"[",
"'catchall'",
"]",
",",
"'config'",
"=>",
"$",
"routableOptions",
"]",
")",
";",
"if",
"(",
"$",
"route",
"->",
"pathResolvable",
"(",
"$",
"this",
")",
")",
"{",
"$",
"this",
"[",
"'logger'",
"]",
"->",
"debug",
"(",
"sprintf",
"(",
"'Loaded routable \"%s\" for path %s'",
",",
"$",
"routableType",
",",
"$",
"args",
"[",
"'catchall'",
"]",
")",
")",
";",
"return",
"$",
"route",
"(",
"$",
"this",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"}",
"// If this point is reached, no routable has provided a callback. 404.",
"return",
"$",
"this",
"[",
"'notFoundHandler'",
"]",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
")",
";",
"}"
] |
Setup the application's "global" routables.
Routables can only be defined globally (app-level) for now.
@return void
|
[
"Setup",
"the",
"application",
"s",
"global",
"routables",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/App.php#L186-L220
|
27,292
|
melisplatform/melis-core
|
src/Model/Tables/MelisPlatformSchemeTable.php
|
MelisPlatformSchemeTable.getSchemeById
|
public function getSchemeById($id, $colorsOnly = false)
{
$id = (int) $id;
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_id', $id);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
php
|
public function getSchemeById($id, $colorsOnly = false)
{
$id = (int) $id;
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_id', $id);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
[
"public",
"function",
"getSchemeById",
"(",
"$",
"id",
",",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
";",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"$",
"colorsOnly",
")",
"{",
"$",
"select",
"->",
"columns",
"(",
"array",
"(",
"'pscheme_id'",
",",
"'pscheme_name'",
",",
"'pscheme_colors'",
",",
"'pscheme_is_active'",
")",
")",
";",
"}",
"$",
"select",
"->",
"where",
"->",
"equalTo",
"(",
"'pscheme_id'",
",",
"$",
"id",
")",
";",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"selectWith",
"(",
"$",
"select",
")",
";",
"return",
"$",
"resultSet",
";",
"}"
] |
Query scheme table by ID
@param $id
@param bool $colorsOnly
@return null|\Zend\Db\ResultSet\ResultSetInterface
|
[
"Query",
"scheme",
"table",
"by",
"ID"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisPlatformSchemeTable.php#L28-L45
|
27,293
|
melisplatform/melis-core
|
src/Model/Tables/MelisPlatformSchemeTable.php
|
MelisPlatformSchemeTable.getSchemeByName
|
public function getSchemeByName($name, $colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_name', $name);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
php
|
public function getSchemeByName($name, $colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_name', $name);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
[
"public",
"function",
"getSchemeByName",
"(",
"$",
"name",
",",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"$",
"colorsOnly",
")",
"{",
"$",
"select",
"->",
"columns",
"(",
"array",
"(",
"'pscheme_id'",
",",
"'pscheme_name'",
",",
"'pscheme_colors'",
",",
"'pscheme_is_active'",
")",
")",
";",
"}",
"$",
"select",
"->",
"where",
"->",
"equalTo",
"(",
"'pscheme_name'",
",",
"$",
"name",
")",
";",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"selectWith",
"(",
"$",
"select",
")",
";",
"return",
"$",
"resultSet",
";",
"}"
] |
Query scheme table by name
@param $name
@param bool $colorsOnly
@return null|\Zend\Db\ResultSet\ResultSetInterface
|
[
"Query",
"scheme",
"table",
"by",
"name"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisPlatformSchemeTable.php#L53-L68
|
27,294
|
melisplatform/melis-core
|
src/Model/Tables/MelisPlatformSchemeTable.php
|
MelisPlatformSchemeTable.getActiveScheme
|
public function getActiveScheme($colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_is_active', 1);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
php
|
public function getActiveScheme($colorsOnly = false)
{
$select = $this->tableGateway->getSql()->select();
if($colorsOnly) {
$select->columns(array(
'pscheme_id', 'pscheme_name', 'pscheme_colors', 'pscheme_is_active'
));
}
$select->where->equalTo('pscheme_is_active', 1);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
}
|
[
"public",
"function",
"getActiveScheme",
"(",
"$",
"colorsOnly",
"=",
"false",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"if",
"(",
"$",
"colorsOnly",
")",
"{",
"$",
"select",
"->",
"columns",
"(",
"array",
"(",
"'pscheme_id'",
",",
"'pscheme_name'",
",",
"'pscheme_colors'",
",",
"'pscheme_is_active'",
")",
")",
";",
"}",
"$",
"select",
"->",
"where",
"->",
"equalTo",
"(",
"'pscheme_is_active'",
",",
"1",
")",
";",
"$",
"resultSet",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"selectWith",
"(",
"$",
"select",
")",
";",
"return",
"$",
"resultSet",
";",
"}"
] |
Returns the currently active scheme
@param bool $colorsOnly
@return null|\Zend\Db\ResultSet\ResultSetInterface
|
[
"Returns",
"the",
"currently",
"active",
"scheme"
] |
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
|
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Model/Tables/MelisPlatformSchemeTable.php#L75-L90
|
27,295
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Handler/AbstractHandler.php
|
AbstractHandler.respondWith
|
protected function respondWith(ResponseInterface $response, $contentType, $output)
{
$body = new Body(fopen('php://temp', 'r+'));
$body->write($output);
return $response->withHeader('Content-Type', $contentType)
->withBody($body);
}
|
php
|
protected function respondWith(ResponseInterface $response, $contentType, $output)
{
$body = new Body(fopen('php://temp', 'r+'));
$body->write($output);
return $response->withHeader('Content-Type', $contentType)
->withBody($body);
}
|
[
"protected",
"function",
"respondWith",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"contentType",
",",
"$",
"output",
")",
"{",
"$",
"body",
"=",
"new",
"Body",
"(",
"fopen",
"(",
"'php://temp'",
",",
"'r+'",
")",
")",
";",
"$",
"body",
"->",
"write",
"(",
"$",
"output",
")",
";",
"return",
"$",
"response",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"$",
"contentType",
")",
"->",
"withBody",
"(",
"$",
"body",
")",
";",
"}"
] |
Mutate the given response.
@param ResponseInterface $response The most recent Response object.
@param string $contentType The content type of the output.
@param string $output The text output.
@return ResponseInterface
|
[
"Mutate",
"the",
"given",
"response",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Handler/AbstractHandler.php#L275-L282
|
27,296
|
UseMuffin/Tokenize
|
src/Model/Table/TokensTable.php
|
TokensTable.findToken
|
public function findToken(Query $query, array $options)
{
$options += [
'token' => null,
'expired >' => new DateTime(),
'status' => false
];
return $query->where($options);
}
|
php
|
public function findToken(Query $query, array $options)
{
$options += [
'token' => null,
'expired >' => new DateTime(),
'status' => false
];
return $query->where($options);
}
|
[
"public",
"function",
"findToken",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"options",
")",
"{",
"$",
"options",
"+=",
"[",
"'token'",
"=>",
"null",
",",
"'expired >'",
"=>",
"new",
"DateTime",
"(",
")",
",",
"'status'",
"=>",
"false",
"]",
";",
"return",
"$",
"query",
"->",
"where",
"(",
"$",
"options",
")",
";",
"}"
] |
Custom finder "token"
@param \Cake\ORM\Query $query Query
@param array $options Options
@return \Cake\ORM\Query
|
[
"Custom",
"finder",
"token"
] |
a7ecf4114782abe12b0ab36e8a32504428fe91ec
|
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Table/TokensTable.php#L42-L51
|
27,297
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Config/LoggerConfig.php
|
LoggerConfig.addHandler
|
public function addHandler(array $handler, $key = null)
{
if (!isset($handler['type'])) {
throw new InvalidArgumentException(
'Handler type is required.'
);
}
if (!is_string($key)) {
$this->handlers[] = $handler;
} else {
$this->handlers[$key] = $handler;
}
return $this;
}
|
php
|
public function addHandler(array $handler, $key = null)
{
if (!isset($handler['type'])) {
throw new InvalidArgumentException(
'Handler type is required.'
);
}
if (!is_string($key)) {
$this->handlers[] = $handler;
} else {
$this->handlers[$key] = $handler;
}
return $this;
}
|
[
"public",
"function",
"addHandler",
"(",
"array",
"$",
"handler",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"handler",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Handler type is required.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"handlers",
"[",
"]",
"=",
"$",
"handler",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"handlers",
"[",
"$",
"key",
"]",
"=",
"$",
"handler",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add a record handler to use.
@param array $handler The record handler structure.
@param string|null $key The handler's key.
@throws InvalidArgumentException If the handler is invalid.
@return self
|
[
"Add",
"a",
"record",
"handler",
"to",
"use",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Config/LoggerConfig.php#L143-L158
|
27,298
|
locomotivemtl/charcoal-app
|
src/Charcoal/App/Config/LoggerConfig.php
|
LoggerConfig.addProcessor
|
public function addProcessor(array $processor, $key = null)
{
if (!isset($processor['type'])) {
throw new InvalidArgumentException(
'Processor type is required.'
);
}
if (!is_string($key)) {
$this->processors[] = $processor;
} else {
$this->processors[$key] = $processor;
}
return $this;
}
|
php
|
public function addProcessor(array $processor, $key = null)
{
if (!isset($processor['type'])) {
throw new InvalidArgumentException(
'Processor type is required.'
);
}
if (!is_string($key)) {
$this->processors[] = $processor;
} else {
$this->processors[$key] = $processor;
}
return $this;
}
|
[
"public",
"function",
"addProcessor",
"(",
"array",
"$",
"processor",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"processor",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Processor type is required.'",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"processors",
"[",
"]",
"=",
"$",
"processor",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"processors",
"[",
"$",
"key",
"]",
"=",
"$",
"processor",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add a record processor to use.
@param array $processor The record processor structure.
@param string|null $key The processor's key.
@throws InvalidArgumentException If the processor is invalid.
@return self
|
[
"Add",
"a",
"record",
"processor",
"to",
"use",
"."
] |
d25bdab08d40dda83c71b770c59e3b469e0ebfbc
|
https://github.com/locomotivemtl/charcoal-app/blob/d25bdab08d40dda83c71b770c59e3b469e0ebfbc/src/Charcoal/App/Config/LoggerConfig.php#L205-L220
|
27,299
|
orchestral/kernel
|
src/Http/FormRequest.php
|
FormRequest.setupValidationScenario
|
protected function setupValidationScenario()
{
$current = $this->method();
$available = [
'POST' => 'store',
'PUT' => 'update',
'DELETE' => 'destroy',
];
if (in_array($current, $available)) {
$this->onValidationScenario($available[$current]);
}
}
|
php
|
protected function setupValidationScenario()
{
$current = $this->method();
$available = [
'POST' => 'store',
'PUT' => 'update',
'DELETE' => 'destroy',
];
if (in_array($current, $available)) {
$this->onValidationScenario($available[$current]);
}
}
|
[
"protected",
"function",
"setupValidationScenario",
"(",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"method",
"(",
")",
";",
"$",
"available",
"=",
"[",
"'POST'",
"=>",
"'store'",
",",
"'PUT'",
"=>",
"'update'",
",",
"'DELETE'",
"=>",
"'destroy'",
",",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"current",
",",
"$",
"available",
")",
")",
"{",
"$",
"this",
"->",
"onValidationScenario",
"(",
"$",
"available",
"[",
"$",
"current",
"]",
")",
";",
"}",
"}"
] |
Setup validation scenario based on request method.
@return void
|
[
"Setup",
"validation",
"scenario",
"based",
"on",
"request",
"method",
"."
] |
d4ebf0604e9aba6fe30813bc3446305157d93eb4
|
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/FormRequest.php#L45-L57
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.