repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
yuncms/framework | src/console/controllers/TaskController.php | TaskController.actionRun | public function actionRun()
{
$crontab = Task::findAll(['switch' => Task::SWITCH_ACTIVE]);
$tasks = [];
foreach ($crontab as $task) {
// 第一次运行,先计算下次运行时间
if (!$task->next_rundate) {
$task->next_rundate = $task->getNextRunDate();
$task->save(false);
continue;
}
// 判断运行时间到了没
if ($task->next_rundate <= date('Y-m-d H:i:s')) {
$tasks[] = $task;
}
}
$this->executeTask($tasks);
return ExitCode::OK;
} | php | public function actionRun()
{
$crontab = Task::findAll(['switch' => Task::SWITCH_ACTIVE]);
$tasks = [];
foreach ($crontab as $task) {
// 第一次运行,先计算下次运行时间
if (!$task->next_rundate) {
$task->next_rundate = $task->getNextRunDate();
$task->save(false);
continue;
}
// 判断运行时间到了没
if ($task->next_rundate <= date('Y-m-d H:i:s')) {
$tasks[] = $task;
}
}
$this->executeTask($tasks);
return ExitCode::OK;
} | [
"public",
"function",
"actionRun",
"(",
")",
"{",
"$",
"crontab",
"=",
"Task",
"::",
"findAll",
"(",
"[",
"'switch'",
"=>",
"Task",
"::",
"SWITCH_ACTIVE",
"]",
")",
";",
"$",
"tasks",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"crontab",
"as",
"$",
"task",
")",
"{",
"// 第一次运行,先计算下次运行时间",
"if",
"(",
"!",
"$",
"task",
"->",
"next_rundate",
")",
"{",
"$",
"task",
"->",
"next_rundate",
"=",
"$",
"task",
"->",
"getNextRunDate",
"(",
")",
";",
"$",
"task",
"->",
"save",
"(",
"false",
")",
";",
"continue",
";",
"}",
"// 判断运行时间到了没",
"if",
"(",
"$",
"task",
"->",
"next_rundate",
"<=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
")",
"{",
"$",
"tasks",
"[",
"]",
"=",
"$",
"task",
";",
"}",
"}",
"$",
"this",
"->",
"executeTask",
"(",
"$",
"tasks",
")",
";",
"return",
"ExitCode",
"::",
"OK",
";",
"}"
] | 定时任务入口
@return int Exit code | [
"定时任务入口"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/console/controllers/TaskController.php#L31-L51 |
yuncms/framework | src/console/controllers/TaskController.php | TaskController.getCurrentTime | private function getCurrentTime()
{
list ($msec, $sec) = explode(" ", microtime());
return (float)$msec + (float)$sec;
} | php | private function getCurrentTime()
{
list ($msec, $sec) = explode(" ", microtime());
return (float)$msec + (float)$sec;
} | [
"private",
"function",
"getCurrentTime",
"(",
")",
"{",
"list",
"(",
"$",
"msec",
",",
"$",
"sec",
")",
"=",
"explode",
"(",
"\" \"",
",",
"microtime",
"(",
")",
")",
";",
"return",
"(",
"float",
")",
"$",
"msec",
"+",
"(",
"float",
")",
"$",
"sec",
";",
"}"
] | 获取当前时间
@return float | [
"获取当前时间"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/console/controllers/TaskController.php#L94-L98 |
photogabble/laravel-remember-uploads | src/ViewComposers/RememberedFilesComposer.php | RememberedFilesComposer.compose | public function compose(View $view)
{
/** @var RememberedFileBag $rememberedFiles */
$rememberedFiles = $this->session->get('_remembered_files', new RememberedFileBag());
$view->with('rememberedFiles', $rememberedFiles->toFileBag());
} | php | public function compose(View $view)
{
/** @var RememberedFileBag $rememberedFiles */
$rememberedFiles = $this->session->get('_remembered_files', new RememberedFileBag());
$view->with('rememberedFiles', $rememberedFiles->toFileBag());
} | [
"public",
"function",
"compose",
"(",
"View",
"$",
"view",
")",
"{",
"/** @var RememberedFileBag $rememberedFiles */",
"$",
"rememberedFiles",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"'_remembered_files'",
",",
"new",
"RememberedFileBag",
"(",
")",
")",
";",
"$",
"view",
"->",
"with",
"(",
"'rememberedFiles'",
",",
"$",
"rememberedFiles",
"->",
"toFileBag",
"(",
")",
")",
";",
"}"
] | Bind data to the view.
@param View $view
@return void | [
"Bind",
"data",
"to",
"the",
"view",
"."
] | train | https://github.com/photogabble/laravel-remember-uploads/blob/28d0667d2de74e5cd4f1980920df828cc5f99514/src/ViewComposers/RememberedFilesComposer.php#L33-L38 |
askupasoftware/amarkal | Extensions/WordPress/Plugin/AbstractPlugin.php | AbstractPlugin.register_hooks | private function register_hooks()
{
register_activation_hook(
$this->plugin_file,
get_called_class().'::activate'
);
register_deactivation_hook(
$this->plugin_file,
get_called_class().'::deactivate'
);
register_uninstall_hook(
$this->plugin_file,
get_called_class().'::uninstall'
);
} | php | private function register_hooks()
{
register_activation_hook(
$this->plugin_file,
get_called_class().'::activate'
);
register_deactivation_hook(
$this->plugin_file,
get_called_class().'::deactivate'
);
register_uninstall_hook(
$this->plugin_file,
get_called_class().'::uninstall'
);
} | [
"private",
"function",
"register_hooks",
"(",
")",
"{",
"register_activation_hook",
"(",
"$",
"this",
"->",
"plugin_file",
",",
"get_called_class",
"(",
")",
".",
"'::activate'",
")",
";",
"register_deactivation_hook",
"(",
"$",
"this",
"->",
"plugin_file",
",",
"get_called_class",
"(",
")",
".",
"'::deactivate'",
")",
";",
"register_uninstall_hook",
"(",
"$",
"this",
"->",
"plugin_file",
",",
"get_called_class",
"(",
")",
".",
"'::uninstall'",
")",
";",
"}"
] | Register hooks that are fired when the plugin is activated,
deactivated, and uninstalled, respectively. The array's first
argument is the name of the plugin defined in `class-plugin-name.php` | [
"Register",
"hooks",
"that",
"are",
"fired",
"when",
"the",
"plugin",
"is",
"activated",
"deactivated",
"and",
"uninstalled",
"respectively",
".",
"The",
"array",
"s",
"first",
"argument",
"is",
"the",
"name",
"of",
"the",
"plugin",
"defined",
"in",
"class",
"-",
"plugin",
"-",
"name",
".",
"php"
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Plugin/AbstractPlugin.php#L33-L49 |
yuncms/framework | src/behaviors/UUIDBehavior.php | UUIDBehavior.init | public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->attribute];
}
} | php | public function init()
{
parent::init();
if (empty($this->attributes)) {
$this->attributes = [BaseActiveRecord::EVENT_BEFORE_VALIDATE => $this->attribute];
}
} | [
"public",
"function",
"init",
"(",
")",
"{",
"parent",
"::",
"init",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"[",
"BaseActiveRecord",
"::",
"EVENT_BEFORE_VALIDATE",
"=>",
"$",
"this",
"->",
"attribute",
"]",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/UUIDBehavior.php#L80-L86 |
yuncms/framework | src/behaviors/UUIDBehavior.php | UUIDBehavior.getValue | protected function getValue($event)
{
if (!empty($this->owner->{$this->attribute})) {
return $this->owner->{$this->attribute};
}
if ($this->value === null) {
$uuid = $this->generateUUID();
} else {
$uuid = parent::getValue($event);
}
return $this->ensureUnique ? $this->makeUnique($uuid) : $uuid;
} | php | protected function getValue($event)
{
if (!empty($this->owner->{$this->attribute})) {
return $this->owner->{$this->attribute};
}
if ($this->value === null) {
$uuid = $this->generateUUID();
} else {
$uuid = parent::getValue($event);
}
return $this->ensureUnique ? $this->makeUnique($uuid) : $uuid;
} | [
"protected",
"function",
"getValue",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"this",
"->",
"attribute",
"}",
")",
")",
"{",
"return",
"$",
"this",
"->",
"owner",
"->",
"{",
"$",
"this",
"->",
"attribute",
"}",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"value",
"===",
"null",
")",
"{",
"$",
"uuid",
"=",
"$",
"this",
"->",
"generateUUID",
"(",
")",
";",
"}",
"else",
"{",
"$",
"uuid",
"=",
"parent",
"::",
"getValue",
"(",
"$",
"event",
")",
";",
"}",
"return",
"$",
"this",
"->",
"ensureUnique",
"?",
"$",
"this",
"->",
"makeUnique",
"(",
"$",
"uuid",
")",
":",
"$",
"uuid",
";",
"}"
] | {@inheritdoc}
@throws \Exception | [
"{"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/UUIDBehavior.php#L92-L103 |
yuncms/framework | src/behaviors/UUIDBehavior.php | UUIDBehavior.makeUnique | protected function makeUnique($uuid): string
{
$uniqueUUID = $uuid;
$iteration = 0;
while (!$this->validateUUID($uniqueUUID)) {
$iteration++;
$uniqueUUID = $this->generateUUID();
}
return $uniqueUUID;
} | php | protected function makeUnique($uuid): string
{
$uniqueUUID = $uuid;
$iteration = 0;
while (!$this->validateUUID($uniqueUUID)) {
$iteration++;
$uniqueUUID = $this->generateUUID();
}
return $uniqueUUID;
} | [
"protected",
"function",
"makeUnique",
"(",
"$",
"uuid",
")",
":",
"string",
"{",
"$",
"uniqueUUID",
"=",
"$",
"uuid",
";",
"$",
"iteration",
"=",
"0",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"validateUUID",
"(",
"$",
"uniqueUUID",
")",
")",
"{",
"$",
"iteration",
"++",
";",
"$",
"uniqueUUID",
"=",
"$",
"this",
"->",
"generateUUID",
"(",
")",
";",
"}",
"return",
"$",
"uniqueUUID",
";",
"}"
] | This method is called by [[getValue]] when [[ensureUnique]] is true to generate the unique uuid.
@param string $uuid
@return string unique uuid
@throws InvalidConfigException
@throws \Exception
@see getValue | [
"This",
"method",
"is",
"called",
"by",
"[[",
"getValue",
"]]",
"when",
"[[",
"ensureUnique",
"]]",
"is",
"true",
"to",
"generate",
"the",
"unique",
"uuid",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/UUIDBehavior.php#L124-L133 |
yuncms/framework | src/behaviors/UUIDBehavior.php | UUIDBehavior.validateUUID | protected function validateUUID($uuid)
{
/* @var $validator UniqueValidator */
/* @var $model BaseActiveRecord */
$validator = Yii::createObject(array_merge([
'class' => UniqueValidator::class,
], $this->uniqueValidator));
$model = clone $this->owner;
$model->clearErrors();
$model->{$this->attribute} = $uuid;
$validator->validateAttribute($model, $this->attribute);
return !$model->hasErrors();
} | php | protected function validateUUID($uuid)
{
/* @var $validator UniqueValidator */
/* @var $model BaseActiveRecord */
$validator = Yii::createObject(array_merge([
'class' => UniqueValidator::class,
], $this->uniqueValidator));
$model = clone $this->owner;
$model->clearErrors();
$model->{$this->attribute} = $uuid;
$validator->validateAttribute($model, $this->attribute);
return !$model->hasErrors();
} | [
"protected",
"function",
"validateUUID",
"(",
"$",
"uuid",
")",
"{",
"/* @var $validator UniqueValidator */",
"/* @var $model BaseActiveRecord */",
"$",
"validator",
"=",
"Yii",
"::",
"createObject",
"(",
"array_merge",
"(",
"[",
"'class'",
"=>",
"UniqueValidator",
"::",
"class",
",",
"]",
",",
"$",
"this",
"->",
"uniqueValidator",
")",
")",
";",
"$",
"model",
"=",
"clone",
"$",
"this",
"->",
"owner",
";",
"$",
"model",
"->",
"clearErrors",
"(",
")",
";",
"$",
"model",
"->",
"{",
"$",
"this",
"->",
"attribute",
"}",
"=",
"$",
"uuid",
";",
"$",
"validator",
"->",
"validateAttribute",
"(",
"$",
"model",
",",
"$",
"this",
"->",
"attribute",
")",
";",
"return",
"!",
"$",
"model",
"->",
"hasErrors",
"(",
")",
";",
"}"
] | Checks if given uuid value is unique.
@param string $uuid slug value
@return bool whether slug is unique.
@throws InvalidConfigException | [
"Checks",
"if",
"given",
"uuid",
"value",
"is",
"unique",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/UUIDBehavior.php#L141-L155 |
parsnick/steak | src/Source.php | Source.changeExtension | public function changeExtension($rename)
{
$search = '';
$replace = '';
if (is_array($rename)) {
$search = key($rename);
$replace = current($rename);
}
if (is_string($rename)) {
$search = pathinfo($this->outputPathname, PATHINFO_EXTENSION);
$replace = $rename;
}
$this->outputPathname = preg_replace("#$search\$#", $replace, $this->outputPathname);
return $this;
} | php | public function changeExtension($rename)
{
$search = '';
$replace = '';
if (is_array($rename)) {
$search = key($rename);
$replace = current($rename);
}
if (is_string($rename)) {
$search = pathinfo($this->outputPathname, PATHINFO_EXTENSION);
$replace = $rename;
}
$this->outputPathname = preg_replace("#$search\$#", $replace, $this->outputPathname);
return $this;
} | [
"public",
"function",
"changeExtension",
"(",
"$",
"rename",
")",
"{",
"$",
"search",
"=",
"''",
";",
"$",
"replace",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"rename",
")",
")",
"{",
"$",
"search",
"=",
"key",
"(",
"$",
"rename",
")",
";",
"$",
"replace",
"=",
"current",
"(",
"$",
"rename",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"rename",
")",
")",
"{",
"$",
"search",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"outputPathname",
",",
"PATHINFO_EXTENSION",
")",
";",
"$",
"replace",
"=",
"$",
"rename",
";",
"}",
"$",
"this",
"->",
"outputPathname",
"=",
"preg_replace",
"(",
"\"#$search\\$#\"",
",",
"$",
"replace",
",",
"$",
"this",
"->",
"outputPathname",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Change the extension of the output pathname.
@param array|string|null $rename
@return $this | [
"Change",
"the",
"extension",
"of",
"the",
"output",
"pathname",
"."
] | train | https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Source.php#L33-L51 |
symfony-bundle/bootstrap-bundle | src/Anezi/Bundle/BootstrapBundle/Command/BootstrapExtraAssetsInstallCommand.php | BootstrapExtraAssetsInstallCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$targetArg = rtrim($input->getArgument('target'), '/');
if (!is_dir($targetArg)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
}
/** @var Filesystem $filesystem */
$filesystem = $this->getContainer()->get('filesystem');
// Create the bundles directory otherwise symlink will fail.
$bundlesDir = $targetArg . '/bundles/';
$filesystem->mkdir($bundlesDir, 0777);
$output->writeln(
'Installing Bootstrap assets.'
);
$targetDir = $bundlesDir . 'bootstrap-extra';
$namespaceParts = explode('\\', __NAMESPACE__);
array_pop($namespaceParts);
$output->writeln(
sprintf(
'Installing assets for <comment>%s</comment> into <comment>%s</comment>',
implode('\\', $namespaceParts),
$targetDir
)
);
$filesystem->remove($targetDir);
$filesystem->mkdir($targetDir, 0777);
$filesystem->mkdir($targetDir . '/css', 0777);
$vendor = 'vendor';
$filesystem->mirror(
$vendor . '/twbs/bootstrap/dist',
$targetDir
);
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$targetArg = rtrim($input->getArgument('target'), '/');
if (!is_dir($targetArg)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
}
/** @var Filesystem $filesystem */
$filesystem = $this->getContainer()->get('filesystem');
// Create the bundles directory otherwise symlink will fail.
$bundlesDir = $targetArg . '/bundles/';
$filesystem->mkdir($bundlesDir, 0777);
$output->writeln(
'Installing Bootstrap assets.'
);
$targetDir = $bundlesDir . 'bootstrap-extra';
$namespaceParts = explode('\\', __NAMESPACE__);
array_pop($namespaceParts);
$output->writeln(
sprintf(
'Installing assets for <comment>%s</comment> into <comment>%s</comment>',
implode('\\', $namespaceParts),
$targetDir
)
);
$filesystem->remove($targetDir);
$filesystem->mkdir($targetDir, 0777);
$filesystem->mkdir($targetDir . '/css', 0777);
$vendor = 'vendor';
$filesystem->mirror(
$vendor . '/twbs/bootstrap/dist',
$targetDir
);
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"targetArg",
"=",
"rtrim",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'target'",
")",
",",
"'/'",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"targetArg",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The target directory \"%s\" does not exist.'",
",",
"$",
"input",
"->",
"getArgument",
"(",
"'target'",
")",
")",
")",
";",
"}",
"/** @var Filesystem $filesystem */",
"$",
"filesystem",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'filesystem'",
")",
";",
"// Create the bundles directory otherwise symlink will fail.",
"$",
"bundlesDir",
"=",
"$",
"targetArg",
".",
"'/bundles/'",
";",
"$",
"filesystem",
"->",
"mkdir",
"(",
"$",
"bundlesDir",
",",
"0777",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"'Installing Bootstrap assets.'",
")",
";",
"$",
"targetDir",
"=",
"$",
"bundlesDir",
".",
"'bootstrap-extra'",
";",
"$",
"namespaceParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"__NAMESPACE__",
")",
";",
"array_pop",
"(",
"$",
"namespaceParts",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'Installing assets for <comment>%s</comment> into <comment>%s</comment>'",
",",
"implode",
"(",
"'\\\\'",
",",
"$",
"namespaceParts",
")",
",",
"$",
"targetDir",
")",
")",
";",
"$",
"filesystem",
"->",
"remove",
"(",
"$",
"targetDir",
")",
";",
"$",
"filesystem",
"->",
"mkdir",
"(",
"$",
"targetDir",
",",
"0777",
")",
";",
"$",
"filesystem",
"->",
"mkdir",
"(",
"$",
"targetDir",
".",
"'/css'",
",",
"0777",
")",
";",
"$",
"vendor",
"=",
"'vendor'",
";",
"$",
"filesystem",
"->",
"mirror",
"(",
"$",
"vendor",
".",
"'/twbs/bootstrap/dist'",
",",
"$",
"targetDir",
")",
";",
"}"
] | {@inheritdoc}
@throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/symfony-bundle/bootstrap-bundle/blob/b4e3f10f0ae2ebcea7636234c5c01771746dd81c/src/Anezi/Bundle/BootstrapBundle/Command/BootstrapExtraAssetsInstallCommand.php#L42-L85 |
arsengoian/viper-framework | src/Viper/Core/Model/Traits/Depictable.php | Depictable.setImg | final public function setImg(array $picture_arr, string $address) {
$this -> set("img", self::registerImg($picture_arr, $address));
} | php | final public function setImg(array $picture_arr, string $address) {
$this -> set("img", self::registerImg($picture_arr, $address));
} | [
"final",
"public",
"function",
"setImg",
"(",
"array",
"$",
"picture_arr",
",",
"string",
"$",
"address",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"\"img\"",
",",
"self",
"::",
"registerImg",
"(",
"$",
"picture_arr",
",",
"$",
"address",
")",
")",
";",
"}"
] | TODO add parameters | [
"TODO",
"add",
"parameters"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Core/Model/Traits/Depictable.php#L15-L17 |
arsengoian/viper-framework | src/Viper/Core/Model/Traits/Depictable.php | Depictable.cropimage | final public static function cropimage(string $address) {
$w = getimagesize($address)[0];
$h = getimagesize($address)[1];
if ($w == $h)
return;
$img = WideImage::load($address);
if ($w > $h)
$cr = $img -> crop(floor(($w - $h)/2), 0, $h, $h);
else $cr = $img -> crop(0, floor(($h - $w)/2), $w, $w);
$cr -> saveToFile($address);
} | php | final public static function cropimage(string $address) {
$w = getimagesize($address)[0];
$h = getimagesize($address)[1];
if ($w == $h)
return;
$img = WideImage::load($address);
if ($w > $h)
$cr = $img -> crop(floor(($w - $h)/2), 0, $h, $h);
else $cr = $img -> crop(0, floor(($h - $w)/2), $w, $w);
$cr -> saveToFile($address);
} | [
"final",
"public",
"static",
"function",
"cropimage",
"(",
"string",
"$",
"address",
")",
"{",
"$",
"w",
"=",
"getimagesize",
"(",
"$",
"address",
")",
"[",
"0",
"]",
";",
"$",
"h",
"=",
"getimagesize",
"(",
"$",
"address",
")",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"w",
"==",
"$",
"h",
")",
"return",
";",
"$",
"img",
"=",
"WideImage",
"::",
"load",
"(",
"$",
"address",
")",
";",
"if",
"(",
"$",
"w",
">",
"$",
"h",
")",
"$",
"cr",
"=",
"$",
"img",
"->",
"crop",
"(",
"floor",
"(",
"(",
"$",
"w",
"-",
"$",
"h",
")",
"/",
"2",
")",
",",
"0",
",",
"$",
"h",
",",
"$",
"h",
")",
";",
"else",
"$",
"cr",
"=",
"$",
"img",
"->",
"crop",
"(",
"0",
",",
"floor",
"(",
"(",
"$",
"h",
"-",
"$",
"w",
")",
"/",
"2",
")",
",",
"$",
"w",
",",
"$",
"w",
")",
";",
"$",
"cr",
"->",
"saveToFile",
"(",
"$",
"address",
")",
";",
"}"
] | TODO add proportions | [
"TODO",
"add",
"proportions"
] | train | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Core/Model/Traits/Depictable.php#L68-L84 |
mihai-stancu/serializer | Serializer/Encoder/YamlEncoder.php | YamlEncoder.encode | public function encode($data, $format, array $context = array())
{
if ($this->native) {
return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
}
return $this->encoder->dump($data);
} | php | public function encode($data, $format, array $context = array())
{
if ($this->native) {
return yaml_emit($data, YAML_UTF8_ENCODING, YAML_LN_BREAK);
}
return $this->encoder->dump($data);
} | [
"public",
"function",
"encode",
"(",
"$",
"data",
",",
"$",
"format",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"native",
")",
"{",
"return",
"yaml_emit",
"(",
"$",
"data",
",",
"YAML_UTF8_ENCODING",
",",
"YAML_LN_BREAK",
")",
";",
"}",
"return",
"$",
"this",
"->",
"encoder",
"->",
"dump",
"(",
"$",
"data",
")",
";",
"}"
] | @param mixed $data
@param string $format
@param array $context
@return string | [
"@param",
"mixed",
"$data",
"@param",
"string",
"$format",
"@param",
"array",
"$context"
] | train | https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Encoder/YamlEncoder.php#L62-L69 |
mihai-stancu/serializer | Serializer/Encoder/YamlEncoder.php | YamlEncoder.decode | public function decode($data, $format, array $context = array())
{
if ($this->native) {
return yaml_parse($data);
}
return $this->decoder->parse($data);
} | php | public function decode($data, $format, array $context = array())
{
if ($this->native) {
return yaml_parse($data);
}
return $this->decoder->parse($data);
} | [
"public",
"function",
"decode",
"(",
"$",
"data",
",",
"$",
"format",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"native",
")",
"{",
"return",
"yaml_parse",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"this",
"->",
"decoder",
"->",
"parse",
"(",
"$",
"data",
")",
";",
"}"
] | @param string $data
@param string $format
@param array $context
@return mixed | [
"@param",
"string",
"$data",
"@param",
"string",
"$format",
"@param",
"array",
"$context"
] | train | https://github.com/mihai-stancu/serializer/blob/4d96f942a3c44d5b5652868be726af656bf1baad/Serializer/Encoder/YamlEncoder.php#L78-L85 |
aedart/laravel-helpers | src/Traits/Auth/PasswordBrokerManagerTrait.php | PasswordBrokerManagerTrait.getPasswordBrokerManager | public function getPasswordBrokerManager(): ?PasswordBrokerManager
{
if (!$this->hasPasswordBrokerManager()) {
$this->setPasswordBrokerManager($this->getDefaultPasswordBrokerManager());
}
return $this->passwordBrokerManager;
} | php | public function getPasswordBrokerManager(): ?PasswordBrokerManager
{
if (!$this->hasPasswordBrokerManager()) {
$this->setPasswordBrokerManager($this->getDefaultPasswordBrokerManager());
}
return $this->passwordBrokerManager;
} | [
"public",
"function",
"getPasswordBrokerManager",
"(",
")",
":",
"?",
"PasswordBrokerManager",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasPasswordBrokerManager",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setPasswordBrokerManager",
"(",
"$",
"this",
"->",
"getDefaultPasswordBrokerManager",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"passwordBrokerManager",
";",
"}"
] | Get password broker manager
If no password broker manager has been set, this method will
set and return a default password broker manager, if any such
value is available
@see getDefaultPasswordBrokerManager()
@return PasswordBrokerManager|null password broker manager or null if none password broker manager has been set | [
"Get",
"password",
"broker",
"manager"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Auth/PasswordBrokerManagerTrait.php#L53-L59 |
VincentChalnot/SidusAdminBundle | Action/DeleteAction.php | DeleteAction.applyAction | protected function applyAction(Request $request, FormInterface $form, $data): Response
{
$this->doctrineHelper->deleteEntity($this->action, $data, $request->getSession());
return $this->routingHelper->redirectToAction(
$this->action->getAdmin()->getAction(
$this->action->getOption('redirect_action', 'list')
)
);
} | php | protected function applyAction(Request $request, FormInterface $form, $data): Response
{
$this->doctrineHelper->deleteEntity($this->action, $data, $request->getSession());
return $this->routingHelper->redirectToAction(
$this->action->getAdmin()->getAction(
$this->action->getOption('redirect_action', 'list')
)
);
} | [
"protected",
"function",
"applyAction",
"(",
"Request",
"$",
"request",
",",
"FormInterface",
"$",
"form",
",",
"$",
"data",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"doctrineHelper",
"->",
"deleteEntity",
"(",
"$",
"this",
"->",
"action",
",",
"$",
"data",
",",
"$",
"request",
"->",
"getSession",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"routingHelper",
"->",
"redirectToAction",
"(",
"$",
"this",
"->",
"action",
"->",
"getAdmin",
"(",
")",
"->",
"getAction",
"(",
"$",
"this",
"->",
"action",
"->",
"getOption",
"(",
"'redirect_action'",
",",
"'list'",
")",
")",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/VincentChalnot/SidusAdminBundle/blob/3366f3f1525435860cf275ed2f1f0b58cf6eea18/Action/DeleteAction.php#L45-L54 |
krzysztofmazur/php-object-mapper | src/KrzysztofMazur/ObjectMapper/Mapping/Field/ValueWriter/AbstractValueWriter.php | AbstractValueWriter.write | public function write($object, $value)
{
if ($object === null) {
throw new \InvalidArgumentException("Unexpected null value");
}
$reference = $object;
if ($this->valueReader !== null) {
$reference = $this->valueReader->read($reference);
}
$this->writeValue($reference, $value);
} | php | public function write($object, $value)
{
if ($object === null) {
throw new \InvalidArgumentException("Unexpected null value");
}
$reference = $object;
if ($this->valueReader !== null) {
$reference = $this->valueReader->read($reference);
}
$this->writeValue($reference, $value);
} | [
"public",
"function",
"write",
"(",
"$",
"object",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unexpected null value\"",
")",
";",
"}",
"$",
"reference",
"=",
"$",
"object",
";",
"if",
"(",
"$",
"this",
"->",
"valueReader",
"!==",
"null",
")",
"{",
"$",
"reference",
"=",
"$",
"this",
"->",
"valueReader",
"->",
"read",
"(",
"$",
"reference",
")",
";",
"}",
"$",
"this",
"->",
"writeValue",
"(",
"$",
"reference",
",",
"$",
"value",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Mapping/Field/ValueWriter/AbstractValueWriter.php#L42-L53 |
tylerjuniorcollege/slim-layout | src/Asset/Container.php | Container.insertAsset | public function insertAsset(AssetAbstract $asset, $location) {
array_splice($this->assets, $location, 0, array($asset));
return $this;
} | php | public function insertAsset(AssetAbstract $asset, $location) {
array_splice($this->assets, $location, 0, array($asset));
return $this;
} | [
"public",
"function",
"insertAsset",
"(",
"AssetAbstract",
"$",
"asset",
",",
"$",
"location",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"assets",
",",
"$",
"location",
",",
"0",
",",
"array",
"(",
"$",
"asset",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | This will insert an asset in to a specific location in the array and then shift the element keys. | [
"This",
"will",
"insert",
"an",
"asset",
"in",
"to",
"a",
"specific",
"location",
"in",
"the",
"array",
"and",
"then",
"shift",
"the",
"element",
"keys",
"."
] | train | https://github.com/tylerjuniorcollege/slim-layout/blob/60939b9f7502b90bf319fe741a747dd40ef61bfe/src/Asset/Container.php#L30-L33 |
phpmob/changmin | src/PhpMob/CoreBundle/Context/UserSettingContext.php | UserSettingContext.get | public function get($path)
{
return $this->settingManager->get($path, $this->tokenStorage->getToken()->getUsername());
} | php | public function get($path)
{
return $this->settingManager->get($path, $this->tokenStorage->getToken()->getUsername());
} | [
"public",
"function",
"get",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"settingManager",
"->",
"get",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
"->",
"getUsername",
"(",
")",
")",
";",
"}"
] | @param string $path eg. section.key
@return mixed | [
"@param",
"string",
"$path",
"eg",
".",
"section",
".",
"key"
] | train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/Context/UserSettingContext.php#L49-L52 |
factorio-item-browser/export-data | src/Entity/Mod/Dependency.php | Dependency.writeData | public function writeData(): array
{
$dataBuilder = new DataBuilder();
$dataBuilder->setString('m', $this->requiredModName, '')
->setString('v', $this->requiredVersion, '')
->setInteger('r', $this->isMandatory ? 1 : 0, 0);
return $dataBuilder->getData();
} | php | public function writeData(): array
{
$dataBuilder = new DataBuilder();
$dataBuilder->setString('m', $this->requiredModName, '')
->setString('v', $this->requiredVersion, '')
->setInteger('r', $this->isMandatory ? 1 : 0, 0);
return $dataBuilder->getData();
} | [
"public",
"function",
"writeData",
"(",
")",
":",
"array",
"{",
"$",
"dataBuilder",
"=",
"new",
"DataBuilder",
"(",
")",
";",
"$",
"dataBuilder",
"->",
"setString",
"(",
"'m'",
",",
"$",
"this",
"->",
"requiredModName",
",",
"''",
")",
"->",
"setString",
"(",
"'v'",
",",
"$",
"this",
"->",
"requiredVersion",
",",
"''",
")",
"->",
"setInteger",
"(",
"'r'",
",",
"$",
"this",
"->",
"isMandatory",
"?",
"1",
":",
"0",
",",
"0",
")",
";",
"return",
"$",
"dataBuilder",
"->",
"getData",
"(",
")",
";",
"}"
] | Writes the entity data to an array.
@return array | [
"Writes",
"the",
"entity",
"data",
"to",
"an",
"array",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Mod/Dependency.php#L102-L109 |
factorio-item-browser/export-data | src/Entity/Mod/Dependency.php | Dependency.readData | public function readData(DataContainer $data)
{
$this->requiredModName = $data->getString('m', '');
$this->requiredVersion = $data->getString('v', '');
$this->isMandatory = $data->getInteger('r', 0) === 1;
return $this;
} | php | public function readData(DataContainer $data)
{
$this->requiredModName = $data->getString('m', '');
$this->requiredVersion = $data->getString('v', '');
$this->isMandatory = $data->getInteger('r', 0) === 1;
return $this;
} | [
"public",
"function",
"readData",
"(",
"DataContainer",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"requiredModName",
"=",
"$",
"data",
"->",
"getString",
"(",
"'m'",
",",
"''",
")",
";",
"$",
"this",
"->",
"requiredVersion",
"=",
"$",
"data",
"->",
"getString",
"(",
"'v'",
",",
"''",
")",
";",
"$",
"this",
"->",
"isMandatory",
"=",
"$",
"data",
"->",
"getInteger",
"(",
"'r'",
",",
"0",
")",
"===",
"1",
";",
"return",
"$",
"this",
";",
"}"
] | Reads the entity data.
@param DataContainer $data
@return $this | [
"Reads",
"the",
"entity",
"data",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Mod/Dependency.php#L116-L122 |
factorio-item-browser/export-data | src/Entity/Mod/Dependency.php | Dependency.calculateHash | public function calculateHash(): string
{
return EntityUtils::calculateHashOfArray([
$this->requiredModName,
$this->requiredVersion,
$this->isMandatory,
]);
} | php | public function calculateHash(): string
{
return EntityUtils::calculateHashOfArray([
$this->requiredModName,
$this->requiredVersion,
$this->isMandatory,
]);
} | [
"public",
"function",
"calculateHash",
"(",
")",
":",
"string",
"{",
"return",
"EntityUtils",
"::",
"calculateHashOfArray",
"(",
"[",
"$",
"this",
"->",
"requiredModName",
",",
"$",
"this",
"->",
"requiredVersion",
",",
"$",
"this",
"->",
"isMandatory",
",",
"]",
")",
";",
"}"
] | Calculates a hash value representing the entity.
@return string | [
"Calculates",
"a",
"hash",
"value",
"representing",
"the",
"entity",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Mod/Dependency.php#L128-L135 |
yuncms/framework | src/notifications/Notification.php | Notification.getContent | public function getContent()
{
$params = $this->getData();
$p = [];
foreach ($params as $name => $value) {
$p['{' . $name . '}'] = $value;
}
return strtr($this->getTemplate(), $p);
} | php | public function getContent()
{
$params = $this->getData();
$p = [];
foreach ($params as $name => $value) {
$p['{' . $name . '}'] = $value;
}
return strtr($this->getTemplate(), $p);
} | [
"public",
"function",
"getContent",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"$",
"p",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"p",
"[",
"'{'",
".",
"$",
"name",
".",
"'}'",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"strtr",
"(",
"$",
"this",
"->",
"getTemplate",
"(",
")",
",",
"$",
"p",
")",
";",
"}"
] | 获取详细内容
@return string | [
"获取详细内容"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/Notification.php#L89-L97 |
yuncms/framework | src/notifications/Notification.php | Notification.toCloudPush | public function toCloudPush()
{
return Yii::createObject([
'class' => CloudPushMessage::class,
'title' => $this->getTitle(),
'content' => $this->getContent(),
'extParameters' => $this->getData()
]);
} | php | public function toCloudPush()
{
return Yii::createObject([
'class' => CloudPushMessage::class,
'title' => $this->getTitle(),
'content' => $this->getContent(),
'extParameters' => $this->getData()
]);
} | [
"public",
"function",
"toCloudPush",
"(",
")",
"{",
"return",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"CloudPushMessage",
"::",
"class",
",",
"'title'",
"=>",
"$",
"this",
"->",
"getTitle",
"(",
")",
",",
"'content'",
"=>",
"$",
"this",
"->",
"getContent",
"(",
")",
",",
"'extParameters'",
"=>",
"$",
"this",
"->",
"getData",
"(",
")",
"]",
")",
";",
"}"
] | 推送到CloudPush 渠道
@return CloudPushMessage
@throws \yii\base\InvalidConfigException | [
"推送到CloudPush",
"渠道"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/Notification.php#L126-L134 |
yuncms/framework | src/rest/models/AvatarForm.php | AvatarForm.save | public function save()
{
if ($this->validate()) {
try {
if (AvatarHelper::save($this->getUser(), $this->_originalImage)) {
$this->file = null;
$this->faceUrl = AvatarHelper::getAvatar($this->getUser());
return true;
} else {
return false;
}
} catch (ErrorException $e) {
$this->addError('file', $e->getMessage());
} catch (\Exception $e) {
$this->addError('file', $e->getMessage());
}
}
return false;
} | php | public function save()
{
if ($this->validate()) {
try {
if (AvatarHelper::save($this->getUser(), $this->_originalImage)) {
$this->file = null;
$this->faceUrl = AvatarHelper::getAvatar($this->getUser());
return true;
} else {
return false;
}
} catch (ErrorException $e) {
$this->addError('file', $e->getMessage());
} catch (\Exception $e) {
$this->addError('file', $e->getMessage());
}
}
return false;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"try",
"{",
"if",
"(",
"AvatarHelper",
"::",
"save",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
",",
"$",
"this",
"->",
"_originalImage",
")",
")",
"{",
"$",
"this",
"->",
"file",
"=",
"null",
";",
"$",
"this",
"->",
"faceUrl",
"=",
"AvatarHelper",
"::",
"getAvatar",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"ErrorException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'file'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'file'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | 保存头像
@return boolean | [
"保存头像"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/models/AvatarForm.php#L60-L78 |
yuncms/framework | src/rest/models/AvatarForm.php | AvatarForm.afterValidate | public function afterValidate()
{
//保存原图
if (($this->_originalImage = $this->file->saveAsTempFile()) == false) {
$this->addError('file', Yii::t('yuncms', 'Failed to save the image.'));
}
parent::afterValidate();
} | php | public function afterValidate()
{
//保存原图
if (($this->_originalImage = $this->file->saveAsTempFile()) == false) {
$this->addError('file', Yii::t('yuncms', 'Failed to save the image.'));
}
parent::afterValidate();
} | [
"public",
"function",
"afterValidate",
"(",
")",
"{",
"//保存原图",
"if",
"(",
"(",
"$",
"this",
"->",
"_originalImage",
"=",
"$",
"this",
"->",
"file",
"->",
"saveAsTempFile",
"(",
")",
")",
"==",
"false",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"'file'",
",",
"Yii",
"::",
"t",
"(",
"'yuncms'",
",",
"'Failed to save the image.'",
")",
")",
";",
"}",
"parent",
"::",
"afterValidate",
"(",
")",
";",
"}"
] | 验证后保存原图
@throws \yii\base\Exception | [
"验证后保存原图"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/rest/models/AvatarForm.php#L90-L97 |
webforge-labs/psc-cms | lib/Psc/PHPExcel/RangeReadFilter.php | RangeReadFilter.readCell | public function readCell($column, $row, $worksheetName = '') {
return ($row >= $this->firstRow && $row <= $this->lastRow &&
array_key_exists($column, $this->range));
} | php | public function readCell($column, $row, $worksheetName = '') {
return ($row >= $this->firstRow && $row <= $this->lastRow &&
array_key_exists($column, $this->range));
} | [
"public",
"function",
"readCell",
"(",
"$",
"column",
",",
"$",
"row",
",",
"$",
"worksheetName",
"=",
"''",
")",
"{",
"return",
"(",
"$",
"row",
">=",
"$",
"this",
"->",
"firstRow",
"&&",
"$",
"row",
"<=",
"$",
"this",
"->",
"lastRow",
"&&",
"array_key_exists",
"(",
"$",
"column",
",",
"$",
"this",
"->",
"range",
")",
")",
";",
"}"
] | Should this cell be read?
@param $column String column index
@param $row Row index
@param $worksheetName Optional worksheet name
@return boolean | [
"Should",
"this",
"cell",
"be",
"read?"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/PHPExcel/RangeReadFilter.php#L51-L55 |
ruvents/ruwork-upload-bundle | Source/SourceResolver.php | SourceResolver.resolve | public function resolve($source): ResolvedSourceInterface
{
foreach ($this->handlers as $handler) {
if ($handler->supports($source)) {
return $this->createResolvedSource($source, $handler);
}
}
throw new \RuntimeException('No handler.');
} | php | public function resolve($source): ResolvedSourceInterface
{
foreach ($this->handlers as $handler) {
if ($handler->supports($source)) {
return $this->createResolvedSource($source, $handler);
}
}
throw new \RuntimeException('No handler.');
} | [
"public",
"function",
"resolve",
"(",
"$",
"source",
")",
":",
"ResolvedSourceInterface",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"supports",
"(",
"$",
"source",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createResolvedSource",
"(",
"$",
"source",
",",
"$",
"handler",
")",
";",
"}",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No handler.'",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Source/SourceResolver.php#L48-L57 |
orchestral/theme-installer | src/ThemeInstaller.php | ThemeInstaller.getInstallPath | public function getInstallPath(PackageInterface $package)
{
$name = $package->getExtra()['theme-name'] ?? null;
if (is_null($name)) {
[, $name] = $package->getPrettyName();
$name = str_replace('-theme', '', $name);
}
return 'public/themes/'.$name;
} | php | public function getInstallPath(PackageInterface $package)
{
$name = $package->getExtra()['theme-name'] ?? null;
if (is_null($name)) {
[, $name] = $package->getPrettyName();
$name = str_replace('-theme', '', $name);
}
return 'public/themes/'.$name;
} | [
"public",
"function",
"getInstallPath",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"name",
"=",
"$",
"package",
"->",
"getExtra",
"(",
")",
"[",
"'theme-name'",
"]",
"??",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"[",
",",
"$",
"name",
"]",
"=",
"$",
"package",
"->",
"getPrettyName",
"(",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"'-theme'",
",",
"''",
",",
"$",
"name",
")",
";",
"}",
"return",
"'public/themes/'",
".",
"$",
"name",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/orchestral/theme-installer/blob/ddc84f8f0c8993229a35e11786b42faa123d0b85/src/ThemeInstaller.php#L13-L24 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.select | public function select($mNameId, $aData, $mDefault = null, $sClass = null, $iTabindex = null, $bDisabled = false, $bMultiple = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<select name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $bMultiple ? ' multiple="multiple"' : '';
$res .= $sExtraHtml;
$res .= '>' . PHP_EOL;
$res .= self::selectOptions($aData, $mDefault);
$res .= '</select>' . PHP_EOL;
return $res;
} | php | public function select($mNameId, $aData, $mDefault = null, $sClass = null, $iTabindex = null, $bDisabled = false, $bMultiple = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<select name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $bMultiple ? ' multiple="multiple"' : '';
$res .= $sExtraHtml;
$res .= '>' . PHP_EOL;
$res .= self::selectOptions($aData, $mDefault);
$res .= '</select>' . PHP_EOL;
return $res;
} | [
"public",
"function",
"select",
"(",
"$",
"mNameId",
",",
"$",
"aData",
",",
"$",
"mDefault",
"=",
"null",
",",
"$",
"sClass",
"=",
"null",
",",
"$",
"iTabindex",
"=",
"null",
",",
"$",
"bDisabled",
"=",
"false",
",",
"$",
"bMultiple",
"=",
"false",
",",
"$",
"sExtraHtml",
"=",
"null",
")",
"{",
"self",
"::",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"$",
"sName",
",",
"$",
"sId",
")",
";",
"$",
"res",
"=",
"'<select name=\"'",
".",
"$",
"sName",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sId",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"sId",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sClass",
"?",
"''",
":",
"' class=\"'",
".",
"$",
"sClass",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iTabindex",
"?",
"''",
":",
"' tabindex=\"'",
".",
"$",
"iTabindex",
".",
"'\"'",
";",
"$",
"res",
".=",
"$",
"bDisabled",
"?",
"' disabled=\"disabled\"'",
":",
"''",
";",
"$",
"res",
".=",
"$",
"bMultiple",
"?",
"' multiple=\"multiple\"'",
":",
"''",
";",
"$",
"res",
".=",
"$",
"sExtraHtml",
";",
"$",
"res",
".=",
"'>'",
".",
"PHP_EOL",
";",
"$",
"res",
".=",
"self",
"::",
"selectOptions",
"(",
"$",
"aData",
",",
"$",
"mDefault",
")",
";",
"$",
"res",
".=",
"'</select>'",
".",
"PHP_EOL",
";",
"return",
"$",
"res",
";",
"}"
] | Retourne un champ de formulaire de type select.
@param mixed $mNameId Le nom et l'identifiant du champ
@param array $aData Le tableau contenant les lignes d'option du select
@param mixed $mDefault La valeur sélectionnée par défaut
@param string $sClass La classe CSS de l'élément
@param integer $iTabindex Le tabindex de l'élément
@param boolean $bDisabled Désactiver ou non le champ
@param boolean $bMultiple Choix multiple
@param string $sExtraHtml Du HTML en plus à mettre dans l'élément
@return string | [
"Retourne",
"un",
"champ",
"de",
"formulaire",
"de",
"type",
"select",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L21-L39 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.selectOptions | public function selectOptions($aData, $mDefault)
{
$res = '';
$option = '<option value="%1$s"%3$s>%2$s</option>' . PHP_EOL;
$optgroup = '<optgroup label="%1$s">' . PHP_EOL . '%2$s' . "</optgroup>\n";
foreach ($aData as $k => $v)
{
if (is_array($v)) {
$res .= sprintf($optgroup, $k, self::selectOptions($v, $mDefault));
}
elseif ($v instanceof SelectOption) {
$res .= $v->render($mDefault);
}
else
{
if (is_array($mDefault)) {
$s = in_array($v, $mDefault) ? ' selected="selected"' : '';
}
else {
$s = $v == $mDefault ? ' selected="selected"' : '';
}
$res .= sprintf($option, $v, $k, $s);
}
}
return $res;
} | php | public function selectOptions($aData, $mDefault)
{
$res = '';
$option = '<option value="%1$s"%3$s>%2$s</option>' . PHP_EOL;
$optgroup = '<optgroup label="%1$s">' . PHP_EOL . '%2$s' . "</optgroup>\n";
foreach ($aData as $k => $v)
{
if (is_array($v)) {
$res .= sprintf($optgroup, $k, self::selectOptions($v, $mDefault));
}
elseif ($v instanceof SelectOption) {
$res .= $v->render($mDefault);
}
else
{
if (is_array($mDefault)) {
$s = in_array($v, $mDefault) ? ' selected="selected"' : '';
}
else {
$s = $v == $mDefault ? ' selected="selected"' : '';
}
$res .= sprintf($option, $v, $k, $s);
}
}
return $res;
} | [
"public",
"function",
"selectOptions",
"(",
"$",
"aData",
",",
"$",
"mDefault",
")",
"{",
"$",
"res",
"=",
"''",
";",
"$",
"option",
"=",
"'<option value=\"%1$s\"%3$s>%2$s</option>'",
".",
"PHP_EOL",
";",
"$",
"optgroup",
"=",
"'<optgroup label=\"%1$s\">'",
".",
"PHP_EOL",
".",
"'%2$s'",
".",
"\"</optgroup>\\n\"",
";",
"foreach",
"(",
"$",
"aData",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"res",
".=",
"sprintf",
"(",
"$",
"optgroup",
",",
"$",
"k",
",",
"self",
"::",
"selectOptions",
"(",
"$",
"v",
",",
"$",
"mDefault",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"v",
"instanceof",
"SelectOption",
")",
"{",
"$",
"res",
".=",
"$",
"v",
"->",
"render",
"(",
"$",
"mDefault",
")",
";",
"}",
"else",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mDefault",
")",
")",
"{",
"$",
"s",
"=",
"in_array",
"(",
"$",
"v",
",",
"$",
"mDefault",
")",
"?",
"' selected=\"selected\"'",
":",
"''",
";",
"}",
"else",
"{",
"$",
"s",
"=",
"$",
"v",
"==",
"$",
"mDefault",
"?",
"' selected=\"selected\"'",
":",
"''",
";",
"}",
"$",
"res",
".=",
"sprintf",
"(",
"$",
"option",
",",
"$",
"v",
",",
"$",
"k",
",",
"$",
"s",
")",
";",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] | Retourne les options d'un élément select.
@param array $aData Le tableau contenant les lignes d'option du select
@param mixed $mDefault La valeur sélectionnée par défaut
@return string | [
"Retourne",
"les",
"options",
"d",
"un",
"élément",
"select",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L48-L76 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.checkbox | public function checkbox($mNameId, $value, $checked = '', $sClass = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="checkbox" name="' . $sName . '" value="' . $value . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= $checked ? ' checked="checked"' : '';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml;
$res .= '>' . PHP_EOL;
return $res;
} | php | public function checkbox($mNameId, $value, $checked = '', $sClass = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="checkbox" name="' . $sName . '" value="' . $value . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= $checked ? ' checked="checked"' : '';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml;
$res .= '>' . PHP_EOL;
return $res;
} | [
"public",
"function",
"checkbox",
"(",
"$",
"mNameId",
",",
"$",
"value",
",",
"$",
"checked",
"=",
"''",
",",
"$",
"sClass",
"=",
"null",
",",
"$",
"iTabindex",
"=",
"null",
",",
"$",
"bDisabled",
"=",
"false",
",",
"$",
"sExtraHtml",
"=",
"null",
")",
"{",
"self",
"::",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"$",
"sName",
",",
"$",
"sId",
")",
";",
"$",
"res",
"=",
"'<input type=\"checkbox\" name=\"'",
".",
"$",
"sName",
".",
"'\" value=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sId",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"sId",
".",
"'\"'",
";",
"$",
"res",
".=",
"$",
"checked",
"?",
"' checked=\"checked\"'",
":",
"''",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sClass",
"?",
"''",
":",
"' class=\"'",
".",
"$",
"sClass",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iTabindex",
"?",
"''",
":",
"' tabindex=\"'",
".",
"$",
"iTabindex",
".",
"'\"'",
";",
"$",
"res",
".=",
"$",
"bDisabled",
"?",
"' disabled=\"disabled\"'",
":",
"''",
";",
"$",
"res",
".=",
"$",
"sExtraHtml",
";",
"$",
"res",
".=",
"'>'",
".",
"PHP_EOL",
";",
"return",
"$",
"res",
";",
"}"
] | Retourne un champ de formulaire de type checkbox.
@param mixed $mNameId Le nom et l'identifiant du champ
@param mixed $value La valeur de l'élément
@param boolean $checked L'état par défaut de l'élément
@param string $sClass La classe CSS de l'élément
@param integer $iTabindex Le tabindex de l'élément
@param boolean $bDisabled Désactiver ou non le champ
@param string $sExtraHtml Du HTML en plus à mettre dans l'élément
@return string | [
"Retourne",
"un",
"champ",
"de",
"formulaire",
"de",
"type",
"checkbox",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L118-L132 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.text | public function text($mNameId, $size, $max = null, $sDefault = null, $sClass = null, $sPlaceholder = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="text" size="' . $size . '" name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $max ? '' : ' maxlength="' . $max . '"';
$res .= null === $sDefault ? '' : ' value="' . $sDefault . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $sPlaceholder ? '' : ' placeholder="' . $sPlaceholder . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml;
$res .= '>';
return $res;
} | php | public function text($mNameId, $size, $max = null, $sDefault = null, $sClass = null, $sPlaceholder = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="text" size="' . $size . '" name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $max ? '' : ' maxlength="' . $max . '"';
$res .= null === $sDefault ? '' : ' value="' . $sDefault . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $sPlaceholder ? '' : ' placeholder="' . $sPlaceholder . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml;
$res .= '>';
return $res;
} | [
"public",
"function",
"text",
"(",
"$",
"mNameId",
",",
"$",
"size",
",",
"$",
"max",
"=",
"null",
",",
"$",
"sDefault",
"=",
"null",
",",
"$",
"sClass",
"=",
"null",
",",
"$",
"sPlaceholder",
"=",
"null",
",",
"$",
"iTabindex",
"=",
"null",
",",
"$",
"bDisabled",
"=",
"false",
",",
"$",
"sExtraHtml",
"=",
"null",
")",
"{",
"self",
"::",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"$",
"sName",
",",
"$",
"sId",
")",
";",
"$",
"res",
"=",
"'<input type=\"text\" size=\"'",
".",
"$",
"size",
".",
"'\" name=\"'",
".",
"$",
"sName",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sId",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"sId",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"max",
"?",
"''",
":",
"' maxlength=\"'",
".",
"$",
"max",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sDefault",
"?",
"''",
":",
"' value=\"'",
".",
"$",
"sDefault",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sClass",
"?",
"''",
":",
"' class=\"'",
".",
"$",
"sClass",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sPlaceholder",
"?",
"''",
":",
"' placeholder=\"'",
".",
"$",
"sPlaceholder",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iTabindex",
"?",
"''",
":",
"' tabindex=\"'",
".",
"$",
"iTabindex",
".",
"'\"'",
";",
"$",
"res",
".=",
"$",
"bDisabled",
"?",
"' disabled=\"disabled\"'",
":",
"''",
";",
"$",
"res",
".=",
"$",
"sExtraHtml",
";",
"$",
"res",
".=",
"'>'",
";",
"return",
"$",
"res",
";",
"}"
] | Retourne un champ de formulaire de type text.
@param mixed $mNameId Le nom et l'identifiant du champ
@param integer $size La taille de l'élément en nombre de caractères
@param integer $max Le nombre maximum de caractères
@param string $sDefault La valeur par défaut de lélément
@param string $sClass La classe CSS de l'élément
@param string $sPlaceholder
@param integer $iTabindex Le tabindex de l'élément
@param boolean $bDisabled Désactiver ou non le champ
@param string $sExtraHtml Du HTML en plus à mettre dans l'élément
@return string | [
"Retourne",
"un",
"champ",
"de",
"formulaire",
"de",
"type",
"text",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L148-L164 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.file | public function file($mNameId, $sDefault = null, $sClass = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="file" name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $sDefault ? '' : ' value="' . $sDefault . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml;
$res .= ' />';
return $res;
} | php | public function file($mNameId, $sDefault = null, $sClass = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="file" name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $sDefault ? '' : ' value="' . $sDefault . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml;
$res .= ' />';
return $res;
} | [
"public",
"function",
"file",
"(",
"$",
"mNameId",
",",
"$",
"sDefault",
"=",
"null",
",",
"$",
"sClass",
"=",
"null",
",",
"$",
"iTabindex",
"=",
"null",
",",
"$",
"bDisabled",
"=",
"false",
",",
"$",
"sExtraHtml",
"=",
"null",
")",
"{",
"self",
"::",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"$",
"sName",
",",
"$",
"sId",
")",
";",
"$",
"res",
"=",
"'<input type=\"file\" name=\"'",
".",
"$",
"sName",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sId",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"sId",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sDefault",
"?",
"''",
":",
"' value=\"'",
".",
"$",
"sDefault",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sClass",
"?",
"''",
":",
"' class=\"'",
".",
"$",
"sClass",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iTabindex",
"?",
"''",
":",
"' tabindex=\"'",
".",
"$",
"iTabindex",
".",
"'\"'",
";",
"$",
"res",
".=",
"$",
"bDisabled",
"?",
"' disabled=\"disabled\"'",
":",
"''",
";",
"$",
"res",
".=",
"$",
"sExtraHtml",
";",
"$",
"res",
".=",
"' />'",
";",
"return",
"$",
"res",
";",
"}"
] | Retourne un champ de formulaire de type file.
@param mixed $mNameId Le nom et l'identifiant du champ
@param string $sDefault La valeur par défaut de lélément
@param string $sClass La classe CSS de l'élément
@param integer $iTabindex Le tabindex de l'élément
@param boolean $bDisabled Désactiver ou non le champ
@param string $sExtraHtml Du HTML en plus à mettre dans l'élément
@return string | [
"Retourne",
"un",
"champ",
"de",
"formulaire",
"de",
"type",
"file",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L177-L191 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.textarea | public function textarea($mNameId, $iCols = null, $iRows = null, $sDefault = null, $sClass = null, $sPlaceholder = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<textarea';
$res .= null === $iCols ? '' : ' cols="' . $iCols . '"';
$res .= null === $iRows ? '' : ' rows="' . $iRows . '"';
$res .= ' name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $sPlaceholder ? '' : ' placeholder="' . $sPlaceholder . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml . '>';
$res .= $sDefault;
$res .= '</textarea>';
return $res;
} | php | public function textarea($mNameId, $iCols = null, $iRows = null, $sDefault = null, $sClass = null, $sPlaceholder = null, $iTabindex = null, $bDisabled = false, $sExtraHtml = null)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<textarea';
$res .= null === $iCols ? '' : ' cols="' . $iCols . '"';
$res .= null === $iRows ? '' : ' rows="' . $iRows . '"';
$res .= ' name="' . $sName . '"';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= null === $sPlaceholder ? '' : ' placeholder="' . $sPlaceholder . '"';
$res .= null === $iTabindex ? '' : ' tabindex="' . $iTabindex . '"';
$res .= null === $sClass ? '' : ' class="' . $sClass . '"';
$res .= $bDisabled ? ' disabled="disabled"' : '';
$res .= $sExtraHtml . '>';
$res .= $sDefault;
$res .= '</textarea>';
return $res;
} | [
"public",
"function",
"textarea",
"(",
"$",
"mNameId",
",",
"$",
"iCols",
"=",
"null",
",",
"$",
"iRows",
"=",
"null",
",",
"$",
"sDefault",
"=",
"null",
",",
"$",
"sClass",
"=",
"null",
",",
"$",
"sPlaceholder",
"=",
"null",
",",
"$",
"iTabindex",
"=",
"null",
",",
"$",
"bDisabled",
"=",
"false",
",",
"$",
"sExtraHtml",
"=",
"null",
")",
"{",
"self",
"::",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"$",
"sName",
",",
"$",
"sId",
")",
";",
"$",
"res",
"=",
"'<textarea'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iCols",
"?",
"''",
":",
"' cols=\"'",
".",
"$",
"iCols",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iRows",
"?",
"''",
":",
"' rows=\"'",
".",
"$",
"iRows",
".",
"'\"'",
";",
"$",
"res",
".=",
"' name=\"'",
".",
"$",
"sName",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sId",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"sId",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sPlaceholder",
"?",
"''",
":",
"' placeholder=\"'",
".",
"$",
"sPlaceholder",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"iTabindex",
"?",
"''",
":",
"' tabindex=\"'",
".",
"$",
"iTabindex",
".",
"'\"'",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sClass",
"?",
"''",
":",
"' class=\"'",
".",
"$",
"sClass",
".",
"'\"'",
";",
"$",
"res",
".=",
"$",
"bDisabled",
"?",
"' disabled=\"disabled\"'",
":",
"''",
";",
"$",
"res",
".=",
"$",
"sExtraHtml",
".",
"'>'",
";",
"$",
"res",
".=",
"$",
"sDefault",
";",
"$",
"res",
".=",
"'</textarea>'",
";",
"return",
"$",
"res",
";",
"}"
] | Retourne un champ de formulaire de type textarea.
@param mixed $mNameId Le nom et l'identifiant du champ
@param integer $iCols Le nombre de colonnes
@param integer $iRows Le nombre de lignes
@param string $sDefault La valeur par défaut de lélément
@param string $sClass La classe CSS de l'élément
@param string $sPlaceholder
@param integer $iTabindex Le tabindex de l'élément
@param boolean $bDisabled Désactiver ou non le champ
@param string $sExtraHtml Du HTML en plus à mettre dans l'élément
@return string | [
"Retourne",
"un",
"champ",
"de",
"formulaire",
"de",
"type",
"textarea",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L237-L255 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.hidden | public function hidden($mNameId, $value)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="hidden" name="' . $sName . '" value="' . $value . '" ';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= '>';
return $res;
} | php | public function hidden($mNameId, $value)
{
self::getNameAndId($mNameId, $sName, $sId);
$res = '<input type="hidden" name="' . $sName . '" value="' . $value . '" ';
$res .= null === $sId ? '' : ' id="' . $sId . '"';
$res .= '>';
return $res;
} | [
"public",
"function",
"hidden",
"(",
"$",
"mNameId",
",",
"$",
"value",
")",
"{",
"self",
"::",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"$",
"sName",
",",
"$",
"sId",
")",
";",
"$",
"res",
"=",
"'<input type=\"hidden\" name=\"'",
".",
"$",
"sName",
".",
"'\" value=\"'",
".",
"$",
"value",
".",
"'\" '",
";",
"$",
"res",
".=",
"null",
"===",
"$",
"sId",
"?",
"''",
":",
"' id=\"'",
".",
"$",
"sId",
".",
"'\"'",
";",
"$",
"res",
".=",
"'>'",
";",
"return",
"$",
"res",
";",
"}"
] | Retourne un champ de formulaire de type hidden.
@param mixed $mNameId Le nom et l'identifiant du champ
@param string $value La valeur par de lélément
@return string | [
"Retourne",
"un",
"champ",
"de",
"formulaire",
"de",
"type",
"hidden",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L264-L273 |
forxer/tao | src/Tao/Templating/Helpers/FormElements.php | FormElements.getNameAndId | protected static function getNameAndId($mNameId, &$sName, &$sId)
{
if (is_array($mNameId))
{
$sName = $mNameId[0];
$sId = !empty($mNameId[1]) ? $mNameId[1] : null;
}
else {
$sName = $sId = $mNameId;
}
} | php | protected static function getNameAndId($mNameId, &$sName, &$sId)
{
if (is_array($mNameId))
{
$sName = $mNameId[0];
$sId = !empty($mNameId[1]) ? $mNameId[1] : null;
}
else {
$sName = $sId = $mNameId;
}
} | [
"protected",
"static",
"function",
"getNameAndId",
"(",
"$",
"mNameId",
",",
"&",
"$",
"sName",
",",
"&",
"$",
"sId",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mNameId",
")",
")",
"{",
"$",
"sName",
"=",
"$",
"mNameId",
"[",
"0",
"]",
";",
"$",
"sId",
"=",
"!",
"empty",
"(",
"$",
"mNameId",
"[",
"1",
"]",
")",
"?",
"$",
"mNameId",
"[",
"1",
"]",
":",
"null",
";",
"}",
"else",
"{",
"$",
"sName",
"=",
"$",
"sId",
"=",
"$",
"mNameId",
";",
"}",
"}"
] | Retourne l'identifiant et le nom du champ en
fonction des paramètres passés en argument.
@param mixed $mNameId
@param string $sName
@param string $sId | [
"Retourne",
"l",
"identifiant",
"et",
"le",
"nom",
"du",
"champ",
"en",
"fonction",
"des",
"paramètres",
"passés",
"en",
"argument",
"."
] | train | https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Templating/Helpers/FormElements.php#L283-L293 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByStreet | public function filterByStreet($street = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($street)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $street)) {
$street = str_replace('*', '%', $street);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::STREET, $street, $comparison);
} | php | public function filterByStreet($street = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($street)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $street)) {
$street = str_replace('*', '%', $street);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::STREET, $street, $comparison);
} | [
"public",
"function",
"filterByStreet",
"(",
"$",
"street",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"street",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"street",
")",
")",
"{",
"$",
"street",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"street",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"STREET",
",",
"$",
"street",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the street column
Example usage:
<code>
$query->filterByStreet('fooValue'); // WHERE street = 'fooValue'
$query->filterByStreet('%fooValue%'); // WHERE street LIKE '%fooValue%'
</code>
@param string $street The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"street",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L376-L388 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByZip | public function filterByZip($zip = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($zip)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $zip)) {
$zip = str_replace('*', '%', $zip);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::ZIP, $zip, $comparison);
} | php | public function filterByZip($zip = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($zip)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $zip)) {
$zip = str_replace('*', '%', $zip);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::ZIP, $zip, $comparison);
} | [
"public",
"function",
"filterByZip",
"(",
"$",
"zip",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"zip",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"zip",
")",
")",
"{",
"$",
"zip",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"zip",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"ZIP",
",",
"$",
"zip",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the zip column
Example usage:
<code>
$query->filterByZip('fooValue'); // WHERE zip = 'fooValue'
$query->filterByZip('%fooValue%'); // WHERE zip LIKE '%fooValue%'
</code>
@param string $zip The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"zip",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L405-L417 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByCity | public function filterByCity($city = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($city)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $city)) {
$city = str_replace('*', '%', $city);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::CITY, $city, $comparison);
} | php | public function filterByCity($city = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($city)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $city)) {
$city = str_replace('*', '%', $city);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::CITY, $city, $comparison);
} | [
"public",
"function",
"filterByCity",
"(",
"$",
"city",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"city",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"city",
")",
")",
"{",
"$",
"city",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"city",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"CITY",
",",
"$",
"city",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the city column
Example usage:
<code>
$query->filterByCity('fooValue'); // WHERE city = 'fooValue'
$query->filterByCity('%fooValue%'); // WHERE city LIKE '%fooValue%'
</code>
@param string $city The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"city",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L434-L446 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByCountryId | public function filterByCountryId($countryId = null, $comparison = null)
{
if (is_array($countryId)) {
$useMinMax = false;
if (isset($countryId['min'])) {
$this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($countryId['max'])) {
$this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId, $comparison);
} | php | public function filterByCountryId($countryId = null, $comparison = null)
{
if (is_array($countryId)) {
$useMinMax = false;
if (isset($countryId['min'])) {
$this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($countryId['max'])) {
$this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CustomerPeer::COUNTRY_ID, $countryId, $comparison);
} | [
"public",
"function",
"filterByCountryId",
"(",
"$",
"countryId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"countryId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"countryId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"COUNTRY_ID",
",",
"$",
"countryId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"countryId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"COUNTRY_ID",
",",
"$",
"countryId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"COUNTRY_ID",
",",
"$",
"countryId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the country_id column
Example usage:
<code>
$query->filterByCountryId(1234); // WHERE country_id = 1234
$query->filterByCountryId(array(12, 34)); // WHERE country_id IN (12, 34)
$query->filterByCountryId(array('min' => 12)); // WHERE country_id >= 12
$query->filterByCountryId(array('max' => 12)); // WHERE country_id <= 12
</code>
@see filterByCountry()
@param mixed $countryId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"country_id",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L469-L490 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByFax | public function filterByFax($fax = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($fax)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $fax)) {
$fax = str_replace('*', '%', $fax);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::FAX, $fax, $comparison);
} | php | public function filterByFax($fax = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($fax)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $fax)) {
$fax = str_replace('*', '%', $fax);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::FAX, $fax, $comparison);
} | [
"public",
"function",
"filterByFax",
"(",
"$",
"fax",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"fax",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"fax",
")",
")",
"{",
"$",
"fax",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"fax",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"FAX",
",",
"$",
"fax",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the fax column
Example usage:
<code>
$query->filterByFax('fooValue'); // WHERE fax = 'fooValue'
$query->filterByFax('%fooValue%'); // WHERE fax LIKE '%fooValue%'
</code>
@param string $fax The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"fax",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L536-L548 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByEmail | public function filterByEmail($email = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($email)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $email)) {
$email = str_replace('*', '%', $email);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::EMAIL, $email, $comparison);
} | php | public function filterByEmail($email = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($email)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $email)) {
$email = str_replace('*', '%', $email);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::EMAIL, $email, $comparison);
} | [
"public",
"function",
"filterByEmail",
"(",
"$",
"email",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"email",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"email",
")",
")",
"{",
"$",
"email",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"email",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"EMAIL",
",",
"$",
"email",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the email column
Example usage:
<code>
$query->filterByEmail('fooValue'); // WHERE email = 'fooValue'
$query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
</code>
@param string $email The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"email",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L565-L577 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByLegalform | public function filterByLegalform($legalform = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($legalform)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $legalform)) {
$legalform = str_replace('*', '%', $legalform);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::LEGALFORM, $legalform, $comparison);
} | php | public function filterByLegalform($legalform = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($legalform)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $legalform)) {
$legalform = str_replace('*', '%', $legalform);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::LEGALFORM, $legalform, $comparison);
} | [
"public",
"function",
"filterByLegalform",
"(",
"$",
"legalform",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"legalform",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"legalform",
")",
")",
"{",
"$",
"legalform",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"legalform",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"LEGALFORM",
",",
"$",
"legalform",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the legalform column
Example usage:
<code>
$query->filterByLegalform('fooValue'); // WHERE legalform = 'fooValue'
$query->filterByLegalform('%fooValue%'); // WHERE legalform LIKE '%fooValue%'
</code>
@param string $legalform The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"legalform",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L594-L606 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByLogo | public function filterByLogo($logo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($logo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $logo)) {
$logo = str_replace('*', '%', $logo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::LOGO, $logo, $comparison);
} | php | public function filterByLogo($logo = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($logo)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $logo)) {
$logo = str_replace('*', '%', $logo);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::LOGO, $logo, $comparison);
} | [
"public",
"function",
"filterByLogo",
"(",
"$",
"logo",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"logo",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"logo",
")",
")",
"{",
"$",
"logo",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"logo",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"LOGO",
",",
"$",
"logo",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the logo column
Example usage:
<code>
$query->filterByLogo('fooValue'); // WHERE logo = 'fooValue'
$query->filterByLogo('%fooValue%'); // WHERE logo LIKE '%fooValue%'
</code>
@param string $logo The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"logo",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L623-L635 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByCreated | public function filterByCreated($created = null, $comparison = null)
{
if (is_array($created)) {
$useMinMax = false;
if (isset($created['min'])) {
$this->addUsingAlias(CustomerPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($created['max'])) {
$this->addUsingAlias(CustomerPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CustomerPeer::CREATED, $created, $comparison);
} | php | public function filterByCreated($created = null, $comparison = null)
{
if (is_array($created)) {
$useMinMax = false;
if (isset($created['min'])) {
$this->addUsingAlias(CustomerPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($created['max'])) {
$this->addUsingAlias(CustomerPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(CustomerPeer::CREATED, $created, $comparison);
} | [
"public",
"function",
"filterByCreated",
"(",
"$",
"created",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"created",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"created",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"CREATED",
",",
"$",
"created",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"created",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"CREATED",
",",
"$",
"created",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"CREATED",
",",
"$",
"created",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the created column
Example usage:
<code>
$query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
$query->filterByCreated('now'); // WHERE created = '2011-03-14'
$query->filterByCreated(array('max' => 'yesterday')); // WHERE created < '2011-03-13'
</code>
@param mixed $created The value to use as filter.
Values can be integers (unix timestamps), DateTime objects, or strings.
Empty strings are treated as NULL.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"created",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L657-L678 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByNotes | public function filterByNotes($notes = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($notes)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $notes)) {
$notes = str_replace('*', '%', $notes);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::NOTES, $notes, $comparison);
} | php | public function filterByNotes($notes = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($notes)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $notes)) {
$notes = str_replace('*', '%', $notes);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(CustomerPeer::NOTES, $notes, $comparison);
} | [
"public",
"function",
"filterByNotes",
"(",
"$",
"notes",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"notes",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"notes",
")",
")",
"{",
"$",
"notes",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"notes",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"NOTES",
",",
"$",
"notes",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the notes column
Example usage:
<code>
$query->filterByNotes('fooValue'); // WHERE notes = 'fooValue'
$query->filterByNotes('%fooValue%'); // WHERE notes LIKE '%fooValue%'
</code>
@param string $notes The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"notes",
"column"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L695-L707 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByCountry | public function filterByCountry($country, $comparison = null)
{
if ($country instanceof Country) {
return $this
->addUsingAlias(CustomerPeer::COUNTRY_ID, $country->getId(), $comparison);
} elseif ($country instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CustomerPeer::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
}
} | php | public function filterByCountry($country, $comparison = null)
{
if ($country instanceof Country) {
return $this
->addUsingAlias(CustomerPeer::COUNTRY_ID, $country->getId(), $comparison);
} elseif ($country instanceof PropelObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(CustomerPeer::COUNTRY_ID, $country->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByCountry() only accepts arguments of type Country or PropelCollection');
}
} | [
"public",
"function",
"filterByCountry",
"(",
"$",
"country",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"country",
"instanceof",
"Country",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"COUNTRY_ID",
",",
"$",
"country",
"->",
"getId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"country",
"instanceof",
"PropelObjectCollection",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"COUNTRY_ID",
",",
"$",
"country",
"->",
"toKeyValue",
"(",
"'PrimaryKey'",
",",
"'Id'",
")",
",",
"$",
"comparison",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByCountry() only accepts arguments of type Country or PropelCollection'",
")",
";",
"}",
"}"
] | Filter the query by a related Country object
@param Country|PropelObjectCollection $country The related object(s) to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface
@throws PropelException - if the provided filter is invalid. | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"Country",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L718-L733 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.useCountryQuery | public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCountry($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Country', '\Slashworks\AppBundle\Model\CountryQuery');
} | php | public function useCountryQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinCountry($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'Country', '\Slashworks\AppBundle\Model\CountryQuery');
} | [
"public",
"function",
"useCountryQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinCountry",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'Country'",
",",
"'\\Slashworks\\AppBundle\\Model\\CountryQuery'",
")",
";",
"}"
] | Use the Country relation Country object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Slashworks\AppBundle\Model\CountryQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"Country",
"relation",
"Country",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L778-L783 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByRemoteApp | public function filterByRemoteApp($remoteApp, $comparison = null)
{
if ($remoteApp instanceof RemoteApp) {
return $this
->addUsingAlias(CustomerPeer::ID, $remoteApp->getCustomerId(), $comparison);
} elseif ($remoteApp instanceof PropelObjectCollection) {
return $this
->useRemoteAppQuery()
->filterByPrimaryKeys($remoteApp->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByRemoteApp() only accepts arguments of type RemoteApp or PropelCollection');
}
} | php | public function filterByRemoteApp($remoteApp, $comparison = null)
{
if ($remoteApp instanceof RemoteApp) {
return $this
->addUsingAlias(CustomerPeer::ID, $remoteApp->getCustomerId(), $comparison);
} elseif ($remoteApp instanceof PropelObjectCollection) {
return $this
->useRemoteAppQuery()
->filterByPrimaryKeys($remoteApp->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByRemoteApp() only accepts arguments of type RemoteApp or PropelCollection');
}
} | [
"public",
"function",
"filterByRemoteApp",
"(",
"$",
"remoteApp",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"remoteApp",
"instanceof",
"RemoteApp",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"ID",
",",
"$",
"remoteApp",
"->",
"getCustomerId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"remoteApp",
"instanceof",
"PropelObjectCollection",
")",
"{",
"return",
"$",
"this",
"->",
"useRemoteAppQuery",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"remoteApp",
"->",
"getPrimaryKeys",
"(",
")",
")",
"->",
"endUse",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByRemoteApp() only accepts arguments of type RemoteApp or PropelCollection'",
")",
";",
"}",
"}"
] | Filter the query by a related RemoteApp object
@param RemoteApp|PropelObjectCollection $remoteApp the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface
@throws PropelException - if the provided filter is invalid. | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"RemoteApp",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L794-L807 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.filterByUserCustomerRelation | public function filterByUserCustomerRelation($userCustomerRelation, $comparison = null)
{
if ($userCustomerRelation instanceof UserCustomerRelation) {
return $this
->addUsingAlias(CustomerPeer::ID, $userCustomerRelation->getCustomerId(), $comparison);
} elseif ($userCustomerRelation instanceof PropelObjectCollection) {
return $this
->useUserCustomerRelationQuery()
->filterByPrimaryKeys($userCustomerRelation->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByUserCustomerRelation() only accepts arguments of type UserCustomerRelation or PropelCollection');
}
} | php | public function filterByUserCustomerRelation($userCustomerRelation, $comparison = null)
{
if ($userCustomerRelation instanceof UserCustomerRelation) {
return $this
->addUsingAlias(CustomerPeer::ID, $userCustomerRelation->getCustomerId(), $comparison);
} elseif ($userCustomerRelation instanceof PropelObjectCollection) {
return $this
->useUserCustomerRelationQuery()
->filterByPrimaryKeys($userCustomerRelation->getPrimaryKeys())
->endUse();
} else {
throw new PropelException('filterByUserCustomerRelation() only accepts arguments of type UserCustomerRelation or PropelCollection');
}
} | [
"public",
"function",
"filterByUserCustomerRelation",
"(",
"$",
"userCustomerRelation",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"userCustomerRelation",
"instanceof",
"UserCustomerRelation",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"ID",
",",
"$",
"userCustomerRelation",
"->",
"getCustomerId",
"(",
")",
",",
"$",
"comparison",
")",
";",
"}",
"elseif",
"(",
"$",
"userCustomerRelation",
"instanceof",
"PropelObjectCollection",
")",
"{",
"return",
"$",
"this",
"->",
"useUserCustomerRelationQuery",
"(",
")",
"->",
"filterByPrimaryKeys",
"(",
"$",
"userCustomerRelation",
"->",
"getPrimaryKeys",
"(",
")",
")",
"->",
"endUse",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"PropelException",
"(",
"'filterByUserCustomerRelation() only accepts arguments of type UserCustomerRelation or PropelCollection'",
")",
";",
"}",
"}"
] | Filter the query by a related UserCustomerRelation object
@param UserCustomerRelation|PropelObjectCollection $userCustomerRelation the related object to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return CustomerQuery The current query, for fluid interface
@throws PropelException - if the provided filter is invalid. | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"UserCustomerRelation",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L868-L881 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.useUserCustomerRelationQuery | public function useUserCustomerRelationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinUserCustomerRelation($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'UserCustomerRelation', '\Slashworks\AppBundle\Model\UserCustomerRelationQuery');
} | php | public function useUserCustomerRelationQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinUserCustomerRelation($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'UserCustomerRelation', '\Slashworks\AppBundle\Model\UserCustomerRelationQuery');
} | [
"public",
"function",
"useUserCustomerRelationQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinUserCustomerRelation",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'UserCustomerRelation'",
",",
"'\\Slashworks\\AppBundle\\Model\\UserCustomerRelationQuery'",
")",
";",
"}"
] | Use the UserCustomerRelation relation UserCustomerRelation object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Slashworks\AppBundle\Model\UserCustomerRelationQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"UserCustomerRelation",
"relation",
"UserCustomerRelation",
"object"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L926-L931 |
slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php | BaseCustomerQuery.prune | public function prune($customer = null)
{
if ($customer) {
$this->addUsingAlias(CustomerPeer::ID, $customer->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | php | public function prune($customer = null)
{
if ($customer) {
$this->addUsingAlias(CustomerPeer::ID, $customer->getId(), Criteria::NOT_EQUAL);
}
return $this;
} | [
"public",
"function",
"prune",
"(",
"$",
"customer",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"customer",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"CustomerPeer",
"::",
"ID",
",",
"$",
"customer",
"->",
"getId",
"(",
")",
",",
"Criteria",
"::",
"NOT_EQUAL",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Exclude object from result
@param Customer $customer Object to remove from the list of results
@return CustomerQuery The current query, for fluid interface | [
"Exclude",
"object",
"from",
"result"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseCustomerQuery.php#L940-L947 |
fyuze/framework | src/Fyuze/Http/Message/Request.php | Request.getRequestTarget | public function getRequestTarget()
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
}
if (!$this->uri) {
return '/';
}
$requestTarget = $this->getUri()->getPath();
if ($query = $this->getUri()->getQuery()) {
$requestTarget .= sprintf('?%s', $query);
}
return empty($requestTarget) ? '/' : $requestTarget;
} | php | public function getRequestTarget()
{
if ($this->requestTarget !== null) {
return $this->requestTarget;
}
if (!$this->uri) {
return '/';
}
$requestTarget = $this->getUri()->getPath();
if ($query = $this->getUri()->getQuery()) {
$requestTarget .= sprintf('?%s', $query);
}
return empty($requestTarget) ? '/' : $requestTarget;
} | [
"public",
"function",
"getRequestTarget",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"requestTarget",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"requestTarget",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"uri",
")",
"{",
"return",
"'/'",
";",
"}",
"$",
"requestTarget",
"=",
"$",
"this",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"query",
"=",
"$",
"this",
"->",
"getUri",
"(",
")",
"->",
"getQuery",
"(",
")",
")",
"{",
"$",
"requestTarget",
".=",
"sprintf",
"(",
"'?%s'",
",",
"$",
"query",
")",
";",
"}",
"return",
"empty",
"(",
"$",
"requestTarget",
")",
"?",
"'/'",
":",
"$",
"requestTarget",
";",
"}"
] | {@inheritdoc}
@return string | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Message/Request.php#L29-L45 |
fyuze/framework | src/Fyuze/Http/Message/Request.php | Request.withMethod | public function withMethod($method)
{
$method = strtoupper($method);
if (false === in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'OPTIONS', 'DELETE'])) {
throw new \InvalidArgumentException(
sprintf('Invalid HTTP method: %s', $method)
);
}
return $this->_clone('method', $method);
} | php | public function withMethod($method)
{
$method = strtoupper($method);
if (false === in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'OPTIONS', 'DELETE'])) {
throw new \InvalidArgumentException(
sprintf('Invalid HTTP method: %s', $method)
);
}
return $this->_clone('method', $method);
} | [
"public",
"function",
"withMethod",
"(",
"$",
"method",
")",
"{",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"if",
"(",
"false",
"===",
"in_array",
"(",
"$",
"method",
",",
"[",
"'GET'",
",",
"'HEAD'",
",",
"'POST'",
",",
"'PUT'",
",",
"'OPTIONS'",
",",
"'DELETE'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid HTTP method: %s'",
",",
"$",
"method",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_clone",
"(",
"'method'",
",",
"$",
"method",
")",
";",
"}"
] | {@inheritdoc}
@param string $method Case-sensitive method.
@return self
@throws \InvalidArgumentException for invalid HTTP methods. | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Message/Request.php#L89-L100 |
fyuze/framework | src/Fyuze/Http/Message/Request.php | Request.withUri | public function withUri(UriInterface $uri, $preserveHost = false)
{
$clone = $this->_clone('uri', $uri);
if ($preserveHost === true || $uri->getHost() === null) {
return $clone;
}
$clone->headers['host'] = $uri->getHost();
return $clone;
} | php | public function withUri(UriInterface $uri, $preserveHost = false)
{
$clone = $this->_clone('uri', $uri);
if ($preserveHost === true || $uri->getHost() === null) {
return $clone;
}
$clone->headers['host'] = $uri->getHost();
return $clone;
} | [
"public",
"function",
"withUri",
"(",
"UriInterface",
"$",
"uri",
",",
"$",
"preserveHost",
"=",
"false",
")",
"{",
"$",
"clone",
"=",
"$",
"this",
"->",
"_clone",
"(",
"'uri'",
",",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"preserveHost",
"===",
"true",
"||",
"$",
"uri",
"->",
"getHost",
"(",
")",
"===",
"null",
")",
"{",
"return",
"$",
"clone",
";",
"}",
"$",
"clone",
"->",
"headers",
"[",
"'host'",
"]",
"=",
"$",
"uri",
"->",
"getHost",
"(",
")",
";",
"return",
"$",
"clone",
";",
"}"
] | {@inheritdoc}
@link http://tools.ietf.org/html/rfc3986#section-4.3
@param UriInterface $uri New request URI to use.
@param bool $preserveHost Preserve the original state of the Host header.
@return self | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Http/Message/Request.php#L110-L123 |
spiral-modules/scaffolder | source/Scaffolder/Declarations/CommandDeclaration.php | CommandDeclaration.declareStructure | private function declareStructure()
{
$perform = $this->method('perform')->setAccess(MethodDeclaration::ACCESS_PROTECTED);
$perform->setComment("Perform command");
$this->constant('NAME');
$this->constant('NAME')->setValue('');
$this->constant('DESCRIPTION');
$this->constant('DESCRIPTION')->setValue('');
$this->constant('ARGUMENTS');
$this->constant('ARGUMENTS')->setValue([]);
$this->constant('OPTIONS');
$this->constant('OPTIONS')->setValue([]);
} | php | private function declareStructure()
{
$perform = $this->method('perform')->setAccess(MethodDeclaration::ACCESS_PROTECTED);
$perform->setComment("Perform command");
$this->constant('NAME');
$this->constant('NAME')->setValue('');
$this->constant('DESCRIPTION');
$this->constant('DESCRIPTION')->setValue('');
$this->constant('ARGUMENTS');
$this->constant('ARGUMENTS')->setValue([]);
$this->constant('OPTIONS');
$this->constant('OPTIONS')->setValue([]);
} | [
"private",
"function",
"declareStructure",
"(",
")",
"{",
"$",
"perform",
"=",
"$",
"this",
"->",
"method",
"(",
"'perform'",
")",
"->",
"setAccess",
"(",
"MethodDeclaration",
"::",
"ACCESS_PROTECTED",
")",
";",
"$",
"perform",
"->",
"setComment",
"(",
"\"Perform command\"",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'NAME'",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'NAME'",
")",
"->",
"setValue",
"(",
"''",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'DESCRIPTION'",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'DESCRIPTION'",
")",
"->",
"setValue",
"(",
"''",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'ARGUMENTS'",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'ARGUMENTS'",
")",
"->",
"setValue",
"(",
"[",
"]",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'OPTIONS'",
")",
";",
"$",
"this",
"->",
"constant",
"(",
"'OPTIONS'",
")",
"->",
"setValue",
"(",
"[",
"]",
")",
";",
"}"
] | Declare default __invoke method body. | [
"Declare",
"default",
"__invoke",
"method",
"body",
"."
] | train | https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/CommandDeclaration.php#L74-L90 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.cloud | public function cloud($disk = null)
{
$disk = !is_null($disk) ? $disk : $this->cloud;
return $this->get($disk);
} | php | public function cloud($disk = null)
{
$disk = !is_null($disk) ? $disk : $this->cloud;
return $this->get($disk);
} | [
"public",
"function",
"cloud",
"(",
"$",
"disk",
"=",
"null",
")",
"{",
"$",
"disk",
"=",
"!",
"is_null",
"(",
"$",
"disk",
")",
"?",
"$",
"disk",
":",
"$",
"this",
"->",
"cloud",
";",
"return",
"$",
"this",
"->",
"get",
"(",
"$",
"disk",
")",
";",
"}"
] | 获取磁盘
@param string|null $disk
@return \yuncms\filesystem\Filesystem|\yuncms\filesystem\Cloud
@throws \yii\base\InvalidConfigException | [
"获取磁盘"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L71-L75 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.resolve | protected function resolve($name)
{
$config = $this->disks[$name];
if (isset($config['class'])) {
return Yii::createObject($config);
} else if (isset($config['adapter'])) {
$driverMethod = 'create' . ucfirst($config['adapter']) . 'Adapter';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Adapter [{$config['adapter']}] is not supported.");
}
} else {
throw new InvalidArgumentException("Wrong adapter configuration.");
}
} | php | protected function resolve($name)
{
$config = $this->disks[$name];
if (isset($config['class'])) {
return Yii::createObject($config);
} else if (isset($config['adapter'])) {
$driverMethod = 'create' . ucfirst($config['adapter']) . 'Adapter';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Adapter [{$config['adapter']}] is not supported.");
}
} else {
throw new InvalidArgumentException("Wrong adapter configuration.");
}
} | [
"protected",
"function",
"resolve",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"disks",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'class'",
"]",
")",
")",
"{",
"return",
"Yii",
"::",
"createObject",
"(",
"$",
"config",
")",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'adapter'",
"]",
")",
")",
"{",
"$",
"driverMethod",
"=",
"'create'",
".",
"ucfirst",
"(",
"$",
"config",
"[",
"'adapter'",
"]",
")",
".",
"'Adapter'",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"driverMethod",
")",
")",
"{",
"return",
"$",
"this",
"->",
"{",
"$",
"driverMethod",
"}",
"(",
"$",
"config",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Adapter [{$config['adapter']}] is not supported.\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Wrong adapter configuration.\"",
")",
";",
"}",
"}"
] | Resolve the given disk.
@param string $name
@return object|Filesystem
@throws \yii\base\InvalidConfigException | [
"Resolve",
"the",
"given",
"disk",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L120-L135 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.createLocalAdapter | public function createLocalAdapter(array $config)
{
$permissions = $config['permissions'] ?? [];
$root = Yii::getAlias($config['root']);
$links = ($config['links'] ?? null) === 'skip'
? LocalAdapter::SKIP_LINKS
: LocalAdapter::DISALLOW_LINKS;
return $this->adapt($this->createFlysystem(new LocalAdapter(
$root, LOCK_EX, $links, $permissions
), $config));
} | php | public function createLocalAdapter(array $config)
{
$permissions = $config['permissions'] ?? [];
$root = Yii::getAlias($config['root']);
$links = ($config['links'] ?? null) === 'skip'
? LocalAdapter::SKIP_LINKS
: LocalAdapter::DISALLOW_LINKS;
return $this->adapt($this->createFlysystem(new LocalAdapter(
$root, LOCK_EX, $links, $permissions
), $config));
} | [
"public",
"function",
"createLocalAdapter",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"permissions",
"=",
"$",
"config",
"[",
"'permissions'",
"]",
"??",
"[",
"]",
";",
"$",
"root",
"=",
"Yii",
"::",
"getAlias",
"(",
"$",
"config",
"[",
"'root'",
"]",
")",
";",
"$",
"links",
"=",
"(",
"$",
"config",
"[",
"'links'",
"]",
"??",
"null",
")",
"===",
"'skip'",
"?",
"LocalAdapter",
"::",
"SKIP_LINKS",
":",
"LocalAdapter",
"::",
"DISALLOW_LINKS",
";",
"return",
"$",
"this",
"->",
"adapt",
"(",
"$",
"this",
"->",
"createFlysystem",
"(",
"new",
"LocalAdapter",
"(",
"$",
"root",
",",
"LOCK_EX",
",",
"$",
"links",
",",
"$",
"permissions",
")",
",",
"$",
"config",
")",
")",
";",
"}"
] | Create an instance of the local adapter.
@param array $config
@return \yuncms\filesystem\Filesystem | [
"Create",
"an",
"instance",
"of",
"the",
"local",
"adapter",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L143-L155 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.createOssAdapter | public function createOssAdapter(array $config)
{
$root = $config['root'] ?? null;
$oss = new OssClient($config['access_id'], $config['access_secret'], $config['endpoint'],
$config['isCName'] ?? false,
$config['securityToken'] ?? null,
$config['proxy'] ?? null
);
$oss->setTimeout($config['timeout'] ?? 3600);
$oss->setConnectTimeout($config['connectTimeout'] ?? 10);
$oss->setUseSSL($config['useSSL'] ?? false);
return $this->adapt($this->createFlysystem(
new OssAdapter($oss, $config['bucket'], $root), $config
));
} | php | public function createOssAdapter(array $config)
{
$root = $config['root'] ?? null;
$oss = new OssClient($config['access_id'], $config['access_secret'], $config['endpoint'],
$config['isCName'] ?? false,
$config['securityToken'] ?? null,
$config['proxy'] ?? null
);
$oss->setTimeout($config['timeout'] ?? 3600);
$oss->setConnectTimeout($config['connectTimeout'] ?? 10);
$oss->setUseSSL($config['useSSL'] ?? false);
return $this->adapt($this->createFlysystem(
new OssAdapter($oss, $config['bucket'], $root), $config
));
} | [
"public",
"function",
"createOssAdapter",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"root",
"=",
"$",
"config",
"[",
"'root'",
"]",
"??",
"null",
";",
"$",
"oss",
"=",
"new",
"OssClient",
"(",
"$",
"config",
"[",
"'access_id'",
"]",
",",
"$",
"config",
"[",
"'access_secret'",
"]",
",",
"$",
"config",
"[",
"'endpoint'",
"]",
",",
"$",
"config",
"[",
"'isCName'",
"]",
"??",
"false",
",",
"$",
"config",
"[",
"'securityToken'",
"]",
"??",
"null",
",",
"$",
"config",
"[",
"'proxy'",
"]",
"??",
"null",
")",
";",
"$",
"oss",
"->",
"setTimeout",
"(",
"$",
"config",
"[",
"'timeout'",
"]",
"??",
"3600",
")",
";",
"$",
"oss",
"->",
"setConnectTimeout",
"(",
"$",
"config",
"[",
"'connectTimeout'",
"]",
"??",
"10",
")",
";",
"$",
"oss",
"->",
"setUseSSL",
"(",
"$",
"config",
"[",
"'useSSL'",
"]",
"??",
"false",
")",
";",
"return",
"$",
"this",
"->",
"adapt",
"(",
"$",
"this",
"->",
"createFlysystem",
"(",
"new",
"OssAdapter",
"(",
"$",
"oss",
",",
"$",
"config",
"[",
"'bucket'",
"]",
",",
"$",
"root",
")",
",",
"$",
"config",
")",
")",
";",
"}"
] | Create an instance of the oss driver.
@param array $config
@return \yuncms\filesystem\Filesystem
@throws \OSS\Core\OssException
@throws \Exception | [
"Create",
"an",
"instance",
"of",
"the",
"oss",
"driver",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L165-L179 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.formatS3Config | protected function formatS3Config(array $config)
{
$config += ['version' => 'latest'];
if ($config['key'] && $config['secret']) {
$config['credentials'] = ArrayHelper::only($config, ['key', 'secret']);
}
return $config;
} | php | protected function formatS3Config(array $config)
{
$config += ['version' => 'latest'];
if ($config['key'] && $config['secret']) {
$config['credentials'] = ArrayHelper::only($config, ['key', 'secret']);
}
return $config;
} | [
"protected",
"function",
"formatS3Config",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"config",
"+=",
"[",
"'version'",
"=>",
"'latest'",
"]",
";",
"if",
"(",
"$",
"config",
"[",
"'key'",
"]",
"&&",
"$",
"config",
"[",
"'secret'",
"]",
")",
"{",
"$",
"config",
"[",
"'credentials'",
"]",
"=",
"ArrayHelper",
"::",
"only",
"(",
"$",
"config",
",",
"[",
"'key'",
",",
"'secret'",
"]",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Format the given S3 configuration with the default options.
@param array $config
@return array | [
"Format",
"the",
"given",
"S3",
"configuration",
"with",
"the",
"default",
"options",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L216-L223 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.createFlysystem | protected function createFlysystem(AdapterInterface $adapter, array $config)
{
$cache = ArrayHelper::pull($config, 'cache');
$config = ArrayHelper::only($config, ['visibility', 'disable_asserts', 'url']);
if ($cache) {
$adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
}
return new Flysystem($adapter, count($config) > 0 ? $config : null);
} | php | protected function createFlysystem(AdapterInterface $adapter, array $config)
{
$cache = ArrayHelper::pull($config, 'cache');
$config = ArrayHelper::only($config, ['visibility', 'disable_asserts', 'url']);
if ($cache) {
$adapter = new CachedAdapter($adapter, $this->createCacheStore($cache));
}
return new Flysystem($adapter, count($config) > 0 ? $config : null);
} | [
"protected",
"function",
"createFlysystem",
"(",
"AdapterInterface",
"$",
"adapter",
",",
"array",
"$",
"config",
")",
"{",
"$",
"cache",
"=",
"ArrayHelper",
"::",
"pull",
"(",
"$",
"config",
",",
"'cache'",
")",
";",
"$",
"config",
"=",
"ArrayHelper",
"::",
"only",
"(",
"$",
"config",
",",
"[",
"'visibility'",
",",
"'disable_asserts'",
",",
"'url'",
"]",
")",
";",
"if",
"(",
"$",
"cache",
")",
"{",
"$",
"adapter",
"=",
"new",
"CachedAdapter",
"(",
"$",
"adapter",
",",
"$",
"this",
"->",
"createCacheStore",
"(",
"$",
"cache",
")",
")",
";",
"}",
"return",
"new",
"Flysystem",
"(",
"$",
"adapter",
",",
"count",
"(",
"$",
"config",
")",
">",
"0",
"?",
"$",
"config",
":",
"null",
")",
";",
"}"
] | Create a Flysystem instance with the given adapter.
@param \League\Flysystem\AdapterInterface $adapter
@param array $config
@return \League\Flysystem\FilesystemInterface | [
"Create",
"a",
"Flysystem",
"instance",
"with",
"the",
"given",
"adapter",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L232-L240 |
yuncms/framework | src/filesystem/FilesystemManager.php | FilesystemManager.createCacheStore | protected function createCacheStore($config)
{
if ($config === true) {
return new MemoryStore;
}
return new Cache(Yii::$app->cache,
$config['prefix'] ?? 'flysystem',
$config['duration'] ?? null
);
} | php | protected function createCacheStore($config)
{
if ($config === true) {
return new MemoryStore;
}
return new Cache(Yii::$app->cache,
$config['prefix'] ?? 'flysystem',
$config['duration'] ?? null
);
} | [
"protected",
"function",
"createCacheStore",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"===",
"true",
")",
"{",
"return",
"new",
"MemoryStore",
";",
"}",
"return",
"new",
"Cache",
"(",
"Yii",
"::",
"$",
"app",
"->",
"cache",
",",
"$",
"config",
"[",
"'prefix'",
"]",
"??",
"'flysystem'",
",",
"$",
"config",
"[",
"'duration'",
"]",
"??",
"null",
")",
";",
"}"
] | Create a cache store instance.
@param mixed $config
@return \League\Flysystem\Cached\CacheInterface
@throws \InvalidArgumentException | [
"Create",
"a",
"cache",
"store",
"instance",
"."
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/FilesystemManager.php#L249-L258 |
andynoelker/laravel-5-view-generator | src/ViewMakeCommand.php | ViewMakeCommand.handle | public function handle()
{
$name = $this->argument('name');
$path = $this->getPath($name);
$this->makeDirectory($path);
if (file_exists($path)) {
if ($this->confirm('View already exists. Do you wish to overwrite it?')) {
$this->createView($path);
}
} else {
$this->createView($path);
}
} | php | public function handle()
{
$name = $this->argument('name');
$path = $this->getPath($name);
$this->makeDirectory($path);
if (file_exists($path)) {
if ($this->confirm('View already exists. Do you wish to overwrite it?')) {
$this->createView($path);
}
} else {
$this->createView($path);
}
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"argument",
"(",
"'name'",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"makeDirectory",
"(",
"$",
"path",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"confirm",
"(",
"'View already exists. Do you wish to overwrite it?'",
")",
")",
"{",
"$",
"this",
"->",
"createView",
"(",
"$",
"path",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"createView",
"(",
"$",
"path",
")",
";",
"}",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/andynoelker/laravel-5-view-generator/blob/c18b1d9e0959cb5d7c5f83650b47464b81ea287d/src/ViewMakeCommand.php#L40-L54 |
andynoelker/laravel-5-view-generator | src/ViewMakeCommand.php | ViewMakeCommand.createView | protected function createView($path)
{
$contents = $this->getViewContents();
file_put_contents($path,$contents);
$this->info('View created successfully.');
} | php | protected function createView($path)
{
$contents = $this->getViewContents();
file_put_contents($path,$contents);
$this->info('View created successfully.');
} | [
"protected",
"function",
"createView",
"(",
"$",
"path",
")",
"{",
"$",
"contents",
"=",
"$",
"this",
"->",
"getViewContents",
"(",
")",
";",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"contents",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'View created successfully.'",
")",
";",
"}"
] | Generate the Blade view.
@param string $path The path of the view.
@return void | [
"Generate",
"the",
"Blade",
"view",
"."
] | train | https://github.com/andynoelker/laravel-5-view-generator/blob/c18b1d9e0959cb5d7c5f83650b47464b81ea287d/src/ViewMakeCommand.php#L62-L69 |
andynoelker/laravel-5-view-generator | src/ViewMakeCommand.php | ViewMakeCommand.makeDirectory | protected function makeDirectory($path)
{
$dir = dirname($path);
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
} | php | protected function makeDirectory($path)
{
$dir = dirname($path);
if (!file_exists($dir)) {
mkdir($dir, 0777, true);
}
} | [
"protected",
"function",
"makeDirectory",
"(",
"$",
"path",
")",
"{",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"mkdir",
"(",
"$",
"dir",
",",
"0777",
",",
"true",
")",
";",
"}",
"}"
] | Create the directory for the view if it does not already exist.
@param string $path The full path of the view file.
@return void | [
"Create",
"the",
"directory",
"for",
"the",
"view",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | train | https://github.com/andynoelker/laravel-5-view-generator/blob/c18b1d9e0959cb5d7c5f83650b47464b81ea287d/src/ViewMakeCommand.php#L92-L99 |
aedart/laravel-helpers | src/Traits/Bus/QueueingBusTrait.php | QueueingBusTrait.getQueueingBus | public function getQueueingBus(): ?QueueingDispatcher
{
if (!$this->hasQueueingBus()) {
$this->setQueueingBus($this->getDefaultQueueingBus());
}
return $this->queueingBus;
} | php | public function getQueueingBus(): ?QueueingDispatcher
{
if (!$this->hasQueueingBus()) {
$this->setQueueingBus($this->getDefaultQueueingBus());
}
return $this->queueingBus;
} | [
"public",
"function",
"getQueueingBus",
"(",
")",
":",
"?",
"QueueingDispatcher",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasQueueingBus",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setQueueingBus",
"(",
"$",
"this",
"->",
"getDefaultQueueingBus",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"queueingBus",
";",
"}"
] | Get queueing bus
If no queueing bus has been set, this method will
set and return a default queueing bus, if any such
value is available
@see getDefaultQueueingBus()
@return QueueingDispatcher|null queueing bus or null if none queueing bus has been set | [
"Get",
"queueing",
"bus"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Bus/QueueingBusTrait.php#L53-L59 |
yuncms/framework | src/admin/migrations/m180324_104125_create_admin_rbac_table.php | m180324_104125_create_admin_rbac_table.safeUp | public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
}
$time = time();
$this->createTable('{{%admin_auth_rule}}', [
'name' => $this->string(64)->notNull()->unique(),
'data' => $this->text(),
'created_at' => $this->unixTimestamp(),
'updated_at' => $this->unixTimestamp()
], $tableOptions);
$this->createTable('{{%admin_auth_item}}', [
'name' => $this->string(64)->notNull()->unique(),
'type' => $this->integer()->notNull(),
'description' => $this->text(),
'rule_name' => $this->string(64),
'data' => $this->text(),
'created_at' => $this->unixTimestamp(),
'updated_at' => $this->unixTimestamp(),
], $tableOptions);
$this->createIndex('idx-auth_item-type', '{{%admin_auth_item}}', 'type');
$this->addForeignKey('admin_auth_item_fk_1', '{{%admin_auth_item}}', 'rule_name', '{{%admin_auth_rule}}', 'name', 'SET NULL', 'CASCADE');
$this->createTable('{{%admin_auth_item_child}}', [
'parent' => $this->string(64)->notNull(),
'child' => $this->string(64)->notNull(),
], $tableOptions);
$this->addPrimaryKey('', '{{%admin_auth_item_child}}', ['parent', 'child']);
$this->addForeignKey('admin_auth_item_child_fk_1', '{{%admin_auth_item_child}}', 'parent', '{{%admin_auth_item}}', 'name', 'CASCADE', 'CASCADE');
$this->addForeignKey('admin_auth_item_child_fk_2', '{{%admin_auth_item_child}}', 'child', '{{%admin_auth_item}}', 'name', 'CASCADE', 'CASCADE');
$this->createTable('{{%admin_auth_assignment}}', [
'item_name' => $this->string(64)->notNull(),
'user_id' => $this->string(64)->notNull(),
'created_at' => $this->unixTimestamp(),
], $tableOptions);
$this->addPrimaryKey('', '{{%admin_auth_assignment}}', ['item_name', 'user_id']);
$this->addForeignKey('{{%admin_auth_assignment_ibfk_1}}', '{{%admin_auth_assignment}}', 'item_name', '{{%admin_auth_item}}', 'name', 'CASCADE', 'CASCADE');
//添加规则
$this->insert('{{%admin_auth_rule}}', ['name' => 'GuestRule', 'data' => 'O:21:"yuncms\rbac\GuestRule":3:{s:4:"name";s:9:"GuestRule";s:9:"createdAt";i:1522062274;s:9:"updatedAt";i:1522062274;}', 'created_at' => time(), 'updated_at' => time()]);
$this->insert('{{%admin_auth_rule}}', ['name' => 'RouteRule', 'data' => 'O:21:"yuncms\rbac\RouteRule":3:{s:4:"name";s:9:"RouteRule";s:9:"createdAt";i:1522062288;s:9:"updatedAt";i:1522062288;}', 'created_at' => time(), 'updated_at' => time()]);
//添加角色
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'description', 'rule_name', 'created_at', 'updated_at'], [
['Super Administrator', 1, '超级管理员对系统有不受限制的完全访问权。', 'RouteRule', $time, $time],
['Administrator', 1, '防止管理员进行有意或无意的系统范围的更改,但是可以执行大部分管理操作。', 'RouteRule', $time, $time],
]);
//添加路由
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'created_at', 'updated_at'], [
['/*', 2, $time, $time],
['/site/*', 2, $time, $time],
['/site/index', 2, $time, $time],
['/admin/security/logout', 2, $time, $time],
['/admin/admin/*', 2, $time, $time],
['/admin/admin/create', 2, $time, $time],
['/admin/admin/delete', 2, $time, $time],
['/admin/admin/index', 2, $time, $time],
['/admin/admin/update', 2, $time, $time],
['/admin/admin/view', 2, $time, $time],
['/admin/assignment/*', 2, $time, $time],
['/admin/assignment/assign', 2, $time, $time],
['/admin/assignment/index', 2, $time, $time],
['/admin/assignment/revoke', 2, $time, $time],
['/admin/assignment/view', 2, $time, $time],
['/admin/attachment/*', 2, $time, $time],
['/admin/attachment/batch-delete', 2, $time, $time],
['/admin/attachment/delete', 2, $time, $time],
['/admin/attachment/index', 2, $time, $time],
['/admin/attachment/setting', 2, $time, $time],
['/admin/attachment/view', 2, $time, $time],
['/admin/menu/*', 2, $time, $time],
['/admin/menu/auto-complete', 2, $time, $time],
['/admin/menu/create', 2, $time, $time],
['/admin/menu/delete', 2, $time, $time],
['/admin/menu/index', 2, $time, $time],
['/admin/menu/position', 2, $time, $time],
['/admin/menu/update', 2, $time, $time],
['/admin/menu/view', 2, $time, $time],
['/admin/oauth2/*', 2, $time, $time],
['/admin/oauth2/batch-delete', 2, $time, $time],
['/admin/oauth2/create', 2, $time, $time],
['/admin/oauth2/delete', 2, $time, $time],
['/admin/oauth2/index', 2, $time, $time],
['/admin/oauth2/update', 2, $time, $time],
['/admin/oauth2/view', 2, $time, $time],
['/admin/permission/*', 2, $time, $time],
['/admin/permission/assign', 2, $time, $time],
['/admin/permission/create', 2, $time, $time],
['/admin/permission/delete', 2, $time, $time],
['/admin/permission/index', 2, $time, $time],
['/admin/permission/remove', 2, $time, $time],
['/admin/permission/update', 2, $time, $time],
['/admin/permission/view', 2, $time, $time],
['/admin/queue/*', 2, $time, $time],
['/admin/role/*', 2, $time, $time],
['/admin/role/assign', 2, $time, $time],
['/admin/role/create', 2, $time, $time],
['/admin/role/delete', 2, $time, $time],
['/admin/role/index', 2, $time, $time],
['/admin/role/remove', 2, $time, $time],
['/admin/role/update', 2, $time, $time],
['/admin/role/view', 2, $time, $time],
['/admin/route/*', 2, $time, $time],
['/admin/route/assign', 2, $time, $time],
['/admin/route/create', 2, $time, $time],
['/admin/route/index', 2, $time, $time],
['/admin/route/refresh', 2, $time, $time],
['/admin/route/remove', 2, $time, $time],
['/admin/rule/*', 2, $time, $time],
['/admin/rule/create', 2, $time, $time],
['/admin/rule/delete', 2, $time, $time],
['/admin/rule/index', 2, $time, $time],
['/admin/rule/update', 2, $time, $time],
['/admin/rule/view', 2, $time, $time],
['/admin/security/*', 2, $time, $time],
['/admin/security/captcha', 2, $time, $time],
['/admin/setting/*', 2, $time, $time],
['/admin/setting/setting', 2, $time, $time],
['/admin/user/*', 2, $time, $time],
['/admin/user/block', 2, $time, $time],
['/admin/user/confirm', 2, $time, $time],
['/admin/user/create', 2, $time, $time],
['/admin/user/delete', 2, $time, $time],
['/admin/user/index', 2, $time, $time],
['/admin/user/settings', 2, $time, $time],
['/admin/user/update', 2, $time, $time],
['/admin/user/update-profile', 2, $time, $time],
['/admin/user/view', 2, $time, $time],
['/upload/*', 2, $time, $time],
['/upload/file-upload', 2, $time, $time],
['/upload/files-upload', 2, $time, $time],
['/upload/image-upload', 2, $time, $time],
['/upload/images-upload', 2, $time, $time],
]);
//给超级管理员组授权
$this->insert('{{%admin_auth_item_child}}', ['parent' => 'Super Administrator', 'child' => '/*']);
$this->insert('{{%admin_auth_assignment}}', ['item_name' => 'Super Administrator', 'user_id' => 1, 'created_at' => $time]);
//新建权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['核心设置', 2, 'RouteRule', $time, $time],
['站点设置', 2, 'RouteRule', $time, $time],
['附件上传', 2, 'RouteRule', $time, $time],
['附件设置', 2, 'RouteRule', $time, $time],
]);
//管理授权
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['站点设置', '/admin/setting/setting'],
['附件上传', '/upload/*'],
['附件上传', '/upload/file-upload'],
['附件上传', '/upload/files-upload'],
['附件上传', '/upload/image-upload'],
['附件上传', '/upload/images-upload'],
['附件设置', '/admin/attachment/setting'],
]);
//管理员相关权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['管理员管理', 2, 'RouteRule', $time, $time],
['管理员列表', 2, 'RouteRule', $time, $time],
['管理员查看', 2, 'RouteRule', $time, $time],
['管理员创建', 2, 'RouteRule', $time, $time],
['管理员删除', 2, 'RouteRule', $time, $time],
['管理员修改', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['管理员创建', '/admin/admin/create'],
['管理员删除', '/admin/admin/delete'],
['管理员列表', '/admin/admin/index'],
['管理员修改', '/admin/admin/update'],
['管理员查看', '/admin/admin/view'],
['管理员管理', '/admin/admin/*'],
['管理员管理', '管理员创建'],
['管理员管理', '管理员删除'],
['管理员管理', '管理员查看'],
['管理员管理', '管理员修改'],
['管理员管理', '管理员列表'],
]);
//角色相关权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['角色管理', 2, 'RouteRule', $time, $time],
['角色授权', 2, 'RouteRule', $time, $time],
['角色创建', 2, 'RouteRule', $time, $time],
['角色删除', 2, 'RouteRule', $time, $time],
['角色列表查看', 2, 'RouteRule', $time, $time],
['角色授权或删除', 2, 'RouteRule', $time, $time],
['角色更新', 2, 'RouteRule', $time, $time],
['角色查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['角色授权', '/admin/role/assign'],
['角色创建', '/admin/role/create'],
['角色删除', '/admin/role/delete'],
['角色列表查看', '/admin/role/index'],
['角色授权或删除', '/admin/role/remove'],
['角色更新', '/admin/role/update'],
['角色查看', '/admin/role/view'],
['角色管理', '/admin/role/*'],
['角色管理', '角色列表查看'],
['角色管理', '角色授权'],
['角色管理', '角色创建'],
['角色管理', '角色删除'],
['角色管理', '角色查看'],
['角色管理', '角色授权或删除'],
['角色管理', '角色更新'],
]);
//权限管理权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['权限管理', 2, 'RouteRule', $time, $time],
['权限授权', 2, 'RouteRule', $time, $time],
['权限创建', 2, 'RouteRule', $time, $time],
['权限删除', 2, 'RouteRule', $time, $time],
['权限列表', 2, 'RouteRule', $time, $time],
['权限授权或删除', 2, 'RouteRule', $time, $time],
['权限更新', 2, 'RouteRule', $time, $time],
['权限查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['权限授权', '/admin/permission/assign'],
['权限创建', '/admin/permission/create'],
['权限删除', '/admin/permission/delete'],
['权限列表', '/admin/permission/index'],
['权限授权或删除', '/admin/permission/remove'],
['权限更新', '/admin/permission/update'],
['权限查看', '/admin/permission/view'],
['权限管理', '/admin/permission/*'],
['权限管理', '权限授权'],
['权限管理', '权限创建'],
['权限管理', '权限删除'],
['权限管理', '权限列表'],
['权限管理', '权限授权或删除'],
['权限管理', '权限更新'],
['权限管理', '权限查看'],
]);
//路由权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['路由管理', 2, 'RouteRule', $time, $time],
['路由授权', 2, 'RouteRule', $time, $time],
['路由创建', 2, 'RouteRule', $time, $time],
['路由列表', 2, 'RouteRule', $time, $time],
['路由刷新', 2, 'RouteRule', $time, $time],
['路由删除', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['路由授权', '/admin/route/assign'],
['路由创建', '/admin/route/create'],
['路由列表', '/admin/route/index'],
['路由刷新', '/admin/route/refresh'],
['路由删除', '/admin/route/remove'],
['路由管理', '/admin/route/*'],
['路由管理', '路由授权'],
['路由管理', '路由创建'],
['路由管理', '路由列表'],
['路由管理', '路由刷新'],
['路由管理', '路由删除'],
]);
//规则管理
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['规则管理', 2, 'RouteRule', $time, $time],
['规则创建', 2, 'RouteRule', $time, $time],
['规则删除', 2, 'RouteRule', $time, $time],
['规则列表', 2, 'RouteRule', $time, $time],
['规则更新', 2, 'RouteRule', $time, $time],
['规则查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['规则创建', '/admin/rule/create'],
['规则删除', '/admin/rule/delete'],
['规则列表', '/admin/rule/index'],
['规则更新', '/admin/rule/update'],
['规则查看', '/admin/rule/view'],
['规则管理', '/admin/rule/*'],
['规则管理', '规则创建'],
['规则管理', '规则删除'],
['规则管理', '规则列表'],
['规则管理', '规则更新'],
['规则管理', '规则查看'],
]);
//菜单权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['菜单管理', 2, 'RouteRule', $time, $time],
['菜单自动下拉提醒', 2, 'RouteRule', $time, $time],
['菜单创建', 2, 'RouteRule', $time, $time],
['菜单删除', 2, 'RouteRule', $time, $time],
['菜单列表', 2, 'RouteRule', $time, $time],
['菜单排序', 2, 'RouteRule', $time, $time],
['菜单更新', 2, 'RouteRule', $time, $time],
['菜单查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['菜单自动下拉提醒', '/admin/menu/auto-complete'],
['菜单创建', '/admin/menu/create'],
['菜单删除', '/admin/menu/delete'],
['菜单列表', '/admin/menu/index'],
['菜单排序', '/admin/menu/position'],
['菜单更新', '/admin/menu/update'],
['菜单查看', '/admin/menu/view'],
['菜单管理', '/admin/menu/*'],
['菜单管理', '菜单自动下拉提醒'],
['菜单管理', '菜单创建'],
['菜单管理', '菜单删除'],
['菜单管理', '菜单列表'],
['菜单管理', '菜单排序'],
['菜单管理', '菜单更新'],
['菜单管理', '菜单查看'],
]);
// 用户管理
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['用户管理', 2, 'RouteRule', $time, $time],
['用户封锁', 2, 'RouteRule', $time, $time],
['用户激活', 2, 'RouteRule', $time, $time],
['用户创建', 2, 'RouteRule', $time, $time],
['用户删除', 2, 'RouteRule', $time, $time],
['用户列表', 2, 'RouteRule', $time, $time],
['用户模块设置', 2, 'RouteRule', $time, $time],
['用户更新', 2, 'RouteRule', $time, $time],
['用户更新个人资料', 2, 'RouteRule', $time, $time],
['用户查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['用户封锁', '/admin/user/block'],
['用户激活', '/admin/user/confirm'],
['用户创建', '/admin/user/create'],
['用户删除', '/admin/user/delete'],
['用户列表', '/admin/user/index'],
['用户模块设置', '/admin/user/settings'],
['用户更新', '/admin/user/update'],
['用户更新个人资料', '/admin/user/update-profile'],
['用户查看', '/admin/user/view'],
['用户管理', '/admin/user/*'],
['用户管理', '用户封锁'],
['用户管理', '用户激活'],
['用户管理', '用户创建'],
['用户管理', '用户删除'],
['用户管理', '用户列表'],
['用户管理', '用户模块设置'],
['用户管理', '用户更新个人资料'],
['用户管理', '用户查看'],
]);
// OAuth2
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['OAuth2管理', 2, 'RouteRule', $time, $time],
['OAuth2批量删除', 2, 'RouteRule', $time, $time],
['OAuth2创建', 2, 'RouteRule', $time, $time],
['OAuth2删除', 2, 'RouteRule', $time, $time],
['OAuth2列表', 2, 'RouteRule', $time, $time],
['OAuth2更新', 2, 'RouteRule', $time, $time],
['OAuth2查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['OAuth2批量删除', '/admin/oauth2/batch-delete'],
['OAuth2创建', '/admin/oauth2/create'],
['OAuth2删除', '/admin/oauth2/delete'],
['OAuth2列表', '/admin/oauth2/index'],
['OAuth2更新', '/admin/oauth2/update'],
['OAuth2查看', '/admin/oauth2/view'],
['OAuth2管理', '/admin/oauth2/*'],
['OAuth2管理', 'OAuth2批量删除'],
['OAuth2管理', 'OAuth2创建'],
['OAuth2管理', 'OAuth2删除'],
['OAuth2管理', 'OAuth2列表'],
['OAuth2管理', 'OAuth2更新'],
['OAuth2管理', 'OAuth2查看'],
]);
// 附件管理
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['附件管理', 2, 'RouteRule', $time, $time],
['附件列表', 2, 'RouteRule', $time, $time],
['附件批量删除', 2, 'RouteRule', $time, $time],
['附件删除', 2, 'RouteRule', $time, $time],
['附件查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['附件列表', '/admin/attachment/index'],
['附件批量删除', '/admin/attachment/batch-delete'],
['附件删除', '/admin/attachment/delete'],
['附件查看', '/admin/attachment/view'],
['附件管理', '/admin/attachment/*'],
['附件管理', '附件列表'],
['附件管理', '附件批量删除'],
['附件管理', '附件删除'],
['附件管理', '附件查看'],
]);
//管理授权
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['核心设置', '站点设置'],
['核心设置', '管理员管理'],
['核心设置', '角色管理'],
['核心设置', '权限管理'],
['核心设置', '路由管理'],
['核心设置', '规则管理'],
['核心设置', '菜单管理'],
['核心设置', '附件设置'],
]);
//给 Administrator 授权
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['Administrator', '/site/index'],
['Administrator', '用户管理'],
['Administrator', '附件上传'],
['Administrator', '附件管理'],
]);
} | php | public function safeUp()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
}
$time = time();
$this->createTable('{{%admin_auth_rule}}', [
'name' => $this->string(64)->notNull()->unique(),
'data' => $this->text(),
'created_at' => $this->unixTimestamp(),
'updated_at' => $this->unixTimestamp()
], $tableOptions);
$this->createTable('{{%admin_auth_item}}', [
'name' => $this->string(64)->notNull()->unique(),
'type' => $this->integer()->notNull(),
'description' => $this->text(),
'rule_name' => $this->string(64),
'data' => $this->text(),
'created_at' => $this->unixTimestamp(),
'updated_at' => $this->unixTimestamp(),
], $tableOptions);
$this->createIndex('idx-auth_item-type', '{{%admin_auth_item}}', 'type');
$this->addForeignKey('admin_auth_item_fk_1', '{{%admin_auth_item}}', 'rule_name', '{{%admin_auth_rule}}', 'name', 'SET NULL', 'CASCADE');
$this->createTable('{{%admin_auth_item_child}}', [
'parent' => $this->string(64)->notNull(),
'child' => $this->string(64)->notNull(),
], $tableOptions);
$this->addPrimaryKey('', '{{%admin_auth_item_child}}', ['parent', 'child']);
$this->addForeignKey('admin_auth_item_child_fk_1', '{{%admin_auth_item_child}}', 'parent', '{{%admin_auth_item}}', 'name', 'CASCADE', 'CASCADE');
$this->addForeignKey('admin_auth_item_child_fk_2', '{{%admin_auth_item_child}}', 'child', '{{%admin_auth_item}}', 'name', 'CASCADE', 'CASCADE');
$this->createTable('{{%admin_auth_assignment}}', [
'item_name' => $this->string(64)->notNull(),
'user_id' => $this->string(64)->notNull(),
'created_at' => $this->unixTimestamp(),
], $tableOptions);
$this->addPrimaryKey('', '{{%admin_auth_assignment}}', ['item_name', 'user_id']);
$this->addForeignKey('{{%admin_auth_assignment_ibfk_1}}', '{{%admin_auth_assignment}}', 'item_name', '{{%admin_auth_item}}', 'name', 'CASCADE', 'CASCADE');
//添加规则
$this->insert('{{%admin_auth_rule}}', ['name' => 'GuestRule', 'data' => 'O:21:"yuncms\rbac\GuestRule":3:{s:4:"name";s:9:"GuestRule";s:9:"createdAt";i:1522062274;s:9:"updatedAt";i:1522062274;}', 'created_at' => time(), 'updated_at' => time()]);
$this->insert('{{%admin_auth_rule}}', ['name' => 'RouteRule', 'data' => 'O:21:"yuncms\rbac\RouteRule":3:{s:4:"name";s:9:"RouteRule";s:9:"createdAt";i:1522062288;s:9:"updatedAt";i:1522062288;}', 'created_at' => time(), 'updated_at' => time()]);
//添加角色
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'description', 'rule_name', 'created_at', 'updated_at'], [
['Super Administrator', 1, '超级管理员对系统有不受限制的完全访问权。', 'RouteRule', $time, $time],
['Administrator', 1, '防止管理员进行有意或无意的系统范围的更改,但是可以执行大部分管理操作。', 'RouteRule', $time, $time],
]);
//添加路由
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'created_at', 'updated_at'], [
['/*', 2, $time, $time],
['/site/*', 2, $time, $time],
['/site/index', 2, $time, $time],
['/admin/security/logout', 2, $time, $time],
['/admin/admin/*', 2, $time, $time],
['/admin/admin/create', 2, $time, $time],
['/admin/admin/delete', 2, $time, $time],
['/admin/admin/index', 2, $time, $time],
['/admin/admin/update', 2, $time, $time],
['/admin/admin/view', 2, $time, $time],
['/admin/assignment/*', 2, $time, $time],
['/admin/assignment/assign', 2, $time, $time],
['/admin/assignment/index', 2, $time, $time],
['/admin/assignment/revoke', 2, $time, $time],
['/admin/assignment/view', 2, $time, $time],
['/admin/attachment/*', 2, $time, $time],
['/admin/attachment/batch-delete', 2, $time, $time],
['/admin/attachment/delete', 2, $time, $time],
['/admin/attachment/index', 2, $time, $time],
['/admin/attachment/setting', 2, $time, $time],
['/admin/attachment/view', 2, $time, $time],
['/admin/menu/*', 2, $time, $time],
['/admin/menu/auto-complete', 2, $time, $time],
['/admin/menu/create', 2, $time, $time],
['/admin/menu/delete', 2, $time, $time],
['/admin/menu/index', 2, $time, $time],
['/admin/menu/position', 2, $time, $time],
['/admin/menu/update', 2, $time, $time],
['/admin/menu/view', 2, $time, $time],
['/admin/oauth2/*', 2, $time, $time],
['/admin/oauth2/batch-delete', 2, $time, $time],
['/admin/oauth2/create', 2, $time, $time],
['/admin/oauth2/delete', 2, $time, $time],
['/admin/oauth2/index', 2, $time, $time],
['/admin/oauth2/update', 2, $time, $time],
['/admin/oauth2/view', 2, $time, $time],
['/admin/permission/*', 2, $time, $time],
['/admin/permission/assign', 2, $time, $time],
['/admin/permission/create', 2, $time, $time],
['/admin/permission/delete', 2, $time, $time],
['/admin/permission/index', 2, $time, $time],
['/admin/permission/remove', 2, $time, $time],
['/admin/permission/update', 2, $time, $time],
['/admin/permission/view', 2, $time, $time],
['/admin/queue/*', 2, $time, $time],
['/admin/role/*', 2, $time, $time],
['/admin/role/assign', 2, $time, $time],
['/admin/role/create', 2, $time, $time],
['/admin/role/delete', 2, $time, $time],
['/admin/role/index', 2, $time, $time],
['/admin/role/remove', 2, $time, $time],
['/admin/role/update', 2, $time, $time],
['/admin/role/view', 2, $time, $time],
['/admin/route/*', 2, $time, $time],
['/admin/route/assign', 2, $time, $time],
['/admin/route/create', 2, $time, $time],
['/admin/route/index', 2, $time, $time],
['/admin/route/refresh', 2, $time, $time],
['/admin/route/remove', 2, $time, $time],
['/admin/rule/*', 2, $time, $time],
['/admin/rule/create', 2, $time, $time],
['/admin/rule/delete', 2, $time, $time],
['/admin/rule/index', 2, $time, $time],
['/admin/rule/update', 2, $time, $time],
['/admin/rule/view', 2, $time, $time],
['/admin/security/*', 2, $time, $time],
['/admin/security/captcha', 2, $time, $time],
['/admin/setting/*', 2, $time, $time],
['/admin/setting/setting', 2, $time, $time],
['/admin/user/*', 2, $time, $time],
['/admin/user/block', 2, $time, $time],
['/admin/user/confirm', 2, $time, $time],
['/admin/user/create', 2, $time, $time],
['/admin/user/delete', 2, $time, $time],
['/admin/user/index', 2, $time, $time],
['/admin/user/settings', 2, $time, $time],
['/admin/user/update', 2, $time, $time],
['/admin/user/update-profile', 2, $time, $time],
['/admin/user/view', 2, $time, $time],
['/upload/*', 2, $time, $time],
['/upload/file-upload', 2, $time, $time],
['/upload/files-upload', 2, $time, $time],
['/upload/image-upload', 2, $time, $time],
['/upload/images-upload', 2, $time, $time],
]);
//给超级管理员组授权
$this->insert('{{%admin_auth_item_child}}', ['parent' => 'Super Administrator', 'child' => '/*']);
$this->insert('{{%admin_auth_assignment}}', ['item_name' => 'Super Administrator', 'user_id' => 1, 'created_at' => $time]);
//新建权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['核心设置', 2, 'RouteRule', $time, $time],
['站点设置', 2, 'RouteRule', $time, $time],
['附件上传', 2, 'RouteRule', $time, $time],
['附件设置', 2, 'RouteRule', $time, $time],
]);
//管理授权
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['站点设置', '/admin/setting/setting'],
['附件上传', '/upload/*'],
['附件上传', '/upload/file-upload'],
['附件上传', '/upload/files-upload'],
['附件上传', '/upload/image-upload'],
['附件上传', '/upload/images-upload'],
['附件设置', '/admin/attachment/setting'],
]);
//管理员相关权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['管理员管理', 2, 'RouteRule', $time, $time],
['管理员列表', 2, 'RouteRule', $time, $time],
['管理员查看', 2, 'RouteRule', $time, $time],
['管理员创建', 2, 'RouteRule', $time, $time],
['管理员删除', 2, 'RouteRule', $time, $time],
['管理员修改', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['管理员创建', '/admin/admin/create'],
['管理员删除', '/admin/admin/delete'],
['管理员列表', '/admin/admin/index'],
['管理员修改', '/admin/admin/update'],
['管理员查看', '/admin/admin/view'],
['管理员管理', '/admin/admin/*'],
['管理员管理', '管理员创建'],
['管理员管理', '管理员删除'],
['管理员管理', '管理员查看'],
['管理员管理', '管理员修改'],
['管理员管理', '管理员列表'],
]);
//角色相关权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['角色管理', 2, 'RouteRule', $time, $time],
['角色授权', 2, 'RouteRule', $time, $time],
['角色创建', 2, 'RouteRule', $time, $time],
['角色删除', 2, 'RouteRule', $time, $time],
['角色列表查看', 2, 'RouteRule', $time, $time],
['角色授权或删除', 2, 'RouteRule', $time, $time],
['角色更新', 2, 'RouteRule', $time, $time],
['角色查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['角色授权', '/admin/role/assign'],
['角色创建', '/admin/role/create'],
['角色删除', '/admin/role/delete'],
['角色列表查看', '/admin/role/index'],
['角色授权或删除', '/admin/role/remove'],
['角色更新', '/admin/role/update'],
['角色查看', '/admin/role/view'],
['角色管理', '/admin/role/*'],
['角色管理', '角色列表查看'],
['角色管理', '角色授权'],
['角色管理', '角色创建'],
['角色管理', '角色删除'],
['角色管理', '角色查看'],
['角色管理', '角色授权或删除'],
['角色管理', '角色更新'],
]);
//权限管理权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['权限管理', 2, 'RouteRule', $time, $time],
['权限授权', 2, 'RouteRule', $time, $time],
['权限创建', 2, 'RouteRule', $time, $time],
['权限删除', 2, 'RouteRule', $time, $time],
['权限列表', 2, 'RouteRule', $time, $time],
['权限授权或删除', 2, 'RouteRule', $time, $time],
['权限更新', 2, 'RouteRule', $time, $time],
['权限查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['权限授权', '/admin/permission/assign'],
['权限创建', '/admin/permission/create'],
['权限删除', '/admin/permission/delete'],
['权限列表', '/admin/permission/index'],
['权限授权或删除', '/admin/permission/remove'],
['权限更新', '/admin/permission/update'],
['权限查看', '/admin/permission/view'],
['权限管理', '/admin/permission/*'],
['权限管理', '权限授权'],
['权限管理', '权限创建'],
['权限管理', '权限删除'],
['权限管理', '权限列表'],
['权限管理', '权限授权或删除'],
['权限管理', '权限更新'],
['权限管理', '权限查看'],
]);
//路由权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['路由管理', 2, 'RouteRule', $time, $time],
['路由授权', 2, 'RouteRule', $time, $time],
['路由创建', 2, 'RouteRule', $time, $time],
['路由列表', 2, 'RouteRule', $time, $time],
['路由刷新', 2, 'RouteRule', $time, $time],
['路由删除', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['路由授权', '/admin/route/assign'],
['路由创建', '/admin/route/create'],
['路由列表', '/admin/route/index'],
['路由刷新', '/admin/route/refresh'],
['路由删除', '/admin/route/remove'],
['路由管理', '/admin/route/*'],
['路由管理', '路由授权'],
['路由管理', '路由创建'],
['路由管理', '路由列表'],
['路由管理', '路由刷新'],
['路由管理', '路由删除'],
]);
//规则管理
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['规则管理', 2, 'RouteRule', $time, $time],
['规则创建', 2, 'RouteRule', $time, $time],
['规则删除', 2, 'RouteRule', $time, $time],
['规则列表', 2, 'RouteRule', $time, $time],
['规则更新', 2, 'RouteRule', $time, $time],
['规则查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['规则创建', '/admin/rule/create'],
['规则删除', '/admin/rule/delete'],
['规则列表', '/admin/rule/index'],
['规则更新', '/admin/rule/update'],
['规则查看', '/admin/rule/view'],
['规则管理', '/admin/rule/*'],
['规则管理', '规则创建'],
['规则管理', '规则删除'],
['规则管理', '规则列表'],
['规则管理', '规则更新'],
['规则管理', '规则查看'],
]);
//菜单权限
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['菜单管理', 2, 'RouteRule', $time, $time],
['菜单自动下拉提醒', 2, 'RouteRule', $time, $time],
['菜单创建', 2, 'RouteRule', $time, $time],
['菜单删除', 2, 'RouteRule', $time, $time],
['菜单列表', 2, 'RouteRule', $time, $time],
['菜单排序', 2, 'RouteRule', $time, $time],
['菜单更新', 2, 'RouteRule', $time, $time],
['菜单查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['菜单自动下拉提醒', '/admin/menu/auto-complete'],
['菜单创建', '/admin/menu/create'],
['菜单删除', '/admin/menu/delete'],
['菜单列表', '/admin/menu/index'],
['菜单排序', '/admin/menu/position'],
['菜单更新', '/admin/menu/update'],
['菜单查看', '/admin/menu/view'],
['菜单管理', '/admin/menu/*'],
['菜单管理', '菜单自动下拉提醒'],
['菜单管理', '菜单创建'],
['菜单管理', '菜单删除'],
['菜单管理', '菜单列表'],
['菜单管理', '菜单排序'],
['菜单管理', '菜单更新'],
['菜单管理', '菜单查看'],
]);
// 用户管理
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['用户管理', 2, 'RouteRule', $time, $time],
['用户封锁', 2, 'RouteRule', $time, $time],
['用户激活', 2, 'RouteRule', $time, $time],
['用户创建', 2, 'RouteRule', $time, $time],
['用户删除', 2, 'RouteRule', $time, $time],
['用户列表', 2, 'RouteRule', $time, $time],
['用户模块设置', 2, 'RouteRule', $time, $time],
['用户更新', 2, 'RouteRule', $time, $time],
['用户更新个人资料', 2, 'RouteRule', $time, $time],
['用户查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['用户封锁', '/admin/user/block'],
['用户激活', '/admin/user/confirm'],
['用户创建', '/admin/user/create'],
['用户删除', '/admin/user/delete'],
['用户列表', '/admin/user/index'],
['用户模块设置', '/admin/user/settings'],
['用户更新', '/admin/user/update'],
['用户更新个人资料', '/admin/user/update-profile'],
['用户查看', '/admin/user/view'],
['用户管理', '/admin/user/*'],
['用户管理', '用户封锁'],
['用户管理', '用户激活'],
['用户管理', '用户创建'],
['用户管理', '用户删除'],
['用户管理', '用户列表'],
['用户管理', '用户模块设置'],
['用户管理', '用户更新个人资料'],
['用户管理', '用户查看'],
]);
// OAuth2
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['OAuth2管理', 2, 'RouteRule', $time, $time],
['OAuth2批量删除', 2, 'RouteRule', $time, $time],
['OAuth2创建', 2, 'RouteRule', $time, $time],
['OAuth2删除', 2, 'RouteRule', $time, $time],
['OAuth2列表', 2, 'RouteRule', $time, $time],
['OAuth2更新', 2, 'RouteRule', $time, $time],
['OAuth2查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['OAuth2批量删除', '/admin/oauth2/batch-delete'],
['OAuth2创建', '/admin/oauth2/create'],
['OAuth2删除', '/admin/oauth2/delete'],
['OAuth2列表', '/admin/oauth2/index'],
['OAuth2更新', '/admin/oauth2/update'],
['OAuth2查看', '/admin/oauth2/view'],
['OAuth2管理', '/admin/oauth2/*'],
['OAuth2管理', 'OAuth2批量删除'],
['OAuth2管理', 'OAuth2创建'],
['OAuth2管理', 'OAuth2删除'],
['OAuth2管理', 'OAuth2列表'],
['OAuth2管理', 'OAuth2更新'],
['OAuth2管理', 'OAuth2查看'],
]);
// 附件管理
$this->batchInsert('{{%admin_auth_item}}', ['name', 'type', 'rule_name', 'created_at', 'updated_at'], [
['附件管理', 2, 'RouteRule', $time, $time],
['附件列表', 2, 'RouteRule', $time, $time],
['附件批量删除', 2, 'RouteRule', $time, $time],
['附件删除', 2, 'RouteRule', $time, $time],
['附件查看', 2, 'RouteRule', $time, $time],
]);
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['附件列表', '/admin/attachment/index'],
['附件批量删除', '/admin/attachment/batch-delete'],
['附件删除', '/admin/attachment/delete'],
['附件查看', '/admin/attachment/view'],
['附件管理', '/admin/attachment/*'],
['附件管理', '附件列表'],
['附件管理', '附件批量删除'],
['附件管理', '附件删除'],
['附件管理', '附件查看'],
]);
//管理授权
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['核心设置', '站点设置'],
['核心设置', '管理员管理'],
['核心设置', '角色管理'],
['核心设置', '权限管理'],
['核心设置', '路由管理'],
['核心设置', '规则管理'],
['核心设置', '菜单管理'],
['核心设置', '附件设置'],
]);
//给 Administrator 授权
$this->batchInsert('{{%admin_auth_item_child}}', ['parent', 'child'], [
['Administrator', '/site/index'],
['Administrator', '用户管理'],
['Administrator', '附件上传'],
['Administrator', '附件管理'],
]);
} | [
"public",
"function",
"safeUp",
"(",
")",
"{",
"$",
"tableOptions",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"driverName",
"===",
"'mysql'",
")",
"{",
"// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci",
"$",
"tableOptions",
"=",
"'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB'",
";",
"}",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"createTable",
"(",
"'{{%admin_auth_rule}}'",
",",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"notNull",
"(",
")",
"->",
"unique",
"(",
")",
",",
"'data'",
"=>",
"$",
"this",
"->",
"text",
"(",
")",
",",
"'created_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
",",
"'updated_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
"]",
",",
"$",
"tableOptions",
")",
";",
"$",
"this",
"->",
"createTable",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"notNull",
"(",
")",
"->",
"unique",
"(",
")",
",",
"'type'",
"=>",
"$",
"this",
"->",
"integer",
"(",
")",
"->",
"notNull",
"(",
")",
",",
"'description'",
"=>",
"$",
"this",
"->",
"text",
"(",
")",
",",
"'rule_name'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
",",
"'data'",
"=>",
"$",
"this",
"->",
"text",
"(",
")",
",",
"'created_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
",",
"'updated_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
",",
"]",
",",
"$",
"tableOptions",
")",
";",
"$",
"this",
"->",
"createIndex",
"(",
"'idx-auth_item-type'",
",",
"'{{%admin_auth_item}}'",
",",
"'type'",
")",
";",
"$",
"this",
"->",
"addForeignKey",
"(",
"'admin_auth_item_fk_1'",
",",
"'{{%admin_auth_item}}'",
",",
"'rule_name'",
",",
"'{{%admin_auth_rule}}'",
",",
"'name'",
",",
"'SET NULL'",
",",
"'CASCADE'",
")",
";",
"$",
"this",
"->",
"createTable",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"notNull",
"(",
")",
",",
"'child'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"notNull",
"(",
")",
",",
"]",
",",
"$",
"tableOptions",
")",
";",
"$",
"this",
"->",
"addPrimaryKey",
"(",
"''",
",",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
")",
";",
"$",
"this",
"->",
"addForeignKey",
"(",
"'admin_auth_item_child_fk_1'",
",",
"'{{%admin_auth_item_child}}'",
",",
"'parent'",
",",
"'{{%admin_auth_item}}'",
",",
"'name'",
",",
"'CASCADE'",
",",
"'CASCADE'",
")",
";",
"$",
"this",
"->",
"addForeignKey",
"(",
"'admin_auth_item_child_fk_2'",
",",
"'{{%admin_auth_item_child}}'",
",",
"'child'",
",",
"'{{%admin_auth_item}}'",
",",
"'name'",
",",
"'CASCADE'",
",",
"'CASCADE'",
")",
";",
"$",
"this",
"->",
"createTable",
"(",
"'{{%admin_auth_assignment}}'",
",",
"[",
"'item_name'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"notNull",
"(",
")",
",",
"'user_id'",
"=>",
"$",
"this",
"->",
"string",
"(",
"64",
")",
"->",
"notNull",
"(",
")",
",",
"'created_at'",
"=>",
"$",
"this",
"->",
"unixTimestamp",
"(",
")",
",",
"]",
",",
"$",
"tableOptions",
")",
";",
"$",
"this",
"->",
"addPrimaryKey",
"(",
"''",
",",
"'{{%admin_auth_assignment}}'",
",",
"[",
"'item_name'",
",",
"'user_id'",
"]",
")",
";",
"$",
"this",
"->",
"addForeignKey",
"(",
"'{{%admin_auth_assignment_ibfk_1}}'",
",",
"'{{%admin_auth_assignment}}'",
",",
"'item_name'",
",",
"'{{%admin_auth_item}}'",
",",
"'name'",
",",
"'CASCADE'",
",",
"'CASCADE'",
")",
";",
"//添加规则",
"$",
"this",
"->",
"insert",
"(",
"'{{%admin_auth_rule}}'",
",",
"[",
"'name'",
"=>",
"'GuestRule'",
",",
"'data'",
"=>",
"'O:21:\"yuncms\\rbac\\GuestRule\":3:{s:4:\"name\";s:9:\"GuestRule\";s:9:\"createdAt\";i:1522062274;s:9:\"updatedAt\";i:1522062274;}'",
",",
"'created_at'",
"=>",
"time",
"(",
")",
",",
"'updated_at'",
"=>",
"time",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"insert",
"(",
"'{{%admin_auth_rule}}'",
",",
"[",
"'name'",
"=>",
"'RouteRule'",
",",
"'data'",
"=>",
"'O:21:\"yuncms\\rbac\\RouteRule\":3:{s:4:\"name\";s:9:\"RouteRule\";s:9:\"createdAt\";i:1522062288;s:9:\"updatedAt\";i:1522062288;}'",
",",
"'created_at'",
"=>",
"time",
"(",
")",
",",
"'updated_at'",
"=>",
"time",
"(",
")",
"]",
")",
";",
"//添加角色",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'description'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'Super Administrator'",
",",
"1",
",",
"'超级管理员对系统有不受限制的完全访问权。', 'RouteRule', $time, $time],",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"[",
"'Administrator'",
",",
"1",
",",
"'防止管理员进行有意或无意的系统范围的更改,但是可以执行大部分管理操作。', 'RouteRule', $time, $time],",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"]",
")",
";",
"//添加路由",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/site/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/site/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/security/logout'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/admin/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/admin/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/admin/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/admin/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/admin/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/admin/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/assignment/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/assignment/assign'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/assignment/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/assignment/revoke'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/assignment/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/attachment/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/attachment/batch-delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/attachment/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/attachment/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/attachment/setting'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/attachment/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/auto-complete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/position'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/menu/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/batch-delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/oauth2/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/assign'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/remove'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/permission/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/queue/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/assign'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/remove'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/role/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/route/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/route/assign'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/route/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/route/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/route/refresh'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/route/remove'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/rule/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/rule/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/rule/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/rule/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/rule/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/rule/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/security/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/security/captcha'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/setting/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/setting/setting'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/block'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/confirm'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/create'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/delete'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/index'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/settings'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/update'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/update-profile'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/admin/user/view'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/upload/*'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/upload/file-upload'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/upload/files-upload'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/upload/image-upload'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"[",
"'/upload/images-upload'",
",",
"2",
",",
"$",
"time",
",",
"$",
"time",
"]",
",",
"]",
")",
";",
"//给超级管理员组授权",
"$",
"this",
"->",
"insert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
"=>",
"'Super Administrator'",
",",
"'child'",
"=>",
"'/*'",
"]",
")",
";",
"$",
"this",
"->",
"insert",
"(",
"'{{%admin_auth_assignment}}'",
",",
"[",
"'item_name'",
"=>",
"'Super Administrator'",
",",
"'user_id'",
"=>",
"1",
",",
"'created_at'",
"=>",
"$",
"time",
"]",
")",
";",
"//新建权限",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'核心设置', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'站点设置', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'附件上传', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'附件设置', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"//管理授权",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'站点设置', '/admi",
"n",
"setting/setting'],",
"",
"",
"[",
"'附件上传', '/uplo",
"a",
"/*'],",
"",
"",
"[",
"'附件上传', '/uplo",
"a",
"/file-upload'],",
"",
"",
"[",
"'附件上传', '/uplo",
"a",
"/files-upload'],",
"",
"",
"[",
"'附件上传', '/uplo",
"a",
"/image-upload'],",
"",
"",
"[",
"'附件上传', '/uplo",
"a",
"/images-upload'],",
"",
"",
"[",
"'附件设置', '/admi",
"n",
"attachment/setting'],",
"",
"",
"]",
")",
";",
"//管理员相关权限",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'管理员管理', 2, 'Rout",
"e",
"u",
"l",
"', $time, $",
"t",
"m",
"e],",
"",
"",
"",
"",
"",
"[",
"'管理员列表', 2, 'Rout",
"e",
"u",
"l",
"', $time, $",
"t",
"m",
"e],",
"",
"",
"",
"",
"",
"[",
"'管理员查看', 2, 'Rout",
"e",
"u",
"l",
"', $time, $",
"t",
"m",
"e],",
"",
"",
"",
"",
"",
"[",
"'管理员创建', 2, 'Rout",
"e",
"u",
"l",
"', $time, $",
"t",
"m",
"e],",
"",
"",
"",
"",
"",
"[",
"'管理员删除', 2, 'Rout",
"e",
"u",
"l",
"', $time, $",
"t",
"m",
"e],",
"",
"",
"",
"",
"",
"[",
"'管理员修改', 2, 'Rout",
"e",
"u",
"l",
"', $time, $",
"t",
"m",
"e],",
"",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'管理员创建', '/admin/",
"a",
"min/create'],",
"",
"",
"[",
"'管理员删除', '/admin/",
"a",
"min/delete'],",
"",
"",
"[",
"'管理员列表', '/admin/",
"a",
"min/index'],",
"",
"",
"[",
"'管理员修改', '/admin/",
"a",
"min/update'],",
"",
"",
"[",
"'管理员查看', '/admin/",
"a",
"min/view'],",
"",
"",
"[",
"'管理员管理', '/admin/",
"a",
"min/*'],",
"",
"",
"[",
"'管理员管理', '管理员创建']",
",",
"",
"",
"",
"[",
"'管理员管理', '管理员删除']",
",",
"",
"",
"",
"[",
"'管理员管理', '管理员查看']",
",",
"",
"",
"",
"[",
"'管理员管理', '管理员修改']",
",",
"",
"",
"",
"[",
"'管理员管理', '管理员列表']",
",",
"",
"",
"",
"]",
")",
";",
"//角色相关权限",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'角色管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'角色授权', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'角色创建', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'角色删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'角色列表查看', 2, 'RouteR",
"u",
"e",
"'",
" $time, $ti",
"m",
"]",
",",
"",
"",
"",
"",
"",
"[",
"'角色授权或删除', 2, 'RouteRul",
"e",
",",
" ",
"time, $time",
"]",
"",
"",
"",
"",
"",
"",
"",
"[",
"'角色更新', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'角色查看', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'角色授权', '/admi",
"n",
"role/assign'],",
"",
"",
"[",
"'角色创建', '/admi",
"n",
"role/create'],",
"",
"",
"[",
"'角色删除', '/admi",
"n",
"role/delete'],",
"",
"",
"[",
"'角色列表查看', '/admin/ro",
"l",
"/index'],",
"",
"",
"[",
"'角色授权或删除', '/admin/role",
"/",
"emove'],",
"",
"",
"[",
"'角色更新', '/admi",
"n",
"role/update'],",
"",
"",
"[",
"'角色查看', '/admi",
"n",
"role/view'],",
"",
"",
"[",
"'角色管理', '/admi",
"n",
"role/*'],",
"",
"",
"[",
"'角色管理', '角色列表查",
"看",
"],",
"",
"",
"[",
"'角色管理', '角色授权'",
"]",
"",
"",
"",
"[",
"'角色管理', '角色创建'",
"]",
"",
"",
"",
"[",
"'角色管理', '角色删除'",
"]",
"",
"",
"",
"[",
"'角色管理', '角色查看'",
"]",
"",
"",
"",
"[",
"'角色管理', '角色授权或",
"删",
"'],",
"",
"",
"[",
"'角色管理', '角色更新'",
"]",
"",
"",
"",
"]",
")",
";",
"//权限管理权限",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'权限管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'权限授权', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'权限创建', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'权限删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'权限列表', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'权限授权或删除', 2, 'RouteRul",
"e",
",",
" ",
"time, $time",
"]",
"",
"",
"",
"",
"",
"",
"",
"[",
"'权限更新', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'权限查看', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'权限授权', '/admi",
"n",
"permission/assign'],",
"",
"",
"[",
"'权限创建', '/admi",
"n",
"permission/create'],",
"",
"",
"[",
"'权限删除', '/admi",
"n",
"permission/delete'],",
"",
"",
"[",
"'权限列表', '/admi",
"n",
"permission/index'],",
"",
"",
"[",
"'权限授权或删除', '/admin/perm",
"i",
"sion/remove'],",
"",
"",
"[",
"'权限更新', '/admi",
"n",
"permission/update'],",
"",
"",
"[",
"'权限查看', '/admi",
"n",
"permission/view'],",
"",
"",
"[",
"'权限管理', '/admi",
"n",
"permission/*'],",
"",
"",
"[",
"'权限管理', '权限授权'",
"]",
"",
"",
"",
"[",
"'权限管理', '权限创建'",
"]",
"",
"",
"",
"[",
"'权限管理', '权限删除'",
"]",
"",
"",
"",
"[",
"'权限管理', '权限列表'",
"]",
"",
"",
"",
"[",
"'权限管理', '权限授权或",
"删",
"'],",
"",
"",
"[",
"'权限管理', '权限更新'",
"]",
"",
"",
"",
"[",
"'权限管理', '权限查看'",
"]",
"",
"",
"",
"]",
")",
";",
"//路由权限",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'路由管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'路由授权', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'路由创建', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'路由列表', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'路由刷新', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'路由删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'路由授权', '/admi",
"n",
"route/assign'],",
"",
"",
"[",
"'路由创建', '/admi",
"n",
"route/create'],",
"",
"",
"[",
"'路由列表', '/admi",
"n",
"route/index'],",
"",
"",
"[",
"'路由刷新', '/admi",
"n",
"route/refresh'],",
"",
"",
"[",
"'路由删除', '/admi",
"n",
"route/remove'],",
"",
"",
"[",
"'路由管理', '/admi",
"n",
"route/*'],",
"",
"",
"[",
"'路由管理', '路由授权'",
"]",
"",
"",
"",
"[",
"'路由管理', '路由创建'",
"]",
"",
"",
"",
"[",
"'路由管理', '路由列表'",
"]",
"",
"",
"",
"[",
"'路由管理', '路由刷新'",
"]",
"",
"",
"",
"[",
"'路由管理', '路由删除'",
"]",
"",
"",
"",
"]",
")",
";",
"//规则管理",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'规则管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'规则创建', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'规则删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'规则列表', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'规则更新', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'规则查看', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'规则创建', '/admi",
"n",
"rule/create'],",
"",
"",
"[",
"'规则删除', '/admi",
"n",
"rule/delete'],",
"",
"",
"[",
"'规则列表', '/admi",
"n",
"rule/index'],",
"",
"",
"[",
"'规则更新', '/admi",
"n",
"rule/update'],",
"",
"",
"[",
"'规则查看', '/admi",
"n",
"rule/view'],",
"",
"",
"[",
"'规则管理', '/admi",
"n",
"rule/*'],",
"",
"",
"[",
"'规则管理', '规则创建'",
"]",
"",
"",
"",
"[",
"'规则管理', '规则删除'",
"]",
"",
"",
"",
"[",
"'规则管理', '规则列表'",
"]",
"",
"",
"",
"[",
"'规则管理', '规则更新'",
"]",
"",
"",
"",
"[",
"'规则管理', '规则查看'",
"]",
"",
"",
"",
"]",
")",
";",
"//菜单权限",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'菜单管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'菜单自动下拉提醒', 2, 'RouteRule'",
",",
"$",
"t",
"me, $time],",
"",
"",
"",
"",
"",
"",
"",
"",
"[",
"'菜单创建', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'菜单删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'菜单列表', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'菜单排序', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'菜单更新', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'菜单查看', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'菜单自动下拉提醒', '/admin/menu/a",
"u",
"o-complete'],",
"",
"",
"[",
"'菜单创建', '/admi",
"n",
"menu/create'],",
"",
"",
"[",
"'菜单删除', '/admi",
"n",
"menu/delete'],",
"",
"",
"[",
"'菜单列表', '/admi",
"n",
"menu/index'],",
"",
"",
"[",
"'菜单排序', '/admi",
"n",
"menu/position'],",
"",
"",
"[",
"'菜单更新', '/admi",
"n",
"menu/update'],",
"",
"",
"[",
"'菜单查看', '/admi",
"n",
"menu/view'],",
"",
"",
"[",
"'菜单管理', '/admi",
"n",
"menu/*'],",
"",
"",
"[",
"'菜单管理', '菜单自动下",
"拉",
"醒'],",
"",
"",
"[",
"'菜单管理', '菜单创建'",
"]",
"",
"",
"",
"[",
"'菜单管理', '菜单删除'",
"]",
"",
"",
"",
"[",
"'菜单管理', '菜单列表'",
"]",
"",
"",
"",
"[",
"'菜单管理', '菜单排序'",
"]",
"",
"",
"",
"[",
"'菜单管理', '菜单更新'",
"]",
"",
"",
"",
"[",
"'菜单管理', '菜单查看'",
"]",
"",
"",
"",
"]",
")",
";",
"// 用户管理",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'用户管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户封锁', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户激活', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户创建', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户列表', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户模块设置', 2, 'RouteR",
"u",
"e",
"'",
" $time, $ti",
"m",
"]",
",",
"",
"",
"",
"",
"",
"[",
"'用户更新', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'用户更新个人资料', 2, 'RouteRule'",
",",
"$",
"t",
"me, $time],",
"",
"",
"",
"",
"",
"",
"",
"",
"[",
"'用户查看', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'用户封锁', '/admi",
"n",
"user/block'],",
"",
"",
"[",
"'用户激活', '/admi",
"n",
"user/confirm'],",
"",
"",
"[",
"'用户创建', '/admi",
"n",
"user/create'],",
"",
"",
"[",
"'用户删除', '/admi",
"n",
"user/delete'],",
"",
"",
"[",
"'用户列表', '/admi",
"n",
"user/index'],",
"",
"",
"[",
"'用户模块设置', '/admin/us",
"e",
"/settings'],",
"",
"",
"[",
"'用户更新', '/admi",
"n",
"user/update'],",
"",
"",
"[",
"'用户更新个人资料', '/admin/user/u",
"p",
"ate-profile'],",
"",
"",
"[",
"'用户查看', '/admi",
"n",
"user/view'],",
"",
"",
"[",
"'用户管理', '/admi",
"n",
"user/*'],",
"",
"",
"[",
"'用户管理', '用户封锁'",
"]",
"",
"",
"",
"[",
"'用户管理', '用户激活'",
"]",
"",
"",
"",
"[",
"'用户管理', '用户创建'",
"]",
"",
"",
"",
"[",
"'用户管理', '用户删除'",
"]",
"",
"",
"",
"[",
"'用户管理', '用户列表'",
"]",
"",
"",
"",
"[",
"'用户管理', '用户模块设",
"置",
"],",
"",
"",
"[",
"'用户管理', '用户更新个",
"人",
"料'],",
"",
"",
"[",
"'用户管理', '用户查看'",
"]",
"",
"",
"",
"]",
")",
";",
"// OAuth2",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'OAuth2管理', 2,",
" ",
"R",
"o",
"teRule', $t",
"i",
"e",
", $t",
"i",
"e",
"],",
"",
"",
"[",
"'OAuth2批量删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'OAuth2创建', 2,",
" ",
"R",
"o",
"teRule', $t",
"i",
"e",
", $t",
"i",
"e",
"],",
"",
"",
"[",
"'OAuth2删除', 2,",
" ",
"R",
"o",
"teRule', $t",
"i",
"e",
", $t",
"i",
"e",
"],",
"",
"",
"[",
"'OAuth2列表', 2,",
" ",
"R",
"o",
"teRule', $t",
"i",
"e",
", $t",
"i",
"e",
"],",
"",
"",
"[",
"'OAuth2更新', 2,",
" ",
"R",
"o",
"teRule', $t",
"i",
"e",
", $t",
"i",
"e",
"],",
"",
"",
"[",
"'OAuth2查看', 2,",
" ",
"R",
"o",
"teRule', $t",
"i",
"e",
", $t",
"i",
"e",
"],",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'OAuth2批量删除', '/admi",
"n",
"oauth2/batch-delete'],",
"",
"",
"[",
"'OAuth2创建', '/",
"a",
"min/oauth2/create'],",
"",
"",
"[",
"'OAuth2删除', '/",
"a",
"min/oauth2/delete'],",
"",
"",
"[",
"'OAuth2列表', '/",
"a",
"min/oauth2/index'],",
"",
"",
"[",
"'OAuth2更新', '/",
"a",
"min/oauth2/update'],",
"",
"",
"[",
"'OAuth2查看', '/",
"a",
"min/oauth2/view'],",
"",
"",
"[",
"'OAuth2管理', '/",
"a",
"min/oauth2/*'],",
"",
"",
"[",
"'OAuth2管理', 'O",
"A",
"th2批量删除'],",
"",
"",
"[",
"'OAuth2管理', 'O",
"A",
"th2创建'],",
"",
"",
"[",
"'OAuth2管理', 'O",
"A",
"th2删除'],",
"",
"",
"[",
"'OAuth2管理', 'O",
"A",
"th2列表'],",
"",
"",
"[",
"'OAuth2管理', 'O",
"A",
"th2更新'],",
"",
"",
"[",
"'OAuth2管理', 'O",
"A",
"th2查看'],",
"",
"",
"]",
")",
";",
"// 附件管理",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item}}'",
",",
"[",
"'name'",
",",
"'type'",
",",
"'rule_name'",
",",
"'created_at'",
",",
"'updated_at'",
"]",
",",
"[",
"[",
"'附件管理', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'附件列表', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'附件批量删除', 2, 'RouteR",
"u",
"e",
"'",
" $time, $ti",
"m",
"]",
",",
"",
"",
"",
"",
"",
"[",
"'附件删除', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"[",
"'附件查看', 2, 'Ro",
"u",
"e",
"R",
"le', $time,",
" ",
"t",
"ime]",
",",
"",
"",
"",
"",
"]",
")",
";",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'附件列表', '/admi",
"n",
"attachment/index'],",
"",
"",
"[",
"'附件批量删除', '/admin/at",
"t",
"chment/batch-delete'],",
"",
"",
"[",
"'附件删除', '/admi",
"n",
"attachment/delete'],",
"",
"",
"[",
"'附件查看', '/admi",
"n",
"attachment/view'],",
"",
"",
"[",
"'附件管理', '/admi",
"n",
"attachment/*'],",
"",
"",
"[",
"'附件管理', '附件列表'",
"]",
"",
"",
"",
"[",
"'附件管理', '附件批量删",
"除",
"],",
"",
"",
"[",
"'附件管理', '附件删除'",
"]",
"",
"",
"",
"[",
"'附件管理', '附件查看'",
"]",
"",
"",
"",
"]",
")",
";",
"//管理授权",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'核心设置', '站点设置'",
"]",
"",
"",
"",
"[",
"'核心设置', '管理员管理",
"'",
",",
"",
"",
"[",
"'核心设置', '角色管理'",
"]",
"",
"",
"",
"[",
"'核心设置', '权限管理'",
"]",
"",
"",
"",
"[",
"'核心设置', '路由管理'",
"]",
"",
"",
"",
"[",
"'核心设置', '规则管理'",
"]",
"",
"",
"",
"[",
"'核心设置', '菜单管理'",
"]",
"",
"",
"",
"[",
"'核心设置', '附件设置'",
"]",
"",
"",
"",
"]",
")",
";",
"//给 Administrator 授权",
"$",
"this",
"->",
"batchInsert",
"(",
"'{{%admin_auth_item_child}}'",
",",
"[",
"'parent'",
",",
"'child'",
"]",
",",
"[",
"[",
"'Administrator'",
",",
"'/site/index'",
"]",
",",
"[",
"'Administrator'",
",",
"'用户管理'],",
"",
"",
"[",
"'Administrator'",
",",
"'附件上传'],",
"",
"",
"[",
"'Administrator'",
",",
"'附件管理'],",
"",
"",
"]",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/admin/migrations/m180324_104125_create_admin_rbac_table.php#L13-L437 |
comodojo/cookies | src/Comodojo/Cookies/SecureCookie.php | SecureCookie.encryptKey | protected static function encryptKey($key) {
if ( isset($_SERVER['REMOTE_ADDR']) ) {
$client_hash = md5($_SERVER['REMOTE_ADDR'].(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ''), true);
$server_hash = md5($key, true);
$cookie_key = $client_hash.$server_hash;
} else {
$cookie_key = hash('sha256', $key);
}
return $cookie_key;
} | php | protected static function encryptKey($key) {
if ( isset($_SERVER['REMOTE_ADDR']) ) {
$client_hash = md5($_SERVER['REMOTE_ADDR'].(isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : ''), true);
$server_hash = md5($key, true);
$cookie_key = $client_hash.$server_hash;
} else {
$cookie_key = hash('sha256', $key);
}
return $cookie_key;
} | [
"protected",
"static",
"function",
"encryptKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
")",
")",
"{",
"$",
"client_hash",
"=",
"md5",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
".",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
":",
"''",
")",
",",
"true",
")",
";",
"$",
"server_hash",
"=",
"md5",
"(",
"$",
"key",
",",
"true",
")",
";",
"$",
"cookie_key",
"=",
"$",
"client_hash",
".",
"$",
"server_hash",
";",
"}",
"else",
"{",
"$",
"cookie_key",
"=",
"hash",
"(",
"'sha256'",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"cookie_key",
";",
"}"
] | Create a client-specific key using provided key,
the client remote address and (in case) the value of
HTTP_X_FORWARDED_FOR header
@param string $key
@return string | [
"Create",
"a",
"client",
"-",
"specific",
"key",
"using",
"provided",
"key",
"the",
"client",
"remote",
"address",
"and",
"(",
"in",
"case",
")",
"the",
"value",
"of",
"HTTP_X_FORWARDED_FOR",
"header"
] | train | https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/SecureCookie.php#L32-L50 |
vi-kon/laravel-auth | src/ViKon/Auth/Middleware/PermissionMiddleware.php | PermissionMiddleware.handle | public function handle(Request $request, \Closure $next, $permission)
{
if (!$this->keeper->check() || !$this->keeper->hasPermission($permission)) {
$router = $this->container->make('router');
$log = $this->container->make('log');
$currentRoute = $router->current();
// If user is not authenticated redirect to login route
if (!$this->keeper->check()) {
$config = $this->container->make('config');
$redirect = $this->container->make('redirect');
$url = $this->container->make('url');
$log->notice('Guest redirected to login screen', [
'from' => $currentRoute->getName(),
'to' => $config->get('vi-kon.auth.login.route'),
]);
return $redirect->guest($url->route($config->get('vi-kon.auth.login.route')));
}
// If user is authenticated but has no permission to access given route then redirect to 403 route
if (!$this->keeper->hasPermission($permission)) {
$log->notice('User has no permission to view page', [
'user' => $this->keeper->user()->toArray(),
'permission' => $permission,
'route' => $currentRoute->getName(),
]);
throw new AccessDeniedHttpException();
}
}
return $next($request);
} | php | public function handle(Request $request, \Closure $next, $permission)
{
if (!$this->keeper->check() || !$this->keeper->hasPermission($permission)) {
$router = $this->container->make('router');
$log = $this->container->make('log');
$currentRoute = $router->current();
// If user is not authenticated redirect to login route
if (!$this->keeper->check()) {
$config = $this->container->make('config');
$redirect = $this->container->make('redirect');
$url = $this->container->make('url');
$log->notice('Guest redirected to login screen', [
'from' => $currentRoute->getName(),
'to' => $config->get('vi-kon.auth.login.route'),
]);
return $redirect->guest($url->route($config->get('vi-kon.auth.login.route')));
}
// If user is authenticated but has no permission to access given route then redirect to 403 route
if (!$this->keeper->hasPermission($permission)) {
$log->notice('User has no permission to view page', [
'user' => $this->keeper->user()->toArray(),
'permission' => $permission,
'route' => $currentRoute->getName(),
]);
throw new AccessDeniedHttpException();
}
}
return $next($request);
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
",",
"\\",
"Closure",
"$",
"next",
",",
"$",
"permission",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"keeper",
"->",
"check",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"keeper",
"->",
"hasPermission",
"(",
"$",
"permission",
")",
")",
"{",
"$",
"router",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'router'",
")",
";",
"$",
"log",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'log'",
")",
";",
"$",
"currentRoute",
"=",
"$",
"router",
"->",
"current",
"(",
")",
";",
"// If user is not authenticated redirect to login route",
"if",
"(",
"!",
"$",
"this",
"->",
"keeper",
"->",
"check",
"(",
")",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"redirect",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'redirect'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'url'",
")",
";",
"$",
"log",
"->",
"notice",
"(",
"'Guest redirected to login screen'",
",",
"[",
"'from'",
"=>",
"$",
"currentRoute",
"->",
"getName",
"(",
")",
",",
"'to'",
"=>",
"$",
"config",
"->",
"get",
"(",
"'vi-kon.auth.login.route'",
")",
",",
"]",
")",
";",
"return",
"$",
"redirect",
"->",
"guest",
"(",
"$",
"url",
"->",
"route",
"(",
"$",
"config",
"->",
"get",
"(",
"'vi-kon.auth.login.route'",
")",
")",
")",
";",
"}",
"// If user is authenticated but has no permission to access given route then redirect to 403 route",
"if",
"(",
"!",
"$",
"this",
"->",
"keeper",
"->",
"hasPermission",
"(",
"$",
"permission",
")",
")",
"{",
"$",
"log",
"->",
"notice",
"(",
"'User has no permission to view page'",
",",
"[",
"'user'",
"=>",
"$",
"this",
"->",
"keeper",
"->",
"user",
"(",
")",
"->",
"toArray",
"(",
")",
",",
"'permission'",
"=>",
"$",
"permission",
",",
"'route'",
"=>",
"$",
"currentRoute",
"->",
"getName",
"(",
")",
",",
"]",
")",
";",
"throw",
"new",
"AccessDeniedHttpException",
"(",
")",
";",
"}",
"}",
"return",
"$",
"next",
"(",
"$",
"request",
")",
";",
"}"
] | @param \Illuminate\Http\Request $request
@param \Closure $next
@param string $permission
@return \Illuminate\Http\RedirectResponse | [
"@param",
"\\",
"Illuminate",
"\\",
"Http",
"\\",
"Request",
"$request",
"@param",
"\\",
"Closure",
"$next",
"@param",
"string",
"$permission"
] | train | https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/Middleware/PermissionMiddleware.php#L42-L77 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.serialize | public function serialize(TranslatableInterface $translatable, $targetLang) {
$output = $this->beginExport($translatable, $targetLang);
$output .= $this->exportTranslatable($translatable, $targetLang);
$output .= $this->endExport();
return $output;
} | php | public function serialize(TranslatableInterface $translatable, $targetLang) {
$output = $this->beginExport($translatable, $targetLang);
$output .= $this->exportTranslatable($translatable, $targetLang);
$output .= $this->endExport();
return $output;
} | [
"public",
"function",
"serialize",
"(",
"TranslatableInterface",
"$",
"translatable",
",",
"$",
"targetLang",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"beginExport",
"(",
"$",
"translatable",
",",
"$",
"targetLang",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"exportTranslatable",
"(",
"$",
"translatable",
",",
"$",
"targetLang",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"endExport",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Serializes a given translatable into an XLIFF file with the specified
target language.
@param TranslatableInterface $translatable
The translatable to be serialized.
@param string $targetLang
The desired target language.
@return string
The resultant XLIFF file as a string. | [
"Serializes",
"a",
"given",
"translatable",
"into",
"an",
"XLIFF",
"file",
"with",
"the",
"specified",
"target",
"language",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L69-L74 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.unserialize | public function unserialize(TranslatableInterface $translatable, $targetLang, $xliff, $callSetData = TRUE) {
// First, validate the provided xliff.
if ($this->validateImport($translatable, $targetLang, $xliff)) {
// If valid, return the imported data as an array.
$data = $this->import($xliff);
// Call TranslatableInterface::setData() on the translatable if desired.
if ($callSetData) {
$translatable->setData($data, $targetLang);
}
return $data;
}
else {
// If there was an error, return an empty array.
return array();
}
} | php | public function unserialize(TranslatableInterface $translatable, $targetLang, $xliff, $callSetData = TRUE) {
// First, validate the provided xliff.
if ($this->validateImport($translatable, $targetLang, $xliff)) {
// If valid, return the imported data as an array.
$data = $this->import($xliff);
// Call TranslatableInterface::setData() on the translatable if desired.
if ($callSetData) {
$translatable->setData($data, $targetLang);
}
return $data;
}
else {
// If there was an error, return an empty array.
return array();
}
} | [
"public",
"function",
"unserialize",
"(",
"TranslatableInterface",
"$",
"translatable",
",",
"$",
"targetLang",
",",
"$",
"xliff",
",",
"$",
"callSetData",
"=",
"TRUE",
")",
"{",
"// First, validate the provided xliff.",
"if",
"(",
"$",
"this",
"->",
"validateImport",
"(",
"$",
"translatable",
",",
"$",
"targetLang",
",",
"$",
"xliff",
")",
")",
"{",
"// If valid, return the imported data as an array.",
"$",
"data",
"=",
"$",
"this",
"->",
"import",
"(",
"$",
"xliff",
")",
";",
"// Call TranslatableInterface::setData() on the translatable if desired.",
"if",
"(",
"$",
"callSetData",
")",
"{",
"$",
"translatable",
"->",
"setData",
"(",
"$",
"data",
",",
"$",
"targetLang",
")",
";",
"}",
"return",
"$",
"data",
";",
"}",
"else",
"{",
"// If there was an error, return an empty array.",
"return",
"array",
"(",
")",
";",
"}",
"}"
] | Unserializes given XLIFF data; before unserialization occurs, the provided
XLIFF is also validated against the provided translatable and target
language.
@param TranslatableInterface $translatable
The translatable against which validation will occur.
@param $targetLang
The language code of the target language (used for validation).
@param string $xliff
XLIFF data to be unserialized.
@param bool $callSetData
(Optional) Whether or not to call the setData method on the provided
translatable. Defaults to TRUE, pass FALSE to disable the setter call.
@return array
Returns unserialized data as an array in the exact same form that was
provided via the translatable's getData method. If there was an error
unserializing the provided XLIFF, an empty array will be returned. | [
"Unserializes",
"given",
"XLIFF",
"data",
";",
"before",
"unserialization",
"occurs",
"the",
"provided",
"XLIFF",
"is",
"also",
"validated",
"against",
"the",
"provided",
"translatable",
"and",
"target",
"language",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L99-L116 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.beginExport | public function beginExport(TranslatableInterface $translatable, $targetLang) {
$this->openMemory();
$this->setIndent(TRUE);
$this->setIndentString(' ');
$this->startDocument('1.0', 'UTF-8');
// Root element with schema definition.
$this->startElement('xliff');
$this->writeAttribute('version', '1.2');
$this->writeAttribute('xmlns:xlf', 'urn:oasis:names:tc:xliff:document:1.2');
$this->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->writeAttribute('xmlns:html', 'http://www.w3.org/1999/xhtml');
$this->writeAttribute('xsi:schemaLocation', 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd');
// File element.
$this->startElement('file');
$this->writeAttribute('original', 'xliff-core-1.2-strict.xsd');
$this->writeAttribute('source-language', $this->sourceLang);
$this->writeAttribute('target-language', $targetLang);
$this->writeAttribute('datatype', 'plaintext');
// Date needs to be in ISO-8601 UTC.
$this->writeAttribute('date', date('Y-m-d\Th:m:i\Z'));
$this->startElement('header');
$this->startElement('phase-group');
$this->startElement('phase');
$this->writeAttribute('tool-id', 'eggs-n-cereal');
$this->writeAttribute('phase-name', 'extraction');
$this->writeAttribute('process-name', 'extraction');
$this->writeAttribute('job-id', $translatable->getIdentifier());
$this->endElement();
$this->endElement();
$this->startElement('tool');
$this->writeAttribute('tool-id', 'eggs-n-cereal');
$this->writeAttribute('tool-name', 'Eggs-n-Cereal XLIFF Serializer');
$this->endElement();
$this->endElement();
return $this->outputMemory() . '<body>';
} | php | public function beginExport(TranslatableInterface $translatable, $targetLang) {
$this->openMemory();
$this->setIndent(TRUE);
$this->setIndentString(' ');
$this->startDocument('1.0', 'UTF-8');
// Root element with schema definition.
$this->startElement('xliff');
$this->writeAttribute('version', '1.2');
$this->writeAttribute('xmlns:xlf', 'urn:oasis:names:tc:xliff:document:1.2');
$this->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
$this->writeAttribute('xmlns:html', 'http://www.w3.org/1999/xhtml');
$this->writeAttribute('xsi:schemaLocation', 'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd');
// File element.
$this->startElement('file');
$this->writeAttribute('original', 'xliff-core-1.2-strict.xsd');
$this->writeAttribute('source-language', $this->sourceLang);
$this->writeAttribute('target-language', $targetLang);
$this->writeAttribute('datatype', 'plaintext');
// Date needs to be in ISO-8601 UTC.
$this->writeAttribute('date', date('Y-m-d\Th:m:i\Z'));
$this->startElement('header');
$this->startElement('phase-group');
$this->startElement('phase');
$this->writeAttribute('tool-id', 'eggs-n-cereal');
$this->writeAttribute('phase-name', 'extraction');
$this->writeAttribute('process-name', 'extraction');
$this->writeAttribute('job-id', $translatable->getIdentifier());
$this->endElement();
$this->endElement();
$this->startElement('tool');
$this->writeAttribute('tool-id', 'eggs-n-cereal');
$this->writeAttribute('tool-name', 'Eggs-n-Cereal XLIFF Serializer');
$this->endElement();
$this->endElement();
return $this->outputMemory() . '<body>';
} | [
"public",
"function",
"beginExport",
"(",
"TranslatableInterface",
"$",
"translatable",
",",
"$",
"targetLang",
")",
"{",
"$",
"this",
"->",
"openMemory",
"(",
")",
";",
"$",
"this",
"->",
"setIndent",
"(",
"TRUE",
")",
";",
"$",
"this",
"->",
"setIndentString",
"(",
"' '",
")",
";",
"$",
"this",
"->",
"startDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
")",
";",
"// Root element with schema definition.",
"$",
"this",
"->",
"startElement",
"(",
"'xliff'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'version'",
",",
"'1.2'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'xmlns:xlf'",
",",
"'urn:oasis:names:tc:xliff:document:1.2'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'xmlns:xsi'",
",",
"'http://www.w3.org/2001/XMLSchema-instance'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'xmlns:html'",
",",
"'http://www.w3.org/1999/xhtml'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'xsi:schemaLocation'",
",",
"'urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd'",
")",
";",
"// File element.",
"$",
"this",
"->",
"startElement",
"(",
"'file'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'original'",
",",
"'xliff-core-1.2-strict.xsd'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'source-language'",
",",
"$",
"this",
"->",
"sourceLang",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'target-language'",
",",
"$",
"targetLang",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'datatype'",
",",
"'plaintext'",
")",
";",
"// Date needs to be in ISO-8601 UTC.",
"$",
"this",
"->",
"writeAttribute",
"(",
"'date'",
",",
"date",
"(",
"'Y-m-d\\Th:m:i\\Z'",
")",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'header'",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'phase-group'",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'phase'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'tool-id'",
",",
"'eggs-n-cereal'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'phase-name'",
",",
"'extraction'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'process-name'",
",",
"'extraction'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'job-id'",
",",
"$",
"translatable",
"->",
"getIdentifier",
"(",
")",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'tool'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'tool-id'",
",",
"'eggs-n-cereal'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'tool-name'",
",",
"'Eggs-n-Cereal XLIFF Serializer'",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"return",
"$",
"this",
"->",
"outputMemory",
"(",
")",
".",
"'<body>'",
";",
"}"
] | Starts an export.
@param TranslatableInterface $translatable
The translatable for which we will be generating an XLIFF.
@param string $targetLang
The language code of the target language for this XLIFF.
@return string
The generated XML. | [
"Starts",
"an",
"export",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L130-L172 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.exportTranslatable | public function exportTranslatable(TranslatableInterface $translatable, $targetLang) {
$this->openMemory();
$this->setIndent(TRUE);
$this->setIndentString(' ');
$this->startElement('xlf:group');
$this->writeAttribute('id', $translatable->getIdentifier());
$this->writeAttribute('restype', 'x-eggs-n-cereal-translatable');
// Retrieve and flatten translatable data.
$translatableData = $translatable->getData();
$flattenedData = Data::flattenData($translatableData);
// @todo: Write in nested groups instead of flattening it.
$data = array_filter($flattenedData, array('EggsCereal\Utils\Data', 'filterData'));
foreach ($data as $key => $element) {
$this->addTransUnit($key, $element, $targetLang);
}
$this->endElement();
return $this->outputMemory();
} | php | public function exportTranslatable(TranslatableInterface $translatable, $targetLang) {
$this->openMemory();
$this->setIndent(TRUE);
$this->setIndentString(' ');
$this->startElement('xlf:group');
$this->writeAttribute('id', $translatable->getIdentifier());
$this->writeAttribute('restype', 'x-eggs-n-cereal-translatable');
// Retrieve and flatten translatable data.
$translatableData = $translatable->getData();
$flattenedData = Data::flattenData($translatableData);
// @todo: Write in nested groups instead of flattening it.
$data = array_filter($flattenedData, array('EggsCereal\Utils\Data', 'filterData'));
foreach ($data as $key => $element) {
$this->addTransUnit($key, $element, $targetLang);
}
$this->endElement();
return $this->outputMemory();
} | [
"public",
"function",
"exportTranslatable",
"(",
"TranslatableInterface",
"$",
"translatable",
",",
"$",
"targetLang",
")",
"{",
"$",
"this",
"->",
"openMemory",
"(",
")",
";",
"$",
"this",
"->",
"setIndent",
"(",
"TRUE",
")",
";",
"$",
"this",
"->",
"setIndentString",
"(",
"' '",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'xlf:group'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'id'",
",",
"$",
"translatable",
"->",
"getIdentifier",
"(",
")",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'restype'",
",",
"'x-eggs-n-cereal-translatable'",
")",
";",
"// Retrieve and flatten translatable data.",
"$",
"translatableData",
"=",
"$",
"translatable",
"->",
"getData",
"(",
")",
";",
"$",
"flattenedData",
"=",
"Data",
"::",
"flattenData",
"(",
"$",
"translatableData",
")",
";",
"// @todo: Write in nested groups instead of flattening it.",
"$",
"data",
"=",
"array_filter",
"(",
"$",
"flattenedData",
",",
"array",
"(",
"'EggsCereal\\Utils\\Data'",
",",
"'filterData'",
")",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"$",
"this",
"->",
"addTransUnit",
"(",
"$",
"key",
",",
"$",
"element",
",",
"$",
"targetLang",
")",
";",
"}",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"return",
"$",
"this",
"->",
"outputMemory",
"(",
")",
";",
"}"
] | Adds a translatable item to the XML export.
@param TranslatableInterface $translatable
The translatable to serialize.
@param string $targetLang
The desired translatable.
@return string
The generated XML. | [
"Adds",
"a",
"translatable",
"item",
"to",
"the",
"XML",
"export",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L186-L206 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.addTransUnit | protected function addTransUnit($key, $element, $targetLang) {
$this->startElement('xlf:group');
$this->writeAttribute('id', $key);
$this->writeAttribute('resname', $key);
$this->writeAttribute('restype', 'x-eggs-n-cereal-field');
//escape named html entities prior to conversion
$list = get_html_translation_table(HTML_ENTITIES);
$namedTable = array();
foreach($list as $k=>$v){
$namedTable[$v]= "&".str_replace('&', '',$v);
}
$element['#text'] = strtr($element['#text'], $namedTable);
try {
$converter = new Converter($element['#text'], $this->sourceLang, $targetLang);
if ($this->logger) {
$converter->setLogger($this->logger);
}
$this->writeRaw($converter->toXLIFF());
}
catch (\Exception $e) {
$this->startElement('trans-unit');
$this->writeAttribute('id', uniqid('text-'));
$this->writeAttribute('restype', 'x-eggs-n-cereal-failure');
$this->startElement('source');
$this->writeAttribute('xml:lang', $this->sourceLang);
$this->text($element['#text']);
$this->endElement();
$this->startElement('target');
$this->writeAttribute('xml:lang', $targetLang);
$this->text($element['#text']);
$this->endElement();
$this->endElement();
}
if (isset($element['#label'])) {
$this->writeElement('note', $element['#label']);
}
$this->endElement();
} | php | protected function addTransUnit($key, $element, $targetLang) {
$this->startElement('xlf:group');
$this->writeAttribute('id', $key);
$this->writeAttribute('resname', $key);
$this->writeAttribute('restype', 'x-eggs-n-cereal-field');
//escape named html entities prior to conversion
$list = get_html_translation_table(HTML_ENTITIES);
$namedTable = array();
foreach($list as $k=>$v){
$namedTable[$v]= "&".str_replace('&', '',$v);
}
$element['#text'] = strtr($element['#text'], $namedTable);
try {
$converter = new Converter($element['#text'], $this->sourceLang, $targetLang);
if ($this->logger) {
$converter->setLogger($this->logger);
}
$this->writeRaw($converter->toXLIFF());
}
catch (\Exception $e) {
$this->startElement('trans-unit');
$this->writeAttribute('id', uniqid('text-'));
$this->writeAttribute('restype', 'x-eggs-n-cereal-failure');
$this->startElement('source');
$this->writeAttribute('xml:lang', $this->sourceLang);
$this->text($element['#text']);
$this->endElement();
$this->startElement('target');
$this->writeAttribute('xml:lang', $targetLang);
$this->text($element['#text']);
$this->endElement();
$this->endElement();
}
if (isset($element['#label'])) {
$this->writeElement('note', $element['#label']);
}
$this->endElement();
} | [
"protected",
"function",
"addTransUnit",
"(",
"$",
"key",
",",
"$",
"element",
",",
"$",
"targetLang",
")",
"{",
"$",
"this",
"->",
"startElement",
"(",
"'xlf:group'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'id'",
",",
"$",
"key",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'resname'",
",",
"$",
"key",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'restype'",
",",
"'x-eggs-n-cereal-field'",
")",
";",
"//escape named html entities prior to conversion",
"$",
"list",
"=",
"get_html_translation_table",
"(",
"HTML_ENTITIES",
")",
";",
"$",
"namedTable",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"namedTable",
"[",
"$",
"v",
"]",
"=",
"\"&\"",
".",
"str_replace",
"(",
"'&'",
",",
"''",
",",
"$",
"v",
")",
";",
"}",
"$",
"element",
"[",
"'#text'",
"]",
"=",
"strtr",
"(",
"$",
"element",
"[",
"'#text'",
"]",
",",
"$",
"namedTable",
")",
";",
"try",
"{",
"$",
"converter",
"=",
"new",
"Converter",
"(",
"$",
"element",
"[",
"'#text'",
"]",
",",
"$",
"this",
"->",
"sourceLang",
",",
"$",
"targetLang",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"converter",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"$",
"this",
"->",
"writeRaw",
"(",
"$",
"converter",
"->",
"toXLIFF",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"startElement",
"(",
"'trans-unit'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'id'",
",",
"uniqid",
"(",
"'text-'",
")",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'restype'",
",",
"'x-eggs-n-cereal-failure'",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'source'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'xml:lang'",
",",
"$",
"this",
"->",
"sourceLang",
")",
";",
"$",
"this",
"->",
"text",
"(",
"$",
"element",
"[",
"'#text'",
"]",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"this",
"->",
"startElement",
"(",
"'target'",
")",
";",
"$",
"this",
"->",
"writeAttribute",
"(",
"'xml:lang'",
",",
"$",
"targetLang",
")",
";",
"$",
"this",
"->",
"text",
"(",
"$",
"element",
"[",
"'#text'",
"]",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"element",
"[",
"'#label'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"writeElement",
"(",
"'note'",
",",
"$",
"element",
"[",
"'#label'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"endElement",
"(",
")",
";",
"}"
] | Adds a single translation unit for a data element.
@param string $key
The unique identifier for this data element.
@param string $element
An element array with the following properties:
- #text: The text string to be translated.
- #label: (Optional) Label, intended for translators, that provides more
context around the translated string.
@param string $targetLang
The target language of the translatable.
@return string
The generated XML. | [
"Adds",
"a",
"single",
"translation",
"unit",
"for",
"a",
"data",
"element",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L226-L266 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.oldImport | public function oldImport(\SimpleXMLElement $xml) {
$data = array();
foreach ($xml->xpath('//trans-unit') as $unit) {
$data[(string) $unit['id']]['#text'] = (string) $unit->target;
}
return Data::unflattenData($data);
} | php | public function oldImport(\SimpleXMLElement $xml) {
$data = array();
foreach ($xml->xpath('//trans-unit') as $unit) {
$data[(string) $unit['id']]['#text'] = (string) $unit->target;
}
return Data::unflattenData($data);
} | [
"public",
"function",
"oldImport",
"(",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"xml",
"->",
"xpath",
"(",
"'//trans-unit'",
")",
"as",
"$",
"unit",
")",
"{",
"$",
"data",
"[",
"(",
"string",
")",
"$",
"unit",
"[",
"'id'",
"]",
"]",
"[",
"'#text'",
"]",
"=",
"(",
"string",
")",
"$",
"unit",
"->",
"target",
";",
"}",
"return",
"Data",
"::",
"unflattenData",
"(",
"$",
"data",
")",
";",
"}"
] | @todo Remove?
Imports a file.
@param \SimpleXMLElement $xml
The XML to be imported.
@return array
The resultant unserialized, flattened data array. | [
"@todo",
"Remove?",
"Imports",
"a",
"file",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L329-L335 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.serializerSimplexmlLoadString | public function serializerSimplexmlLoadString($xmlString){
$numericTable = array();
//commonly present restricted characters that can safely be replaced
$numericTable['&'] = '&';
$entBitmask = defined('ENT_HTML5') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
$trans = get_html_translation_table(HTML_ENTITIES, $entBitmask);
foreach ($trans as $k=>$v){
$numericTable[$v]= "&#".ord($k).";";
}
$xmlString = strtr($xmlString, $numericTable);
return simplexml_load_string($xmlString);
} | php | public function serializerSimplexmlLoadString($xmlString){
$numericTable = array();
//commonly present restricted characters that can safely be replaced
$numericTable['&'] = '&';
$entBitmask = defined('ENT_HTML5') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
$trans = get_html_translation_table(HTML_ENTITIES, $entBitmask);
foreach ($trans as $k=>$v){
$numericTable[$v]= "&#".ord($k).";";
}
$xmlString = strtr($xmlString, $numericTable);
return simplexml_load_string($xmlString);
} | [
"public",
"function",
"serializerSimplexmlLoadString",
"(",
"$",
"xmlString",
")",
"{",
"$",
"numericTable",
"=",
"array",
"(",
")",
";",
"//commonly present restricted characters that can safely be replaced",
"$",
"numericTable",
"[",
"'&'",
"]",
"=",
"'&'",
";",
"$",
"entBitmask",
"=",
"defined",
"(",
"'ENT_HTML5'",
")",
"?",
"ENT_QUOTES",
"|",
"ENT_HTML5",
":",
"ENT_QUOTES",
";",
"$",
"trans",
"=",
"get_html_translation_table",
"(",
"HTML_ENTITIES",
",",
"$",
"entBitmask",
")",
";",
"foreach",
"(",
"$",
"trans",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"numericTable",
"[",
"$",
"v",
"]",
"=",
"\"&#\"",
".",
"ord",
"(",
"$",
"k",
")",
".",
"\";\"",
";",
"}",
"$",
"xmlString",
"=",
"strtr",
"(",
"$",
"xmlString",
",",
"$",
"numericTable",
")",
";",
"return",
"simplexml_load_string",
"(",
"$",
"xmlString",
")",
";",
"}"
] | Converts xml to string and handles entity encoding.
@param string $xmlString
The xml string to convert to xml.
@return \SimpleXMLElement
Returns SimpleXml element | [
"Converts",
"xml",
"to",
"string",
"and",
"handles",
"entity",
"encoding",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L346-L357 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.validateImport | public function validateImport(TranslatableInterface $translatable, $targetLang, $xmlString) {
$xmlString = Converter::filterXmlControlCharacters($xmlString);
$error = $this->errorStart();
// XML does not support most named HTML entities (eg, ), but should be
// able to handle the UTF-8 uncoded entity characters just fine.
$xml = $this->serializerSimplexmlLoadString($xmlString);
$this->errorStop($error);
if (!$xml) {
return FALSE;
}
$errorArgs = array(
'%lang' => $targetLang,
'%srclang' => $this->sourceLang,
'%name' => $translatable->getLabel(),
'%id' => $translatable->getIdentifier(),
);
// Check if our phase information is there.
$phase = $xml->xpath("//phase[@phase-name='extraction']");
if ($phase) {
$phase = reset($phase);
}
else {
$this->log(LogLevel::ERROR, 'Phase missing from XML.', $errorArgs);
return FALSE;
}
// Check if the project can be loaded.
if (!isset($phase['job-id']) || ($translatable->getIdentifier() != (string) $phase['job-id'])) {
$this->log(LogLevel::ERROR, 'The project id is missing in the XML.', $errorArgs);
return FALSE;
}
elseif ($translatable->getIdentifier() != (string) $phase['job-id']) {
$this->log(LogLevel::ERROR, 'The project id is invalid in the XML. Correct id: %id.', $errorArgs);
return FALSE;
}
// Compare source language.
if (!isset($xml->file['source-language'])) {
$this->log(LogLevel::ERROR, 'The source language is missing in the XML.', $errorArgs);
return FALSE;
}
elseif ($xml->file['source-language'] != $this->sourceLang) {
$this->log(LogLevel::ERROR, 'The source language is invalid in the XML. Correct langcode: %srclang.', $errorArgs);
return FALSE;
}
// Compare target language.
if (!isset($xml->file['target-language'])) {
$this->log(LogLevel::ERROR, 'The target language is missing in the XML.', $errorArgs);
return FALSE;
}
elseif ($targetLang != Data::normalizeLangcode($xml->file['target-language'])) {
$errorArgs['%wrong'] = $xml->file['target-language'];
$this->log(LogLevel::ERROR, 'The target language %wrong is invalid in the XML. Correct langcode: %lang.', $errorArgs);
return FALSE;
}
// Validation successful.
return TRUE;
} | php | public function validateImport(TranslatableInterface $translatable, $targetLang, $xmlString) {
$xmlString = Converter::filterXmlControlCharacters($xmlString);
$error = $this->errorStart();
// XML does not support most named HTML entities (eg, ), but should be
// able to handle the UTF-8 uncoded entity characters just fine.
$xml = $this->serializerSimplexmlLoadString($xmlString);
$this->errorStop($error);
if (!$xml) {
return FALSE;
}
$errorArgs = array(
'%lang' => $targetLang,
'%srclang' => $this->sourceLang,
'%name' => $translatable->getLabel(),
'%id' => $translatable->getIdentifier(),
);
// Check if our phase information is there.
$phase = $xml->xpath("//phase[@phase-name='extraction']");
if ($phase) {
$phase = reset($phase);
}
else {
$this->log(LogLevel::ERROR, 'Phase missing from XML.', $errorArgs);
return FALSE;
}
// Check if the project can be loaded.
if (!isset($phase['job-id']) || ($translatable->getIdentifier() != (string) $phase['job-id'])) {
$this->log(LogLevel::ERROR, 'The project id is missing in the XML.', $errorArgs);
return FALSE;
}
elseif ($translatable->getIdentifier() != (string) $phase['job-id']) {
$this->log(LogLevel::ERROR, 'The project id is invalid in the XML. Correct id: %id.', $errorArgs);
return FALSE;
}
// Compare source language.
if (!isset($xml->file['source-language'])) {
$this->log(LogLevel::ERROR, 'The source language is missing in the XML.', $errorArgs);
return FALSE;
}
elseif ($xml->file['source-language'] != $this->sourceLang) {
$this->log(LogLevel::ERROR, 'The source language is invalid in the XML. Correct langcode: %srclang.', $errorArgs);
return FALSE;
}
// Compare target language.
if (!isset($xml->file['target-language'])) {
$this->log(LogLevel::ERROR, 'The target language is missing in the XML.', $errorArgs);
return FALSE;
}
elseif ($targetLang != Data::normalizeLangcode($xml->file['target-language'])) {
$errorArgs['%wrong'] = $xml->file['target-language'];
$this->log(LogLevel::ERROR, 'The target language %wrong is invalid in the XML. Correct langcode: %lang.', $errorArgs);
return FALSE;
}
// Validation successful.
return TRUE;
} | [
"public",
"function",
"validateImport",
"(",
"TranslatableInterface",
"$",
"translatable",
",",
"$",
"targetLang",
",",
"$",
"xmlString",
")",
"{",
"$",
"xmlString",
"=",
"Converter",
"::",
"filterXmlControlCharacters",
"(",
"$",
"xmlString",
")",
";",
"$",
"error",
"=",
"$",
"this",
"->",
"errorStart",
"(",
")",
";",
"// XML does not support most named HTML entities (eg, ), but should be",
"// able to handle the UTF-8 uncoded entity characters just fine.",
"$",
"xml",
"=",
"$",
"this",
"->",
"serializerSimplexmlLoadString",
"(",
"$",
"xmlString",
")",
";",
"$",
"this",
"->",
"errorStop",
"(",
"$",
"error",
")",
";",
"if",
"(",
"!",
"$",
"xml",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"errorArgs",
"=",
"array",
"(",
"'%lang'",
"=>",
"$",
"targetLang",
",",
"'%srclang'",
"=>",
"$",
"this",
"->",
"sourceLang",
",",
"'%name'",
"=>",
"$",
"translatable",
"->",
"getLabel",
"(",
")",
",",
"'%id'",
"=>",
"$",
"translatable",
"->",
"getIdentifier",
"(",
")",
",",
")",
";",
"// Check if our phase information is there.",
"$",
"phase",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"\"//phase[@phase-name='extraction']\"",
")",
";",
"if",
"(",
"$",
"phase",
")",
"{",
"$",
"phase",
"=",
"reset",
"(",
"$",
"phase",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'Phase missing from XML.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"// Check if the project can be loaded.",
"if",
"(",
"!",
"isset",
"(",
"$",
"phase",
"[",
"'job-id'",
"]",
")",
"||",
"(",
"$",
"translatable",
"->",
"getIdentifier",
"(",
")",
"!=",
"(",
"string",
")",
"$",
"phase",
"[",
"'job-id'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'The project id is missing in the XML.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"$",
"translatable",
"->",
"getIdentifier",
"(",
")",
"!=",
"(",
"string",
")",
"$",
"phase",
"[",
"'job-id'",
"]",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'The project id is invalid in the XML. Correct id: %id.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"// Compare source language.",
"if",
"(",
"!",
"isset",
"(",
"$",
"xml",
"->",
"file",
"[",
"'source-language'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'The source language is missing in the XML.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"$",
"xml",
"->",
"file",
"[",
"'source-language'",
"]",
"!=",
"$",
"this",
"->",
"sourceLang",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'The source language is invalid in the XML. Correct langcode: %srclang.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"// Compare target language.",
"if",
"(",
"!",
"isset",
"(",
"$",
"xml",
"->",
"file",
"[",
"'target-language'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'The target language is missing in the XML.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"elseif",
"(",
"$",
"targetLang",
"!=",
"Data",
"::",
"normalizeLangcode",
"(",
"$",
"xml",
"->",
"file",
"[",
"'target-language'",
"]",
")",
")",
"{",
"$",
"errorArgs",
"[",
"'%wrong'",
"]",
"=",
"$",
"xml",
"->",
"file",
"[",
"'target-language'",
"]",
";",
"$",
"this",
"->",
"log",
"(",
"LogLevel",
"::",
"ERROR",
",",
"'The target language %wrong is invalid in the XML. Correct langcode: %lang.'",
",",
"$",
"errorArgs",
")",
";",
"return",
"FALSE",
";",
"}",
"// Validation successful.",
"return",
"TRUE",
";",
"}"
] | Validates an import.
@param TranslatableInterface $translatable
A translatable object.
@param string $targetLang
The target language for this translatable.
@param string $xmlString
The XLIFF data as a string to validate.
@return bool
Returns TRUE on success or FALSE on failure. | [
"Validates",
"an",
"import",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L372-L437 |
tableau-mkt/eggs-n-cereal | src/Serializer.php | Serializer.errorStop | protected function errorStop($use) {
foreach (libxml_get_errors() as $error) {
switch ($error->level) {
case LIBXML_ERR_WARNING:
case LIBXML_ERR_ERROR:
$level = LogLevel::WARNING;
break;
case LIBXML_ERR_FATAL:
$level = LogLevel::ERROR;
break;
default:
$level = LogLevel::INFO;
}
$this->log($level, '%error on line %num. Error code: %code.', array(
'%error' => trim($error->message),
'%num' => $error->line,
'%code' => $error->code,
));
}
libxml_clear_errors();
libxml_use_internal_errors($use);
} | php | protected function errorStop($use) {
foreach (libxml_get_errors() as $error) {
switch ($error->level) {
case LIBXML_ERR_WARNING:
case LIBXML_ERR_ERROR:
$level = LogLevel::WARNING;
break;
case LIBXML_ERR_FATAL:
$level = LogLevel::ERROR;
break;
default:
$level = LogLevel::INFO;
}
$this->log($level, '%error on line %num. Error code: %code.', array(
'%error' => trim($error->message),
'%num' => $error->line,
'%code' => $error->code,
));
}
libxml_clear_errors();
libxml_use_internal_errors($use);
} | [
"protected",
"function",
"errorStop",
"(",
"$",
"use",
")",
"{",
"foreach",
"(",
"libxml_get_errors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"switch",
"(",
"$",
"error",
"->",
"level",
")",
"{",
"case",
"LIBXML_ERR_WARNING",
":",
"case",
"LIBXML_ERR_ERROR",
":",
"$",
"level",
"=",
"LogLevel",
"::",
"WARNING",
";",
"break",
";",
"case",
"LIBXML_ERR_FATAL",
":",
"$",
"level",
"=",
"LogLevel",
"::",
"ERROR",
";",
"break",
";",
"default",
":",
"$",
"level",
"=",
"LogLevel",
"::",
"INFO",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"$",
"level",
",",
"'%error on line %num. Error code: %code.'",
",",
"array",
"(",
"'%error'",
"=>",
"trim",
"(",
"$",
"error",
"->",
"message",
")",
",",
"'%num'",
"=>",
"$",
"error",
"->",
"line",
",",
"'%code'",
"=>",
"$",
"error",
"->",
"code",
",",
")",
")",
";",
"}",
"libxml_clear_errors",
"(",
")",
";",
"libxml_use_internal_errors",
"(",
"$",
"use",
")",
";",
"}"
] | Ends custom error handling.
@param bool $use
The return value of Serializer::errorStart(). | [
"Ends",
"custom",
"error",
"handling",
"."
] | train | https://github.com/tableau-mkt/eggs-n-cereal/blob/778b83ddae1dd687724a84545ce8afa1a31e4bcf/src/Serializer.php#L455-L479 |
prowebcraft/dot | src/Dot.php | Dot.getValue | public static function getValue($array, $key, $default = null)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
foreach ($keys as $key) {
if (!isset($array[$key])) {
return $default;
}
$array = &$array[$key];
}
// Get value
return $array;
} elseif (is_null($key)) {
// Get all data
return $array;
}
return null;
} | php | public static function getValue($array, $key, $default = null)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
foreach ($keys as $key) {
if (!isset($array[$key])) {
return $default;
}
$array = &$array[$key];
}
// Get value
return $array;
} elseif (is_null($key)) {
// Get all data
return $array;
}
return null;
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"array",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate path",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"// Get value",
"return",
"$",
"array",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"// Get all data",
"return",
"$",
"array",
";",
"}",
"return",
"null",
";",
"}"
] | Get value of path, default value if path doesn't exist or all data
@param array $array Source Array
@param mixed|null $key Path
@param mixed|null $default Default value
@return mixed Value of path | [
"Get",
"value",
"of",
"path",
"default",
"value",
"if",
"path",
"doesn",
"t",
"exist",
"or",
"all",
"data"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L39-L57 |
prowebcraft/dot | src/Dot.php | Dot.setValue | public static function setValue(&$array, $key, $value)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
foreach ($keys as $key) {
if (!isset($array[$key]) || !is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
// Set value to path
$array = $value;
} elseif (is_array($key)) {
// Iterate array of paths and values
foreach ($key as $k => $v) {
self::setValue($array, $k, $v);
}
}
} | php | public static function setValue(&$array, $key, $value)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
foreach ($keys as $key) {
if (!isset($array[$key]) || !is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
// Set value to path
$array = $value;
} elseif (is_array($key)) {
// Iterate array of paths and values
foreach ($key as $k => $v) {
self::setValue($array, $k, $v);
}
}
} | [
"public",
"static",
"function",
"setValue",
"(",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate path",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"// Set value to path",
"$",
"array",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate array of paths and values",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"self",
"::",
"setValue",
"(",
"$",
"array",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"}"
] | Set value or array of values to path
@param array $array Target array with data
@param mixed $key Path or array of paths and values
@param mixed|null $value Value to set if path is not an array | [
"Set",
"value",
"or",
"array",
"of",
"values",
"to",
"path"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L66-L85 |
prowebcraft/dot | src/Dot.php | Dot.addValue | public static function addValue(&$array, $key, $value = null, $pop = false)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
if ($pop === true) {
array_pop($keys);
}
foreach ($keys as $key) {
if (!isset($array[$key]) || !is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
// Add value to path
$array[] = $value;
} elseif (is_array($key)) {
// Iterate array of paths and values
foreach ($key as $k => $v) {
self::addValue($array, $k, $v);
}
}
} | php | public static function addValue(&$array, $key, $value = null, $pop = false)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
if ($pop === true) {
array_pop($keys);
}
foreach ($keys as $key) {
if (!isset($array[$key]) || !is_array($array[$key])) {
$array[$key] = [];
}
$array = &$array[$key];
}
// Add value to path
$array[] = $value;
} elseif (is_array($key)) {
// Iterate array of paths and values
foreach ($key as $k => $v) {
self::addValue($array, $k, $v);
}
}
} | [
"public",
"static",
"function",
"addValue",
"(",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"pop",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate path",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"if",
"(",
"$",
"pop",
"===",
"true",
")",
"{",
"array_pop",
"(",
"$",
"keys",
")",
";",
"}",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"// Add value to path",
"$",
"array",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate array of paths and values",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"self",
"::",
"addValue",
"(",
"$",
"array",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"}"
] | Add value or array of values to path
@param array $array Target array with data
@param mixed $key Path or array of paths and values
@param mixed|null $value Value to set if path is not an array
@param boolean $pop Helper to pop out last key if value is an array | [
"Add",
"value",
"or",
"array",
"of",
"values",
"to",
"path"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L95-L117 |
prowebcraft/dot | src/Dot.php | Dot.deleteValue | public static function deleteValue(&$array, $key)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
$last = array_pop($keys);
foreach ($keys as $key) {
if (!isset($array[$key])) {
return;
}
$array = &$array[$key];
}
if (isset($array[$last])) {
// Detele path
unset($array[$last]);
}
} elseif (is_array($key)) {
// Iterate array of paths
foreach ($key as $k) {
self::delete($k);
}
}
} | php | public static function deleteValue(&$array, $key)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
$last = array_pop($keys);
foreach ($keys as $key) {
if (!isset($array[$key])) {
return;
}
$array = &$array[$key];
}
if (isset($array[$last])) {
// Detele path
unset($array[$last]);
}
} elseif (is_array($key)) {
// Iterate array of paths
foreach ($key as $k) {
self::delete($k);
}
}
} | [
"public",
"static",
"function",
"deleteValue",
"(",
"&",
"$",
"array",
",",
"$",
"key",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate path",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"keys",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"$",
"last",
"]",
")",
")",
"{",
"// Detele path",
"unset",
"(",
"$",
"array",
"[",
"$",
"last",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate array of paths",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
")",
"{",
"self",
"::",
"delete",
"(",
"$",
"k",
")",
";",
"}",
"}",
"}"
] | Delete path or array of paths
@param array $array Target array with data
@param mixed $key Path or array of paths to delete | [
"Delete",
"path",
"or",
"array",
"of",
"paths"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L125-L147 |
prowebcraft/dot | src/Dot.php | Dot.set | public function set($key, $value = null)
{
return self::setValue($this->data, $key, $value);
} | php | public function set($key, $value = null)
{
return self::setValue($this->data, $key, $value);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"setValue",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Set value or array of values to path
@param mixed $key Path or array of paths and values
@param mixed|null $value Value to set if path is not an array | [
"Set",
"value",
"or",
"array",
"of",
"values",
"to",
"path"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L168-L171 |
prowebcraft/dot | src/Dot.php | Dot.add | public function add($key, $value = null, $pop = false)
{
return self::addValue($this->data, $key, $value, $pop);
} | php | public function add($key, $value = null, $pop = false)
{
return self::addValue($this->data, $key, $value, $pop);
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"$",
"pop",
"=",
"false",
")",
"{",
"return",
"self",
"::",
"addValue",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"pop",
")",
";",
"}"
] | Add value or array of values to path
@param mixed $key Path or array of paths and values
@param mixed|null $value Value to set if path is not an array
@param boolean $pop Helper to pop out last key if value is an array | [
"Add",
"value",
"or",
"array",
"of",
"values",
"to",
"path"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L180-L183 |
prowebcraft/dot | src/Dot.php | Dot.has | public function has($key)
{
$keys = explode('.', (string)$key);
$data = &$this->data;
foreach ($keys as $key) {
if (!isset($data[$key])) {
return false;
}
$data = &$data[$key];
}
return true;
} | php | public function has($key)
{
$keys = explode('.', (string)$key);
$data = &$this->data;
foreach ($keys as $key) {
if (!isset($data[$key])) {
return false;
}
$data = &$data[$key];
}
return true;
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"(",
"string",
")",
"$",
"key",
")",
";",
"$",
"data",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"&",
"$",
"data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"true",
";",
"}"
] | Check if path exists
@param string $key Path
@return boolean | [
"Check",
"if",
"path",
"exists"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L191-L203 |
prowebcraft/dot | src/Dot.php | Dot.clear | public function clear($key = null, $format = false)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
$data = &$this->data;
foreach ($keys as $key) {
if (!isset($data[$key]) || !is_array($data[$key])) {
if ($format === true) {
$data[$key] = [];
} else {
return;
}
}
$data = &$data[$key];
}
// Clear path
$data = [];
} elseif (is_array($key)) {
// Iterate array
foreach ($key as $k) {
$this->clear($k, $format);
}
} elseif (is_null($key)) {
// Clear all data
$this->data = [];
}
} | php | public function clear($key = null, $format = false)
{
if (is_string($key)) {
// Iterate path
$keys = explode('.', $key);
$data = &$this->data;
foreach ($keys as $key) {
if (!isset($data[$key]) || !is_array($data[$key])) {
if ($format === true) {
$data[$key] = [];
} else {
return;
}
}
$data = &$data[$key];
}
// Clear path
$data = [];
} elseif (is_array($key)) {
// Iterate array
foreach ($key as $k) {
$this->clear($k, $format);
}
} elseif (is_null($key)) {
// Clear all data
$this->data = [];
}
} | [
"public",
"function",
"clear",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"format",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate path",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"data",
"=",
"&",
"$",
"this",
"->",
"data",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"$",
"format",
"===",
"true",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"$",
"data",
"=",
"&",
"$",
"data",
"[",
"$",
"key",
"]",
";",
"}",
"// Clear path",
"$",
"data",
"=",
"[",
"]",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"// Iterate array",
"foreach",
"(",
"$",
"key",
"as",
"$",
"k",
")",
"{",
"$",
"this",
"->",
"clear",
"(",
"$",
"k",
",",
"$",
"format",
")",
";",
"}",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"// Clear all data",
"$",
"this",
"->",
"data",
"=",
"[",
"]",
";",
"}",
"}"
] | Delete all data, data from path or array of paths and
optionally format path if it doesn't exist
@param mixed|null $key Path or array of paths to clean
@param boolean $format Format option | [
"Delete",
"all",
"data",
"data",
"from",
"path",
"or",
"array",
"of",
"paths",
"and",
"optionally",
"format",
"path",
"if",
"it",
"doesn",
"t",
"exist"
] | train | https://github.com/prowebcraft/dot/blob/de47137ec650f39c6835f30474a42cd9548063c4/src/Dot.php#L222-L249 |
lmammino/e-foundation | src/Variation/Model/OptionSubjectTrait.php | OptionSubjectTrait.setOptions | public function setOptions(Collection $options)
{
/** @var OptionInterface $option */
foreach ($options as $option) {
$this->addOption($option);
}
return $this;
} | php | public function setOptions(Collection $options)
{
/** @var OptionInterface $option */
foreach ($options as $option) {
$this->addOption($option);
}
return $this;
} | [
"public",
"function",
"setOptions",
"(",
"Collection",
"$",
"options",
")",
"{",
"/** @var OptionInterface $option */",
"foreach",
"(",
"$",
"options",
"as",
"$",
"option",
")",
"{",
"$",
"this",
"->",
"addOption",
"(",
"$",
"option",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set options
@param Collection $options
@return $this | [
"Set",
"options"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/OptionSubjectTrait.php#L44-L52 |
lmammino/e-foundation | src/Variation/Model/OptionSubjectTrait.php | OptionSubjectTrait.addOption | public function addOption(OptionInterface $option)
{
if (!$this->hasOption($option)) {
$this->options->add($option);
}
return $this;
} | php | public function addOption(OptionInterface $option)
{
if (!$this->hasOption($option)) {
$this->options->add($option);
}
return $this;
} | [
"public",
"function",
"addOption",
"(",
"OptionInterface",
"$",
"option",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"option",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"add",
"(",
"$",
"option",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a given option
@param OptionInterface $option
@return $this | [
"Add",
"a",
"given",
"option"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/OptionSubjectTrait.php#L71-L78 |
lmammino/e-foundation | src/Variation/Model/OptionSubjectTrait.php | OptionSubjectTrait.removeOption | public function removeOption(OptionInterface $option)
{
if ($this->hasOption($option)) {
$this->options->removeElement($option);
}
return $this;
} | php | public function removeOption(OptionInterface $option)
{
if ($this->hasOption($option)) {
$this->options->removeElement($option);
}
return $this;
} | [
"public",
"function",
"removeOption",
"(",
"OptionInterface",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"option",
")",
")",
"{",
"$",
"this",
"->",
"options",
"->",
"removeElement",
"(",
"$",
"option",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove a given option
@param OptionInterface $option
@return $this | [
"Remove",
"a",
"given",
"option"
] | train | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/OptionSubjectTrait.php#L86-L93 |
atkrad/data-tables | src/Column/Action.php | Action.initialize | public function initialize(Table $table)
{
$this->table = $table;
if (!$this->builder instanceof ActionBuilder) {
$this->builder = new ActionBuilder($this->table);
}
} | php | public function initialize(Table $table)
{
$this->table = $table;
if (!$this->builder instanceof ActionBuilder) {
$this->builder = new ActionBuilder($this->table);
}
} | [
"public",
"function",
"initialize",
"(",
"Table",
"$",
"table",
")",
"{",
"$",
"this",
"->",
"table",
"=",
"$",
"table",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"builder",
"instanceof",
"ActionBuilder",
")",
"{",
"$",
"this",
"->",
"builder",
"=",
"new",
"ActionBuilder",
"(",
"$",
"this",
"->",
"table",
")",
";",
"}",
"}"
] | Initialize table
@param Table $table Table object
@return void | [
"Initialize",
"table"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/Action.php#L59-L66 |
atkrad/data-tables | src/Column/Action.php | Action.getContent | public function getContent($rowResult)
{
if ($this->callManager($rowResult) === false) {
return '';
}
return $this->builder->render($this->template);
} | php | public function getContent($rowResult)
{
if ($this->callManager($rowResult) === false) {
return '';
}
return $this->builder->render($this->template);
} | [
"public",
"function",
"getContent",
"(",
"$",
"rowResult",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"callManager",
"(",
"$",
"rowResult",
")",
"===",
"false",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"builder",
"->",
"render",
"(",
"$",
"this",
"->",
"template",
")",
";",
"}"
] | Get column content
@param mixed $rowResult Per row result
@return string | [
"Get",
"column",
"content"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/Action.php#L75-L82 |
atkrad/data-tables | src/Column/Action.php | Action.setManager | public function setManager(Closure $manager)
{
if (!is_callable($manager)) {
throw new Exception('Manager must be callable.');
}
$this->manager = $manager;
return $this;
} | php | public function setManager(Closure $manager)
{
if (!is_callable($manager)) {
throw new Exception('Manager must be callable.');
}
$this->manager = $manager;
return $this;
} | [
"public",
"function",
"setManager",
"(",
"Closure",
"$",
"manager",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"manager",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Manager must be callable.'",
")",
";",
"}",
"$",
"this",
"->",
"manager",
"=",
"$",
"manager",
";",
"return",
"$",
"this",
";",
"}"
] | Set action manager
@param callable $manager
@throws \DataTable\Exception
@return Action | [
"Set",
"action",
"manager"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/Action.php#L92-L101 |
atkrad/data-tables | src/Column/Action.php | Action.callManager | protected function callManager($rowResult)
{
if (is_callable($this->manager)) {
call_user_func_array($this->manager, [$this->builder, $rowResult]);
return true;
} else {
return false;
}
} | php | protected function callManager($rowResult)
{
if (is_callable($this->manager)) {
call_user_func_array($this->manager, [$this->builder, $rowResult]);
return true;
} else {
return false;
}
} | [
"protected",
"function",
"callManager",
"(",
"$",
"rowResult",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"manager",
")",
")",
"{",
"call_user_func_array",
"(",
"$",
"this",
"->",
"manager",
",",
"[",
"$",
"this",
"->",
"builder",
",",
"$",
"rowResult",
"]",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Call manager
@param mixed $rowResult Per row result
@return bool | [
"Call",
"manager"
] | train | https://github.com/atkrad/data-tables/blob/5afcc337ab624ca626e29d9674459c5105982b16/src/Column/Action.php#L110-L119 |
vi-kon/laravel-auth | src/database/migrations/2014_08_27_000001_create_user_roles_table.php | CreateUserRolesTable.up | public function up()
{
$schema = app()->make('db')->connection()->getSchemaBuilder();
$schema->create(config('vi-kon.auth.table.user_roles'), function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('token')
->nullable(true)
->default(null)
->unique();
$table->boolean('static')
->default(false);
$table->boolean('hidden')
->default(false);
});
} | php | public function up()
{
$schema = app()->make('db')->connection()->getSchemaBuilder();
$schema->create(config('vi-kon.auth.table.user_roles'), function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('token')
->nullable(true)
->default(null)
->unique();
$table->boolean('static')
->default(false);
$table->boolean('hidden')
->default(false);
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"$",
"schema",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"'db'",
")",
"->",
"connection",
"(",
")",
"->",
"getSchemaBuilder",
"(",
")",
";",
"$",
"schema",
"->",
"create",
"(",
"config",
"(",
"'vi-kon.auth.table.user_roles'",
")",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"engine",
"=",
"'InnoDB'",
";",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'token'",
")",
"->",
"nullable",
"(",
"true",
")",
"->",
"default",
"(",
"null",
")",
"->",
"unique",
"(",
")",
";",
"$",
"table",
"->",
"boolean",
"(",
"'static'",
")",
"->",
"default",
"(",
"false",
")",
";",
"$",
"table",
"->",
"boolean",
"(",
"'hidden'",
")",
"->",
"default",
"(",
"false",
")",
";",
"}",
")",
";",
"}"
] | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/database/migrations/2014_08_27_000001_create_user_roles_table.php#L18-L35 |
barebone-php/barebone-core | lib/Controller.php | Controller.render | protected function render($template, $data = [], $status = 200)
{
$rendered = View::render($template, $data);
$this->response->getBody()->write($rendered);
return $this->getResponse()
->withStatus($status)
->withHeader('Content-Type', 'text/html; charset=utf-8');
} | php | protected function render($template, $data = [], $status = 200)
{
$rendered = View::render($template, $data);
$this->response->getBody()->write($rendered);
return $this->getResponse()
->withStatus($status)
->withHeader('Content-Type', 'text/html; charset=utf-8');
} | [
"protected",
"function",
"render",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"status",
"=",
"200",
")",
"{",
"$",
"rendered",
"=",
"View",
"::",
"render",
"(",
"$",
"template",
",",
"$",
"data",
")",
";",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"$",
"rendered",
")",
";",
"return",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"withStatus",
"(",
"$",
"status",
")",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"'text/html; charset=utf-8'",
")",
";",
"}"
] | Render a view template with optional data
@param string $template Relative Path to Template File
@param array|object $data Associate Array or Object (key => value)
@param int $status HTTP status code (100-599, default 200)
@return Response | [
"Render",
"a",
"view",
"template",
"with",
"optional",
"data"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L109-L118 |
barebone-php/barebone-core | lib/Controller.php | Controller.renderJSON | protected function renderJSON($data = [], $status = 200, $flags = null)
{
$rendered = View::renderJSON($data, $flags);
$this->response->getBody()->rewind();
$this->response->getBody()->write($rendered);
return $this->getResponse()
->withStatus($status)
->withHeader('Content-Type', 'application/json; charset=utf-8');
} | php | protected function renderJSON($data = [], $status = 200, $flags = null)
{
$rendered = View::renderJSON($data, $flags);
$this->response->getBody()->rewind();
$this->response->getBody()->write($rendered);
return $this->getResponse()
->withStatus($status)
->withHeader('Content-Type', 'application/json; charset=utf-8');
} | [
"protected",
"function",
"renderJSON",
"(",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"status",
"=",
"200",
",",
"$",
"flags",
"=",
"null",
")",
"{",
"$",
"rendered",
"=",
"View",
"::",
"renderJSON",
"(",
"$",
"data",
",",
"$",
"flags",
")",
";",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
"->",
"rewind",
"(",
")",
";",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"$",
"rendered",
")",
";",
"return",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"withStatus",
"(",
"$",
"status",
")",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"'application/json; charset=utf-8'",
")",
";",
"}"
] | Render data variable as application/json string
@param array|object $data Associate Array or Object (key => value)
@param int $status HTTP status code (100-599, default 200)
@param int $flags JSON Encoding Flags
@return Response | [
"Render",
"data",
"variable",
"as",
"application",
"/",
"json",
"string"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L129-L139 |
barebone-php/barebone-core | lib/Controller.php | Controller.redirect | protected function redirect($url, $status = 302)
{
return $this->getResponse()
->withStatus($status)
->withHeader('Location', (string)$url);
} | php | protected function redirect($url, $status = 302)
{
return $this->getResponse()
->withStatus($status)
->withHeader('Location', (string)$url);
} | [
"protected",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"status",
"=",
"302",
")",
"{",
"return",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"withStatus",
"(",
"$",
"status",
")",
"->",
"withHeader",
"(",
"'Location'",
",",
"(",
"string",
")",
"$",
"url",
")",
";",
"}"
] | Redirect to URL with optional status
@param string $url The redirect destination.
@param int $status The redirect HTTP status code (between 100 and 599).
@return Response | [
"Redirect",
"to",
"URL",
"with",
"optional",
"status"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L150-L155 |
barebone-php/barebone-core | lib/Controller.php | Controller.routerError | public function routerError($error = null, $subject = null)
{
switch ($error) {
case Router::ERR_NOT_FOUND:
$status = 404;
$template = 'router/error404';
break;
case Router::ERR_BAD_METHOD:
$status = 405;
$template = 'router/error405';
break;
case Router::ERR_MISSING_CONTROLLER:
case Router::ERR_MISSING_ACTION:
default:
$status = 500;
$template = 'router/error';
break;
}
return $this->render($template, compact('error', 'subject'), $status);
} | php | public function routerError($error = null, $subject = null)
{
switch ($error) {
case Router::ERR_NOT_FOUND:
$status = 404;
$template = 'router/error404';
break;
case Router::ERR_BAD_METHOD:
$status = 405;
$template = 'router/error405';
break;
case Router::ERR_MISSING_CONTROLLER:
case Router::ERR_MISSING_ACTION:
default:
$status = 500;
$template = 'router/error';
break;
}
return $this->render($template, compact('error', 'subject'), $status);
} | [
"public",
"function",
"routerError",
"(",
"$",
"error",
"=",
"null",
",",
"$",
"subject",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"error",
")",
"{",
"case",
"Router",
"::",
"ERR_NOT_FOUND",
":",
"$",
"status",
"=",
"404",
";",
"$",
"template",
"=",
"'router/error404'",
";",
"break",
";",
"case",
"Router",
"::",
"ERR_BAD_METHOD",
":",
"$",
"status",
"=",
"405",
";",
"$",
"template",
"=",
"'router/error405'",
";",
"break",
";",
"case",
"Router",
"::",
"ERR_MISSING_CONTROLLER",
":",
"case",
"Router",
"::",
"ERR_MISSING_ACTION",
":",
"default",
":",
"$",
"status",
"=",
"500",
";",
"$",
"template",
"=",
"'router/error'",
";",
"break",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"template",
",",
"compact",
"(",
"'error'",
",",
"'subject'",
")",
",",
"$",
"status",
")",
";",
"}"
] | Router Error Action
@param string $error Router::ERR_*
@param mixed $subject Optional value for the error template
@return Response | [
"Router",
"Error",
"Action"
] | train | https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Controller.php#L165-L185 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.