repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.injectorSetup | protected function injectorSetup()
{
if ($this->_injectorObjects === null) {
foreach ($this->injectors() as $varName => $injector) {
$injector->setContext($this);
$injector->varName = $varName;
$injector->setup();
$this->_injectorObjects[$injector->varName] = $injector;
}
}
} | php | protected function injectorSetup()
{
if ($this->_injectorObjects === null) {
foreach ($this->injectors() as $varName => $injector) {
$injector->setContext($this);
$injector->varName = $varName;
$injector->setup();
$this->_injectorObjects[$injector->varName] = $injector;
}
}
} | [
"protected",
"function",
"injectorSetup",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_injectorObjects",
"===",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"injectors",
"(",
")",
"as",
"$",
"varName",
"=>",
"$",
"injector",
")",
"{",
"$",
... | Setup injectors. | [
"Setup",
"injectors",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L49-L59 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.createAjaxLink | public function createAjaxLink($callbackName, array $params = [])
{
$params['callback'] = Inflector::camel2id($callbackName);
$params['id'] = $this->getEnvOption('id', 0);
return Url::toAjax('cms/block/index', $params);
} | php | public function createAjaxLink($callbackName, array $params = [])
{
$params['callback'] = Inflector::camel2id($callbackName);
$params['id'] = $this->getEnvOption('id', 0);
return Url::toAjax('cms/block/index', $params);
} | [
"public",
"function",
"createAjaxLink",
"(",
"$",
"callbackName",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'callback'",
"]",
"=",
"Inflector",
"::",
"camel2id",
"(",
"$",
"callbackName",
")",
";",
"$",
"params",
"[",
"... | Return link for usage in ajax request, the link will call the defined callback inside
this block. All callback methods must start with `callback`. An example for a callback method:.
```php
public function callbackTestAjax($arg1)
{
return 'hello callback test ajax with argument: arg1 ' . $arg1;
}
```
The above defined callback link can be created with the follow code:
```php
$this->createAjaxLink('TestAjax', ['arg1' => 'My Value for Arg1']);
```
The most convient way to assign the variable is via extraVars
```php
public function extraVars()
{
return [
'ajaxLinkToTestAjax' => $this->createAjaxLink('TestAjax', ['arg1' => 'Value for Arg1']),
];
}
```
@param string $callbackName The callback name in uppercamelcase to call. The method must exists in the block class.
@param array $params A list of parameters who have to match the argument list in the method.
@return string | [
"Return",
"link",
"for",
"usage",
"in",
"ajax",
"request",
"the",
"link",
"will",
"call",
"the",
"defined",
"callback",
"inside",
"this",
"block",
".",
"All",
"callback",
"methods",
"must",
"start",
"with",
"callback",
".",
"An",
"example",
"for",
"a",
"ca... | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L215-L220 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.getEnvOption | public function getEnvOption($key, $default = false)
{
return (array_key_exists($key, $this->_envOptions)) ? $this->_envOptions[$key] : $default;
} | php | public function getEnvOption($key, $default = false)
{
return (array_key_exists($key, $this->_envOptions)) ? $this->_envOptions[$key] : $default;
} | [
"public",
"function",
"getEnvOption",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"false",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_envOptions",
")",
")",
"?",
"$",
"this",
"->",
"_envOptions",
"[",
"$",
... | Get a env option by $key. If $key does not exist it will return given $default or false.
@param $key
@param mixed $default
@return mixed | [
"Get",
"a",
"env",
"option",
"by",
"$key",
".",
"If",
"$key",
"does",
"not",
"exist",
"it",
"will",
"return",
"given",
"$default",
"or",
"false",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L286-L289 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.getVarValue | public function getVarValue($key, $default = false)
{
return (isset($this->_varValues[$key]) && $this->_varValues[$key] != '') ? $this->_varValues[$key] : $default;
} | php | public function getVarValue($key, $default = false)
{
return (isset($this->_varValues[$key]) && $this->_varValues[$key] != '') ? $this->_varValues[$key] : $default;
} | [
"public",
"function",
"getVarValue",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"false",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"_varValues",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"this",
"->",
"_varValues",
"[",
"$",
"key",
"]",... | Get var value.
If the key does not exist in the array, is an empty string or null the default value will be returned.
@param string $key The name of the key you want to retrieve
@param mixed $default A default value that will be returned if the key isn't found or empty.
@return mixed | [
"Get",
"var",
"value",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L349-L352 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.getCfgValue | public function getCfgValue($key, $default = false)
{
return (isset($this->_cfgValues[$key]) && $this->_cfgValues[$key] != '') ? $this->_cfgValues[$key] : $default;
} | php | public function getCfgValue($key, $default = false)
{
return (isset($this->_cfgValues[$key]) && $this->_cfgValues[$key] != '') ? $this->_cfgValues[$key] : $default;
} | [
"public",
"function",
"getCfgValue",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"false",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"_cfgValues",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"this",
"->",
"_cfgValues",
"[",
"$",
"key",
"]",... | Get cfg value.
If the key does not exist in the array, is an empty string or null the default value will be returned.
@param string $key The name of the key you want to retrieve
@param mixed $default A default value that will be returned if the key isn't found or empty.
@return mixed | [
"Get",
"cfg",
"value",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L384-L387 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.addVar | public function addVar(array $varConfig, $append = false)
{
$count = count($this->_vars);
$iteration = $append ? $count + 1000 : $count;
$this->_vars[$iteration] = (new BlockVar($varConfig))->toArray();
} | php | public function addVar(array $varConfig, $append = false)
{
$count = count($this->_vars);
$iteration = $append ? $count + 1000 : $count;
$this->_vars[$iteration] = (new BlockVar($varConfig))->toArray();
} | [
"public",
"function",
"addVar",
"(",
"array",
"$",
"varConfig",
",",
"$",
"append",
"=",
"false",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"_vars",
")",
";",
"$",
"iteration",
"=",
"$",
"append",
"?",
"$",
"count",
"+",
"1000",... | Add a var variable to the config.
@param array $varConfig
@param boolean Whether the variable should be append to the end instead of prepanding. | [
"Add",
"a",
"var",
"variable",
"to",
"the",
"config",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L474-L479 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.addCfg | public function addCfg(array $cfgConfig, $append = false)
{
$count = count($this->_cfgs);
$iteration = $append ? $count + 1000 : $count;
$this->_cfgs[$iteration] = (new BlockCfg($cfgConfig))->toArray();
} | php | public function addCfg(array $cfgConfig, $append = false)
{
$count = count($this->_cfgs);
$iteration = $append ? $count + 1000 : $count;
$this->_cfgs[$iteration] = (new BlockCfg($cfgConfig))->toArray();
} | [
"public",
"function",
"addCfg",
"(",
"array",
"$",
"cfgConfig",
",",
"$",
"append",
"=",
"false",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"_cfgs",
")",
";",
"$",
"iteration",
"=",
"$",
"append",
"?",
"$",
"count",
"+",
"1000",... | Add a cfg variable to the config.
@param array $cfgConfig
@param boolean Whether the variable should be append to the end instead of prepanding. | [
"Add",
"a",
"cfg",
"variable",
"to",
"the",
"config",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L549-L554 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.getViewFileName | public function getViewFileName($extension)
{
$className = get_class($this);
if (preg_match('/\\\\([\w]+)$/', $className, $matches)) {
$className = $matches[1];
}
return $className.'.'.$extension;
} | php | public function getViewFileName($extension)
{
$className = get_class($this);
if (preg_match('/\\\\([\w]+)$/', $className, $matches)) {
$className = $matches[1];
}
return $className.'.'.$extension;
} | [
"public",
"function",
"getViewFileName",
"(",
"$",
"extension",
")",
"{",
"$",
"className",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/\\\\\\\\([\\w]+)$/'",
",",
"$",
"className",
",",
"$",
"matches",
")",
")",
"{",
"$... | Returns the name of the php file to be rendered.
@return string The name of the php file (example.php) | [
"Returns",
"the",
"name",
"of",
"the",
"php",
"file",
"to",
"be",
"rendered",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L561-L570 |
luyadev/luya-module-cms | src/base/InternalBaseBlock.php | InternalBaseBlock.getPreviewImageSource | protected function getPreviewImageSource()
{
$imageName = $this->getViewFileName('jpg');
$reflector = new \ReflectionClass($this);
$dirPath = dirname($reflector->getFileName(), 2);
$imagePath = $dirPath . '/images/blocks/' . $imageName;
// file get content resolved Yii aliases.
$data = FileHelper::getFileContent($imagePath);
if ($data) {
return 'data:image/jpg;base64,' . base64_encode($data);
}
return false;
} | php | protected function getPreviewImageSource()
{
$imageName = $this->getViewFileName('jpg');
$reflector = new \ReflectionClass($this);
$dirPath = dirname($reflector->getFileName(), 2);
$imagePath = $dirPath . '/images/blocks/' . $imageName;
// file get content resolved Yii aliases.
$data = FileHelper::getFileContent($imagePath);
if ($data) {
return 'data:image/jpg;base64,' . base64_encode($data);
}
return false;
} | [
"protected",
"function",
"getPreviewImageSource",
"(",
")",
"{",
"$",
"imageName",
"=",
"$",
"this",
"->",
"getViewFileName",
"(",
"'jpg'",
")",
";",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"dirPath",
"=",
... | Path to the preview image.
@since 1.0.8 | [
"Path",
"to",
"the",
"preview",
"image",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/InternalBaseBlock.php#L637-L651 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.selectArrayOption | public static function selectArrayOption(array $options, $prompt = null)
{
$transform = [];
if ($prompt) {
$transform[] = ['value' => 0, 'label' => $prompt];
}
foreach ($options as $key => $value) {
$transform[] = ['value' => $key, 'label' => $value];
}
return $transform;
} | php | public static function selectArrayOption(array $options, $prompt = null)
{
$transform = [];
if ($prompt) {
$transform[] = ['value' => 0, 'label' => $prompt];
}
foreach ($options as $key => $value) {
$transform[] = ['value' => $key, 'label' => $value];
}
return $transform;
} | [
"public",
"static",
"function",
"selectArrayOption",
"(",
"array",
"$",
"options",
",",
"$",
"prompt",
"=",
"null",
")",
"{",
"$",
"transform",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"prompt",
")",
"{",
"$",
"transform",
"[",
"]",
"=",
"[",
"'value'",
... | Create the options array for a zaa-select field based on an key value pairing
array.
In order to provide a prompt message which displayes when nothing is selected us the $prompt param.
In order to get a key value pairing directly from an ActiveRecord Model use:
```php
return Tag::find()->select(['name'])->indexBy('id')->column();
```
@param array $options The key value array pairing the select array should be created from.
@param string $prompt The prompt message when nothing is selected (contains the value 0 by default).
@return array
@since 1.0.0 | [
"Create",
"the",
"options",
"array",
"for",
"a",
"zaa",
"-",
"select",
"field",
"based",
"on",
"an",
"key",
"value",
"pairing",
"array",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L52-L63 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.checkboxArrayOption | public static function checkboxArrayOption(array $options)
{
$transform = [];
foreach ($options as $key => $value) {
$transform[] = ['value' => $key, 'label' => $value];
}
return ['items' => $transform];
} | php | public static function checkboxArrayOption(array $options)
{
$transform = [];
foreach ($options as $key => $value) {
$transform[] = ['value' => $key, 'label' => $value];
}
return ['items' => $transform];
} | [
"public",
"static",
"function",
"checkboxArrayOption",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"transform",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"transform",
"[",
"]",
"=",
"[",... | Create the Options list in the config for a zaa-checkbox-array based on an
key => value pairing array.
In order to get a key value pairing directly from an ActiveRecord Model use:
```php
return Tag::find()->select(['name'])->indexBy('id')->column();
```
Where name is the value and id the key for the array.
@param array $options The array who cares the options with items
@return array
@since 1.0.0 | [
"Create",
"the",
"Options",
"list",
"in",
"the",
"config",
"for",
"a",
"zaa",
"-",
"checkbox",
"-",
"array",
"based",
"on",
"an",
"key",
"=",
">",
"value",
"pairing",
"array",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L81-L89 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.imageUpload | public static function imageUpload($value, $applyFilter = false, $returnObject = false)
{
if (empty($value)) {
return false;
}
$image = Yii::$app->storage->getImage($value);
if (!$image) {
return false;
}
if ($applyFilter && is_string($applyFilter)) {
$filter = $image->applyFilter($applyFilter);
if ($filter) {
if ($returnObject) {
return $filter;
}
return $filter->toArray();
}
}
if ($returnObject) {
return $image;
}
return $image->toArray();
} | php | public static function imageUpload($value, $applyFilter = false, $returnObject = false)
{
if (empty($value)) {
return false;
}
$image = Yii::$app->storage->getImage($value);
if (!$image) {
return false;
}
if ($applyFilter && is_string($applyFilter)) {
$filter = $image->applyFilter($applyFilter);
if ($filter) {
if ($returnObject) {
return $filter;
}
return $filter->toArray();
}
}
if ($returnObject) {
return $image;
}
return $image->toArray();
} | [
"public",
"static",
"function",
"imageUpload",
"(",
"$",
"value",
",",
"$",
"applyFilter",
"=",
"false",
",",
"$",
"returnObject",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"image"... | Get all informations from an zaa-image-upload type:
```php
'image' => BlockHelper::ImageUpload($this->getVarValue('myImage')),
```
apply a filter for the image
```php
'imageFiltered' => BlockHelper::ImageUpload($this->getVarValue('myImage'), 'small-thumbnail'),
```
@param string|int $value Provided the value
@param boolean|string $applyFilter To apply a filter insert the identifier of the filter.
@param boolean $returnObject Whether the storage object should be returned or an array.
@return boolean|array|luya\admin\image\Item Returns false when not found, returns an array with all data for the image on success. | [
"Get",
"all",
"informations",
"from",
"an",
"zaa",
"-",
"image",
"-",
"upload",
"type",
":"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L109-L136 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.imageArrayUpload | public static function imageArrayUpload($value, $applyFilter = false, $returnObject = false)
{
if (!empty($value) && is_array($value)) {
$data = [];
foreach ($value as $key => $item) {
$image = static::imageUpload($item['imageId'], $applyFilter, true);
if ($image) {
if ($item['caption']) {
$image->caption = $item['caption'];
}
$data[$key] = ($returnObject) ? $image : $image->toArray();
}
}
return $data;
}
return [];
} | php | public static function imageArrayUpload($value, $applyFilter = false, $returnObject = false)
{
if (!empty($value) && is_array($value)) {
$data = [];
foreach ($value as $key => $item) {
$image = static::imageUpload($item['imageId'], $applyFilter, true);
if ($image) {
if ($item['caption']) {
$image->caption = $item['caption'];
}
$data[$key] = ($returnObject) ? $image : $image->toArray();
}
}
return $data;
}
return [];
} | [
"public",
"static",
"function",
"imageArrayUpload",
"(",
"$",
"value",
",",
"$",
"applyFilter",
"=",
"false",
",",
"$",
"returnObject",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"is_array",
"(",
"$",
"value",
")",
... | Get the full array for the specific zaa-file-image-upload type
```php
'imageList' => BlockHelper::ImageArrayUpload($this->getVarValue('images')),
```
Each array item will have all file query item data and a caption key.
@param string|int $value The specific var or cfg fieldvalue.
@param boolean|string $applyFilter To apply a filter insert the identifier of the filter.
@param boolean $returnObject Whether the storage object should be returned or an array.
@return array Returns an array in any case, even an empty array. | [
"Get",
"the",
"full",
"array",
"for",
"the",
"specific",
"zaa",
"-",
"file",
"-",
"image",
"-",
"upload",
"type"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L152-L172 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.fileUpload | public static function fileUpload($fileId, $returnObject = false)
{
if (!empty($fileId)) {
$file = Yii::$app->storage->getFile($fileId);
/* @var \luya\admin\file\Item $file */
if ($file) {
if ($returnObject) {
return $file;
}
return $file->toArray();
}
}
return false;
} | php | public static function fileUpload($fileId, $returnObject = false)
{
if (!empty($fileId)) {
$file = Yii::$app->storage->getFile($fileId);
/* @var \luya\admin\file\Item $file */
if ($file) {
if ($returnObject) {
return $file;
}
return $file->toArray();
}
}
return false;
} | [
"public",
"static",
"function",
"fileUpload",
"(",
"$",
"fileId",
",",
"$",
"returnObject",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"fileId",
")",
")",
"{",
"$",
"file",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"getFi... | Get file information based on input fileId.
In order to use the FileUpload helper, define an extraVar based on the fileId from the cfg or
var configurations.
```php
public function extraVars()
{
return [
'file' => BlockHelper::FileUpload($this->getVarValue('myFile'), true)
];
}
```
Attention: Always use if statement in your view file to check if file exists. An example view
for the above defined extra var `file`:
```html
<?php if ($this->extraValue('file')): ?>
<a href="<?= $this->extraValue('file')->href; ?>">File Download</a>
<?php endif; ?>
```
@param integer $fileId The file id from a config or cfg value in order to find the file.
@param boolean $returnObject Whether the storage object should be returned or an array, if the file could not be found this parameter is
has no affect to the response and will return false.
@return boolean|array|\luya\admin\file\Item Returns an array or the {{\luya\admin\file\Item}} object if the file could be find, otherwise the response is false. Make
sure to check whether return value is false or not to ensure no exception will be thrown. | [
"Get",
"file",
"information",
"based",
"on",
"input",
"fileId",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L204-L218 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.fileArrayUpload | public static function fileArrayUpload($value, $returnObject = false)
{
if (!empty($value) && is_array($value)) {
$data = [];
foreach ($value as $key => $item) {
$file = static::fileUpload($item['fileId'], true);
if ($file) {
if (!empty($item['caption'])) {
$file->caption = $item['caption'];
} else {
$file->caption = $file->name;
}
$data[$key] = ($returnObject) ? $file : $file->toArray();
}
}
return $data;
}
return [];
} | php | public static function fileArrayUpload($value, $returnObject = false)
{
if (!empty($value) && is_array($value)) {
$data = [];
foreach ($value as $key => $item) {
$file = static::fileUpload($item['fileId'], true);
if ($file) {
if (!empty($item['caption'])) {
$file->caption = $item['caption'];
} else {
$file->caption = $file->name;
}
$data[$key] = ($returnObject) ? $file : $file->toArray();
}
}
return $data;
}
return [];
} | [
"public",
"static",
"function",
"fileArrayUpload",
"(",
"$",
"value",
",",
"$",
"returnObject",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"data",
"=",
"[",
"]",... | Get the full array for the specific zaa-file-array-upload type
```php
'fileList' => BlockHelper::FileArrayUpload($this->getVarValue('files')),
```
Each array item will have all file query item data and a caption key.
@param string|int $value The specific var or cfg fieldvalue.
@param boolean $returnObject Whether the storage object should be returned or an array.
@return array Returns an array in any case, even an empty array. | [
"Get",
"the",
"full",
"array",
"for",
"the",
"specific",
"zaa",
"-",
"file",
"-",
"array",
"-",
"upload",
"type"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L233-L253 |
luyadev/luya-module-cms | src/helpers/BlockHelper.php | BlockHelper.linkObject | public static function linkObject($config)
{
if (empty($config) || !is_array($config)) {
return false;
}
$converter = LinkConverter::fromArray($config);
if (!$converter) {
return false;
}
return $converter->getLink();
} | php | public static function linkObject($config)
{
if (empty($config) || !is_array($config)) {
return false;
}
$converter = LinkConverter::fromArray($config);
if (!$converter) {
return false;
}
return $converter->getLink();
} | [
"public",
"static",
"function",
"linkObject",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
")",
"||",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"converter",
"=",
"LinkConverter",
":... | Generate a link object based on the configuration (array).
@param array $config The configuration array to build the object the config array requires the following keys
+ type: The type of redirect (1 = internal, 2 = external, 3 = file, etc.)
+ value: The value assoiated to the type (link to a file can be an integer, redirect to an external page string with an url)
+ target: (optional)
@return \luya\web\LinkInterface|false Returns a linkable resource object or false if configuration is wrong. | [
"Generate",
"a",
"link",
"object",
"based",
"on",
"the",
"configuration",
"(",
"array",
")",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/BlockHelper.php#L265-L278 |
luyadev/luya-module-cms | src/frontend/controllers/PreviewController.php | PreviewController.actionIndex | public function actionIndex($itemId, $version = false, $date = false)
{
if (Yii::$app->adminuser->isGuest) {
throw new ForbiddenHttpException('Unable to see the preview page, session expired or not logged in.');
}
$navItem = NavItem::findOne($itemId);
if (!$navItem) {
throw new NotFoundHttpException("The requested nav item with id {$itemId} does not exist.");
}
$langShortCode = $navItem->lang->short_code;
Yii::$app->composition['langShortCode'] = $langShortCode;
$item = Yii::$app->menu->find()->where(['id' => $itemId])->with('hidden')->lang($langShortCode)->one();
if ($item && !$date && $navItem->nav_item_type_id == $version) {
return $this->redirect($item->link);
}
// this item is still offline so we have to inject and fake it with the inject api
if (!$item) {
// create new item to inject
$inject = new InjectItem([
'id' => $itemId,
'navId' => $navItem->nav->id,
'childOf' => Yii::$app->menu->home->id,
'title' => $navItem->title,
'alias' => $navItem->alias,
'isHidden' => true,
]);
// inject item into menu component
Yii::$app->menu->injectItem($inject);
// find the inject menu item
$item = Yii::$app->menu->find()->where(['id' => $inject->id])->with('hidden')->lang($langShortCode)->one();
// something really went wrong while finding injected item
if (!$item) {
throw new NotFoundHttpException("Unable to find the preview for this ID, maybe the page is still Offline?");
}
}
// set the current item, as it would be resolved wrong from the url manager / request path
Yii::$app->menu->current = $item;
return $this->renderContent($this->renderItem($itemId, null, $version));
} | php | public function actionIndex($itemId, $version = false, $date = false)
{
if (Yii::$app->adminuser->isGuest) {
throw new ForbiddenHttpException('Unable to see the preview page, session expired or not logged in.');
}
$navItem = NavItem::findOne($itemId);
if (!$navItem) {
throw new NotFoundHttpException("The requested nav item with id {$itemId} does not exist.");
}
$langShortCode = $navItem->lang->short_code;
Yii::$app->composition['langShortCode'] = $langShortCode;
$item = Yii::$app->menu->find()->where(['id' => $itemId])->with('hidden')->lang($langShortCode)->one();
if ($item && !$date && $navItem->nav_item_type_id == $version) {
return $this->redirect($item->link);
}
// this item is still offline so we have to inject and fake it with the inject api
if (!$item) {
// create new item to inject
$inject = new InjectItem([
'id' => $itemId,
'navId' => $navItem->nav->id,
'childOf' => Yii::$app->menu->home->id,
'title' => $navItem->title,
'alias' => $navItem->alias,
'isHidden' => true,
]);
// inject item into menu component
Yii::$app->menu->injectItem($inject);
// find the inject menu item
$item = Yii::$app->menu->find()->where(['id' => $inject->id])->with('hidden')->lang($langShortCode)->one();
// something really went wrong while finding injected item
if (!$item) {
throw new NotFoundHttpException("Unable to find the preview for this ID, maybe the page is still Offline?");
}
}
// set the current item, as it would be resolved wrong from the url manager / request path
Yii::$app->menu->current = $item;
return $this->renderContent($this->renderItem($itemId, null, $version));
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"itemId",
",",
"$",
"version",
"=",
"false",
",",
"$",
"date",
"=",
"false",
")",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"adminuser",
"->",
"isGuest",
")",
"{",
"throw",
"new",
"ForbiddenHttpExcept... | Renders the preview action.
@param integer $itemId The nav item to render.
@param integer $version The version to display.
@param integer $date The date from the preview frame, is false when not using the preview frame from the cms.
@throws ForbiddenHttpException
@throws NotFoundHttpException
@return \yii\web\Response|string | [
"Renders",
"the",
"preview",
"action",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/frontend/controllers/PreviewController.php#L30-L77 |
luyadev/luya-module-cms | src/menu/QueryIteratorFilter.php | QueryIteratorFilter.accept | public function accept()
{
$event = new MenuItemEvent();
$event->item = $this->current();
if (isset($this->getInnerIterator()->with['hidden'])) {
$event->visible = true;
}
Yii::$app->menu->trigger(Menu::EVENT_ON_ITEM_FIND, $event);
return $event->visible;
} | php | public function accept()
{
$event = new MenuItemEvent();
$event->item = $this->current();
if (isset($this->getInnerIterator()->with['hidden'])) {
$event->visible = true;
}
Yii::$app->menu->trigger(Menu::EVENT_ON_ITEM_FIND, $event);
return $event->visible;
} | [
"public",
"function",
"accept",
"(",
")",
"{",
"$",
"event",
"=",
"new",
"MenuItemEvent",
"(",
")",
";",
"$",
"event",
"->",
"item",
"=",
"$",
"this",
"->",
"current",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getInnerIterator",
"... | Verifys if an menu item does have valid event response.
{@inheritDoc}
@see FilterIterator::accept() | [
"Verifys",
"if",
"an",
"menu",
"item",
"does",
"have",
"valid",
"event",
"response",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/QueryIteratorFilter.php#L25-L34 |
luyadev/luya-module-cms | src/models/Redirect.php | Redirect.matchRequestPath | public function matchRequestPath($requestPath)
{
foreach ([$requestPath, urlencode($requestPath), urldecode($requestPath)] as $path) {
foreach ([$this->catch_path, urlencode($this->catch_path), urldecode($this->catch_path)] as $catch) {
if ($this->pathMatcher($path, $catch)) {
return true;
}
}
}
return false;
} | php | public function matchRequestPath($requestPath)
{
foreach ([$requestPath, urlencode($requestPath), urldecode($requestPath)] as $path) {
foreach ([$this->catch_path, urlencode($this->catch_path), urldecode($this->catch_path)] as $catch) {
if ($this->pathMatcher($path, $catch)) {
return true;
}
}
}
return false;
} | [
"public",
"function",
"matchRequestPath",
"(",
"$",
"requestPath",
")",
"{",
"foreach",
"(",
"[",
"$",
"requestPath",
",",
"urlencode",
"(",
"$",
"requestPath",
")",
",",
"urldecode",
"(",
"$",
"requestPath",
")",
"]",
"as",
"$",
"path",
")",
"{",
"forea... | Match Request Path against catch_path.
Several version of the request path will be checked in order to ensure different siutations can be handled.
@param string $requestPath
@return boolean | [
"Match",
"Request",
"Path",
"against",
"catch_path",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/Redirect.php#L137-L148 |
luyadev/luya-module-cms | src/models/Redirect.php | Redirect.pathMatcher | private function pathMatcher($input, $catchPath)
{
// ensure request path is prefix with slash
$requestPath = '/'.ltrim($input, '/');
// see if wildcard string matches
if (StringHelper::startsWithWildcard($requestPath, $catchPath)) {
return true;
}
// compare strings
return ($requestPath == $catchPath);
} | php | private function pathMatcher($input, $catchPath)
{
// ensure request path is prefix with slash
$requestPath = '/'.ltrim($input, '/');
// see if wildcard string matches
if (StringHelper::startsWithWildcard($requestPath, $catchPath)) {
return true;
}
// compare strings
return ($requestPath == $catchPath);
} | [
"private",
"function",
"pathMatcher",
"(",
"$",
"input",
",",
"$",
"catchPath",
")",
"{",
"// ensure request path is prefix with slash",
"$",
"requestPath",
"=",
"'/'",
".",
"ltrim",
"(",
"$",
"input",
",",
"'/'",
")",
";",
"// see if wildcard string matches",
"if... | Internal path matcher
@param string $input The input request path
@param string $catchPath The path to catch
@return boolean
@since 1.0.8 | [
"Internal",
"path",
"matcher"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/Redirect.php#L158-L168 |
luyadev/luya-module-cms | src/base/PhpBlockView.php | PhpBlockView.wrapTemplate | public function wrapTemplate($key, $value, $template)
{
if (!$template || empty($value)) {
return $value;
}
return str_replace(['{{' . $key . '}}'], $value, $template);
} | php | public function wrapTemplate($key, $value, $template)
{
if (!$template || empty($value)) {
return $value;
}
return str_replace(['{{' . $key . '}}'], $value, $template);
} | [
"public",
"function",
"wrapTemplate",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"$",
"template",
"||",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"str_replace",
"... | Wrap a very basic template arounte the value if value is not `empty()`.
Assuming to have variable `title` with the value `Hello World` and a template `<p>{{title}}</p>` renders:
```
<p>Hello World</p>
```
If a template is provided and $value is not empty return the wrapped template, otherwise the original $value input is returned.
@param string $key The variable name to idenfier as {{key}}.
@param mixed $value The value which should be replaced for the $key.
@param string $template The template as a string which replates the $key enclosed in {{
@return string If a template is provided and $value is not empty return the wrapped template, otherwise the original $value input. | [
"Wrap",
"a",
"very",
"basic",
"template",
"arounte",
"the",
"value",
"if",
"value",
"is",
"not",
"empty",
"()",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/PhpBlockView.php#L210-L217 |
luyadev/luya-module-cms | src/base/PhpBlockView.php | PhpBlockView.varValue | public function varValue($key, $defaultValue = null, $template = false)
{
return $this->wrapTemplate($key, $this->context->getVarValue($key, $defaultValue), $template);
} | php | public function varValue($key, $defaultValue = null, $template = false)
{
return $this->wrapTemplate($key, $this->context->getVarValue($key, $defaultValue), $template);
} | [
"public",
"function",
"varValue",
"(",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"$",
"template",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"wrapTemplate",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"context",
"->",
"getVarValue"... | The the content value of a var.
@param string $key The name of the var value to return, defined as `varName` inside the `config()` method of the vars section.
@param string $defaultValue Env value is not found this value will be returned.
@param string $template Provde a template which replaces the current variable if value is not `empty()`. e.g. `<p>{{variable}}≤/p>` See {{luya\cms\base\PhpBlockView::wrapTemplate}}.
@return mixed | [
"The",
"the",
"content",
"value",
"of",
"a",
"var",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/PhpBlockView.php#L227-L230 |
luyadev/luya-module-cms | src/base/PhpBlockView.php | PhpBlockView.cfgValue | public function cfgValue($key, $defaultValue = null, $template = false)
{
return $this->wrapTemplate($key, $this->context->getCfgValue($key, $defaultValue), $template);
} | php | public function cfgValue($key, $defaultValue = null, $template = false)
{
return $this->wrapTemplate($key, $this->context->getCfgValue($key, $defaultValue), $template);
} | [
"public",
"function",
"cfgValue",
"(",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"$",
"template",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"wrapTemplate",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"context",
"->",
"getCfgValue"... | Get the content of a cfg.
@param string $key The name of the cfg value to return, defined as `varName` inside the `config()` method of the cfgs section.
@param string $defaultValue Env value is not found this value will be returned.
@param string $template Provde a template which replaces the current variable if value is not `empty()`. e.g. `<p>{{variable}}≤/p>` See {{luya\cms\base\PhpBlockView::wrapTemplate}}.
@return mixed | [
"Get",
"the",
"content",
"of",
"a",
"cfg",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/PhpBlockView.php#L240-L243 |
luyadev/luya-module-cms | src/base/PhpBlockView.php | PhpBlockView.extraValue | public function extraValue($key, $defaultValue = null, $template = false)
{
return $this->wrapTemplate($key, $this->context->getExtraValue($key, $defaultValue), $template);
} | php | public function extraValue($key, $defaultValue = null, $template = false)
{
return $this->wrapTemplate($key, $this->context->getExtraValue($key, $defaultValue), $template);
} | [
"public",
"function",
"extraValue",
"(",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"$",
"template",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"wrapTemplate",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"context",
"->",
"getExtraVa... | Get the value of an extra var.
@param string $key The name of the extra var to return, defined as key inside the `extraVars()` method return array.
@param string $defaultValue Env value is not found this value will be returned.
@param string $template Provde a template which replaces the current variable if value is not `empty()`. e.g. `<p>{{variable}}≤/p>` See {{luya\cms\base\PhpBlockView::wrapTemplate}}.
@return mixed | [
"Get",
"the",
"value",
"of",
"an",
"extra",
"var",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/base/PhpBlockView.php#L253-L256 |
luyadev/luya-module-cms | src/menu/QueryIterator.php | QueryIterator.loadModels | public function loadModels()
{
if ($this->_loadModels === null) {
$this->_loadModels = Nav::find()->indexBy('id')->where(['in', 'id', ArrayHelper::getColumn($this->data, 'nav_id')])->with(['properties.adminProperty'])->all();
}
return $this->_loadModels;
} | php | public function loadModels()
{
if ($this->_loadModels === null) {
$this->_loadModels = Nav::find()->indexBy('id')->where(['in', 'id', ArrayHelper::getColumn($this->data, 'nav_id')])->with(['properties.adminProperty'])->all();
}
return $this->_loadModels;
} | [
"public",
"function",
"loadModels",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_loadModels",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_loadModels",
"=",
"Nav",
"::",
"find",
"(",
")",
"->",
"indexBy",
"(",
"'id'",
")",
"->",
"where",
"(",
"[... | Load all models for ghe given Menu Query.
@return array An array where the key is the id of the nav model and value the {{luya\cms\models\Nav}} object. | [
"Load",
"all",
"models",
"for",
"ghe",
"given",
"Menu",
"Query",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/QueryIterator.php#L62-L69 |
luyadev/luya-module-cms | src/menu/QueryIterator.php | QueryIterator.getLoadedModel | public function getLoadedModel($id)
{
return isset($this->_loadModels[$id]) ? $this->_loadModels[$id] : null;
} | php | public function getLoadedModel($id)
{
return isset($this->_loadModels[$id]) ? $this->_loadModels[$id] : null;
} | [
"public",
"function",
"getLoadedModel",
"(",
"$",
"id",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_loadModels",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"_loadModels",
"[",
"$",
"id",
"]",
":",
"null",
";",
"}"
] | Get the model for a given id.
If the model was not preloaded by {{loadModels}} null is returned.
@param integer $id
@return null|\luya\cms\models\Nav | [
"Get",
"the",
"model",
"for",
"a",
"given",
"id",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/QueryIterator.php#L79-L82 |
luyadev/luya-module-cms | src/menu/QueryIterator.php | QueryIterator.current | public function current()
{
$data = current($this->data);
return Query::createItemObject($data, $this->lang, $this->getLoadedModel($data['id']));
} | php | public function current()
{
$data = current($this->data);
return Query::createItemObject($data, $this->lang, $this->getLoadedModel($data['id']));
} | [
"public",
"function",
"current",
"(",
")",
"{",
"$",
"data",
"=",
"current",
"(",
"$",
"this",
"->",
"data",
")",
";",
"return",
"Query",
"::",
"createItemObject",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"lang",
",",
"$",
"this",
"->",
"getLoadedMo... | Iterator get current element, generates a new object for the current item on accessing.s.
@return \luya\cms\menu\Item | [
"Iterator",
"get",
"current",
"element",
"generates",
"a",
"new",
"object",
"for",
"the",
"current",
"item",
"on",
"accessing",
".",
"s",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/QueryIterator.php#L89-L93 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.eventLogger | protected function eventLogger($event)
{
switch ($event->name) {
case 'afterInsert':
return Log::add(1, ['tableName' => 'cms_nav_item', 'action' => 'insert', 'row' => $this->id], 'cms_nav_item', $this->id, $this->toArray());
case 'afterUpdate':
return Log::add(2, ['tableName' => 'cms_nav_item', 'action' => 'update', 'row' => $this->id], 'cms_nav_item', $this->id, $this->toArray());
case 'afterDelete':
return Log::add(3, ['tableName' => 'cms_nav_item', 'action' => 'delete', 'row' => $this->id], 'cms_nav_item', $this->id, $this->toArray());
}
} | php | protected function eventLogger($event)
{
switch ($event->name) {
case 'afterInsert':
return Log::add(1, ['tableName' => 'cms_nav_item', 'action' => 'insert', 'row' => $this->id], 'cms_nav_item', $this->id, $this->toArray());
case 'afterUpdate':
return Log::add(2, ['tableName' => 'cms_nav_item', 'action' => 'update', 'row' => $this->id], 'cms_nav_item', $this->id, $this->toArray());
case 'afterDelete':
return Log::add(3, ['tableName' => 'cms_nav_item', 'action' => 'delete', 'row' => $this->id], 'cms_nav_item', $this->id, $this->toArray());
}
} | [
"protected",
"function",
"eventLogger",
"(",
"$",
"event",
")",
"{",
"switch",
"(",
"$",
"event",
"->",
"name",
")",
"{",
"case",
"'afterInsert'",
":",
"return",
"Log",
"::",
"add",
"(",
"1",
",",
"[",
"'tableName'",
"=>",
"'cms_nav_item'",
",",
"'action... | Log the current event in a database to retrieve data in case of emergency. This method will be trigger
on: EVENT_BEFORE_DELETE, EVENT_AFTER_INSERT & EVENT_AFTER_UPDATE
@param \yii\base\Event $event
@return boolean | [
"Log",
"the",
"current",
"event",
"in",
"a",
"database",
"to",
"retrieve",
"data",
"in",
"case",
"of",
"emergency",
".",
"This",
"method",
"will",
"be",
"trigger",
"on",
":",
"EVENT_BEFORE_DELETE",
"EVENT_AFTER_INSERT",
"&",
"EVENT_AFTER_UPDATE"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L86-L96 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.getType | public function getType()
{
if ($this->_type === null) {
// what kind of item type are we looking for
if ($this->nav_item_type == self::TYPE_PAGE) {
$this->_type = NavItemPage::findOne($this->nav_item_type_id);
} elseif ($this->nav_item_type == self::TYPE_MODULE) {
$this->_type = NavItemModule::findOne($this->nav_item_type_id);
} elseif ($this->nav_item_type == self::TYPE_REDIRECT) {
$this->_type = NavItemRedirect::findOne($this->nav_item_type_id);
}
if ($this->_type === null) {
$this->_type = false;
}
// set context for the object
/// 5.4.2016: Discontinue, as the type model does have getNavItem relation
//$this->_type->setNavItem($this);
}
return $this->_type;
} | php | public function getType()
{
if ($this->_type === null) {
// what kind of item type are we looking for
if ($this->nav_item_type == self::TYPE_PAGE) {
$this->_type = NavItemPage::findOne($this->nav_item_type_id);
} elseif ($this->nav_item_type == self::TYPE_MODULE) {
$this->_type = NavItemModule::findOne($this->nav_item_type_id);
} elseif ($this->nav_item_type == self::TYPE_REDIRECT) {
$this->_type = NavItemRedirect::findOne($this->nav_item_type_id);
}
if ($this->_type === null) {
$this->_type = false;
}
// set context for the object
/// 5.4.2016: Discontinue, as the type model does have getNavItem relation
//$this->_type->setNavItem($this);
}
return $this->_type;
} | [
"public",
"function",
"getType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_type",
"===",
"null",
")",
"{",
"// what kind of item type are we looking for",
"if",
"(",
"$",
"this",
"->",
"nav_item_type",
"==",
"self",
"::",
"TYPE_PAGE",
")",
"{",
"$",
"... | GET the type object based on the nav_item_type defintion and the nav_item_type_id which is the
primary key for the corresponding type table (page, module, redirect). This approach has been choosen
do dynamically extend type of pages whithout any limitation.
@return \luya\cms\models\NavItemPage|\luya\cms\models\NavItemModule|\luya\cms\models\NavItemRedirect Returns the object based on the type
@throws Exception | [
"GET",
"the",
"type",
"object",
"based",
"on",
"the",
"nav_item_type",
"defintion",
"and",
"the",
"nav_item_type_id",
"which",
"is",
"the",
"primary",
"key",
"for",
"the",
"corresponding",
"type",
"table",
"(",
"page",
"module",
"redirect",
")",
".",
"This",
... | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L160-L183 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.updateType | public function updateType(array $postData)
{
$model = $this->getType();
$model->setAttributes($postData);
return $model->update();
} | php | public function updateType(array $postData)
{
$model = $this->getType();
$model->setAttributes($postData);
return $model->update();
} | [
"public",
"function",
"updateType",
"(",
"array",
"$",
"postData",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"$",
"model",
"->",
"setAttributes",
"(",
"$",
"postData",
")",
";",
"return",
"$",
"model",
"->",
"update",
... | Update attributes of the current nav item type relation.
@param array $postData
@return boolean Whether the update has been successfull or not | [
"Update",
"attributes",
"of",
"the",
"current",
"nav",
"item",
"type",
"relation",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L211-L216 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.verifyAlias | public function verifyAlias($alias, $langId)
{
if (Yii::$app->hasModule($alias) && $this->parent_nav_id == 0) {
$this->addError('alias', Module::t('nav_item_model_error_modulenameexists', ['alias' => $alias]));
return false;
}
if ($this->parent_nav_id === null) {
$this->addError('parent_nav_id', Module::t('nav_item_model_error_parentnavidcannotnull'));
return false;
}
if ($this->find()->where(['alias' => $alias, 'lang_id' => $langId])->leftJoin('cms_nav', 'cms_nav_item.nav_id=cms_nav.id')->andWhere(['=', 'cms_nav.parent_nav_id', $this->parent_nav_id])->exists()) {
$this->addError('alias', Module::t('nav_item_model_error_urlsegementexistsalready'));
return false;
}
} | php | public function verifyAlias($alias, $langId)
{
if (Yii::$app->hasModule($alias) && $this->parent_nav_id == 0) {
$this->addError('alias', Module::t('nav_item_model_error_modulenameexists', ['alias' => $alias]));
return false;
}
if ($this->parent_nav_id === null) {
$this->addError('parent_nav_id', Module::t('nav_item_model_error_parentnavidcannotnull'));
return false;
}
if ($this->find()->where(['alias' => $alias, 'lang_id' => $langId])->leftJoin('cms_nav', 'cms_nav_item.nav_id=cms_nav.id')->andWhere(['=', 'cms_nav.parent_nav_id', $this->parent_nav_id])->exists()) {
$this->addError('alias', Module::t('nav_item_model_error_urlsegementexistsalready'));
return false;
}
} | [
"public",
"function",
"verifyAlias",
"(",
"$",
"alias",
",",
"$",
"langId",
")",
"{",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"hasModule",
"(",
"$",
"alias",
")",
"&&",
"$",
"this",
"->",
"parent_nav_id",
"==",
"0",
")",
"{",
"$",
"this",
"->",
... | Alias verification.
@param string $alias
@param integer $langId
@return boolean | [
"Alias",
"verification",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L234-L253 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.validateAlias | public function validateAlias()
{
$dirty = $this->getDirtyAttributes(['alias']);
if (!isset($dirty['alias'])) {
return true;
}
if (!$this->verifyAlias($this->alias, $this->lang_id)) {
return false;
}
} | php | public function validateAlias()
{
$dirty = $this->getDirtyAttributes(['alias']);
if (!isset($dirty['alias'])) {
return true;
}
if (!$this->verifyAlias($this->alias, $this->lang_id)) {
return false;
}
} | [
"public",
"function",
"validateAlias",
"(",
")",
"{",
"$",
"dirty",
"=",
"$",
"this",
"->",
"getDirtyAttributes",
"(",
"[",
"'alias'",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"dirty",
"[",
"'alias'",
"]",
")",
")",
"{",
"return",
"true",
... | Alias Validator.
@return boolean | [
"Alias",
"Validator",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L260-L270 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.beforeCreate | public function beforeCreate()
{
$this->timestamp_create = time();
$this->timestamp_update = 0;
$this->create_user_id = Module::getAuthorUserId();
$this->update_user_id = Module::getAuthorUserId();
$this->slugifyAlias();
} | php | public function beforeCreate()
{
$this->timestamp_create = time();
$this->timestamp_update = 0;
$this->create_user_id = Module::getAuthorUserId();
$this->update_user_id = Module::getAuthorUserId();
$this->slugifyAlias();
} | [
"public",
"function",
"beforeCreate",
"(",
")",
"{",
"$",
"this",
"->",
"timestamp_create",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"timestamp_update",
"=",
"0",
";",
"$",
"this",
"->",
"create_user_id",
"=",
"Module",
"::",
"getAuthorUserId",
"(",
... | Before create event. | [
"Before",
"create",
"event",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L275-L282 |
luyadev/luya-module-cms | src/models/NavItem.php | NavItem.eventBeforeUpdate | public function eventBeforeUpdate()
{
$this->timestamp_update = time();
$this->update_user_id = Module::getAuthorUserId();
$this->slugifyAlias();
} | php | public function eventBeforeUpdate()
{
$this->timestamp_update = time();
$this->update_user_id = Module::getAuthorUserId();
$this->slugifyAlias();
} | [
"public",
"function",
"eventBeforeUpdate",
"(",
")",
"{",
"$",
"this",
"->",
"timestamp_update",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"update_user_id",
"=",
"Module",
"::",
"getAuthorUserId",
"(",
")",
";",
"$",
"this",
"->",
"slugifyAlias",
"(",... | Before update event. | [
"Before",
"update",
"event",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/NavItem.php#L287-L292 |
luyadev/luya-module-cms | src/admin/apis/NavItemBlockController.php | NavItemBlockController.copySubBlocksTo | private function copySubBlocksTo($sourceId, $targetPrevId, $targetNavItemPageId)
{
if ($sourceId) {
$subBlocks = NavItemPageBlockItem::findAll(['prev_id' => $sourceId]);
foreach ($subBlocks as $block) {
$newBlock = new NavItemPageBlockItem();
$newBlock->attributes = $block->toArray();
$newBlock->nav_item_page_id = $targetNavItemPageId;
$newBlock->prev_id = $targetPrevId;
$newBlock->insert();
// check for attached sub blocks and start recursion
$attachedBlocks = NavItemPageBlockItem::findAll(['prev_id' => $block->id]);
if ($attachedBlocks) {
$this->copySubBlocksTo($block->id, $newBlock->id, $targetNavItemPageId);
}
}
}
} | php | private function copySubBlocksTo($sourceId, $targetPrevId, $targetNavItemPageId)
{
if ($sourceId) {
$subBlocks = NavItemPageBlockItem::findAll(['prev_id' => $sourceId]);
foreach ($subBlocks as $block) {
$newBlock = new NavItemPageBlockItem();
$newBlock->attributes = $block->toArray();
$newBlock->nav_item_page_id = $targetNavItemPageId;
$newBlock->prev_id = $targetPrevId;
$newBlock->insert();
// check for attached sub blocks and start recursion
$attachedBlocks = NavItemPageBlockItem::findAll(['prev_id' => $block->id]);
if ($attachedBlocks) {
$this->copySubBlocksTo($block->id, $newBlock->id, $targetNavItemPageId);
}
}
}
} | [
"private",
"function",
"copySubBlocksTo",
"(",
"$",
"sourceId",
",",
"$",
"targetPrevId",
",",
"$",
"targetNavItemPageId",
")",
"{",
"if",
"(",
"$",
"sourceId",
")",
"{",
"$",
"subBlocks",
"=",
"NavItemPageBlockItem",
"::",
"findAll",
"(",
"[",
"'prev_id'",
... | Copy all attached sub blocks (referencing sourceId) into new context and update prevId to sourceId
@param $sourceId
@param $targetPrevId
@param $targetNavItemPageId | [
"Copy",
"all",
"attached",
"sub",
"blocks",
"(",
"referencing",
"sourceId",
")",
"into",
"new",
"context",
"and",
"update",
"prevId",
"to",
"sourceId"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/admin/apis/NavItemBlockController.php#L23-L41 |
luyadev/luya-module-cms | src/models/Property.php | Property.getObject | public function getObject()
{
if ($this->_object === null) {
$this->_object = $this->adminProperty->createObject($this->value);
}
return $this->_object;
} | php | public function getObject()
{
if ($this->_object === null) {
$this->_object = $this->adminProperty->createObject($this->value);
}
return $this->_object;
} | [
"public",
"function",
"getObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_object",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_object",
"=",
"$",
"this",
"->",
"adminProperty",
"->",
"createObject",
"(",
"$",
"this",
"->",
"value",
")",
";"... | Create the Property object with the given value.
@return \luya\admin\base\Property | [
"Create",
"the",
"Property",
"object",
"with",
"the",
"given",
"value",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/Property.php#L54-L61 |
luyadev/luya-module-cms | src/admin/aws/BlockPagesActiveWindow.php | BlockPagesActiveWindow.index | public function index()
{
return $this->render('index', [
'pages' => $this->model->getNavItemPageBlockItems()->select(['nav_item_page_id'])->distinct()->orderBy([])->all(),
]);
} | php | public function index()
{
return $this->render('index', [
'pages' => $this->model->getNavItemPageBlockItems()->select(['nav_item_page_id'])->distinct()->orderBy([])->all(),
]);
} | [
"public",
"function",
"index",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'pages'",
"=>",
"$",
"this",
"->",
"model",
"->",
"getNavItemPageBlockItems",
"(",
")",
"->",
"select",
"(",
"[",
"'nav_item_page_id'",
"]",
"... | The default action which is going to be requested when clicking the ActiveWindow.
@return string The response string, render and displayed trough the angular ajax request. | [
"The",
"default",
"action",
"which",
"is",
"going",
"to",
"be",
"requested",
"when",
"clicking",
"the",
"ActiveWindow",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/admin/aws/BlockPagesActiveWindow.php#L44-L49 |
luyadev/luya-module-cms | src/frontend/blocks/ModuleBlock.php | ModuleBlock.getControllerClasses | public function getControllerClasses()
{
$moduleName = $this->getVarValue('moduleName', false);
return (empty($moduleName) || !Yii::$app->hasModule($moduleName)) ? [] : Yii::$app->getModule($moduleName)->getControllerFiles();
} | php | public function getControllerClasses()
{
$moduleName = $this->getVarValue('moduleName', false);
return (empty($moduleName) || !Yii::$app->hasModule($moduleName)) ? [] : Yii::$app->getModule($moduleName)->getControllerFiles();
} | [
"public",
"function",
"getControllerClasses",
"(",
")",
"{",
"$",
"moduleName",
"=",
"$",
"this",
"->",
"getVarValue",
"(",
"'moduleName'",
",",
"false",
")",
";",
"return",
"(",
"empty",
"(",
"$",
"moduleName",
")",
"||",
"!",
"Yii",
"::",
"$",
"app",
... | Get all module related controllers.
@return array | [
"Get",
"all",
"module",
"related",
"controllers",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/frontend/blocks/ModuleBlock.php#L110-L115 |
luyadev/luya-module-cms | src/frontend/blocks/ModuleBlock.php | ModuleBlock.getModuleNames | public function getModuleNames()
{
$data = [];
foreach (Yii::$app->getFrontendModules() as $k => $f) {
$data[] = ['value' => $k, 'label' => $k];
}
return $data;
} | php | public function getModuleNames()
{
$data = [];
foreach (Yii::$app->getFrontendModules() as $k => $f) {
$data[] = ['value' => $k, 'label' => $k];
}
return $data;
} | [
"public",
"function",
"getModuleNames",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
"getFrontendModules",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"f",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"[",
"'... | Get all available frontend modules to make module selection in block.
@return array | [
"Get",
"all",
"available",
"frontend",
"modules",
"to",
"make",
"module",
"selection",
"in",
"block",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/frontend/blocks/ModuleBlock.php#L122-L129 |
luyadev/luya-module-cms | src/frontend/blocks/ModuleBlock.php | ModuleBlock.moduleContent | public function moduleContent($moduleName)
{
if ($this->isAdminContext() || empty($moduleName) || count($this->getEnvOptions()) === 0 || !Yii::$app->hasModule($moduleName)) {
return;
}
// get module
$module = Yii::$app->getModule($moduleName);
$module->context = 'cms';
// start module reflection
$reflection = Yii::createObject(['class' => ModuleReflection::class, 'module' => $module]);
$reflection->suffix = $this->getEnvOption('restString');
$args = Json::decode($this->getCfgValue('moduleActionArgs', '{}'));
// if a controller has been defined we inject a custom starting route for the
// module reflection object.
$ctrl = $this->getCfgValue('moduleController');
if (!empty($ctrl)) {
$reflection->defaultRoute($ctrl, $this->getCfgValue('moduleAction', 'index'), $args);
}
if ($this->getCfgValue('strictRender')) {
$reflection->setRequestRoute(implode("/", [$this->getCfgValue('moduleController', $module->defaultRoute), $this->getCfgValue('moduleAction', 'index')]), $args);
} else {
Yii::$app->request->queryParams = array_merge($reflection->getRequestRoute()['args'], Yii::$app->request->queryParams);
}
$response = $reflection->run();
if ($response instanceof Response) {
return Yii::$app->end(0, $response);
}
return $response;
} | php | public function moduleContent($moduleName)
{
if ($this->isAdminContext() || empty($moduleName) || count($this->getEnvOptions()) === 0 || !Yii::$app->hasModule($moduleName)) {
return;
}
// get module
$module = Yii::$app->getModule($moduleName);
$module->context = 'cms';
// start module reflection
$reflection = Yii::createObject(['class' => ModuleReflection::class, 'module' => $module]);
$reflection->suffix = $this->getEnvOption('restString');
$args = Json::decode($this->getCfgValue('moduleActionArgs', '{}'));
// if a controller has been defined we inject a custom starting route for the
// module reflection object.
$ctrl = $this->getCfgValue('moduleController');
if (!empty($ctrl)) {
$reflection->defaultRoute($ctrl, $this->getCfgValue('moduleAction', 'index'), $args);
}
if ($this->getCfgValue('strictRender')) {
$reflection->setRequestRoute(implode("/", [$this->getCfgValue('moduleController', $module->defaultRoute), $this->getCfgValue('moduleAction', 'index')]), $args);
} else {
Yii::$app->request->queryParams = array_merge($reflection->getRequestRoute()['args'], Yii::$app->request->queryParams);
}
$response = $reflection->run();
if ($response instanceof Response) {
return Yii::$app->end(0, $response);
}
return $response;
} | [
"public",
"function",
"moduleContent",
"(",
"$",
"moduleName",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAdminContext",
"(",
")",
"||",
"empty",
"(",
"$",
"moduleName",
")",
"||",
"count",
"(",
"$",
"this",
"->",
"getEnvOptions",
"(",
")",
")",
"===",... | Return the Module output based on the module name.
@param string $moduleName
@return string|null|\yii\web\Response | [
"Return",
"the",
"Module",
"output",
"based",
"on",
"the",
"module",
"name",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/frontend/blocks/ModuleBlock.php#L137-L173 |
luyadev/luya-module-cms | src/admin/apis/RedirectController.php | RedirectController.actionCatch | public function actionCatch($path)
{
$compositePath = Yii::$app->composition->prependTo($path);
foreach (Redirect::find()->all() as $redirect) {
if ($redirect->matchRequestPath($path)) {
return $redirect;
}
// if its a multi linguage website and the language has not been omited form request path compare this version too.
// this is requred since the luya UrlManager can change the pathInfo
if ($path !== $compositePath) {
if ($redirect->matchRequestPath($compositePath)) {
return $redirect;
}
}
}
return false;
} | php | public function actionCatch($path)
{
$compositePath = Yii::$app->composition->prependTo($path);
foreach (Redirect::find()->all() as $redirect) {
if ($redirect->matchRequestPath($path)) {
return $redirect;
}
// if its a multi linguage website and the language has not been omited form request path compare this version too.
// this is requred since the luya UrlManager can change the pathInfo
if ($path !== $compositePath) {
if ($redirect->matchRequestPath($compositePath)) {
return $redirect;
}
}
}
return false;
} | [
"public",
"function",
"actionCatch",
"(",
"$",
"path",
")",
"{",
"$",
"compositePath",
"=",
"Yii",
"::",
"$",
"app",
"->",
"composition",
"->",
"prependTo",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"Redirect",
"::",
"find",
"(",
")",
"->",
"all",
... | Find a redirect object for a given path info.
An example using path would be: Yii::$app->request->pathInfo
url: https://example.com/hello/world
path: hello/world
@param string $path The path to check inside the redirect list.
@return array|false
@since 1.0.9 | [
"Find",
"a",
"redirect",
"object",
"for",
"a",
"given",
"path",
"info",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/admin/apis/RedirectController.php#L32-L50 |
luyadev/luya-module-cms | src/models/Layout.php | Layout.getJsonConfig | public function getJsonConfig($node = null)
{
$json = Json::decode($this->json_config);
if (!$node) {
return $json;
}
if (isset($json[$node])) {
return $json[$node];
}
return [];
} | php | public function getJsonConfig($node = null)
{
$json = Json::decode($this->json_config);
if (!$node) {
return $json;
}
if (isset($json[$node])) {
return $json[$node];
}
return [];
} | [
"public",
"function",
"getJsonConfig",
"(",
"$",
"node",
"=",
"null",
")",
"{",
"$",
"json",
"=",
"Json",
"::",
"decode",
"(",
"$",
"this",
"->",
"json_config",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"return",
"$",
"json",
";",
"}",
"if... | Get the json config as array.
@param string $node Get a given key from the config array.
@return array If the given node is not found an empty array will be returned. | [
"Get",
"the",
"json",
"config",
"as",
"array",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/models/Layout.php#L78-L91 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getLink | public function getLink()
{
// take care of redirect
if ($this->getType() === 3 && !empty($this->redirectMapData('value'))) {
// generate convert object to determine correctn usage.
$converter = new LinkConverter([
'type' => $this->redirectMapData('type'),
'value' => $this->redirectMapData('value'),
'target' => $this->redirectMapData('target'),
]);
if ($this->redirectMapData('target')) {
$this->setTarget($this->redirectMapData('target'));
}
switch ($converter->type) {
case $converter::TYPE_EXTERNAL_URL:
return $converter->getWebsiteLink($converter->value, $converter->target)->getHref();
case $converter::TYPE_INTERNAL_PAGE:
if (empty($converter->value) || $converter->value == $this->navId) {
return;
}
$page = $converter->getPageLink($converter->value, $converter->target, $this->lang);
return $page ? $page->getHref() : '';
case $converter::TYPE_LINK_TO_EMAIL:
return $converter->getEmailLink($converter->value)->getHref();
case $converter::TYPE_LINK_TO_FILE:
return $converter->getFileLink($converter->value, $converter->target)->getHref();
case $converter::TYPE_LINK_TO_TELEPHONE:
return $converter->getTelephoneLink($converter->value)->getHref();
}
}
// if its the homepage and the default lang short code is equasl to this lang the link has no path.
if ($this->itemArray['is_home'] && Yii::$app->composition->defaultLangShortCode == $this->itemArray['lang']) {
return Yii::$app->urlManager->prependBaseUrl('');
}
return $this->itemArray['link'];
} | php | public function getLink()
{
// take care of redirect
if ($this->getType() === 3 && !empty($this->redirectMapData('value'))) {
// generate convert object to determine correctn usage.
$converter = new LinkConverter([
'type' => $this->redirectMapData('type'),
'value' => $this->redirectMapData('value'),
'target' => $this->redirectMapData('target'),
]);
if ($this->redirectMapData('target')) {
$this->setTarget($this->redirectMapData('target'));
}
switch ($converter->type) {
case $converter::TYPE_EXTERNAL_URL:
return $converter->getWebsiteLink($converter->value, $converter->target)->getHref();
case $converter::TYPE_INTERNAL_PAGE:
if (empty($converter->value) || $converter->value == $this->navId) {
return;
}
$page = $converter->getPageLink($converter->value, $converter->target, $this->lang);
return $page ? $page->getHref() : '';
case $converter::TYPE_LINK_TO_EMAIL:
return $converter->getEmailLink($converter->value)->getHref();
case $converter::TYPE_LINK_TO_FILE:
return $converter->getFileLink($converter->value, $converter->target)->getHref();
case $converter::TYPE_LINK_TO_TELEPHONE:
return $converter->getTelephoneLink($converter->value)->getHref();
}
}
// if its the homepage and the default lang short code is equasl to this lang the link has no path.
if ($this->itemArray['is_home'] && Yii::$app->composition->defaultLangShortCode == $this->itemArray['lang']) {
return Yii::$app->urlManager->prependBaseUrl('');
}
return $this->itemArray['link'];
} | [
"public",
"function",
"getLink",
"(",
")",
"{",
"// take care of redirect",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"3",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"redirectMapData",
"(",
"'value'",
")",
")",
")",
"{",
"// generate con... | Returns the current item link relative path with composition (language). The
path is always relativ to the host.
Hidden links will be returned from getLink. So if you make a link
from a page to a hidden page, the link of the hidden page will be returned and the link
will be successfully displayed
@return string The link path `/home/about-us` or with composition `/de/home/about-us` | [
"Returns",
"the",
"current",
"item",
"link",
"relative",
"path",
"with",
"composition",
"(",
"language",
")",
".",
"The",
"path",
"is",
"always",
"relativ",
"to",
"the",
"host",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L418-L459 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getParent | public function getParent()
{
return (new Query())->where(['nav_id' => $this->parentNavId, 'container' => $this->getContainer()])->with($this->_with)->lang($this->lang)->one();
} | php | public function getParent()
{
return (new Query())->where(['nav_id' => $this->parentNavId, 'container' => $this->getContainer()])->with($this->_with)->lang($this->lang)->one();
} | [
"public",
"function",
"getParent",
"(",
")",
"{",
"return",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"where",
"(",
"[",
"'nav_id'",
"=>",
"$",
"this",
"->",
"parentNavId",
",",
"'container'",
"=>",
"$",
"this",
"->",
"getContainer",
"(",
")",
"]",
"... | Returns a Item-Object of the parent element, if no parent element exists returns false.
@return \luya\cms\menu\Item|boolean Returns the parent item-object or false if not exists. | [
"Returns",
"a",
"Item",
"-",
"Object",
"of",
"the",
"parent",
"element",
"if",
"no",
"parent",
"element",
"exists",
"returns",
"false",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L511-L514 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getParents | public function getParents()
{
$parent = $this->with($this->_with)->getParent();
$data = [];
while ($parent) {
$data[] = $parent;
$parent = $parent->with($this->_with)->getParent();
}
return array_reverse($data);
} | php | public function getParents()
{
$parent = $this->with($this->_with)->getParent();
$data = [];
while ($parent) {
$data[] = $parent;
$parent = $parent->with($this->_with)->getParent();
}
return array_reverse($data);
} | [
"public",
"function",
"getParents",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"with",
"(",
"$",
"this",
"->",
"_with",
")",
"->",
"getParent",
"(",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"parent",
")",
"{",
"$... | Return all parent elements **without** the current item.
@return array An array with Item-Objects. | [
"Return",
"all",
"parent",
"elements",
"**",
"without",
"**",
"the",
"current",
"item",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L521-L531 |
luyadev/luya-module-cms | src/menu/Item.php | Item.down | public function down(callable $fn)
{
$parent = $this->with($this->_with)->getParent();
while ($parent) {
$response = call_user_func_array($fn, [$parent]);
if ($response) {
return $response;
}
$parent = $parent->with($this->_with)->getParent();
}
return false;
} | php | public function down(callable $fn)
{
$parent = $this->with($this->_with)->getParent();
while ($parent) {
$response = call_user_func_array($fn, [$parent]);
if ($response) {
return $response;
}
$parent = $parent->with($this->_with)->getParent();
}
return false;
} | [
"public",
"function",
"down",
"(",
"callable",
"$",
"fn",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"with",
"(",
"$",
"this",
"->",
"_with",
")",
"->",
"getParent",
"(",
")",
";",
"while",
"(",
"$",
"parent",
")",
"{",
"$",
"response",
"="... | Go down to a given element which is evalutaed trough a callable.
Iterate trough parent elements until the last.
```php
$item = Yii::$app->menu->current->down(function(Item $item) {
if ($item->depth == 1) {
return $item;
}
});
```
@param callable $fn A function which holds the current iterated item.
@return static|boolean If no item has been picked, false is returned.
@since 1.0.9 | [
"Go",
"down",
"to",
"a",
"given",
"element",
"which",
"is",
"evalutaed",
"trough",
"a",
"callable",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L550-L562 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getSiblings | public function getSiblings()
{
return (new Query())->where(['parent_nav_id' => $this->parentNavId, 'container' => $this->container])->with($this->_with)->lang($this->lang)->all();
} | php | public function getSiblings()
{
return (new Query())->where(['parent_nav_id' => $this->parentNavId, 'container' => $this->container])->with($this->_with)->lang($this->lang)->all();
} | [
"public",
"function",
"getSiblings",
"(",
")",
"{",
"return",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"where",
"(",
"[",
"'parent_nav_id'",
"=>",
"$",
"this",
"->",
"parentNavId",
",",
"'container'",
"=>",
"$",
"this",
"->",
"container",
"]",
")",
"-... | Get all sibilings for the current item, this also includes the current item iteself.
@return array An array with all item-object siblings | [
"Get",
"all",
"sibilings",
"for",
"the",
"current",
"item",
"this",
"also",
"includes",
"the",
"current",
"item",
"iteself",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L569-L572 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getNextSibling | public function getNextSibling()
{
return (new Query())
->where(['parent_nav_id' => $this->parentNavId, 'container' => $this->container])
->andWhere(['>', 'sort_index', $this->sortIndex])
->with($this->_with)
->lang($this->lang)
->orderBy(['sort_index' => SORT_ASC])
->one();
} | php | public function getNextSibling()
{
return (new Query())
->where(['parent_nav_id' => $this->parentNavId, 'container' => $this->container])
->andWhere(['>', 'sort_index', $this->sortIndex])
->with($this->_with)
->lang($this->lang)
->orderBy(['sort_index' => SORT_ASC])
->one();
} | [
"public",
"function",
"getNextSibling",
"(",
")",
"{",
"return",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"where",
"(",
"[",
"'parent_nav_id'",
"=>",
"$",
"this",
"->",
"parentNavId",
",",
"'container'",
"=>",
"$",
"this",
"->",
"container",
"]",
")",
... | Get the next sibling in the current siblings list.
If there is no next sibling (assuming its the last sibling item in the list) false is returned, otherwise the {{luya\cms\menu\Item}} is returned.
@return \luya\cms\menu\Item|boolean Returns the next sibling based on the current sibling, if not found false is returned. | [
"Get",
"the",
"next",
"sibling",
"in",
"the",
"current",
"siblings",
"list",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L581-L590 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getPrevSibling | public function getPrevSibling()
{
return (new Query())
->where(['parent_nav_id' => $this->parentNavId, 'container' => $this->container])
->andWhere(['<', 'sort_index', $this->sortIndex])
->with($this->_with)
->lang($this->lang)
->orderBy(['sort_index' => SORT_DESC])
->one();
} | php | public function getPrevSibling()
{
return (new Query())
->where(['parent_nav_id' => $this->parentNavId, 'container' => $this->container])
->andWhere(['<', 'sort_index', $this->sortIndex])
->with($this->_with)
->lang($this->lang)
->orderBy(['sort_index' => SORT_DESC])
->one();
} | [
"public",
"function",
"getPrevSibling",
"(",
")",
"{",
"return",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"where",
"(",
"[",
"'parent_nav_id'",
"=>",
"$",
"this",
"->",
"parentNavId",
",",
"'container'",
"=>",
"$",
"this",
"->",
"container",
"]",
")",
... | Get the previous sibling in the current siblings list.
If there is no previous sibling (assuming its the first sibling item in the list) false is returned, otherwise the {{luya\cms\menu\Item}} is returned.
@return \luya\cms\menu\Item|boolean Returns the previous sibling based on the current sibling, if not found false is returned. | [
"Get",
"the",
"previous",
"sibling",
"in",
"the",
"current",
"siblings",
"list",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L599-L608 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getTeardown | public function getTeardown()
{
$parent = $this->with($this->_with)->getParent();
$current = $this;
$data[$current->id] = $current;
while ($parent) {
$data[$parent->id] = $parent;
$parent = $parent->with($this->_with)->getParent();
}
return array_reverse($data, true);
} | php | public function getTeardown()
{
$parent = $this->with($this->_with)->getParent();
$current = $this;
$data[$current->id] = $current;
while ($parent) {
$data[$parent->id] = $parent;
$parent = $parent->with($this->_with)->getParent();
}
return array_reverse($data, true);
} | [
"public",
"function",
"getTeardown",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"with",
"(",
"$",
"this",
"->",
"_with",
")",
"->",
"getParent",
"(",
")",
";",
"$",
"current",
"=",
"$",
"this",
";",
"$",
"data",
"[",
"$",
"current",
"-... | Return all parent elements **with** the current item.
@return array An array with Item-Objects. | [
"Return",
"all",
"parent",
"elements",
"**",
"with",
"**",
"the",
"current",
"item",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L615-L626 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getChildren | public function getChildren()
{
return (new Query())->where(['parent_nav_id' => $this->navId, 'container' => $this->getContainer()])->with($this->_with)->lang($this->lang)->all();
} | php | public function getChildren()
{
return (new Query())->where(['parent_nav_id' => $this->navId, 'container' => $this->getContainer()])->with($this->_with)->lang($this->lang)->all();
} | [
"public",
"function",
"getChildren",
"(",
")",
"{",
"return",
"(",
"new",
"Query",
"(",
")",
")",
"->",
"where",
"(",
"[",
"'parent_nav_id'",
"=>",
"$",
"this",
"->",
"navId",
",",
"'container'",
"=>",
"$",
"this",
"->",
"getContainer",
"(",
")",
"]",
... | Get all children of the current item. Children means going the depth/menulevel down e.g. from 1 to 2.
@return \luya\cms\menu\QueryIterator Returns all children | [
"Get",
"all",
"children",
"of",
"the",
"current",
"item",
".",
"Children",
"means",
"going",
"the",
"depth",
"/",
"menulevel",
"down",
"e",
".",
"g",
".",
"from",
"1",
"to",
"2",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L633-L636 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getModel | public function getModel()
{
if ($this->_model === null) {
$this->_model = Nav::findOne($this->navId);
if (empty($this->_model)) {
throw new Exception('The model active record could not be found for the corresponding nav item. Maybe you have inconsistent Database data.');
}
}
return $this->_model;
} | php | public function getModel()
{
if ($this->_model === null) {
$this->_model = Nav::findOne($this->navId);
if (empty($this->_model)) {
throw new Exception('The model active record could not be found for the corresponding nav item. Maybe you have inconsistent Database data.');
}
}
return $this->_model;
} | [
"public",
"function",
"getModel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_model",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_model",
"=",
"Nav",
"::",
"findOne",
"(",
"$",
"this",
"->",
"navId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
... | Get the ActiveRecord Model for the current Nav Model.
@throws \luya\cms\Exception
@return \luya\cms\models\Nav Returns the {{\luya\cms\models\Nav}} object for the current navigation item. | [
"Get",
"the",
"ActiveRecord",
"Model",
"for",
"the",
"current",
"Nav",
"Model",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L656-L667 |
luyadev/luya-module-cms | src/menu/Item.php | Item.getPropertyValue | public function getPropertyValue($varName, $defaultValue = null)
{
return $this->getProperty($varName) ? $this->getProperty($varName)->getValue() : $defaultValue;
} | php | public function getPropertyValue($varName, $defaultValue = null)
{
return $this->getProperty($varName) ? $this->getProperty($varName)->getValue() : $defaultValue;
} | [
"public",
"function",
"getPropertyValue",
"(",
"$",
"varName",
",",
"$",
"defaultValue",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"varName",
")",
"?",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"varName",
")",
"->",
... | Get the value of a Property Object.
Compared to {{luya\cms\menu\Item::getProperty}} this method returns only the value for a given property. If the
property is not assigned for the current Menu Item the $defaultValue will be returned, which is null by default.
@param string $varName The variable name of the property defined in the method {{luya\\admin\base\Property::varName}}
@param mixed $defaultValue The default value which will be returned if the property is not set for the current page.
@return string|mixed Returns the value of {{luya\admin\base\Property::getValue}} if set, otherwise $defaultValue. | [
"Get",
"the",
"value",
"of",
"a",
"Property",
"Object",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L706-L709 |
luyadev/luya-module-cms | src/menu/Item.php | Item.without | public function without($without)
{
$without = (array) $without;
foreach ($without as $expression) {
$key = array_search($expression, $this->_with);
if ($key !== false) {
unset($this->_with[$key]);
}
}
return $this;
} | php | public function without($without)
{
$without = (array) $without;
foreach ($without as $expression) {
$key = array_search($expression, $this->_with);
if ($key !== false) {
unset($this->_with[$key]);
}
}
return $this;
} | [
"public",
"function",
"without",
"(",
"$",
"without",
")",
"{",
"$",
"without",
"=",
"(",
"array",
")",
"$",
"without",
";",
"foreach",
"(",
"$",
"without",
"as",
"$",
"expression",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"expression",
"... | Unset a value from the `with()` method. Lets assume you want to to get the children with hidden
```php
foreach ($item->with('hidden')->children as $child) {
// but get the sibilings without the hidden state
$siblings = $child->without('hidden')->siblings;
}
```
@param string|array $without Can be a string `hidden` or an array `['hidden']`.
@return \luya\cms\menu\Item | [
"Unset",
"a",
"value",
"from",
"the",
"with",
"()",
"method",
".",
"Lets",
"assume",
"you",
"want",
"to",
"to",
"get",
"the",
"children",
"with",
"hidden"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/menu/Item.php#L753-L765 |
luyadev/luya-module-cms | src/Menu.php | Menu.getLanguageContainer | public function getLanguageContainer($langShortCode)
{
if (!array_key_exists($langShortCode, $this->_languageContainer)) {
$this->_languageContainer[$langShortCode] = $this->loadLanguageContainer($langShortCode);
$this->trigger(self::EVENT_AFTER_LOAD);
}
return $this->_languageContainer[$langShortCode];
} | php | public function getLanguageContainer($langShortCode)
{
if (!array_key_exists($langShortCode, $this->_languageContainer)) {
$this->_languageContainer[$langShortCode] = $this->loadLanguageContainer($langShortCode);
$this->trigger(self::EVENT_AFTER_LOAD);
}
return $this->_languageContainer[$langShortCode];
} | [
"public",
"function",
"getLanguageContainer",
"(",
"$",
"langShortCode",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"langShortCode",
",",
"$",
"this",
"->",
"_languageContainer",
")",
")",
"{",
"$",
"this",
"->",
"_languageContainer",
"[",
"$",
... | Load and return the language container for the specific langShortCode, this method is used
when using the ArrayAccess offsetGet() method.
@param string $langShortCode A language short code which have to access in $this->getLanguages().
@return array An array containing all items in theyr keys for the provided language short code. | [
"Load",
"and",
"return",
"the",
"language",
"container",
"for",
"the",
"specific",
"langShortCode",
"this",
"method",
"is",
"used",
"when",
"using",
"the",
"ArrayAccess",
"offsetGet",
"()",
"method",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L319-L327 |
luyadev/luya-module-cms | src/Menu.php | Menu.getLanguage | public function getLanguage($shortCode)
{
return (array_key_exists($shortCode, $this->getLanguages())) ? $this->getLanguages()[$shortCode] : false;
} | php | public function getLanguage($shortCode)
{
return (array_key_exists($shortCode, $this->getLanguages())) ? $this->getLanguages()[$shortCode] : false;
} | [
"public",
"function",
"getLanguage",
"(",
"$",
"shortCode",
")",
"{",
"return",
"(",
"array_key_exists",
"(",
"$",
"shortCode",
",",
"$",
"this",
"->",
"getLanguages",
"(",
")",
")",
")",
"?",
"$",
"this",
"->",
"getLanguages",
"(",
")",
"[",
"$",
"sho... | Get languag information for a specific language short code.
@param string $shortCode E.g. de or en
@return array|boolean If the shortCode exists an array with informations as returned, otherwise false. | [
"Get",
"languag",
"information",
"for",
"a",
"specific",
"language",
"short",
"code",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L335-L338 |
luyadev/luya-module-cms | src/Menu.php | Menu.getLanguages | public function getLanguages()
{
if ($this->_languages === null) {
$this->_languages = (new DbQuery())->select(['short_code', 'id'])->indexBy('short_code')->from('admin_lang')->all();
}
return $this->_languages;
} | php | public function getLanguages()
{
if ($this->_languages === null) {
$this->_languages = (new DbQuery())->select(['short_code', 'id'])->indexBy('short_code')->from('admin_lang')->all();
}
return $this->_languages;
} | [
"public",
"function",
"getLanguages",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_languages",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_languages",
"=",
"(",
"new",
"DbQuery",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'short_code'",
",",
"'id'... | Get an array with all available system languages based on the admin_lang table.
@return array An array where the key is the short_code and the value an array containing shortcode and id. | [
"Get",
"an",
"array",
"with",
"all",
"available",
"system",
"languages",
"based",
"on",
"the",
"admin_lang",
"table",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L345-L352 |
luyadev/luya-module-cms | src/Menu.php | Menu.getRedirectMap | public function getRedirectMap()
{
if ($this->_redirectMap === null) {
$this->_redirectMap = (new DbQuery())->select(['id', 'type', 'value', 'target'])->from('cms_nav_item_redirect')->indexBy('id')->all();
}
return $this->_redirectMap;
} | php | public function getRedirectMap()
{
if ($this->_redirectMap === null) {
$this->_redirectMap = (new DbQuery())->select(['id', 'type', 'value', 'target'])->from('cms_nav_item_redirect')->indexBy('id')->all();
}
return $this->_redirectMap;
} | [
"public",
"function",
"getRedirectMap",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_redirectMap",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_redirectMap",
"=",
"(",
"new",
"DbQuery",
"(",
")",
")",
"->",
"select",
"(",
"[",
"'id'",
",",
"'type'... | Get an array containing all redirect items from the database table cms_nav_item_redirect.
@return array An array where the key is the id and the value an array containing id, type and value. | [
"Get",
"an",
"array",
"containing",
"all",
"redirect",
"items",
"from",
"the",
"database",
"table",
"cms_nav_item_redirect",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L359-L366 |
luyadev/luya-module-cms | src/Menu.php | Menu.getCurrentAppendix | public function getCurrentAppendix()
{
if ($this->_current === null) {
$this->_current = $this->resolveCurrent();
}
return $this->_currentAppendix;
} | php | public function getCurrentAppendix()
{
if ($this->_current === null) {
$this->_current = $this->resolveCurrent();
}
return $this->_currentAppendix;
} | [
"public",
"function",
"getCurrentAppendix",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_current",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_current",
"=",
"$",
"this",
"->",
"resolveCurrent",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_... | Returns the parts of the rules who do not belong to the current active menu item link.
For instance the current menu link is `/de/company/news` where this
page is declared as a module with urlRules, controllers and actions. If the url path is `/de/company/news/detail/my-first-news` the
appendix would be `detail/my-first-news`.
@return string The url part not related for the current active link | [
"Returns",
"the",
"parts",
"of",
"the",
"rules",
"who",
"do",
"not",
"belong",
"to",
"the",
"current",
"active",
"menu",
"item",
"link",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L377-L384 |
luyadev/luya-module-cms | src/Menu.php | Menu.getCurrent | public function getCurrent()
{
if ($this->_current === null) {
$this->_current = $this->resolveCurrent();
$this->trigger(self::EVENT_AFTER_RESOLVE_CURRENT);
}
return $this->_current;
} | php | public function getCurrent()
{
if ($this->_current === null) {
$this->_current = $this->resolveCurrent();
$this->trigger(self::EVENT_AFTER_RESOLVE_CURRENT);
}
return $this->_current;
} | [
"public",
"function",
"getCurrent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_current",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_current",
"=",
"$",
"this",
"->",
"resolveCurrent",
"(",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
... | Get the current menu item resolved by active language (from composition).
@return \luya\cms\menu\Item An item-object for the current active item. | [
"Get",
"the",
"current",
"menu",
"item",
"resolved",
"by",
"active",
"language",
"(",
"from",
"composition",
")",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L403-L411 |
luyadev/luya-module-cms | src/Menu.php | Menu.getLevelContainer | public function getLevelContainer($level, Item $baseItem = null)
{
// define if the requested level is the root line (level 1) or not
$rootLine = ($level === 1) ? true : false;
// countdown the level (as we need the parent of the element to get the children
$level--;
// foreach counter
$i = 1;
if ($baseItem === null) {
$baseItem = $this->getCurrent();
}
// foreach
foreach ($baseItem->with('hidden')->getTeardown() as $item) {
// if its the root line an match level 1 get all siblings
if ($rootLine && $i == 1) {
return $item->without(['hidden'])->siblings;
} elseif ($i == $level) {
return $item->without(['hidden'])->children;
}
$i++;
}
// no no container found for the defined level
return [];
} | php | public function getLevelContainer($level, Item $baseItem = null)
{
// define if the requested level is the root line (level 1) or not
$rootLine = ($level === 1) ? true : false;
// countdown the level (as we need the parent of the element to get the children
$level--;
// foreach counter
$i = 1;
if ($baseItem === null) {
$baseItem = $this->getCurrent();
}
// foreach
foreach ($baseItem->with('hidden')->getTeardown() as $item) {
// if its the root line an match level 1 get all siblings
if ($rootLine && $i == 1) {
return $item->without(['hidden'])->siblings;
} elseif ($i == $level) {
return $item->without(['hidden'])->children;
}
$i++;
}
// no no container found for the defined level
return [];
} | [
"public",
"function",
"getLevelContainer",
"(",
"$",
"level",
",",
"Item",
"$",
"baseItem",
"=",
"null",
")",
"{",
"// define if the requested level is the root line (level 1) or not",
"$",
"rootLine",
"=",
"(",
"$",
"level",
"===",
"1",
")",
"?",
"true",
":",
"... | Get all items for a specific level.
@param integer $level Define the level you like to get the items from, the hirarchy starts by the level 1, which is the root line.
@param \luya\cms\menu\Item $baseItem Provide an optional element which represents the base calculation item for Theme
siblings/children calculation, this can be case when you have several contains do not want to use the "current" Item
as base calucation, because getCurrent() could be in another container so it would get you all level container items for
this container.
@return array|\luya\cms\menu\QueryIterator All siblings or children items, if not found an empty array will return. | [
"Get",
"all",
"items",
"for",
"a",
"specific",
"level",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L423-L448 |
luyadev/luya-module-cms | src/Menu.php | Menu.getLevelCurrent | public function getLevelCurrent($level)
{
$i = 1;
foreach ($this->getCurrent()->with('hidden')->getTeardown() as $item) {
if ($i == $level) {
return $item;
}
++$i;
}
return false;
} | php | public function getLevelCurrent($level)
{
$i = 1;
foreach ($this->getCurrent()->with('hidden')->getTeardown() as $item) {
if ($i == $level) {
return $item;
}
++$i;
}
return false;
} | [
"public",
"function",
"getLevelCurrent",
"(",
"$",
"level",
")",
"{",
"$",
"i",
"=",
"1",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCurrent",
"(",
")",
"->",
"with",
"(",
"'hidden'",
")",
"->",
"getTeardown",
"(",
")",
"as",
"$",
"item",
")",
"{"... | Get the current item for specified level/depth. Menus always start on level/depth 1. This works
only in reversed order, to get the parent level from a child!
@param integer $level Level menu starts with 1
@return \luya\cms\menu\Item|boolean An item-object for the specific level current, false otherwise. | [
"Get",
"the",
"current",
"item",
"for",
"specified",
"level",
"/",
"depth",
".",
"Menus",
"always",
"start",
"on",
"level",
"/",
"depth",
"1",
".",
"This",
"works",
"only",
"in",
"reversed",
"order",
"to",
"get",
"the",
"parent",
"level",
"from",
"a",
... | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L457-L468 |
luyadev/luya-module-cms | src/Menu.php | Menu.findAll | public function findAll(array $where, $preloadModels = false)
{
return (new MenuQuery())->where($where)->preloadModels($preloadModels)->all();
} | php | public function findAll(array $where, $preloadModels = false)
{
return (new MenuQuery())->where($where)->preloadModels($preloadModels)->all();
} | [
"public",
"function",
"findAll",
"(",
"array",
"$",
"where",
",",
"$",
"preloadModels",
"=",
"false",
")",
"{",
"return",
"(",
"new",
"MenuQuery",
"(",
")",
")",
"->",
"where",
"(",
"$",
"where",
")",
"->",
"preloadModels",
"(",
"$",
"preloadModels",
"... | Wrapper method to get all menu items for the current language without hidden items for
the specific where statement.
@param array $where See {{\luya\cms\menu\Query::where()}}
@param boolean $preloadModels Whether to preload all models for the given menu Query. See {{luya\cms\menu\Query::preloadModels()}}
@see \luya\cms\menu\Query::where()
@return \luya\cms\menu\QueryIterator | [
"Wrapper",
"method",
"to",
"get",
"all",
"menu",
"items",
"for",
"the",
"current",
"language",
"without",
"hidden",
"items",
"for",
"the",
"specific",
"where",
"statement",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L499-L502 |
luyadev/luya-module-cms | src/Menu.php | Menu.resolveCurrent | private function resolveCurrent()
{
$requestPath = $this->request->get('path', null);
if (empty($requestPath)) {
$home = $this->getHome();
if (!$home) {
throw new NotFoundHttpException('Home item could not be found, have you forget to set a default page?');
}
$requestPath = $home->alias;
}
$requestPath = rtrim($requestPath, '/');
$urlParts = explode('/', $requestPath);
$item = $this->aliasMatch($urlParts);
if (!$item) {
while (array_pop($urlParts)) {
if (($item = $this->aliasMatch($urlParts, true)) !== false) {
break;
}
}
}
if ($item) {
$this->_currentAppendix = substr($requestPath, strlen($item->alias) + 1);
return $item;
}
// no item could have been resolved, but the home side type is module, which can have links.
if (!$item && $this->home->type == 2) {
$this->_currentAppendix = $requestPath;
return $this->getHome();
}
// we could not resolve a page, check if the website has customized 404 error page defined.
$navId = Config::get(Config::HTTP_EXCEPTION_NAV_ID, 0);
$menu = Yii::$app->menu->find()->with(['hidden'])->where(['nav_id' => $navId])->one();
if ($menu) {
$menu->is404Page = true;
return $menu;
}
throw new NotFoundHttpException("Unable to resolve requested path '".$requestPath."'.");
} | php | private function resolveCurrent()
{
$requestPath = $this->request->get('path', null);
if (empty($requestPath)) {
$home = $this->getHome();
if (!$home) {
throw new NotFoundHttpException('Home item could not be found, have you forget to set a default page?');
}
$requestPath = $home->alias;
}
$requestPath = rtrim($requestPath, '/');
$urlParts = explode('/', $requestPath);
$item = $this->aliasMatch($urlParts);
if (!$item) {
while (array_pop($urlParts)) {
if (($item = $this->aliasMatch($urlParts, true)) !== false) {
break;
}
}
}
if ($item) {
$this->_currentAppendix = substr($requestPath, strlen($item->alias) + 1);
return $item;
}
// no item could have been resolved, but the home side type is module, which can have links.
if (!$item && $this->home->type == 2) {
$this->_currentAppendix = $requestPath;
return $this->getHome();
}
// we could not resolve a page, check if the website has customized 404 error page defined.
$navId = Config::get(Config::HTTP_EXCEPTION_NAV_ID, 0);
$menu = Yii::$app->menu->find()->with(['hidden'])->where(['nav_id' => $navId])->one();
if ($menu) {
$menu->is404Page = true;
return $menu;
}
throw new NotFoundHttpException("Unable to resolve requested path '".$requestPath."'.");
} | [
"private",
"function",
"resolveCurrent",
"(",
")",
"{",
"$",
"requestPath",
"=",
"$",
"this",
"->",
"request",
"->",
"get",
"(",
"'path'",
",",
"null",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"requestPath",
")",
")",
"{",
"$",
"home",
"=",
"$",
"th... | Find the current element based on the request get property 'path'.
1. if request path is empty us the getHome() to return alias.
2. find menu item based on the end of the current path (via array_pop)
3. if no item could be found the home item will be returned
4. otherwise return the alias match from step 2.
@return Item
@throws NotFoundHttpException | [
"Find",
"the",
"current",
"element",
"based",
"on",
"the",
"request",
"get",
"property",
"path",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L529-L575 |
luyadev/luya-module-cms | src/Menu.php | Menu.buildItemLink | public function buildItemLink($alias, $langShortCode)
{
return Yii::$app->getUrlManager()->prependBaseUrl($this->composition->prependTo($alias, $this->composition->createRouteEnsure(['langShortCode' => $langShortCode])));
} | php | public function buildItemLink($alias, $langShortCode)
{
return Yii::$app->getUrlManager()->prependBaseUrl($this->composition->prependTo($alias, $this->composition->createRouteEnsure(['langShortCode' => $langShortCode])));
} | [
"public",
"function",
"buildItemLink",
"(",
"$",
"alias",
",",
"$",
"langShortCode",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"getUrlManager",
"(",
")",
"->",
"prependBaseUrl",
"(",
"$",
"this",
"->",
"composition",
"->",
"prependTo",
"(",
"$",
... | prepand the base url for the provided alias.
@param string $alias
@return string | [
"prepand",
"the",
"base",
"url",
"for",
"the",
"provided",
"alias",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L583-L586 |
luyadev/luya-module-cms | src/Menu.php | Menu.getModulesMap | public function getModulesMap()
{
if ($this->_modulesMap === null) {
$this->_modulesMap = NavItemModule::find()->select(['module_name', 'id'])->indexBy('id')->asArray()->all();
}
return $this->_modulesMap;
} | php | public function getModulesMap()
{
if ($this->_modulesMap === null) {
$this->_modulesMap = NavItemModule::find()->select(['module_name', 'id'])->indexBy('id')->asArray()->all();
}
return $this->_modulesMap;
} | [
"public",
"function",
"getModulesMap",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_modulesMap",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_modulesMap",
"=",
"NavItemModule",
"::",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'module_name'",
",",
... | Return all nav item modules to request data later in items
@return array An array with all modules index by the id | [
"Return",
"all",
"nav",
"item",
"modules",
"to",
"request",
"data",
"later",
"in",
"items"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L593-L600 |
luyadev/luya-module-cms | src/Menu.php | Menu.getNavData | private function getNavData($langId)
{
return (new DbQuery())
->from(['cms_nav_item item'])
->select(['item.id', 'item.nav_id', 'item.title', 'item.description', 'item.keywords', 'item.image_id', 'item.is_url_strict_parsing_disabled', 'item.alias', 'item.title_tag', 'item.timestamp_create', 'item.timestamp_update', 'item.create_user_id', 'item.update_user_id', 'nav.is_home', 'nav.parent_nav_id', 'nav.sort_index', 'nav.is_hidden', 'item.nav_item_type', 'item.nav_item_type_id', 'nav_container.alias AS container'])
->leftJoin('cms_nav nav', 'nav.id=item.nav_id')
->leftJoin('cms_nav_container nav_container', 'nav_container.id=nav.nav_container_id')
->where(['nav.is_deleted' => false, 'item.lang_id' => $langId, 'nav.is_offline' => false, 'nav.is_draft' => false])
->andWhere(['or', ['publish_from' => null], ['<=', 'publish_from', new Expression('UNIX_TIMESTAMP()')]])
->andWhere(['or', ['publish_till' => null], ['>=', 'publish_till', new Expression('UNIX_TIMESTAMP()')]])
->orderBy(['container' => 'ASC', 'parent_nav_id' => 'ASC', 'nav.sort_index' => 'ASC'])
->indexBy('id')
->all();
} | php | private function getNavData($langId)
{
return (new DbQuery())
->from(['cms_nav_item item'])
->select(['item.id', 'item.nav_id', 'item.title', 'item.description', 'item.keywords', 'item.image_id', 'item.is_url_strict_parsing_disabled', 'item.alias', 'item.title_tag', 'item.timestamp_create', 'item.timestamp_update', 'item.create_user_id', 'item.update_user_id', 'nav.is_home', 'nav.parent_nav_id', 'nav.sort_index', 'nav.is_hidden', 'item.nav_item_type', 'item.nav_item_type_id', 'nav_container.alias AS container'])
->leftJoin('cms_nav nav', 'nav.id=item.nav_id')
->leftJoin('cms_nav_container nav_container', 'nav_container.id=nav.nav_container_id')
->where(['nav.is_deleted' => false, 'item.lang_id' => $langId, 'nav.is_offline' => false, 'nav.is_draft' => false])
->andWhere(['or', ['publish_from' => null], ['<=', 'publish_from', new Expression('UNIX_TIMESTAMP()')]])
->andWhere(['or', ['publish_till' => null], ['>=', 'publish_till', new Expression('UNIX_TIMESTAMP()')]])
->orderBy(['container' => 'ASC', 'parent_nav_id' => 'ASC', 'nav.sort_index' => 'ASC'])
->indexBy('id')
->all();
} | [
"private",
"function",
"getNavData",
"(",
"$",
"langId",
")",
"{",
"return",
"(",
"new",
"DbQuery",
"(",
")",
")",
"->",
"from",
"(",
"[",
"'cms_nav_item item'",
"]",
")",
"->",
"select",
"(",
"[",
"'item.id'",
",",
"'item.nav_id'",
",",
"'item.title'",
... | load all navigation items for a specific language id.
@param integer $langId
@return array | [
"load",
"all",
"navigation",
"items",
"for",
"a",
"specific",
"language",
"id",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L608-L621 |
luyadev/luya-module-cms | src/Menu.php | Menu.buildIndexForContainer | private function buildIndexForContainer($data)
{
$this->_paths = [];
$this->_nodes = [];
foreach ($data as $item) {
$this->_nodes[$item['nav_id']] = ['parent_nav_id' => $item['parent_nav_id'], 'alias' => $item['alias'], 'nav_id' => $item['nav_id']];
}
foreach ($this->_nodes as $node) {
$this->_paths[$node['nav_id']] = $this->processParent($node['nav_id'], null);
}
return $this->_paths;
} | php | private function buildIndexForContainer($data)
{
$this->_paths = [];
$this->_nodes = [];
foreach ($data as $item) {
$this->_nodes[$item['nav_id']] = ['parent_nav_id' => $item['parent_nav_id'], 'alias' => $item['alias'], 'nav_id' => $item['nav_id']];
}
foreach ($this->_nodes as $node) {
$this->_paths[$node['nav_id']] = $this->processParent($node['nav_id'], null);
}
return $this->_paths;
} | [
"private",
"function",
"buildIndexForContainer",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"_paths",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_nodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"$",
"this",
... | Helper method to build an index with all the alias paths to build the correct links.
@param array $data
@return array An array with the index where the key is the nav_id | [
"Helper",
"method",
"to",
"build",
"an",
"index",
"with",
"all",
"the",
"alias",
"paths",
"to",
"build",
"the",
"correct",
"links",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L633-L647 |
luyadev/luya-module-cms | src/Menu.php | Menu.aliasMatch | private function aliasMatch(array $urlParts, $strictParsing = false)
{
if ($strictParsing) {
$query = (new MenuQuery())
->where([self::FIELD_ALIAS => implode('/', $urlParts)])
->with('hidden')
->andWhere([self::FIELD_TYPE => self::ITEM_TYPE_MODULE])
->one();
if ($query) {
return $query;
}
return (new MenuQuery())
->where([self::FIELD_ALIAS => implode('/', $urlParts)])
->with('hidden')
->andWhere([self::FIELD_IS_URL_STRICT_PARSING_DISABLED => 1])
->one();
}
return (new MenuQuery())
->where([self::FIELD_ALIAS => implode('/', $urlParts)])
->with('hidden')
->one();
} | php | private function aliasMatch(array $urlParts, $strictParsing = false)
{
if ($strictParsing) {
$query = (new MenuQuery())
->where([self::FIELD_ALIAS => implode('/', $urlParts)])
->with('hidden')
->andWhere([self::FIELD_TYPE => self::ITEM_TYPE_MODULE])
->one();
if ($query) {
return $query;
}
return (new MenuQuery())
->where([self::FIELD_ALIAS => implode('/', $urlParts)])
->with('hidden')
->andWhere([self::FIELD_IS_URL_STRICT_PARSING_DISABLED => 1])
->one();
}
return (new MenuQuery())
->where([self::FIELD_ALIAS => implode('/', $urlParts)])
->with('hidden')
->one();
} | [
"private",
"function",
"aliasMatch",
"(",
"array",
"$",
"urlParts",
",",
"$",
"strictParsing",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"strictParsing",
")",
"{",
"$",
"query",
"=",
"(",
"new",
"MenuQuery",
"(",
")",
")",
"->",
"where",
"(",
"[",
"sel... | helper method to see if the request url can be found in the active container.
@param array $urlParts
@return bool|Item | [
"helper",
"method",
"to",
"see",
"if",
"the",
"request",
"url",
"can",
"be",
"found",
"in",
"the",
"active",
"container",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L667-L690 |
luyadev/luya-module-cms | src/Menu.php | Menu.loadLanguageContainer | private function loadLanguageContainer($langShortCode)
{
$cacheKey = $this->_cachePrefix.$langShortCode;
$languageContainer = $this->getHasCache($cacheKey);
if ($languageContainer === false) {
$lang = $this->getLanguage($langShortCode);
if (!$lang) {
throw new NotFoundHttpException(sprintf("The requested language '%s' does not exist in language table", $langShortCode));
}
$data = $this->getNavData($lang['id']);
$index = $this->buildIndexForContainer($data);
$languageContainer = [];
// $key = cms_nav_item.id (as of indexBy('id'))
foreach ($data as $key => $item) {
$alias = $item['alias'];
if ($item['parent_nav_id'] > 0 && array_key_exists($item['parent_nav_id'], $index)) {
$alias = $index[$item['parent_nav_id']].'/'.$item['alias'];
}
$languageContainer[$key] = [
'id' => $item['id'],
'nav_id' => $item['nav_id'],
'lang' => $lang['short_code'],
'link' => $this->buildItemLink($alias, $langShortCode),
'title' => $this->encodeValue($item['title']),
'title_tag' => $this->encodeValue($item['title_tag']),
'alias' => $alias,
'description' => $this->encodeValue($item['description']),
'keywords' => $this->encodeValue($item['keywords']),
'create_user_id' => $item['create_user_id'],
'update_user_id' => $item['update_user_id'],
'timestamp_create' => $item['timestamp_create'],
'timestamp_update' => $item['timestamp_update'],
'is_home' => $item['is_home'],
'parent_nav_id' => $item['parent_nav_id'],
'sort_index' => $item['sort_index'],
'is_hidden' => $item['is_hidden'],
'type' => $item['nav_item_type'],
'image_id' => $item['image_id'],
'redirect' => ($item['nav_item_type'] == 3 && isset($this->redirectMap[$item['nav_item_type_id']])) ? $this->redirectMap[$item['nav_item_type_id']] : false,
'module_name' => ($item['nav_item_type'] == 2 && isset($this->modulesMap[$item['nav_item_type_id']])) ? $this->modulesMap[$item['nav_item_type_id']]['module_name'] : false,
'container' => $item['container'],
'depth' => count(explode('/', $alias)),
'is_url_strict_parsing_disabled' => $item['is_url_strict_parsing_disabled'],
];
}
$this->setHasCache($cacheKey, $languageContainer);
}
return $languageContainer;
} | php | private function loadLanguageContainer($langShortCode)
{
$cacheKey = $this->_cachePrefix.$langShortCode;
$languageContainer = $this->getHasCache($cacheKey);
if ($languageContainer === false) {
$lang = $this->getLanguage($langShortCode);
if (!$lang) {
throw new NotFoundHttpException(sprintf("The requested language '%s' does not exist in language table", $langShortCode));
}
$data = $this->getNavData($lang['id']);
$index = $this->buildIndexForContainer($data);
$languageContainer = [];
// $key = cms_nav_item.id (as of indexBy('id'))
foreach ($data as $key => $item) {
$alias = $item['alias'];
if ($item['parent_nav_id'] > 0 && array_key_exists($item['parent_nav_id'], $index)) {
$alias = $index[$item['parent_nav_id']].'/'.$item['alias'];
}
$languageContainer[$key] = [
'id' => $item['id'],
'nav_id' => $item['nav_id'],
'lang' => $lang['short_code'],
'link' => $this->buildItemLink($alias, $langShortCode),
'title' => $this->encodeValue($item['title']),
'title_tag' => $this->encodeValue($item['title_tag']),
'alias' => $alias,
'description' => $this->encodeValue($item['description']),
'keywords' => $this->encodeValue($item['keywords']),
'create_user_id' => $item['create_user_id'],
'update_user_id' => $item['update_user_id'],
'timestamp_create' => $item['timestamp_create'],
'timestamp_update' => $item['timestamp_update'],
'is_home' => $item['is_home'],
'parent_nav_id' => $item['parent_nav_id'],
'sort_index' => $item['sort_index'],
'is_hidden' => $item['is_hidden'],
'type' => $item['nav_item_type'],
'image_id' => $item['image_id'],
'redirect' => ($item['nav_item_type'] == 3 && isset($this->redirectMap[$item['nav_item_type_id']])) ? $this->redirectMap[$item['nav_item_type_id']] : false,
'module_name' => ($item['nav_item_type'] == 2 && isset($this->modulesMap[$item['nav_item_type_id']])) ? $this->modulesMap[$item['nav_item_type_id']]['module_name'] : false,
'container' => $item['container'],
'depth' => count(explode('/', $alias)),
'is_url_strict_parsing_disabled' => $item['is_url_strict_parsing_disabled'],
];
}
$this->setHasCache($cacheKey, $languageContainer);
}
return $languageContainer;
} | [
"private",
"function",
"loadLanguageContainer",
"(",
"$",
"langShortCode",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"_cachePrefix",
".",
"$",
"langShortCode",
";",
"$",
"languageContainer",
"=",
"$",
"this",
"->",
"getHasCache",
"(",
"$",
"cacheKey",... | Helper method to load all contaienr data for a specific langauge.
@param string $langShortCode e.g. de
@return array
@throws NotFoundHttpException | [
"Helper",
"method",
"to",
"load",
"all",
"contaienr",
"data",
"for",
"a",
"specific",
"langauge",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L699-L758 |
luyadev/luya-module-cms | src/Menu.php | Menu.flushCache | public function flushCache()
{
foreach ($this->getLanguages() as $lang) {
$this->deleteHasCache($this->_cachePrefix . $lang['short_code']);
}
} | php | public function flushCache()
{
foreach ($this->getLanguages() as $lang) {
$this->deleteHasCache($this->_cachePrefix . $lang['short_code']);
}
} | [
"public",
"function",
"flushCache",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getLanguages",
"(",
")",
"as",
"$",
"lang",
")",
"{",
"$",
"this",
"->",
"deleteHasCache",
"(",
"$",
"this",
"->",
"_cachePrefix",
".",
"$",
"lang",
"[",
"'short_cod... | Flush all caching data for the menu for each language | [
"Flush",
"all",
"caching",
"data",
"for",
"the",
"menu",
"for",
"each",
"language"
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/Menu.php#L772-L777 |
luyadev/luya-module-cms | src/helpers/Url.php | Url.toModule | public static function toModule($moduleName)
{
$item = Yii::$app->menu->find()->where(['module_name' => $moduleName])->with(['hidden'])->one();
if ($item) {
return $item->link;
}
return $moduleName;
} | php | public static function toModule($moduleName)
{
$item = Yii::$app->menu->find()->where(['module_name' => $moduleName])->with(['hidden'])->one();
if ($item) {
return $item->link;
}
return $moduleName;
} | [
"public",
"static",
"function",
"toModule",
"(",
"$",
"moduleName",
")",
"{",
"$",
"item",
"=",
"Yii",
"::",
"$",
"app",
"->",
"menu",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'module_name'",
"=>",
"$",
"moduleName",
"]",
")",
"->",
"with",
... | if the module could not be found (not registered in the cms) the method returns the provided module name.
returns only ONE even if there are more! not good structure inside the cms?
@param string $moduleName
@return string The full_url from links component. | [
"if",
"the",
"module",
"could",
"not",
"be",
"found",
"(",
"not",
"registered",
"in",
"the",
"cms",
")",
"the",
"method",
"returns",
"the",
"provided",
"module",
"name",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/Url.php#L30-L39 |
luyadev/luya-module-cms | src/helpers/Url.php | Url.toModuleRoute | public static function toModuleRoute($moduleName, array $route)
{
$item = Yii::$app->menu->find()->where(['module_name' => $moduleName])->with(['hidden'])->one();
if ($item) {
return static::toMenuItem($item->id, $route);
}
throw new Exception("The module route creation could not find the module '$moduleName'. Have you created a page with this module in this language context?");
} | php | public static function toModuleRoute($moduleName, array $route)
{
$item = Yii::$app->menu->find()->where(['module_name' => $moduleName])->with(['hidden'])->one();
if ($item) {
return static::toMenuItem($item->id, $route);
}
throw new Exception("The module route creation could not find the module '$moduleName'. Have you created a page with this module in this language context?");
} | [
"public",
"static",
"function",
"toModuleRoute",
"(",
"$",
"moduleName",
",",
"array",
"$",
"route",
")",
"{",
"$",
"item",
"=",
"Yii",
"::",
"$",
"app",
"->",
"menu",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'module_name'",
"=>",
"$",
"modu... | Helper method to create a route based on the module name and the route and params.
Use the route as defined in the modules' $urlRules array in order to generate the URL according
to the rules' pattern. Example:
```php
Url::toModuleRoute('blog', ['/blog/default/index', 'year' => 2016, 'month' => '07]);
```
generates the following URL, assuming the blog module is located on the CMS page /my-super-blog:
/my-super-blog/2016/07
according to the following URL rule:
```php
public $urlRules = [
['pattern' => 'blog/<year:\d{4}>/<month:\d{2}>', 'route' => 'blog/default/index'],
];
```
@param string $moduleName The ID of the module, which should be found inside the nav items.
@param string|array $route The route of the module `module/controller/action` or an array like in Url::to with param infos `['/module/controller/action', 'foo' => 'bar']`.
@param array $params The parameters for the url rule. If the route is provided as an array with params the further defined params or overwritten by the array_merge process.
@throws Exception
@return string
@see \luya\helpers\Url::toModule() | [
"Helper",
"method",
"to",
"create",
"a",
"route",
"based",
"on",
"the",
"module",
"name",
"and",
"the",
"route",
"and",
"params",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/Url.php#L70-L79 |
luyadev/luya-module-cms | src/helpers/Url.php | Url.toMenuNav | public static function toMenuNav($navId, array $route)
{
$menu = Yii::$app->menu->find()->where([Menu::FIELD_NAVID => $navId])->with(['hidden'])->one();
return static::toMenuNavItem($menu->id, $route);
} | php | public static function toMenuNav($navId, array $route)
{
$menu = Yii::$app->menu->find()->where([Menu::FIELD_NAVID => $navId])->with(['hidden'])->one();
return static::toMenuNavItem($menu->id, $route);
} | [
"public",
"static",
"function",
"toMenuNav",
"(",
"$",
"navId",
",",
"array",
"$",
"route",
")",
"{",
"$",
"menu",
"=",
"Yii",
"::",
"$",
"app",
"->",
"menu",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"Menu",
"::",
"FIELD_NAVID",
"=>",
"$",
... | Create an url to a cms page based on the nav id.
This method uses the language independent navId which is displayed in the cms page tree.
@param integer $navId The nav id of the given page which is the base path for the generated url.
@param array $route An array with a route and optional params `['/module/controller/action', 'param' => 'bar]`.
@return string The url with the base path from the nav id and the appended route.
@since 1.0.4 | [
"Create",
"an",
"url",
"to",
"a",
"cms",
"page",
"based",
"on",
"the",
"nav",
"id",
"."
] | train | https://github.com/luyadev/luya-module-cms/blob/9a74bc5869c365e50bc455c4860e3af8c6145d34/src/helpers/Url.php#L123-L128 |
Spomky-Labs/base64url | src/Base64Url.php | Base64Url.decode | public static function decode(string $data): string
{
$decoded = base64_decode(strtr($data, '-_', '+/'), true);
if (false === $decoded) {
throw new InvalidArgumentException('Invalid data provided');
}
return $decoded;
} | php | public static function decode(string $data): string
{
$decoded = base64_decode(strtr($data, '-_', '+/'), true);
if (false === $decoded) {
throw new InvalidArgumentException('Invalid data provided');
}
return $decoded;
} | [
"public",
"static",
"function",
"decode",
"(",
"string",
"$",
"data",
")",
":",
"string",
"{",
"$",
"decoded",
"=",
"base64_decode",
"(",
"strtr",
"(",
"$",
"data",
",",
"'-_'",
",",
"'+/'",
")",
",",
"true",
")",
";",
"if",
"(",
"false",
"===",
"$... | @param string $data The data to decode
@throws InvalidArgumentException
@return string The data decoded | [
"@param",
"string",
"$data",
"The",
"data",
"to",
"decode"
] | train | https://github.com/Spomky-Labs/base64url/blob/a5eaf0352b89abdd93f7fb4668dd4dbfe8831f6d/src/Base64Url.php#L47-L55 |
johnpbloch/wordpress-core-installer | src/johnpbloch/Composer/WordPressCoreInstaller.php | WordPressCoreInstaller.getInstallPath | public function getInstallPath( PackageInterface $package ) {
$installationDir = false;
$prettyName = $package->getPrettyName();
if ( $this->composer->getPackage() ) {
$topExtra = $this->composer->getPackage()->getExtra();
if ( ! empty( $topExtra['wordpress-install-dir'] ) ) {
$installationDir = $topExtra['wordpress-install-dir'];
if ( is_array( $installationDir ) ) {
$installationDir = empty( $installationDir[ $prettyName ] ) ? false : $installationDir[ $prettyName ];
}
}
}
$extra = $package->getExtra();
if ( ! $installationDir && ! empty( $extra['wordpress-install-dir'] ) ) {
$installationDir = $extra['wordpress-install-dir'];
}
if ( ! $installationDir ) {
$installationDir = 'wordpress';
}
$vendorDir = $this->composer->getConfig()->get( 'vendor-dir', Config::RELATIVE_PATHS ) ?: 'vendor';
if (
in_array( $installationDir, $this->sensitiveDirectories ) ||
( $installationDir === $vendorDir )
) {
throw new \InvalidArgumentException( $this->getSensitiveDirectoryMessage( $installationDir, $prettyName ) );
}
if (
! empty( self::$_installedPaths[ $installationDir ] ) &&
$prettyName !== self::$_installedPaths[ $installationDir ]
) {
$conflict_message = $this->getConflictMessage( $prettyName, self::$_installedPaths[ $installationDir ] );
throw new \InvalidArgumentException( $conflict_message );
}
self::$_installedPaths[ $installationDir ] = $prettyName;
return $installationDir;
} | php | public function getInstallPath( PackageInterface $package ) {
$installationDir = false;
$prettyName = $package->getPrettyName();
if ( $this->composer->getPackage() ) {
$topExtra = $this->composer->getPackage()->getExtra();
if ( ! empty( $topExtra['wordpress-install-dir'] ) ) {
$installationDir = $topExtra['wordpress-install-dir'];
if ( is_array( $installationDir ) ) {
$installationDir = empty( $installationDir[ $prettyName ] ) ? false : $installationDir[ $prettyName ];
}
}
}
$extra = $package->getExtra();
if ( ! $installationDir && ! empty( $extra['wordpress-install-dir'] ) ) {
$installationDir = $extra['wordpress-install-dir'];
}
if ( ! $installationDir ) {
$installationDir = 'wordpress';
}
$vendorDir = $this->composer->getConfig()->get( 'vendor-dir', Config::RELATIVE_PATHS ) ?: 'vendor';
if (
in_array( $installationDir, $this->sensitiveDirectories ) ||
( $installationDir === $vendorDir )
) {
throw new \InvalidArgumentException( $this->getSensitiveDirectoryMessage( $installationDir, $prettyName ) );
}
if (
! empty( self::$_installedPaths[ $installationDir ] ) &&
$prettyName !== self::$_installedPaths[ $installationDir ]
) {
$conflict_message = $this->getConflictMessage( $prettyName, self::$_installedPaths[ $installationDir ] );
throw new \InvalidArgumentException( $conflict_message );
}
self::$_installedPaths[ $installationDir ] = $prettyName;
return $installationDir;
} | [
"public",
"function",
"getInstallPath",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"installationDir",
"=",
"false",
";",
"$",
"prettyName",
"=",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"composer",
"-... | {@inheritDoc} | [
"{"
] | train | https://github.com/johnpbloch/wordpress-core-installer/blob/ec541ae6666c1994c5944a3a5797dd455b6b8ff2/src/johnpbloch/Composer/WordPressCoreInstaller.php#L42-L78 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.append | public function append($key, $value = null)
{
if (0 == strlen($key)) {
throw new RuntimeException("Key cannot be an empty string");
}
$currentValue =& $this->data;
$keyPath = explode('.', $key);
if (1 == count($keyPath)) {
if (!isset($currentValue[$key])) {
$currentValue[$key] = [];
}
if (!is_array($currentValue[$key])) {
// Promote this key to an array.
// TODO: Is this really what we want to do?
$currentValue[$key] = [$currentValue[$key]];
}
$currentValue[$key][] = $value;
return;
}
$endKey = array_pop($keyPath);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey =& $keyPath[$i];
if ( ! isset($currentValue[$currentKey]) ) {
$currentValue[$currentKey] = [];
}
$currentValue =& $currentValue[$currentKey];
}
if (!isset($currentValue[$endKey])) {
$currentValue[$endKey] = [];
}
if (!is_array($currentValue[$endKey])) {
$currentValue[$endKey] = [$currentValue[$endKey]];
}
// Promote this key to an array.
// TODO: Is this really what we want to do?
$currentValue[$endKey][] = $value;
} | php | public function append($key, $value = null)
{
if (0 == strlen($key)) {
throw new RuntimeException("Key cannot be an empty string");
}
$currentValue =& $this->data;
$keyPath = explode('.', $key);
if (1 == count($keyPath)) {
if (!isset($currentValue[$key])) {
$currentValue[$key] = [];
}
if (!is_array($currentValue[$key])) {
// Promote this key to an array.
// TODO: Is this really what we want to do?
$currentValue[$key] = [$currentValue[$key]];
}
$currentValue[$key][] = $value;
return;
}
$endKey = array_pop($keyPath);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey =& $keyPath[$i];
if ( ! isset($currentValue[$currentKey]) ) {
$currentValue[$currentKey] = [];
}
$currentValue =& $currentValue[$currentKey];
}
if (!isset($currentValue[$endKey])) {
$currentValue[$endKey] = [];
}
if (!is_array($currentValue[$endKey])) {
$currentValue[$endKey] = [$currentValue[$endKey]];
}
// Promote this key to an array.
// TODO: Is this really what we want to do?
$currentValue[$endKey][] = $value;
} | [
"public",
"function",
"append",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"0",
"==",
"strlen",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Key cannot be an empty string\"",
")",
";",
"}",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L38-L79 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.set | public function set($key, $value = null)
{
if (0 == strlen($key)) {
throw new RuntimeException("Key cannot be an empty string");
}
$currentValue =& $this->data;
$keyPath = explode('.', $key);
if (1 == count($keyPath)) {
$currentValue[$key] = $value;
return;
}
$endKey = array_pop($keyPath);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey =& $keyPath[$i];
if (!isset($currentValue[$currentKey])) {
$currentValue[$currentKey] = [];
}
if (!is_array($currentValue[$currentKey])) {
throw new RuntimeException("Key path at $currentKey of $key cannot be indexed into (is not an array)");
}
$currentValue =& $currentValue[$currentKey];
}
$currentValue[$endKey] = $value;
} | php | public function set($key, $value = null)
{
if (0 == strlen($key)) {
throw new RuntimeException("Key cannot be an empty string");
}
$currentValue =& $this->data;
$keyPath = explode('.', $key);
if (1 == count($keyPath)) {
$currentValue[$key] = $value;
return;
}
$endKey = array_pop($keyPath);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey =& $keyPath[$i];
if (!isset($currentValue[$currentKey])) {
$currentValue[$currentKey] = [];
}
if (!is_array($currentValue[$currentKey])) {
throw new RuntimeException("Key path at $currentKey of $key cannot be indexed into (is not an array)");
}
$currentValue =& $currentValue[$currentKey];
}
$currentValue[$endKey] = $value;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"0",
"==",
"strlen",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Key cannot be an empty string\"",
")",
";",
"}",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L84-L111 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.remove | public function remove($key)
{
if (0 == strlen($key)) {
throw new RuntimeException("Key cannot be an empty string");
}
$currentValue =& $this->data;
$keyPath = explode('.', $key);
if (1 == count($keyPath)) {
unset($currentValue[$key]);
return;
}
$endKey = array_pop($keyPath);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey =& $keyPath[$i];
if (!isset($currentValue[$currentKey])) {
return;
}
$currentValue =& $currentValue[$currentKey];
}
unset($currentValue[$endKey]);
} | php | public function remove($key)
{
if (0 == strlen($key)) {
throw new RuntimeException("Key cannot be an empty string");
}
$currentValue =& $this->data;
$keyPath = explode('.', $key);
if (1 == count($keyPath)) {
unset($currentValue[$key]);
return;
}
$endKey = array_pop($keyPath);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey =& $keyPath[$i];
if (!isset($currentValue[$currentKey])) {
return;
}
$currentValue =& $currentValue[$currentKey];
}
unset($currentValue[$endKey]);
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"0",
"==",
"strlen",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Key cannot be an empty string\"",
")",
";",
"}",
"$",
"currentValue",
"=",
"&",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L116-L140 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.get | public function get($key, $default = null)
{
$currentValue = $this->data;
$keyPath = explode('.', $key);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey = $keyPath[$i];
if (!isset($currentValue[$currentKey]) ) {
return $default;
}
if (!is_array($currentValue)) {
return $default;
}
$currentValue = $currentValue[$currentKey];
}
return $currentValue === null ? $default : $currentValue;
} | php | public function get($key, $default = null)
{
$currentValue = $this->data;
$keyPath = explode('.', $key);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey = $keyPath[$i];
if (!isset($currentValue[$currentKey]) ) {
return $default;
}
if (!is_array($currentValue)) {
return $default;
}
$currentValue = $currentValue[$currentKey];
}
return $currentValue === null ? $default : $currentValue;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"currentValue",
"=",
"$",
"this",
"->",
"data",
";",
"$",
"keyPath",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"for",
"(",
"$",
"i",
"="... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L145-L162 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.has | public function has($key)
{
$currentValue = &$this->data;
$keyPath = explode('.', $key);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey = $keyPath[$i];
if (
!is_array($currentValue) ||
!array_key_exists($currentKey, $currentValue)
) {
return false;
}
$currentValue = &$currentValue[$currentKey];
}
return true;
} | php | public function has($key)
{
$currentValue = &$this->data;
$keyPath = explode('.', $key);
for ( $i = 0; $i < count($keyPath); $i++ ) {
$currentKey = $keyPath[$i];
if (
!is_array($currentValue) ||
!array_key_exists($currentKey, $currentValue)
) {
return false;
}
$currentValue = &$currentValue[$currentKey];
}
return true;
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"currentValue",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"$",
"keyPath",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L167-L184 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.getData | public function getData($key)
{
$value = $this->get($key);
if (is_array($value) && Util::isAssoc($value)) {
return new Data($value);
}
throw new RuntimeException("Value at '$key' could not be represented as a DataInterface");
} | php | public function getData($key)
{
$value = $this->get($key);
if (is_array($value) && Util::isAssoc($value)) {
return new Data($value);
}
throw new RuntimeException("Value at '$key' could not be represented as a DataInterface");
} | [
"public",
"function",
"getData",
"(",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"Util",
"::",
"isAssoc",
"(",
"$",
"value",
")",
")",
"{",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L189-L197 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.import | public function import(array $data, $clobber = true)
{
$this->data = Util::mergeAssocArray($this->data, $data, $clobber);
} | php | public function import(array $data, $clobber = true)
{
$this->data = Util::mergeAssocArray($this->data, $data, $clobber);
} | [
"public",
"function",
"import",
"(",
"array",
"$",
"data",
",",
"$",
"clobber",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"Util",
"::",
"mergeAssocArray",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"data",
",",
"$",
"clobber",
")",
";",... | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L202-L205 |
dflydev/dflydev-dot-access-data | src/Data.php | Data.importData | public function importData(DataInterface $data, $clobber = true)
{
$this->import($data->export(), $clobber);
} | php | public function importData(DataInterface $data, $clobber = true)
{
$this->import($data->export(), $clobber);
} | [
"public",
"function",
"importData",
"(",
"DataInterface",
"$",
"data",
",",
"$",
"clobber",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"import",
"(",
"$",
"data",
"->",
"export",
"(",
")",
",",
"$",
"clobber",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Data.php#L210-L213 |
dflydev/dflydev-dot-access-data | src/Util.php | Util.isAssoc | public static function isAssoc(array $arr)
{
return (is_array($arr) && (!count($arr) || count(array_filter(array_keys($arr),'is_string')) == count($arr)));
} | php | public static function isAssoc(array $arr)
{
return (is_array($arr) && (!count($arr) || count(array_filter(array_keys($arr),'is_string')) == count($arr)));
} | [
"public",
"static",
"function",
"isAssoc",
"(",
"array",
"$",
"arr",
")",
"{",
"return",
"(",
"is_array",
"(",
"$",
"arr",
")",
"&&",
"(",
"!",
"count",
"(",
"$",
"arr",
")",
"||",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"arr",
"... | Test if array is an associative array
Note that this function will return true if an array is empty. Meaning
empty arrays will be treated as if they are associative arrays.
@param array $arr
@return boolean | [
"Test",
"if",
"array",
"is",
"an",
"associative",
"array"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Util.php#L26-L29 |
dflydev/dflydev-dot-access-data | src/Util.php | Util.mergeAssocArray | public static function mergeAssocArray($to, $from, $clobber = true)
{
if ( is_array($from) ) {
foreach ($from as $k => $v) {
if (!isset($to[$k])) {
$to[$k] = $v;
} else {
$to[$k] = self::mergeAssocArray($to[$k], $v, $clobber);
}
}
return $to;
}
return $clobber ? $from : $to;
} | php | public static function mergeAssocArray($to, $from, $clobber = true)
{
if ( is_array($from) ) {
foreach ($from as $k => $v) {
if (!isset($to[$k])) {
$to[$k] = $v;
} else {
$to[$k] = self::mergeAssocArray($to[$k], $v, $clobber);
}
}
return $to;
}
return $clobber ? $from : $to;
} | [
"public",
"static",
"function",
"mergeAssocArray",
"(",
"$",
"to",
",",
"$",
"from",
",",
"$",
"clobber",
"=",
"true",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"from",
")",
")",
"{",
"foreach",
"(",
"$",
"from",
"as",
"$",
"k",
"=>",
"$",
"v",
... | Merge contents from one associtative array to another
@param array $to
@param array $from
@param bool $clobber | [
"Merge",
"contents",
"from",
"one",
"associtative",
"array",
"to",
"another"
] | train | https://github.com/dflydev/dflydev-dot-access-data/blob/b5899e067a8eb6fa4e4c64318a0bd71bad8c272c/src/Util.php#L38-L53 |
clue/reactphp-redis | src/Factory.php | Factory.createClient | public function createClient($target)
{
try {
$parts = $this->parseUrl($target);
} catch (InvalidArgumentException $e) {
return \React\Promise\reject($e);
}
$connecting = $this->connector->connect($parts['authority']);
$deferred = new Deferred(function ($_, $reject) use ($connecting) {
// connection cancelled, start with rejecting attempt, then clean up
$reject(new \RuntimeException('Connection to Redis server cancelled'));
// either close successful connection or cancel pending connection attempt
$connecting->then(function (ConnectionInterface $connection) {
$connection->close();
});
$connecting->cancel();
});
$protocol = $this->protocol;
$promise = $connecting->then(function (ConnectionInterface $stream) use ($protocol) {
return new StreamingClient($stream, $protocol->createResponseParser(), $protocol->createSerializer());
}, function (\Exception $e) {
throw new \RuntimeException(
'Connection to Redis server failed because underlying transport connection failed',
0,
$e
);
});
if (isset($parts['auth'])) {
$promise = $promise->then(function (StreamingClient $client) use ($parts) {
return $client->auth($parts['auth'])->then(
function () use ($client) {
return $client;
},
function ($error) use ($client) {
$client->close();
throw new \RuntimeException(
'Connection to Redis server failed because AUTH command failed',
0,
$error
);
}
);
});
}
if (isset($parts['db'])) {
$promise = $promise->then(function (StreamingClient $client) use ($parts) {
return $client->select($parts['db'])->then(
function () use ($client) {
return $client;
},
function ($error) use ($client) {
$client->close();
throw new \RuntimeException(
'Connection to Redis server failed because SELECT command failed',
0,
$error
);
}
);
});
}
$promise->then(array($deferred, 'resolve'), array($deferred, 'reject'));
// use timeout from explicit ?timeout=x parameter or default to PHP's default_socket_timeout (60)
$timeout = (float) isset($parts['timeout']) ? $parts['timeout'] : ini_get("default_socket_timeout");
if ($timeout < 0) {
return $deferred->promise();
}
return \React\Promise\Timer\timeout($deferred->promise(), $timeout, $this->loop)->then(null, function ($e) {
if ($e instanceof TimeoutException) {
throw new \RuntimeException(
'Connection to Redis server timed out after ' . $e->getTimeout() . ' seconds'
);
}
throw $e;
});
} | php | public function createClient($target)
{
try {
$parts = $this->parseUrl($target);
} catch (InvalidArgumentException $e) {
return \React\Promise\reject($e);
}
$connecting = $this->connector->connect($parts['authority']);
$deferred = new Deferred(function ($_, $reject) use ($connecting) {
// connection cancelled, start with rejecting attempt, then clean up
$reject(new \RuntimeException('Connection to Redis server cancelled'));
// either close successful connection or cancel pending connection attempt
$connecting->then(function (ConnectionInterface $connection) {
$connection->close();
});
$connecting->cancel();
});
$protocol = $this->protocol;
$promise = $connecting->then(function (ConnectionInterface $stream) use ($protocol) {
return new StreamingClient($stream, $protocol->createResponseParser(), $protocol->createSerializer());
}, function (\Exception $e) {
throw new \RuntimeException(
'Connection to Redis server failed because underlying transport connection failed',
0,
$e
);
});
if (isset($parts['auth'])) {
$promise = $promise->then(function (StreamingClient $client) use ($parts) {
return $client->auth($parts['auth'])->then(
function () use ($client) {
return $client;
},
function ($error) use ($client) {
$client->close();
throw new \RuntimeException(
'Connection to Redis server failed because AUTH command failed',
0,
$error
);
}
);
});
}
if (isset($parts['db'])) {
$promise = $promise->then(function (StreamingClient $client) use ($parts) {
return $client->select($parts['db'])->then(
function () use ($client) {
return $client;
},
function ($error) use ($client) {
$client->close();
throw new \RuntimeException(
'Connection to Redis server failed because SELECT command failed',
0,
$error
);
}
);
});
}
$promise->then(array($deferred, 'resolve'), array($deferred, 'reject'));
// use timeout from explicit ?timeout=x parameter or default to PHP's default_socket_timeout (60)
$timeout = (float) isset($parts['timeout']) ? $parts['timeout'] : ini_get("default_socket_timeout");
if ($timeout < 0) {
return $deferred->promise();
}
return \React\Promise\Timer\timeout($deferred->promise(), $timeout, $this->loop)->then(null, function ($e) {
if ($e instanceof TimeoutException) {
throw new \RuntimeException(
'Connection to Redis server timed out after ' . $e->getTimeout() . ' seconds'
);
}
throw $e;
});
} | [
"public",
"function",
"createClient",
"(",
"$",
"target",
")",
"{",
"try",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"parseUrl",
"(",
"$",
"target",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"return",
"\\",
"React",
... | Create Redis client connected to address of given redis instance
@param string $target Redis server URI to connect to
@return \React\Promise\PromiseInterface<Client> resolves with Client or rejects with \Exception | [
"Create",
"Redis",
"client",
"connected",
"to",
"address",
"of",
"given",
"redis",
"instance"
] | train | https://github.com/clue/reactphp-redis/blob/426e9dfd71e7ffa20de080a725589ff9b42762ca/src/Factory.php#L47-L132 |
Indatus/dispatcher | src/Indatus/Dispatcher/Services/CommandService.php | CommandService.runDue | public function runDue(Debugger $debugger)
{
$debugger->log('Running commands...');
/** @var \Indatus\Dispatcher\BackgroundProcessRunner $backgroundProcessRunner */
$backgroundProcessRunner = App::make('Indatus\Dispatcher\BackgroundProcessRunner');
/** @var \Indatus\Dispatcher\Queue $queue */
$queue = $this->scheduleService->getQueue($debugger);
foreach ($queue->flush() as $queueItem) {
/** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
$command = $queueItem->getCommand();
//determine if the command is enabled
if ($command->isEnabled()) {
if ($this->runnableInCurrentMaintenanceSetting($command)) {
if ($this->runnableInEnvironment($command)) {
$scheduler = $queueItem->getScheduler();
$backgroundProcessRunner->run(
$command,
$scheduler->getArguments(),
$scheduler->getOptions(),
$debugger
);
} else {
$debugger->commandNotRun(
$command,
'Command is not configured to run in '.App::environment()
);
}
} else {
$debugger->commandNotRun(
$command,
'Command is not configured to run while application is in maintenance mode'
);
}
} else {
$debugger->commandNotRun($command, 'Command is disabled');
}
}
} | php | public function runDue(Debugger $debugger)
{
$debugger->log('Running commands...');
/** @var \Indatus\Dispatcher\BackgroundProcessRunner $backgroundProcessRunner */
$backgroundProcessRunner = App::make('Indatus\Dispatcher\BackgroundProcessRunner');
/** @var \Indatus\Dispatcher\Queue $queue */
$queue = $this->scheduleService->getQueue($debugger);
foreach ($queue->flush() as $queueItem) {
/** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
$command = $queueItem->getCommand();
//determine if the command is enabled
if ($command->isEnabled()) {
if ($this->runnableInCurrentMaintenanceSetting($command)) {
if ($this->runnableInEnvironment($command)) {
$scheduler = $queueItem->getScheduler();
$backgroundProcessRunner->run(
$command,
$scheduler->getArguments(),
$scheduler->getOptions(),
$debugger
);
} else {
$debugger->commandNotRun(
$command,
'Command is not configured to run in '.App::environment()
);
}
} else {
$debugger->commandNotRun(
$command,
'Command is not configured to run while application is in maintenance mode'
);
}
} else {
$debugger->commandNotRun($command, 'Command is disabled');
}
}
} | [
"public",
"function",
"runDue",
"(",
"Debugger",
"$",
"debugger",
")",
"{",
"$",
"debugger",
"->",
"log",
"(",
"'Running commands...'",
")",
";",
"/** @var \\Indatus\\Dispatcher\\BackgroundProcessRunner $backgroundProcessRunner */",
"$",
"backgroundProcessRunner",
"=",
"App... | Run all commands that are due to be run | [
"Run",
"all",
"commands",
"that",
"are",
"due",
"to",
"be",
"run"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Services/CommandService.php#L32-L74 |
Indatus/dispatcher | src/Indatus/Dispatcher/Services/CommandService.php | CommandService.runnableInEnvironment | public function runnableInEnvironment(ScheduledCommandInterface $command)
{
$environment = $command->environment();
//if any
if ($environment == '*' || $environment == App::environment()) {
return true;
}
if (is_array($environment) && in_array(App::environment(), $environment)) {
return true;
}
return false;
} | php | public function runnableInEnvironment(ScheduledCommandInterface $command)
{
$environment = $command->environment();
//if any
if ($environment == '*' || $environment == App::environment()) {
return true;
}
if (is_array($environment) && in_array(App::environment(), $environment)) {
return true;
}
return false;
} | [
"public",
"function",
"runnableInEnvironment",
"(",
"ScheduledCommandInterface",
"$",
"command",
")",
"{",
"$",
"environment",
"=",
"$",
"command",
"->",
"environment",
"(",
")",
";",
"//if any",
"if",
"(",
"$",
"environment",
"==",
"'*'",
"||",
"$",
"environm... | Determine if a scheduled command is in the correct environment
@param \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command
@return bool | [
"Determine",
"if",
"a",
"scheduled",
"command",
"is",
"in",
"the",
"correct",
"environment"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Services/CommandService.php#L83-L97 |
Indatus/dispatcher | src/Indatus/Dispatcher/Services/CommandService.php | CommandService.prepareOptions | public function prepareOptions(array $options)
{
$optionPieces = [];
foreach ($options as $opt => $value) {
//if it's an array of options, throw them in there as well
if (is_array($value)) {
foreach ($value as $optArrayValue) {
$optionPieces[] = '--'.$opt.'="'.addslashes($optArrayValue).'"';
}
} else {
$option = null;
//option exists with no value
if (is_numeric($opt)) {
$option = $value;
} elseif (!empty($value)) {
$option = $opt.'="'.addslashes($value).'"';
}
if (!is_null($option)) {
$optionPieces[] = '--'.$option;
}
}
}
return implode(' ', $optionPieces);
} | php | public function prepareOptions(array $options)
{
$optionPieces = [];
foreach ($options as $opt => $value) {
//if it's an array of options, throw them in there as well
if (is_array($value)) {
foreach ($value as $optArrayValue) {
$optionPieces[] = '--'.$opt.'="'.addslashes($optArrayValue).'"';
}
} else {
$option = null;
//option exists with no value
if (is_numeric($opt)) {
$option = $value;
} elseif (!empty($value)) {
$option = $opt.'="'.addslashes($value).'"';
}
if (!is_null($option)) {
$optionPieces[] = '--'.$option;
}
}
}
return implode(' ', $optionPieces);
} | [
"public",
"function",
"prepareOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"optionPieces",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"opt",
"=>",
"$",
"value",
")",
"{",
"//if it's an array of options, throw them in there as well",... | Prepare a command's options for command line usage
@param array $options
@return string | [
"Prepare",
"a",
"command",
"s",
"options",
"for",
"command",
"line",
"usage"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Services/CommandService.php#L134-L160 |
Indatus/dispatcher | src/Indatus/Dispatcher/Services/CommandService.php | CommandService.getRunCommand | public function getRunCommand(
ScheduledCommandInterface $scheduledCommand,
array $arguments = [],
array $options = []
) {
/** @var \Indatus\Dispatcher\Platform $platform */
$platform = App::make('Indatus\Dispatcher\Platform');
$commandPieces = [];
if ($platform->isHHVM()) {
$commandPieces[] = '/usr/bin/env hhvm';
} else {
$commandPieces[] = PHP_BINARY;
}
$commandPieces[] = base_path().'/artisan';
$commandPieces[] = $scheduledCommand->getName();
if (count($arguments) > 0) {
$commandPieces[] = $this->prepareArguments($arguments);
}
if (count($options) > 0) {
$commandPieces[] = $this->prepareOptions($options);
}
//always pass environment
$commandPieces[] = '--env='.App::environment();
if ($platform->isUnix()) {
$commandPieces[] = '> /dev/null'; //don't show output, errors can be viewed in the Laravel log
$commandPieces[] = '&'; //run in background
//run the command as a different user
if (is_string($scheduledCommand->user())) {
array_unshift($commandPieces, 'sudo -u '.$scheduledCommand->user());
}
} elseif ($platform->isWindows()) {
$commandPieces[] = '> NULL'; //don't show output, errors can be viewed in the Laravel log
//run in background on windows
array_unshift($commandPieces, '/B');
array_unshift($commandPieces, 'START');
}
return implode(' ', $commandPieces);
} | php | public function getRunCommand(
ScheduledCommandInterface $scheduledCommand,
array $arguments = [],
array $options = []
) {
/** @var \Indatus\Dispatcher\Platform $platform */
$platform = App::make('Indatus\Dispatcher\Platform');
$commandPieces = [];
if ($platform->isHHVM()) {
$commandPieces[] = '/usr/bin/env hhvm';
} else {
$commandPieces[] = PHP_BINARY;
}
$commandPieces[] = base_path().'/artisan';
$commandPieces[] = $scheduledCommand->getName();
if (count($arguments) > 0) {
$commandPieces[] = $this->prepareArguments($arguments);
}
if (count($options) > 0) {
$commandPieces[] = $this->prepareOptions($options);
}
//always pass environment
$commandPieces[] = '--env='.App::environment();
if ($platform->isUnix()) {
$commandPieces[] = '> /dev/null'; //don't show output, errors can be viewed in the Laravel log
$commandPieces[] = '&'; //run in background
//run the command as a different user
if (is_string($scheduledCommand->user())) {
array_unshift($commandPieces, 'sudo -u '.$scheduledCommand->user());
}
} elseif ($platform->isWindows()) {
$commandPieces[] = '> NULL'; //don't show output, errors can be viewed in the Laravel log
//run in background on windows
array_unshift($commandPieces, '/B');
array_unshift($commandPieces, 'START');
}
return implode(' ', $commandPieces);
} | [
"public",
"function",
"getRunCommand",
"(",
"ScheduledCommandInterface",
"$",
"scheduledCommand",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"/** @var \\Indatus\\Dispatcher\\Platform $platform */",
"$",
"pla... | Get a command to run this application
@param \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $scheduledCommand
@param array $arguments
@param array $options
@return string | [
"Get",
"a",
"command",
"to",
"run",
"this",
"application"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Services/CommandService.php#L171-L217 |
Indatus/dispatcher | src/Indatus/Dispatcher/Services/ScheduleService.php | ScheduleService.getScheduledCommands | public function getScheduledCommands()
{
$scheduledCommands = [];
foreach ($this->console->all() as $command) {
if ($command instanceof ScheduledCommandInterface) {
$scheduledCommands[] = $command;
}
}
return $scheduledCommands;
} | php | public function getScheduledCommands()
{
$scheduledCommands = [];
foreach ($this->console->all() as $command) {
if ($command instanceof ScheduledCommandInterface) {
$scheduledCommands[] = $command;
}
}
return $scheduledCommands;
} | [
"public",
"function",
"getScheduledCommands",
"(",
")",
"{",
"$",
"scheduledCommands",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"console",
"->",
"all",
"(",
")",
"as",
"$",
"command",
")",
"{",
"if",
"(",
"$",
"command",
"instanceof",
"Sc... | Get all commands that are scheduled
@return \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface[] | [
"Get",
"all",
"commands",
"that",
"are",
"scheduled"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Services/ScheduleService.php#L42-L52 |
Indatus/dispatcher | src/Indatus/Dispatcher/Services/ScheduleService.php | ScheduleService.getQueue | public function getQueue(Debugger $debugger)
{
/** @var \Indatus\Dispatcher\Queue $queue */
$queue = App::make('Indatus\Dispatcher\Queue');
/** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
foreach ($this->getScheduledCommands() as $command) {
/** @var \Indatus\Dispatcher\Scheduling\Schedulable $scheduler */
$scheduler = App::make('Indatus\Dispatcher\Scheduling\Schedulable');
//could be multiple schedules based on arguments
$schedules = $command->schedule($scheduler);
if (!is_array($schedules)) {
$schedules = [$schedules];
}
$willBeRun = false;
foreach ($schedules as $schedule) {
if (($schedule instanceof Schedulable) === false) {
$msg = 'Schedule for "'.$command->getName().'" is not an instance of Schedulable';
throw new \InvalidArgumentException($msg);
}
if ($this->isDue($schedule)) {
/** @var \Indatus\Dispatcher\QueueItem $queueItem */
$queueItem = App::make('Indatus\Dispatcher\QueueItem');
$queueItem->setCommand($command);
$queueItem->setScheduler($schedule);
if ($queue->add($queueItem)) {
$willBeRun = true;
}
}
}
//it didn't run, so record that it didn't run
if ($willBeRun === false) {
$debugger->commandNotRun($command, 'No schedules were due');
}
}
return $queue;
} | php | public function getQueue(Debugger $debugger)
{
/** @var \Indatus\Dispatcher\Queue $queue */
$queue = App::make('Indatus\Dispatcher\Queue');
/** @var \Indatus\Dispatcher\Scheduling\ScheduledCommandInterface $command */
foreach ($this->getScheduledCommands() as $command) {
/** @var \Indatus\Dispatcher\Scheduling\Schedulable $scheduler */
$scheduler = App::make('Indatus\Dispatcher\Scheduling\Schedulable');
//could be multiple schedules based on arguments
$schedules = $command->schedule($scheduler);
if (!is_array($schedules)) {
$schedules = [$schedules];
}
$willBeRun = false;
foreach ($schedules as $schedule) {
if (($schedule instanceof Schedulable) === false) {
$msg = 'Schedule for "'.$command->getName().'" is not an instance of Schedulable';
throw new \InvalidArgumentException($msg);
}
if ($this->isDue($schedule)) {
/** @var \Indatus\Dispatcher\QueueItem $queueItem */
$queueItem = App::make('Indatus\Dispatcher\QueueItem');
$queueItem->setCommand($command);
$queueItem->setScheduler($schedule);
if ($queue->add($queueItem)) {
$willBeRun = true;
}
}
}
//it didn't run, so record that it didn't run
if ($willBeRun === false) {
$debugger->commandNotRun($command, 'No schedules were due');
}
}
return $queue;
} | [
"public",
"function",
"getQueue",
"(",
"Debugger",
"$",
"debugger",
")",
"{",
"/** @var \\Indatus\\Dispatcher\\Queue $queue */",
"$",
"queue",
"=",
"App",
"::",
"make",
"(",
"'Indatus\\Dispatcher\\Queue'",
")",
";",
"/** @var \\Indatus\\Dispatcher\\Scheduling\\ScheduledComman... | Get all commands that are due to be run
@param Debugger $debugger
@throws \InvalidArgumentException
@return \Indatus\Dispatcher\Queue | [
"Get",
"all",
"commands",
"that",
"are",
"due",
"to",
"be",
"run"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Services/ScheduleService.php#L62-L105 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.getSchedule | public function getSchedule()
{
return implode(' ', [
$this->getScheduleMonth(),
$this->getScheduleWeek(),
$this->getScheduleDayOfMonth(),
$this->getScheduleDayOfWeek(),
$this->getScheduleHour(),
$this->getScheduleMinute()
]);
} | php | public function getSchedule()
{
return implode(' ', [
$this->getScheduleMonth(),
$this->getScheduleWeek(),
$this->getScheduleDayOfMonth(),
$this->getScheduleDayOfWeek(),
$this->getScheduleHour(),
$this->getScheduleMinute()
]);
} | [
"public",
"function",
"getSchedule",
"(",
")",
"{",
"return",
"implode",
"(",
"' '",
",",
"[",
"$",
"this",
"->",
"getScheduleMonth",
"(",
")",
",",
"$",
"this",
"->",
"getScheduleWeek",
"(",
")",
",",
"$",
"this",
"->",
"getScheduleDayOfMonth",
"(",
")"... | Get the scheduling definition in a readable way
@return string | [
"Get",
"the",
"scheduling",
"definition",
"in",
"a",
"readable",
"way"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L35-L45 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.setSchedule | public function setSchedule($minute, $hour, $dayOfMonth, $month, $dayOfWeek, $week = self::NONE)
{
$month = $this->parseTimeParameter($month);
$week = $this->parseTimeParameter($week);
$dayOfMonth = $this->parseTimeParameter($dayOfMonth);
$dayOfWeek = $this->parseTimeParameter($dayOfWeek);
$hour = $this->parseTimeParameter($hour);
$minute = $this->parseTimeParameter($minute);
$this->setScheduleMonth($month);
$this->setScheduleWeek($week);
$this->setScheduleDayOfMonth($dayOfMonth);
$this->setScheduleDayOfWeek($dayOfWeek);
$this->setScheduleHour($hour);
$this->setScheduleMinute($minute);
return $this;
} | php | public function setSchedule($minute, $hour, $dayOfMonth, $month, $dayOfWeek, $week = self::NONE)
{
$month = $this->parseTimeParameter($month);
$week = $this->parseTimeParameter($week);
$dayOfMonth = $this->parseTimeParameter($dayOfMonth);
$dayOfWeek = $this->parseTimeParameter($dayOfWeek);
$hour = $this->parseTimeParameter($hour);
$minute = $this->parseTimeParameter($minute);
$this->setScheduleMonth($month);
$this->setScheduleWeek($week);
$this->setScheduleDayOfMonth($dayOfMonth);
$this->setScheduleDayOfWeek($dayOfWeek);
$this->setScheduleHour($hour);
$this->setScheduleMinute($minute);
return $this;
} | [
"public",
"function",
"setSchedule",
"(",
"$",
"minute",
",",
"$",
"hour",
",",
"$",
"dayOfMonth",
",",
"$",
"month",
",",
"$",
"dayOfWeek",
",",
"$",
"week",
"=",
"self",
"::",
"NONE",
")",
"{",
"$",
"month",
"=",
"$",
"this",
"->",
"parseTimeParame... | Manually set a command's execution schedule. Parameter
order follows standard cron syntax
@param int|array $minute
@param int|array $hour
@param int|array $dayOfMonth
@param int|array $month
@param int|array $dayOfWeek
@param string|int|array $week
@return $this | [
"Manually",
"set",
"a",
"command",
"s",
"execution",
"schedule",
".",
"Parameter",
"order",
"follows",
"standard",
"cron",
"syntax"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L75-L92 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.quarterly | public function quarterly()
{
$months = [Month::JANUARY, Month::APRIL, Month::JULY, Month::OCTOBER];
$this->setScheduleMonth($this->parseTimeParameter($months));
$this->setScheduleWeek(self::NONE);
$this->setScheduleDayOfMonth(1);
$this->setScheduleDayOfWeek(self::ANY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | php | public function quarterly()
{
$months = [Month::JANUARY, Month::APRIL, Month::JULY, Month::OCTOBER];
$this->setScheduleMonth($this->parseTimeParameter($months));
$this->setScheduleWeek(self::NONE);
$this->setScheduleDayOfMonth(1);
$this->setScheduleDayOfWeek(self::ANY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | [
"public",
"function",
"quarterly",
"(",
")",
"{",
"$",
"months",
"=",
"[",
"Month",
"::",
"JANUARY",
",",
"Month",
"::",
"APRIL",
",",
"Month",
"::",
"JULY",
",",
"Month",
"::",
"OCTOBER",
"]",
";",
"$",
"this",
"->",
"setScheduleMonth",
"(",
"$",
"t... | Run once a quarter at the beginning of the quarter
@return $this | [
"Run",
"once",
"a",
"quarter",
"at",
"the",
"beginning",
"of",
"the",
"quarter"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L116-L127 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.monthly | public function monthly()
{
$this->setScheduleMonth(self::ANY);
$this->setScheduleWeek(self::NONE);
$this->setScheduleDayOfMonth(1);
$this->setScheduleDayOfWeek(self::ANY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | php | public function monthly()
{
$this->setScheduleMonth(self::ANY);
$this->setScheduleWeek(self::NONE);
$this->setScheduleDayOfMonth(1);
$this->setScheduleDayOfWeek(self::ANY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | [
"public",
"function",
"monthly",
"(",
")",
"{",
"$",
"this",
"->",
"setScheduleMonth",
"(",
"self",
"::",
"ANY",
")",
";",
"$",
"this",
"->",
"setScheduleWeek",
"(",
"self",
"::",
"NONE",
")",
";",
"$",
"this",
"->",
"setScheduleDayOfMonth",
"(",
"1",
... | Run once a month at midnight in the morning of the first day of the month
@return $this | [
"Run",
"once",
"a",
"month",
"at",
"midnight",
"in",
"the",
"morning",
"of",
"the",
"first",
"day",
"of",
"the",
"month"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L146-L156 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.everyOddWeek | public function everyOddWeek()
{
$this->setScheduleMonth(self::ANY);
$this->setScheduleWeek('odd');
$this->setScheduleDayOfMonth(self::ANY);
$this->setScheduleDayOfWeek(self::ANY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | php | public function everyOddWeek()
{
$this->setScheduleMonth(self::ANY);
$this->setScheduleWeek('odd');
$this->setScheduleDayOfMonth(self::ANY);
$this->setScheduleDayOfWeek(self::ANY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | [
"public",
"function",
"everyOddWeek",
"(",
")",
"{",
"$",
"this",
"->",
"setScheduleMonth",
"(",
"self",
"::",
"ANY",
")",
";",
"$",
"this",
"->",
"setScheduleWeek",
"(",
"'odd'",
")",
";",
"$",
"this",
"->",
"setScheduleDayOfMonth",
"(",
"self",
"::",
"... | Run once every odd week at midnight on Sunday morning
@return $this | [
"Run",
"once",
"every",
"odd",
"week",
"at",
"midnight",
"on",
"Sunday",
"morning"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L187-L197 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.weekly | public function weekly()
{
$this->setScheduleMonth(self::ANY);
$this->setScheduleWeek(self::ANY);
$this->setScheduleDayOfMonth(self::ANY);
$this->setScheduleDayOfWeek(Day::SUNDAY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | php | public function weekly()
{
$this->setScheduleMonth(self::ANY);
$this->setScheduleWeek(self::ANY);
$this->setScheduleDayOfMonth(self::ANY);
$this->setScheduleDayOfWeek(Day::SUNDAY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | [
"public",
"function",
"weekly",
"(",
")",
"{",
"$",
"this",
"->",
"setScheduleMonth",
"(",
"self",
"::",
"ANY",
")",
";",
"$",
"this",
"->",
"setScheduleWeek",
"(",
"self",
"::",
"ANY",
")",
";",
"$",
"this",
"->",
"setScheduleDayOfMonth",
"(",
"self",
... | Run once a week at midnight on Sunday morning
@return $this | [
"Run",
"once",
"a",
"week",
"at",
"midnight",
"on",
"Sunday",
"morning"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L221-L231 |
Indatus/dispatcher | src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php | Scheduler.weekOfYear | public function weekOfYear($week)
{
$this->setScheduleMonth(self::NONE);
$this->setScheduleWeek($this->parseTimeParameter($week));
$this->setScheduleDayOfMonth(self::ANY);
$this->setScheduleDayOfWeek(Day::SUNDAY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | php | public function weekOfYear($week)
{
$this->setScheduleMonth(self::NONE);
$this->setScheduleWeek($this->parseTimeParameter($week));
$this->setScheduleDayOfMonth(self::ANY);
$this->setScheduleDayOfWeek(Day::SUNDAY);
$this->setScheduleHour(0);
$this->setScheduleMinute(0);
return $this;
} | [
"public",
"function",
"weekOfYear",
"(",
"$",
"week",
")",
"{",
"$",
"this",
"->",
"setScheduleMonth",
"(",
"self",
"::",
"NONE",
")",
";",
"$",
"this",
"->",
"setScheduleWeek",
"(",
"$",
"this",
"->",
"parseTimeParameter",
"(",
"$",
"week",
")",
")",
... | Run on the given week of each month
@param int|array $week
@throws BadScheduleException
@return $this | [
"Run",
"on",
"the",
"given",
"week",
"of",
"each",
"month"
] | train | https://github.com/Indatus/dispatcher/blob/9548ab90d0c1e9a2ff7239f28e470de4493c00ff/src/Indatus/Dispatcher/Drivers/DateTime/Scheduler.php#L257-L267 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.