id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
10,900
|
mlocati/composer-patcher
|
src/Plugin.php
|
Plugin.installPatchesForPackage
|
protected function installPatchesForPackage(PackageInterface $package)
{
$considerPatchErrorsAsWarnings = $this->considerPatchErrorsAsWarnings();
$patches = $this->getPatchCollection()->getPatchesFor($package);
$patcher = $this->getPatcher();
$appliedPatchesToSave = method_exists($package, 'setExtra') ? array() : null;
foreach ($patches->getPatches() as $patch) {
try {
$patcher->applyPatch($patch, $package);
if ($appliedPatchesToSave !== null) {
$appliedPatchesToSave[] = array(
'from-package' => $patch->getFromPackage()->getPrettyString(),
'path' => $patch->getOriginalPath(),
'description' => $patch->getDescription(),
);
}
} catch (GenericException $x) {
$appliedPatchesToSave = null;
if (!$considerPatchErrorsAsWarnings) {
throw $x;
}
$this->io->write('<error>'.$x->getMessage().'</error>');
}
}
if ($appliedPatchesToSave !== null) {
$this->setPatchedPackageData($package, array(
'hash' => $patches->getHash(),
'list' => $appliedPatchesToSave,
));
}
}
|
php
|
protected function installPatchesForPackage(PackageInterface $package)
{
$considerPatchErrorsAsWarnings = $this->considerPatchErrorsAsWarnings();
$patches = $this->getPatchCollection()->getPatchesFor($package);
$patcher = $this->getPatcher();
$appliedPatchesToSave = method_exists($package, 'setExtra') ? array() : null;
foreach ($patches->getPatches() as $patch) {
try {
$patcher->applyPatch($patch, $package);
if ($appliedPatchesToSave !== null) {
$appliedPatchesToSave[] = array(
'from-package' => $patch->getFromPackage()->getPrettyString(),
'path' => $patch->getOriginalPath(),
'description' => $patch->getDescription(),
);
}
} catch (GenericException $x) {
$appliedPatchesToSave = null;
if (!$considerPatchErrorsAsWarnings) {
throw $x;
}
$this->io->write('<error>'.$x->getMessage().'</error>');
}
}
if ($appliedPatchesToSave !== null) {
$this->setPatchedPackageData($package, array(
'hash' => $patches->getHash(),
'list' => $appliedPatchesToSave,
));
}
}
|
[
"protected",
"function",
"installPatchesForPackage",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"$",
"considerPatchErrorsAsWarnings",
"=",
"$",
"this",
"->",
"considerPatchErrorsAsWarnings",
"(",
")",
";",
"$",
"patches",
"=",
"$",
"this",
"->",
"getPatchCollection",
"(",
")",
"->",
"getPatchesFor",
"(",
"$",
"package",
")",
";",
"$",
"patcher",
"=",
"$",
"this",
"->",
"getPatcher",
"(",
")",
";",
"$",
"appliedPatchesToSave",
"=",
"method_exists",
"(",
"$",
"package",
",",
"'setExtra'",
")",
"?",
"array",
"(",
")",
":",
"null",
";",
"foreach",
"(",
"$",
"patches",
"->",
"getPatches",
"(",
")",
"as",
"$",
"patch",
")",
"{",
"try",
"{",
"$",
"patcher",
"->",
"applyPatch",
"(",
"$",
"patch",
",",
"$",
"package",
")",
";",
"if",
"(",
"$",
"appliedPatchesToSave",
"!==",
"null",
")",
"{",
"$",
"appliedPatchesToSave",
"[",
"]",
"=",
"array",
"(",
"'from-package'",
"=>",
"$",
"patch",
"->",
"getFromPackage",
"(",
")",
"->",
"getPrettyString",
"(",
")",
",",
"'path'",
"=>",
"$",
"patch",
"->",
"getOriginalPath",
"(",
")",
",",
"'description'",
"=>",
"$",
"patch",
"->",
"getDescription",
"(",
")",
",",
")",
";",
"}",
"}",
"catch",
"(",
"GenericException",
"$",
"x",
")",
"{",
"$",
"appliedPatchesToSave",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"considerPatchErrorsAsWarnings",
")",
"{",
"throw",
"$",
"x",
";",
"}",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"'<error>'",
".",
"$",
"x",
"->",
"getMessage",
"(",
")",
".",
"'</error>'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"appliedPatchesToSave",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setPatchedPackageData",
"(",
"$",
"package",
",",
"array",
"(",
"'hash'",
"=>",
"$",
"patches",
"->",
"getHash",
"(",
")",
",",
"'list'",
"=>",
"$",
"appliedPatchesToSave",
",",
")",
")",
";",
"}",
"}"
] |
Install the patches for a specific package.
@param \Composer\Package\PackageInterface $package the package to be patched
|
[
"Install",
"the",
"patches",
"for",
"a",
"specific",
"package",
"."
] |
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
|
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Plugin.php#L331-L361
|
10,901
|
mlocati/composer-patcher
|
src/Plugin.php
|
Plugin.setPatchedPackageData
|
protected function setPatchedPackageData(PackageInterface $package, array $patchesAppliedData)
{
$extra = $package->getExtra();
$extra['patches_applied'] = $patchesAppliedData;
$package->setExtra($extra);
$this->composer->getRepositoryManager()->getLocalRepository()->write();
}
|
php
|
protected function setPatchedPackageData(PackageInterface $package, array $patchesAppliedData)
{
$extra = $package->getExtra();
$extra['patches_applied'] = $patchesAppliedData;
$package->setExtra($extra);
$this->composer->getRepositoryManager()->getLocalRepository()->write();
}
|
[
"protected",
"function",
"setPatchedPackageData",
"(",
"PackageInterface",
"$",
"package",
",",
"array",
"$",
"patchesAppliedData",
")",
"{",
"$",
"extra",
"=",
"$",
"package",
"->",
"getExtra",
"(",
")",
";",
"$",
"extra",
"[",
"'patches_applied'",
"]",
"=",
"$",
"patchesAppliedData",
";",
"$",
"package",
"->",
"setExtra",
"(",
"$",
"extra",
")",
";",
"$",
"this",
"->",
"composer",
"->",
"getRepositoryManager",
"(",
")",
"->",
"getLocalRepository",
"(",
")",
"->",
"write",
"(",
")",
";",
"}"
] |
Persist the patches_applied to the package extra section.
@param \Composer\Package\PackageInterface $package
@param array $patchesAppliedData
|
[
"Persist",
"the",
"patches_applied",
"to",
"the",
"package",
"extra",
"section",
"."
] |
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
|
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Plugin.php#L369-L375
|
10,902
|
mlocati/composer-patcher
|
src/Plugin.php
|
Plugin.getLocalRepositoryPackages
|
protected function getLocalRepositoryPackages($excludeRootPackage = false)
{
$repositoryManager = $this->composer->getRepositoryManager();
$localRepository = $repositoryManager->getLocalRepository();
$packages = $localRepository->getPackages();
if ($excludeRootPackage) {
$result = array();
foreach ($packages as $package) {
if (!$package instanceof RootPackageInterface) {
$result[] = $package;
}
}
} else {
$result = $packages;
}
return $result;
}
|
php
|
protected function getLocalRepositoryPackages($excludeRootPackage = false)
{
$repositoryManager = $this->composer->getRepositoryManager();
$localRepository = $repositoryManager->getLocalRepository();
$packages = $localRepository->getPackages();
if ($excludeRootPackage) {
$result = array();
foreach ($packages as $package) {
if (!$package instanceof RootPackageInterface) {
$result[] = $package;
}
}
} else {
$result = $packages;
}
return $result;
}
|
[
"protected",
"function",
"getLocalRepositoryPackages",
"(",
"$",
"excludeRootPackage",
"=",
"false",
")",
"{",
"$",
"repositoryManager",
"=",
"$",
"this",
"->",
"composer",
"->",
"getRepositoryManager",
"(",
")",
";",
"$",
"localRepository",
"=",
"$",
"repositoryManager",
"->",
"getLocalRepository",
"(",
")",
";",
"$",
"packages",
"=",
"$",
"localRepository",
"->",
"getPackages",
"(",
")",
";",
"if",
"(",
"$",
"excludeRootPackage",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"!",
"$",
"package",
"instanceof",
"RootPackageInterface",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"package",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"result",
"=",
"$",
"packages",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the packages from the local Composer repository.
@param mixed $excludeRootPackage
@return \Composer\Package\PackageInterface[]
|
[
"Get",
"the",
"packages",
"from",
"the",
"local",
"Composer",
"repository",
"."
] |
d8ba45c10b5cf8ac8da3591e09b6afd47fc10667
|
https://github.com/mlocati/composer-patcher/blob/d8ba45c10b5cf8ac8da3591e09b6afd47fc10667/src/Plugin.php#L399-L416
|
10,903
|
novuso/system
|
RoboFile.php
|
RoboFile.build
|
public function build()
{
$this->yell('Starting default build');
$this->dirRemove();
$this->dirPrepare();
$this->phpLint();
$this->phpTestComplete();
$this->phpCodeStyle();
$this->apiGenerate();
$this->yell('Build complete');
}
|
php
|
public function build()
{
$this->yell('Starting default build');
$this->dirRemove();
$this->dirPrepare();
$this->phpLint();
$this->phpTestComplete();
$this->phpCodeStyle();
$this->apiGenerate();
$this->yell('Build complete');
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"yell",
"(",
"'Starting default build'",
")",
";",
"$",
"this",
"->",
"dirRemove",
"(",
")",
";",
"$",
"this",
"->",
"dirPrepare",
"(",
")",
";",
"$",
"this",
"->",
"phpLint",
"(",
")",
";",
"$",
"this",
"->",
"phpTestComplete",
"(",
")",
";",
"$",
"this",
"->",
"phpCodeStyle",
"(",
")",
";",
"$",
"this",
"->",
"apiGenerate",
"(",
")",
";",
"$",
"this",
"->",
"yell",
"(",
"'Build complete'",
")",
";",
"}"
] |
Runs the default build process
@return void
|
[
"Runs",
"the",
"default",
"build",
"process"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L44-L54
|
10,904
|
novuso/system
|
RoboFile.php
|
RoboFile.integration
|
public function integration()
{
$this->yell('Starting continuous integration build');
$this->dirRemove();
$this->dirPrepare();
$this->phpLint();
$this->phpTestComplete();
$this->phpCodeStyle();
$this->yell('Build complete');
}
|
php
|
public function integration()
{
$this->yell('Starting continuous integration build');
$this->dirRemove();
$this->dirPrepare();
$this->phpLint();
$this->phpTestComplete();
$this->phpCodeStyle();
$this->yell('Build complete');
}
|
[
"public",
"function",
"integration",
"(",
")",
"{",
"$",
"this",
"->",
"yell",
"(",
"'Starting continuous integration build'",
")",
";",
"$",
"this",
"->",
"dirRemove",
"(",
")",
";",
"$",
"this",
"->",
"dirPrepare",
"(",
")",
";",
"$",
"this",
"->",
"phpLint",
"(",
")",
";",
"$",
"this",
"->",
"phpTestComplete",
"(",
")",
";",
"$",
"this",
"->",
"phpCodeStyle",
"(",
")",
";",
"$",
"this",
"->",
"yell",
"(",
"'Build complete'",
")",
";",
"}"
] |
Runs the build process for continuous integration
@return void
|
[
"Runs",
"the",
"build",
"process",
"for",
"continuous",
"integration"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L61-L70
|
10,905
|
novuso/system
|
RoboFile.php
|
RoboFile.install
|
public function install($opts = ['prod' => false])
{
$prod = isset($opts['prod']) && $opts['prod'] ? true : false;
$this->info('Installing project dependencies');
$this->composerInstall(['prod' => $prod]);
$this->info('Project dependencies installed');
}
|
php
|
public function install($opts = ['prod' => false])
{
$prod = isset($opts['prod']) && $opts['prod'] ? true : false;
$this->info('Installing project dependencies');
$this->composerInstall(['prod' => $prod]);
$this->info('Project dependencies installed');
}
|
[
"public",
"function",
"install",
"(",
"$",
"opts",
"=",
"[",
"'prod'",
"=>",
"false",
"]",
")",
"{",
"$",
"prod",
"=",
"isset",
"(",
"$",
"opts",
"[",
"'prod'",
"]",
")",
"&&",
"$",
"opts",
"[",
"'prod'",
"]",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"info",
"(",
"'Installing project dependencies'",
")",
";",
"$",
"this",
"->",
"composerInstall",
"(",
"[",
"'prod'",
"=>",
"$",
"prod",
"]",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Project dependencies installed'",
")",
";",
"}"
] |
Installs project dependencies
@option $prod Optimize for production
@return void
|
[
"Installs",
"project",
"dependencies"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L79-L85
|
10,906
|
novuso/system
|
RoboFile.php
|
RoboFile.update
|
public function update($opts = ['prod' => false])
{
$prod = isset($opts['prod']) && $opts['prod'] ? true : false;
$this->info('Updating project dependencies');
$this->composerUpdate(['prod' => $prod]);
$this->info('Project dependencies updated');
}
|
php
|
public function update($opts = ['prod' => false])
{
$prod = isset($opts['prod']) && $opts['prod'] ? true : false;
$this->info('Updating project dependencies');
$this->composerUpdate(['prod' => $prod]);
$this->info('Project dependencies updated');
}
|
[
"public",
"function",
"update",
"(",
"$",
"opts",
"=",
"[",
"'prod'",
"=>",
"false",
"]",
")",
"{",
"$",
"prod",
"=",
"isset",
"(",
"$",
"opts",
"[",
"'prod'",
"]",
")",
"&&",
"$",
"opts",
"[",
"'prod'",
"]",
"?",
"true",
":",
"false",
";",
"$",
"this",
"->",
"info",
"(",
"'Updating project dependencies'",
")",
";",
"$",
"this",
"->",
"composerUpdate",
"(",
"[",
"'prod'",
"=>",
"$",
"prod",
"]",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Project dependencies updated'",
")",
";",
"}"
] |
Updates project dependencies
@option $prod Optimize for production
@return void
|
[
"Updates",
"project",
"dependencies"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L94-L100
|
10,907
|
novuso/system
|
RoboFile.php
|
RoboFile.apiGenerate
|
public function apiGenerate()
{
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Generating API documentation');
$this->taskExec(sprintf('%s/sami', $paths['bin']))
->arg('update')
->arg(sprintf('%s/sami.php', $paths['build']))
->printOutput(true)
->run();
$this->info('API documentation generated');
}
|
php
|
public function apiGenerate()
{
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Generating API documentation');
$this->taskExec(sprintf('%s/sami', $paths['bin']))
->arg('update')
->arg(sprintf('%s/sami.php', $paths['build']))
->printOutput(true)
->run();
$this->info('API documentation generated');
}
|
[
"public",
"function",
"apiGenerate",
"(",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"this",
"->",
"stopOnFail",
"(",
"true",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Generating API documentation'",
")",
";",
"$",
"this",
"->",
"taskExec",
"(",
"sprintf",
"(",
"'%s/sami'",
",",
"$",
"paths",
"[",
"'bin'",
"]",
")",
")",
"->",
"arg",
"(",
"'update'",
")",
"->",
"arg",
"(",
"sprintf",
"(",
"'%s/sami.php'",
",",
"$",
"paths",
"[",
"'build'",
"]",
")",
")",
"->",
"printOutput",
"(",
"true",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'API documentation generated'",
")",
";",
"}"
] |
Generates API documentation
@return void
|
[
"Generates",
"API",
"documentation"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L111-L122
|
10,908
|
novuso/system
|
RoboFile.php
|
RoboFile.composerInstall
|
public function composerInstall($opts = ['prod' => false])
{
$prod = isset($opts['prod']) && $opts['prod'] ? true : false;
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Installing Composer dependencies');
$command = $this->taskExec('composer')->dir($paths['root']);
$command
->arg('install')
->option('prefer-dist');
if ($prod) {
$command->option('no-dev');
$command->option('optimize-autoloader');
}
$command
->printOutput(true)
->run();
$this->info('Composer dependencies installed');
}
|
php
|
public function composerInstall($opts = ['prod' => false])
{
$prod = isset($opts['prod']) && $opts['prod'] ? true : false;
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Installing Composer dependencies');
$command = $this->taskExec('composer')->dir($paths['root']);
$command
->arg('install')
->option('prefer-dist');
if ($prod) {
$command->option('no-dev');
$command->option('optimize-autoloader');
}
$command
->printOutput(true)
->run();
$this->info('Composer dependencies installed');
}
|
[
"public",
"function",
"composerInstall",
"(",
"$",
"opts",
"=",
"[",
"'prod'",
"=>",
"false",
"]",
")",
"{",
"$",
"prod",
"=",
"isset",
"(",
"$",
"opts",
"[",
"'prod'",
"]",
")",
"&&",
"$",
"opts",
"[",
"'prod'",
"]",
"?",
"true",
":",
"false",
";",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"this",
"->",
"stopOnFail",
"(",
"true",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Installing Composer dependencies'",
")",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"taskExec",
"(",
"'composer'",
")",
"->",
"dir",
"(",
"$",
"paths",
"[",
"'root'",
"]",
")",
";",
"$",
"command",
"->",
"arg",
"(",
"'install'",
")",
"->",
"option",
"(",
"'prefer-dist'",
")",
";",
"if",
"(",
"$",
"prod",
")",
"{",
"$",
"command",
"->",
"option",
"(",
"'no-dev'",
")",
";",
"$",
"command",
"->",
"option",
"(",
"'optimize-autoloader'",
")",
";",
"}",
"$",
"command",
"->",
"printOutput",
"(",
"true",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Composer dependencies installed'",
")",
";",
"}"
] |
Installs Composer dependencies
@option $prod Optimize for production
@return void
|
[
"Installs",
"Composer",
"dependencies"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L135-L153
|
10,909
|
novuso/system
|
RoboFile.php
|
RoboFile.composerUpdateHash
|
public function composerUpdateHash()
{
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Updating Composer lock file');
$command = $this->taskExec('composer')->dir($paths['root']);
$command
->arg('update')
->option('lock')
->printOutput(true)
->run();
$this->info('Composer lock file updated');
}
|
php
|
public function composerUpdateHash()
{
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Updating Composer lock file');
$command = $this->taskExec('composer')->dir($paths['root']);
$command
->arg('update')
->option('lock')
->printOutput(true)
->run();
$this->info('Composer lock file updated');
}
|
[
"public",
"function",
"composerUpdateHash",
"(",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"this",
"->",
"stopOnFail",
"(",
"true",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Updating Composer lock file'",
")",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"taskExec",
"(",
"'composer'",
")",
"->",
"dir",
"(",
"$",
"paths",
"[",
"'root'",
"]",
")",
";",
"$",
"command",
"->",
"arg",
"(",
"'update'",
")",
"->",
"option",
"(",
"'lock'",
")",
"->",
"printOutput",
"(",
"true",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Composer lock file updated'",
")",
";",
"}"
] |
Updates composer.lock file hash
@return void
|
[
"Updates",
"composer",
".",
"lock",
"file",
"hash"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L187-L199
|
10,910
|
novuso/system
|
RoboFile.php
|
RoboFile.dirPrepare
|
public function dirPrepare()
{
$paths = $this->getPaths();
$filesystem = $this->getFilesystem();
$this->info('Preparing artifact directories');
$filesystem->mkdir([
$paths['coverage'],
$paths['reports']
]);
$this->info('Artifact directories prepared');
}
|
php
|
public function dirPrepare()
{
$paths = $this->getPaths();
$filesystem = $this->getFilesystem();
$this->info('Preparing artifact directories');
$filesystem->mkdir([
$paths['coverage'],
$paths['reports']
]);
$this->info('Artifact directories prepared');
}
|
[
"public",
"function",
"dirPrepare",
"(",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"filesystem",
"=",
"$",
"this",
"->",
"getFilesystem",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Preparing artifact directories'",
")",
";",
"$",
"filesystem",
"->",
"mkdir",
"(",
"[",
"$",
"paths",
"[",
"'coverage'",
"]",
",",
"$",
"paths",
"[",
"'reports'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Artifact directories prepared'",
")",
";",
"}"
] |
Prepares artifact directories
@return void
|
[
"Prepares",
"artifact",
"directories"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L210-L220
|
10,911
|
novuso/system
|
RoboFile.php
|
RoboFile.dirRemove
|
public function dirRemove()
{
$paths = $this->getPaths();
$filesystem = $this->getFilesystem();
$this->info('Removing artifact directories');
$filesystem->remove([
$paths['coverage'],
$paths['reports']
]);
$this->info('Artifact directories removed');
}
|
php
|
public function dirRemove()
{
$paths = $this->getPaths();
$filesystem = $this->getFilesystem();
$this->info('Removing artifact directories');
$filesystem->remove([
$paths['coverage'],
$paths['reports']
]);
$this->info('Artifact directories removed');
}
|
[
"public",
"function",
"dirRemove",
"(",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"filesystem",
"=",
"$",
"this",
"->",
"getFilesystem",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Removing artifact directories'",
")",
";",
"$",
"filesystem",
"->",
"remove",
"(",
"[",
"$",
"paths",
"[",
"'coverage'",
"]",
",",
"$",
"paths",
"[",
"'reports'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Artifact directories removed'",
")",
";",
"}"
] |
Removes artifact directories
@return void
|
[
"Removes",
"artifact",
"directories"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L227-L237
|
10,912
|
novuso/system
|
RoboFile.php
|
RoboFile.phpCodeStyle
|
public function phpCodeStyle($opts = ['report' => false])
{
$report = isset($opts['report']) && $opts['report'] ? true : false;
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Starting code style check for PHP source files');
$command = $this->taskExec('php');
$command
->arg(sprintf('%s/phpcs', $paths['lib']));
if ($report) {
$command->option('report=checkstyle');
$command->option(sprintf('report-file=%s/checkstyle.xml', $paths['reports']));
$command->option('warning-severity=0');
}
$command
->option(sprintf('standard=%s/phpcs.xml', $paths['build']))
->arg($paths['src'])
->printOutput($report ? false : true)
->run();
$this->info('PHP source files passed code style check');
}
|
php
|
public function phpCodeStyle($opts = ['report' => false])
{
$report = isset($opts['report']) && $opts['report'] ? true : false;
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Starting code style check for PHP source files');
$command = $this->taskExec('php');
$command
->arg(sprintf('%s/phpcs', $paths['lib']));
if ($report) {
$command->option('report=checkstyle');
$command->option(sprintf('report-file=%s/checkstyle.xml', $paths['reports']));
$command->option('warning-severity=0');
}
$command
->option(sprintf('standard=%s/phpcs.xml', $paths['build']))
->arg($paths['src'])
->printOutput($report ? false : true)
->run();
$this->info('PHP source files passed code style check');
}
|
[
"public",
"function",
"phpCodeStyle",
"(",
"$",
"opts",
"=",
"[",
"'report'",
"=>",
"false",
"]",
")",
"{",
"$",
"report",
"=",
"isset",
"(",
"$",
"opts",
"[",
"'report'",
"]",
")",
"&&",
"$",
"opts",
"[",
"'report'",
"]",
"?",
"true",
":",
"false",
";",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"this",
"->",
"stopOnFail",
"(",
"true",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Starting code style check for PHP source files'",
")",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"taskExec",
"(",
"'php'",
")",
";",
"$",
"command",
"->",
"arg",
"(",
"sprintf",
"(",
"'%s/phpcs'",
",",
"$",
"paths",
"[",
"'lib'",
"]",
")",
")",
";",
"if",
"(",
"$",
"report",
")",
"{",
"$",
"command",
"->",
"option",
"(",
"'report=checkstyle'",
")",
";",
"$",
"command",
"->",
"option",
"(",
"sprintf",
"(",
"'report-file=%s/checkstyle.xml'",
",",
"$",
"paths",
"[",
"'reports'",
"]",
")",
")",
";",
"$",
"command",
"->",
"option",
"(",
"'warning-severity=0'",
")",
";",
"}",
"$",
"command",
"->",
"option",
"(",
"sprintf",
"(",
"'standard=%s/phpcs.xml'",
",",
"$",
"paths",
"[",
"'build'",
"]",
")",
")",
"->",
"arg",
"(",
"$",
"paths",
"[",
"'src'",
"]",
")",
"->",
"printOutput",
"(",
"$",
"report",
"?",
"false",
":",
"true",
")",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'PHP source files passed code style check'",
")",
";",
"}"
] |
Performs code style check on PHP source
@option $report Generate an XML report for continuous integration
@return void
|
[
"Performs",
"code",
"style",
"check",
"on",
"PHP",
"source"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L250-L270
|
10,913
|
novuso/system
|
RoboFile.php
|
RoboFile.phpLint
|
public function phpLint()
{
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Starting syntax check of PHP source files');
$iterator = Finder::create()
->files()
->name('*.php')
->in($paths['src'])
->sortByName();
/** @var SplFileInfo $file */
foreach ($iterator as $file) {
$command = $this->taskExec('php');
$command
->arg('-l')
->arg($file->getRealPath())
->printOutput(false)
->run();
}
$this->info('PHP source files passed syntax check');
}
|
php
|
public function phpLint()
{
$paths = $this->getPaths();
$this->stopOnFail(true);
$this->info('Starting syntax check of PHP source files');
$iterator = Finder::create()
->files()
->name('*.php')
->in($paths['src'])
->sortByName();
/** @var SplFileInfo $file */
foreach ($iterator as $file) {
$command = $this->taskExec('php');
$command
->arg('-l')
->arg($file->getRealPath())
->printOutput(false)
->run();
}
$this->info('PHP source files passed syntax check');
}
|
[
"public",
"function",
"phpLint",
"(",
")",
"{",
"$",
"paths",
"=",
"$",
"this",
"->",
"getPaths",
"(",
")",
";",
"$",
"this",
"->",
"stopOnFail",
"(",
"true",
")",
";",
"$",
"this",
"->",
"info",
"(",
"'Starting syntax check of PHP source files'",
")",
";",
"$",
"iterator",
"=",
"Finder",
"::",
"create",
"(",
")",
"->",
"files",
"(",
")",
"->",
"name",
"(",
"'*.php'",
")",
"->",
"in",
"(",
"$",
"paths",
"[",
"'src'",
"]",
")",
"->",
"sortByName",
"(",
")",
";",
"/** @var SplFileInfo $file */",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"taskExec",
"(",
"'php'",
")",
";",
"$",
"command",
"->",
"arg",
"(",
"'-l'",
")",
"->",
"arg",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
"->",
"printOutput",
"(",
"false",
")",
"->",
"run",
"(",
")",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"'PHP source files passed syntax check'",
")",
";",
"}"
] |
Performs syntax check on PHP source
@return void
|
[
"Performs",
"syntax",
"check",
"on",
"PHP",
"source"
] |
e34038b391826edc68d0b5fccfba96642de9d6f0
|
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/RoboFile.php#L277-L297
|
10,914
|
bishopb/vanilla
|
library/core/class.theme.php
|
Gdn_Theme.BulletItem
|
public static function BulletItem($Section, $Return = TRUE) {
$Result = '';
if (self::$_BulletSection === FALSE)
self::$_BulletSection = $Section;
elseif (self::$_BulletSection != $Section) {
$Result = "<!-- $Section -->".self::$_BulletSep;
self::$_BulletSection = $Section;
}
if ($Return)
return $Result;
else
echo $Result;
}
|
php
|
public static function BulletItem($Section, $Return = TRUE) {
$Result = '';
if (self::$_BulletSection === FALSE)
self::$_BulletSection = $Section;
elseif (self::$_BulletSection != $Section) {
$Result = "<!-- $Section -->".self::$_BulletSep;
self::$_BulletSection = $Section;
}
if ($Return)
return $Result;
else
echo $Result;
}
|
[
"public",
"static",
"function",
"BulletItem",
"(",
"$",
"Section",
",",
"$",
"Return",
"=",
"TRUE",
")",
"{",
"$",
"Result",
"=",
"''",
";",
"if",
"(",
"self",
"::",
"$",
"_BulletSection",
"===",
"FALSE",
")",
"self",
"::",
"$",
"_BulletSection",
"=",
"$",
"Section",
";",
"elseif",
"(",
"self",
"::",
"$",
"_BulletSection",
"!=",
"$",
"Section",
")",
"{",
"$",
"Result",
"=",
"\"<!-- $Section -->\"",
".",
"self",
"::",
"$",
"_BulletSep",
";",
"self",
"::",
"$",
"_BulletSection",
"=",
"$",
"Section",
";",
"}",
"if",
"(",
"$",
"Return",
")",
"return",
"$",
"Result",
";",
"else",
"echo",
"$",
"Result",
";",
"}"
] |
Call before writing an item and it will optionally write a bullet seperator.
@param string $Section The name of the section.
@param bool $Return whether or not to return the result or echo it.
@return string
@since 2.1
|
[
"Call",
"before",
"writing",
"an",
"item",
"and",
"it",
"will",
"optionally",
"write",
"a",
"bullet",
"seperator",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.theme.php#L107-L121
|
10,915
|
bishopb/vanilla
|
library/core/class.theme.php
|
Gdn_Theme.BulletRow
|
public static function BulletRow($Sep = FALSE) {
if (!$Sep) {
if (!self::$_BulletSep)
self::$_BulletSep = ' '.Bullet().' ';
} else {
self::$_BulletSep = $Sep;
}
self::$_BulletSection = FALSE;
}
|
php
|
public static function BulletRow($Sep = FALSE) {
if (!$Sep) {
if (!self::$_BulletSep)
self::$_BulletSep = ' '.Bullet().' ';
} else {
self::$_BulletSep = $Sep;
}
self::$_BulletSection = FALSE;
}
|
[
"public",
"static",
"function",
"BulletRow",
"(",
"$",
"Sep",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"Sep",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_BulletSep",
")",
"self",
"::",
"$",
"_BulletSep",
"=",
"' '",
".",
"Bullet",
"(",
")",
".",
"' '",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"_BulletSep",
"=",
"$",
"Sep",
";",
"}",
"self",
"::",
"$",
"_BulletSection",
"=",
"FALSE",
";",
"}"
] |
Call before starting a row of bullet-seperated items.
@param strng|bool $Sep The seperator used to seperate each section.
@since 2.1
|
[
"Call",
"before",
"starting",
"a",
"row",
"of",
"bullet",
"-",
"seperated",
"items",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.theme.php#L129-L137
|
10,916
|
bishopb/vanilla
|
library/core/class.theme.php
|
Gdn_Theme.InSection
|
public static function InSection($Section) {
$Section = (array)$Section;
foreach ($Section as $Name) {
if (isset(self::$_Section[$Name]))
return TRUE;
}
return FALSE;
}
|
php
|
public static function InSection($Section) {
$Section = (array)$Section;
foreach ($Section as $Name) {
if (isset(self::$_Section[$Name]))
return TRUE;
}
return FALSE;
}
|
[
"public",
"static",
"function",
"InSection",
"(",
"$",
"Section",
")",
"{",
"$",
"Section",
"=",
"(",
"array",
")",
"$",
"Section",
";",
"foreach",
"(",
"$",
"Section",
"as",
"$",
"Name",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_Section",
"[",
"$",
"Name",
"]",
")",
")",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] |
Returns whether or not the page is in the current section.
@param string|array $Section
|
[
"Returns",
"whether",
"or",
"not",
"the",
"page",
"is",
"in",
"the",
"current",
"section",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.theme.php#L145-L152
|
10,917
|
bishopb/vanilla
|
library/core/class.theme.php
|
Gdn_Theme.Logo
|
public static function Logo() {
$Logo = C('Garden.Logo');
if ($Logo) {
$Logo = ltrim($Logo, '/');
// Fix the logo path.
if (StringBeginsWith($Logo, 'uploads/'))
$Logo = substr($Logo, strlen('uploads/'));
}
$Title = C('Garden.Title', 'Title');
echo $Logo ? Img(Gdn_Upload::Url($Logo), array('alt' => $Title)) : $Title;
}
|
php
|
public static function Logo() {
$Logo = C('Garden.Logo');
if ($Logo) {
$Logo = ltrim($Logo, '/');
// Fix the logo path.
if (StringBeginsWith($Logo, 'uploads/'))
$Logo = substr($Logo, strlen('uploads/'));
}
$Title = C('Garden.Title', 'Title');
echo $Logo ? Img(Gdn_Upload::Url($Logo), array('alt' => $Title)) : $Title;
}
|
[
"public",
"static",
"function",
"Logo",
"(",
")",
"{",
"$",
"Logo",
"=",
"C",
"(",
"'Garden.Logo'",
")",
";",
"if",
"(",
"$",
"Logo",
")",
"{",
"$",
"Logo",
"=",
"ltrim",
"(",
"$",
"Logo",
",",
"'/'",
")",
";",
"// Fix the logo path.",
"if",
"(",
"StringBeginsWith",
"(",
"$",
"Logo",
",",
"'uploads/'",
")",
")",
"$",
"Logo",
"=",
"substr",
"(",
"$",
"Logo",
",",
"strlen",
"(",
"'uploads/'",
")",
")",
";",
"}",
"$",
"Title",
"=",
"C",
"(",
"'Garden.Title'",
",",
"'Title'",
")",
";",
"echo",
"$",
"Logo",
"?",
"Img",
"(",
"Gdn_Upload",
"::",
"Url",
"(",
"$",
"Logo",
")",
",",
"array",
"(",
"'alt'",
"=>",
"$",
"Title",
")",
")",
":",
"$",
"Title",
";",
"}"
] |
Renders the banner logo, or just the banner title if the logo is not defined.
|
[
"Renders",
"the",
"banner",
"logo",
"or",
"just",
"the",
"banner",
"title",
"if",
"the",
"logo",
"is",
"not",
"defined",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.theme.php#L314-L324
|
10,918
|
bishopb/vanilla
|
library/core/class.theme.php
|
Gdn_Theme.Section
|
public static function Section($Section, $Method = 'add') {
$Section = array_fill_keys((array)$Section, TRUE);
switch (strtolower($Method)) {
case 'add':
self::$_Section = array_merge(self::$_Section, $Section);
break;
case 'remove':
self::$_Section = array_diff_key(self::$_Section, $Section);
break;
case 'set':
self::$_Section = $Section;
break;
case 'get':
default:
return array_keys(self::$_Section);
}
}
|
php
|
public static function Section($Section, $Method = 'add') {
$Section = array_fill_keys((array)$Section, TRUE);
switch (strtolower($Method)) {
case 'add':
self::$_Section = array_merge(self::$_Section, $Section);
break;
case 'remove':
self::$_Section = array_diff_key(self::$_Section, $Section);
break;
case 'set':
self::$_Section = $Section;
break;
case 'get':
default:
return array_keys(self::$_Section);
}
}
|
[
"public",
"static",
"function",
"Section",
"(",
"$",
"Section",
",",
"$",
"Method",
"=",
"'add'",
")",
"{",
"$",
"Section",
"=",
"array_fill_keys",
"(",
"(",
"array",
")",
"$",
"Section",
",",
"TRUE",
")",
";",
"switch",
"(",
"strtolower",
"(",
"$",
"Method",
")",
")",
"{",
"case",
"'add'",
":",
"self",
"::",
"$",
"_Section",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"_Section",
",",
"$",
"Section",
")",
";",
"break",
";",
"case",
"'remove'",
":",
"self",
"::",
"$",
"_Section",
"=",
"array_diff_key",
"(",
"self",
"::",
"$",
"_Section",
",",
"$",
"Section",
")",
";",
"break",
";",
"case",
"'set'",
":",
"self",
"::",
"$",
"_Section",
"=",
"$",
"Section",
";",
"break",
";",
"case",
"'get'",
":",
"default",
":",
"return",
"array_keys",
"(",
"self",
"::",
"$",
"_Section",
")",
";",
"}",
"}"
] |
The current section the site is in. This can be one or more values. Think of it like a server-side css-class.
@since 2.1
@param string $Section The name of the section
@param string $Method One of:
- add
- remove
- set
- get
|
[
"The",
"current",
"section",
"the",
"site",
"is",
"in",
".",
"This",
"can",
"be",
"one",
"or",
"more",
"values",
".",
"Think",
"of",
"it",
"like",
"a",
"server",
"-",
"side",
"css",
"-",
"class",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.theme.php#L391-L409
|
10,919
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.escapeHtml
|
public function escapeHtml($text)
{
if (!$this->escapeHtmlHelper) {
$this->escapeHtmlHelper = $this->getView()->plugin('escapehtml');
if (!$this->escapeHtmlHelper instanceof EscapeHtml) {
throw new Exception\RuntimeException('Helper not loaded: escapeHtml');
}
}
return $this->escapeHtmlHelper->__invoke($text);
}
|
php
|
public function escapeHtml($text)
{
if (!$this->escapeHtmlHelper) {
$this->escapeHtmlHelper = $this->getView()->plugin('escapehtml');
if (!$this->escapeHtmlHelper instanceof EscapeHtml) {
throw new Exception\RuntimeException('Helper not loaded: escapeHtml');
}
}
return $this->escapeHtmlHelper->__invoke($text);
}
|
[
"public",
"function",
"escapeHtml",
"(",
"$",
"text",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"escapeHtmlHelper",
")",
"{",
"$",
"this",
"->",
"escapeHtmlHelper",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"plugin",
"(",
"'escapehtml'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"escapeHtmlHelper",
"instanceof",
"EscapeHtml",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Helper not loaded: escapeHtml'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"escapeHtmlHelper",
"->",
"__invoke",
"(",
"$",
"text",
")",
";",
"}"
] |
Escape html using view helper
@param string $text
@return string
|
[
"Escape",
"html",
"using",
"view",
"helper"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L81-L90
|
10,920
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.escapeHtmlAttribute
|
public function escapeHtmlAttribute($attribute)
{
if (!$this->escapeHtmlAttrHelper) {
$this->escapeHtmlAttrHelper = $this->getView()->plugin('escapehtmlattr');
if (!$this->escapeHtmlAttrHelper instanceof EscapeHtmlAttr) {
throw new Exception\RuntimeException('Helper not loaded: escapeHtmlAttr');
}
}
return $this->escapeHtmlAttrHelper->__invoke($attribute);
}
|
php
|
public function escapeHtmlAttribute($attribute)
{
if (!$this->escapeHtmlAttrHelper) {
$this->escapeHtmlAttrHelper = $this->getView()->plugin('escapehtmlattr');
if (!$this->escapeHtmlAttrHelper instanceof EscapeHtmlAttr) {
throw new Exception\RuntimeException('Helper not loaded: escapeHtmlAttr');
}
}
return $this->escapeHtmlAttrHelper->__invoke($attribute);
}
|
[
"public",
"function",
"escapeHtmlAttribute",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"escapeHtmlAttrHelper",
")",
"{",
"$",
"this",
"->",
"escapeHtmlAttrHelper",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"plugin",
"(",
"'escapehtmlattr'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"escapeHtmlAttrHelper",
"instanceof",
"EscapeHtmlAttr",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Helper not loaded: escapeHtmlAttr'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"escapeHtmlAttrHelper",
"->",
"__invoke",
"(",
"$",
"attribute",
")",
";",
"}"
] |
Escape html attribute using view helper
@param string $attribute
@return string
|
[
"Escape",
"html",
"attribute",
"using",
"view",
"helper"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L98-L107
|
10,921
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.removeClass
|
public function removeClass($class)
{
$index = array_search((string) $class, $this->class);
if ($index !== false) {
unset($this->class[$index]);
}
return $this;
}
|
php
|
public function removeClass($class)
{
$index = array_search((string) $class, $this->class);
if ($index !== false) {
unset($this->class[$index]);
}
return $this;
}
|
[
"public",
"function",
"removeClass",
"(",
"$",
"class",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"(",
"string",
")",
"$",
"class",
",",
"$",
"this",
"->",
"class",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"class",
"[",
"$",
"index",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove a class from this element
@param string $class
@return self
|
[
"Remove",
"a",
"class",
"from",
"this",
"element"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L171-L178
|
10,922
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.setAttribute
|
public function setAttribute($key, $valueue)
{
if ($key === 'class') {
$this->setClass([$valueue]);
}
$this->attributes[$key] = $valueue;
return $this;
}
|
php
|
public function setAttribute($key, $valueue)
{
if ($key === 'class') {
$this->setClass([$valueue]);
}
$this->attributes[$key] = $valueue;
return $this;
}
|
[
"public",
"function",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"valueue",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"'class'",
")",
"{",
"$",
"this",
"->",
"setClass",
"(",
"[",
"$",
"valueue",
"]",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
"=",
"$",
"valueue",
";",
"return",
"$",
"this",
";",
"}"
] |
Set an attribute on this element
@param string $key
@param string $valueue
@return self
|
[
"Set",
"an",
"attribute",
"on",
"this",
"element"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L219-L226
|
10,923
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.setAttributes
|
public function setAttributes($attributes)
{
if (isset($attributes['class'])) {
$class = $attributes['class'];
$this->setClass([$class]);
unset($attributes['class']);
}
$this->attributes = $attributes;
return $this;
}
|
php
|
public function setAttributes($attributes)
{
if (isset($attributes['class'])) {
$class = $attributes['class'];
$this->setClass([$class]);
unset($attributes['class']);
}
$this->attributes = $attributes;
return $this;
}
|
[
"public",
"function",
"setAttributes",
"(",
"$",
"attributes",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"attributes",
"[",
"'class'",
"]",
";",
"$",
"this",
"->",
"setClass",
"(",
"[",
"$",
"class",
"]",
")",
";",
"unset",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"=",
"$",
"attributes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set attribute associative array
@param string[] $attributes
@return self
|
[
"Set",
"attribute",
"associative",
"array"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L251-L260
|
10,924
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.getAttributes
|
public function getAttributes()
{
$id = $this->getId();
$attributes = $this->attributes;
$class = implode(' ', $this->getClass());
if ($id) {
$attributes['id'] = $this->normalizeId($id);
}
if ($class) {
$attributes['class'] = $class;
}
return $attributes;
}
|
php
|
public function getAttributes()
{
$id = $this->getId();
$attributes = $this->attributes;
$class = implode(' ', $this->getClass());
if ($id) {
$attributes['id'] = $this->normalizeId($id);
}
if ($class) {
$attributes['class'] = $class;
}
return $attributes;
}
|
[
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getId",
"(",
")",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attributes",
";",
"$",
"class",
"=",
"implode",
"(",
"' '",
",",
"$",
"this",
"->",
"getClass",
"(",
")",
")",
";",
"if",
"(",
"$",
"id",
")",
"{",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"$",
"this",
"->",
"normalizeId",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"class",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Get attribute associative array
@return string[]
|
[
"Get",
"attribute",
"associative",
"array"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L281-L293
|
10,925
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.renderElement
|
protected function renderElement($content = null)
{
// Get element parts
$element = $this->getElement();
$attributes = $this->getAttributesAsString();
// Create html
$html = '<' . $element;
if ($attributes) {
$html .= $attributes;
}
// Create closing tag
if (is_string($content)) {
$html .= '>' . $content . '</' . $element;
}
$html .= $this->getClosingBracket();
return $html;
}
|
php
|
protected function renderElement($content = null)
{
// Get element parts
$element = $this->getElement();
$attributes = $this->getAttributesAsString();
// Create html
$html = '<' . $element;
if ($attributes) {
$html .= $attributes;
}
// Create closing tag
if (is_string($content)) {
$html .= '>' . $content . '</' . $element;
}
$html .= $this->getClosingBracket();
return $html;
}
|
[
"protected",
"function",
"renderElement",
"(",
"$",
"content",
"=",
"null",
")",
"{",
"// Get element parts",
"$",
"element",
"=",
"$",
"this",
"->",
"getElement",
"(",
")",
";",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributesAsString",
"(",
")",
";",
"// Create html",
"$",
"html",
"=",
"'<'",
".",
"$",
"element",
";",
"if",
"(",
"$",
"attributes",
")",
"{",
"$",
"html",
".=",
"$",
"attributes",
";",
"}",
"// Create closing tag",
"if",
"(",
"is_string",
"(",
"$",
"content",
")",
")",
"{",
"$",
"html",
".=",
"'>'",
".",
"$",
"content",
".",
"'</'",
".",
"$",
"element",
";",
"}",
"$",
"html",
".=",
"$",
"this",
"->",
"getClosingBracket",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Render html element
@param string $content
@return string
|
[
"Render",
"html",
"element"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L324-L343
|
10,926
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.htmlAttribs
|
protected function htmlAttribs($attribs)
{
$html = '';
$escapeHtml = $this->getView()->plugin('escapehtml');
$escapeHtmlAttr = $this->getView()->plugin('escapehtmlattr');
foreach ((array) $attribs as $key => $value) {
$key = $escapeHtml($key);
$this->cleanHtmlAttribValue($key, $value);
if (!$value) {
continue;
}
switch ($key) {
case 'class':
case 'href':
$value = $escapeHtml($value);
break;
default:
$value = $escapeHtmlAttr($value);
break;
}
if ('id' == $key) {
$value = $this->normalizeId($value);
}
$html .= $this->getKeyValuePair($key, $value);
}
return $html;
}
|
php
|
protected function htmlAttribs($attribs)
{
$html = '';
$escapeHtml = $this->getView()->plugin('escapehtml');
$escapeHtmlAttr = $this->getView()->plugin('escapehtmlattr');
foreach ((array) $attribs as $key => $value) {
$key = $escapeHtml($key);
$this->cleanHtmlAttribValue($key, $value);
if (!$value) {
continue;
}
switch ($key) {
case 'class':
case 'href':
$value = $escapeHtml($value);
break;
default:
$value = $escapeHtmlAttr($value);
break;
}
if ('id' == $key) {
$value = $this->normalizeId($value);
}
$html .= $this->getKeyValuePair($key, $value);
}
return $html;
}
|
[
"protected",
"function",
"htmlAttribs",
"(",
"$",
"attribs",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"escapeHtml",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"plugin",
"(",
"'escapehtml'",
")",
";",
"$",
"escapeHtmlAttr",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"plugin",
"(",
"'escapehtmlattr'",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"attribs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"$",
"escapeHtml",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"cleanHtmlAttribValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'class'",
":",
"case",
"'href'",
":",
"$",
"value",
"=",
"$",
"escapeHtml",
"(",
"$",
"value",
")",
";",
"break",
";",
"default",
":",
"$",
"value",
"=",
"$",
"escapeHtmlAttr",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"if",
"(",
"'id'",
"==",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeId",
"(",
"$",
"value",
")",
";",
"}",
"$",
"html",
".=",
"$",
"this",
"->",
"getKeyValuePair",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"html",
";",
"}"
] |
Converts an associative array to a string of tag attributes.
@access public
@param array $attribs From this array, each key-value pair is
converted to an attribute name and value.
@return string The XHTML for the attributes.
|
[
"Converts",
"an",
"associative",
"array",
"to",
"a",
"string",
"of",
"tag",
"attributes",
"."
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L355-L386
|
10,927
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.getKeyValuePair
|
protected function getKeyValuePair($key, $value)
{
if (strpos($value, '"') !== false) {
return ' ' . $key . '=\'' . $value . '\'';
}
return ' ' . $key . '="' . $value . '"';
}
|
php
|
protected function getKeyValuePair($key, $value)
{
if (strpos($value, '"') !== false) {
return ' ' . $key . '=\'' . $value . '\'';
}
return ' ' . $key . '="' . $value . '"';
}
|
[
"protected",
"function",
"getKeyValuePair",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'\"'",
")",
"!==",
"false",
")",
"{",
"return",
"' '",
".",
"$",
"key",
".",
"'=\\''",
".",
"$",
"value",
".",
"'\\''",
";",
"}",
"return",
"' '",
".",
"$",
"key",
".",
"'=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"}"
] |
Get key value pair string
@param string $key The parameter key
@param string $value The parameter value
@return string
|
[
"Get",
"key",
"value",
"pair",
"string"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L395-L401
|
10,928
|
internalsystemerror/ise-module-bootstrap
|
src/View/Helper/HtmlElementTrait.php
|
HtmlElementTrait.getHtmlAttribValue
|
protected function getHtmlAttribValue($key, $value)
{
if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) {
// Don't escape event attributes; _do_ substitute double quotes with singles
if (!is_scalar($value)) {
// Non-scalar data should be cast to JSON first
return Json::encode($value);
}
return $value;
}
if (is_array($value)) {
return implode(' ', $value);
}
return $value;
}
|
php
|
protected function getHtmlAttribValue($key, $value)
{
if (('on' == substr($key, 0, 2)) || ('constraints' == $key)) {
// Don't escape event attributes; _do_ substitute double quotes with singles
if (!is_scalar($value)) {
// Non-scalar data should be cast to JSON first
return Json::encode($value);
}
return $value;
}
if (is_array($value)) {
return implode(' ', $value);
}
return $value;
}
|
[
"protected",
"function",
"getHtmlAttribValue",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"(",
"'on'",
"==",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"2",
")",
")",
"||",
"(",
"'constraints'",
"==",
"$",
"key",
")",
")",
"{",
"// Don't escape event attributes; _do_ substitute double quotes with singles",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"// Non-scalar data should be cast to JSON first",
"return",
"Json",
"::",
"encode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"implode",
"(",
"' '",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Get html attribute value
@param string $key
@param string $value
@return string
@SuppressWarnings(PHPMD.StaticAccess)
|
[
"Get",
"html",
"attribute",
"value"
] |
289afa531a12e6159568b592b95964374442e850
|
https://github.com/internalsystemerror/ise-module-bootstrap/blob/289afa531a12e6159568b592b95964374442e850/src/View/Helper/HtmlElementTrait.php#L423-L439
|
10,929
|
romanmatyus/FileMailer
|
src/FileMailer/MailPanelExtension.php
|
MailPanelExtension.beforeCompile
|
public function beforeCompile()
{
$builder = $this->getContainerBuilder();
$this->validateConfig($this->defaults);
$config = $this->getConfig($this->defaults);
foreach ($builder->findByType('Nette\Mail\IMailer') as $name => $def) {
$builder->removeDefinition($name);
}
if ($config['debugger'] && interface_exists('Tracy\IBarPanel')) {
$builder->addDefinition($this->prefix('panel'))
->setClass('RM\MailPanel')
->addSetup('$newMessageTime', [$config['newMessageTime']])
->addSetup('$show', [array_unique($config['show'])])
->addSetup('$autoremove', [$config['autoremove']])
->addSetup('$hideEmpty', [$config['hideEmpty']]);
}
$builder->addDefinition($this->prefix('mailer'))
->setClass('RM\FileMailer', [Helpers::expand($config['tempDir'], $builder->parameters)])
->addSetup('@RM\MailPanel::setFileMailer', ['@self'])
->addSetup('@Tracy\Bar::addPanel', [$this->prefix('@panel')]);
}
|
php
|
public function beforeCompile()
{
$builder = $this->getContainerBuilder();
$this->validateConfig($this->defaults);
$config = $this->getConfig($this->defaults);
foreach ($builder->findByType('Nette\Mail\IMailer') as $name => $def) {
$builder->removeDefinition($name);
}
if ($config['debugger'] && interface_exists('Tracy\IBarPanel')) {
$builder->addDefinition($this->prefix('panel'))
->setClass('RM\MailPanel')
->addSetup('$newMessageTime', [$config['newMessageTime']])
->addSetup('$show', [array_unique($config['show'])])
->addSetup('$autoremove', [$config['autoremove']])
->addSetup('$hideEmpty', [$config['hideEmpty']]);
}
$builder->addDefinition($this->prefix('mailer'))
->setClass('RM\FileMailer', [Helpers::expand($config['tempDir'], $builder->parameters)])
->addSetup('@RM\MailPanel::setFileMailer', ['@self'])
->addSetup('@Tracy\Bar::addPanel', [$this->prefix('@panel')]);
}
|
[
"public",
"function",
"beforeCompile",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"this",
"->",
"validateConfig",
"(",
"$",
"this",
"->",
"defaults",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"$",
"this",
"->",
"defaults",
")",
";",
"foreach",
"(",
"$",
"builder",
"->",
"findByType",
"(",
"'Nette\\Mail\\IMailer'",
")",
"as",
"$",
"name",
"=>",
"$",
"def",
")",
"{",
"$",
"builder",
"->",
"removeDefinition",
"(",
"$",
"name",
")",
";",
"}",
"if",
"(",
"$",
"config",
"[",
"'debugger'",
"]",
"&&",
"interface_exists",
"(",
"'Tracy\\IBarPanel'",
")",
")",
"{",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'panel'",
")",
")",
"->",
"setClass",
"(",
"'RM\\MailPanel'",
")",
"->",
"addSetup",
"(",
"'$newMessageTime'",
",",
"[",
"$",
"config",
"[",
"'newMessageTime'",
"]",
"]",
")",
"->",
"addSetup",
"(",
"'$show'",
",",
"[",
"array_unique",
"(",
"$",
"config",
"[",
"'show'",
"]",
")",
"]",
")",
"->",
"addSetup",
"(",
"'$autoremove'",
",",
"[",
"$",
"config",
"[",
"'autoremove'",
"]",
"]",
")",
"->",
"addSetup",
"(",
"'$hideEmpty'",
",",
"[",
"$",
"config",
"[",
"'hideEmpty'",
"]",
"]",
")",
";",
"}",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'mailer'",
")",
")",
"->",
"setClass",
"(",
"'RM\\FileMailer'",
",",
"[",
"Helpers",
"::",
"expand",
"(",
"$",
"config",
"[",
"'tempDir'",
"]",
",",
"$",
"builder",
"->",
"parameters",
")",
"]",
")",
"->",
"addSetup",
"(",
"'@RM\\MailPanel::setFileMailer'",
",",
"[",
"'@self'",
"]",
")",
"->",
"addSetup",
"(",
"'@Tracy\\Bar::addPanel'",
",",
"[",
"$",
"this",
"->",
"prefix",
"(",
"'@panel'",
")",
"]",
")",
";",
"}"
] |
Method setings extension.
|
[
"Method",
"setings",
"extension",
"."
] |
732685f5505ea764fe76cc92bc4ffbc3b4ea917b
|
https://github.com/romanmatyus/FileMailer/blob/732685f5505ea764fe76cc92bc4ffbc3b4ea917b/src/FileMailer/MailPanelExtension.php#L34-L58
|
10,930
|
romanmatyus/FileMailer
|
src/FileMailer/MailPanelExtension.php
|
MailPanelExtension.register
|
public static function register(Configurator $config)
{
$config->onCompile[] = function (Configurator $config, Compiler $compiler) {
$compiler->addExtension('mailPanel', new MailPanelExtension());
};
}
|
php
|
public static function register(Configurator $config)
{
$config->onCompile[] = function (Configurator $config, Compiler $compiler) {
$compiler->addExtension('mailPanel', new MailPanelExtension());
};
}
|
[
"public",
"static",
"function",
"register",
"(",
"Configurator",
"$",
"config",
")",
"{",
"$",
"config",
"->",
"onCompile",
"[",
"]",
"=",
"function",
"(",
"Configurator",
"$",
"config",
",",
"Compiler",
"$",
"compiler",
")",
"{",
"$",
"compiler",
"->",
"addExtension",
"(",
"'mailPanel'",
",",
"new",
"MailPanelExtension",
"(",
")",
")",
";",
"}",
";",
"}"
] |
Register extension to DI Container.
@param Configurator $config
|
[
"Register",
"extension",
"to",
"DI",
"Container",
"."
] |
732685f5505ea764fe76cc92bc4ffbc3b4ea917b
|
https://github.com/romanmatyus/FileMailer/blob/732685f5505ea764fe76cc92bc4ffbc3b4ea917b/src/FileMailer/MailPanelExtension.php#L65-L70
|
10,931
|
apnet/AsseticImporterBundle
|
src/Apnet/AsseticImporterBundle/Twig/Extension/ImporterExtension.php
|
ImporterExtension.importedAsset
|
public function importedAsset($path, $parameters = array())
{
if ($this->useController) {
$path = $this->router->generate(
"_assetic_" . $this->res->getFormulaeName($path),
$parameters
);
} else {
$path = $this->assets->getAssetUrl(
ltrim($path, "/")
);
}
return $path;
}
|
php
|
public function importedAsset($path, $parameters = array())
{
if ($this->useController) {
$path = $this->router->generate(
"_assetic_" . $this->res->getFormulaeName($path),
$parameters
);
} else {
$path = $this->assets->getAssetUrl(
ltrim($path, "/")
);
}
return $path;
}
|
[
"public",
"function",
"importedAsset",
"(",
"$",
"path",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"useController",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"\"_assetic_\"",
".",
"$",
"this",
"->",
"res",
"->",
"getFormulaeName",
"(",
"$",
"path",
")",
",",
"$",
"parameters",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"assets",
"->",
"getAssetUrl",
"(",
"ltrim",
"(",
"$",
"path",
",",
"\"/\"",
")",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Return absolute path to imported asset
@param string $path Target import path
@param array $parameters Parameters
@return string
|
[
"Return",
"absolute",
"path",
"to",
"imported",
"asset"
] |
104ad3593795c016a5b89ecc8c240d4d96d3de45
|
https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticImporterBundle/Twig/Extension/ImporterExtension.php#L63-L77
|
10,932
|
samurai-fw/samurai
|
src/Samurai/Component/Routing/Router.php
|
Router.dispatch
|
public function dispatch($path = '/', $method = 'GET')
{
foreach ($this->rules as $rule)
{
if ($rule->matching($path, $method))
return $rule->toActionCaller($path, $method);
}
throw new NotFoundException($path);
}
|
php
|
public function dispatch($path = '/', $method = 'GET')
{
foreach ($this->rules as $rule)
{
if ($rule->matching($path, $method))
return $rule->toActionCaller($path, $method);
}
throw new NotFoundException($path);
}
|
[
"public",
"function",
"dispatch",
"(",
"$",
"path",
"=",
"'/'",
",",
"$",
"method",
"=",
"'GET'",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"rule",
"->",
"matching",
"(",
"$",
"path",
",",
"$",
"method",
")",
")",
"return",
"$",
"rule",
"->",
"toActionCaller",
"(",
"$",
"path",
",",
"$",
"method",
")",
";",
"}",
"throw",
"new",
"NotFoundException",
"(",
"$",
"path",
")",
";",
"}"
] |
dispatch to action
@param string $path
@param string $method
@return Closure
|
[
"dispatch",
"to",
"action"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Router.php#L98-L106
|
10,933
|
samurai-fw/samurai
|
src/Samurai/Component/Routing/Router.php
|
Router.patch
|
public function patch($path, $action = null)
{
return $this->match($path, Rule\HttpMethodRule::HTTP_METHOD_PATCH, $action);
}
|
php
|
public function patch($path, $action = null)
{
return $this->match($path, Rule\HttpMethodRule::HTTP_METHOD_PATCH, $action);
}
|
[
"public",
"function",
"patch",
"(",
"$",
"path",
",",
"$",
"action",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"match",
"(",
"$",
"path",
",",
"Rule",
"\\",
"HttpMethodRule",
"::",
"HTTP_METHOD_PATCH",
",",
"$",
"action",
")",
";",
"}"
] |
add patch routing
@param string $path
@param string|Closure $action
@return Rule
|
[
"add",
"patch",
"routing"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Router.php#L152-L155
|
10,934
|
samurai-fw/samurai
|
src/Samurai/Component/Routing/Router.php
|
Router.import
|
public function import($file)
{
$rules = $this->yaml->load($file);
foreach ($rules as $rule) {
list($key, $value) = each($rule);
switch ($key) {
case 'root':
$this->setRoot($value);
break;
case 'match':
$this->addMatchRule($value);
break;
}
}
}
|
php
|
public function import($file)
{
$rules = $this->yaml->load($file);
foreach ($rules as $rule) {
list($key, $value) = each($rule);
switch ($key) {
case 'root':
$this->setRoot($value);
break;
case 'match':
$this->addMatchRule($value);
break;
}
}
}
|
[
"public",
"function",
"import",
"(",
"$",
"file",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"yaml",
"->",
"load",
"(",
"$",
"file",
")",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
")",
"{",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"each",
"(",
"$",
"rule",
")",
";",
"switch",
"(",
"$",
"key",
")",
"{",
"case",
"'root'",
":",
"$",
"this",
"->",
"setRoot",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'match'",
":",
"$",
"this",
"->",
"addMatchRule",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"}"
] |
import routing config.
@access public
@param string $file
|
[
"import",
"routing",
"config",
"."
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Router.php#L252-L267
|
10,935
|
samurai-fw/samurai
|
src/Samurai/Component/Routing/Router.php
|
Router.isActionExists
|
public function isActionExists(Rule\Rule $rule)
{
return $this->actionChain->existsController($rule->getController(), $rule->getAction());
}
|
php
|
public function isActionExists(Rule\Rule $rule)
{
return $this->actionChain->existsController($rule->getController(), $rule->getAction());
}
|
[
"public",
"function",
"isActionExists",
"(",
"Rule",
"\\",
"Rule",
"$",
"rule",
")",
"{",
"return",
"$",
"this",
"->",
"actionChain",
"->",
"existsController",
"(",
"$",
"rule",
"->",
"getController",
"(",
")",
",",
"$",
"rule",
"->",
"getAction",
"(",
")",
")",
";",
"}"
] |
is exists targeted action ?
@param Samurai\Samurai\Component\Routing\Rule\Rule
@return boolean
|
[
"is",
"exists",
"targeted",
"action",
"?"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Routing/Router.php#L369-L372
|
10,936
|
leadthread/php-viddler
|
src/Request.php
|
Request.execute
|
public function execute()
{
// Get the parameters
$params = $this->getParams();
// Get the url
$url = $this->getUrl($params);
// Run it
return $this->sendRequest($url, $params);
}
|
php
|
public function execute()
{
// Get the parameters
$params = $this->getParams();
// Get the url
$url = $this->getUrl($params);
// Run it
return $this->sendRequest($url, $params);
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"// Get the parameters",
"$",
"params",
"=",
"$",
"this",
"->",
"getParams",
"(",
")",
";",
"// Get the url",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"$",
"params",
")",
";",
"// Run it",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}"
] |
Constructs the Request requirements and then sends the Request returning the response
|
[
"Constructs",
"the",
"Request",
"requirements",
"and",
"then",
"sends",
"the",
"Request",
"returning",
"the",
"response"
] |
7167b58995cf75099c75add4aecfd63c08c5dcdc
|
https://github.com/leadthread/php-viddler/blob/7167b58995cf75099c75add4aecfd63c08c5dcdc/src/Request.php#L93-L103
|
10,937
|
leadthread/php-viddler
|
src/Request.php
|
Request.sendRequest
|
protected function sendRequest($url, $params)
{
// Construct the cURL call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Figure POST vs. GET
if ($this->isPost()) {
curl_setopt($ch, CURLOPT_POST, true);
if ($this->isBinary()) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getBinaryArgs());
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
} else {
curl_setopt($ch, CURLOPT_HTTPGET, true);
}
//Get the response
$response = curl_exec($ch);
if (!$response) {
throw new Exceptions\ViddlerException(curl_error($ch));
} else {
$response = unserialize($response);
}
curl_close($ch);
$response = $this->checkResponseForErrors($response);
return $response;
}
|
php
|
protected function sendRequest($url, $params)
{
// Construct the cURL call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Figure POST vs. GET
if ($this->isPost()) {
curl_setopt($ch, CURLOPT_POST, true);
if ($this->isBinary()) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getBinaryArgs());
} else {
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
}
} else {
curl_setopt($ch, CURLOPT_HTTPGET, true);
}
//Get the response
$response = curl_exec($ch);
if (!$response) {
throw new Exceptions\ViddlerException(curl_error($ch));
} else {
$response = unserialize($response);
}
curl_close($ch);
$response = $this->checkResponseForErrors($response);
return $response;
}
|
[
"protected",
"function",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
")",
"{",
"// Construct the cURL call",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_TIMEOUT",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"// Figure POST vs. GET",
"if",
"(",
"$",
"this",
"->",
"isPost",
"(",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"true",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isBinary",
"(",
")",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"this",
"->",
"getBinaryArgs",
"(",
")",
")",
";",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"params",
")",
";",
"}",
"}",
"else",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPGET",
",",
"true",
")",
";",
"}",
"//Get the response",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"!",
"$",
"response",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"ViddlerException",
"(",
"curl_error",
"(",
"$",
"ch",
")",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"unserialize",
"(",
"$",
"response",
")",
";",
"}",
"curl_close",
"(",
"$",
"ch",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"checkResponseForErrors",
"(",
"$",
"response",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
Sends the actual curl request
|
[
"Sends",
"the",
"actual",
"curl",
"request"
] |
7167b58995cf75099c75add4aecfd63c08c5dcdc
|
https://github.com/leadthread/php-viddler/blob/7167b58995cf75099c75add4aecfd63c08c5dcdc/src/Request.php#L108-L144
|
10,938
|
leadthread/php-viddler
|
src/Request.php
|
Request.getParams
|
protected function getParams()
{
$params = ["key=".$this->apiKey];
if (@count($this->options[0]) > 0 && is_array($this->options[0])) {
foreach ($this->options[0] as $k => $v) {
if ($k != "response_type" && $k != "apiKey") {
array_push($params, "$k=$v");
}
}
}
return $params;
}
|
php
|
protected function getParams()
{
$params = ["key=".$this->apiKey];
if (@count($this->options[0]) > 0 && is_array($this->options[0])) {
foreach ($this->options[0] as $k => $v) {
if ($k != "response_type" && $k != "apiKey") {
array_push($params, "$k=$v");
}
}
}
return $params;
}
|
[
"protected",
"function",
"getParams",
"(",
")",
"{",
"$",
"params",
"=",
"[",
"\"key=\"",
".",
"$",
"this",
"->",
"apiKey",
"]",
";",
"if",
"(",
"@",
"count",
"(",
"$",
"this",
"->",
"options",
"[",
"0",
"]",
")",
">",
"0",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"options",
"[",
"0",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"options",
"[",
"0",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"k",
"!=",
"\"response_type\"",
"&&",
"$",
"k",
"!=",
"\"apiKey\"",
")",
"{",
"array_push",
"(",
"$",
"params",
",",
"\"$k=$v\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"params",
";",
"}"
] |
Builds the query object from the options property
|
[
"Builds",
"the",
"query",
"object",
"from",
"the",
"options",
"property"
] |
7167b58995cf75099c75add4aecfd63c08c5dcdc
|
https://github.com/leadthread/php-viddler/blob/7167b58995cf75099c75add4aecfd63c08c5dcdc/src/Request.php#L149-L160
|
10,939
|
leadthread/php-viddler
|
src/Request.php
|
Request.getUrl
|
protected function getUrl($params)
{
// Figure protocol http:// or https://
$protocol = $this->getProtocol();
// The base
$url = $protocol . "://api.viddler.com/api/v2/" . $this->method . ".php";
// Add on the params
if (!$this->isPost() && @count($params) > 0 && is_array($params)) {
$url .= "?" . implode("&", $params);
}
return $url;
}
|
php
|
protected function getUrl($params)
{
// Figure protocol http:// or https://
$protocol = $this->getProtocol();
// The base
$url = $protocol . "://api.viddler.com/api/v2/" . $this->method . ".php";
// Add on the params
if (!$this->isPost() && @count($params) > 0 && is_array($params)) {
$url .= "?" . implode("&", $params);
}
return $url;
}
|
[
"protected",
"function",
"getUrl",
"(",
"$",
"params",
")",
"{",
"// Figure protocol http:// or https://",
"$",
"protocol",
"=",
"$",
"this",
"->",
"getProtocol",
"(",
")",
";",
"// The base",
"$",
"url",
"=",
"$",
"protocol",
".",
"\"://api.viddler.com/api/v2/\"",
".",
"$",
"this",
"->",
"method",
".",
"\".php\"",
";",
"// Add on the params",
"if",
"(",
"!",
"$",
"this",
"->",
"isPost",
"(",
")",
"&&",
"@",
"count",
"(",
"$",
"params",
")",
">",
"0",
"&&",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"url",
".=",
"\"?\"",
".",
"implode",
"(",
"\"&\"",
",",
"$",
"params",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Builds the URL for the request
|
[
"Builds",
"the",
"URL",
"for",
"the",
"request"
] |
7167b58995cf75099c75add4aecfd63c08c5dcdc
|
https://github.com/leadthread/php-viddler/blob/7167b58995cf75099c75add4aecfd63c08c5dcdc/src/Request.php#L165-L179
|
10,940
|
leadthread/php-viddler
|
src/Request.php
|
Request.getBinaryArgs
|
protected function getBinaryArgs()
{
$bArgs = array();
foreach ($this->options[0] as $k => $v) {
if ($k != 'file') {
$bArgs[$k] = $v;
}
}
if (!isset($bArgs['key'])) {
$bArgs['key'] = $this->apiKey;
}
$bArgs['file'] = curl_file_create($this->options[0]['file']);
return $bArgs;
}
|
php
|
protected function getBinaryArgs()
{
$bArgs = array();
foreach ($this->options[0] as $k => $v) {
if ($k != 'file') {
$bArgs[$k] = $v;
}
}
if (!isset($bArgs['key'])) {
$bArgs['key'] = $this->apiKey;
}
$bArgs['file'] = curl_file_create($this->options[0]['file']);
return $bArgs;
}
|
[
"protected",
"function",
"getBinaryArgs",
"(",
")",
"{",
"$",
"bArgs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"[",
"0",
"]",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"k",
"!=",
"'file'",
")",
"{",
"$",
"bArgs",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"bArgs",
"[",
"'key'",
"]",
")",
")",
"{",
"$",
"bArgs",
"[",
"'key'",
"]",
"=",
"$",
"this",
"->",
"apiKey",
";",
"}",
"$",
"bArgs",
"[",
"'file'",
"]",
"=",
"curl_file_create",
"(",
"$",
"this",
"->",
"options",
"[",
"0",
"]",
"[",
"'file'",
"]",
")",
";",
"return",
"$",
"bArgs",
";",
"}"
] |
Returns the binary arguments for the request
|
[
"Returns",
"the",
"binary",
"arguments",
"for",
"the",
"request"
] |
7167b58995cf75099c75add4aecfd63c08c5dcdc
|
https://github.com/leadthread/php-viddler/blob/7167b58995cf75099c75add4aecfd63c08c5dcdc/src/Request.php#L184-L200
|
10,941
|
leadthread/php-viddler
|
src/Request.php
|
Request.checkResponseForErrors
|
protected function checkResponseForErrors($response)
{
if (isset($response["error"])) {
$msg = [];
$parts = ["code", "description", "details"];
foreach ($parts as $part) {
if (!empty($response["error"][$part])) {
$msg[] = $part.": ".$response["error"][$part];
}
}
$msg = implode(" | ", $msg);
$code = $response["error"]["code"];
if (!array_key_exists($code, $this->exceptions)) {
$code = "default";
}
throw new $this->exceptions[$code]($msg);
}
return $response;
}
|
php
|
protected function checkResponseForErrors($response)
{
if (isset($response["error"])) {
$msg = [];
$parts = ["code", "description", "details"];
foreach ($parts as $part) {
if (!empty($response["error"][$part])) {
$msg[] = $part.": ".$response["error"][$part];
}
}
$msg = implode(" | ", $msg);
$code = $response["error"]["code"];
if (!array_key_exists($code, $this->exceptions)) {
$code = "default";
}
throw new $this->exceptions[$code]($msg);
}
return $response;
}
|
[
"protected",
"function",
"checkResponseForErrors",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"\"error\"",
"]",
")",
")",
"{",
"$",
"msg",
"=",
"[",
"]",
";",
"$",
"parts",
"=",
"[",
"\"code\"",
",",
"\"description\"",
",",
"\"details\"",
"]",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"response",
"[",
"\"error\"",
"]",
"[",
"$",
"part",
"]",
")",
")",
"{",
"$",
"msg",
"[",
"]",
"=",
"$",
"part",
".",
"\": \"",
".",
"$",
"response",
"[",
"\"error\"",
"]",
"[",
"$",
"part",
"]",
";",
"}",
"}",
"$",
"msg",
"=",
"implode",
"(",
"\" | \"",
",",
"$",
"msg",
")",
";",
"$",
"code",
"=",
"$",
"response",
"[",
"\"error\"",
"]",
"[",
"\"code\"",
"]",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"code",
",",
"$",
"this",
"->",
"exceptions",
")",
")",
"{",
"$",
"code",
"=",
"\"default\"",
";",
"}",
"throw",
"new",
"$",
"this",
"->",
"exceptions",
"[",
"$",
"code",
"]",
"(",
"$",
"msg",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Throws an Exception if the response contains an error
|
[
"Throws",
"an",
"Exception",
"if",
"the",
"response",
"contains",
"an",
"error"
] |
7167b58995cf75099c75add4aecfd63c08c5dcdc
|
https://github.com/leadthread/php-viddler/blob/7167b58995cf75099c75add4aecfd63c08c5dcdc/src/Request.php#L205-L228
|
10,942
|
vincenttouzet/AdminConfigurationBundle
|
Form/DataTransformer/StringToBooleanTransformer.php
|
StringToBooleanTransformer.reverseTransform
|
public function reverseTransform($value)
{
if (null === $value) {
return false;
}
if (!is_bool($value)) {
throw new UnexpectedTypeException($value, 'Boolean');
}
return true === $value ? $this->trueValue : null;
}
|
php
|
public function reverseTransform($value)
{
if (null === $value) {
return false;
}
if (!is_bool($value)) {
throw new UnexpectedTypeException($value, 'Boolean');
}
return true === $value ? $this->trueValue : null;
}
|
[
"public",
"function",
"reverseTransform",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"UnexpectedTypeException",
"(",
"$",
"value",
",",
"'Boolean'",
")",
";",
"}",
"return",
"true",
"===",
"$",
"value",
"?",
"$",
"this",
"->",
"trueValue",
":",
"null",
";",
"}"
] |
Transforms a Boolean into a string.
@param Boolean $value Boolean value.
@return string String value.
@throws UnexpectedTypeException if the given value is not a Boolean
|
[
"Transforms",
"a",
"Boolean",
"into",
"a",
"string",
"."
] |
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
|
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Form/DataTransformer/StringToBooleanTransformer.php#L75-L86
|
10,943
|
phproberto/joomla-common
|
src/Traits/HasExtension.php
|
HasExtension.getExtension
|
public function getExtension($reload = false)
{
if ($reload || null === $this->extension)
{
$this->extension = $this->loadExtension();
}
return clone $this->extension;
}
|
php
|
public function getExtension($reload = false)
{
if ($reload || null === $this->extension)
{
$this->extension = $this->loadExtension();
}
return clone $this->extension;
}
|
[
"public",
"function",
"getExtension",
"(",
"$",
"reload",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"reload",
"||",
"null",
"===",
"$",
"this",
"->",
"extension",
")",
"{",
"$",
"this",
"->",
"extension",
"=",
"$",
"this",
"->",
"loadExtension",
"(",
")",
";",
"}",
"return",
"clone",
"$",
"this",
"->",
"extension",
";",
"}"
] |
Get the extension information.
@param boolean $reload Force reloading?
@return \stdClass
|
[
"Get",
"the",
"extension",
"information",
"."
] |
bbb37df453bfcb545c3a2c6f14340f0a27e448b2
|
https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Traits/HasExtension.php#L36-L44
|
10,944
|
phproberto/joomla-common
|
src/Traits/HasExtension.php
|
HasExtension.getExtensionProperty
|
public function getExtensionProperty($property, $default = null)
{
$extension = new Registry((array) $this->getExtension());
return $extension->get($property, $default);
}
|
php
|
public function getExtensionProperty($property, $default = null)
{
$extension = new Registry((array) $this->getExtension());
return $extension->get($property, $default);
}
|
[
"public",
"function",
"getExtensionProperty",
"(",
"$",
"property",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"extension",
"=",
"new",
"Registry",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getExtension",
"(",
")",
")",
";",
"return",
"$",
"extension",
"->",
"get",
"(",
"$",
"property",
",",
"$",
"default",
")",
";",
"}"
] |
Get an extension property.
@param string $property Name of the property
@param mixed $default Default value
@return mixed
|
[
"Get",
"an",
"extension",
"property",
"."
] |
bbb37df453bfcb545c3a2c6f14340f0a27e448b2
|
https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Traits/HasExtension.php#L54-L59
|
10,945
|
flamecore/container
|
lib/EditableContainer.php
|
EditableContainer.get
|
public function get($id)
{
$id = (string) $id;
if (!$this->has($id)) {
throw new NotFoundException(sprintf('The item with identifier "%s" was not found.', $id));
}
return $this->items[$id];
}
|
php
|
public function get($id)
{
$id = (string) $id;
if (!$this->has($id)) {
throw new NotFoundException(sprintf('The item with identifier "%s" was not found.', $id));
}
return $this->items[$id];
}
|
[
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"id",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"sprintf",
"(",
"'The item with identifier \"%s\" was not found.'",
",",
"$",
"id",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
";",
"}"
] |
Returns the value of the item with given name.
@param string $id The name of the item
@return mixed
@throws NotFoundException if no entry was found for this identifier.
@throws ContainerException for errors while retrieving the entry.
@throws InvalidArgumentException if the item name is invalid.
|
[
"Returns",
"the",
"value",
"of",
"the",
"item",
"with",
"given",
"name",
"."
] |
b8b59b752964d9c82324053cbdbc8a5cf6d99658
|
https://github.com/flamecore/container/blob/b8b59b752964d9c82324053cbdbc8a5cf6d99658/lib/EditableContainer.php#L70-L79
|
10,946
|
flamecore/container
|
lib/EditableContainer.php
|
EditableContainer.has
|
public function has($id)
{
$id = (string) $id;
$this->validateName($id);
return isset($this->items[$id]);
}
|
php
|
public function has($id)
{
$id = (string) $id;
$this->validateName($id);
return isset($this->items[$id]);
}
|
[
"public",
"function",
"has",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"id",
";",
"$",
"this",
"->",
"validateName",
"(",
"$",
"id",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
";",
"}"
] |
Returns whether an item with given name is defined.
@param string $id The name of the item
@return bool
@throws InvalidArgumentException if the item name is invalid.
|
[
"Returns",
"whether",
"an",
"item",
"with",
"given",
"name",
"is",
"defined",
"."
] |
b8b59b752964d9c82324053cbdbc8a5cf6d99658
|
https://github.com/flamecore/container/blob/b8b59b752964d9c82324053cbdbc8a5cf6d99658/lib/EditableContainer.php#L90-L97
|
10,947
|
flamecore/container
|
lib/EditableContainer.php
|
EditableContainer.define
|
public function define($id, $type)
{
$id = (string) $id;
$this->validateName($id);
if ($type[0] == ':') {
$expectedType = substr($type, 1);
$allowedTypes = (array) $this->getAllowedTypes();
if (!in_array($expectedType, $allowedTypes)) {
throw new InvalidArgumentException(sprintf('Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.',
$expectedType, $id, $this->name, join(', ', $allowedTypes)));
}
} else {
if (!class_exists($type)) {
throw new InvalidArgumentException(sprintf('Cannot use non-existing class %s as type to define item "%s" in %s container.',
$type, $id, $this->name));
}
}
$this->typemap[$id] = $type;
}
|
php
|
public function define($id, $type)
{
$id = (string) $id;
$this->validateName($id);
if ($type[0] == ':') {
$expectedType = substr($type, 1);
$allowedTypes = (array) $this->getAllowedTypes();
if (!in_array($expectedType, $allowedTypes)) {
throw new InvalidArgumentException(sprintf('Cannot use type %s to define item "%s" in %s container. Allowed types are: %s.',
$expectedType, $id, $this->name, join(', ', $allowedTypes)));
}
} else {
if (!class_exists($type)) {
throw new InvalidArgumentException(sprintf('Cannot use non-existing class %s as type to define item "%s" in %s container.',
$type, $id, $this->name));
}
}
$this->typemap[$id] = $type;
}
|
[
"public",
"function",
"define",
"(",
"$",
"id",
",",
"$",
"type",
")",
"{",
"$",
"id",
"=",
"(",
"string",
")",
"$",
"id",
";",
"$",
"this",
"->",
"validateName",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"type",
"[",
"0",
"]",
"==",
"':'",
")",
"{",
"$",
"expectedType",
"=",
"substr",
"(",
"$",
"type",
",",
"1",
")",
";",
"$",
"allowedTypes",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getAllowedTypes",
"(",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"expectedType",
",",
"$",
"allowedTypes",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Cannot use type %s to define item \"%s\" in %s container. Allowed types are: %s.'",
",",
"$",
"expectedType",
",",
"$",
"id",
",",
"$",
"this",
"->",
"name",
",",
"join",
"(",
"', '",
",",
"$",
"allowedTypes",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"type",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Cannot use non-existing class %s as type to define item \"%s\" in %s container.'",
",",
"$",
"type",
",",
"$",
"id",
",",
"$",
"this",
"->",
"name",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"typemap",
"[",
"$",
"id",
"]",
"=",
"$",
"type",
";",
"}"
] |
Defines the given item in the typemap.
@param string $id The name of the item
@param string $type The required type of the value
@throws InvalidArgumentException if the ID name is invalid.
|
[
"Defines",
"the",
"given",
"item",
"in",
"the",
"typemap",
"."
] |
b8b59b752964d9c82324053cbdbc8a5cf6d99658
|
https://github.com/flamecore/container/blob/b8b59b752964d9c82324053cbdbc8a5cf6d99658/lib/EditableContainer.php#L154-L175
|
10,948
|
flamecore/container
|
lib/EditableContainer.php
|
EditableContainer.defineAll
|
public function defineAll(array $typemap)
{
foreach ($typemap as $id => $type) {
$this->define($id, $type);
}
}
|
php
|
public function defineAll(array $typemap)
{
foreach ($typemap as $id => $type) {
$this->define($id, $type);
}
}
|
[
"public",
"function",
"defineAll",
"(",
"array",
"$",
"typemap",
")",
"{",
"foreach",
"(",
"$",
"typemap",
"as",
"$",
"id",
"=>",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"define",
"(",
"$",
"id",
",",
"$",
"type",
")",
";",
"}",
"}"
] |
Defines multiple items in the typemap.
@param array $typemap The typemap
@throws InvalidArgumentException if an ID name is invalid.
|
[
"Defines",
"multiple",
"items",
"in",
"the",
"typemap",
"."
] |
b8b59b752964d9c82324053cbdbc8a5cf6d99658
|
https://github.com/flamecore/container/blob/b8b59b752964d9c82324053cbdbc8a5cf6d99658/lib/EditableContainer.php#L184-L189
|
10,949
|
flamecore/container
|
lib/EditableContainer.php
|
EditableContainer.isDefined
|
public function isDefined($id)
{
return isset($this->typemap[$id]) ? $this->typemap[$id] : false;
}
|
php
|
public function isDefined($id)
{
return isset($this->typemap[$id]) ? $this->typemap[$id] : false;
}
|
[
"public",
"function",
"isDefined",
"(",
"$",
"id",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"typemap",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"typemap",
"[",
"$",
"id",
"]",
":",
"false",
";",
"}"
] |
Checks whether an item with given name is defined and, if so, which type it requires.
@param string $id The name of the item
@return string|false Returns the required type of the item if it is defined or FALSE if not.
|
[
"Checks",
"whether",
"an",
"item",
"with",
"given",
"name",
"is",
"defined",
"and",
"if",
"so",
"which",
"type",
"it",
"requires",
"."
] |
b8b59b752964d9c82324053cbdbc8a5cf6d99658
|
https://github.com/flamecore/container/blob/b8b59b752964d9c82324053cbdbc8a5cf6d99658/lib/EditableContainer.php#L198-L201
|
10,950
|
flamecore/container
|
lib/EditableContainer.php
|
EditableContainer.getType
|
protected function getType($value)
{
if (is_object($value)) {
return get_class($value);
} elseif (is_null($value)) {
return 'null';
} elseif (is_string($value)) {
return 'string';
} elseif (is_array($value)) {
return 'array';
} elseif (is_int($value)) {
return 'integer';
} elseif (is_bool($value)) {
return 'boolean';
} elseif (is_float($value)) {
return 'float';
} elseif (is_resource($value)) {
return 'resource';
} else {
return 'unknown';
}
}
|
php
|
protected function getType($value)
{
if (is_object($value)) {
return get_class($value);
} elseif (is_null($value)) {
return 'null';
} elseif (is_string($value)) {
return 'string';
} elseif (is_array($value)) {
return 'array';
} elseif (is_int($value)) {
return 'integer';
} elseif (is_bool($value)) {
return 'boolean';
} elseif (is_float($value)) {
return 'float';
} elseif (is_resource($value)) {
return 'resource';
} else {
return 'unknown';
}
}
|
[
"protected",
"function",
"getType",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"return",
"get_class",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'null'",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'string'",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'array'",
";",
"}",
"elseif",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'integer'",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'boolean'",
";",
"}",
"elseif",
"(",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'float'",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'resource'",
";",
"}",
"else",
"{",
"return",
"'unknown'",
";",
"}",
"}"
] |
Returns the type of the value.
@param mixed $value The value
@return string
|
[
"Returns",
"the",
"type",
"of",
"the",
"value",
"."
] |
b8b59b752964d9c82324053cbdbc8a5cf6d99658
|
https://github.com/flamecore/container/blob/b8b59b752964d9c82324053cbdbc8a5cf6d99658/lib/EditableContainer.php#L257-L278
|
10,951
|
CampaignChain/campaign-scheduled
|
Controller/REST/ScheduledCampaignRESTController.php
|
ScheduledCampaignRESTController.postCampaignAction
|
public function postCampaignAction(Request $request)
{
$campaign = new Campaign();
$campaignType = $this->get('campaignchain.core.form.type.campaign');
$campaignType->setView('rest');
$campaignType->setBundleName(ScheduledCampaignController::BUNDLE_NAME);
$campaignType->setModuleIdentifier(ScheduledCampaignController::MODULE_IDENTIFIER);
$form = $this->createForm($campaignType, $campaign);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
// Make sure that data stays intact by using transactions.
try {
$em->getConnection()->beginTransaction();
$em->persist($campaign);
// We need the campaign ID for storing the hooks. Hence we must flush here.
$em->flush();
/** @var HookService $hookService */
$hookService = $this->get('campaignchain.core.hook');
$hookService->processHooks(ScheduledCampaignController::BUNDLE_NAME, ScheduledCampaignController::MODULE_IDENTIFIER, $campaign, $form, true);
$campaign = $hookService->getEntity();
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
$em->getConnection()->rollback();
return $this->errorResponse($e->getMessage());
}
return $this->response(['campaign' => ['id' => $campaign->getId()]]);
}
return $this->errorResponse($form);
}
|
php
|
public function postCampaignAction(Request $request)
{
$campaign = new Campaign();
$campaignType = $this->get('campaignchain.core.form.type.campaign');
$campaignType->setView('rest');
$campaignType->setBundleName(ScheduledCampaignController::BUNDLE_NAME);
$campaignType->setModuleIdentifier(ScheduledCampaignController::MODULE_IDENTIFIER);
$form = $this->createForm($campaignType, $campaign);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
// Make sure that data stays intact by using transactions.
try {
$em->getConnection()->beginTransaction();
$em->persist($campaign);
// We need the campaign ID for storing the hooks. Hence we must flush here.
$em->flush();
/** @var HookService $hookService */
$hookService = $this->get('campaignchain.core.hook');
$hookService->processHooks(ScheduledCampaignController::BUNDLE_NAME, ScheduledCampaignController::MODULE_IDENTIFIER, $campaign, $form, true);
$campaign = $hookService->getEntity();
$em->flush();
$em->getConnection()->commit();
} catch (\Exception $e) {
$em->getConnection()->rollback();
return $this->errorResponse($e->getMessage());
}
return $this->response(['campaign' => ['id' => $campaign->getId()]]);
}
return $this->errorResponse($form);
}
|
[
"public",
"function",
"postCampaignAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"campaign",
"=",
"new",
"Campaign",
"(",
")",
";",
"$",
"campaignType",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.form.type.campaign'",
")",
";",
"$",
"campaignType",
"->",
"setView",
"(",
"'rest'",
")",
";",
"$",
"campaignType",
"->",
"setBundleName",
"(",
"ScheduledCampaignController",
"::",
"BUNDLE_NAME",
")",
";",
"$",
"campaignType",
"->",
"setModuleIdentifier",
"(",
"ScheduledCampaignController",
"::",
"MODULE_IDENTIFIER",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"$",
"campaignType",
",",
"$",
"campaign",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"// Make sure that data stays intact by using transactions.",
"try",
"{",
"$",
"em",
"->",
"getConnection",
"(",
")",
"->",
"beginTransaction",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"campaign",
")",
";",
"// We need the campaign ID for storing the hooks. Hence we must flush here.",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"/** @var HookService $hookService */",
"$",
"hookService",
"=",
"$",
"this",
"->",
"get",
"(",
"'campaignchain.core.hook'",
")",
";",
"$",
"hookService",
"->",
"processHooks",
"(",
"ScheduledCampaignController",
"::",
"BUNDLE_NAME",
",",
"ScheduledCampaignController",
"::",
"MODULE_IDENTIFIER",
",",
"$",
"campaign",
",",
"$",
"form",
",",
"true",
")",
";",
"$",
"campaign",
"=",
"$",
"hookService",
"->",
"getEntity",
"(",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"em",
"->",
"getConnection",
"(",
")",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"em",
"->",
"getConnection",
"(",
")",
"->",
"rollback",
"(",
")",
";",
"return",
"$",
"this",
"->",
"errorResponse",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"response",
"(",
"[",
"'campaign'",
"=>",
"[",
"'id'",
"=>",
"$",
"campaign",
"->",
"getId",
"(",
")",
"]",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"errorResponse",
"(",
"$",
"form",
")",
";",
"}"
] |
Create new Scheduled Campaign
Example Request
===============
POST /api/v1/p/campaignchain/campaign-scheduled/campaigns
Example Input
=============
{
"campaign": {
"name": "REST4 Campaign",
"timezone": "UTC",
"campaignchain_hook_campaignchain_duration": {
"startDate": "2016-05-05T12:00:00+0000",
"endDate": "2016-06-05T12:00:00+0000",
"timezone": "UTC"
}
}
}
Example Response
================
{
"campaign": {
"id": 5
}
}
@ApiDoc(section="Campaigns")
@param Request $request
@return \Symfony\Component\HttpFoundation\Response
|
[
"Create",
"new",
"Scheduled",
"Campaign"
] |
e1d413a9e5d8f73a0405516f9bfc396883559b30
|
https://github.com/CampaignChain/campaign-scheduled/blob/e1d413a9e5d8f73a0405516f9bfc396883559b30/Controller/REST/ScheduledCampaignRESTController.php#L75-L117
|
10,952
|
nhagemann/anycontent-client-php
|
src/AnyContent/Cache/CachingRepository.php
|
CachingRepository.enableCmdlCaching
|
public function enableCmdlCaching($duration = null)
{
if ($duration == null) {
$duration = $this->duration;
}
$this->cmdlCaching = $duration;
$checkLastModifiedDate = false;
if ($this->hasLastModifiedCacheStrategy()) {
$checkLastModifiedDate = true;
}
$this->readConnection->enableCMDLCaching($duration, $checkLastModifiedDate);
if ($this->writeConnection) {
$this->writeConnection->enableCMDLCaching($duration, $checkLastModifiedDate);
}
}
|
php
|
public function enableCmdlCaching($duration = null)
{
if ($duration == null) {
$duration = $this->duration;
}
$this->cmdlCaching = $duration;
$checkLastModifiedDate = false;
if ($this->hasLastModifiedCacheStrategy()) {
$checkLastModifiedDate = true;
}
$this->readConnection->enableCMDLCaching($duration, $checkLastModifiedDate);
if ($this->writeConnection) {
$this->writeConnection->enableCMDLCaching($duration, $checkLastModifiedDate);
}
}
|
[
"public",
"function",
"enableCmdlCaching",
"(",
"$",
"duration",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"duration",
"==",
"null",
")",
"{",
"$",
"duration",
"=",
"$",
"this",
"->",
"duration",
";",
"}",
"$",
"this",
"->",
"cmdlCaching",
"=",
"$",
"duration",
";",
"$",
"checkLastModifiedDate",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"hasLastModifiedCacheStrategy",
"(",
")",
")",
"{",
"$",
"checkLastModifiedDate",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"readConnection",
"->",
"enableCMDLCaching",
"(",
"$",
"duration",
",",
"$",
"checkLastModifiedDate",
")",
";",
"if",
"(",
"$",
"this",
"->",
"writeConnection",
")",
"{",
"$",
"this",
"->",
"writeConnection",
"->",
"enableCMDLCaching",
"(",
"$",
"duration",
",",
"$",
"checkLastModifiedDate",
")",
";",
"}",
"}"
] |
Allow connection to cache CMDL definitions. Adjustable via duration if you're not sure how likely CMDL changes occur.
@param $duration
|
[
"Allow",
"connection",
"to",
"cache",
"CMDL",
"definitions",
".",
"Adjustable",
"via",
"duration",
"if",
"you",
"re",
"not",
"sure",
"how",
"likely",
"CMDL",
"changes",
"occur",
"."
] |
7120f91197fda5a98de6d2917c5e312bd67546c0
|
https://github.com/nhagemann/anycontent-client-php/blob/7120f91197fda5a98de6d2917c5e312bd67546c0/src/AnyContent/Cache/CachingRepository.php#L145-L161
|
10,953
|
AthensFramework/Core
|
src/visitor/VisitableTrait.php
|
VisitableTrait.accept
|
public function accept(VisitorInterface $visitor)
{
$hierarchy = array_merge([get_class($this)], array_values(class_parents($this)));
$visitorMethods = array_map(
function ($className) {
if (strrpos($className, "\\") !== false) {
$className = substr($className, strrpos($className, "\\") + 1);
}
return "visit" . $className;
},
$hierarchy
);
foreach ($visitorMethods as $visitorMethod) {
if (method_exists($visitor, $visitorMethod) === true) {
return $visitor->$visitorMethod($this);
}
}
if (method_exists($visitor, "visit") === true) {
return $visitor->visit($this);
}
return null;
}
|
php
|
public function accept(VisitorInterface $visitor)
{
$hierarchy = array_merge([get_class($this)], array_values(class_parents($this)));
$visitorMethods = array_map(
function ($className) {
if (strrpos($className, "\\") !== false) {
$className = substr($className, strrpos($className, "\\") + 1);
}
return "visit" . $className;
},
$hierarchy
);
foreach ($visitorMethods as $visitorMethod) {
if (method_exists($visitor, $visitorMethod) === true) {
return $visitor->$visitorMethod($this);
}
}
if (method_exists($visitor, "visit") === true) {
return $visitor->visit($this);
}
return null;
}
|
[
"public",
"function",
"accept",
"(",
"VisitorInterface",
"$",
"visitor",
")",
"{",
"$",
"hierarchy",
"=",
"array_merge",
"(",
"[",
"get_class",
"(",
"$",
"this",
")",
"]",
",",
"array_values",
"(",
"class_parents",
"(",
"$",
"this",
")",
")",
")",
";",
"$",
"visitorMethods",
"=",
"array_map",
"(",
"function",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"strrpos",
"(",
"$",
"className",
",",
"\"\\\\\"",
")",
"!==",
"false",
")",
"{",
"$",
"className",
"=",
"substr",
"(",
"$",
"className",
",",
"strrpos",
"(",
"$",
"className",
",",
"\"\\\\\"",
")",
"+",
"1",
")",
";",
"}",
"return",
"\"visit\"",
".",
"$",
"className",
";",
"}",
",",
"$",
"hierarchy",
")",
";",
"foreach",
"(",
"$",
"visitorMethods",
"as",
"$",
"visitorMethod",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"visitor",
",",
"$",
"visitorMethod",
")",
"===",
"true",
")",
"{",
"return",
"$",
"visitor",
"->",
"$",
"visitorMethod",
"(",
"$",
"this",
")",
";",
"}",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"visitor",
",",
"\"visit\"",
")",
"===",
"true",
")",
"{",
"return",
"$",
"visitor",
"->",
"visit",
"(",
"$",
"this",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Accept a visitor, per the Visitor pattern.
@param VisitorInterface $visitor
@return mixed
|
[
"Accept",
"a",
"visitor",
"per",
"the",
"Visitor",
"pattern",
"."
] |
6237b914b9f6aef6b2fcac23094b657a86185340
|
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/visitor/VisitableTrait.php#L21-L46
|
10,954
|
MarcusFulbright/represent
|
src/Represent/Builder/Format/HalFormatBuilder.php
|
HalFormatBuilder.handleProperty
|
protected function handleProperty(\ReflectionProperty $property, ClassContext $classContext, $original, \stdClass $output)
{
$propertyContext = $this->propertyBuilder->propertyContextFromReflection($property, $original, $classContext);
$value = $propertyContext->value;
$name = $propertyContext->name;
switch (true):
case $this->checkArrayCollection($value):
$value = $value->toArray();
case is_array($value);
$output->$name = $this->handleArray($value, $classContext->views);
break;
case is_object($value);
$output->$name = $this->handleObject($value, $classContext->views);
break;
default:
$output->$name = $value;
break;
endswitch;
return $output;
}
|
php
|
protected function handleProperty(\ReflectionProperty $property, ClassContext $classContext, $original, \stdClass $output)
{
$propertyContext = $this->propertyBuilder->propertyContextFromReflection($property, $original, $classContext);
$value = $propertyContext->value;
$name = $propertyContext->name;
switch (true):
case $this->checkArrayCollection($value):
$value = $value->toArray();
case is_array($value);
$output->$name = $this->handleArray($value, $classContext->views);
break;
case is_object($value);
$output->$name = $this->handleObject($value, $classContext->views);
break;
default:
$output->$name = $value;
break;
endswitch;
return $output;
}
|
[
"protected",
"function",
"handleProperty",
"(",
"\\",
"ReflectionProperty",
"$",
"property",
",",
"ClassContext",
"$",
"classContext",
",",
"$",
"original",
",",
"\\",
"stdClass",
"$",
"output",
")",
"{",
"$",
"propertyContext",
"=",
"$",
"this",
"->",
"propertyBuilder",
"->",
"propertyContextFromReflection",
"(",
"$",
"property",
",",
"$",
"original",
",",
"$",
"classContext",
")",
";",
"$",
"value",
"=",
"$",
"propertyContext",
"->",
"value",
";",
"$",
"name",
"=",
"$",
"propertyContext",
"->",
"name",
";",
"switch",
"(",
"true",
")",
":",
"case",
"$",
"this",
"->",
"checkArrayCollection",
"(",
"$",
"value",
")",
":",
"$",
"value",
"=",
"$",
"value",
"->",
"toArray",
"(",
")",
";",
"case",
"is_array",
"(",
"$",
"value",
")",
";",
"$",
"output",
"->",
"$",
"name",
"=",
"$",
"this",
"->",
"handleArray",
"(",
"$",
"value",
",",
"$",
"classContext",
"->",
"views",
")",
";",
"break",
";",
"case",
"is_object",
"(",
"$",
"value",
")",
";",
"$",
"output",
"->",
"$",
"name",
"=",
"$",
"this",
"->",
"handleObject",
"(",
"$",
"value",
",",
"$",
"classContext",
"->",
"views",
")",
";",
"break",
";",
"default",
":",
"$",
"output",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"break",
";",
"endswitch",
";",
"return",
"$",
"output",
";",
"}"
] |
Used to handle determining representing object properties
@param \ReflectionProperty $property
@param $original
@param $output
@param \Represent\Context\ClassContext $classContext
@return stdClass
|
[
"Used",
"to",
"handle",
"determining",
"representing",
"object",
"properties"
] |
f7b624f473a3247a29f05c4a694d04bba4038e59
|
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/Format/HalFormatBuilder.php#L84-L104
|
10,955
|
MarcusFulbright/represent
|
src/Represent/Builder/Format/HalFormatBuilder.php
|
HalFormatBuilder.getEmbedded
|
protected function getEmbedded($representation, \ReflectionClass $reflection)
{
$embedded = new \stdClass();
$properties = $reflection->getProperties();
$reader = $this->reader;
array_walk(
$properties,
function (\ReflectionProperty $property) use ($representation, $embedded, $reader) {
$property->setAccessible(true);
$annot = $reader->getPropertyAnnotation($property, '\Represent\Annotations\Embedded');
if ($annot) {
$name = $property->getName();
$value = $representation->$name;
$embedded->$name = $value;
unset($representation->$name);
}
}
);
return $embedded;
}
|
php
|
protected function getEmbedded($representation, \ReflectionClass $reflection)
{
$embedded = new \stdClass();
$properties = $reflection->getProperties();
$reader = $this->reader;
array_walk(
$properties,
function (\ReflectionProperty $property) use ($representation, $embedded, $reader) {
$property->setAccessible(true);
$annot = $reader->getPropertyAnnotation($property, '\Represent\Annotations\Embedded');
if ($annot) {
$name = $property->getName();
$value = $representation->$name;
$embedded->$name = $value;
unset($representation->$name);
}
}
);
return $embedded;
}
|
[
"protected",
"function",
"getEmbedded",
"(",
"$",
"representation",
",",
"\\",
"ReflectionClass",
"$",
"reflection",
")",
"{",
"$",
"embedded",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"properties",
"=",
"$",
"reflection",
"->",
"getProperties",
"(",
")",
";",
"$",
"reader",
"=",
"$",
"this",
"->",
"reader",
";",
"array_walk",
"(",
"$",
"properties",
",",
"function",
"(",
"\\",
"ReflectionProperty",
"$",
"property",
")",
"use",
"(",
"$",
"representation",
",",
"$",
"embedded",
",",
"$",
"reader",
")",
"{",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"annot",
"=",
"$",
"reader",
"->",
"getPropertyAnnotation",
"(",
"$",
"property",
",",
"'\\Represent\\Annotations\\Embedded'",
")",
";",
"if",
"(",
"$",
"annot",
")",
"{",
"$",
"name",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"$",
"value",
"=",
"$",
"representation",
"->",
"$",
"name",
";",
"$",
"embedded",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"unset",
"(",
"$",
"representation",
"->",
"$",
"name",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"embedded",
";",
"}"
] |
Handles moving embedded properties to _embedded
@param $representation
@param \ReflectionClass $reflection
@return \stdClass
|
[
"Handles",
"moving",
"embedded",
"properties",
"to",
"_embedded"
] |
f7b624f473a3247a29f05c4a694d04bba4038e59
|
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/Format/HalFormatBuilder.php#L138-L160
|
10,956
|
MarcusFulbright/represent
|
src/Represent/Builder/Format/HalFormatBuilder.php
|
HalFormatBuilder.getLinks
|
protected function getLinks($object, $view)
{
$reflection = new \ReflectionClass($object);
$links = new \stdClass();
$annot = $this->reader->getClassAnnotation($reflection, '\Represent\Annotations\LinkCollection');
if ($annot) {
$links = $this->parseLinks($annot, $view, $links, $object);
}
return $links;
}
|
php
|
protected function getLinks($object, $view)
{
$reflection = new \ReflectionClass($object);
$links = new \stdClass();
$annot = $this->reader->getClassAnnotation($reflection, '\Represent\Annotations\LinkCollection');
if ($annot) {
$links = $this->parseLinks($annot, $view, $links, $object);
}
return $links;
}
|
[
"protected",
"function",
"getLinks",
"(",
"$",
"object",
",",
"$",
"view",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"object",
")",
";",
"$",
"links",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"annot",
"=",
"$",
"this",
"->",
"reader",
"->",
"getClassAnnotation",
"(",
"$",
"reflection",
",",
"'\\Represent\\Annotations\\LinkCollection'",
")",
";",
"if",
"(",
"$",
"annot",
")",
"{",
"$",
"links",
"=",
"$",
"this",
"->",
"parseLinks",
"(",
"$",
"annot",
",",
"$",
"view",
",",
"$",
"links",
",",
"$",
"object",
")",
";",
"}",
"return",
"$",
"links",
";",
"}"
] |
Handles getting _links
@param $object
@param $view
@internal param \ReflectionClass $reflection
@return \stdClass
|
[
"Handles",
"getting",
"_links"
] |
f7b624f473a3247a29f05c4a694d04bba4038e59
|
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/Format/HalFormatBuilder.php#L169-L180
|
10,957
|
MarcusFulbright/represent
|
src/Represent/Builder/Format/HalFormatBuilder.php
|
HalFormatBuilder.parseLinks
|
protected function parseLinks(LinkCollection $annot, $view, \stdClass $output, $object)
{
$generator = $this->linkGenerator;
array_walk(
$annot->links,
function($link) use ($view, $output, $generator, $object) {
if ($view == null || in_array($view, $link->views)) {
$name = $generator->parseName($link, $object);
$output->$name = $generator->generate($link, $object);
}
}
);
return $output;
}
|
php
|
protected function parseLinks(LinkCollection $annot, $view, \stdClass $output, $object)
{
$generator = $this->linkGenerator;
array_walk(
$annot->links,
function($link) use ($view, $output, $generator, $object) {
if ($view == null || in_array($view, $link->views)) {
$name = $generator->parseName($link, $object);
$output->$name = $generator->generate($link, $object);
}
}
);
return $output;
}
|
[
"protected",
"function",
"parseLinks",
"(",
"LinkCollection",
"$",
"annot",
",",
"$",
"view",
",",
"\\",
"stdClass",
"$",
"output",
",",
"$",
"object",
")",
"{",
"$",
"generator",
"=",
"$",
"this",
"->",
"linkGenerator",
";",
"array_walk",
"(",
"$",
"annot",
"->",
"links",
",",
"function",
"(",
"$",
"link",
")",
"use",
"(",
"$",
"view",
",",
"$",
"output",
",",
"$",
"generator",
",",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"view",
"==",
"null",
"||",
"in_array",
"(",
"$",
"view",
",",
"$",
"link",
"->",
"views",
")",
")",
"{",
"$",
"name",
"=",
"$",
"generator",
"->",
"parseName",
"(",
"$",
"link",
",",
"$",
"object",
")",
";",
"$",
"output",
"->",
"$",
"name",
"=",
"$",
"generator",
"->",
"generate",
"(",
"$",
"link",
",",
"$",
"object",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Parses through link annotations and generates valid links
@param LinkCollection $annot
@param $view
@param \stdClass $output
@param $object
@return \stdClass
|
[
"Parses",
"through",
"link",
"annotations",
"and",
"generates",
"valid",
"links"
] |
f7b624f473a3247a29f05c4a694d04bba4038e59
|
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/Format/HalFormatBuilder.php#L190-L204
|
10,958
|
AlcyZ/Alcys-ORM
|
src/Core/Db/References/MySql/Column.php
|
Column._prepareColumnArgument
|
private function _prepareColumnArgument($column)
{
if(!is_string($column) && !$column instanceof SqlFunctionInterface)
{
throw new \InvalidArgumentException('Argument 1 passed is not the expected type!');
}
if($column instanceof SqlFunctionInterface || $column === '*')
{
$this->columnName = (string)htmlentities($column, ENT_QUOTES);
}
else
{
$this->columnName = '`' . htmlentities($column, ENT_QUOTES) . '`';
}
}
|
php
|
private function _prepareColumnArgument($column)
{
if(!is_string($column) && !$column instanceof SqlFunctionInterface)
{
throw new \InvalidArgumentException('Argument 1 passed is not the expected type!');
}
if($column instanceof SqlFunctionInterface || $column === '*')
{
$this->columnName = (string)htmlentities($column, ENT_QUOTES);
}
else
{
$this->columnName = '`' . htmlentities($column, ENT_QUOTES) . '`';
}
}
|
[
"private",
"function",
"_prepareColumnArgument",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"column",
")",
"&&",
"!",
"$",
"column",
"instanceof",
"SqlFunctionInterface",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Argument 1 passed is not the expected type!'",
")",
";",
"}",
"if",
"(",
"$",
"column",
"instanceof",
"SqlFunctionInterface",
"||",
"$",
"column",
"===",
"'*'",
")",
"{",
"$",
"this",
"->",
"columnName",
"=",
"(",
"string",
")",
"htmlentities",
"(",
"$",
"column",
",",
"ENT_QUOTES",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"columnName",
"=",
"'`'",
".",
"htmlentities",
"(",
"$",
"column",
",",
"ENT_QUOTES",
")",
".",
"'`'",
";",
"}",
"}"
] |
This method validate and prepare the column name,
or throw an exception if an invalid argument is passed
as parameter.
@param string $column
|
[
"This",
"method",
"validate",
"and",
"prepare",
"the",
"column",
"name",
"or",
"throw",
"an",
"exception",
"if",
"an",
"invalid",
"argument",
"is",
"passed",
"as",
"parameter",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/References/MySql/Column.php#L172-L186
|
10,959
|
AlcyZ/Alcys-ORM
|
src/Core/Db/References/MySql/Column.php
|
Column._prepareExpression
|
private function _prepareExpression()
{
$this->expression = ($this->tableName && $this->alias) ?
$this->tableName . '.' . $this->columnName . ' AS ' . $this->alias : (($this->tableName && !$this->alias) ?
$this->tableName . '.' . $this->columnName : ((!$this->tableName && $this->alias) ?
$this->columnName . ' AS ' . $this->alias : $this->columnName));
}
|
php
|
private function _prepareExpression()
{
$this->expression = ($this->tableName && $this->alias) ?
$this->tableName . '.' . $this->columnName . ' AS ' . $this->alias : (($this->tableName && !$this->alias) ?
$this->tableName . '.' . $this->columnName : ((!$this->tableName && $this->alias) ?
$this->columnName . ' AS ' . $this->alias : $this->columnName));
}
|
[
"private",
"function",
"_prepareExpression",
"(",
")",
"{",
"$",
"this",
"->",
"expression",
"=",
"(",
"$",
"this",
"->",
"tableName",
"&&",
"$",
"this",
"->",
"alias",
")",
"?",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"this",
"->",
"columnName",
".",
"' AS '",
".",
"$",
"this",
"->",
"alias",
":",
"(",
"(",
"$",
"this",
"->",
"tableName",
"&&",
"!",
"$",
"this",
"->",
"alias",
")",
"?",
"$",
"this",
"->",
"tableName",
".",
"'.'",
".",
"$",
"this",
"->",
"columnName",
":",
"(",
"(",
"!",
"$",
"this",
"->",
"tableName",
"&&",
"$",
"this",
"->",
"alias",
")",
"?",
"$",
"this",
"->",
"columnName",
".",
"' AS '",
".",
"$",
"this",
"->",
"alias",
":",
"$",
"this",
"->",
"columnName",
")",
")",
";",
"}"
] |
Prepare the expression property, which is at least
the column name or a combination of the name,
alias and table reference.
|
[
"Prepare",
"the",
"expression",
"property",
"which",
"is",
"at",
"least",
"the",
"column",
"name",
"or",
"a",
"combination",
"of",
"the",
"name",
"alias",
"and",
"table",
"reference",
"."
] |
dd30946ad35ab06cba2167cf6dfa02b733614720
|
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/References/MySql/Column.php#L194-L200
|
10,960
|
gossi/trixionary
|
src/model/Base/Kstruktur.php
|
Kstruktur.getParentOrCreate
|
public function getParentOrCreate($con = null)
{
if ($this->isNew()) {
if ($this->isPrimaryKeyNull()) {
$parent = new ChildStructureNode();
$parent->setDescendantClass('gossi\trixionary\model\Kstruktur');
return $parent;
} else {
$parent = \gossi\trixionary\model\StructureNodeQuery::create()->findPk($this->getPrimaryKey(), $con);
if (null === $parent || null !== $parent->getDescendantClass()) {
$parent = new ChildStructureNode();
$parent->setPrimaryKey($this->getPrimaryKey());
$parent->setDescendantClass('gossi\trixionary\model\Kstruktur');
}
return $parent;
}
} else {
return ChildStructureNodeQuery::create()->findPk($this->getPrimaryKey(), $con);
}
}
|
php
|
public function getParentOrCreate($con = null)
{
if ($this->isNew()) {
if ($this->isPrimaryKeyNull()) {
$parent = new ChildStructureNode();
$parent->setDescendantClass('gossi\trixionary\model\Kstruktur');
return $parent;
} else {
$parent = \gossi\trixionary\model\StructureNodeQuery::create()->findPk($this->getPrimaryKey(), $con);
if (null === $parent || null !== $parent->getDescendantClass()) {
$parent = new ChildStructureNode();
$parent->setPrimaryKey($this->getPrimaryKey());
$parent->setDescendantClass('gossi\trixionary\model\Kstruktur');
}
return $parent;
}
} else {
return ChildStructureNodeQuery::create()->findPk($this->getPrimaryKey(), $con);
}
}
|
[
"public",
"function",
"getParentOrCreate",
"(",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPrimaryKeyNull",
"(",
")",
")",
"{",
"$",
"parent",
"=",
"new",
"ChildStructureNode",
"(",
")",
";",
"$",
"parent",
"->",
"setDescendantClass",
"(",
"'gossi\\trixionary\\model\\Kstruktur'",
")",
";",
"return",
"$",
"parent",
";",
"}",
"else",
"{",
"$",
"parent",
"=",
"\\",
"gossi",
"\\",
"trixionary",
"\\",
"model",
"\\",
"StructureNodeQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
",",
"$",
"con",
")",
";",
"if",
"(",
"null",
"===",
"$",
"parent",
"||",
"null",
"!==",
"$",
"parent",
"->",
"getDescendantClass",
"(",
")",
")",
"{",
"$",
"parent",
"=",
"new",
"ChildStructureNode",
"(",
")",
";",
"$",
"parent",
"->",
"setPrimaryKey",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"$",
"parent",
"->",
"setDescendantClass",
"(",
"'gossi\\trixionary\\model\\Kstruktur'",
")",
";",
"}",
"return",
"$",
"parent",
";",
"}",
"}",
"else",
"{",
"return",
"ChildStructureNodeQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
",",
"$",
"con",
")",
";",
"}",
"}"
] |
Get or Create the parent ChildStructureNode object of the current object
@return ChildStructureNode The parent object
|
[
"Get",
"or",
"Create",
"the",
"parent",
"ChildStructureNode",
"object",
"of",
"the",
"current",
"object"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Kstruktur.php#L1877-L1898
|
10,961
|
FuturaSoft/Pabana
|
src/Type/StringType.php
|
StringType.replace
|
public function replace($oldString, $newString)
{
$this->stringVar = str_replace($oldString, $newString, $this->stringVar);
}
|
php
|
public function replace($oldString, $newString)
{
$this->stringVar = str_replace($oldString, $newString, $this->stringVar);
}
|
[
"public",
"function",
"replace",
"(",
"$",
"oldString",
",",
"$",
"newString",
")",
"{",
"$",
"this",
"->",
"stringVar",
"=",
"str_replace",
"(",
"$",
"oldString",
",",
"$",
"newString",
",",
"$",
"this",
"->",
"stringVar",
")",
";",
"}"
] |
Returns a new string resulting from replacing all occurrences of oldString in this string with newString.
@since 1.1
@param string $oldString The old string.
@param string $newString The new string.
@return void
|
[
"Returns",
"a",
"new",
"string",
"resulting",
"from",
"replacing",
"all",
"occurrences",
"of",
"oldString",
"in",
"this",
"string",
"with",
"newString",
"."
] |
b3a95eeb976042ac2a393cc10755a7adbc164c24
|
https://github.com/FuturaSoft/Pabana/blob/b3a95eeb976042ac2a393cc10755a7adbc164c24/src/Type/StringType.php#L99-L102
|
10,962
|
hermajan/lib
|
src/Folder.php
|
Folder.content
|
public function content($dots = true) {
$content = scandir($this->path);
foreach($content as $file) {
if($dots == false) {
if((strcmp($file, ".") == 0) or (strcmp($file, "..") == 0)) {
continue;
}
}
echo "<a href='".$this->path."/".$file."'>".$file."</a><br>";
}
}
|
php
|
public function content($dots = true) {
$content = scandir($this->path);
foreach($content as $file) {
if($dots == false) {
if((strcmp($file, ".") == 0) or (strcmp($file, "..") == 0)) {
continue;
}
}
echo "<a href='".$this->path."/".$file."'>".$file."</a><br>";
}
}
|
[
"public",
"function",
"content",
"(",
"$",
"dots",
"=",
"true",
")",
"{",
"$",
"content",
"=",
"scandir",
"(",
"$",
"this",
"->",
"path",
")",
";",
"foreach",
"(",
"$",
"content",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"dots",
"==",
"false",
")",
"{",
"if",
"(",
"(",
"strcmp",
"(",
"$",
"file",
",",
"\".\"",
")",
"==",
"0",
")",
"or",
"(",
"strcmp",
"(",
"$",
"file",
",",
"\"..\"",
")",
"==",
"0",
")",
")",
"{",
"continue",
";",
"}",
"}",
"echo",
"\"<a href='\"",
".",
"$",
"this",
"->",
"path",
".",
"\"/\"",
".",
"$",
"file",
".",
"\"'>\"",
".",
"$",
"file",
".",
"\"</a><br>\"",
";",
"}",
"}"
] |
Prints content of folder.
@param bool $dots True if show dots, false otherwise.
|
[
"Prints",
"content",
"of",
"folder",
"."
] |
7d666260f5bcee041f130a3c3100f520b5e4bbd2
|
https://github.com/hermajan/lib/blob/7d666260f5bcee041f130a3c3100f520b5e4bbd2/src/Folder.php#L18-L28
|
10,963
|
gossi/trixionary
|
src/domain/base/PictureDomainTrait.php
|
PictureDomainTrait.setFeaturedSkillId
|
public function setFeaturedSkillId($id, $relatedId) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Picture not found.']);
}
// update
if ($this->doSetFeaturedSkillId($model, $relatedId)) {
$this->dispatch(PictureEvent::PRE_FEATURED_SKILL_UPDATE, $model);
$this->dispatch(PictureEvent::PRE_SAVE, $model);
$model->save();
$this->dispatch(PictureEvent::POST_FEATURED_SKILL_UPDATE, $model);
$this->dispatch(PictureEvent::POST_SAVE, $model);
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
php
|
public function setFeaturedSkillId($id, $relatedId) {
// find
$model = $this->get($id);
if ($model === null) {
return new NotFound(['message' => 'Picture not found.']);
}
// update
if ($this->doSetFeaturedSkillId($model, $relatedId)) {
$this->dispatch(PictureEvent::PRE_FEATURED_SKILL_UPDATE, $model);
$this->dispatch(PictureEvent::PRE_SAVE, $model);
$model->save();
$this->dispatch(PictureEvent::POST_FEATURED_SKILL_UPDATE, $model);
$this->dispatch(PictureEvent::POST_SAVE, $model);
return Updated(['model' => $model]);
}
return NotUpdated(['model' => $model]);
}
|
[
"public",
"function",
"setFeaturedSkillId",
"(",
"$",
"id",
",",
"$",
"relatedId",
")",
"{",
"// find",
"$",
"model",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"return",
"new",
"NotFound",
"(",
"[",
"'message'",
"=>",
"'Picture not found.'",
"]",
")",
";",
"}",
"// update",
"if",
"(",
"$",
"this",
"->",
"doSetFeaturedSkillId",
"(",
"$",
"model",
",",
"$",
"relatedId",
")",
")",
"{",
"$",
"this",
"->",
"dispatch",
"(",
"PictureEvent",
"::",
"PRE_FEATURED_SKILL_UPDATE",
",",
"$",
"model",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"PictureEvent",
"::",
"PRE_SAVE",
",",
"$",
"model",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"PictureEvent",
"::",
"POST_FEATURED_SKILL_UPDATE",
",",
"$",
"model",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"PictureEvent",
"::",
"POST_SAVE",
",",
"$",
"model",
")",
";",
"return",
"Updated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}",
"return",
"NotUpdated",
"(",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Sets the FeaturedSkill id
@param mixed $id
@param mixed $relatedId
@return PayloadInterface
|
[
"Sets",
"the",
"FeaturedSkill",
"id"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/PictureDomainTrait.php#L151-L171
|
10,964
|
gossi/trixionary
|
src/domain/base/PictureDomainTrait.php
|
PictureDomainTrait.doSetFeaturedSkillId
|
protected function doSetFeaturedSkillId(Picture $model, $relatedId) {
if ($model->getPictureId() !== $relatedId) {
$model->setPictureId($relatedId);
return true;
}
return false;
}
|
php
|
protected function doSetFeaturedSkillId(Picture $model, $relatedId) {
if ($model->getPictureId() !== $relatedId) {
$model->setPictureId($relatedId);
return true;
}
return false;
}
|
[
"protected",
"function",
"doSetFeaturedSkillId",
"(",
"Picture",
"$",
"model",
",",
"$",
"relatedId",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"getPictureId",
"(",
")",
"!==",
"$",
"relatedId",
")",
"{",
"$",
"model",
"->",
"setPictureId",
"(",
"$",
"relatedId",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Internal mechanism to set the FeaturedSkill id
@param Picture $model
@param mixed $relatedId
|
[
"Internal",
"mechanism",
"to",
"set",
"the",
"FeaturedSkill",
"id"
] |
221a6c5322473d7d7f8e322958a3ee46d87da150
|
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/domain/base/PictureDomainTrait.php#L326-L334
|
10,965
|
bishopb/vanilla
|
library/core/class.validation.php
|
Gdn_Validation.ApplyRules
|
public function ApplyRules($Fields) {
foreach ($Fields as $Index => $Row) {
$Validation = GetValue('Validation', $Row);
if (!$Validation)
continue;
$FieldName = GetValue('Name', $Row, $Index);
if (is_string($Validation)) {
$this->ApplyRule($FieldName, $Validation);
} elseif (is_array($Validation)) {
foreach ($Validation as $Rule) {
if (is_array($Rule)) {
$this->ApplyRule($FieldName, $Rule[0], $Rule[1]);
} else {
$this->ApplyRule($FieldName, $Rule);
}
}
}
}
}
|
php
|
public function ApplyRules($Fields) {
foreach ($Fields as $Index => $Row) {
$Validation = GetValue('Validation', $Row);
if (!$Validation)
continue;
$FieldName = GetValue('Name', $Row, $Index);
if (is_string($Validation)) {
$this->ApplyRule($FieldName, $Validation);
} elseif (is_array($Validation)) {
foreach ($Validation as $Rule) {
if (is_array($Rule)) {
$this->ApplyRule($FieldName, $Rule[0], $Rule[1]);
} else {
$this->ApplyRule($FieldName, $Rule);
}
}
}
}
}
|
[
"public",
"function",
"ApplyRules",
"(",
"$",
"Fields",
")",
"{",
"foreach",
"(",
"$",
"Fields",
"as",
"$",
"Index",
"=>",
"$",
"Row",
")",
"{",
"$",
"Validation",
"=",
"GetValue",
"(",
"'Validation'",
",",
"$",
"Row",
")",
";",
"if",
"(",
"!",
"$",
"Validation",
")",
"continue",
";",
"$",
"FieldName",
"=",
"GetValue",
"(",
"'Name'",
",",
"$",
"Row",
",",
"$",
"Index",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"Validation",
")",
")",
"{",
"$",
"this",
"->",
"ApplyRule",
"(",
"$",
"FieldName",
",",
"$",
"Validation",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"Validation",
")",
")",
"{",
"foreach",
"(",
"$",
"Validation",
"as",
"$",
"Rule",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"Rule",
")",
")",
"{",
"$",
"this",
"->",
"ApplyRule",
"(",
"$",
"FieldName",
",",
"$",
"Rule",
"[",
"0",
"]",
",",
"$",
"Rule",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"ApplyRule",
"(",
"$",
"FieldName",
",",
"$",
"Rule",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Apply an array of validation rules all at once.
@param array $Fields
|
[
"Apply",
"an",
"array",
"of",
"validation",
"rules",
"all",
"at",
"once",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.validation.php#L252-L271
|
10,966
|
bishopb/vanilla
|
library/core/class.validation.php
|
Gdn_Validation.ValidateRule
|
public static function ValidateRule($Value, $FieldName, $Rule, $CustomError = FALSE) {
// Figure out the type of rule.
if (is_string($Rule)) {
if (StringBeginsWith($Rule, 'regex:', TRUE)) {
$RuleName = 'regex';
$Args = substr($Rule, 6);
} elseif (StringBeginsWith($Rule, 'function:', TRUE)) {
$RuleName = substr($Rule, 9);
} else {
$RuleName = $Rule;
}
} elseif (is_array($Rule)) {
$RuleName = GetValue('Name', $Rule);
$Args = GetValue('Args', $Rule);
}
if (!isset($Args))
$Args = NULL;
if (function_exists($RuleName)) {
$Result = $RuleName($Value, $Args);
if ($Result === TRUE)
return TRUE;
elseif ($CustomError)
return $CustomError;
elseif (is_string($Result))
return $Result;
else
return sprintf(T($RuleName), T($FieldName));
} else {
return sprintf('Validation does not exist: %s.', $RuleName);
}
}
|
php
|
public static function ValidateRule($Value, $FieldName, $Rule, $CustomError = FALSE) {
// Figure out the type of rule.
if (is_string($Rule)) {
if (StringBeginsWith($Rule, 'regex:', TRUE)) {
$RuleName = 'regex';
$Args = substr($Rule, 6);
} elseif (StringBeginsWith($Rule, 'function:', TRUE)) {
$RuleName = substr($Rule, 9);
} else {
$RuleName = $Rule;
}
} elseif (is_array($Rule)) {
$RuleName = GetValue('Name', $Rule);
$Args = GetValue('Args', $Rule);
}
if (!isset($Args))
$Args = NULL;
if (function_exists($RuleName)) {
$Result = $RuleName($Value, $Args);
if ($Result === TRUE)
return TRUE;
elseif ($CustomError)
return $CustomError;
elseif (is_string($Result))
return $Result;
else
return sprintf(T($RuleName), T($FieldName));
} else {
return sprintf('Validation does not exist: %s.', $RuleName);
}
}
|
[
"public",
"static",
"function",
"ValidateRule",
"(",
"$",
"Value",
",",
"$",
"FieldName",
",",
"$",
"Rule",
",",
"$",
"CustomError",
"=",
"FALSE",
")",
"{",
"// Figure out the type of rule.",
"if",
"(",
"is_string",
"(",
"$",
"Rule",
")",
")",
"{",
"if",
"(",
"StringBeginsWith",
"(",
"$",
"Rule",
",",
"'regex:'",
",",
"TRUE",
")",
")",
"{",
"$",
"RuleName",
"=",
"'regex'",
";",
"$",
"Args",
"=",
"substr",
"(",
"$",
"Rule",
",",
"6",
")",
";",
"}",
"elseif",
"(",
"StringBeginsWith",
"(",
"$",
"Rule",
",",
"'function:'",
",",
"TRUE",
")",
")",
"{",
"$",
"RuleName",
"=",
"substr",
"(",
"$",
"Rule",
",",
"9",
")",
";",
"}",
"else",
"{",
"$",
"RuleName",
"=",
"$",
"Rule",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"Rule",
")",
")",
"{",
"$",
"RuleName",
"=",
"GetValue",
"(",
"'Name'",
",",
"$",
"Rule",
")",
";",
"$",
"Args",
"=",
"GetValue",
"(",
"'Args'",
",",
"$",
"Rule",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"Args",
")",
")",
"$",
"Args",
"=",
"NULL",
";",
"if",
"(",
"function_exists",
"(",
"$",
"RuleName",
")",
")",
"{",
"$",
"Result",
"=",
"$",
"RuleName",
"(",
"$",
"Value",
",",
"$",
"Args",
")",
";",
"if",
"(",
"$",
"Result",
"===",
"TRUE",
")",
"return",
"TRUE",
";",
"elseif",
"(",
"$",
"CustomError",
")",
"return",
"$",
"CustomError",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"Result",
")",
")",
"return",
"$",
"Result",
";",
"else",
"return",
"sprintf",
"(",
"T",
"(",
"$",
"RuleName",
")",
",",
"T",
"(",
"$",
"FieldName",
")",
")",
";",
"}",
"else",
"{",
"return",
"sprintf",
"(",
"'Validation does not exist: %s.'",
",",
"$",
"RuleName",
")",
";",
"}",
"}"
] |
Execute a single validation rule and return its result.
@param mixed $Value The value to validate.
@param string $FieldName The name of the field to put into the error result.
@param string|array $Rule The rule to validate which can be one of the following.
- string: The name of a function used to validate the value.
- 'regex:<regex>': The regular expression used to validate the value.
- array: An array with the following keys:
- Name: The name of the function used to validate.
- Args: An argument to pass to the function after the value.
@param string $CustomError A custom error message.
@return bool|string One of the following
- TRUE: The value passed validation.
- string: The error message associated with the error.
|
[
"Execute",
"a",
"single",
"validation",
"rule",
"and",
"return",
"its",
"result",
"."
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.validation.php#L464-L496
|
10,967
|
AlexHowansky/ork-base
|
src/Image/Gravatar.php
|
Gravatar.getUri
|
public function getUri()
{
if (empty($this->getConfig('email')) === true) {
throw new \RuntimeException('No email specified.');
}
$uri = 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($this->getConfig('email')))) . '.jpg';
$args = http_build_query([
's' => $this->getConfig('size'),
'd' => $this->getConfig('defaultUri'),
]);
if (empty($args) === false) {
$uri .= '?' . $args;
}
return $uri;
}
|
php
|
public function getUri()
{
if (empty($this->getConfig('email')) === true) {
throw new \RuntimeException('No email specified.');
}
$uri = 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($this->getConfig('email')))) . '.jpg';
$args = http_build_query([
's' => $this->getConfig('size'),
'd' => $this->getConfig('defaultUri'),
]);
if (empty($args) === false) {
$uri .= '?' . $args;
}
return $uri;
}
|
[
"public",
"function",
"getUri",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'email'",
")",
")",
"===",
"true",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'No email specified.'",
")",
";",
"}",
"$",
"uri",
"=",
"'http://www.gravatar.com/avatar/'",
".",
"md5",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'email'",
")",
")",
")",
")",
".",
"'.jpg'",
";",
"$",
"args",
"=",
"http_build_query",
"(",
"[",
"'s'",
"=>",
"$",
"this",
"->",
"getConfig",
"(",
"'size'",
")",
",",
"'d'",
"=>",
"$",
"this",
"->",
"getConfig",
"(",
"'defaultUri'",
")",
",",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
"===",
"false",
")",
"{",
"$",
"uri",
".=",
"'?'",
".",
"$",
"args",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] |
Get the gravatar URI.
@return string The gravatar URI.
|
[
"Get",
"the",
"gravatar",
"URI",
"."
] |
5f4ab14e63bbc8b17898639fd1fff86ee6659bb0
|
https://github.com/AlexHowansky/ork-base/blob/5f4ab14e63bbc8b17898639fd1fff86ee6659bb0/src/Image/Gravatar.php#L67-L81
|
10,968
|
fabsgc/framework
|
Core/Form/Validation/Validation.php
|
Validation.radio
|
public function radio($field, $label) {
$radio = new Radio($field, $label);
array_push($this->_elements, $radio);
return $radio;
}
|
php
|
public function radio($field, $label) {
$radio = new Radio($field, $label);
array_push($this->_elements, $radio);
return $radio;
}
|
[
"public",
"function",
"radio",
"(",
"$",
"field",
",",
"$",
"label",
")",
"{",
"$",
"radio",
"=",
"new",
"Radio",
"(",
"$",
"field",
",",
"$",
"label",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"_elements",
",",
"$",
"radio",
")",
";",
"return",
"$",
"radio",
";",
"}"
] |
add radio element
@access public
@param $field string
@param $label string
@return \Gcs\Framework\Core\Form\Validation\Element\Radio
@since 3.0
@package Gcs\Framework\Core\Form\Validation
|
[
"add",
"radio",
"element"
] |
45e58182aba6a3c6381970a1fd3c17662cff2168
|
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Form/Validation/Validation.php#L140-L145
|
10,969
|
ellipsephp/validation
|
src/RulesCollection.php
|
RulesCollection.withRule
|
public function withRule(Rule $rule): RulesCollection
{
$rules = array_merge($this->rules, [$rule]);
return new RulesCollection($rules);
}
|
php
|
public function withRule(Rule $rule): RulesCollection
{
$rules = array_merge($this->rules, [$rule]);
return new RulesCollection($rules);
}
|
[
"public",
"function",
"withRule",
"(",
"Rule",
"$",
"rule",
")",
":",
"RulesCollection",
"{",
"$",
"rules",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"rules",
",",
"[",
"$",
"rule",
"]",
")",
";",
"return",
"new",
"RulesCollection",
"(",
"$",
"rules",
")",
";",
"}"
] |
Return a new rules collection with an aditional rule.
@param \Ellipse\Validation\Rule $rule
@return \Ellipse\Validation\RulesCollection
|
[
"Return",
"a",
"new",
"rules",
"collection",
"with",
"an",
"aditional",
"rule",
"."
] |
5a7e11807099165ff6217bf8c38df4b21d99599d
|
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/RulesCollection.php#L32-L37
|
10,970
|
ellipsephp/validation
|
src/RulesCollection.php
|
RulesCollection.getNestedErrors
|
private function getNestedErrors(string $key, array $scope, array $input): array
{
$parts = explode('.', $key);
$current = array_shift($parts);
$next = implode('.', $parts);
// The current part is * and there is still some parts, rune the
// validation on each nested value.
if ($current == '*' && count($parts) > 0) {
$errors = [];
foreach ($scope as $key => $nested) {
$new_errors = $this->getNestedErrors($next, $nested, $input);
$errors = array_merge($errors, $new_errors);
}
return $errors;
}
// There is still some parts, run the validation on the nested value.
if (count($parts) > 0) {
return $this->getNestedErrors($next, $scope[$current] ?? [], $input);
}
// There is no more parts, run the validation on the current scope.
return $this->getErrors($current, $scope, $input);
}
|
php
|
private function getNestedErrors(string $key, array $scope, array $input): array
{
$parts = explode('.', $key);
$current = array_shift($parts);
$next = implode('.', $parts);
// The current part is * and there is still some parts, rune the
// validation on each nested value.
if ($current == '*' && count($parts) > 0) {
$errors = [];
foreach ($scope as $key => $nested) {
$new_errors = $this->getNestedErrors($next, $nested, $input);
$errors = array_merge($errors, $new_errors);
}
return $errors;
}
// There is still some parts, run the validation on the nested value.
if (count($parts) > 0) {
return $this->getNestedErrors($next, $scope[$current] ?? [], $input);
}
// There is no more parts, run the validation on the current scope.
return $this->getErrors($current, $scope, $input);
}
|
[
"private",
"function",
"getNestedErrors",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"scope",
",",
"array",
"$",
"input",
")",
":",
"array",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"$",
"current",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"$",
"next",
"=",
"implode",
"(",
"'.'",
",",
"$",
"parts",
")",
";",
"// The current part is * and there is still some parts, rune the",
"// validation on each nested value.",
"if",
"(",
"$",
"current",
"==",
"'*'",
"&&",
"count",
"(",
"$",
"parts",
")",
">",
"0",
")",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"scope",
"as",
"$",
"key",
"=>",
"$",
"nested",
")",
"{",
"$",
"new_errors",
"=",
"$",
"this",
"->",
"getNestedErrors",
"(",
"$",
"next",
",",
"$",
"nested",
",",
"$",
"input",
")",
";",
"$",
"errors",
"=",
"array_merge",
"(",
"$",
"errors",
",",
"$",
"new_errors",
")",
";",
"}",
"return",
"$",
"errors",
";",
"}",
"// There is still some parts, run the validation on the nested value.",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"getNestedErrors",
"(",
"$",
"next",
",",
"$",
"scope",
"[",
"$",
"current",
"]",
"??",
"[",
"]",
",",
"$",
"input",
")",
";",
"}",
"// There is no more parts, run the validation on the current scope.",
"return",
"$",
"this",
"->",
"getErrors",
"(",
"$",
"current",
",",
"$",
"scope",
",",
"$",
"input",
")",
";",
"}"
] |
Go deeper in the input array for each dot in the rule key. Run the
validation when on the last part of the rule key.
@param string $key
@param array $scope
@param array $input
@return array
|
[
"Go",
"deeper",
"in",
"the",
"input",
"array",
"for",
"each",
"dot",
"in",
"the",
"rule",
"key",
".",
"Run",
"the",
"validation",
"when",
"on",
"the",
"last",
"part",
"of",
"the",
"rule",
"key",
"."
] |
5a7e11807099165ff6217bf8c38df4b21d99599d
|
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/RulesCollection.php#L61-L94
|
10,971
|
ellipsephp/validation
|
src/RulesCollection.php
|
RulesCollection.getErrors
|
private function getErrors(string $key, array $scope, array $input): array
{
$errors = [];
foreach ($this->rules as $rule) {
try {
$rule->validate($key, $scope, $input);
}
catch (ValidationException $e) {
$parameters = $e->getParameters();
$errors[] = new ValidationError($rule->getName(), $parameters);
}
}
return $errors;
}
|
php
|
private function getErrors(string $key, array $scope, array $input): array
{
$errors = [];
foreach ($this->rules as $rule) {
try {
$rule->validate($key, $scope, $input);
}
catch (ValidationException $e) {
$parameters = $e->getParameters();
$errors[] = new ValidationError($rule->getName(), $parameters);
}
}
return $errors;
}
|
[
"private",
"function",
"getErrors",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"scope",
",",
"array",
"$",
"input",
")",
":",
"array",
"{",
"$",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"try",
"{",
"$",
"rule",
"->",
"validate",
"(",
"$",
"key",
",",
"$",
"scope",
",",
"$",
"input",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"$",
"parameters",
"=",
"$",
"e",
"->",
"getParameters",
"(",
")",
";",
"$",
"errors",
"[",
"]",
"=",
"new",
"ValidationError",
"(",
"$",
"rule",
"->",
"getName",
"(",
")",
",",
"$",
"parameters",
")",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Run the validation on a key of the given scope.
@param string $key
@param array $scope
@param array $input
@return array
|
[
"Run",
"the",
"validation",
"on",
"a",
"key",
"of",
"the",
"given",
"scope",
"."
] |
5a7e11807099165ff6217bf8c38df4b21d99599d
|
https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/RulesCollection.php#L104-L127
|
10,972
|
Apatis/Http-Message
|
src/Uri.php
|
Uri.parseURI
|
public function parseURI(string $uri) : array
{
if ($uri == '') {
throw new \InvalidArgumentException(
"URI Could not be empty"
);
}
$parsedUri = parse_url($uri);
if ($parsedUri === false) {
throw new \InvalidArgumentException("Unable to parse URI: $uri");
}
$defaultParsedUri = [
'user' => null,
'pass' => null,
'scheme'=> '',
'host' => '',
'port' => null,
'path' => '',
'query' => '',
'fragment' => '',
];
return array_merge($defaultParsedUri, $parsedUri);
}
|
php
|
public function parseURI(string $uri) : array
{
if ($uri == '') {
throw new \InvalidArgumentException(
"URI Could not be empty"
);
}
$parsedUri = parse_url($uri);
if ($parsedUri === false) {
throw new \InvalidArgumentException("Unable to parse URI: $uri");
}
$defaultParsedUri = [
'user' => null,
'pass' => null,
'scheme'=> '',
'host' => '',
'port' => null,
'path' => '',
'query' => '',
'fragment' => '',
];
return array_merge($defaultParsedUri, $parsedUri);
}
|
[
"public",
"function",
"parseURI",
"(",
"string",
"$",
"uri",
")",
":",
"array",
"{",
"if",
"(",
"$",
"uri",
"==",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"URI Could not be empty\"",
")",
";",
"}",
"$",
"parsedUri",
"=",
"parse_url",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"parsedUri",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unable to parse URI: $uri\"",
")",
";",
"}",
"$",
"defaultParsedUri",
"=",
"[",
"'user'",
"=>",
"null",
",",
"'pass'",
"=>",
"null",
",",
"'scheme'",
"=>",
"''",
",",
"'host'",
"=>",
"''",
",",
"'port'",
"=>",
"null",
",",
"'path'",
"=>",
"''",
",",
"'query'",
"=>",
"''",
",",
"'fragment'",
"=>",
"''",
",",
"]",
";",
"return",
"array_merge",
"(",
"$",
"defaultParsedUri",
",",
"$",
"parsedUri",
")",
";",
"}"
] |
Parse URI and return full detail
@param string $uri
@return array
|
[
"Parse",
"URI",
"and",
"return",
"full",
"detail"
] |
9ede3f8bcdd2400b238e0624a4af8f09c60da222
|
https://github.com/Apatis/Http-Message/blob/9ede3f8bcdd2400b238e0624a4af8f09c60da222/src/Uri.php#L133-L158
|
10,973
|
Apatis/Http-Message
|
src/Uri.php
|
Uri.removeDefaultPort
|
public function removeDefaultPort()
{
if ($this->port !== null
&& isset($this->defaultPorts[$this->getScheme()])
&& $this->defaultPorts[$this->getScheme()] === $this->port
) {
$this->port = null;
}
}
|
php
|
public function removeDefaultPort()
{
if ($this->port !== null
&& isset($this->defaultPorts[$this->getScheme()])
&& $this->defaultPorts[$this->getScheme()] === $this->port
) {
$this->port = null;
}
}
|
[
"public",
"function",
"removeDefaultPort",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"port",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"this",
"->",
"defaultPorts",
"[",
"$",
"this",
"->",
"getScheme",
"(",
")",
"]",
")",
"&&",
"$",
"this",
"->",
"defaultPorts",
"[",
"$",
"this",
"->",
"getScheme",
"(",
")",
"]",
"===",
"$",
"this",
"->",
"port",
")",
"{",
"$",
"this",
"->",
"port",
"=",
"null",
";",
"}",
"}"
] |
Remove Default Port
|
[
"Remove",
"Default",
"Port"
] |
9ede3f8bcdd2400b238e0624a4af8f09c60da222
|
https://github.com/Apatis/Http-Message/blob/9ede3f8bcdd2400b238e0624a4af8f09c60da222/src/Uri.php#L173-L181
|
10,974
|
Apatis/Http-Message
|
src/Uri.php
|
Uri.toUriString
|
public function toUriString() : string
{
$uri = '';
if (($scheme = $this->getScheme()) != '') {
$uri .= $scheme . ':';
}
if (($authority = $this->getAuthority()) != '' || $scheme === 'file') {
$uri .= '//' . $authority;
}
$uri .= $this->getPath();
if (($query = $this->getQuery()) != '') {
$uri .= '?' . $query;
}
if (($fragment = $this->getFragment()) != '') {
$uri .= '#' . $fragment;
}
return $uri;
}
|
php
|
public function toUriString() : string
{
$uri = '';
if (($scheme = $this->getScheme()) != '') {
$uri .= $scheme . ':';
}
if (($authority = $this->getAuthority()) != '' || $scheme === 'file') {
$uri .= '//' . $authority;
}
$uri .= $this->getPath();
if (($query = $this->getQuery()) != '') {
$uri .= '?' . $query;
}
if (($fragment = $this->getFragment()) != '') {
$uri .= '#' . $fragment;
}
return $uri;
}
|
[
"public",
"function",
"toUriString",
"(",
")",
":",
"string",
"{",
"$",
"uri",
"=",
"''",
";",
"if",
"(",
"(",
"$",
"scheme",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
")",
"!=",
"''",
")",
"{",
"$",
"uri",
".=",
"$",
"scheme",
".",
"':'",
";",
"}",
"if",
"(",
"(",
"$",
"authority",
"=",
"$",
"this",
"->",
"getAuthority",
"(",
")",
")",
"!=",
"''",
"||",
"$",
"scheme",
"===",
"'file'",
")",
"{",
"$",
"uri",
".=",
"'//'",
".",
"$",
"authority",
";",
"}",
"$",
"uri",
".=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"(",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
")",
"!=",
"''",
")",
"{",
"$",
"uri",
".=",
"'?'",
".",
"$",
"query",
";",
"}",
"if",
"(",
"(",
"$",
"fragment",
"=",
"$",
"this",
"->",
"getFragment",
"(",
")",
")",
"!=",
"''",
")",
"{",
"$",
"uri",
".=",
"'#'",
".",
"$",
"fragment",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] |
Convert Uri to String
@return string
|
[
"Convert",
"Uri",
"to",
"String"
] |
9ede3f8bcdd2400b238e0624a4af8f09c60da222
|
https://github.com/Apatis/Http-Message/blob/9ede3f8bcdd2400b238e0624a4af8f09c60da222/src/Uri.php#L476-L499
|
10,975
|
Apatis/Http-Message
|
src/Uri.php
|
Uri.fixSchemeProxyFromGlobals
|
public static function fixSchemeProxyFromGlobals(array $globals = null) : array
{
$globals = $globals === null ? $_SERVER : $globals;
if (!empty($globals['HTTPS']) && strtolower($globals['HTTPS']) !== 'off'
// hide behind proxy / maybe cloud flare cdn
|| isset($globals['HTTP_X_FORWARDED_PROTO']) && $globals['HTTP_X_FORWARDED_PROTO'] === 'https'
|| !empty($globals['HTTP_FRONT_END_HTTPS']) && strtolower($globals['HTTP_FRONT_END_HTTPS']) !== 'off'
) {
// fixing HTTPS Environment
$globals['HTTPS'] = 'on';
}
return $globals;
}
|
php
|
public static function fixSchemeProxyFromGlobals(array $globals = null) : array
{
$globals = $globals === null ? $_SERVER : $globals;
if (!empty($globals['HTTPS']) && strtolower($globals['HTTPS']) !== 'off'
// hide behind proxy / maybe cloud flare cdn
|| isset($globals['HTTP_X_FORWARDED_PROTO']) && $globals['HTTP_X_FORWARDED_PROTO'] === 'https'
|| !empty($globals['HTTP_FRONT_END_HTTPS']) && strtolower($globals['HTTP_FRONT_END_HTTPS']) !== 'off'
) {
// fixing HTTPS Environment
$globals['HTTPS'] = 'on';
}
return $globals;
}
|
[
"public",
"static",
"function",
"fixSchemeProxyFromGlobals",
"(",
"array",
"$",
"globals",
"=",
"null",
")",
":",
"array",
"{",
"$",
"globals",
"=",
"$",
"globals",
"===",
"null",
"?",
"$",
"_SERVER",
":",
"$",
"globals",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"globals",
"[",
"'HTTPS'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"globals",
"[",
"'HTTPS'",
"]",
")",
"!==",
"'off'",
"// hide behind proxy / maybe cloud flare cdn",
"||",
"isset",
"(",
"$",
"globals",
"[",
"'HTTP_X_FORWARDED_PROTO'",
"]",
")",
"&&",
"$",
"globals",
"[",
"'HTTP_X_FORWARDED_PROTO'",
"]",
"===",
"'https'",
"||",
"!",
"empty",
"(",
"$",
"globals",
"[",
"'HTTP_FRONT_END_HTTPS'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"globals",
"[",
"'HTTP_FRONT_END_HTTPS'",
"]",
")",
"!==",
"'off'",
")",
"{",
"// fixing HTTPS Environment",
"$",
"globals",
"[",
"'HTTPS'",
"]",
"=",
"'on'",
";",
"}",
"return",
"$",
"globals",
";",
"}"
] |
Fix Connection Behind Proxy Scheme
@param array|null $globals
@return array
|
[
"Fix",
"Connection",
"Behind",
"Proxy",
"Scheme"
] |
9ede3f8bcdd2400b238e0624a4af8f09c60da222
|
https://github.com/Apatis/Http-Message/blob/9ede3f8bcdd2400b238e0624a4af8f09c60da222/src/Uri.php#L518-L531
|
10,976
|
Archi-Strasbourg/archi-wiki
|
includes/framework/frameworkClasses/calqueObject.class.php
|
calqueObject.getDiv
|
public function getDiv($params=array())
{
$t=new Template($this->cheminTemplates);
$t->set_filenames((array('popup'=>'popupGeneric.tpl')));
$width = 500;
if(isset($params['width']) && $params['width']!='')
{
$width = $params['width'];
}
$height = 500;
if(isset($params['height']) && $params['height']!='')
{
$height = $params['height'];
}
$left = 100;
if(isset($params['left']) && $params['left']!='')
{
$left = $params['left'];
}
$top = 50;
if(isset($params['top']) && $params['top']!='')
{
$top = $params['top'];
}
$titrePopup="";
if(isset($params['titre']) && $params['titre']!='')
{
$titrePopup = $params['titre'];
}
$codeJsFermer="";
if(isset($params['codeJsFermerButton']) && $params['codeJsFermerButton']!='')
{
$codeJsFermer = $params['codeJsFermerButton'];
}
$hiddenFields="";
if(isset($params['hiddenFields']))
{
foreach($params['hiddenFields'] as $indice => $value)
{
$hiddenFields .= "<input type='hidden' id='".$indice."' name='".$indice."' value='".$value."'>";
}
}
$t->assign_vars(array(
'width'=>$width,
'height'=>$height,
'left'=>$left,
'top'=> $top,
'hiddenFields'=>$hiddenFields,
'divIdPopup'=>'div'.$this->idPopup,
'tdIdPopup'=>'td'.$this->idPopup,
'iFrameIdPopup'=>'iFrame'.$this->idPopup,
'lienSrcIFrame'=>$params['lienSrcIFrame'],
'titrePopup'=>$titrePopup,
'codeJsFermer'=>$codeJsFermer
));
ob_start();
$t->pparse('popup');
$html=ob_get_contents();
ob_end_clean();
return $html;
}
|
php
|
public function getDiv($params=array())
{
$t=new Template($this->cheminTemplates);
$t->set_filenames((array('popup'=>'popupGeneric.tpl')));
$width = 500;
if(isset($params['width']) && $params['width']!='')
{
$width = $params['width'];
}
$height = 500;
if(isset($params['height']) && $params['height']!='')
{
$height = $params['height'];
}
$left = 100;
if(isset($params['left']) && $params['left']!='')
{
$left = $params['left'];
}
$top = 50;
if(isset($params['top']) && $params['top']!='')
{
$top = $params['top'];
}
$titrePopup="";
if(isset($params['titre']) && $params['titre']!='')
{
$titrePopup = $params['titre'];
}
$codeJsFermer="";
if(isset($params['codeJsFermerButton']) && $params['codeJsFermerButton']!='')
{
$codeJsFermer = $params['codeJsFermerButton'];
}
$hiddenFields="";
if(isset($params['hiddenFields']))
{
foreach($params['hiddenFields'] as $indice => $value)
{
$hiddenFields .= "<input type='hidden' id='".$indice."' name='".$indice."' value='".$value."'>";
}
}
$t->assign_vars(array(
'width'=>$width,
'height'=>$height,
'left'=>$left,
'top'=> $top,
'hiddenFields'=>$hiddenFields,
'divIdPopup'=>'div'.$this->idPopup,
'tdIdPopup'=>'td'.$this->idPopup,
'iFrameIdPopup'=>'iFrame'.$this->idPopup,
'lienSrcIFrame'=>$params['lienSrcIFrame'],
'titrePopup'=>$titrePopup,
'codeJsFermer'=>$codeJsFermer
));
ob_start();
$t->pparse('popup');
$html=ob_get_contents();
ob_end_clean();
return $html;
}
|
[
"public",
"function",
"getDiv",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"t",
"=",
"new",
"Template",
"(",
"$",
"this",
"->",
"cheminTemplates",
")",
";",
"$",
"t",
"->",
"set_filenames",
"(",
"(",
"array",
"(",
"'popup'",
"=>",
"'popupGeneric.tpl'",
")",
")",
")",
";",
"$",
"width",
"=",
"500",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'width'",
"]",
")",
"&&",
"$",
"params",
"[",
"'width'",
"]",
"!=",
"''",
")",
"{",
"$",
"width",
"=",
"$",
"params",
"[",
"'width'",
"]",
";",
"}",
"$",
"height",
"=",
"500",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'height'",
"]",
")",
"&&",
"$",
"params",
"[",
"'height'",
"]",
"!=",
"''",
")",
"{",
"$",
"height",
"=",
"$",
"params",
"[",
"'height'",
"]",
";",
"}",
"$",
"left",
"=",
"100",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'left'",
"]",
")",
"&&",
"$",
"params",
"[",
"'left'",
"]",
"!=",
"''",
")",
"{",
"$",
"left",
"=",
"$",
"params",
"[",
"'left'",
"]",
";",
"}",
"$",
"top",
"=",
"50",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'top'",
"]",
")",
"&&",
"$",
"params",
"[",
"'top'",
"]",
"!=",
"''",
")",
"{",
"$",
"top",
"=",
"$",
"params",
"[",
"'top'",
"]",
";",
"}",
"$",
"titrePopup",
"=",
"\"\"",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'titre'",
"]",
")",
"&&",
"$",
"params",
"[",
"'titre'",
"]",
"!=",
"''",
")",
"{",
"$",
"titrePopup",
"=",
"$",
"params",
"[",
"'titre'",
"]",
";",
"}",
"$",
"codeJsFermer",
"=",
"\"\"",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'codeJsFermerButton'",
"]",
")",
"&&",
"$",
"params",
"[",
"'codeJsFermerButton'",
"]",
"!=",
"''",
")",
"{",
"$",
"codeJsFermer",
"=",
"$",
"params",
"[",
"'codeJsFermerButton'",
"]",
";",
"}",
"$",
"hiddenFields",
"=",
"\"\"",
";",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'hiddenFields'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"params",
"[",
"'hiddenFields'",
"]",
"as",
"$",
"indice",
"=>",
"$",
"value",
")",
"{",
"$",
"hiddenFields",
".=",
"\"<input type='hidden' id='\"",
".",
"$",
"indice",
".",
"\"' name='\"",
".",
"$",
"indice",
".",
"\"' value='\"",
".",
"$",
"value",
".",
"\"'>\"",
";",
"}",
"}",
"$",
"t",
"->",
"assign_vars",
"(",
"array",
"(",
"'width'",
"=>",
"$",
"width",
",",
"'height'",
"=>",
"$",
"height",
",",
"'left'",
"=>",
"$",
"left",
",",
"'top'",
"=>",
"$",
"top",
",",
"'hiddenFields'",
"=>",
"$",
"hiddenFields",
",",
"'divIdPopup'",
"=>",
"'div'",
".",
"$",
"this",
"->",
"idPopup",
",",
"'tdIdPopup'",
"=>",
"'td'",
".",
"$",
"this",
"->",
"idPopup",
",",
"'iFrameIdPopup'",
"=>",
"'iFrame'",
".",
"$",
"this",
"->",
"idPopup",
",",
"'lienSrcIFrame'",
"=>",
"$",
"params",
"[",
"'lienSrcIFrame'",
"]",
",",
"'titrePopup'",
"=>",
"$",
"titrePopup",
",",
"'codeJsFermer'",
"=>",
"$",
"codeJsFermer",
")",
")",
";",
"ob_start",
"(",
")",
";",
"$",
"t",
"->",
"pparse",
"(",
"'popup'",
")",
";",
"$",
"html",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
renvoi le code HTML de la popup en calque
|
[
"renvoi",
"le",
"code",
"HTML",
"de",
"la",
"popup",
"en",
"calque"
] |
b9fb39f43a78409890a7de96426c1f6c49d5c323
|
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/calqueObject.class.php#L155-L231
|
10,977
|
AnonymPHP/Anonym-Library
|
src/Anonym/Html/Form/Open.php
|
Open.prepareOptions
|
private function prepareOptions(array $options){
if (!Arr::has($options, 'method')) {
Arr::set($options, 'method', 'post');
}
if (!Arr::has($options, 'action')) {
Arr::set($options, 'action', '');
}
return $options;
}
|
php
|
private function prepareOptions(array $options){
if (!Arr::has($options, 'method')) {
Arr::set($options, 'method', 'post');
}
if (!Arr::has($options, 'action')) {
Arr::set($options, 'action', '');
}
return $options;
}
|
[
"private",
"function",
"prepareOptions",
"(",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"has",
"(",
"$",
"options",
",",
"'method'",
")",
")",
"{",
"Arr",
"::",
"set",
"(",
"$",
"options",
",",
"'method'",
",",
"'post'",
")",
";",
"}",
"if",
"(",
"!",
"Arr",
"::",
"has",
"(",
"$",
"options",
",",
"'action'",
")",
")",
"{",
"Arr",
"::",
"set",
"(",
"$",
"options",
",",
"'action'",
",",
"''",
")",
";",
"}",
"return",
"$",
"options",
";",
"}"
] |
prepare options for build
@param array $options
@return array
|
[
"prepare",
"options",
"for",
"build"
] |
c967ad804f84e8fb204593a0959cda2fed5ae075
|
https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Html/Form/Open.php#L56-L66
|
10,978
|
JumpGateio/Database
|
src/JumpGate/Database/Traits/Collection/Chaining.php
|
Chaining.chainingGetMethod
|
public function chainingGetMethod($key)
{
$newCollection = new self();
foreach ($this->items as $item) {
// This item is a collection
if ($item instanceof self) {
foreach ($item as $subItem) {
$newCollection->put($newCollection->count(), $subItem->$key);
}
continue;
}
// The next item in the chain is a collection
if (is_object($item) && ! $item instanceof self && $item->$key instanceof self) {
foreach ($item->$key as $subItem) {
$newCollection->put($newCollection->count(), $subItem);
}
continue;
}
$newCollection->put($newCollection->count(), $item->$key);
}
return $newCollection;
}
|
php
|
public function chainingGetMethod($key)
{
$newCollection = new self();
foreach ($this->items as $item) {
// This item is a collection
if ($item instanceof self) {
foreach ($item as $subItem) {
$newCollection->put($newCollection->count(), $subItem->$key);
}
continue;
}
// The next item in the chain is a collection
if (is_object($item) && ! $item instanceof self && $item->$key instanceof self) {
foreach ($item->$key as $subItem) {
$newCollection->put($newCollection->count(), $subItem);
}
continue;
}
$newCollection->put($newCollection->count(), $item->$key);
}
return $newCollection;
}
|
[
"public",
"function",
"chainingGetMethod",
"(",
"$",
"key",
")",
"{",
"$",
"newCollection",
"=",
"new",
"self",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"// This item is a collection",
"if",
"(",
"$",
"item",
"instanceof",
"self",
")",
"{",
"foreach",
"(",
"$",
"item",
"as",
"$",
"subItem",
")",
"{",
"$",
"newCollection",
"->",
"put",
"(",
"$",
"newCollection",
"->",
"count",
"(",
")",
",",
"$",
"subItem",
"->",
"$",
"key",
")",
";",
"}",
"continue",
";",
"}",
"// The next item in the chain is a collection",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"!",
"$",
"item",
"instanceof",
"self",
"&&",
"$",
"item",
"->",
"$",
"key",
"instanceof",
"self",
")",
"{",
"foreach",
"(",
"$",
"item",
"->",
"$",
"key",
"as",
"$",
"subItem",
")",
"{",
"$",
"newCollection",
"->",
"put",
"(",
"$",
"newCollection",
"->",
"count",
"(",
")",
",",
"$",
"subItem",
")",
";",
"}",
"continue",
";",
"}",
"$",
"newCollection",
"->",
"put",
"(",
"$",
"newCollection",
"->",
"count",
"(",
")",
",",
"$",
"item",
"->",
"$",
"key",
")",
";",
"}",
"return",
"$",
"newCollection",
";",
"}"
] |
Dynamically retrieve attributes on the model.
@param string $key
@return mixed
|
[
"Dynamically",
"retrieve",
"attributes",
"on",
"the",
"model",
"."
] |
0d857a1fa85a66dfe380ab153feaa3b167339822
|
https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Traits/Collection/Chaining.php#L14-L41
|
10,979
|
tunaqui-solutions/utils
|
src/Objects.php
|
Objects.attrToArray
|
public static function attrToArray($object){
if(is_array($object) || is_object($object)) {
$result = [];
foreach ($object as $key => $value) {
$result[$key] = self::attrToArray($value);
}
return $result;
}
return $object;
}
|
php
|
public static function attrToArray($object){
if(is_array($object) || is_object($object)) {
$result = [];
foreach ($object as $key => $value) {
$result[$key] = self::attrToArray($value);
}
return $result;
}
return $object;
}
|
[
"public",
"static",
"function",
"attrToArray",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
"||",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"object",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"self",
"::",
"attrToArray",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
Extract attributes object in array.
@param object|array $object
@return array
|
[
"Extract",
"attributes",
"object",
"in",
"array",
"."
] |
f332f606df2ca4aea17352082182a6b21e859e0f
|
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Objects.php#L27-L36
|
10,980
|
tunaqui-solutions/utils
|
src/Objects.php
|
Objects.fromArray
|
public static function fromArray(array $attributes) {
$object = new ArrayObject();
foreach ($attributes as $key => $val) {
$object[$key] = $val;
}
return $object;
}
|
php
|
public static function fromArray(array $attributes) {
$object = new ArrayObject();
foreach ($attributes as $key => $val) {
$object[$key] = $val;
}
return $object;
}
|
[
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"object",
"=",
"new",
"ArrayObject",
"(",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"object",
"[",
"$",
"key",
"]",
"=",
"$",
"val",
";",
"}",
"return",
"$",
"object",
";",
"}"
] |
Array attributes to object class ArrayObject.
@param array $attributes
@return ArrayObject
|
[
"Array",
"attributes",
"to",
"object",
"class",
"ArrayObject",
"."
] |
f332f606df2ca4aea17352082182a6b21e859e0f
|
https://github.com/tunaqui-solutions/utils/blob/f332f606df2ca4aea17352082182a6b21e859e0f/src/Objects.php#L43-L49
|
10,981
|
issei-m/sfDependencyInjectionPlugin
|
lib/config/sfEventDispatcherRetriever.class.php
|
sfEventDispatcherRetriever.retrieve
|
public static function retrieve($context)
{
if ($context instanceof sfContext || $context instanceof sfProjectConfiguration) {
return $context->getEventDispatcher();
} elseif (isset($GLOBALS['dispatcher'])) {
return $GLOBALS['dispatcher'];
}
$refClass = new ReflectionClass(get_class($context));
if ($refClass->hasProperty('dispatcher')) {
return self::retrieveByDispatcherProperty($refClass, $context);
} elseif ($refClass->hasProperty('configuration')) {
return self::retrieveByConfigurationProperty($refClass, $context);
}
}
|
php
|
public static function retrieve($context)
{
if ($context instanceof sfContext || $context instanceof sfProjectConfiguration) {
return $context->getEventDispatcher();
} elseif (isset($GLOBALS['dispatcher'])) {
return $GLOBALS['dispatcher'];
}
$refClass = new ReflectionClass(get_class($context));
if ($refClass->hasProperty('dispatcher')) {
return self::retrieveByDispatcherProperty($refClass, $context);
} elseif ($refClass->hasProperty('configuration')) {
return self::retrieveByConfigurationProperty($refClass, $context);
}
}
|
[
"public",
"static",
"function",
"retrieve",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"context",
"instanceof",
"sfContext",
"||",
"$",
"context",
"instanceof",
"sfProjectConfiguration",
")",
"{",
"return",
"$",
"context",
"->",
"getEventDispatcher",
"(",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'dispatcher'",
"]",
")",
")",
"{",
"return",
"$",
"GLOBALS",
"[",
"'dispatcher'",
"]",
";",
"}",
"$",
"refClass",
"=",
"new",
"ReflectionClass",
"(",
"get_class",
"(",
"$",
"context",
")",
")",
";",
"if",
"(",
"$",
"refClass",
"->",
"hasProperty",
"(",
"'dispatcher'",
")",
")",
"{",
"return",
"self",
"::",
"retrieveByDispatcherProperty",
"(",
"$",
"refClass",
",",
"$",
"context",
")",
";",
"}",
"elseif",
"(",
"$",
"refClass",
"->",
"hasProperty",
"(",
"'configuration'",
")",
")",
"{",
"return",
"self",
"::",
"retrieveByConfigurationProperty",
"(",
"$",
"refClass",
",",
"$",
"context",
")",
";",
"}",
"}"
] |
Returns the sfEventDispatcher instance.
@param mixed $context
@return sfEventDispatcher|null
|
[
"Returns",
"the",
"sfEventDispatcher",
"instance",
"."
] |
dc17326fc2f31716b50e124ebc453a09903031ef
|
https://github.com/issei-m/sfDependencyInjectionPlugin/blob/dc17326fc2f31716b50e124ebc453a09903031ef/lib/config/sfEventDispatcherRetriever.class.php#L30-L45
|
10,982
|
GustavSoftware/Utils
|
src/RequestData.php
|
RequestData.initialize
|
public static function initialize()
{
switch($_SERVER['REQUEST_METHOD']) {
case "POST":
self::$_method = self::POST;
break;
case "GET":
self::$_method = self::GET;
break;
case "PUT":
self::$_method = self::PUT;
break;
case "DELETE":
self::$_method = self::DELETE;
break;
default:
self::$_method = self::HEAD;
}
self::$_data = array();
self::_parseData($_GET);
self::_parseData($_POST);
if(
isset($_SERVER['HTTPS']) &&
$_SERVER['HTTPS'] !== null &&
$_SERVER['HTTPS'] !== "off"
) {
self::$_https = true;
} else {
self::$_https = false;
}
self::$_domain = (string) $_SERVER['HTTP_HOST'];
self::$_file = (string) $_SERVER['SCRIPT_FILENAME'];
if(isset($_SERVER['PATH_INFO'])) {
self::$_pathInfo = (string) $_SERVER['PATH_INFO'];
} else {
self::$_pathInfo = "";
}
}
|
php
|
public static function initialize()
{
switch($_SERVER['REQUEST_METHOD']) {
case "POST":
self::$_method = self::POST;
break;
case "GET":
self::$_method = self::GET;
break;
case "PUT":
self::$_method = self::PUT;
break;
case "DELETE":
self::$_method = self::DELETE;
break;
default:
self::$_method = self::HEAD;
}
self::$_data = array();
self::_parseData($_GET);
self::_parseData($_POST);
if(
isset($_SERVER['HTTPS']) &&
$_SERVER['HTTPS'] !== null &&
$_SERVER['HTTPS'] !== "off"
) {
self::$_https = true;
} else {
self::$_https = false;
}
self::$_domain = (string) $_SERVER['HTTP_HOST'];
self::$_file = (string) $_SERVER['SCRIPT_FILENAME'];
if(isset($_SERVER['PATH_INFO'])) {
self::$_pathInfo = (string) $_SERVER['PATH_INFO'];
} else {
self::$_pathInfo = "";
}
}
|
[
"public",
"static",
"function",
"initialize",
"(",
")",
"{",
"switch",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
"{",
"case",
"\"POST\"",
":",
"self",
"::",
"$",
"_method",
"=",
"self",
"::",
"POST",
";",
"break",
";",
"case",
"\"GET\"",
":",
"self",
"::",
"$",
"_method",
"=",
"self",
"::",
"GET",
";",
"break",
";",
"case",
"\"PUT\"",
":",
"self",
"::",
"$",
"_method",
"=",
"self",
"::",
"PUT",
";",
"break",
";",
"case",
"\"DELETE\"",
":",
"self",
"::",
"$",
"_method",
"=",
"self",
"::",
"DELETE",
";",
"break",
";",
"default",
":",
"self",
"::",
"$",
"_method",
"=",
"self",
"::",
"HEAD",
";",
"}",
"self",
"::",
"$",
"_data",
"=",
"array",
"(",
")",
";",
"self",
"::",
"_parseData",
"(",
"$",
"_GET",
")",
";",
"self",
"::",
"_parseData",
"(",
"$",
"_POST",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!==",
"null",
"&&",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
"!==",
"\"off\"",
")",
"{",
"self",
"::",
"$",
"_https",
"=",
"true",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"_https",
"=",
"false",
";",
"}",
"self",
"::",
"$",
"_domain",
"=",
"(",
"string",
")",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
";",
"self",
"::",
"$",
"_file",
"=",
"(",
"string",
")",
"$",
"_SERVER",
"[",
"'SCRIPT_FILENAME'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'PATH_INFO'",
"]",
")",
")",
"{",
"self",
"::",
"$",
"_pathInfo",
"=",
"(",
"string",
")",
"$",
"_SERVER",
"[",
"'PATH_INFO'",
"]",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"_pathInfo",
"=",
"\"\"",
";",
"}",
"}"
] |
Initializes this class. This means, the request and input data will be
loaded and parsed.
|
[
"Initializes",
"this",
"class",
".",
"This",
"means",
"the",
"request",
"and",
"input",
"data",
"will",
"be",
"loaded",
"and",
"parsed",
"."
] |
370131e9baf3477863123ca31972cbbfaaf2f39b
|
https://github.com/GustavSoftware/Utils/blob/370131e9baf3477863123ca31972cbbfaaf2f39b/src/RequestData.php#L99-L138
|
10,983
|
GustavSoftware/Utils
|
src/RequestData.php
|
RequestData._parseData
|
private static function _parseData(array $data)
{
foreach($data as $key => $value) {
self::$_data[\mb_strtolower($key)] = $value;
}
}
|
php
|
private static function _parseData(array $data)
{
foreach($data as $key => $value) {
self::$_data[\mb_strtolower($key)] = $value;
}
}
|
[
"private",
"static",
"function",
"_parseData",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"self",
"::",
"$",
"_data",
"[",
"\\",
"mb_strtolower",
"(",
"$",
"key",
")",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Adds the given array data to the input data.
@param array $data
The data to add
|
[
"Adds",
"the",
"given",
"array",
"data",
"to",
"the",
"input",
"data",
"."
] |
370131e9baf3477863123ca31972cbbfaaf2f39b
|
https://github.com/GustavSoftware/Utils/blob/370131e9baf3477863123ca31972cbbfaaf2f39b/src/RequestData.php#L146-L151
|
10,984
|
GustavSoftware/Utils
|
src/RequestData.php
|
RequestData.getValue
|
public static function getValue(string $key)
{
$key = \mb_strtolower($key);
if(isset(self::$_data[$key])) {
return self::$_data[$key];
}
return null;
}
|
php
|
public static function getValue(string $key)
{
$key = \mb_strtolower($key);
if(isset(self::$_data[$key])) {
return self::$_data[$key];
}
return null;
}
|
[
"public",
"static",
"function",
"getValue",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"\\",
"mb_strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_data",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"_data",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the value with the given key from input data.
@param string $key
The input key
@return mixed
The input value
|
[
"Returns",
"the",
"value",
"with",
"the",
"given",
"key",
"from",
"input",
"data",
"."
] |
370131e9baf3477863123ca31972cbbfaaf2f39b
|
https://github.com/GustavSoftware/Utils/blob/370131e9baf3477863123ca31972cbbfaaf2f39b/src/RequestData.php#L173-L180
|
10,985
|
GustavSoftware/Utils
|
src/RequestData.php
|
RequestData.issetValue
|
public static function issetValue(string $key): bool
{
$key = \mb_strtolower($key);
return isset(self::$_data[$key]);
}
|
php
|
public static function issetValue(string $key): bool
{
$key = \mb_strtolower($key);
return isset(self::$_data[$key]);
}
|
[
"public",
"static",
"function",
"issetValue",
"(",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"$",
"key",
"=",
"\\",
"mb_strtolower",
"(",
"$",
"key",
")",
";",
"return",
"isset",
"(",
"self",
"::",
"$",
"_data",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Checks whether a value t the given input key was set in the form.
@param string $key
The input key to check
@return boolean
true, if the value exists, otherwise, false
|
[
"Checks",
"whether",
"a",
"value",
"t",
"the",
"given",
"input",
"key",
"was",
"set",
"in",
"the",
"form",
"."
] |
370131e9baf3477863123ca31972cbbfaaf2f39b
|
https://github.com/GustavSoftware/Utils/blob/370131e9baf3477863123ca31972cbbfaaf2f39b/src/RequestData.php#L190-L194
|
10,986
|
DerekMarcinyshyn/monashee-backup
|
src/Monashee/Backup/Dump.php
|
Dump.backup
|
public function backup($databases)
{
foreach ($databases as $database)
{
echo "\n".'dumping '.$database.' database'."\n";
try {
system($this->command($database));
} catch (\Exception $e) {
$this->event->fire('MonasheeBackupError', $e->getMessage());
throw new \Exception('mysqldump error');
}
echo 'done.'."\n\n";
}
$this->event->fire('MonasheeBackupInfo', 'All databases done dumping.');
return true;
}
|
php
|
public function backup($databases)
{
foreach ($databases as $database)
{
echo "\n".'dumping '.$database.' database'."\n";
try {
system($this->command($database));
} catch (\Exception $e) {
$this->event->fire('MonasheeBackupError', $e->getMessage());
throw new \Exception('mysqldump error');
}
echo 'done.'."\n\n";
}
$this->event->fire('MonasheeBackupInfo', 'All databases done dumping.');
return true;
}
|
[
"public",
"function",
"backup",
"(",
"$",
"databases",
")",
"{",
"foreach",
"(",
"$",
"databases",
"as",
"$",
"database",
")",
"{",
"echo",
"\"\\n\"",
".",
"'dumping '",
".",
"$",
"database",
".",
"' database'",
".",
"\"\\n\"",
";",
"try",
"{",
"system",
"(",
"$",
"this",
"->",
"command",
"(",
"$",
"database",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"event",
"->",
"fire",
"(",
"'MonasheeBackupError'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"new",
"\\",
"Exception",
"(",
"'mysqldump error'",
")",
";",
"}",
"echo",
"'done.'",
".",
"\"\\n\\n\"",
";",
"}",
"$",
"this",
"->",
"event",
"->",
"fire",
"(",
"'MonasheeBackupInfo'",
",",
"'All databases done dumping.'",
")",
";",
"return",
"true",
";",
"}"
] |
Create backups and save to file
@param $databases
@return bool
@throws \Exception
|
[
"Create",
"backups",
"and",
"save",
"to",
"file"
] |
2f96f3ddbbdd1c672e0064bf3b66951f94975158
|
https://github.com/DerekMarcinyshyn/monashee-backup/blob/2f96f3ddbbdd1c672e0064bf3b66951f94975158/src/Monashee/Backup/Dump.php#L40-L59
|
10,987
|
Ara95/user
|
src/User/UserController.php
|
UserController.getPostEditUser
|
public function getPostEditUser()
{
$this->di->get("auth")->isLoggedIn();
$user = new User();
$user->setDb($this->di->get("db"));
$user->find("email", $this->di->get("session")->get("user"));
$title = "Redigera profil";
$card = "Redigera";
$view = $this->di->get("view");
$pageRender = $this->di->get("pageRender");
$form = new EditUserForm($this->di, $user->email);
$form->check();
$data = [
"form" => $form->getHTML(),
"card" => $card,
"title" => $title,
];
$view->add("user/edit", $data);
$pageRender->renderPage(["title" => $title]);
}
|
php
|
public function getPostEditUser()
{
$this->di->get("auth")->isLoggedIn();
$user = new User();
$user->setDb($this->di->get("db"));
$user->find("email", $this->di->get("session")->get("user"));
$title = "Redigera profil";
$card = "Redigera";
$view = $this->di->get("view");
$pageRender = $this->di->get("pageRender");
$form = new EditUserForm($this->di, $user->email);
$form->check();
$data = [
"form" => $form->getHTML(),
"card" => $card,
"title" => $title,
];
$view->add("user/edit", $data);
$pageRender->renderPage(["title" => $title]);
}
|
[
"public",
"function",
"getPostEditUser",
"(",
")",
"{",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"auth\"",
")",
"->",
"isLoggedIn",
"(",
")",
";",
"$",
"user",
"=",
"new",
"User",
"(",
")",
";",
"$",
"user",
"->",
"setDb",
"(",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"db\"",
")",
")",
";",
"$",
"user",
"->",
"find",
"(",
"\"email\"",
",",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"session\"",
")",
"->",
"get",
"(",
"\"user\"",
")",
")",
";",
"$",
"title",
"=",
"\"Redigera profil\"",
";",
"$",
"card",
"=",
"\"Redigera\"",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"view\"",
")",
";",
"$",
"pageRender",
"=",
"$",
"this",
"->",
"di",
"->",
"get",
"(",
"\"pageRender\"",
")",
";",
"$",
"form",
"=",
"new",
"EditUserForm",
"(",
"$",
"this",
"->",
"di",
",",
"$",
"user",
"->",
"email",
")",
";",
"$",
"form",
"->",
"check",
"(",
")",
";",
"$",
"data",
"=",
"[",
"\"form\"",
"=>",
"$",
"form",
"->",
"getHTML",
"(",
")",
",",
"\"card\"",
"=>",
"$",
"card",
",",
"\"title\"",
"=>",
"$",
"title",
",",
"]",
";",
"$",
"view",
"->",
"add",
"(",
"\"user/edit\"",
",",
"$",
"data",
")",
";",
"$",
"pageRender",
"->",
"renderPage",
"(",
"[",
"\"title\"",
"=>",
"$",
"title",
"]",
")",
";",
"}"
] |
Handler with form to update a user.
@return void
|
[
"Handler",
"with",
"form",
"to",
"update",
"a",
"user",
"."
] |
96e15a19906562a689abedf6bcf4818ad8437a3b
|
https://github.com/Ara95/user/blob/96e15a19906562a689abedf6bcf4818ad8437a3b/src/User/UserController.php#L131-L156
|
10,988
|
samurai-fw/samurai
|
src/Samurai/Component/Task/OptionParser.php
|
OptionParser.pickShortName
|
private function pickShortName($syntax)
{
$name = null;
if (preg_match('/,(\w+)=?/', $syntax, $matches)) {
$name = $matches[1];
}
return $name;
}
|
php
|
private function pickShortName($syntax)
{
$name = null;
if (preg_match('/,(\w+)=?/', $syntax, $matches)) {
$name = $matches[1];
}
return $name;
}
|
[
"private",
"function",
"pickShortName",
"(",
"$",
"syntax",
")",
"{",
"$",
"name",
"=",
"null",
";",
"if",
"(",
"preg_match",
"(",
"'/,(\\w+)=?/'",
",",
"$",
"syntax",
",",
"$",
"matches",
")",
")",
"{",
"$",
"name",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"name",
";",
"}"
] |
pick short name
@param string $syntax
@return string
|
[
"pick",
"short",
"name"
] |
7ca3847b13f86e2847a17ab5e8e4e20893021d5a
|
https://github.com/samurai-fw/samurai/blob/7ca3847b13f86e2847a17ab5e8e4e20893021d5a/src/Samurai/Component/Task/OptionParser.php#L115-L122
|
10,989
|
lucifurious/kisma
|
src/Kisma/Core/Utility/DateTime.php
|
DateTime.prettySeconds
|
public static function prettySeconds( $seconds = 0.0 )
{
$_remain = $seconds;
$_hours = floor( $_remain / Enums\DateTime::SecondsPerHour );
$_remain -= $_hours * Enums\DateTime::SecondsPerHour;
$_minutes = floor( $_remain / Enums\DateTime::SecondsPerMinute );
$_remain -= $_minutes * Enums\DateTime::SecondsPerMinute;
return $_hours . 'h ' . $_minutes . 'm ' . number_format( $_remain, 2 ) . 's';
}
|
php
|
public static function prettySeconds( $seconds = 0.0 )
{
$_remain = $seconds;
$_hours = floor( $_remain / Enums\DateTime::SecondsPerHour );
$_remain -= $_hours * Enums\DateTime::SecondsPerHour;
$_minutes = floor( $_remain / Enums\DateTime::SecondsPerMinute );
$_remain -= $_minutes * Enums\DateTime::SecondsPerMinute;
return $_hours . 'h ' . $_minutes . 'm ' . number_format( $_remain, 2 ) . 's';
}
|
[
"public",
"static",
"function",
"prettySeconds",
"(",
"$",
"seconds",
"=",
"0.0",
")",
"{",
"$",
"_remain",
"=",
"$",
"seconds",
";",
"$",
"_hours",
"=",
"floor",
"(",
"$",
"_remain",
"/",
"Enums",
"\\",
"DateTime",
"::",
"SecondsPerHour",
")",
";",
"$",
"_remain",
"-=",
"$",
"_hours",
"*",
"Enums",
"\\",
"DateTime",
"::",
"SecondsPerHour",
";",
"$",
"_minutes",
"=",
"floor",
"(",
"$",
"_remain",
"/",
"Enums",
"\\",
"DateTime",
"::",
"SecondsPerMinute",
")",
";",
"$",
"_remain",
"-=",
"$",
"_minutes",
"*",
"Enums",
"\\",
"DateTime",
"::",
"SecondsPerMinute",
";",
"return",
"$",
"_hours",
".",
"'h '",
".",
"$",
"_minutes",
".",
"'m '",
".",
"number_format",
"(",
"$",
"_remain",
",",
"2",
")",
".",
"'s'",
";",
"}"
] |
Coverts a number of seconds into a pretty string (i.e. 0d 0h 0m 0.00s
@param float $seconds
@return string
|
[
"Coverts",
"a",
"number",
"of",
"seconds",
"into",
"a",
"pretty",
"string",
"(",
"i",
".",
"e",
".",
"0d",
"0h",
"0m",
"0",
".",
"00s"
] |
4cc9954249da4e535b52f154e728935f07e648ae
|
https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/DateTime.php#L42-L52
|
10,990
|
roboapp/crud
|
src/BaseAction.php
|
BaseAction.getModel
|
public function getModel($id)
{
if (!is_array($id)) {
$id = [$id];
}
$model = call_user_func($this->findModel, $id);
if ($model === null) {
throw new NotFoundHttpException('The requested page does not exist.');
}
return $model;
}
|
php
|
public function getModel($id)
{
if (!is_array($id)) {
$id = [$id];
}
$model = call_user_func($this->findModel, $id);
if ($model === null) {
throw new NotFoundHttpException('The requested page does not exist.');
}
return $model;
}
|
[
"public",
"function",
"getModel",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"id",
")",
")",
"{",
"$",
"id",
"=",
"[",
"$",
"id",
"]",
";",
"}",
"$",
"model",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"findModel",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"model",
"===",
"null",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The requested page does not exist.'",
")",
";",
"}",
"return",
"$",
"model",
";",
"}"
] |
If the data model is not found, an exception is thrown HTTP 404
@param mixed $id
@return ActiveRecord
@throws NotFoundHttpException
|
[
"If",
"the",
"data",
"model",
"is",
"not",
"found",
"an",
"exception",
"is",
"thrown",
"HTTP",
"404"
] |
cda8ce1b8996157e08df949fcc83e314e25621f1
|
https://github.com/roboapp/crud/blob/cda8ce1b8996157e08df949fcc83e314e25621f1/src/BaseAction.php#L85-L97
|
10,991
|
roboapp/crud
|
src/BaseAction.php
|
BaseAction.redirect
|
public function redirect(ActiveRecord $model = null)
{
$route = $this->redirectTo;
$controller = $this->controller;
$request = Yii::$app->getRequest();
// if callable
if ($model && $route instanceof \Closure) {
$route = call_user_func($route, $model);
}
if ($route === null) {
return $request->getReferrer() ?
$controller->redirect($request->getReferrer()) : $controller->goHome();
}
return $controller->redirect($route);
}
|
php
|
public function redirect(ActiveRecord $model = null)
{
$route = $this->redirectTo;
$controller = $this->controller;
$request = Yii::$app->getRequest();
// if callable
if ($model && $route instanceof \Closure) {
$route = call_user_func($route, $model);
}
if ($route === null) {
return $request->getReferrer() ?
$controller->redirect($request->getReferrer()) : $controller->goHome();
}
return $controller->redirect($route);
}
|
[
"public",
"function",
"redirect",
"(",
"ActiveRecord",
"$",
"model",
"=",
"null",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"redirectTo",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"controller",
";",
"$",
"request",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
";",
"// if callable",
"if",
"(",
"$",
"model",
"&&",
"$",
"route",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"route",
"=",
"call_user_func",
"(",
"$",
"route",
",",
"$",
"model",
")",
";",
"}",
"if",
"(",
"$",
"route",
"===",
"null",
")",
"{",
"return",
"$",
"request",
"->",
"getReferrer",
"(",
")",
"?",
"$",
"controller",
"->",
"redirect",
"(",
"$",
"request",
"->",
"getReferrer",
"(",
")",
")",
":",
"$",
"controller",
"->",
"goHome",
"(",
")",
";",
"}",
"return",
"$",
"controller",
"->",
"redirect",
"(",
"$",
"route",
")",
";",
"}"
] |
Redirect to route passed as param
@param ActiveRecord $model
@return mixed
|
[
"Redirect",
"to",
"route",
"passed",
"as",
"param"
] |
cda8ce1b8996157e08df949fcc83e314e25621f1
|
https://github.com/roboapp/crud/blob/cda8ce1b8996157e08df949fcc83e314e25621f1/src/BaseAction.php#L105-L122
|
10,992
|
roboapp/crud
|
src/BaseAction.php
|
BaseAction.addSuccessFlash
|
public function addSuccessFlash()
{
if ($this->successMessage) {
/* @var Session $session */
$session = Instance::of($this->session)->get();
$session->addFlash('success', $this->successMessage);
}
}
|
php
|
public function addSuccessFlash()
{
if ($this->successMessage) {
/* @var Session $session */
$session = Instance::of($this->session)->get();
$session->addFlash('success', $this->successMessage);
}
}
|
[
"public",
"function",
"addSuccessFlash",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"successMessage",
")",
"{",
"/* @var Session $session */",
"$",
"session",
"=",
"Instance",
"::",
"of",
"(",
"$",
"this",
"->",
"session",
")",
"->",
"get",
"(",
")",
";",
"$",
"session",
"->",
"addFlash",
"(",
"'success'",
",",
"$",
"this",
"->",
"successMessage",
")",
";",
"}",
"}"
] |
Adds flash message about success completed operation.
|
[
"Adds",
"flash",
"message",
"about",
"success",
"completed",
"operation",
"."
] |
cda8ce1b8996157e08df949fcc83e314e25621f1
|
https://github.com/roboapp/crud/blob/cda8ce1b8996157e08df949fcc83e314e25621f1/src/BaseAction.php#L127-L134
|
10,993
|
roboapp/crud
|
src/BaseAction.php
|
BaseAction.addErrorFlash
|
public function addErrorFlash()
{
if ($this->errorMessage) {
/* @var Session $session */
$session = Instance::of($this->session)->get();
$session->addFlash('error', $this->errorMessage);
}
}
|
php
|
public function addErrorFlash()
{
if ($this->errorMessage) {
/* @var Session $session */
$session = Instance::of($this->session)->get();
$session->addFlash('error', $this->errorMessage);
}
}
|
[
"public",
"function",
"addErrorFlash",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"errorMessage",
")",
"{",
"/* @var Session $session */",
"$",
"session",
"=",
"Instance",
"::",
"of",
"(",
"$",
"this",
"->",
"session",
")",
"->",
"get",
"(",
")",
";",
"$",
"session",
"->",
"addFlash",
"(",
"'error'",
",",
"$",
"this",
"->",
"errorMessage",
")",
";",
"}",
"}"
] |
Adds flash message if completed operation with error.
|
[
"Adds",
"flash",
"message",
"if",
"completed",
"operation",
"with",
"error",
"."
] |
cda8ce1b8996157e08df949fcc83e314e25621f1
|
https://github.com/roboapp/crud/blob/cda8ce1b8996157e08df949fcc83e314e25621f1/src/BaseAction.php#L139-L146
|
10,994
|
agalbourdin/agl-core
|
src/Mysql/Query/Count.php
|
Count.commit
|
public function commit()
{
try {
if (empty($this->_fields)) {
$field = 'COUNT(1)';
} else {
$field = 'COUNT(';
if ($this->_fields[static::FIELD_DISTINCT]) {
$field .= 'DISTINCT(';
}
$field .= '`' . $this->_fields[static::FIELD_NAME] . '`';
if ($this->_fields[static::FIELD_DISTINCT]) {
$field .= ')';
}
$field = ')';
}
$query = "
SELECT
$field AS nb
FROM
`" . $this->getDbPrefix() . $this->_dbContainer . "`";
if ($this->_conditions->count()) {
$query .= "
WHERE
" . $this->_conditions->getPreparedConditions($this->_dbContainer) . "";
}
$prepared = Agl::app()->getDb()->getConnection()->prepare($query);
if ($prepared->execute($this->_conditions->getPreparedValues())) {
$result = $prepared->fetchObject();
if (! $result) {
throw new Exception("The count query failed (table '" . $this->getDbPrefix() . $this->_dbContainer . "')");
}
} else {
$error = $prepared->errorInfo();
throw new Exception("The count query failed (table '" . $this->getDbPrefix() . $this->_dbContainer . "') with message '" . $error[2] . "'");
}
if (Agl::app()->isDebugMode()) {
Agl::app()->getDb()->incrementCounter();
}
return (int)$result->{'nb'};
} catch (Exception $e) {
throw new Exception($e);
}
}
|
php
|
public function commit()
{
try {
if (empty($this->_fields)) {
$field = 'COUNT(1)';
} else {
$field = 'COUNT(';
if ($this->_fields[static::FIELD_DISTINCT]) {
$field .= 'DISTINCT(';
}
$field .= '`' . $this->_fields[static::FIELD_NAME] . '`';
if ($this->_fields[static::FIELD_DISTINCT]) {
$field .= ')';
}
$field = ')';
}
$query = "
SELECT
$field AS nb
FROM
`" . $this->getDbPrefix() . $this->_dbContainer . "`";
if ($this->_conditions->count()) {
$query .= "
WHERE
" . $this->_conditions->getPreparedConditions($this->_dbContainer) . "";
}
$prepared = Agl::app()->getDb()->getConnection()->prepare($query);
if ($prepared->execute($this->_conditions->getPreparedValues())) {
$result = $prepared->fetchObject();
if (! $result) {
throw new Exception("The count query failed (table '" . $this->getDbPrefix() . $this->_dbContainer . "')");
}
} else {
$error = $prepared->errorInfo();
throw new Exception("The count query failed (table '" . $this->getDbPrefix() . $this->_dbContainer . "') with message '" . $error[2] . "'");
}
if (Agl::app()->isDebugMode()) {
Agl::app()->getDb()->incrementCounter();
}
return (int)$result->{'nb'};
} catch (Exception $e) {
throw new Exception($e);
}
}
|
[
"public",
"function",
"commit",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_fields",
")",
")",
"{",
"$",
"field",
"=",
"'COUNT(1)'",
";",
"}",
"else",
"{",
"$",
"field",
"=",
"'COUNT('",
";",
"if",
"(",
"$",
"this",
"->",
"_fields",
"[",
"static",
"::",
"FIELD_DISTINCT",
"]",
")",
"{",
"$",
"field",
".=",
"'DISTINCT('",
";",
"}",
"$",
"field",
".=",
"'`'",
".",
"$",
"this",
"->",
"_fields",
"[",
"static",
"::",
"FIELD_NAME",
"]",
".",
"'`'",
";",
"if",
"(",
"$",
"this",
"->",
"_fields",
"[",
"static",
"::",
"FIELD_DISTINCT",
"]",
")",
"{",
"$",
"field",
".=",
"')'",
";",
"}",
"$",
"field",
"=",
"')'",
";",
"}",
"$",
"query",
"=",
"\"\n SELECT\n $field AS nb\n FROM\n `\"",
".",
"$",
"this",
"->",
"getDbPrefix",
"(",
")",
".",
"$",
"this",
"->",
"_dbContainer",
".",
"\"`\"",
";",
"if",
"(",
"$",
"this",
"->",
"_conditions",
"->",
"count",
"(",
")",
")",
"{",
"$",
"query",
".=",
"\"\n WHERE\n \"",
".",
"$",
"this",
"->",
"_conditions",
"->",
"getPreparedConditions",
"(",
"$",
"this",
"->",
"_dbContainer",
")",
".",
"\"\"",
";",
"}",
"$",
"prepared",
"=",
"Agl",
"::",
"app",
"(",
")",
"->",
"getDb",
"(",
")",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"prepared",
"->",
"execute",
"(",
"$",
"this",
"->",
"_conditions",
"->",
"getPreparedValues",
"(",
")",
")",
")",
"{",
"$",
"result",
"=",
"$",
"prepared",
"->",
"fetchObject",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The count query failed (table '\"",
".",
"$",
"this",
"->",
"getDbPrefix",
"(",
")",
".",
"$",
"this",
"->",
"_dbContainer",
".",
"\"')\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"error",
"=",
"$",
"prepared",
"->",
"errorInfo",
"(",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"The count query failed (table '\"",
".",
"$",
"this",
"->",
"getDbPrefix",
"(",
")",
".",
"$",
"this",
"->",
"_dbContainer",
".",
"\"') with message '\"",
".",
"$",
"error",
"[",
"2",
"]",
".",
"\"'\"",
")",
";",
"}",
"if",
"(",
"Agl",
"::",
"app",
"(",
")",
"->",
"isDebugMode",
"(",
")",
")",
"{",
"Agl",
"::",
"app",
"(",
")",
"->",
"getDb",
"(",
")",
"->",
"incrementCounter",
"(",
")",
";",
"}",
"return",
"(",
"int",
")",
"$",
"result",
"->",
"{",
"'nb'",
"}",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
Commit the count query to the database and return the result.
@return array
|
[
"Commit",
"the",
"count",
"query",
"to",
"the",
"database",
"and",
"return",
"the",
"result",
"."
] |
1db556f9a49488aa9fab6887fefb7141a79ad97d
|
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Query/Count.php#L26-L75
|
10,995
|
flowcode/AmulenShopBundle
|
src/Flowcode/ShopBundle/Controller/AdminServiceController.php
|
AdminServiceController.newAction
|
public function newAction()
{
$entity = new Service();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
}
|
php
|
public function newAction()
{
$entity = new Service();
$form = $this->createCreateForm($entity);
return array(
'entity' => $entity,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"entity",
"=",
"new",
"Service",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createCreateForm",
"(",
"$",
"entity",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Displays a form to create a new Service entity.
@Route("/new", name="admin_service_new")
@Method("GET")
@Template()
|
[
"Displays",
"a",
"form",
"to",
"create",
"a",
"new",
"Service",
"entity",
"."
] |
500aaf4364be3c42fca69ecd10a449da03993814
|
https://github.com/flowcode/AmulenShopBundle/blob/500aaf4364be3c42fca69ecd10a449da03993814/src/Flowcode/ShopBundle/Controller/AdminServiceController.php#L90-L99
|
10,996
|
ntentan/ajumamoro
|
src/brokers/RedisBroker.php
|
RedisBroker.get
|
public function get()
{
do {
$response = $this->redis->rpop("job_queue");
usleep(500);
} while ($response === null);
return unserialize($response);
}
|
php
|
public function get()
{
do {
$response = $this->redis->rpop("job_queue");
usleep(500);
} while ($response === null);
return unserialize($response);
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"do",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"redis",
"->",
"rpop",
"(",
"\"job_queue\"",
")",
";",
"usleep",
"(",
"500",
")",
";",
"}",
"while",
"(",
"$",
"response",
"===",
"null",
")",
";",
"return",
"unserialize",
"(",
"$",
"response",
")",
";",
"}"
] |
Get the next job on the job queue.
@return mixed Job
|
[
"Get",
"the",
"next",
"job",
"on",
"the",
"job",
"queue",
"."
] |
160c772c02e40e9656ab03acd1e9387aebce7219
|
https://github.com/ntentan/ajumamoro/blob/160c772c02e40e9656ab03acd1e9387aebce7219/src/brokers/RedisBroker.php#L41-L48
|
10,997
|
philelson/VagrantTransient
|
src/VagrantTransient.php
|
VagrantTransient.execute
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->before($input, $output);
$this->runTransient($input, $output);
$this->after($input, $output);
}
|
php
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->before($input, $output);
$this->runTransient($input, $output);
$this->after($input, $output);
}
|
[
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"before",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"this",
"->",
"runTransient",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"$",
"this",
"->",
"after",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}"
] |
This is the command which executes the application
@param InputInterface $input input interface for command
@param OutputInterface $output output interface for command
@return void
|
[
"This",
"is",
"the",
"command",
"which",
"executes",
"the",
"application"
] |
cd82523e175ee3786c1a262fb7e75c38f24c0eb1
|
https://github.com/philelson/VagrantTransient/blob/cd82523e175ee3786c1a262fb7e75c38f24c0eb1/src/VagrantTransient.php#L222-L227
|
10,998
|
philelson/VagrantTransient
|
src/VagrantTransient.php
|
VagrantTransient.loadEnvironments
|
protected function loadEnvironments()
{
$this->purge();
if (false == file_exists($this->getFileName())) {
touch($this->getFileName());
}
$tempEnvironments = file($this->getFileName());
foreach ($tempEnvironments as $key => $value) {
$value = trim($value);
if (null != $value && '' != $value && false == is_array($value)) {
if (true == $this->vagrentExists($value)) {
$this->_environments[] = $value;
}
}
}
return $this->_environments;
}
|
php
|
protected function loadEnvironments()
{
$this->purge();
if (false == file_exists($this->getFileName())) {
touch($this->getFileName());
}
$tempEnvironments = file($this->getFileName());
foreach ($tempEnvironments as $key => $value) {
$value = trim($value);
if (null != $value && '' != $value && false == is_array($value)) {
if (true == $this->vagrentExists($value)) {
$this->_environments[] = $value;
}
}
}
return $this->_environments;
}
|
[
"protected",
"function",
"loadEnvironments",
"(",
")",
"{",
"$",
"this",
"->",
"purge",
"(",
")",
";",
"if",
"(",
"false",
"==",
"file_exists",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
")",
"{",
"touch",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
";",
"}",
"$",
"tempEnvironments",
"=",
"file",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"tempEnvironments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"if",
"(",
"null",
"!=",
"$",
"value",
"&&",
"''",
"!=",
"$",
"value",
"&&",
"false",
"==",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"true",
"==",
"$",
"this",
"->",
"vagrentExists",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"_environments",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"_environments",
";",
"}"
] |
This method loads the _environments from disk into an array
@return array
|
[
"This",
"method",
"loads",
"the",
"_environments",
"from",
"disk",
"into",
"an",
"array"
] |
cd82523e175ee3786c1a262fb7e75c38f24c0eb1
|
https://github.com/philelson/VagrantTransient/blob/cd82523e175ee3786c1a262fb7e75c38f24c0eb1/src/VagrantTransient.php#L255-L271
|
10,999
|
philelson/VagrantTransient
|
src/VagrantTransient.php
|
VagrantTransient.save
|
public function save()
{
if (true == file_exists($this->getFileName())) {
unlink($this->getFileName());
}
touch($this->getFileName());
$content = "";
foreach ($this->getEnvironments() as $environment) {
$content .= "{$environment}\n";
}
file_put_contents($this->getFileName(), $content);
return $content;
}
|
php
|
public function save()
{
if (true == file_exists($this->getFileName())) {
unlink($this->getFileName());
}
touch($this->getFileName());
$content = "";
foreach ($this->getEnvironments() as $environment) {
$content .= "{$environment}\n";
}
file_put_contents($this->getFileName(), $content);
return $content;
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"true",
"==",
"file_exists",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
")",
"{",
"unlink",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
";",
"}",
"touch",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
")",
";",
"$",
"content",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"getEnvironments",
"(",
")",
"as",
"$",
"environment",
")",
"{",
"$",
"content",
".=",
"\"{$environment}\\n\"",
";",
"}",
"file_put_contents",
"(",
"$",
"this",
"->",
"getFileName",
"(",
")",
",",
"$",
"content",
")",
";",
"return",
"$",
"content",
";",
"}"
] |
This method iterates over the _environments writing them to disk.
@return string
|
[
"This",
"method",
"iterates",
"over",
"the",
"_environments",
"writing",
"them",
"to",
"disk",
"."
] |
cd82523e175ee3786c1a262fb7e75c38f24c0eb1
|
https://github.com/philelson/VagrantTransient/blob/cd82523e175ee3786c1a262fb7e75c38f24c0eb1/src/VagrantTransient.php#L278-L290
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.