repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
luyadev/luya-module-admin | src/ngrest/base/ActiveWindow.php | ActiveWindow.getHashName | public function getHashName()
{
if ($this->_hashName === null) {
$this->_hashName = sha1(get_called_class());
}
return $this->_hashName;
} | php | public function getHashName()
{
if ($this->_hashName === null) {
$this->_hashName = sha1(get_called_class());
}
return $this->_hashName;
} | [
"public",
"function",
"getHashName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_hashName",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_hashName",
"=",
"sha1",
"(",
"get_called_class",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_hash... | Get a unique identifier hash based on the name and config values like icon and label.
@return string | [
"Get",
"a",
"unique",
"identifier",
"hash",
"based",
"on",
"the",
"name",
"and",
"config",
"values",
"like",
"icon",
"and",
"label",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveWindow.php#L283-L290 | train |
luyadev/luya-module-admin | src/ngrest/base/ActiveWindow.php | ActiveWindow.getViewPath | public function getViewPath()
{
$module = $this->module;
if (substr($module, 0, 1) !== '@') {
$module = '@'.$module;
}
return implode(DIRECTORY_SEPARATOR, [Yii::getAlias($module), 'views', 'aws', $this->getViewFolderName()]);
} | php | public function getViewPath()
{
$module = $this->module;
if (substr($module, 0, 1) !== '@') {
$module = '@'.$module;
}
return implode(DIRECTORY_SEPARATOR, [Yii::getAlias($module), 'views', 'aws', $this->getViewFolderName()]);
} | [
"public",
"function",
"getViewPath",
"(",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"module",
";",
"if",
"(",
"substr",
"(",
"$",
"module",
",",
"0",
",",
"1",
")",
"!==",
"'@'",
")",
"{",
"$",
"module",
"=",
"'@'",
".",
"$",
"module",
"... | Return the view path for view context.
{@inheritDoc}
@see \yii\base\ViewContextInterface::getViewPath() | [
"Return",
"the",
"view",
"path",
"for",
"view",
"context",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/ActiveWindow.php#L298-L307 | train |
luyadev/luya-module-admin | src/dashboard/BaseDashboardObject.php | BaseDashboardObject.setTitle | public function setTitle($title)
{
if (is_array($title)) {
list($category, $message) = $title;
$this->_title = Yii::t($category, $message);
} else {
$this->_title = $title;
}
} | php | public function setTitle($title)
{
if (is_array($title)) {
list($category, $message) = $title;
$this->_title = Yii::t($category, $message);
} else {
$this->_title = $title;
}
} | [
"public",
"function",
"setTitle",
"(",
"$",
"title",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"title",
")",
")",
"{",
"list",
"(",
"$",
"category",
",",
"$",
"message",
")",
"=",
"$",
"title",
";",
"$",
"this",
"->",
"_title",
"=",
"Yii",
"::",... | Setter method for title.
The title can be either a string on array, if an array is provided the first key is used to defined the yii2 message category and second key
is used in order to find the message. For example the input array `['cmsadmin', 'mytitle']` would be converted to `Yii::t('cmsadmin', 'mytitle')`.
@param string|array $title The title of the dashboard object item, if an array is given the first element is the translation category the second element the message. | [
"Setter",
"method",
"for",
"title",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/dashboard/BaseDashboardObject.php#L90-L98 | train |
luyadev/luya-module-admin | src/ngrest/base/Controller.php | Controller.getModel | public function getModel()
{
if ($this->_model === null) {
$this->_model = Yii::createObject($this->modelClass);
}
return $this->_model;
} | php | public function getModel()
{
if ($this->_model === null) {
$this->_model = Yii::createObject($this->modelClass);
}
return $this->_model;
} | [
"public",
"function",
"getModel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_model",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_model",
"=",
"Yii",
"::",
"createObject",
"(",
"$",
"this",
"->",
"modelClass",
")",
";",
"}",
"return",
"$",
"th... | Get Model Object
@return \luya\admin\ngrest\base\NgRestModel | [
"Get",
"Model",
"Object"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/Controller.php#L135-L142 | train |
luyadev/luya-module-admin | src/ngrest/base/Controller.php | Controller.actionIndex | public function actionIndex($inline = false, $relation = false, $arrayIndex = false, $modelClass = false, $modelSelection = false)
{
$apiEndpoint = $this->model->ngRestApiEndpoint();
$config = $this->model->getNgRestConfig();
$userSortSettings = Yii::$app->adminuser->identity->setting->get('ngrestorder.admin/'.$apiEndpoint, false);
if ($userSortSettings && is_array($userSortSettings) && $config->getDefaultOrder() !== false) {
$config->defaultOrder = [$userSortSettings['field'] => $userSortSettings['sort']];
}
// generate crud renderer
$crud = Yii::createObject($this->renderCrud);
$crud->setModel($this->model);
$crud->setSettingButtonDefinitions($this->globalButtons);
$crud->setIsInline($inline);
$crud->setModelSelection($modelSelection);
if ($relation && is_numeric($relation) && $arrayIndex !== false && $modelClass !== false) {
$crud->setRelationCall(['id' => $relation, 'arrayIndex' => $arrayIndex, 'modelClass' => $modelClass]);
}
// generate ngrest object from config and render renderer
$ngrest = new NgRest($config);
return $ngrest->render($crud);
} | php | public function actionIndex($inline = false, $relation = false, $arrayIndex = false, $modelClass = false, $modelSelection = false)
{
$apiEndpoint = $this->model->ngRestApiEndpoint();
$config = $this->model->getNgRestConfig();
$userSortSettings = Yii::$app->adminuser->identity->setting->get('ngrestorder.admin/'.$apiEndpoint, false);
if ($userSortSettings && is_array($userSortSettings) && $config->getDefaultOrder() !== false) {
$config->defaultOrder = [$userSortSettings['field'] => $userSortSettings['sort']];
}
// generate crud renderer
$crud = Yii::createObject($this->renderCrud);
$crud->setModel($this->model);
$crud->setSettingButtonDefinitions($this->globalButtons);
$crud->setIsInline($inline);
$crud->setModelSelection($modelSelection);
if ($relation && is_numeric($relation) && $arrayIndex !== false && $modelClass !== false) {
$crud->setRelationCall(['id' => $relation, 'arrayIndex' => $arrayIndex, 'modelClass' => $modelClass]);
}
// generate ngrest object from config and render renderer
$ngrest = new NgRest($config);
return $ngrest->render($crud);
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"inline",
"=",
"false",
",",
"$",
"relation",
"=",
"false",
",",
"$",
"arrayIndex",
"=",
"false",
",",
"$",
"modelClass",
"=",
"false",
",",
"$",
"modelSelection",
"=",
"false",
")",
"{",
"$",
"apiEndpoint",... | Render the ngrest default index template.
@param string $inline
@param string $relation
@param string $arrayIndex
@param string $modelClass
@param string $modelSelection
@throws Exception
@return string | [
"Render",
"the",
"ngrest",
"default",
"index",
"template",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/Controller.php#L155-L180 | train |
luyadev/luya-module-admin | src/ngrest/base/Controller.php | Controller.actionExportDownload | public function actionExportDownload($key)
{
$sessionkey = Yii::$app->session->get('tempNgRestFileKey');
$fileName = Yii::$app->session->get('tempNgRestFileName');
$mimeType = Yii::$app->session->get('tempNgRestFileMime');
if ($sessionkey !== base64_decode($key)) {
throw new ForbiddenHttpException('Invalid download key.');
}
$content = FileHelper::getFileContent('@runtime/'.$sessionkey.'.tmp');
Yii::$app->session->remove('tempNgRestFileKey');
Yii::$app->session->remove('tempNgRestFileName');
Yii::$app->session->remove('tempNgRestFileMime');
@unlink(Yii::getAlias('@runtime/'.$sessionkey.'.tmp'));
return Yii::$app->response->sendContentAsFile($content, $fileName, ['mimeType' => $mimeType]);
} | php | public function actionExportDownload($key)
{
$sessionkey = Yii::$app->session->get('tempNgRestFileKey');
$fileName = Yii::$app->session->get('tempNgRestFileName');
$mimeType = Yii::$app->session->get('tempNgRestFileMime');
if ($sessionkey !== base64_decode($key)) {
throw new ForbiddenHttpException('Invalid download key.');
}
$content = FileHelper::getFileContent('@runtime/'.$sessionkey.'.tmp');
Yii::$app->session->remove('tempNgRestFileKey');
Yii::$app->session->remove('tempNgRestFileName');
Yii::$app->session->remove('tempNgRestFileMime');
@unlink(Yii::getAlias('@runtime/'.$sessionkey.'.tmp'));
return Yii::$app->response->sendContentAsFile($content, $fileName, ['mimeType' => $mimeType]);
} | [
"public",
"function",
"actionExportDownload",
"(",
"$",
"key",
")",
"{",
"$",
"sessionkey",
"=",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"get",
"(",
"'tempNgRestFileKey'",
")",
";",
"$",
"fileName",
"=",
"Yii",
"::",
"$",
"app",
"->",
"session",
... | Get the file content response for a given key.
@param string $key
@throws ForbiddenHttpException
@return \yii\web\Response | [
"Get",
"the",
"file",
"content",
"response",
"for",
"a",
"given",
"key",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/Controller.php#L189-L207 | train |
luyadev/luya-module-admin | src/commands/ActiveWindowController.php | ActiveWindowController.renderWindowClassView | public function renderWindowClassView($className, $namespace, $moduleId)
{
$alias = Inflector::humanize(Inflector::camel2words($className));
return $this->view->render('@admin/commands/views/aw/classfile.php', [
'className' => $className,
'namespace' => $namespace,
'luyaText' => $this->getGeneratorText('aw/create'),
'moduleId' => $moduleId,
'alias' => $alias,
]);
} | php | public function renderWindowClassView($className, $namespace, $moduleId)
{
$alias = Inflector::humanize(Inflector::camel2words($className));
return $this->view->render('@admin/commands/views/aw/classfile.php', [
'className' => $className,
'namespace' => $namespace,
'luyaText' => $this->getGeneratorText('aw/create'),
'moduleId' => $moduleId,
'alias' => $alias,
]);
} | [
"public",
"function",
"renderWindowClassView",
"(",
"$",
"className",
",",
"$",
"namespace",
",",
"$",
"moduleId",
")",
"{",
"$",
"alias",
"=",
"Inflector",
"::",
"humanize",
"(",
"Inflector",
"::",
"camel2words",
"(",
"$",
"className",
")",
")",
";",
"ret... | Render the view file with its parameters.
@param string $className The class name to use.
@param string $namespace The namespace for the file.
@param string $moduleId The module identifier.
@return string | [
"Render",
"the",
"view",
"file",
"with",
"its",
"parameters",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/ActiveWindowController.php#L36-L46 | train |
luyadev/luya-module-admin | src/commands/ActiveWindowController.php | ActiveWindowController.actionCreate | public function actionCreate()
{
$name = $this->prompt("Please enter a name for the Active Window:", [
'required' => true,
]);
$className = $this->createClassName($name, $this->suffix);
$moduleId = $this->selectModule(['text' => 'What module should '.$className.' belong to?', 'onlyAdmin' => true]);
$module = Yii::$app->getModule($moduleId);
$folder = $module->basePath . DIRECTORY_SEPARATOR . 'aws';
$file = $folder . DIRECTORY_SEPARATOR . $className . '.php';
$namespace = $module->getNamespace() . '\\aws';
if (FileHelper::createDirectory($folder) && FileHelper::writeFile($file, $this->renderWindowClassView($className, $namespace, $moduleId))) {
$object = Yii::createObject(['class' => $namespace . '\\' . $className]);
if (FileHelper::createDirectory($object->getViewPath()) && FileHelper::writeFile($object->getViewPath() . DIRECTORY_SEPARATOR . 'index.php', $this->renderWindowClassViewFile($className, $moduleId))) {
$this->outputInfo("View file generated.");
}
return $this->outputSuccess("Active Window '$file' created.");
}
return $this->outputError("Error while writing the Actice Window file '$file'.");
} | php | public function actionCreate()
{
$name = $this->prompt("Please enter a name for the Active Window:", [
'required' => true,
]);
$className = $this->createClassName($name, $this->suffix);
$moduleId = $this->selectModule(['text' => 'What module should '.$className.' belong to?', 'onlyAdmin' => true]);
$module = Yii::$app->getModule($moduleId);
$folder = $module->basePath . DIRECTORY_SEPARATOR . 'aws';
$file = $folder . DIRECTORY_SEPARATOR . $className . '.php';
$namespace = $module->getNamespace() . '\\aws';
if (FileHelper::createDirectory($folder) && FileHelper::writeFile($file, $this->renderWindowClassView($className, $namespace, $moduleId))) {
$object = Yii::createObject(['class' => $namespace . '\\' . $className]);
if (FileHelper::createDirectory($object->getViewPath()) && FileHelper::writeFile($object->getViewPath() . DIRECTORY_SEPARATOR . 'index.php', $this->renderWindowClassViewFile($className, $moduleId))) {
$this->outputInfo("View file generated.");
}
return $this->outputSuccess("Active Window '$file' created.");
}
return $this->outputError("Error while writing the Actice Window file '$file'.");
} | [
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"prompt",
"(",
"\"Please enter a name for the Active Window:\"",
",",
"[",
"'required'",
"=>",
"true",
",",
"]",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"... | Create a new ActiveWindow class based on you properties. | [
"Create",
"a",
"new",
"ActiveWindow",
"class",
"based",
"on",
"you",
"properties",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/ActiveWindowController.php#L59-L88 | train |
luyadev/luya-module-admin | src/base/RestActiveController.php | RestActiveController.can | public function can($type)
{
if (!in_array($type, [Auth::CAN_CREATE, Auth::CAN_DELETE, Auth::CAN_UPDATE, Auth::CAN_VIEW])) {
throw new InvalidConfigException("Invalid type of permission check.");
}
$can = Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, $type);
if (!$can) {
throw new ForbiddenHttpException("User is unable to access the API due to insufficient permissions.");
}
return true;
} | php | public function can($type)
{
if (!in_array($type, [Auth::CAN_CREATE, Auth::CAN_DELETE, Auth::CAN_UPDATE, Auth::CAN_VIEW])) {
throw new InvalidConfigException("Invalid type of permission check.");
}
$can = Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, $type);
if (!$can) {
throw new ForbiddenHttpException("User is unable to access the API due to insufficient permissions.");
}
return true;
} | [
"public",
"function",
"can",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"type",
",",
"[",
"Auth",
"::",
"CAN_CREATE",
",",
"Auth",
"::",
"CAN_DELETE",
",",
"Auth",
"::",
"CAN_UPDATE",
",",
"Auth",
"::",
"CAN_VIEW",
"]",
")",
... | Check if the current user have given permissions type.
```php
$this->can(Auth::CAN_UPDATE);
```
If the user has no permission to update a forbidden http exception is thrown.
@param integer $type
@return boolean Returns true otherwise throws an exception
@throws ForbiddenHttpException
@since 2.0.0 | [
"Check",
"if",
"the",
"current",
"user",
"have",
"given",
"permissions",
"type",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/RestActiveController.php#L98-L111 | train |
luyadev/luya-module-admin | src/base/RestActiveController.php | RestActiveController.checkEndpointAccess | public function checkEndpointAccess()
{
UserOnline::refreshUser($this->userAuthClass()->identity, $this->id);
if (!Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, false)) {
throw new ForbiddenHttpException('Unable to access this action due to insufficient permissions.');
}
} | php | public function checkEndpointAccess()
{
UserOnline::refreshUser($this->userAuthClass()->identity, $this->id);
if (!Yii::$app->auth->matchApi($this->userAuthClass()->identity->id, $this->id, false)) {
throw new ForbiddenHttpException('Unable to access this action due to insufficient permissions.');
}
} | [
"public",
"function",
"checkEndpointAccess",
"(",
")",
"{",
"UserOnline",
"::",
"refreshUser",
"(",
"$",
"this",
"->",
"userAuthClass",
"(",
")",
"->",
"identity",
",",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
... | Checks if the current api endpoint exists in the list of accessables APIs.
@throws ForbiddenHttpException
@since 1.1.0 | [
"Checks",
"if",
"the",
"current",
"api",
"endpoint",
"exists",
"in",
"the",
"list",
"of",
"accessables",
"APIs",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/RestActiveController.php#L119-L126 | train |
luyadev/luya-module-admin | src/models/UserChangePassword.php | UserChangePassword.checkAndStore | public function checkAndStore()
{
if (!$this->user->validatePassword($this->oldpass)) {
return $this->addError('oldpass', 'The previous old password is invalid.');
}
if (!$this->user->changePassword($this->newpass)) {
return $this->addErrors($this->user->getErrors());
}
} | php | public function checkAndStore()
{
if (!$this->user->validatePassword($this->oldpass)) {
return $this->addError('oldpass', 'The previous old password is invalid.');
}
if (!$this->user->changePassword($this->newpass)) {
return $this->addErrors($this->user->getErrors());
}
} | [
"public",
"function",
"checkAndStore",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"user",
"->",
"validatePassword",
"(",
"$",
"this",
"->",
"oldpass",
")",
")",
"{",
"return",
"$",
"this",
"->",
"addError",
"(",
"'oldpass'",
",",
"'The previous ol... | Checks if the password is valid and stores the new password.
@return boolean | [
"Checks",
"if",
"the",
"password",
"is",
"valid",
"and",
"stores",
"the",
"new",
"password",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserChangePassword.php#L73-L82 | train |
luyadev/luya-module-admin | src/aws/FlowActiveWindowTrait.php | FlowActiveWindowTrait.flowSaveImage | public function flowSaveImage(Item $image)
{
Yii::$app->db->createCommand()->insert($this->getConfigValue('table'), [
$this->getConfigValue('itemField') => $this->id,
$this->getConfigValue('imageField') => $image->id,
])->execute();
} | php | public function flowSaveImage(Item $image)
{
Yii::$app->db->createCommand()->insert($this->getConfigValue('table'), [
$this->getConfigValue('itemField') => $this->id,
$this->getConfigValue('imageField') => $image->id,
])->execute();
} | [
"public",
"function",
"flowSaveImage",
"(",
"Item",
"$",
"image",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"insert",
"(",
"$",
"this",
"->",
"getConfigValue",
"(",
"'table'",
")",
",",
"[",
"$",
"this",
"-... | This method will be called when the storage item is created, so you can perform the database save action
by implementing this method.
@param \admin\image\Item $image The storage image item object which has been generated from active window. | [
"This",
"method",
"will",
"be",
"called",
"when",
"the",
"storage",
"item",
"is",
"created",
"so",
"you",
"can",
"perform",
"the",
"database",
"save",
"action",
"by",
"implementing",
"this",
"method",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/FlowActiveWindowTrait.php#L68-L74 | train |
luyadev/luya-module-admin | src/aws/FlowActiveWindowTrait.php | FlowActiveWindowTrait.flowDeleteImage | public function flowDeleteImage(Item $image)
{
Yii::$app->db->createCommand()->delete($this->getConfigValue('table'), [$this->getConfigValue('imageField') => $image->id])->execute();
} | php | public function flowDeleteImage(Item $image)
{
Yii::$app->db->createCommand()->delete($this->getConfigValue('table'), [$this->getConfigValue('imageField') => $image->id])->execute();
} | [
"public",
"function",
"flowDeleteImage",
"(",
"Item",
"$",
"image",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"getConfigValue",
"(",
"'table'",
")",
",",
"[",
"$",
"this",
... | This method will be called when the delete button will be triggered for an uploaded image. Now you should removed
the corresponding reference item in your database table. The image objec deletion will be trigger by the active window.
@param \admin\image\Item $image | [
"This",
"method",
"will",
"be",
"called",
"when",
"the",
"delete",
"button",
"will",
"be",
"triggered",
"for",
"an",
"uploaded",
"image",
".",
"Now",
"you",
"should",
"removed",
"the",
"corresponding",
"reference",
"item",
"in",
"your",
"database",
"table",
... | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/FlowActiveWindowTrait.php#L82-L85 | train |
luyadev/luya-module-admin | src/aws/ChangePasswordActiveWindow.php | ChangePasswordActiveWindow.callbackSave | public function callbackSave($newpass, $newpasswd)
{
if (!$this->model || !$this->model instanceof ChangePasswordInterface) {
throw new Exception("Unable to find related model object or the model does not implemented the \luya\admin\aws\ChangePasswordInterface.");
}
if (strlen($newpass) < $this->minCharLength) {
return $this->sendError(Module::t('aws_changeapssword_minchar', ['min' => $this->minCharLength]));
}
if ($newpass !== $newpasswd) {
return $this->sendError(Module::t('aws_changepassword_notequal'));
}
if ($this->model->changePassword($newpass)) {
return $this->sendSuccess(Module::t('aws_changepassword_succes'));
}
$error = current($this->model->getFirstErrors());
return $this->sendError($error);
} | php | public function callbackSave($newpass, $newpasswd)
{
if (!$this->model || !$this->model instanceof ChangePasswordInterface) {
throw new Exception("Unable to find related model object or the model does not implemented the \luya\admin\aws\ChangePasswordInterface.");
}
if (strlen($newpass) < $this->minCharLength) {
return $this->sendError(Module::t('aws_changeapssword_minchar', ['min' => $this->minCharLength]));
}
if ($newpass !== $newpasswd) {
return $this->sendError(Module::t('aws_changepassword_notequal'));
}
if ($this->model->changePassword($newpass)) {
return $this->sendSuccess(Module::t('aws_changepassword_succes'));
}
$error = current($this->model->getFirstErrors());
return $this->sendError($error);
} | [
"public",
"function",
"callbackSave",
"(",
"$",
"newpass",
",",
"$",
"newpasswd",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"model",
"||",
"!",
"$",
"this",
"->",
"model",
"instanceof",
"ChangePasswordInterface",
")",
"{",
"throw",
"new",
"Exception",
... | The method which is going to change the password on the current model.
The implementation of this must make sure if the $newPassword and $newPasswordRepetition are equals!
@param string $newpass The new password which must be set.
@param string $newpasswd The repeation in order to check whether does inputs are equal or not.
@return array
@throws \luya\Exception | [
"The",
"method",
"which",
"is",
"going",
"to",
"change",
"the",
"password",
"on",
"the",
"current",
"model",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/ChangePasswordActiveWindow.php#L64-L85 | train |
luyadev/luya-module-admin | src/aws/FlowActiveWindow.php | FlowActiveWindow.callbackList | public function callbackList()
{
$data = $this->model->flowListImages();
$images = [];
foreach (Yii::$app->storage->findImages(['in', 'id', $data]) as $item) {
$images[$item->id] = $item->applyFilter('small-crop')->toArray();
}
return $this->sendSuccess('list loaded', [
'images' => $images,
]);
} | php | public function callbackList()
{
$data = $this->model->flowListImages();
$images = [];
foreach (Yii::$app->storage->findImages(['in', 'id', $data]) as $item) {
$images[$item->id] = $item->applyFilter('small-crop')->toArray();
}
return $this->sendSuccess('list loaded', [
'images' => $images,
]);
} | [
"public",
"function",
"callbackList",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"model",
"->",
"flowListImages",
"(",
")",
";",
"$",
"images",
"=",
"[",
"]",
";",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"findImages",... | Returns a list of uploaded images.
@return array | [
"Returns",
"a",
"list",
"of",
"uploaded",
"images",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/FlowActiveWindow.php#L88-L100 | train |
luyadev/luya-module-admin | src/aws/FlowActiveWindow.php | FlowActiveWindow.callbackRemove | public function callbackRemove($imageId)
{
$image = Yii::$app->storage->getImage($imageId);
if ($image) {
$this->model->flowDeleteImage($image);
if (Storage::removeImage($image->id, true)) {
return $this->sendSuccess('image has been removed');
}
}
return $this->sendError('Unable to remove this image');
} | php | public function callbackRemove($imageId)
{
$image = Yii::$app->storage->getImage($imageId);
if ($image) {
$this->model->flowDeleteImage($image);
if (Storage::removeImage($image->id, true)) {
return $this->sendSuccess('image has been removed');
}
}
return $this->sendError('Unable to remove this image');
} | [
"public",
"function",
"callbackRemove",
"(",
"$",
"imageId",
")",
"{",
"$",
"image",
"=",
"Yii",
"::",
"$",
"app",
"->",
"storage",
"->",
"getImage",
"(",
"$",
"imageId",
")",
";",
"if",
"(",
"$",
"image",
")",
"{",
"$",
"this",
"->",
"model",
"->"... | Remove a given image from the collection.
@param integer $imageId
@return array | [
"Remove",
"a",
"given",
"image",
"from",
"the",
"collection",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/FlowActiveWindow.php#L108-L120 | train |
luyadev/luya-module-admin | src/aws/FlowActiveWindow.php | FlowActiveWindow.callbackUpload | public function callbackUpload()
{
$config = new Config();
$config->setTempDir($this->getTempFolder());
$file = new File($config);
$request = new Request();
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if ($file->checkChunk()) {
header("HTTP/1.1 200 Ok");
} else {
header("HTTP/1.1 204 No Content");
exit;
}
} else {
if ($file->validateChunk()) {
$file->saveChunk();
} else {
// error, invalid chunk upload request, retry
header("HTTP/1.1 400 Bad Request");
exit;
}
}
if ($file->validateFile() && $file->save($this->getUploadFolder() . '/'.$request->getFileName())) {
// File upload was completed
$file = Yii::$app->storage->addFile($this->getUploadFolder() . '/'.$request->getFileName(), $request->getFileName(), 0, true);
if ($file) {
@unlink($this->getUploadFolder() . '/'.$request->getFileName());
$image = Yii::$app->storage->addImage($file->id);
if ($image) {
$image->applyFilter('small-crop');
$this->model->flowSaveImage($image);
return 'done';
}
}
} else {
// This is not a final chunk, continue to upload
}
} | php | public function callbackUpload()
{
$config = new Config();
$config->setTempDir($this->getTempFolder());
$file = new File($config);
$request = new Request();
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if ($file->checkChunk()) {
header("HTTP/1.1 200 Ok");
} else {
header("HTTP/1.1 204 No Content");
exit;
}
} else {
if ($file->validateChunk()) {
$file->saveChunk();
} else {
// error, invalid chunk upload request, retry
header("HTTP/1.1 400 Bad Request");
exit;
}
}
if ($file->validateFile() && $file->save($this->getUploadFolder() . '/'.$request->getFileName())) {
// File upload was completed
$file = Yii::$app->storage->addFile($this->getUploadFolder() . '/'.$request->getFileName(), $request->getFileName(), 0, true);
if ($file) {
@unlink($this->getUploadFolder() . '/'.$request->getFileName());
$image = Yii::$app->storage->addImage($file->id);
if ($image) {
$image->applyFilter('small-crop');
$this->model->flowSaveImage($image);
return 'done';
}
}
} else {
// This is not a final chunk, continue to upload
}
} | [
"public",
"function",
"callbackUpload",
"(",
")",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"$",
"config",
"->",
"setTempDir",
"(",
"$",
"this",
"->",
"getTempFolder",
"(",
")",
")",
";",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"c... | Flow Uploader Upload.
@return string | [
"Flow",
"Uploader",
"Upload",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/FlowActiveWindow.php#L127-L168 | train |
luyadev/luya-module-admin | src/base/Property.php | Property.getAdminValue | public function getAdminValue()
{
if ($this->i18n) {
$this->value = I18n::decode($this->value);
} elseif ($this->autoDecodeJson && Json::isJson($this->value)) {
$this->value = Json::decode($this->value);
}
return $this->value;
} | php | public function getAdminValue()
{
if ($this->i18n) {
$this->value = I18n::decode($this->value);
} elseif ($this->autoDecodeJson && Json::isJson($this->value)) {
$this->value = Json::decode($this->value);
}
return $this->value;
} | [
"public",
"function",
"getAdminValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"i18n",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"I18n",
"::",
"decode",
"(",
"$",
"this",
"->",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"auto... | The value is passed from the administration area side to the angular view.
@return mixed | [
"The",
"value",
"is",
"passed",
"from",
"the",
"administration",
"area",
"side",
"to",
"the",
"angular",
"view",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/base/Property.php#L167-L176 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderActiveWindow.php | RenderActiveWindow.getActiveWindowObject | public function getActiveWindowObject()
{
if ($this->_activeWindowObject === null) {
$activeWindow = $this->findActiveWindow($this->activeWindowHash);
$object = Yii::createObject($activeWindow['objectConfig']);
$object->setItemId($this->itemId);
$object->setConfigHash($this->config->getHash());
$object->setActiveWindowHash($this->activeWindowHash);
Yii::$app->session->set($this->activeWindowHash, $this->itemId);
$this->_activeWindowObject = $object;
}
return $this->_activeWindowObject;
} | php | public function getActiveWindowObject()
{
if ($this->_activeWindowObject === null) {
$activeWindow = $this->findActiveWindow($this->activeWindowHash);
$object = Yii::createObject($activeWindow['objectConfig']);
$object->setItemId($this->itemId);
$object->setConfigHash($this->config->getHash());
$object->setActiveWindowHash($this->activeWindowHash);
Yii::$app->session->set($this->activeWindowHash, $this->itemId);
$this->_activeWindowObject = $object;
}
return $this->_activeWindowObject;
} | [
"public",
"function",
"getActiveWindowObject",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_activeWindowObject",
"===",
"null",
")",
"{",
"$",
"activeWindow",
"=",
"$",
"this",
"->",
"findActiveWindow",
"(",
"$",
"this",
"->",
"activeWindowHash",
")",
";",... | Get current Active Window Object.
@return \luya\admin\ngrest\base\ActiveWindowInterface | [
"Get",
"current",
"Active",
"Window",
"Object",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderActiveWindow.php#L35-L48 | train |
luyadev/luya-module-admin | src/ngrest/render/RenderActiveWindow.php | RenderActiveWindow.findActiveWindow | public function findActiveWindow($activeWindowHash)
{
$activeWindows = $this->getConfig()->getPointer('aw');
return isset($activeWindows[$activeWindowHash]) ? $activeWindows[$activeWindowHash] : false;
} | php | public function findActiveWindow($activeWindowHash)
{
$activeWindows = $this->getConfig()->getPointer('aw');
return isset($activeWindows[$activeWindowHash]) ? $activeWindows[$activeWindowHash] : false;
} | [
"public",
"function",
"findActiveWindow",
"(",
"$",
"activeWindowHash",
")",
"{",
"$",
"activeWindows",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getPointer",
"(",
"'aw'",
")",
";",
"return",
"isset",
"(",
"$",
"activeWindows",
"[",
"$",
"activ... | Find the active window in the config based on a given Hash.
@param string $activeWindowHash
@return array|boolean | [
"Find",
"the",
"active",
"window",
"in",
"the",
"config",
"based",
"on",
"a",
"given",
"Hash",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/render/RenderActiveWindow.php#L100-L105 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.injector | protected static function injector($type, $ngModel, $label, $options = [], array $mergeOptions = [])
{
// parse boolean values to integer values is it would not bind the values correctly to the angular directive.
foreach ($mergeOptions as $key => $value) {
if (!is_array($value) && is_bool($value)) {
$mergeOptions[$key] = (int) $value;
}
}
$opt = array_merge($mergeOptions, [
'model' => $ngModel,
'label' => $label,
'options' => $options,
'fieldid' => Inflector::camel2id(Inflector::camelize($ngModel.'-'.$type)),
'fieldname' => Inflector::camel2id(Inflector::camelize($ngModel)),
]);
return new AngularObject([
'type' => $type,
'options' => $opt,
]);
} | php | protected static function injector($type, $ngModel, $label, $options = [], array $mergeOptions = [])
{
// parse boolean values to integer values is it would not bind the values correctly to the angular directive.
foreach ($mergeOptions as $key => $value) {
if (!is_array($value) && is_bool($value)) {
$mergeOptions[$key] = (int) $value;
}
}
$opt = array_merge($mergeOptions, [
'model' => $ngModel,
'label' => $label,
'options' => $options,
'fieldid' => Inflector::camel2id(Inflector::camelize($ngModel.'-'.$type)),
'fieldname' => Inflector::camel2id(Inflector::camelize($ngModel)),
]);
return new AngularObject([
'type' => $type,
'options' => $opt,
]);
} | [
"protected",
"static",
"function",
"injector",
"(",
"$",
"type",
",",
"$",
"ngModel",
",",
"$",
"label",
",",
"$",
"options",
"=",
"[",
"]",
",",
"array",
"$",
"mergeOptions",
"=",
"[",
"]",
")",
"{",
"// parse boolean values to integer values is it would not ... | Internal method to use to create the angular injector helper method like in angular context of directives.js
```
"dir": "=",
"model": "=",
"options": "=",
"label": "@label",
"grid": "@grid",
"fieldid": "@fieldid",
"fieldname": "@fieldname",
"placeholder": "@placeholder",
"initvalue": "@initvalue"
```
@param string $type
@param string $ngModel
@param string $label
@param array $options The options parameter is mostly a data provider for the directive an is depending on the type.
@param array $mergeOptions Additonal attributes to be set for the tag $type.
+ fieldid:
+ fieldname:
+ placeholder:
+ initvalue:
@return AngularObject: | [
"Internal",
"method",
"to",
"use",
"to",
"create",
"the",
"angular",
"injector",
"helper",
"method",
"like",
"in",
"angular",
"context",
"of",
"directives",
".",
"js"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L50-L71 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.optionsArrayInput | public static function optionsArrayInput($data)
{
// seems to be a two way data binind, thefore direct return the string and do not transform.
if (is_scalar($data)) {
return $data;
}
$output = [];
foreach ($data as $value => $label) {
if (is_array($label)) {
if (!isset($label['label']) || !isset($label['value'])) {
throw new InvalidConfigException("The options array data for the given element must contain a label and value key.");
}
$output[] = $label;
} else {
$output[] = ['label' => $label, 'value' => $value];
}
}
return $output;
} | php | public static function optionsArrayInput($data)
{
// seems to be a two way data binind, thefore direct return the string and do not transform.
if (is_scalar($data)) {
return $data;
}
$output = [];
foreach ($data as $value => $label) {
if (is_array($label)) {
if (!isset($label['label']) || !isset($label['value'])) {
throw new InvalidConfigException("The options array data for the given element must contain a label and value key.");
}
$output[] = $label;
} else {
$output[] = ['label' => $label, 'value' => $value];
}
}
return $output;
} | [
"public",
"static",
"function",
"optionsArrayInput",
"(",
"$",
"data",
")",
"{",
"// seems to be a two way data binind, thefore direct return the string and do not transform.",
"if",
"(",
"is_scalar",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"... | Ensures the input structure for optional data for selects, radios etc.
Following options are possible:
+ An array with key => values.
+ An array with a nested array ['label' => , 'value' => ] format.
+ A string, this can be used when two way data binding should be used instead of array genertion
@param array $data|string Key value Paring or an array with label and value key.
@return array | [
"Ensures",
"the",
"input",
"structure",
"for",
"optional",
"data",
"for",
"selects",
"radios",
"etc",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L85-L107 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.directive | public static function directive($name, array $options = [])
{
return Html::tag(Inflector::camel2id($name), null, $options);
} | php | public static function directive($name, array $options = [])
{
return Html::tag(Inflector::camel2id($name), null, $options);
} | [
"public",
"static",
"function",
"directive",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"Html",
"::",
"tag",
"(",
"Inflector",
"::",
"camel2id",
"(",
"$",
"name",
")",
",",
"null",
",",
"$",
"options",
")",
"... | Create a Angular Directive tag based on the name.
```php
Angular::directive('my-input', 'name');
```
would produce the my input directive tag:
```html
<my-input ng-model="name"></my-input>
```
@param string $name The name for the generated direcitve tag which will be converted from camelcase to id notation.
@param array $options An array with optional properties for the tag creation, where key is the property name and value its content.
@return string | [
"Create",
"a",
"Angular",
"Directive",
"tag",
"based",
"on",
"the",
"name",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L126-L129 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.sortRelationArray | public static function sortRelationArray($ngModel, $label, array $sourceData, array $options = [])
{
return self::injector(TypesInterface::TYPE_SORT_RELATION_ARRAY, $ngModel, $label, ['sourceData' => $sourceData], $options);
} | php | public static function sortRelationArray($ngModel, $label, array $sourceData, array $options = [])
{
return self::injector(TypesInterface::TYPE_SORT_RELATION_ARRAY, $ngModel, $label, ['sourceData' => $sourceData], $options);
} | [
"public",
"static",
"function",
"sortRelationArray",
"(",
"$",
"ngModel",
",",
"$",
"label",
",",
"array",
"$",
"sourceData",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"injector",
"(",
"TypesInterface",
"::",
"TYPE_SORT... | Sort Relation Array.
Generates a multi selection and sortable list and returns a json array with the selected values.
@param string $ngModel The name of the ng model which should be used for data binding.
@param string $label The label to display for the form input.
@param array $sourceData
@param array $options An array with optional properties for the tag creation, where key is the property name and value its content.
@return AngularObject | [
"Sort",
"Relation",
"Array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L142-L145 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.radio | public static function radio($ngModel, $label, array $data, array $options = [])
{
return self::injector(TypesInterface::TYPE_RADIO, $ngModel, $label, self::optionsArrayInput($data), $options);
} | php | public static function radio($ngModel, $label, array $data, array $options = [])
{
return self::injector(TypesInterface::TYPE_RADIO, $ngModel, $label, self::optionsArrayInput($data), $options);
} | [
"public",
"static",
"function",
"radio",
"(",
"$",
"ngModel",
",",
"$",
"label",
",",
"array",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"injector",
"(",
"TypesInterface",
"::",
"TYPE_RADIO",
",",
"$",
... | Radio Input.
Generate a list of radios where you can select only one element.
Example:
```php
Angular::radio('exportType', 'Format', ['csv' => 'CSV', 'xlss' => 'XLSX'])
```
@param string $ngModel The name of the ng model which should be used for data binding.
@param string $label The label to display for the form input.
@param array $data An array with data where the array key is what is stored in the model e.g. `[1 => 'Mrs', 2 => 'Mr']`
@param array $options Additonal arguments to create the tag.
@return AngularObject | [
"Radio",
"Input",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L247-L250 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.asyncRequest | public static function asyncRequest($ngModel, $label, $api, $fields, array $options = [])
{
return self::injector(TYpesInterface::TYPE_ASYNC_VALUE, $ngModel, $label, [], ['api' => $api, 'fields' => $fields]);
} | php | public static function asyncRequest($ngModel, $label, $api, $fields, array $options = [])
{
return self::injector(TYpesInterface::TYPE_ASYNC_VALUE, $ngModel, $label, [], ['api' => $api, 'fields' => $fields]);
} | [
"public",
"static",
"function",
"asyncRequest",
"(",
"$",
"ngModel",
",",
"$",
"label",
",",
"$",
"api",
",",
"$",
"fields",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"injector",
"(",
"TYpesInterface",
"::",
"TYPE_A... | Generates a directive which requies a value from an api where the model is the primary key field of the api.
Angular code example
```js
zaa-async-value model="theModel" label="Hello world" api="admin/api-admin-users" fields="[foo,bar]" />
```
@param string $ngModel The name of the ng model which should be used for data binding.
@param string $label The label to display for the form input.
@param string $api The path to the api endpoint like `admin/api-admin-users`.
@param array $fields An array with all fiels which should be requested from the api
@param array $options
@since 1.2.1
@return AngularObject | [
"Generates",
"a",
"directive",
"which",
"requies",
"a",
"value",
"from",
"an",
"api",
"where",
"the",
"model",
"is",
"the",
"primary",
"key",
"field",
"of",
"the",
"api",
".",
"Angular",
"code",
"example"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L415-L418 | train |
luyadev/luya-module-admin | src/helpers/Angular.php | Angular.readonly | public static function readonly($ngModel, $label, array $options = [])
{
return self::injector(TypesInterface::TYPE_READONLY, $ngModel, $label, [], $options);
} | php | public static function readonly($ngModel, $label, array $options = [])
{
return self::injector(TypesInterface::TYPE_READONLY, $ngModel, $label, [], $options);
} | [
"public",
"static",
"function",
"readonly",
"(",
"$",
"ngModel",
",",
"$",
"label",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"self",
"::",
"injector",
"(",
"TypesInterface",
"::",
"TYPE_READONLY",
",",
"$",
"ngModel",
",",
"$",
... | Generate a read only attribute tag.
@param string $ngModel The name of the ng model which should be used for data binding.
@param string $label The label to display for the form input.
@param array $options An array with optional properties for the tag creation, where key is the property name and value its content.
@since 1.2.1
@return AngularObject | [
"Generate",
"a",
"read",
"only",
"attribute",
"tag",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/helpers/Angular.php#L429-L432 | train |
luyadev/luya-module-admin | src/commands/CrudController.php | CrudController.getDbTableShema | public function getDbTableShema()
{
if ($this->_dbTableShema === null) {
$this->_dbTableShema = Yii::$app->db->getTableSchema($this->dbTableName, true);
}
return $this->_dbTableShema;
} | php | public function getDbTableShema()
{
if ($this->_dbTableShema === null) {
$this->_dbTableShema = Yii::$app->db->getTableSchema($this->dbTableName, true);
}
return $this->_dbTableShema;
} | [
"public",
"function",
"getDbTableShema",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_dbTableShema",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_dbTableShema",
"=",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"getTableSchema",
"(",
"$",
"this",
"->"... | Get the database table schema.
@return \yii\db\TableSchema The schmema object | [
"Get",
"the",
"database",
"table",
"schema",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/CrudController.php#L148-L155 | train |
luyadev/luya-module-admin | src/commands/CrudController.php | CrudController.generateApiContent | public function generateApiContent($fileNamespace, $className, $modelClass)
{
$alias = Inflector::humanize(Inflector::camel2words($className));
return $this->view->render('@admin/commands/views/crud/create_api.php', [
'namespace' => $fileNamespace,
'className' => $className,
'modelClass' => $modelClass,
'luyaVersion' => $this->getGeneratorText('crud/create'),
'alias' => $alias,
]);
} | php | public function generateApiContent($fileNamespace, $className, $modelClass)
{
$alias = Inflector::humanize(Inflector::camel2words($className));
return $this->view->render('@admin/commands/views/crud/create_api.php', [
'namespace' => $fileNamespace,
'className' => $className,
'modelClass' => $modelClass,
'luyaVersion' => $this->getGeneratorText('crud/create'),
'alias' => $alias,
]);
} | [
"public",
"function",
"generateApiContent",
"(",
"$",
"fileNamespace",
",",
"$",
"className",
",",
"$",
"modelClass",
")",
"{",
"$",
"alias",
"=",
"Inflector",
"::",
"humanize",
"(",
"Inflector",
"::",
"camel2words",
"(",
"$",
"className",
")",
")",
";",
"... | Generate the api file content based on its view file.
@param string $fileNamespace
@param string $className
@param string $modelClass
@return string | [
"Generate",
"the",
"api",
"file",
"content",
"based",
"on",
"its",
"view",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/CrudController.php#L270-L280 | train |
luyadev/luya-module-admin | src/commands/CrudController.php | CrudController.generateModelContent | public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields)
{
$alias = Inflector::humanize(Inflector::camel2words($className));
$dbTableName = $schema->fullName;
$fields = [];
$textfields = [];
$properties = [];
$ngrestFieldConfig = [];
foreach ($schema->columns as $k => $v) {
$properties[$v->name] = $v->type;
if ($v->isPrimaryKey) {
continue;
}
$fields[] = $v->name;
if ($v->phpType == 'string') {
$textfields[] = $v->name;
}
if ($v->type == 'text') {
$ngrestFieldConfig[$v->name] = 'textarea';
}
if ($v->type == 'string') {
$ngrestFieldConfig[$v->name] = 'text';
}
if ($v->type == 'integer' || $v->type == 'bigint' || $v->type == 'smallint' || $v->type == 'tinyint') {
$ngrestFieldConfig[$v->name] = 'number';
}
if ($v->type == 'decimal' || $v->type == 'float' || $v->type == 'double') {
$ngrestFieldConfig[$v->name] = 'decimal';
}
if ($v->type == 'boolean') {
$ngrestFieldConfig[$v->name] = 'toggleStatus';
}
};
return $this->view->render('@admin/commands/views/crud/create_model.php', [
'namespace' => $fileNamepsace,
'className' => $className,
'luyaVersion' => $this->getGeneratorText('crud/create'),
'apiEndpoint' => $apiEndpoint,
'dbTableName' => $dbTableName,
'fields' => $fields,
'textFields' => $textfields,
'rules' => $this->generateRules($schema),
'labels' => $this->generateLabels($schema),
'properties' => $properties,
'ngrestFieldConfig' => $ngrestFieldConfig,
'i18nFields' => $i18nFields,
'alias' => $alias,
]);
} | php | public function generateModelContent($fileNamepsace, $className, $apiEndpoint, TableSchema $schema, $i18nFields)
{
$alias = Inflector::humanize(Inflector::camel2words($className));
$dbTableName = $schema->fullName;
$fields = [];
$textfields = [];
$properties = [];
$ngrestFieldConfig = [];
foreach ($schema->columns as $k => $v) {
$properties[$v->name] = $v->type;
if ($v->isPrimaryKey) {
continue;
}
$fields[] = $v->name;
if ($v->phpType == 'string') {
$textfields[] = $v->name;
}
if ($v->type == 'text') {
$ngrestFieldConfig[$v->name] = 'textarea';
}
if ($v->type == 'string') {
$ngrestFieldConfig[$v->name] = 'text';
}
if ($v->type == 'integer' || $v->type == 'bigint' || $v->type == 'smallint' || $v->type == 'tinyint') {
$ngrestFieldConfig[$v->name] = 'number';
}
if ($v->type == 'decimal' || $v->type == 'float' || $v->type == 'double') {
$ngrestFieldConfig[$v->name] = 'decimal';
}
if ($v->type == 'boolean') {
$ngrestFieldConfig[$v->name] = 'toggleStatus';
}
};
return $this->view->render('@admin/commands/views/crud/create_model.php', [
'namespace' => $fileNamepsace,
'className' => $className,
'luyaVersion' => $this->getGeneratorText('crud/create'),
'apiEndpoint' => $apiEndpoint,
'dbTableName' => $dbTableName,
'fields' => $fields,
'textFields' => $textfields,
'rules' => $this->generateRules($schema),
'labels' => $this->generateLabels($schema),
'properties' => $properties,
'ngrestFieldConfig' => $ngrestFieldConfig,
'i18nFields' => $i18nFields,
'alias' => $alias,
]);
} | [
"public",
"function",
"generateModelContent",
"(",
"$",
"fileNamepsace",
",",
"$",
"className",
",",
"$",
"apiEndpoint",
",",
"TableSchema",
"$",
"schema",
",",
"$",
"i18nFields",
")",
"{",
"$",
"alias",
"=",
"Inflector",
"::",
"humanize",
"(",
"Inflector",
... | Generate the model content based on its view file.
@param string $fileNamepsace
@param string $className
@param string $apiEndpoint
@param \yii\db\TableSchema $schema
@param boolean $i18nFields
@return string | [
"Generate",
"the",
"model",
"content",
"based",
"on",
"its",
"view",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/CrudController.php#L311-L363 | train |
luyadev/luya-module-admin | src/commands/CrudController.php | CrudController.generateBuildSummery | public function generateBuildSummery($apiEndpoint, $apiClassPath, $humanizeModelName, $controllerRoute)
{
return $this->view->render('@admin/commands/views/crud/build_summary.php', [
'apiEndpoint' => $apiEndpoint,
'apiClassPath' => $apiClassPath,
'humanizeModelName' => $humanizeModelName,
'controllerRoute' => $controllerRoute,
]);
} | php | public function generateBuildSummery($apiEndpoint, $apiClassPath, $humanizeModelName, $controllerRoute)
{
return $this->view->render('@admin/commands/views/crud/build_summary.php', [
'apiEndpoint' => $apiEndpoint,
'apiClassPath' => $apiClassPath,
'humanizeModelName' => $humanizeModelName,
'controllerRoute' => $controllerRoute,
]);
} | [
"public",
"function",
"generateBuildSummery",
"(",
"$",
"apiEndpoint",
",",
"$",
"apiClassPath",
",",
"$",
"humanizeModelName",
",",
"$",
"controllerRoute",
")",
"{",
"return",
"$",
"this",
"->",
"view",
"->",
"render",
"(",
"'@admin/commands/views/crud/build_summar... | Generate the block build summary based on its view file.
@param string $apiEndpoint
@param string $apiClassPath
@param string $humanizeModelName
@param string $controllerRoute
@return string | [
"Generate",
"the",
"block",
"build",
"summary",
"based",
"on",
"its",
"view",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/CrudController.php#L374-L382 | train |
luyadev/luya-module-admin | src/commands/CrudController.php | CrudController.actionModel | public function actionModel($model = null)
{
if (!$model) {
$model = $this->prompt('Namespaced path to the ngrest model (e.g. "app\models\Users"):');
}
$object = Yii::createObject(['class' => $model]);
if (!$object instanceof NgRestModelInterface) {
throw new Exception("Model must be instance of NgRestModelInterface.");
}
$reflector = new \ReflectionClass($model);
$fileName = $reflector->getFileName();
$path = dirname($fileName);
$apiEndpoint = $object->ngrestApiEndpoint();
$i18n = !empty($object->i18n);
$data = [
'path' => $path,
'fileName' => basename($fileName),
'content' => $this->generateModelContent(
$reflector->getNamespaceName(),
$reflector->getShortName(),
$apiEndpoint,
Yii::$app->db->getTableSchema($object->tableName(), true),
$i18n
),
];
$this->generateFile($data);
} | php | public function actionModel($model = null)
{
if (!$model) {
$model = $this->prompt('Namespaced path to the ngrest model (e.g. "app\models\Users"):');
}
$object = Yii::createObject(['class' => $model]);
if (!$object instanceof NgRestModelInterface) {
throw new Exception("Model must be instance of NgRestModelInterface.");
}
$reflector = new \ReflectionClass($model);
$fileName = $reflector->getFileName();
$path = dirname($fileName);
$apiEndpoint = $object->ngrestApiEndpoint();
$i18n = !empty($object->i18n);
$data = [
'path' => $path,
'fileName' => basename($fileName),
'content' => $this->generateModelContent(
$reflector->getNamespaceName(),
$reflector->getShortName(),
$apiEndpoint,
Yii::$app->db->getTableSchema($object->tableName(), true),
$i18n
),
];
$this->generateFile($data);
} | [
"public",
"function",
"actionModel",
"(",
"$",
"model",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"model",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"prompt",
"(",
"'Namespaced path to the ngrest model (e.g. \"app\\models\\Users\"):'",
")",
";",
"}",
... | Generate only the ngrest model
@param string $model Provide
@throws Exception | [
"Generate",
"only",
"the",
"ngrest",
"model"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/CrudController.php#L507-L536 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.i18nAttributeValue | public function i18nAttributeValue($attributeName)
{
$value = $this->{$attributeName};
if ($this->isI18n($attributeName) && Json::isJson($value)) {
return I18n::decodeFindActive($value);
}
return $this->{$attributeName};
} | php | public function i18nAttributeValue($attributeName)
{
$value = $this->{$attributeName};
if ($this->isI18n($attributeName) && Json::isJson($value)) {
return I18n::decodeFindActive($value);
}
return $this->{$attributeName};
} | [
"public",
"function",
"i18nAttributeValue",
"(",
"$",
"attributeName",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"{",
"$",
"attributeName",
"}",
";",
"if",
"(",
"$",
"this",
"->",
"isI18n",
"(",
"$",
"attributeName",
")",
"&&",
"Json",
"::",
"isJ... | Checks whether given attribute is in the list of i18n fields, if so
the field value will be decoded and the value for the current active
language is returned.
If the attribute is not in the list of attributes values, the value of the attribute is returned. So
its also safe to use this function when dealing with none i18n fields.
@param string $attributeName The attribute of the ActiveRecord to check and return its decoded i18n value.
@return string A json decoded value from an i18n field.
@since 2.0.0 | [
"Checks",
"whether",
"given",
"attribute",
"is",
"in",
"the",
"list",
"of",
"i18n",
"fields",
"if",
"so",
"the",
"field",
"value",
"will",
"be",
"decoded",
"and",
"the",
"value",
"for",
"the",
"current",
"active",
"language",
"is",
"returned",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L144-L152 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.i18nAttributesValue | public function i18nAttributesValue(array $attributes)
{
$values = [];
foreach ($attributes as $attribute) {
$values[$attribute] = $this->i18nAttributeValue($attribute);
}
return $values;
} | php | public function i18nAttributesValue(array $attributes)
{
$values = [];
foreach ($attributes as $attribute) {
$values[$attribute] = $this->i18nAttributeValue($attribute);
}
return $values;
} | [
"public",
"function",
"i18nAttributesValue",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"values",
"[",
"$",
"attribute",
"]",
"=",
"$",
"this",... | Returns the decoded i18n value for a set of attributes.
@param array $attributes An array with attributes to return its value
@return An array with where the key is the attribute name and value is the decoded i18n value
@see {{luya\admin\ngrest\base\NgRestModel::i18nAttributeValue()}}.
@since 2.0.0 | [
"Returns",
"the",
"decoded",
"i18n",
"value",
"for",
"a",
"set",
"of",
"attributes",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L162-L170 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.ngRestFullQuerySearch | public function ngRestFullQuerySearch($query)
{
$find = $this->ngRestFind();
$operand = [];
foreach ($this->genericSearchFields() as $column) {
$operand[] = ['like', $column, $query];
}
$find->andWhere(new OrCondition($operand));
return $find;
} | php | public function ngRestFullQuerySearch($query)
{
$find = $this->ngRestFind();
$operand = [];
foreach ($this->genericSearchFields() as $column) {
$operand[] = ['like', $column, $query];
}
$find->andWhere(new OrCondition($operand));
return $find;
} | [
"public",
"function",
"ngRestFullQuerySearch",
"(",
"$",
"query",
")",
"{",
"$",
"find",
"=",
"$",
"this",
"->",
"ngRestFind",
"(",
")",
";",
"$",
"operand",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"genericSearchFields",
"(",
")",
"as",
... | Search trough the whole table as ajax fallback when pagination is enabled.
This method is used when the angular crud view switches to a pages view and a search term is entered into
the query field. By default it will also take the fields from {{genericSearchFields()}}.
When you have relations to lookup you can extend the parent implementation, for example:
```php
public function ngRestFullQuerySearch($query)
{
return parent::ngRestFullQuerySearch($query)
->joinWith(['production'])
->orFilterWhere(['like', 'title', $query]);
}
```
@param string $query The query which will be used in order to make the like statement request.
@return \yii\db\ActiveQuery Returns an ActiveQuery instance in order to send to the ActiveDataProvider. | [
"Search",
"trough",
"the",
"whole",
"table",
"as",
"ajax",
"fallback",
"when",
"pagination",
"is",
"enabled",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L381-L393 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.getNgRestCallType | public function getNgRestCallType()
{
if ($this->_ngrestCallType === null) {
$this->_ngrestCallType = (!Yii::$app instanceof \yii\web\Application) ? false : Yii::$app->request->get('ngrestCallType', false);
}
return $this->_ngrestCallType;
} | php | public function getNgRestCallType()
{
if ($this->_ngrestCallType === null) {
$this->_ngrestCallType = (!Yii::$app instanceof \yii\web\Application) ? false : Yii::$app->request->get('ngrestCallType', false);
}
return $this->_ngrestCallType;
} | [
"public",
"function",
"getNgRestCallType",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ngrestCallType",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_ngrestCallType",
"=",
"(",
"!",
"Yii",
"::",
"$",
"app",
"instanceof",
"\\",
"yii",
"\\",
"web",
"\... | Determine the current call type based on get params as they can change the output behavior to make the ngrest crud list view.
@return boolean|string | [
"Determine",
"the",
"current",
"call",
"type",
"based",
"on",
"get",
"params",
"as",
"they",
"can",
"change",
"the",
"output",
"behavior",
"to",
"make",
"the",
"ngrest",
"crud",
"list",
"view",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L463-L470 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.getNgRestPrimaryKey | public function getNgRestPrimaryKey()
{
if ($this->_ngRestPrimaryKey === null) {
$keys = static::primaryKey();
if (!isset($keys[0])) {
throw new InvalidConfigException("The NgRestModel '".__CLASS__."' requires at least one primaryKey in order to work.");
}
return (array) $keys;
}
return $this->_ngRestPrimaryKey;
} | php | public function getNgRestPrimaryKey()
{
if ($this->_ngRestPrimaryKey === null) {
$keys = static::primaryKey();
if (!isset($keys[0])) {
throw new InvalidConfigException("The NgRestModel '".__CLASS__."' requires at least one primaryKey in order to work.");
}
return (array) $keys;
}
return $this->_ngRestPrimaryKey;
} | [
"public",
"function",
"getNgRestPrimaryKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_ngRestPrimaryKey",
"===",
"null",
")",
"{",
"$",
"keys",
"=",
"static",
"::",
"primaryKey",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"keys",
"[",
"0"... | Getter method for NgRest Primary Key.
@return string
@throws InvalidConfigException | [
"Getter",
"method",
"for",
"NgRest",
"Primary",
"Key",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L495-L507 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.getNgRestConfig | public function getNgRestConfig()
{
if ($this->_config == null) {
$config = new Config();
// Generate config builder object
$configBuilder = new ConfigBuilder(static::class);
$this->ngRestConfig($configBuilder);
$config->setConfig($configBuilder->getConfig());
foreach ($this->i18n as $fieldName) {
$config->appendFieldOption($fieldName, 'i18n', true);
}
// copy model data into config
$config->setApiEndpoint(static::ngRestApiEndpoint());
$config->setPrimaryKey($this->getNgRestPrimaryKey());
$config->setFilters($this->ngRestFilters());
$config->setDefaultOrder($this->ngRestListOrder());
$config->setAttributeGroups($this->ngRestAttributeGroups());
$config->setGroupByField($this->ngRestGroupByField());
$config->setGroupByExpanded($this->ngRestGroupByExpanded());
$config->setTableName($this->tableName());
$config->setAttributeLabels($this->attributeLabels());
$config->setActiveButtons($this->ngRestActiveButtons());
// ensure relations are made not on composite table.
if ($this->ngRestRelations() && count($this->getNgRestPrimaryKey()) > 1) {
throw new InvalidConfigException("You can not use the ngRestRelations() on composite key model.");
}
// generate relations
foreach ($this->generateNgRestRelations() as $relation) {
$config->setRelation($relation);
}
$config->onFinish();
$this->_config = $config;
}
return $this->_config;
} | php | public function getNgRestConfig()
{
if ($this->_config == null) {
$config = new Config();
// Generate config builder object
$configBuilder = new ConfigBuilder(static::class);
$this->ngRestConfig($configBuilder);
$config->setConfig($configBuilder->getConfig());
foreach ($this->i18n as $fieldName) {
$config->appendFieldOption($fieldName, 'i18n', true);
}
// copy model data into config
$config->setApiEndpoint(static::ngRestApiEndpoint());
$config->setPrimaryKey($this->getNgRestPrimaryKey());
$config->setFilters($this->ngRestFilters());
$config->setDefaultOrder($this->ngRestListOrder());
$config->setAttributeGroups($this->ngRestAttributeGroups());
$config->setGroupByField($this->ngRestGroupByField());
$config->setGroupByExpanded($this->ngRestGroupByExpanded());
$config->setTableName($this->tableName());
$config->setAttributeLabels($this->attributeLabels());
$config->setActiveButtons($this->ngRestActiveButtons());
// ensure relations are made not on composite table.
if ($this->ngRestRelations() && count($this->getNgRestPrimaryKey()) > 1) {
throw new InvalidConfigException("You can not use the ngRestRelations() on composite key model.");
}
// generate relations
foreach ($this->generateNgRestRelations() as $relation) {
$config->setRelation($relation);
}
$config->onFinish();
$this->_config = $config;
}
return $this->_config;
} | [
"public",
"function",
"getNgRestConfig",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_config",
"==",
"null",
")",
"{",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"// Generate config builder object",
"$",
"configBuilder",
"=",
"new",
"ConfigBuilder... | Build and call the full config object if not build yet for this model.
@return \luya\admin\ngrest\Config | [
"Build",
"and",
"call",
"the",
"full",
"config",
"object",
"if",
"not",
"build",
"yet",
"for",
"this",
"model",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L827-L867 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.generateNgRestRelations | protected function generateNgRestRelations()
{
$relations = [];
// generate relations
foreach ($this->ngRestRelations() as $key => $item) {
/** @var $item \luya\admin\ngrest\base\NgRestRelationInterface */
if (!$item instanceof NgRestRelation) {
if (!isset($item['class'])) {
$item['class'] = 'luya\admin\ngrest\base\NgRestRelation';
}
$item = Yii::createObject($item);
}
$item->setModelClass($this->className());
$item->setArrayIndex($key);
$relations[$key] = $item;
}
return $relations;
} | php | protected function generateNgRestRelations()
{
$relations = [];
// generate relations
foreach ($this->ngRestRelations() as $key => $item) {
/** @var $item \luya\admin\ngrest\base\NgRestRelationInterface */
if (!$item instanceof NgRestRelation) {
if (!isset($item['class'])) {
$item['class'] = 'luya\admin\ngrest\base\NgRestRelation';
}
$item = Yii::createObject($item);
}
$item->setModelClass($this->className());
$item->setArrayIndex($key);
$relations[$key] = $item;
}
return $relations;
} | [
"protected",
"function",
"generateNgRestRelations",
"(",
")",
"{",
"$",
"relations",
"=",
"[",
"]",
";",
"// generate relations",
"foreach",
"(",
"$",
"this",
"->",
"ngRestRelations",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"/** @var $item \... | Generate an array with NgRestRelation objects
@return array
@since 2.0.0 | [
"Generate",
"an",
"array",
"with",
"NgRestRelation",
"objects"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L875-L894 | train |
luyadev/luya-module-admin | src/ngrest/base/NgRestModel.php | NgRestModel.getNgRestRelationByIndex | public function getNgRestRelationByIndex($index)
{
$relations = $this->generateNgRestRelations();
return isset($relations[$index]) ? $relations[$index] : false;
} | php | public function getNgRestRelationByIndex($index)
{
$relations = $this->generateNgRestRelations();
return isset($relations[$index]) ? $relations[$index] : false;
} | [
"public",
"function",
"getNgRestRelationByIndex",
"(",
"$",
"index",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"generateNgRestRelations",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"relations",
"[",
"$",
"index",
"]",
")",
"?",
"$",
"relations",... | Get the NgRest Relation defintion object.
@param integer $index
@return NgRestRelationInterface
@since 2.0.0 | [
"Get",
"the",
"NgRest",
"Relation",
"defintion",
"object",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/base/NgRestModel.php#L903-L908 | train |
luyadev/luya-module-admin | src/models/LoginForm.php | LoginForm.validatePassword | public function validatePassword($attribute)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if ($user && $this->userAttemptBruteForceLock($user)) {
return $this->addError($attribute, Module::t('model_loginform_max_user_attempts', ['time' => Yii::$app->formatter->asRelativeTime($user->login_attempt_lock_expiration)]));
}
if (!$user || !$user->validatePassword($this->password)) {
if ($this->attempts) {
// use `model_loginform_wrong_user_or_password` instead of `model_loginform_wrong_user_or_password_attempts` due to informations about correct email input.
$this->addError($attribute, Module::t('model_loginform_wrong_user_or_password', ['attempt' => $this->attempts, 'allowedAttempts' => $this->allowedAttempts]));
} else {
$this->addError($attribute, Module::t('model_loginform_wrong_user_or_password'));
}
}
}
} | php | public function validatePassword($attribute)
{
if (!$this->hasErrors()) {
$user = $this->getUser();
if ($user && $this->userAttemptBruteForceLock($user)) {
return $this->addError($attribute, Module::t('model_loginform_max_user_attempts', ['time' => Yii::$app->formatter->asRelativeTime($user->login_attempt_lock_expiration)]));
}
if (!$user || !$user->validatePassword($this->password)) {
if ($this->attempts) {
// use `model_loginform_wrong_user_or_password` instead of `model_loginform_wrong_user_or_password_attempts` due to informations about correct email input.
$this->addError($attribute, Module::t('model_loginform_wrong_user_or_password', ['attempt' => $this->attempts, 'allowedAttempts' => $this->allowedAttempts]));
} else {
$this->addError($attribute, Module::t('model_loginform_wrong_user_or_password'));
}
}
}
} | [
"public",
"function",
"validatePassword",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasErrors",
"(",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"$",
"user",
"&&",
"$",
"this... | Inline validator.
@param string $attribute Attribute value | [
"Inline",
"validator",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/LoginForm.php#L62-L80 | train |
luyadev/luya-module-admin | src/models/LoginForm.php | LoginForm.userAttemptBruteForceLock | private function userAttemptBruteForceLock(User $user)
{
if ($this->userAttemptBruteForceLockHasExceeded($user)) {
return true;
}
$this->attempts = $user->login_attempt + 1;
if ($this->attempts >= $this->allowedAttempts) {
$user->updateAttributes(['login_attempt_lock_expiration' => time() + $this->lockoutTime]);
}
$user->updateAttributes(['login_attempt' => $this->attempts]);
} | php | private function userAttemptBruteForceLock(User $user)
{
if ($this->userAttemptBruteForceLockHasExceeded($user)) {
return true;
}
$this->attempts = $user->login_attempt + 1;
if ($this->attempts >= $this->allowedAttempts) {
$user->updateAttributes(['login_attempt_lock_expiration' => time() + $this->lockoutTime]);
}
$user->updateAttributes(['login_attempt' => $this->attempts]);
} | [
"private",
"function",
"userAttemptBruteForceLock",
"(",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"userAttemptBruteForceLockHasExceeded",
"(",
"$",
"user",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"attempts",
"=",
"... | Check if the given user has a lockout, otherwise upcount the attempts.
@param User $user
@return boolean
@since 1.2.0 | [
"Check",
"if",
"the",
"given",
"user",
"has",
"a",
"lockout",
"otherwise",
"upcount",
"the",
"attempts",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/LoginForm.php#L89-L102 | train |
luyadev/luya-module-admin | src/models/LoginForm.php | LoginForm.userAttemptBruteForceLockHasExceeded | private function userAttemptBruteForceLockHasExceeded(User $user)
{
if ($user->login_attempt_lock_expiration > time()) {
$user->updateAttributes(['login_attempt' => 0]);
return true;
}
return false;
} | php | private function userAttemptBruteForceLockHasExceeded(User $user)
{
if ($user->login_attempt_lock_expiration > time()) {
$user->updateAttributes(['login_attempt' => 0]);
return true;
}
return false;
} | [
"private",
"function",
"userAttemptBruteForceLockHasExceeded",
"(",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"login_attempt_lock_expiration",
">",
"time",
"(",
")",
")",
"{",
"$",
"user",
"->",
"updateAttributes",
"(",
"[",
"'login_attempt'",... | Check if lockout has expired or not.
@param User $user
@return boolean
@since 1.2.0 | [
"Check",
"if",
"lockout",
"has",
"expired",
"or",
"not",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/LoginForm.php#L111-L120 | train |
luyadev/luya-module-admin | src/models/LoginForm.php | LoginForm.sendSecureLogin | public function sendSecureLogin()
{
$token = $this->getUser()->getAndStoreToken();
return Yii::$app->mail
->compose(Module::t('login_securetoken_mail_subject'), Module::t('login_securetoken_mail', [
'url' => Url::base(true),
'token' => $token,
]))
->address($this->user->email)
->send();
} | php | public function sendSecureLogin()
{
$token = $this->getUser()->getAndStoreToken();
return Yii::$app->mail
->compose(Module::t('login_securetoken_mail_subject'), Module::t('login_securetoken_mail', [
'url' => Url::base(true),
'token' => $token,
]))
->address($this->user->email)
->send();
} | [
"public",
"function",
"sendSecureLogin",
"(",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getAndStoreToken",
"(",
")",
";",
"return",
"Yii",
"::",
"$",
"app",
"->",
"mail",
"->",
"compose",
"(",
"Module",
"::",
"t",
"(... | Send the secure token by mail.
@return boolean | [
"Send",
"the",
"secure",
"token",
"by",
"mail",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/LoginForm.php#L127-L138 | train |
luyadev/luya-module-admin | src/models/LoginForm.php | LoginForm.validateSecureToken | public function validateSecureToken($token, $userId)
{
$user = User::findOne($userId);
if (!$user) {
return false;
}
if ($this->userAttemptBruteForceLockHasExceeded($user)) {
return false;
}
if ($user->secure_token == sha1($token) && $user->secure_token_timestamp >= (time() - $this->secureTokenExpirationTime)) {
return $user;
}
return false;
} | php | public function validateSecureToken($token, $userId)
{
$user = User::findOne($userId);
if (!$user) {
return false;
}
if ($this->userAttemptBruteForceLockHasExceeded($user)) {
return false;
}
if ($user->secure_token == sha1($token) && $user->secure_token_timestamp >= (time() - $this->secureTokenExpirationTime)) {
return $user;
}
return false;
} | [
"public",
"function",
"validateSecureToken",
"(",
"$",
"token",
",",
"$",
"userId",
")",
"{",
"$",
"user",
"=",
"User",
"::",
"findOne",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
... | Validate the secure token.
@param string $token
@param integer $userId
@return boolean|\luya\admin\models\User | [
"Validate",
"the",
"secure",
"token",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/LoginForm.php#L147-L164 | train |
luyadev/luya-module-admin | src/models/LoginForm.php | LoginForm.login | public function login()
{
if ($this->validate()) {
$user = $this->getUser();
$user->detachBehavior('LogBehavior');
// update user model
$user->updateAttributes([
'force_reload' => false,
'login_attempt' => 0,
'login_attempt_lock_expiration' => null,
'auth_token' => Yii::$app->security->hashData(Yii::$app->security->generateRandomString(), $user->password_salt),
]);
// kill prev user logins
UserLogin::updateAll(['is_destroyed' => true], ['user_id' => $user->id]);
// create new user login
$login = new UserLogin([
'auth_token' => $user->auth_token,
'user_id' => $user->id,
'is_destroyed' => false,
]);
$login->save();
// refresh user online list
UserOnline::refreshUser($user, 'login');
return $user;
}
return false;
} | php | public function login()
{
if ($this->validate()) {
$user = $this->getUser();
$user->detachBehavior('LogBehavior');
// update user model
$user->updateAttributes([
'force_reload' => false,
'login_attempt' => 0,
'login_attempt_lock_expiration' => null,
'auth_token' => Yii::$app->security->hashData(Yii::$app->security->generateRandomString(), $user->password_salt),
]);
// kill prev user logins
UserLogin::updateAll(['is_destroyed' => true], ['user_id' => $user->id]);
// create new user login
$login = new UserLogin([
'auth_token' => $user->auth_token,
'user_id' => $user->id,
'is_destroyed' => false,
]);
$login->save();
// refresh user online list
UserOnline::refreshUser($user, 'login');
return $user;
}
return false;
} | [
"public",
"function",
"login",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
";",
"$",
"user",
"->",
"detachBehavior",
"(",
"'LogBehavior'",
")",
";",
"// upda... | Login the current user if valid.
@return boolean|\luya\admin\models\User|boolean | [
"Login",
"the",
"current",
"user",
"if",
"valid",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/LoginForm.php#L171-L202 | train |
luyadev/luya-module-admin | src/storage/QueryTrait.php | QueryTrait.arrayFilter | private function arrayFilter($value, $field)
{
foreach ($this->_where as $expression) {
if ($expression['field'] == $field) {
switch ($expression['op']) {
case '=':
return ($value == $expression['value']);
case '==':
return ($value === $expression['value']);
case '>':
return ($value > $expression['value']);
case '>=':
return ($value >= $expression['value']);
case '<':
return ($value < $expression['value']);
case '<=':
return ($value <= $expression['value']);
case 'in':
return in_array($value, $expression['value']);
}
}
}
return true;
} | php | private function arrayFilter($value, $field)
{
foreach ($this->_where as $expression) {
if ($expression['field'] == $field) {
switch ($expression['op']) {
case '=':
return ($value == $expression['value']);
case '==':
return ($value === $expression['value']);
case '>':
return ($value > $expression['value']);
case '>=':
return ($value >= $expression['value']);
case '<':
return ($value < $expression['value']);
case '<=':
return ($value <= $expression['value']);
case 'in':
return in_array($value, $expression['value']);
}
}
}
return true;
} | [
"private",
"function",
"arrayFilter",
"(",
"$",
"value",
",",
"$",
"field",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_where",
"as",
"$",
"expression",
")",
"{",
"if",
"(",
"$",
"expression",
"[",
"'field'",
"]",
"==",
"$",
"field",
")",
"{",
"... | Process items against where filters
@param string $value
@param string $field
@return boolean | [
"Process",
"items",
"against",
"where",
"filters"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/storage/QueryTrait.php#L104-L128 | train |
luyadev/luya-module-admin | src/storage/QueryTrait.php | QueryTrait.filter | private function filter()
{
$containerData = $this->getDataProvider();
$whereExpression = $this->_where;
if (empty($whereExpression)) {
$data = $containerData;
} else {
$data = array_filter($containerData, function ($item) {
foreach ($item as $field => $value) {
if (!$this->arrayFilter($value, $field)) {
return false;
}
}
return true;
});
}
if ($this->_offset !== null) {
$data = array_slice($data, $this->_offset, null, true);
}
if ($this->_limit !== null) {
$data = array_slice($data, 0, $this->_limit, true);
}
if ($this->_binds) {
foreach ($this->_binds as $id => $values) {
if (isset($data[$id])) {
$data[$id] = array_merge($data[$id], $values);
}
}
}
return $data;
} | php | private function filter()
{
$containerData = $this->getDataProvider();
$whereExpression = $this->_where;
if (empty($whereExpression)) {
$data = $containerData;
} else {
$data = array_filter($containerData, function ($item) {
foreach ($item as $field => $value) {
if (!$this->arrayFilter($value, $field)) {
return false;
}
}
return true;
});
}
if ($this->_offset !== null) {
$data = array_slice($data, $this->_offset, null, true);
}
if ($this->_limit !== null) {
$data = array_slice($data, 0, $this->_limit, true);
}
if ($this->_binds) {
foreach ($this->_binds as $id => $values) {
if (isset($data[$id])) {
$data[$id] = array_merge($data[$id], $values);
}
}
}
return $data;
} | [
"private",
"function",
"filter",
"(",
")",
"{",
"$",
"containerData",
"=",
"$",
"this",
"->",
"getDataProvider",
"(",
")",
";",
"$",
"whereExpression",
"=",
"$",
"this",
"->",
"_where",
";",
"if",
"(",
"empty",
"(",
"$",
"whereExpression",
")",
")",
"{... | Filter container data provider against where conditions
@return array | [
"Filter",
"container",
"data",
"provider",
"against",
"where",
"conditions"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/storage/QueryTrait.php#L135-L171 | train |
luyadev/luya-module-admin | src/storage/QueryTrait.php | QueryTrait.one | public function one()
{
$data = $this->filter();
return (count($data) !== 0) ? $this->createItem(array_values($data)[0]): false;
} | php | public function one()
{
$data = $this->filter();
return (count($data) !== 0) ? $this->createItem(array_values($data)[0]): false;
} | [
"public",
"function",
"one",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"filter",
"(",
")",
";",
"return",
"(",
"count",
"(",
"$",
"data",
")",
"!==",
"0",
")",
"?",
"$",
"this",
"->",
"createItem",
"(",
"array_values",
"(",
"$",
"data",... | Find One based on the where condition.
If there are several items, it just takes the first one and does not throw an exception.
@return \luya\admin\image\Item|\luya\admin\file\Item|\luya\admin\folder\Item | [
"Find",
"One",
"based",
"on",
"the",
"where",
"condition",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/storage/QueryTrait.php#L341-L346 | train |
luyadev/luya-module-admin | src/storage/QueryTrait.php | QueryTrait.findOne | public function findOne($id)
{
return ($itemArray = $this->getItemDataProvider($id)) ? $this->createItem($itemArray) : false;
} | php | public function findOne($id)
{
return ($itemArray = $this->getItemDataProvider($id)) ? $this->createItem($itemArray) : false;
} | [
"public",
"function",
"findOne",
"(",
"$",
"id",
")",
"{",
"return",
"(",
"$",
"itemArray",
"=",
"$",
"this",
"->",
"getItemDataProvider",
"(",
"$",
"id",
")",
")",
"?",
"$",
"this",
"->",
"createItem",
"(",
"$",
"itemArray",
")",
":",
"false",
";",
... | FindOne with the specific ID.
@param integer $id The specific item id
@return \luya\admin\image\Item|\luya\admin\file\Item|\luya\admin\folder\Item | [
"FindOne",
"with",
"the",
"specific",
"ID",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/storage/QueryTrait.php#L354-L357 | train |
luyadev/luya-module-admin | src/models/StorageFilterChain.php | StorageFilterChain.eventBeforeValidate | public function eventBeforeValidate()
{
if (is_array($this->effect_json_values)) {
$this->effect_json_values = Json::encode($this->effect_json_values);
}
} | php | public function eventBeforeValidate()
{
if (is_array($this->effect_json_values)) {
$this->effect_json_values = Json::encode($this->effect_json_values);
}
} | [
"public",
"function",
"eventBeforeValidate",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"effect_json_values",
")",
")",
"{",
"$",
"this",
"->",
"effect_json_values",
"=",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"effect_json_values"... | Encode the the effect_json_values array to a json structure. | [
"Encode",
"the",
"the",
"effect_json_values",
"array",
"to",
"a",
"json",
"structure",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFilterChain.php#L77-L82 | train |
luyadev/luya-module-admin | src/models/StorageFilterChain.php | StorageFilterChain.effectDefinition | public function effectDefinition($effect, $key = null)
{
$definition = isset($this->effectDefinitions[$effect]) ? $this->effectDefinitions[$effect] : false;
if (!$definition) {
return false;
}
if ($key) {
return $definition[$key];
}
return $definition;
} | php | public function effectDefinition($effect, $key = null)
{
$definition = isset($this->effectDefinitions[$effect]) ? $this->effectDefinitions[$effect] : false;
if (!$definition) {
return false;
}
if ($key) {
return $definition[$key];
}
return $definition;
} | [
"public",
"function",
"effectDefinition",
"(",
"$",
"effect",
",",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"definition",
"=",
"isset",
"(",
"$",
"this",
"->",
"effectDefinitions",
"[",
"$",
"effect",
"]",
")",
"?",
"$",
"this",
"->",
"effectDefinitions",... | Get the definition for a given effect name.
@param string $effect
@param string $key
@return mixed
@since 1.2.0 | [
"Get",
"the",
"definition",
"for",
"a",
"given",
"effect",
"name",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFilterChain.php#L149-L162 | train |
luyadev/luya-module-admin | src/models/StorageFilterChain.php | StorageFilterChain.hasMissingRequiredEffectDefinition | public function hasMissingRequiredEffectDefinition($effect)
{
foreach ($this->effectDefinition($effect, 'required') as $param) {
if ($this->getJsonValue($param) === false) {
return true;
}
}
return false;
} | php | public function hasMissingRequiredEffectDefinition($effect)
{
foreach ($this->effectDefinition($effect, 'required') as $param) {
if ($this->getJsonValue($param) === false) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasMissingRequiredEffectDefinition",
"(",
"$",
"effect",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"effectDefinition",
"(",
"$",
"effect",
",",
"'required'",
")",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getJso... | Check if a missing required param is not provided in the chain.
@param string $effect
@return boolean
@since 1.2.0 | [
"Check",
"if",
"a",
"missing",
"required",
"param",
"is",
"not",
"provided",
"in",
"the",
"chain",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFilterChain.php#L171-L180 | train |
luyadev/luya-module-admin | src/models/StorageFilterChain.php | StorageFilterChain.getJsonValue | protected function getJsonValue($key)
{
return array_key_exists($key, $this->effect_json_values) ? $this->effect_json_values[$key] : false;
} | php | protected function getJsonValue($key)
{
return array_key_exists($key, $this->effect_json_values) ? $this->effect_json_values[$key] : false;
} | [
"protected",
"function",
"getJsonValue",
"(",
"$",
"key",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"effect_json_values",
")",
"?",
"$",
"this",
"->",
"effect_json_values",
"[",
"$",
"key",
"]",
":",
"false",
";",
"... | Get the value for a effect json key.
@param string $key
@return boolean | [
"Get",
"the",
"value",
"for",
"a",
"effect",
"json",
"key",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFilterChain.php#L209-L212 | train |
luyadev/luya-module-admin | src/models/UserOnline.php | UserOnline.lock | public static function lock($userId, $table, $pk, $translation, array $translationArgs = [])
{
$model = self::findOne(['user_id' => $userId]);
if ($model) {
$model->updateAttributes([
'last_timestamp' => time(),
'lock_table' => $table,
'lock_pk' => $pk,
'lock_translation' => $translation,
'lock_translation_args' => Json::encode($translationArgs),
]);
}
} | php | public static function lock($userId, $table, $pk, $translation, array $translationArgs = [])
{
$model = self::findOne(['user_id' => $userId]);
if ($model) {
$model->updateAttributes([
'last_timestamp' => time(),
'lock_table' => $table,
'lock_pk' => $pk,
'lock_translation' => $translation,
'lock_translation_args' => Json::encode($translationArgs),
]);
}
} | [
"public",
"static",
"function",
"lock",
"(",
"$",
"userId",
",",
"$",
"table",
",",
"$",
"pk",
",",
"$",
"translation",
",",
"array",
"$",
"translationArgs",
"=",
"[",
"]",
")",
"{",
"$",
"model",
"=",
"self",
"::",
"findOne",
"(",
"[",
"'user_id'",
... | Lock the user for an action.
@param integer $userId
@param string $table
@param string $pk
@param string $translation
@param array $translationArgs | [
"Lock",
"the",
"user",
"for",
"an",
"action",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserOnline.php#L84-L97 | train |
luyadev/luya-module-admin | src/models/UserOnline.php | UserOnline.unlock | public static function unlock($userId)
{
$model = self::findOne(['user_id' => $userId]);
if ($model) {
$model->updateAttributes([
'last_timestamp' => time(),
'lock_table' => '',
'lock_pk' => '',
'lock_translation' => '',
'lock_translation_args' => '',
]);
}
} | php | public static function unlock($userId)
{
$model = self::findOne(['user_id' => $userId]);
if ($model) {
$model->updateAttributes([
'last_timestamp' => time(),
'lock_table' => '',
'lock_pk' => '',
'lock_translation' => '',
'lock_translation_args' => '',
]);
}
} | [
"public",
"static",
"function",
"unlock",
"(",
"$",
"userId",
")",
"{",
"$",
"model",
"=",
"self",
"::",
"findOne",
"(",
"[",
"'user_id'",
"=>",
"$",
"userId",
"]",
")",
";",
"if",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"updateAttributes",
... | Unlock the user from an action.
@param integer $userId | [
"Unlock",
"the",
"user",
"from",
"an",
"action",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserOnline.php#L104-L117 | train |
luyadev/luya-module-admin | src/models/UserOnline.php | UserOnline.refreshUser | public static function refreshUser(User $user, $route)
{
// skip the process if an api user is try to refresh.
if ($user->is_api_user) {
return;
}
$model = self::findOne(['user_id' => $user->id]);
if ($model) {
return (bool) $model->updateAttributes(['last_timestamp' => time(), 'invoken_route' => $route]);
}
$model = new self(['last_timestamp' => time(), 'user_id' => $user->id, 'invoken_route' => $route]);
return $model->save();
} | php | public static function refreshUser(User $user, $route)
{
// skip the process if an api user is try to refresh.
if ($user->is_api_user) {
return;
}
$model = self::findOne(['user_id' => $user->id]);
if ($model) {
return (bool) $model->updateAttributes(['last_timestamp' => time(), 'invoken_route' => $route]);
}
$model = new self(['last_timestamp' => time(), 'user_id' => $user->id, 'invoken_route' => $route]);
return $model->save();
} | [
"public",
"static",
"function",
"refreshUser",
"(",
"User",
"$",
"user",
",",
"$",
"route",
")",
"{",
"// skip the process if an api user is try to refresh.",
"if",
"(",
"$",
"user",
"->",
"is_api_user",
")",
"{",
"return",
";",
"}",
"$",
"model",
"=",
"self",... | Refresh the state of the current user, or add if not exists.
@param User $user
@param string $route
@return bool | [
"Refresh",
"the",
"state",
"of",
"the",
"current",
"user",
"or",
"add",
"if",
"not",
"exists",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserOnline.php#L126-L141 | train |
luyadev/luya-module-admin | src/models/UserOnline.php | UserOnline.getList | public static function getList()
{
$time = time();
$return = [];
foreach (self::find()->with('user')->all() as $item) {
/* @var $item \luya\admin\models\UserOnline */
$inactiveSince = ($time - $item->last_timestamp);
$return[] = [
'firstname' => $item->user->firstname,
'lastname' => $item->user->lastname,
'email' => $item->user->email,
'last_timestamp' => $item->last_timestamp,
'is_active' => ($inactiveSince >= (3*60)) ? false : true,
'inactive_since' => round(($inactiveSince / 60)).' min',
'lock_description' => Module::t($item->lock_translation, empty($item->lock_translation_args) ? [] : Json::decode($item->lock_translation_args)),
];
}
return $return;
} | php | public static function getList()
{
$time = time();
$return = [];
foreach (self::find()->with('user')->all() as $item) {
/* @var $item \luya\admin\models\UserOnline */
$inactiveSince = ($time - $item->last_timestamp);
$return[] = [
'firstname' => $item->user->firstname,
'lastname' => $item->user->lastname,
'email' => $item->user->email,
'last_timestamp' => $item->last_timestamp,
'is_active' => ($inactiveSince >= (3*60)) ? false : true,
'inactive_since' => round(($inactiveSince / 60)).' min',
'lock_description' => Module::t($item->lock_translation, empty($item->lock_translation_args) ? [] : Json::decode($item->lock_translation_args)),
];
}
return $return;
} | [
"public",
"static",
"function",
"getList",
"(",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"find",
"(",
")",
"->",
"with",
"(",
"'user'",
")",
"->",
"all",
"(",
")",
"as",... | Get the user online list.
@return array | [
"Get",
"the",
"user",
"online",
"list",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserOnline.php#L168-L188 | train |
luyadev/luya-module-admin | src/models/Scheduler.php | Scheduler.triggerJob | public function triggerJob()
{
try {
$class = $this->model_class;
$model = $class::findOne($this->primary_key);
if ($model) {
$oldValue = $model->{$this->target_attribute_name};
$model->{$this->target_attribute_name} = StringHelper::typeCast($this->new_attribute_value);
$model->save(true, [$this->target_attribute_name]);
return $this->updateAttributes(['old_attribute_value' => $oldValue, 'is_done' => true]);
}
} catch (\Exception $err) {
$this->delete();
}
} | php | public function triggerJob()
{
try {
$class = $this->model_class;
$model = $class::findOne($this->primary_key);
if ($model) {
$oldValue = $model->{$this->target_attribute_name};
$model->{$this->target_attribute_name} = StringHelper::typeCast($this->new_attribute_value);
$model->save(true, [$this->target_attribute_name]);
return $this->updateAttributes(['old_attribute_value' => $oldValue, 'is_done' => true]);
}
} catch (\Exception $err) {
$this->delete();
}
} | [
"public",
"function",
"triggerJob",
"(",
")",
"{",
"try",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"model_class",
";",
"$",
"model",
"=",
"$",
"class",
"::",
"findOne",
"(",
"$",
"this",
"->",
"primary_key",
")",
";",
"if",
"(",
"$",
"model",
")"... | Job Trigger.
This method is execute by the queue job.
@return void | [
"Job",
"Trigger",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Scheduler.php#L69-L85 | train |
luyadev/luya-module-admin | src/models/Scheduler.php | Scheduler.hasTriggerPermission | public function hasTriggerPermission($class)
{
$model = new $class();
if (!$model instanceof NgRestModel) {
return false;
}
return Yii::$app->adminmenu->getApiDetail($class::ngRestApiEndpoint());
} | php | public function hasTriggerPermission($class)
{
$model = new $class();
if (!$model instanceof NgRestModel) {
return false;
}
return Yii::$app->adminmenu->getApiDetail($class::ngRestApiEndpoint());
} | [
"public",
"function",
"hasTriggerPermission",
"(",
"$",
"class",
")",
"{",
"$",
"model",
"=",
"new",
"$",
"class",
"(",
")",
";",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"NgRestModel",
")",
"{",
"return",
"false",
";",
"}",
"return",
"Yii",
"::",
... | Ensure if the given class is an ngrest model and permission exists.
@param string $class
@return boolean | [
"Ensure",
"if",
"the",
"given",
"class",
"is",
"an",
"ngrest",
"model",
"and",
"permission",
"exists",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Scheduler.php#L93-L102 | train |
luyadev/luya-module-admin | src/models/Scheduler.php | Scheduler.pushQueue | public function pushQueue()
{
$delay = $this->schedule_timestamp - time();
if ($delay < 1) {
$delay = 0;
}
Yii::$app->adminqueue->delay($delay)->push(new ScheduleJob(['schedulerId' => $this->id]));
} | php | public function pushQueue()
{
$delay = $this->schedule_timestamp - time();
if ($delay < 1) {
$delay = 0;
}
Yii::$app->adminqueue->delay($delay)->push(new ScheduleJob(['schedulerId' => $this->id]));
} | [
"public",
"function",
"pushQueue",
"(",
")",
"{",
"$",
"delay",
"=",
"$",
"this",
"->",
"schedule_timestamp",
"-",
"time",
"(",
")",
";",
"if",
"(",
"$",
"delay",
"<",
"1",
")",
"{",
"$",
"delay",
"=",
"0",
";",
"}",
"Yii",
"::",
"$",
"app",
"-... | Push the given scheduler model into the queue.
@return void | [
"Push",
"the",
"given",
"scheduler",
"model",
"into",
"the",
"queue",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Scheduler.php#L109-L118 | train |
luyadev/luya-module-admin | src/apis/RemoteController.php | RemoteController.actionIndex | public function actionIndex($token)
{
if (empty(Yii::$app->remoteToken) || sha1(Yii::$app->remoteToken) !== $token) {
throw new Exception('The provided remote token is wrong.');
}
UserOnline::clearList($this->module->userIdleTimeout);
return [
'yii_version' => Yii::getVersion(),
'luya_version' => Boot::VERSION,
'app_title' => Yii::$app->siteTitle,
'app_debug' => (int) YII_DEBUG,
'app_env' => YII_ENV,
'app_transfer_exceptions' => (int) Yii::$app->errorHandler->transferException,
'admin_online_count' => UserOnline::find()->count(),
'app_elapsed_time' => Yii::getLogger()->getElapsedTime(),
'packages' => Yii::$app->getPackageInstaller()->getConfigs(),
'packages_update_timestamp' => Yii::$app->getPackageInstaller()->getTimestamp(),
];
} | php | public function actionIndex($token)
{
if (empty(Yii::$app->remoteToken) || sha1(Yii::$app->remoteToken) !== $token) {
throw new Exception('The provided remote token is wrong.');
}
UserOnline::clearList($this->module->userIdleTimeout);
return [
'yii_version' => Yii::getVersion(),
'luya_version' => Boot::VERSION,
'app_title' => Yii::$app->siteTitle,
'app_debug' => (int) YII_DEBUG,
'app_env' => YII_ENV,
'app_transfer_exceptions' => (int) Yii::$app->errorHandler->transferException,
'admin_online_count' => UserOnline::find()->count(),
'app_elapsed_time' => Yii::getLogger()->getElapsedTime(),
'packages' => Yii::$app->getPackageInstaller()->getConfigs(),
'packages_update_timestamp' => Yii::$app->getPackageInstaller()->getTimestamp(),
];
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"token",
")",
"{",
"if",
"(",
"empty",
"(",
"Yii",
"::",
"$",
"app",
"->",
"remoteToken",
")",
"||",
"sha1",
"(",
"Yii",
"::",
"$",
"app",
"->",
"remoteToken",
")",
"!==",
"$",
"token",
")",
"{",
"thro... | Retrieve administration informations if the token is valid.
@param string $token The sha1 encrypted access token.
@return array If invalid token.
@throws Exception | [
"Retrieve",
"administration",
"informations",
"if",
"the",
"token",
"is",
"valid",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/RemoteController.php#L38-L58 | train |
luyadev/luya-module-admin | src/aws/TaggableActiveWindow.php | TaggableActiveWindow.getTableName | public function getTableName()
{
if ($this->_tableName === null) {
$this->_tableName = $this->model->tableName();
}
return $this->_tableName;
} | php | public function getTableName()
{
if ($this->_tableName === null) {
$this->_tableName = $this->model->tableName();
}
return $this->_tableName;
} | [
"public",
"function",
"getTableName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_tableName",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_tableName",
"=",
"$",
"this",
"->",
"model",
"->",
"tableName",
"(",
")",
";",
"}",
"return",
"$",
"this",
... | Getter tableName.
@return string | [
"Getter",
"tableName",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/TaggableActiveWindow.php#L69-L76 | train |
luyadev/luya-module-admin | src/aws/TaggableActiveWindow.php | TaggableActiveWindow.callbackLoadRelations | public function callbackLoadRelations()
{
return TagRelation::find()->where(['table_name' => TaggableTrait::cleanBaseTableName($this->tableName), 'pk_id' => $this->getItemId()])->asArray()->all();
} | php | public function callbackLoadRelations()
{
return TagRelation::find()->where(['table_name' => TaggableTrait::cleanBaseTableName($this->tableName), 'pk_id' => $this->getItemId()])->asArray()->all();
} | [
"public",
"function",
"callbackLoadRelations",
"(",
")",
"{",
"return",
"TagRelation",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'table_name'",
"=>",
"TaggableTrait",
"::",
"cleanBaseTableName",
"(",
"$",
"this",
"->",
"tableName",
")",
",",
"'pk_id'",... | Get only tags for the current record.
@return array|\yii\db\ActiveRecord[] | [
"Get",
"only",
"tags",
"for",
"the",
"current",
"record",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/TaggableActiveWindow.php#L129-L132 | train |
luyadev/luya-module-admin | src/aws/TaggableActiveWindow.php | TaggableActiveWindow.callbackSaveRelation | public function callbackSaveRelation($tagId)
{
$find = TagRelation::find()->where(['tag_id' => $tagId, 'table_name' => TaggableTrait::cleanBaseTableName($this->tableName), 'pk_id' => $this->getItemId()])->one();
if ($find) {
TagRelation::deleteAll(['tag_id' => $tagId, 'table_name' => TaggableTrait::cleanBaseTableName($this->tableName), 'pk_id' => $this->getItemId()]);
return 0;
} else {
$model = new TagRelation();
$model->setAttributes([
'tag_id' => $tagId,
'table_name' => TaggableTrait::cleanBaseTableName($this->tableName),
'pk_id' => $this->getItemId(),
]);
$model->insert(false);
return 1;
}
} | php | public function callbackSaveRelation($tagId)
{
$find = TagRelation::find()->where(['tag_id' => $tagId, 'table_name' => TaggableTrait::cleanBaseTableName($this->tableName), 'pk_id' => $this->getItemId()])->one();
if ($find) {
TagRelation::deleteAll(['tag_id' => $tagId, 'table_name' => TaggableTrait::cleanBaseTableName($this->tableName), 'pk_id' => $this->getItemId()]);
return 0;
} else {
$model = new TagRelation();
$model->setAttributes([
'tag_id' => $tagId,
'table_name' => TaggableTrait::cleanBaseTableName($this->tableName),
'pk_id' => $this->getItemId(),
]);
$model->insert(false);
return 1;
}
} | [
"public",
"function",
"callbackSaveRelation",
"(",
"$",
"tagId",
")",
"{",
"$",
"find",
"=",
"TagRelation",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'tag_id'",
"=>",
"$",
"tagId",
",",
"'table_name'",
"=>",
"TaggableTrait",
"::",
"cleanBaseTableName... | Save or delete a given tag id from the list of tags.
@param integer $tagId The id of the tag.
@return number | [
"Save",
"or",
"delete",
"a",
"given",
"tag",
"id",
"from",
"the",
"list",
"of",
"tags",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/TaggableActiveWindow.php#L140-L157 | train |
luyadev/luya-module-admin | src/aws/TaggableActiveWindow.php | TaggableActiveWindow.callbackSaveTag | public function callbackSaveTag($tagName)
{
$model = Tag::find()->where(['name' => $tagName])->exists();
if ($model) {
return false;
}
$model = new Tag();
$model->name = $tagName;
$model->save();
return $model->id;
} | php | public function callbackSaveTag($tagName)
{
$model = Tag::find()->where(['name' => $tagName])->exists();
if ($model) {
return false;
}
$model = new Tag();
$model->name = $tagName;
$model->save();
return $model->id;
} | [
"public",
"function",
"callbackSaveTag",
"(",
"$",
"tagName",
")",
"{",
"$",
"model",
"=",
"Tag",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'name'",
"=>",
"$",
"tagName",
"]",
")",
"->",
"exists",
"(",
")",
";",
"if",
"(",
"$",
"model",
"... | Save new tag to the list of tags.
@param string $tagName
@return boolean|number | [
"Save",
"new",
"tag",
"to",
"the",
"list",
"of",
"tags",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/aws/TaggableActiveWindow.php#L165-L178 | train |
luyadev/luya-module-admin | src/ngrest/Config.php | Config.getPointerPlugins | public function getPointerPlugins($pointer)
{
$plugins = [];
foreach ($this->getPointer($pointer, []) as $field) {
$plugins[] = self::createField($field);
}
return $plugins;
} | php | public function getPointerPlugins($pointer)
{
$plugins = [];
foreach ($this->getPointer($pointer, []) as $field) {
$plugins[] = self::createField($field);
}
return $plugins;
} | [
"public",
"function",
"getPointerPlugins",
"(",
"$",
"pointer",
")",
"{",
"$",
"plugins",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getPointer",
"(",
"$",
"pointer",
",",
"[",
"]",
")",
"as",
"$",
"field",
")",
"{",
"$",
"plugins",
"[... | Get all plugin objects for a given pointer.
@param string $pointer The name of the pointer (list, create, update).
@return \luya\admin\ngrest\base\Plugin An array with plugin objects
@since 2.0.0 | [
"Get",
"all",
"plugin",
"objects",
"for",
"a",
"given",
"pointer",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/Config.php#L398-L406 | train |
luyadev/luya-module-admin | src/ngrest/Config.php | Config.getOption | public function getOption($key)
{
return ($this->hasPointer('options') && array_key_exists($key, $this->_config['options'])) ? $this->_config['options'][$key] : false;
} | php | public function getOption($key)
{
return ($this->hasPointer('options') && array_key_exists($key, $this->_config['options'])) ? $this->_config['options'][$key] : false;
} | [
"public",
"function",
"getOption",
"(",
"$",
"key",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"hasPointer",
"(",
"'options'",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_config",
"[",
"'options'",
"]",
")",
")",
"?",
"... | Get an option by its key from the options pointer. Define options like
```php
$configBuilder->options = ['saveCallback' => 'console.log(this)'];
```
Get the option parameter
```php
$config->getOption('saveCallback');
```
@param string $key
@return boolean | [
"Get",
"an",
"option",
"by",
"its",
"key",
"from",
"the",
"options",
"pointer",
".",
"Define",
"options",
"like"
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/Config.php#L441-L444 | train |
luyadev/luya-module-admin | src/ngrest/Config.php | Config.getExtraFields | public function getExtraFields()
{
if ($this->_extraFields === null) {
$extraFields = [];
foreach ($this->getConfig() as $pointer => $fields) {
if (is_array($fields)) {
foreach ($fields as $field) {
if (isset($field['extraField']) && $field['extraField']) {
if (!array_key_exists($field['name'], $extraFields)) {
$extraFields[] = $field['name'];
}
}
}
}
}
$this->_extraFields = $extraFields;
}
return $this->_extraFields;
} | php | public function getExtraFields()
{
if ($this->_extraFields === null) {
$extraFields = [];
foreach ($this->getConfig() as $pointer => $fields) {
if (is_array($fields)) {
foreach ($fields as $field) {
if (isset($field['extraField']) && $field['extraField']) {
if (!array_key_exists($field['name'], $extraFields)) {
$extraFields[] = $field['name'];
}
}
}
}
}
$this->_extraFields = $extraFields;
}
return $this->_extraFields;
} | [
"public",
"function",
"getExtraFields",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_extraFields",
"===",
"null",
")",
"{",
"$",
"extraFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"as",
"$",
"pointer",
"=>"... | Get all extra fields.
@return array | [
"Get",
"all",
"extra",
"fields",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/Config.php#L544-L563 | train |
luyadev/luya-module-admin | src/models/StorageFilter.php | StorageFilter.removeImageSources | public function removeImageSources()
{
$log = [];
foreach (StorageImage::find()->where(['filter_id' => $this->id])->all() as $img) {
$source = $img->serverSource;
$image = $img->delete();
$log[$source] = $image;
}
return $log;
} | php | public function removeImageSources()
{
$log = [];
foreach (StorageImage::find()->where(['filter_id' => $this->id])->all() as $img) {
$source = $img->serverSource;
$image = $img->delete();
$log[$source] = $image;
}
return $log;
} | [
"public",
"function",
"removeImageSources",
"(",
")",
"{",
"$",
"log",
"=",
"[",
"]",
";",
"foreach",
"(",
"StorageImage",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'filter_id'",
"=>",
"$",
"this",
"->",
"id",
"]",
")",
"->",
"all",
"(",
")... | Remove image sources of the file. | [
"Remove",
"image",
"sources",
"of",
"the",
"file",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFilter.php#L58-L69 | train |
luyadev/luya-module-admin | src/models/StorageFilter.php | StorageFilter.applyFilterChain | public function applyFilterChain($source, $fileSavePath)
{
$loadFrom = $source;
foreach (StorageFilterChain::find()->where(['filter_id' => $this->id])->with(['effect'])->all() as $chain) {
// apply filter
$chain->applyFilter($loadFrom, $fileSavePath);
// override load from path for next iteration (if any).
$loadFrom = $fileSavePath;
}
return true;
} | php | public function applyFilterChain($source, $fileSavePath)
{
$loadFrom = $source;
foreach (StorageFilterChain::find()->where(['filter_id' => $this->id])->with(['effect'])->all() as $chain) {
// apply filter
$chain->applyFilter($loadFrom, $fileSavePath);
// override load from path for next iteration (if any).
$loadFrom = $fileSavePath;
}
return true;
} | [
"public",
"function",
"applyFilterChain",
"(",
"$",
"source",
",",
"$",
"fileSavePath",
")",
"{",
"$",
"loadFrom",
"=",
"$",
"source",
";",
"foreach",
"(",
"StorageFilterChain",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'filter_id'",
"=>",
"$",
"... | Apply the current filter chain.
Apply all filters from the chain to a given file and stores the new generated file on the $fileSavePath
@param string $source the Source path to the file, which the filter chain should be applied to.
@param string $fileSavePath
@return boolean | [
"Apply",
"the",
"current",
"filter",
"chain",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/StorageFilter.php#L95-L107 | train |
luyadev/luya-module-admin | src/commands/QueueController.php | QueueController.actionIndex | public function actionIndex()
{
Yii::$app->adminqueue->run(false);
Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
return ExitCode::OK;
} | php | public function actionIndex()
{
Yii::$app->adminqueue->run(false);
Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
return ExitCode::OK;
} | [
"public",
"function",
"actionIndex",
"(",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"adminqueue",
"->",
"run",
"(",
"false",
")",
";",
"Config",
"::",
"set",
"(",
"Config",
"::",
"CONFIG_QUEUE_TIMESTAMP",
",",
"time",
"(",
")",
")",
";",
"return",
"Exit... | Run the queue jobs. | [
"Run",
"the",
"queue",
"jobs",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/QueueController.php#L26-L31 | train |
luyadev/luya-module-admin | src/models/UserSetting.php | UserSetting.get | public function get($key, $default = null)
{
$array = $this->data;
foreach (explode(self::SEPERATOR, $key) as $item) {
if (is_array($array) && array_key_exists($item, $array)) {
$array = $array[$item];
} else {
return $default;
}
}
return $array;
} | php | public function get($key, $default = null)
{
$array = $this->data;
foreach (explode(self::SEPERATOR, $key) as $item) {
if (is_array($array) && array_key_exists($item, $array)) {
$array = $array[$item];
} else {
return $default;
}
}
return $array;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"array",
"=",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"explode",
"(",
"self",
"::",
"SEPERATOR",
",",
"$",
"key",
")",
"as",
"$",
"item",
")",
... | Get a key of the user settings, dot notation is allowed to return a key of an array.
@param string $key
@param string|bool|null $default
@return string|array|null | [
"Get",
"a",
"key",
"of",
"the",
"user",
"settings",
"dot",
"notation",
"is",
"allowed",
"to",
"return",
"a",
"key",
"of",
"an",
"array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserSetting.php#L66-L78 | train |
luyadev/luya-module-admin | src/models/UserSetting.php | UserSetting.getArray | public function getArray(array $keys, array $defaultMapping = [])
{
$data = [];
foreach ($keys as $key) {
$data[$key] = $this->get($key, array_key_exists($key, $defaultMapping) ? $defaultMapping[$key] : null);
}
return $data;
} | php | public function getArray(array $keys, array $defaultMapping = [])
{
$data = [];
foreach ($keys as $key) {
$data[$key] = $this->get($key, array_key_exists($key, $defaultMapping) ? $defaultMapping[$key] : null);
}
return $data;
} | [
"public",
"function",
"getArray",
"(",
"array",
"$",
"keys",
",",
"array",
"$",
"defaultMapping",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"... | Returns multiple array keys from the user settings table.
Example usage:
```php
getArray(['key1', 'key2', [
'key1' => false,
'key2' => true,
]);
```
The above example would return the default value true for `key2` if this element is not found inside the
user settings.
@param array $keys Provide an array of keys you to select.
@param array $defaultMapping In order to define a default value for a given key, just use the variable name
as array key.`
@return array | [
"Returns",
"multiple",
"array",
"keys",
"from",
"the",
"user",
"settings",
"table",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserSetting.php#L100-L108 | train |
luyadev/luya-module-admin | src/models/UserSetting.php | UserSetting.has | public function has($key)
{
$array = $this->data;
foreach (explode(self::SEPERATOR, $key) as $item) {
if (is_array($array) && array_key_exists($item, $array)) {
$array = $array[$item];
} else {
return false;
}
}
return true;
} | php | public function has($key)
{
$array = $this->data;
foreach (explode(self::SEPERATOR, $key) as $item) {
if (is_array($array) && array_key_exists($item, $array)) {
$array = $array[$item];
} else {
return false;
}
}
return true;
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"array",
"=",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"explode",
"(",
"self",
"::",
"SEPERATOR",
",",
"$",
"key",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
... | Check if an element existing inside the user settings or not.
@param string $key
@return boolean | [
"Check",
"if",
"an",
"element",
"existing",
"inside",
"the",
"user",
"settings",
"or",
"not",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserSetting.php#L116-L128 | train |
luyadev/luya-module-admin | src/models/UserSetting.php | UserSetting.remove | public function remove($key)
{
if ($this->has($key)) {
$array = &$this->data;
foreach (explode(self::SEPERATOR, $key) as $item) {
if (array_key_exists($item, $array)) {
$lastArray = &$array;
$array = &$array[$item];
}
}
unset($lastArray[$item]);
if (empty($lastArray)) {
unset($lastArray);
}
$this->save();
return true;
}
return false;
} | php | public function remove($key)
{
if ($this->has($key)) {
$array = &$this->data;
foreach (explode(self::SEPERATOR, $key) as $item) {
if (array_key_exists($item, $array)) {
$lastArray = &$array;
$array = &$array[$item];
}
}
unset($lastArray[$item]);
if (empty($lastArray)) {
unset($lastArray);
}
$this->save();
return true;
}
return false;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"array",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"explode",
"(",
"self",
"::",
"SEPERATOR",
"... | Remove an element from the user settings data array.
@param string $key
@return bool | [
"Remove",
"an",
"element",
"from",
"the",
"user",
"settings",
"data",
"array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserSetting.php#L136-L156 | train |
luyadev/luya-module-admin | src/models/UserSetting.php | UserSetting.set | public function set($key, $value)
{
$array = &$this->data;
$keys = explode(self::SEPERATOR, $key);
$i = 1;
foreach ($keys as $item) {
if (is_array($array) && array_key_exists($item, $array) && !is_array($array[$item]) && $i !== count($keys)) {
return false;
}
$array = &$array[$item];
$i++;
}
$array = $value;
$this->save();
return true;
} | php | public function set($key, $value)
{
$array = &$this->data;
$keys = explode(self::SEPERATOR, $key);
$i = 1;
foreach ($keys as $item) {
if (is_array($array) && array_key_exists($item, $array) && !is_array($array[$item]) && $i !== count($keys)) {
return false;
}
$array = &$array[$item];
$i++;
}
$array = $value;
$this->save();
return true;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"array",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"$",
"keys",
"=",
"explode",
"(",
"self",
"::",
"SEPERATOR",
",",
"$",
"key",
")",
";",
"$",
"i",
"=",
"1",
";"... | Add a new element to the user settings array.
@param string $key
@param array|string|boolean $value
@return bool | [
"Add",
"a",
"new",
"element",
"to",
"the",
"user",
"settings",
"array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/UserSetting.php#L165-L180 | train |
luyadev/luya-module-admin | src/commands/SetupController.php | SetupController.actionUser | public function actionUser()
{
while (true) {
$email = $this->prompt('User E-Mail:');
if (!empty(User::findByEmail($email))) {
$this->outputError('The provided E-Mail already exists in the System.');
} else {
break;
}
}
$titleArray = ['Mr' => 1, 'Mrs' => 2];
$title = $this->select('Title:', $titleArray);
$firstname = $this->prompt('Firstname:');
$lastname = $this->prompt('Lastname:');
$password = $this->prompt('User Password:');
if ($this->confirm("Are you sure to create the User '$email'?") !== true) {
return $this->outputError('Abort user creation process.');
}
$user = new User();
$user->email = $email;
$user->password_salt = Yii::$app->getSecurity()->generateRandomString();
$user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->title = $titleArray[$title];
if (!$user->save()) {
return $this->outputError('User validation error: ' . VarDumper::dumpAsString($user->getErrors()));
}
$groupSelect = [];
foreach (Group::find()->all() as $entry) {
$groupSelect[$entry->id] = $entry->name.' ('.$entry->text.')';
$this->output($entry->id.' - '.$groupSelect[$entry->id]);
}
$groupId = $this->select('Select Group the user should belong to:', $groupSelect);
$this->insert('{{%admin_user_group}}', [
'user_id' => $user->id,
'group_id' => $groupId,
]);
return $this->outputSuccess("The user ($email) has been created.");
} | php | public function actionUser()
{
while (true) {
$email = $this->prompt('User E-Mail:');
if (!empty(User::findByEmail($email))) {
$this->outputError('The provided E-Mail already exists in the System.');
} else {
break;
}
}
$titleArray = ['Mr' => 1, 'Mrs' => 2];
$title = $this->select('Title:', $titleArray);
$firstname = $this->prompt('Firstname:');
$lastname = $this->prompt('Lastname:');
$password = $this->prompt('User Password:');
if ($this->confirm("Are you sure to create the User '$email'?") !== true) {
return $this->outputError('Abort user creation process.');
}
$user = new User();
$user->email = $email;
$user->password_salt = Yii::$app->getSecurity()->generateRandomString();
$user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->title = $titleArray[$title];
if (!$user->save()) {
return $this->outputError('User validation error: ' . VarDumper::dumpAsString($user->getErrors()));
}
$groupSelect = [];
foreach (Group::find()->all() as $entry) {
$groupSelect[$entry->id] = $entry->name.' ('.$entry->text.')';
$this->output($entry->id.' - '.$groupSelect[$entry->id]);
}
$groupId = $this->select('Select Group the user should belong to:', $groupSelect);
$this->insert('{{%admin_user_group}}', [
'user_id' => $user->id,
'group_id' => $groupId,
]);
return $this->outputSuccess("The user ($email) has been created.");
} | [
"public",
"function",
"actionUser",
"(",
")",
"{",
"while",
"(",
"true",
")",
"{",
"$",
"email",
"=",
"$",
"this",
"->",
"prompt",
"(",
"'User E-Mail:'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"User",
"::",
"findByEmail",
"(",
"$",
"email",
")",
"... | Create a new user and append them to an existing group.
@return bool
@throws Exception | [
"Create",
"a",
"new",
"user",
"and",
"append",
"them",
"to",
"an",
"existing",
"group",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/SetupController.php#L197-L244 | train |
luyadev/luya-module-admin | src/commands/SetupController.php | SetupController.actionResetPassword | public function actionResetPassword()
{
/** @var User $user */
$user = null;
while (empty($user)) {
$email = $this->email ?: $this->prompt('User E-Mail:');
$user = User::findByEmail($email);
if (empty($user)) {
$this->outputError('The provided E-Mail not found in the System.');
}
}
$password = $this->password ?: $this->prompt('User Password:');
if ($this->confirm("Are you sure to change the password of User '$email'?") !== true) {
return $this->outputError('Abort password change process.');
}
$user->password_salt = Yii::$app->getSecurity()->generateRandomString();
$user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
if ($user->save(true, ['password', 'password_salt'])) {
return $this->outputSuccess("The password for user ($email) has been changed.");
}
return $this->outputError("The password could not changed.\n" . implode("\n", $user->firstErrors));
} | php | public function actionResetPassword()
{
/** @var User $user */
$user = null;
while (empty($user)) {
$email = $this->email ?: $this->prompt('User E-Mail:');
$user = User::findByEmail($email);
if (empty($user)) {
$this->outputError('The provided E-Mail not found in the System.');
}
}
$password = $this->password ?: $this->prompt('User Password:');
if ($this->confirm("Are you sure to change the password of User '$email'?") !== true) {
return $this->outputError('Abort password change process.');
}
$user->password_salt = Yii::$app->getSecurity()->generateRandomString();
$user->password = Yii::$app->getSecurity()->generatePasswordHash($password.$user->password_salt);
if ($user->save(true, ['password', 'password_salt'])) {
return $this->outputSuccess("The password for user ($email) has been changed.");
}
return $this->outputError("The password could not changed.\n" . implode("\n", $user->firstErrors));
} | [
"public",
"function",
"actionResetPassword",
"(",
")",
"{",
"/** @var User $user */",
"$",
"user",
"=",
"null",
";",
"while",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"{",
"$",
"email",
"=",
"$",
"this",
"->",
"email",
"?",
":",
"$",
"this",
"->",
"... | Change the password of a admin user.
@return bool
@since 2.0.0 | [
"Change",
"the",
"password",
"of",
"a",
"admin",
"user",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/SetupController.php#L252-L278 | train |
luyadev/luya-module-admin | src/commands/SetupController.php | SetupController.insert | private function insert($table, array $fields)
{
return Yii::$app->db->createCommand()->insert($table, $fields)->execute();
} | php | private function insert($table, array $fields)
{
return Yii::$app->db->createCommand()->insert($table, $fields)->execute();
} | [
"private",
"function",
"insert",
"(",
"$",
"table",
",",
"array",
"$",
"fields",
")",
"{",
"return",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"insert",
"(",
"$",
"table",
",",
"$",
"fields",
")",
"->",
"execute",
... | Helper to insert data in database table.
@param string $table The database table
@param array $fields The array with insert fields
@return int | [
"Helper",
"to",
"insert",
"data",
"in",
"database",
"table",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/commands/SetupController.php#L287-L290 | train |
luyadev/luya-module-admin | src/components/AdminUser.php | AdminUser.onAfterLogin | public function onAfterLogin(UserEvent $event)
{
if (!$this->identity->is_api_user) {
Yii::$app->language = $this->getInterfaceLanguage();
}
} | php | public function onAfterLogin(UserEvent $event)
{
if (!$this->identity->is_api_user) {
Yii::$app->language = $this->getInterfaceLanguage();
}
} | [
"public",
"function",
"onAfterLogin",
"(",
"UserEvent",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"identity",
"->",
"is_api_user",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"language",
"=",
"$",
"this",
"->",
"getInterfaceLanguage",
"(",
... | After the login process of the user, set the admin interface language based on the user settings.
@param UserEvent $event | [
"After",
"the",
"login",
"process",
"of",
"the",
"user",
"set",
"the",
"admin",
"interface",
"language",
"based",
"on",
"the",
"user",
"settings",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/AdminUser.php#L71-L76 | train |
luyadev/luya-module-admin | src/components/AdminUser.php | AdminUser.getInterfaceLanguage | public function getInterfaceLanguage()
{
return $this->getIsGuest() ? $this->defaultLanguage : $this->identity->setting->get('luyadminlanguage', $this->defaultLanguage);
} | php | public function getInterfaceLanguage()
{
return $this->getIsGuest() ? $this->defaultLanguage : $this->identity->setting->get('luyadminlanguage', $this->defaultLanguage);
} | [
"public",
"function",
"getInterfaceLanguage",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getIsGuest",
"(",
")",
"?",
"$",
"this",
"->",
"defaultLanguage",
":",
"$",
"this",
"->",
"identity",
"->",
"setting",
"->",
"get",
"(",
"'luyadminlanguage'",
",",
"... | Return the interface language for the given logged in user.
@return string | [
"Return",
"the",
"interface",
"language",
"for",
"the",
"given",
"logged",
"in",
"user",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/AdminUser.php#L83-L86 | train |
luyadev/luya-module-admin | src/components/AdminUser.php | AdminUser.onBeforeLogout | public function onBeforeLogout()
{
UserOnline::removeUser($this->id);
$this->identity->updateAttributes([
'auth_token' => Yii::$app->security->hashData(Yii::$app->security->generateRandomString(), $this->identity->password_salt),
]);
// kill all user logins for the given user
UserLogin::updateAll(['is_destroyed' => true], ['user_id' => $this->id]);
} | php | public function onBeforeLogout()
{
UserOnline::removeUser($this->id);
$this->identity->updateAttributes([
'auth_token' => Yii::$app->security->hashData(Yii::$app->security->generateRandomString(), $this->identity->password_salt),
]);
// kill all user logins for the given user
UserLogin::updateAll(['is_destroyed' => true], ['user_id' => $this->id]);
} | [
"public",
"function",
"onBeforeLogout",
"(",
")",
"{",
"UserOnline",
"::",
"removeUser",
"(",
"$",
"this",
"->",
"id",
")",
";",
"$",
"this",
"->",
"identity",
"->",
"updateAttributes",
"(",
"[",
"'auth_token'",
"=>",
"Yii",
"::",
"$",
"app",
"->",
"secu... | After loging out, the useronline status must be refreshed and the current user must be deleted from the user online list. | [
"After",
"loging",
"out",
"the",
"useronline",
"status",
"must",
"be",
"refreshed",
"and",
"the",
"current",
"user",
"must",
"be",
"deleted",
"from",
"the",
"user",
"online",
"list",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/AdminUser.php#L91-L101 | train |
luyadev/luya-module-admin | src/components/AdminUser.php | AdminUser.canApi | public function canApi($apiEndpoint, $typeVerification = false)
{
return !$this->isGuest && Yii::$app->auth->matchApi($this->getId(), $apiEndpoint, $typeVerification);
} | php | public function canApi($apiEndpoint, $typeVerification = false)
{
return !$this->isGuest && Yii::$app->auth->matchApi($this->getId(), $apiEndpoint, $typeVerification);
} | [
"public",
"function",
"canApi",
"(",
"$",
"apiEndpoint",
",",
"$",
"typeVerification",
"=",
"false",
")",
"{",
"return",
"!",
"$",
"this",
"->",
"isGuest",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"auth",
"->",
"matchApi",
"(",
"$",
"this",
"->",
"getId",
... | Perform a can api match request for the logged in user if user is logged in, returns false otherwhise.
See the {{luya\admin\components\Auth::matchApi}} for details.
@param string $apiEndpoint
@param string $typeVerification
@return boolean Whether the current user can request the provided api endpoint. | [
"Perform",
"a",
"can",
"api",
"match",
"request",
"for",
"the",
"logged",
"in",
"user",
"if",
"user",
"is",
"logged",
"in",
"returns",
"false",
"otherwhise",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/AdminUser.php#L112-L115 | train |
luyadev/luya-module-admin | src/components/AdminUser.php | AdminUser.canRoute | public function canRoute($route)
{
return !$this->isGuest && Yii::$app->auth->matchRoute($this->getId(), $route);
} | php | public function canRoute($route)
{
return !$this->isGuest && Yii::$app->auth->matchRoute($this->getId(), $route);
} | [
"public",
"function",
"canRoute",
"(",
"$",
"route",
")",
"{",
"return",
"!",
"$",
"this",
"->",
"isGuest",
"&&",
"Yii",
"::",
"$",
"app",
"->",
"auth",
"->",
"matchRoute",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
",",
"$",
"route",
")",
";",
"... | Perform a can route auth request match for the logged in user if user is logged in, returns false otherwhise.
See the {{luya\admin\components\Auth::matchRoute}} for details.
@param string $route
@return bool Whether the current user can request the provided route. | [
"Perform",
"a",
"can",
"route",
"auth",
"request",
"match",
"for",
"the",
"logged",
"in",
"user",
"if",
"user",
"is",
"logged",
"in",
"returns",
"false",
"otherwhise",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/components/AdminUser.php#L125-L128 | train |
luyadev/luya-module-admin | src/ngrest/plugins/SelectRelationActiveQuery.php | SelectRelationActiveQuery.setLabelField | public function setLabelField($labelField)
{
if (is_string($labelField)) {
$labelField = explode(",", $labelField);
}
$this->_labelField = $labelField;
} | php | public function setLabelField($labelField)
{
if (is_string($labelField)) {
$labelField = explode(",", $labelField);
}
$this->_labelField = $labelField;
} | [
"public",
"function",
"setLabelField",
"(",
"$",
"labelField",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"labelField",
")",
")",
"{",
"$",
"labelField",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"labelField",
")",
";",
"}",
"$",
"this",
"->",
"_labelFi... | Setter method for Label Field.
@param string|array $labelField The fields to display based on the sql table seperated by commas or as array. | [
"Setter",
"method",
"for",
"Label",
"Field",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/plugins/SelectRelationActiveQuery.php#L64-L71 | train |
luyadev/luya-module-admin | src/ngrest/plugins/SelectRelationActiveQuery.php | SelectRelationActiveQuery.getRelationApiEndpoint | protected function getRelationApiEndpoint()
{
// build class name
$class = $this->_query->modelClass;
// fetch menu api detail from endpoint name
$menu = Yii::$app->adminmenu->getApiDetail($class::ngRestApiEndpoint());
if (!$menu) {
throw new InvalidConfigException("Unable to find the API endpoint, maybe insufficent permission or missing admin module context (admin module prefix).");
}
// @todo what about: admin/
return 'admin/'.$menu['permissionApiEndpoint'];
} | php | protected function getRelationApiEndpoint()
{
// build class name
$class = $this->_query->modelClass;
// fetch menu api detail from endpoint name
$menu = Yii::$app->adminmenu->getApiDetail($class::ngRestApiEndpoint());
if (!$menu) {
throw new InvalidConfigException("Unable to find the API endpoint, maybe insufficent permission or missing admin module context (admin module prefix).");
}
// @todo what about: admin/
return 'admin/'.$menu['permissionApiEndpoint'];
} | [
"protected",
"function",
"getRelationApiEndpoint",
"(",
")",
"{",
"// build class name",
"$",
"class",
"=",
"$",
"this",
"->",
"_query",
"->",
"modelClass",
";",
"// fetch menu api detail from endpoint name",
"$",
"menu",
"=",
"Yii",
"::",
"$",
"app",
"->",
"admin... | Get the admin api endpoint name.
@return string
@since 1.2.2 | [
"Get",
"the",
"admin",
"api",
"endpoint",
"name",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/plugins/SelectRelationActiveQuery.php#L135-L148 | train |
luyadev/luya-module-admin | src/apis/SearchController.php | SearchController.transformGenericSearchToData | private function transformGenericSearchToData($response)
{
if ($response instanceof ActiveQueryInterface) {
return $response->asArray(true)->all();
} elseif ($response instanceof QueryInterface) {
return $response->all();
}
return $response;
} | php | private function transformGenericSearchToData($response)
{
if ($response instanceof ActiveQueryInterface) {
return $response->asArray(true)->all();
} elseif ($response instanceof QueryInterface) {
return $response->all();
}
return $response;
} | [
"private",
"function",
"transformGenericSearchToData",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"instanceof",
"ActiveQueryInterface",
")",
"{",
"return",
"$",
"response",
"->",
"asArray",
"(",
"true",
")",
"->",
"all",
"(",
")",
";",
"}",
... | Transform the different generic search response into an array.
@param array|\yii\db\QueryInterface|\yii\db\ActiveQueryInterface $response
@return array
@since 1.2.2 | [
"Transform",
"the",
"different",
"generic",
"search",
"response",
"into",
"an",
"array",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/SearchController.php#L28-L37 | train |
luyadev/luya-module-admin | src/apis/SearchController.php | SearchController.actionIndex | public function actionIndex($query)
{
$search = [];
$module = Yii::$app->getModule('admin');
foreach (Yii::$app->adminmenu->getModules() as $node) {
if (isset($node['searchModelClass']) && !empty($node['searchModelClass'])) {
$model = Yii::createObject($node['searchModelClass']);
if (!$model instanceof GenericSearchInterface) {
throw new Exception('The model must be an instance of GenericSearchInterface');
}
$data = $this->transformGenericSearchToData($model->genericSearch($query));
if (count($data) > 0) {
$stateProvider = $model->genericSearchStateProvider();
$search[] = [
'hideFields' => $model->genericSearchHiddenFields(),
'type' => 'custom',
'menuItem' => $node,
'data' => $data,
'stateProvider' => $stateProvider,
];
}
unset($data);
}
}
foreach (Yii::$app->adminmenu->getItems() as $api) {
if ($api['permissionIsApi']) {
$ctrl = $module->createController($api['permissionApiEndpoint']);
$controller = $ctrl[0];
$data = $this->transformGenericSearchToData($controller->model->genericSearch($query));
if (count($data) > 0) {
$search[] = [
'hideFields' => $controller->model->genericSearchHiddenFields(),
'type' => 'api',
'menuItem' => $api,
'data' => $data,
'stateProvider' => $controller->model->genericSearchStateProvider(),
];
}
unset($data);
}
}
$searchData = new SearchData();
$searchData->query = $query;
$searchData->num_rows = count($search);
$searchData->save();
return $search;
} | php | public function actionIndex($query)
{
$search = [];
$module = Yii::$app->getModule('admin');
foreach (Yii::$app->adminmenu->getModules() as $node) {
if (isset($node['searchModelClass']) && !empty($node['searchModelClass'])) {
$model = Yii::createObject($node['searchModelClass']);
if (!$model instanceof GenericSearchInterface) {
throw new Exception('The model must be an instance of GenericSearchInterface');
}
$data = $this->transformGenericSearchToData($model->genericSearch($query));
if (count($data) > 0) {
$stateProvider = $model->genericSearchStateProvider();
$search[] = [
'hideFields' => $model->genericSearchHiddenFields(),
'type' => 'custom',
'menuItem' => $node,
'data' => $data,
'stateProvider' => $stateProvider,
];
}
unset($data);
}
}
foreach (Yii::$app->adminmenu->getItems() as $api) {
if ($api['permissionIsApi']) {
$ctrl = $module->createController($api['permissionApiEndpoint']);
$controller = $ctrl[0];
$data = $this->transformGenericSearchToData($controller->model->genericSearch($query));
if (count($data) > 0) {
$search[] = [
'hideFields' => $controller->model->genericSearchHiddenFields(),
'type' => 'api',
'menuItem' => $api,
'data' => $data,
'stateProvider' => $controller->model->genericSearchStateProvider(),
];
}
unset($data);
}
}
$searchData = new SearchData();
$searchData->query = $query;
$searchData->num_rows = count($search);
$searchData->save();
return $search;
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"query",
")",
"{",
"$",
"search",
"=",
"[",
"]",
";",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"'admin'",
")",
";",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
"adminmenu... | Administration Global search provider.
This method returns all node items with an search model class or a generic search interface instance and returns its data.
@param string $query The query to search for.
@return array
@throws Exception | [
"Administration",
"Global",
"search",
"provider",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/apis/SearchController.php#L47-L99 | train |
luyadev/luya-module-admin | src/ngrest/aw/ActiveWindowFormWidget.php | ActiveWindowFormWidget.field | public function field($attribute, $label = null, $options = [])
{
$config = $this->fieldConfig;
if (!isset($config['class'])) {
$config['class'] = $this->fieldClass;
}
return Yii::createObject(ArrayHelper::merge($config, $options, [
'attribute' => $attribute,
'form' => $this,
'label' => $label,
]));
} | php | public function field($attribute, $label = null, $options = [])
{
$config = $this->fieldConfig;
if (!isset($config['class'])) {
$config['class'] = $this->fieldClass;
}
return Yii::createObject(ArrayHelper::merge($config, $options, [
'attribute' => $attribute,
'form' => $this,
'label' => $label,
]));
} | [
"public",
"function",
"field",
"(",
"$",
"attribute",
",",
"$",
"label",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"fieldConfig",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'cla... | Generate a field based on attribute name and optional label.
@param string $attribute The name of the field (which also will sent to the callback as this name)
@param string $label Optional Label
@param array $options
@return \luya\admin\ngrest\aw\ActiveField | [
"Generate",
"a",
"field",
"based",
"on",
"attribute",
"name",
"and",
"optional",
"label",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/aw/ActiveWindowFormWidget.php#L103-L116 | train |
luyadev/luya-module-admin | src/ngrest/NgRest.php | NgRest.render | public function render(RenderInterface $render)
{
$this->render = $render;
$this->render->setConfig($this->config);
return $this->render->render();
} | php | public function render(RenderInterface $render)
{
$this->render = $render;
$this->render->setConfig($this->config);
return $this->render->render();
} | [
"public",
"function",
"render",
"(",
"RenderInterface",
"$",
"render",
")",
"{",
"$",
"this",
"->",
"render",
"=",
"$",
"render",
";",
"$",
"this",
"->",
"render",
"->",
"setConfig",
"(",
"$",
"this",
"->",
"config",
")",
";",
"return",
"$",
"this",
... | Renders the Config for the Given Render Interface.
@param \luya\admin\ngrest\render\RenderInterface $render
@return string | [
"Renders",
"the",
"Config",
"for",
"the",
"Given",
"Render",
"Interface",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/NgRest.php#L54-L59 | train |
luyadev/luya-module-admin | src/ngrest/NgRest.php | NgRest.createPluginObject | public static function createPluginObject($className, $name, $alias, $i18n, $args = [])
{
return Yii::createObject(array_merge([
'class' => $className,
'name' => $name,
'alias' => $alias,
'i18n' => $i18n,
], $args));
} | php | public static function createPluginObject($className, $name, $alias, $i18n, $args = [])
{
return Yii::createObject(array_merge([
'class' => $className,
'name' => $name,
'alias' => $alias,
'i18n' => $i18n,
], $args));
} | [
"public",
"static",
"function",
"createPluginObject",
"(",
"$",
"className",
",",
"$",
"name",
",",
"$",
"alias",
",",
"$",
"i18n",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"return",
"Yii",
"::",
"createObject",
"(",
"array_merge",
"(",
"[",
"'class'... | Generates an NgRest Plugin Object.
@param string $className
@param string $name
@param string $alias
@param boolean $i18n
@param array $args
@return \luya\admin\ngrest\base\Plugin | [
"Generates",
"an",
"NgRest",
"Plugin",
"Object",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/ngrest/NgRest.php#L71-L79 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.getTypeBadge | public function getTypeBadge()
{
switch ($this->type) {
case self::TYPE_INFO:
return '<span class="badge badge-info">info</span>';
case self::TYPE_WARNING:
return '<span class="badge badge-warning">Warning</span>';
case self::TYPE_ERROR:
return '<span class="badge badge-danger">Error</span>';
case self::TYPE_SUCCESS:
return '<span class="badge badge-success">success</span>';
}
} | php | public function getTypeBadge()
{
switch ($this->type) {
case self::TYPE_INFO:
return '<span class="badge badge-info">info</span>';
case self::TYPE_WARNING:
return '<span class="badge badge-warning">Warning</span>';
case self::TYPE_ERROR:
return '<span class="badge badge-danger">Error</span>';
case self::TYPE_SUCCESS:
return '<span class="badge badge-success">success</span>';
}
} | [
"public",
"function",
"getTypeBadge",
"(",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"TYPE_INFO",
":",
"return",
"'<span class=\"badge badge-info\">info</span>'",
";",
"case",
"self",
"::",
"TYPE_WARNING",
":",
"return",... | Get the html badge for a status type in order to display inside the admin module.
@return string Type value evaluated as a badge. | [
"Get",
"the",
"html",
"badge",
"for",
"a",
"status",
"type",
"in",
"order",
"to",
"display",
"inside",
"the",
"admin",
"module",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L140-L152 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.getRequestIdentifier | private static function getRequestIdentifier()
{
if (self::$requestIdentifier === null) {
self::$requestIdentifier = uniqid('logger', true);
}
return self::$requestIdentifier;
} | php | private static function getRequestIdentifier()
{
if (self::$requestIdentifier === null) {
self::$requestIdentifier = uniqid('logger', true);
}
return self::$requestIdentifier;
} | [
"private",
"static",
"function",
"getRequestIdentifier",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"requestIdentifier",
"===",
"null",
")",
"{",
"self",
"::",
"$",
"requestIdentifier",
"=",
"uniqid",
"(",
"'logger'",
",",
"true",
")",
";",
"}",
"return"... | Generate request identifier.
@return string | [
"Generate",
"request",
"identifier",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L215-L222 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.getHashArray | private static function getHashArray($message, $groupIdentifier)
{
$hash = md5(static::getRequestIdentifier() . Json::encode((array) $groupIdentifier));
if (isset(self::$identiferIndex[$hash])) {
self::$identiferIndex[$hash]++;
} else {
self::$identiferIndex[$hash] = 1;
}
$hashIndex = self::$identiferIndex[$hash];
return [
'hash' => $hash,
'index' => $hashIndex,
];
} | php | private static function getHashArray($message, $groupIdentifier)
{
$hash = md5(static::getRequestIdentifier() . Json::encode((array) $groupIdentifier));
if (isset(self::$identiferIndex[$hash])) {
self::$identiferIndex[$hash]++;
} else {
self::$identiferIndex[$hash] = 1;
}
$hashIndex = self::$identiferIndex[$hash];
return [
'hash' => $hash,
'index' => $hashIndex,
];
} | [
"private",
"static",
"function",
"getHashArray",
"(",
"$",
"message",
",",
"$",
"groupIdentifier",
")",
"{",
"$",
"hash",
"=",
"md5",
"(",
"static",
"::",
"getRequestIdentifier",
"(",
")",
".",
"Json",
"::",
"encode",
"(",
"(",
"array",
")",
"$",
"groupI... | Get array index based on identifiers.
@param string $message
@param string $groupIdentifier
@return string[]|mixed[] | [
"Get",
"array",
"index",
"based",
"on",
"identifiers",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L231-L246 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.log | private static function log($type, $message, $trace, $groupIdentifier)
{
$hashArray = static::getHashArray($message, $groupIdentifier);
$file = 'unknown';
$line = 'unknown';
$fn = 'unknown';
$fnArgs = [];
if (isset($trace[0])) {
$file = !isset($trace[0]['file']) ? : $trace[0]['file'];
$line = !isset($trace[0]['line']) ? : $trace[0]['line'];
$fn = !isset($trace[0]['function']) ? : $trace[0]['function'];
$fnArgs = !isset($trace[0]['args']) ? : $trace[0]['args'];
}
if (isset($trace[1])) {
$fn = !isset($trace[1]['function']) ? : $trace[1]['function'];
$fnArgs = !isset($trace[1]['args']) ? : $trace[1]['args'];
}
if ($message instanceof Arrayable) {
$message = $message->toArray();
}
$model = new self();
$model->attributes = [
'time' => time(),
'message' => is_array($message) ? Json::encode($message) : $message,
'type' => $type,
'trace_file' => $file,
'trace_line' => $line,
'trace_function' => $fn,
'trace_function_args' => Json::encode($fnArgs),
'get' => (isset($_GET)) ? Json::encode($_GET) : '{}',
'post' => (isset($_POST)) ? Json::encode($_POST) : '{}',
'session' => (isset($_SESSION)) ? Json::encode($_SESSION) : '{}',
'server' => (isset($_SERVER)) ? Json::encode($_SERVER) : '{}',
'group_identifier' => $hashArray['hash'],
'group_identifier_index' => $hashArray['index'],
];
return $model->save(false);
} | php | private static function log($type, $message, $trace, $groupIdentifier)
{
$hashArray = static::getHashArray($message, $groupIdentifier);
$file = 'unknown';
$line = 'unknown';
$fn = 'unknown';
$fnArgs = [];
if (isset($trace[0])) {
$file = !isset($trace[0]['file']) ? : $trace[0]['file'];
$line = !isset($trace[0]['line']) ? : $trace[0]['line'];
$fn = !isset($trace[0]['function']) ? : $trace[0]['function'];
$fnArgs = !isset($trace[0]['args']) ? : $trace[0]['args'];
}
if (isset($trace[1])) {
$fn = !isset($trace[1]['function']) ? : $trace[1]['function'];
$fnArgs = !isset($trace[1]['args']) ? : $trace[1]['args'];
}
if ($message instanceof Arrayable) {
$message = $message->toArray();
}
$model = new self();
$model->attributes = [
'time' => time(),
'message' => is_array($message) ? Json::encode($message) : $message,
'type' => $type,
'trace_file' => $file,
'trace_line' => $line,
'trace_function' => $fn,
'trace_function_args' => Json::encode($fnArgs),
'get' => (isset($_GET)) ? Json::encode($_GET) : '{}',
'post' => (isset($_POST)) ? Json::encode($_POST) : '{}',
'session' => (isset($_SESSION)) ? Json::encode($_SESSION) : '{}',
'server' => (isset($_SERVER)) ? Json::encode($_SERVER) : '{}',
'group_identifier' => $hashArray['hash'],
'group_identifier_index' => $hashArray['index'],
];
return $model->save(false);
} | [
"private",
"static",
"function",
"log",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"trace",
",",
"$",
"groupIdentifier",
")",
"{",
"$",
"hashArray",
"=",
"static",
"::",
"getHashArray",
"(",
"$",
"message",
",",
"$",
"groupIdentifier",
")",
";",
... | Internal generate log message.
@param string $type
@param string $message
@param string $trace
@param string $groupIdentifier
@return boolean | [
"Internal",
"generate",
"log",
"message",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L257-L300 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.success | public static function success($message, $groupIdentifier = null)
{
return static::log(self::TYPE_SUCCESS, $message, debug_backtrace(false, 2), $groupIdentifier);
} | php | public static function success($message, $groupIdentifier = null)
{
return static::log(self::TYPE_SUCCESS, $message, debug_backtrace(false, 2), $groupIdentifier);
} | [
"public",
"static",
"function",
"success",
"(",
"$",
"message",
",",
"$",
"groupIdentifier",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"log",
"(",
"self",
"::",
"TYPE_SUCCESS",
",",
"$",
"message",
",",
"debug_backtrace",
"(",
"false",
",",
"2",
"... | Log a success message.
@param string $message The message to log for this current request event.
@param string $groupIdentifier If multiple logger events are in the same action and you want to seperate them, define an additional group identifier.
@return boolean | [
"Log",
"a",
"success",
"message",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L333-L336 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.info | public static function info($message, $groupIdentifier = null)
{
return static::log(self::TYPE_INFO, $message, debug_backtrace(false, 2), $groupIdentifier);
} | php | public static function info($message, $groupIdentifier = null)
{
return static::log(self::TYPE_INFO, $message, debug_backtrace(false, 2), $groupIdentifier);
} | [
"public",
"static",
"function",
"info",
"(",
"$",
"message",
",",
"$",
"groupIdentifier",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"log",
"(",
"self",
"::",
"TYPE_INFO",
",",
"$",
"message",
",",
"debug_backtrace",
"(",
"false",
",",
"2",
")",
... | Log an info message.
@param string $message The message to log for this current request event.
@param string $groupIdentifier If multiple logger events are in the same action and you want to seperate them, define an additional group identifier.
@return boolean | [
"Log",
"an",
"info",
"message",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L357-L360 | train |
luyadev/luya-module-admin | src/models/Logger.php | Logger.warning | public static function warning($message, $groupIdentifier = null)
{
return static::log(self::TYPE_WARNING, $message, debug_backtrace(false, 2), $groupIdentifier);
} | php | public static function warning($message, $groupIdentifier = null)
{
return static::log(self::TYPE_WARNING, $message, debug_backtrace(false, 2), $groupIdentifier);
} | [
"public",
"static",
"function",
"warning",
"(",
"$",
"message",
",",
"$",
"groupIdentifier",
"=",
"null",
")",
"{",
"return",
"static",
"::",
"log",
"(",
"self",
"::",
"TYPE_WARNING",
",",
"$",
"message",
",",
"debug_backtrace",
"(",
"false",
",",
"2",
"... | Log a warning message.
@param string $message The message to log for this current request event.
@param string $groupIdentifier If multiple logger events are in the same action and you want to seperate them, define an additional group identifier.
@return boolean | [
"Log",
"a",
"warning",
"message",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/models/Logger.php#L369-L372 | train |
luyadev/luya-module-admin | src/image/Item.php | Item.getCaption | public function getCaption()
{
if ($this->_caption === null) {
if ($this->getKey('caption', false)) {
$this->_caption = $this->getKey('caption');
} else {
$this->_caption = $this->file->caption;
}
}
return $this->_caption;
} | php | public function getCaption()
{
if ($this->_caption === null) {
if ($this->getKey('caption', false)) {
$this->_caption = $this->getKey('caption');
} else {
$this->_caption = $this->file->caption;
}
}
return $this->_caption;
} | [
"public",
"function",
"getCaption",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_caption",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getKey",
"(",
"'caption'",
",",
"false",
")",
")",
"{",
"$",
"this",
"->",
"_caption",
"=",
"$",
... | Return the caption text for this image, if not defined or none give its null.
If no image caption is defined from bind it will try to retrieve the caption from the file (set by filemanager).
@return string The caption text for this image
@since 1.0.0 | [
"Return",
"the",
"caption",
"text",
"for",
"this",
"image",
"if",
"not",
"defined",
"or",
"none",
"give",
"its",
"null",
"."
] | 58ddcefc96df70af010076216e43a78dd2bc61db | https://github.com/luyadev/luya-module-admin/blob/58ddcefc96df70af010076216e43a78dd2bc61db/src/image/Item.php#L54-L65 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.