repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
spatie/laravel-menu | src/Menu.php | Menu.urlIf | public function urlIf($condition, string $path, string $text, array $parameters = [], $secure = null)
{
return $this->addIf($condition, Link::toUrl($path, $text, $parameters, $secure));
} | php | public function urlIf($condition, string $path, string $text, array $parameters = [], $secure = null)
{
return $this->addIf($condition, Link::toUrl($path, $text, $parameters, $secure));
} | [
"public",
"function",
"urlIf",
"(",
"$",
"condition",
",",
"string",
"$",
"path",
",",
"string",
"$",
"text",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addIf",
"(",
"$",... | @param bool $condition
@param string $path
@param string $text
@param array $parameters
@param bool|null $secure
@return $this | [
"@param",
"bool",
"$condition",
"@param",
"string",
"$path",
"@param",
"string",
"$text",
"@param",
"array",
"$parameters",
"@param",
"bool|null",
"$secure"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L94-L97 |
spatie/laravel-menu | src/Menu.php | Menu.actionIf | public function actionIf($condition, $action, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIf($condition, Link::toAction($action, $text, $parameters, $absolute));
} | php | public function actionIf($condition, $action, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIf($condition, Link::toAction($action, $text, $parameters, $absolute));
} | [
"public",
"function",
"actionIf",
"(",
"$",
"condition",
",",
"$",
"action",
",",
"string",
"$",
"text",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"bool",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"addIf",
"(",
... | @param bool $condition
@param string|array $action
@param string $text
@param array $parameters
@param bool $absolute
@return $this | [
"@param",
"bool",
"$condition",
"@param",
"string|array",
"$action",
"@param",
"string",
"$text",
"@param",
"array",
"$parameters",
"@param",
"bool",
"$absolute"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L108-L111 |
spatie/laravel-menu | src/Menu.php | Menu.routeIf | public function routeIf($condition, string $name, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIf($condition, Link::toRoute($name, $text, $parameters, $absolute));
} | php | public function routeIf($condition, string $name, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIf($condition, Link::toRoute($name, $text, $parameters, $absolute));
} | [
"public",
"function",
"routeIf",
"(",
"$",
"condition",
",",
"string",
"$",
"name",
",",
"string",
"$",
"text",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"bool",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"addIf",... | @param bool $condition
@param string $name
@param string $text
@param array $parameters
@param bool $absolute
@return $this | [
"@param",
"bool",
"$condition",
"@param",
"string",
"$name",
"@param",
"string",
"$text",
"@param",
"array",
"$parameters",
"@param",
"bool",
"$absolute"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L122-L125 |
spatie/laravel-menu | src/Menu.php | Menu.viewIf | public function viewIf($condition, string $name, array $data = null)
{
return $this->addIf($condition, View::create($name, $data));
} | php | public function viewIf($condition, string $name, array $data = null)
{
return $this->addIf($condition, View::create($name, $data));
} | [
"public",
"function",
"viewIf",
"(",
"$",
"condition",
",",
"string",
"$",
"name",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addIf",
"(",
"$",
"condition",
",",
"View",
"::",
"create",
"(",
"$",
"name",
",",
"$... | @param $condition
@param string $name
@param array $data
@return $this | [
"@param",
"$condition",
"@param",
"string",
"$name",
"@param",
"array",
"$data"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L134-L137 |
spatie/laravel-menu | src/Menu.php | Menu.addIfCan | public function addIfCan($authorization, Item $item)
{
$ablityArguments = is_array($authorization) ? $authorization : [$authorization];
$ability = array_shift($ablityArguments);
return $this->addIf(app(Gate::class)->allows($ability, $ablityArguments), $item);
} | php | public function addIfCan($authorization, Item $item)
{
$ablityArguments = is_array($authorization) ? $authorization : [$authorization];
$ability = array_shift($ablityArguments);
return $this->addIf(app(Gate::class)->allows($ability, $ablityArguments), $item);
} | [
"public",
"function",
"addIfCan",
"(",
"$",
"authorization",
",",
"Item",
"$",
"item",
")",
"{",
"$",
"ablityArguments",
"=",
"is_array",
"(",
"$",
"authorization",
")",
"?",
"$",
"authorization",
":",
"[",
"$",
"authorization",
"]",
";",
"$",
"ability",
... | @param string|array $authorization
@param \Spatie\Menu\Item $item
@return $this | [
"@param",
"string|array",
"$authorization",
"@param",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Item",
"$item"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L145-L151 |
spatie/laravel-menu | src/Menu.php | Menu.linkIfCan | public function linkIfCan($authorization, string $url, string $text)
{
return $this->addIfCan($authorization, Link::to($url, $text));
} | php | public function linkIfCan($authorization, string $url, string $text)
{
return $this->addIfCan($authorization, Link::to($url, $text));
} | [
"public",
"function",
"linkIfCan",
"(",
"$",
"authorization",
",",
"string",
"$",
"url",
",",
"string",
"$",
"text",
")",
"{",
"return",
"$",
"this",
"->",
"addIfCan",
"(",
"$",
"authorization",
",",
"Link",
"::",
"to",
"(",
"$",
"url",
",",
"$",
"te... | @param string|array $authorization
@param string $url
@param string $text
@return $this | [
"@param",
"string|array",
"$authorization",
"@param",
"string",
"$url",
"@param",
"string",
"$text"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L160-L163 |
spatie/laravel-menu | src/Menu.php | Menu.htmlIfCan | public function htmlIfCan($authorization, string $html)
{
return $this->addIfCan($authorization, Html::raw($html));
} | php | public function htmlIfCan($authorization, string $html)
{
return $this->addIfCan($authorization, Html::raw($html));
} | [
"public",
"function",
"htmlIfCan",
"(",
"$",
"authorization",
",",
"string",
"$",
"html",
")",
"{",
"return",
"$",
"this",
"->",
"addIfCan",
"(",
"$",
"authorization",
",",
"Html",
"::",
"raw",
"(",
"$",
"html",
")",
")",
";",
"}"
] | @param string|array $authorization
@param string $html
@return \Spatie\Menu\Laravel\Menu | [
"@param",
"string|array",
"$authorization",
"@param",
"string",
"$html"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L171-L174 |
spatie/laravel-menu | src/Menu.php | Menu.submenuIfCan | public function submenuIfCan($authorization, $header, $menu = null)
{
list($authorization, $header, $menu) = $this->parseSubmenuIfCanArgs(...func_get_args());
$menu = $this->createSubmenuMenu($menu);
$header = $this->createSubmenuHeader($header);
return $this->addIfCan($authorization, $menu->prependIf($header, $header));
} | php | public function submenuIfCan($authorization, $header, $menu = null)
{
list($authorization, $header, $menu) = $this->parseSubmenuIfCanArgs(...func_get_args());
$menu = $this->createSubmenuMenu($menu);
$header = $this->createSubmenuHeader($header);
return $this->addIfCan($authorization, $menu->prependIf($header, $header));
} | [
"public",
"function",
"submenuIfCan",
"(",
"$",
"authorization",
",",
"$",
"header",
",",
"$",
"menu",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"authorization",
",",
"$",
"header",
",",
"$",
"menu",
")",
"=",
"$",
"this",
"->",
"parseSubmenuIfCanArgs",
... | @param string|array $authorization
@param callable|\Spatie\Menu\Menu|\Spatie\Menu\Item $header
@param callable|\Spatie\Menu\Menu|null $menu
@return $this | [
"@param",
"string|array",
"$authorization",
"@param",
"callable|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Item",
"$header",
"@param",
"callable|",
"\\",
"Spatie",
"\\",
"Menu",
"\\",
"Menu|null",
"$menu"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L183-L191 |
spatie/laravel-menu | src/Menu.php | Menu.urlIfCan | public function urlIfCan($authorization, string $path, string $text, array $parameters = [], $secure = null)
{
return $this->addIfCan($authorization, Link::toUrl($path, $text, $parameters, $secure));
} | php | public function urlIfCan($authorization, string $path, string $text, array $parameters = [], $secure = null)
{
return $this->addIfCan($authorization, Link::toUrl($path, $text, $parameters, $secure));
} | [
"public",
"function",
"urlIfCan",
"(",
"$",
"authorization",
",",
"string",
"$",
"path",
",",
"string",
"$",
"text",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addIfCan",
"... | @param string|array $authorization
@param string $path
@param string $text
@param array $parameters
@param bool|null $secure
@return $this | [
"@param",
"string|array",
"$authorization",
"@param",
"string",
"$path",
"@param",
"string",
"$text",
"@param",
"array",
"$parameters",
"@param",
"bool|null",
"$secure"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L207-L210 |
spatie/laravel-menu | src/Menu.php | Menu.actionIfCan | public function actionIfCan($authorization, $action, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIfCan($authorization, Link::toAction($action, $text, $parameters, $absolute));
} | php | public function actionIfCan($authorization, $action, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIfCan($authorization, Link::toAction($action, $text, $parameters, $absolute));
} | [
"public",
"function",
"actionIfCan",
"(",
"$",
"authorization",
",",
"$",
"action",
",",
"string",
"$",
"text",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"bool",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"addIfCan"... | @param string|array $authorization
@param string|array $action
@param string $text
@param array $parameters
@param bool $absolute
@return $this | [
"@param",
"string|array",
"$authorization",
"@param",
"string|array",
"$action",
"@param",
"string",
"$text",
"@param",
"array",
"$parameters",
"@param",
"bool",
"$absolute"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L221-L224 |
spatie/laravel-menu | src/Menu.php | Menu.routeIfCan | public function routeIfCan($authorization, string $name, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIfCan($authorization, Link::toRoute($name, $text, $parameters, $absolute));
} | php | public function routeIfCan($authorization, string $name, string $text, array $parameters = [], bool $absolute = true)
{
return $this->addIfCan($authorization, Link::toRoute($name, $text, $parameters, $absolute));
} | [
"public",
"function",
"routeIfCan",
"(",
"$",
"authorization",
",",
"string",
"$",
"name",
",",
"string",
"$",
"text",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"bool",
"$",
"absolute",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"... | @param string|array $authorization
@param string $name
@param string $text
@param array $parameters
@param bool $absolute
@return $this | [
"@param",
"string|array",
"$authorization",
"@param",
"string",
"$name",
"@param",
"string",
"$text",
"@param",
"array",
"$parameters",
"@param",
"bool",
"$absolute"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L235-L238 |
spatie/laravel-menu | src/Menu.php | Menu.viewIfCan | public function viewIfCan($authorization, string $name, array $data = null)
{
return $this->addIfCan($authorization, View::create($name, $data));
} | php | public function viewIfCan($authorization, string $name, array $data = null)
{
return $this->addIfCan($authorization, View::create($name, $data));
} | [
"public",
"function",
"viewIfCan",
"(",
"$",
"authorization",
",",
"string",
"$",
"name",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addIfCan",
"(",
"$",
"authorization",
",",
"View",
"::",
"create",
"(",
"$",
"name... | @param $authorization
@param string $name
@param array $data
@return $this
@internal param $condition | [
"@param",
"$authorization",
"@param",
"string",
"$name",
"@param",
"array",
"$data"
] | train | https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L248-L251 |
Yurunsoft/Guzzle-Swoole | src/Plugin/Plugin.php | Plugin.parseGuzzle | protected function parseGuzzle()
{
$filePath = dirname(__DIR__) . '/load.php';
$config = $this->composer->getConfig();
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
$autoloadFilesFile = $vendorPath.'/composer/autoload_files.php';
$files = include $autoloadFilesFile;
foreach($files as $fileName)
{
if($this->stringEndwith($fileName, '/guzzlehttp/guzzle/src/functions_include.php'))
{
$path = dirname($fileName) . '/functions.php';
include $path;
$refFunction = new \ReflectionFunction('GuzzleHttp\choose_handler');
$content = file_get_contents($path);
$eol = $this->getEOL($content);
$contents = explode($eol, $content);
for($i = $refFunction->getStartLine() - 1; $i < $refFunction->getEndLine(); ++$i)
{
unset($contents[$i]);
}
$content = implode($eol, $contents);
file_put_contents($filePath, $content);
break;
}
}
} | php | protected function parseGuzzle()
{
$filePath = dirname(__DIR__) . '/load.php';
$config = $this->composer->getConfig();
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
$autoloadFilesFile = $vendorPath.'/composer/autoload_files.php';
$files = include $autoloadFilesFile;
foreach($files as $fileName)
{
if($this->stringEndwith($fileName, '/guzzlehttp/guzzle/src/functions_include.php'))
{
$path = dirname($fileName) . '/functions.php';
include $path;
$refFunction = new \ReflectionFunction('GuzzleHttp\choose_handler');
$content = file_get_contents($path);
$eol = $this->getEOL($content);
$contents = explode($eol, $content);
for($i = $refFunction->getStartLine() - 1; $i < $refFunction->getEndLine(); ++$i)
{
unset($contents[$i]);
}
$content = implode($eol, $contents);
file_put_contents($filePath, $content);
break;
}
}
} | [
"protected",
"function",
"parseGuzzle",
"(",
")",
"{",
"$",
"filePath",
"=",
"dirname",
"(",
"__DIR__",
")",
".",
"'/load.php'",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"composer",
"->",
"getConfig",
"(",
")",
";",
"$",
"filesystem",
"=",
"new",
"F... | 处理Guzzle代码
@return void | [
"处理Guzzle代码"
] | train | https://github.com/Yurunsoft/Guzzle-Swoole/blob/f94ff71ed907212eb5faa5d93dc47a610bb3e735/src/Plugin/Plugin.php#L80-L111 |
Yurunsoft/Guzzle-Swoole | src/Plugin/Plugin.php | Plugin.appendIncludeFiles | protected function appendIncludeFiles()
{
$generator = new \ComposerIncludeFiles\Composer\AutoloadGenerator($this->composer->getEventDispatcher(), $this->io);
$config = $this->composer->getConfig();
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
$generator->dumpFiles($this->composer, [
$vendorPath . "/yurunsoft/guzzle-swoole/src/load.php",
$vendorPath . "/yurunsoft/guzzle-swoole/src/functions.php"
]);
} | php | protected function appendIncludeFiles()
{
$generator = new \ComposerIncludeFiles\Composer\AutoloadGenerator($this->composer->getEventDispatcher(), $this->io);
$config = $this->composer->getConfig();
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
$vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
$generator->dumpFiles($this->composer, [
$vendorPath . "/yurunsoft/guzzle-swoole/src/load.php",
$vendorPath . "/yurunsoft/guzzle-swoole/src/functions.php"
]);
} | [
"protected",
"function",
"appendIncludeFiles",
"(",
")",
"{",
"$",
"generator",
"=",
"new",
"\\",
"ComposerIncludeFiles",
"\\",
"Composer",
"\\",
"AutoloadGenerator",
"(",
"$",
"this",
"->",
"composer",
"->",
"getEventDispatcher",
"(",
")",
",",
"$",
"this",
"... | 追加 include 文件
@return void | [
"追加",
"include",
"文件"
] | train | https://github.com/Yurunsoft/Guzzle-Swoole/blob/f94ff71ed907212eb5faa5d93dc47a610bb3e735/src/Plugin/Plugin.php#L118-L131 |
Yurunsoft/Guzzle-Swoole | src/Plugin/Plugin.php | Plugin.getEOL | protected function getEOL($content)
{
static $eols = [
"\r\n",
"\n",
"\r",
];
foreach($eols as $eol)
{
if(strpos($content, $eol))
{
return $eol;
}
}
return PHP_EOL;
} | php | protected function getEOL($content)
{
static $eols = [
"\r\n",
"\n",
"\r",
];
foreach($eols as $eol)
{
if(strpos($content, $eol))
{
return $eol;
}
}
return PHP_EOL;
} | [
"protected",
"function",
"getEOL",
"(",
"$",
"content",
")",
"{",
"static",
"$",
"eols",
"=",
"[",
"\"\\r\\n\"",
",",
"\"\\n\"",
",",
"\"\\r\"",
",",
"]",
";",
"foreach",
"(",
"$",
"eols",
"as",
"$",
"eol",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
... | 获取换行符
@param string $content
@return string | [
"获取换行符"
] | train | https://github.com/Yurunsoft/Guzzle-Swoole/blob/f94ff71ed907212eb5faa5d93dc47a610bb3e735/src/Plugin/Plugin.php#L150-L165 |
Intervention/imagecache | src/Intervention/Image/ImageCacheController.php | ImageCacheController.getResponse | public function getResponse($template, $filename)
{
switch (strtolower($template)) {
case 'original':
return $this->getOriginal($filename);
case 'download':
return $this->getDownload($filename);
default:
return $this->getImage($template, $filename);
}
} | php | public function getResponse($template, $filename)
{
switch (strtolower($template)) {
case 'original':
return $this->getOriginal($filename);
case 'download':
return $this->getDownload($filename);
default:
return $this->getImage($template, $filename);
}
} | [
"public",
"function",
"getResponse",
"(",
"$",
"template",
",",
"$",
"filename",
")",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"template",
")",
")",
"{",
"case",
"'original'",
":",
"return",
"$",
"this",
"->",
"getOriginal",
"(",
"$",
"filename",
")",... | Get HTTP response of either original image file or
template applied file.
@param string $template
@param string $filename
@return Illuminate\Http\Response | [
"Get",
"HTTP",
"response",
"of",
"either",
"original",
"image",
"file",
"or",
"template",
"applied",
"file",
"."
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCacheController.php#L21-L33 |
Intervention/imagecache | src/Intervention/Image/ImageCacheController.php | ImageCacheController.getImage | public function getImage($template, $filename)
{
$template = $this->getTemplate($template);
$path = $this->getImagePath($filename);
// image manipulation based on callback
$manager = new ImageManager(Config::get('image'));
$content = $manager->cache(function ($image) use ($template, $path) {
if ($template instanceof Closure) {
// build from closure callback template
$template($image->make($path));
} else {
// build from filter template
$image->make($path)->filter($template);
}
}, config('imagecache.lifetime'));
return $this->buildResponse($content);
} | php | public function getImage($template, $filename)
{
$template = $this->getTemplate($template);
$path = $this->getImagePath($filename);
// image manipulation based on callback
$manager = new ImageManager(Config::get('image'));
$content = $manager->cache(function ($image) use ($template, $path) {
if ($template instanceof Closure) {
// build from closure callback template
$template($image->make($path));
} else {
// build from filter template
$image->make($path)->filter($template);
}
}, config('imagecache.lifetime'));
return $this->buildResponse($content);
} | [
"public",
"function",
"getImage",
"(",
"$",
"template",
",",
"$",
"filename",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"template",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getImagePath",
"(",
"$",
"filename",
... | Get HTTP response of template applied image file
@param string $template
@param string $filename
@return Illuminate\Http\Response | [
"Get",
"HTTP",
"response",
"of",
"template",
"applied",
"image",
"file"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCacheController.php#L42-L62 |
Intervention/imagecache | src/Intervention/Image/ImageCacheController.php | ImageCacheController.getOriginal | public function getOriginal($filename)
{
$path = $this->getImagePath($filename);
return $this->buildResponse(file_get_contents($path));
} | php | public function getOriginal($filename)
{
$path = $this->getImagePath($filename);
return $this->buildResponse(file_get_contents($path));
} | [
"public",
"function",
"getOriginal",
"(",
"$",
"filename",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getImagePath",
"(",
"$",
"filename",
")",
";",
"return",
"$",
"this",
"->",
"buildResponse",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
")",
... | Get HTTP response of original image file
@param string $filename
@return Illuminate\Http\Response | [
"Get",
"HTTP",
"response",
"of",
"original",
"image",
"file"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCacheController.php#L70-L75 |
Intervention/imagecache | src/Intervention/Image/ImageCacheController.php | ImageCacheController.getTemplate | protected function getTemplate($template)
{
$template = config("imagecache.templates.{$template}");
switch (true) {
// closure template found
case is_callable($template):
return $template;
// filter template found
case class_exists($template):
return new $template;
default:
// template not found
abort(404);
break;
}
} | php | protected function getTemplate($template)
{
$template = config("imagecache.templates.{$template}");
switch (true) {
// closure template found
case is_callable($template):
return $template;
// filter template found
case class_exists($template):
return new $template;
default:
// template not found
abort(404);
break;
}
} | [
"protected",
"function",
"getTemplate",
"(",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"config",
"(",
"\"imagecache.templates.{$template}\"",
")",
";",
"switch",
"(",
"true",
")",
"{",
"// closure template found",
"case",
"is_callable",
"(",
"$",
"template"... | Returns corresponding template object from given template name
@param string $template
@return mixed | [
"Returns",
"corresponding",
"template",
"object",
"from",
"given",
"template",
"name"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCacheController.php#L99-L117 |
Intervention/imagecache | src/Intervention/Image/ImageCacheController.php | ImageCacheController.getImagePath | protected function getImagePath($filename)
{
// find file
foreach (config('imagecache.paths') as $path) {
// don't allow '..' in filenames
$image_path = $path.'/'.str_replace('..', '', $filename);
if (file_exists($image_path) && is_file($image_path)) {
// file found
return $image_path;
}
}
// file not found
abort(404);
} | php | protected function getImagePath($filename)
{
// find file
foreach (config('imagecache.paths') as $path) {
// don't allow '..' in filenames
$image_path = $path.'/'.str_replace('..', '', $filename);
if (file_exists($image_path) && is_file($image_path)) {
// file found
return $image_path;
}
}
// file not found
abort(404);
} | [
"protected",
"function",
"getImagePath",
"(",
"$",
"filename",
")",
"{",
"// find file",
"foreach",
"(",
"config",
"(",
"'imagecache.paths'",
")",
"as",
"$",
"path",
")",
"{",
"// don't allow '..' in filenames",
"$",
"image_path",
"=",
"$",
"path",
".",
"'/'",
... | Returns full image path from given filename
@param string $filename
@return string | [
"Returns",
"full",
"image",
"path",
"from",
"given",
"filename"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCacheController.php#L125-L139 |
Intervention/imagecache | src/Intervention/Image/ImageCacheController.php | ImageCacheController.buildResponse | protected function buildResponse($content)
{
// define mime type
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
// respond with 304 not modified if browser has the image cached
$etag = md5($content);
$not_modified = isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag;
$content = $not_modified ? NULL : $content;
$status_code = $not_modified ? 304 : 200;
// return http response
return new IlluminateResponse($content, $status_code, array(
'Content-Type' => $mime,
'Cache-Control' => 'max-age='.(config('imagecache.lifetime')*60).', public',
'Content-Length' => strlen($content),
'Etag' => $etag
));
} | php | protected function buildResponse($content)
{
// define mime type
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
// respond with 304 not modified if browser has the image cached
$etag = md5($content);
$not_modified = isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag;
$content = $not_modified ? NULL : $content;
$status_code = $not_modified ? 304 : 200;
// return http response
return new IlluminateResponse($content, $status_code, array(
'Content-Type' => $mime,
'Cache-Control' => 'max-age='.(config('imagecache.lifetime')*60).', public',
'Content-Length' => strlen($content),
'Etag' => $etag
));
} | [
"protected",
"function",
"buildResponse",
"(",
"$",
"content",
")",
"{",
"// define mime type",
"$",
"mime",
"=",
"finfo_buffer",
"(",
"finfo_open",
"(",
"FILEINFO_MIME_TYPE",
")",
",",
"$",
"content",
")",
";",
"// respond with 304 not modified if browser has the image... | Builds HTTP response from given image data
@param string $content
@return Illuminate\Http\Response | [
"Builds",
"HTTP",
"response",
"from",
"given",
"image",
"data"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCacheController.php#L147-L165 |
Intervention/imagecache | src/Intervention/Image/ImageCache.php | ImageCache.isFile | protected function isFile($value)
{
$value = strval(str_replace("\0", "", $value));
return strlen($value) <= PHP_MAXPATHLEN && is_file($value);
} | php | protected function isFile($value)
{
$value = strval(str_replace("\0", "", $value));
return strlen($value) <= PHP_MAXPATHLEN && is_file($value);
} | [
"protected",
"function",
"isFile",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strval",
"(",
"str_replace",
"(",
"\"\\0\"",
",",
"\"\"",
",",
"$",
"value",
")",
")",
";",
"return",
"strlen",
"(",
"$",
"value",
")",
"<=",
"PHP_MAXPATHLEN",
"&&",
... | Checks if given data is file, handles mixed input
@param mixed $value
@return boolean | [
"Checks",
"if",
"given",
"data",
"is",
"file",
"handles",
"mixed",
"input"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCache.php#L136-L141 |
Intervention/imagecache | src/Intervention/Image/ImageCache.php | ImageCache.checksum | public function checksum()
{
$properties = serialize($this->properties);
$calls = serialize($this->getSanitizedCalls());
return md5($properties.$calls);
} | php | public function checksum()
{
$properties = serialize($this->properties);
$calls = serialize($this->getSanitizedCalls());
return md5($properties.$calls);
} | [
"public",
"function",
"checksum",
"(",
")",
"{",
"$",
"properties",
"=",
"serialize",
"(",
"$",
"this",
"->",
"properties",
")",
";",
"$",
"calls",
"=",
"serialize",
"(",
"$",
"this",
"->",
"getSanitizedCalls",
"(",
")",
")",
";",
"return",
"md5",
"(",... | Returns checksum of current image state
@return string | [
"Returns",
"checksum",
"of",
"current",
"image",
"state"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCache.php#L162-L168 |
Intervention/imagecache | src/Intervention/Image/ImageCache.php | ImageCache.getSanitizedCalls | protected function getSanitizedCalls()
{
$calls = $this->getCalls();
foreach ($calls as $i => $call) {
foreach ($call['arguments'] as $j => $argument) {
if (is_a($argument, 'Closure')) {
$calls[$i]['arguments'][$j] = $this->buildSerializableClosure($argument);
}
}
}
return $calls;
} | php | protected function getSanitizedCalls()
{
$calls = $this->getCalls();
foreach ($calls as $i => $call) {
foreach ($call['arguments'] as $j => $argument) {
if (is_a($argument, 'Closure')) {
$calls[$i]['arguments'][$j] = $this->buildSerializableClosure($argument);
}
}
}
return $calls;
} | [
"protected",
"function",
"getSanitizedCalls",
"(",
")",
"{",
"$",
"calls",
"=",
"$",
"this",
"->",
"getCalls",
"(",
")",
";",
"foreach",
"(",
"$",
"calls",
"as",
"$",
"i",
"=>",
"$",
"call",
")",
"{",
"foreach",
"(",
"$",
"call",
"[",
"'arguments'",
... | Replace Closures in arguments with SerializableClosure
@return array | [
"Replace",
"Closures",
"in",
"arguments",
"with",
"SerializableClosure"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCache.php#L217-L230 |
Intervention/imagecache | src/Intervention/Image/ImageCache.php | ImageCache.buildSerializableClosure | protected function buildSerializableClosure(\Closure $closure)
{
switch (true) {
case class_exists('SuperClosure\\SerializableClosure'):
return new \SuperClosure\SerializableClosure($closure);
default:
return new \Jeremeamia\SuperClosure\SerializableClosure($closure);
}
} | php | protected function buildSerializableClosure(\Closure $closure)
{
switch (true) {
case class_exists('SuperClosure\\SerializableClosure'):
return new \SuperClosure\SerializableClosure($closure);
default:
return new \Jeremeamia\SuperClosure\SerializableClosure($closure);
}
} | [
"protected",
"function",
"buildSerializableClosure",
"(",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"class_exists",
"(",
"'SuperClosure\\\\SerializableClosure'",
")",
":",
"return",
"new",
"\\",
"SuperClosure",
"\\",
"Seri... | Build SerializableClosure from Closure
@param Closure $closure
@return Jeremeamia\SuperClosure\SerializableClosure|SuperClosure\SerializableClosure | [
"Build",
"SerializableClosure",
"from",
"Closure"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCache.php#L238-L247 |
Intervention/imagecache | src/Intervention/Image/ImageCache.php | ImageCache.process | public function process()
{
// first call on manager
$this->image = $this->manager;
// process calls on image
foreach ($this->getCalls() as $call) {
$this->processCall($call);
}
// append checksum to image
$this->image->cachekey = $this->checksum();
// clean-up
$this->clearCalls();
$this->clearProperties();
return $this->image;
} | php | public function process()
{
// first call on manager
$this->image = $this->manager;
// process calls on image
foreach ($this->getCalls() as $call) {
$this->processCall($call);
}
// append checksum to image
$this->image->cachekey = $this->checksum();
// clean-up
$this->clearCalls();
$this->clearProperties();
return $this->image;
} | [
"public",
"function",
"process",
"(",
")",
"{",
"// first call on manager",
"$",
"this",
"->",
"image",
"=",
"$",
"this",
"->",
"manager",
";",
"// process calls on image",
"foreach",
"(",
"$",
"this",
"->",
"getCalls",
"(",
")",
"as",
"$",
"call",
")",
"{... | Process all saved image calls on Image object
@return Intervention\Image\Image | [
"Process",
"all",
"saved",
"image",
"calls",
"on",
"Image",
"object"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCache.php#L265-L283 |
Intervention/imagecache | src/Intervention/Image/ImageCache.php | ImageCache.get | public function get($lifetime = null, $returnObj = false)
{
$lifetime = is_null($lifetime) ? $this->lifetime : intval($lifetime);
$key = $this->checksum();
// try to get image from cache
$cachedImageData = $this->cache->get($key);
// if imagedata exists in cache
if ($cachedImageData) {
// transform into image-object
if ($returnObj) {
$image = $this->manager->make($cachedImageData);
$cachedImage = new CachedImage;
return $cachedImage->setFromOriginal($image, $key);
}
// return raw data
return $cachedImageData;
} else {
// process image data
$image = $this->process();
// encode image data only if image is not encoded yet
$encoded = $image->encoded ? $image->encoded : (string) $image->encode();
// save to cache...
$this->cache->put($key, $encoded, Carbon::now()->addMinutes($lifetime));
// return processed image
return $returnObj ? $image : $encoded;
}
} | php | public function get($lifetime = null, $returnObj = false)
{
$lifetime = is_null($lifetime) ? $this->lifetime : intval($lifetime);
$key = $this->checksum();
// try to get image from cache
$cachedImageData = $this->cache->get($key);
// if imagedata exists in cache
if ($cachedImageData) {
// transform into image-object
if ($returnObj) {
$image = $this->manager->make($cachedImageData);
$cachedImage = new CachedImage;
return $cachedImage->setFromOriginal($image, $key);
}
// return raw data
return $cachedImageData;
} else {
// process image data
$image = $this->process();
// encode image data only if image is not encoded yet
$encoded = $image->encoded ? $image->encoded : (string) $image->encode();
// save to cache...
$this->cache->put($key, $encoded, Carbon::now()->addMinutes($lifetime));
// return processed image
return $returnObj ? $image : $encoded;
}
} | [
"public",
"function",
"get",
"(",
"$",
"lifetime",
"=",
"null",
",",
"$",
"returnObj",
"=",
"false",
")",
"{",
"$",
"lifetime",
"=",
"is_null",
"(",
"$",
"lifetime",
")",
"?",
"$",
"this",
"->",
"lifetime",
":",
"intval",
"(",
"$",
"lifetime",
")",
... | Get image either from cache or directly processed
and save image in cache if it's not saved yet
@param int $lifetime
@param bool $returnObj
@return mixed | [
"Get",
"image",
"either",
"from",
"cache",
"or",
"directly",
"processed",
"and",
"save",
"image",
"in",
"cache",
"if",
"it",
"s",
"not",
"saved",
"yet"
] | train | https://github.com/Intervention/imagecache/blob/fce486614cb67584637a383c1d09be893f1e6076/src/Intervention/Image/ImageCache.php#L293-L329 |
symfony/security-acl | Util/ClassUtils.php | ClassUtils.getRealClass | public static function getRealClass($object)
{
$class = is_object($object) ? get_class($object) : $object;
if (class_exists('Doctrine\Common\Util\ClassUtils')) {
return DoctrineClassUtils::getRealClass($class);
}
// fallback in case doctrine common is not installed
if (false === $pos = strrpos($class, '\\'.self::MARKER.'\\')) {
return $class;
}
return substr($class, $pos + self::MARKER_LENGTH + 2);
} | php | public static function getRealClass($object)
{
$class = is_object($object) ? get_class($object) : $object;
if (class_exists('Doctrine\Common\Util\ClassUtils')) {
return DoctrineClassUtils::getRealClass($class);
}
// fallback in case doctrine common is not installed
if (false === $pos = strrpos($class, '\\'.self::MARKER.'\\')) {
return $class;
}
return substr($class, $pos + self::MARKER_LENGTH + 2);
} | [
"public",
"static",
"function",
"getRealClass",
"(",
"$",
"object",
")",
"{",
"$",
"class",
"=",
"is_object",
"(",
"$",
"object",
")",
"?",
"get_class",
"(",
"$",
"object",
")",
":",
"$",
"object",
";",
"if",
"(",
"class_exists",
"(",
"'Doctrine\\Common\... | Gets the real class name of a class name that could be a proxy.
@param string|object $object
@return string | [
"Gets",
"the",
"real",
"class",
"name",
"of",
"a",
"class",
"name",
"that",
"could",
"be",
"a",
"proxy",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Util/ClassUtils.php#L55-L69 |
symfony/security-acl | Domain/PermissionGrantingStrategy.php | PermissionGrantingStrategy.isGranted | public function isGranted(AclInterface $acl, array $masks, array $sids, $administrativeMode = false)
{
try {
try {
$aces = $acl->getObjectAces();
if (!$aces) {
throw new NoAceFoundException();
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
} catch (NoAceFoundException $e) {
$aces = $acl->getClassAces();
if (!$aces) {
throw $e;
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
}
} catch (NoAceFoundException $e) {
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
return $parentAcl->isGranted($masks, $sids, $administrativeMode);
}
throw $e;
}
} | php | public function isGranted(AclInterface $acl, array $masks, array $sids, $administrativeMode = false)
{
try {
try {
$aces = $acl->getObjectAces();
if (!$aces) {
throw new NoAceFoundException();
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
} catch (NoAceFoundException $e) {
$aces = $acl->getClassAces();
if (!$aces) {
throw $e;
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
}
} catch (NoAceFoundException $e) {
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
return $parentAcl->isGranted($masks, $sids, $administrativeMode);
}
throw $e;
}
} | [
"public",
"function",
"isGranted",
"(",
"AclInterface",
"$",
"acl",
",",
"array",
"$",
"masks",
",",
"array",
"$",
"sids",
",",
"$",
"administrativeMode",
"=",
"false",
")",
"{",
"try",
"{",
"try",
"{",
"$",
"aces",
"=",
"$",
"acl",
"->",
"getObjectAce... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/PermissionGrantingStrategy.php#L47-L74 |
symfony/security-acl | Domain/PermissionGrantingStrategy.php | PermissionGrantingStrategy.isFieldGranted | public function isFieldGranted(AclInterface $acl, $field, array $masks, array $sids, $administrativeMode = false)
{
try {
try {
$aces = $acl->getObjectFieldAces($field);
if (!$aces) {
throw new NoAceFoundException();
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
} catch (NoAceFoundException $e) {
$aces = $acl->getClassFieldAces($field);
if (!$aces) {
throw $e;
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
}
} catch (NoAceFoundException $e) {
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode);
}
throw $e;
}
} | php | public function isFieldGranted(AclInterface $acl, $field, array $masks, array $sids, $administrativeMode = false)
{
try {
try {
$aces = $acl->getObjectFieldAces($field);
if (!$aces) {
throw new NoAceFoundException();
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
} catch (NoAceFoundException $e) {
$aces = $acl->getClassFieldAces($field);
if (!$aces) {
throw $e;
}
return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
}
} catch (NoAceFoundException $e) {
if ($acl->isEntriesInheriting() && null !== $parentAcl = $acl->getParentAcl()) {
return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode);
}
throw $e;
}
} | [
"public",
"function",
"isFieldGranted",
"(",
"AclInterface",
"$",
"acl",
",",
"$",
"field",
",",
"array",
"$",
"masks",
",",
"array",
"$",
"sids",
",",
"$",
"administrativeMode",
"=",
"false",
")",
"{",
"try",
"{",
"try",
"{",
"$",
"aces",
"=",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/PermissionGrantingStrategy.php#L79-L104 |
symfony/security-acl | Domain/PermissionGrantingStrategy.php | PermissionGrantingStrategy.hasSufficientPermissions | private function hasSufficientPermissions(AclInterface $acl, array $aces, array $masks, array $sids, $administrativeMode)
{
$firstRejectedAce = null;
foreach ($masks as $requiredMask) {
foreach ($sids as $sid) {
foreach ($aces as $ace) {
if ($sid->equals($ace->getSecurityIdentity()) && $this->isAceApplicable($requiredMask, $ace)) {
if ($ace->isGranting()) {
if (!$administrativeMode && null !== $this->auditLogger) {
$this->auditLogger->logIfNeeded(true, $ace);
}
return true;
}
if (null === $firstRejectedAce) {
$firstRejectedAce = $ace;
}
break 2;
}
}
}
}
if (null !== $firstRejectedAce) {
if (!$administrativeMode && null !== $this->auditLogger) {
$this->auditLogger->logIfNeeded(false, $firstRejectedAce);
}
return false;
}
throw new NoAceFoundException();
} | php | private function hasSufficientPermissions(AclInterface $acl, array $aces, array $masks, array $sids, $administrativeMode)
{
$firstRejectedAce = null;
foreach ($masks as $requiredMask) {
foreach ($sids as $sid) {
foreach ($aces as $ace) {
if ($sid->equals($ace->getSecurityIdentity()) && $this->isAceApplicable($requiredMask, $ace)) {
if ($ace->isGranting()) {
if (!$administrativeMode && null !== $this->auditLogger) {
$this->auditLogger->logIfNeeded(true, $ace);
}
return true;
}
if (null === $firstRejectedAce) {
$firstRejectedAce = $ace;
}
break 2;
}
}
}
}
if (null !== $firstRejectedAce) {
if (!$administrativeMode && null !== $this->auditLogger) {
$this->auditLogger->logIfNeeded(false, $firstRejectedAce);
}
return false;
}
throw new NoAceFoundException();
} | [
"private",
"function",
"hasSufficientPermissions",
"(",
"AclInterface",
"$",
"acl",
",",
"array",
"$",
"aces",
",",
"array",
"$",
"masks",
",",
"array",
"$",
"sids",
",",
"$",
"administrativeMode",
")",
"{",
"$",
"firstRejectedAce",
"=",
"null",
";",
"foreac... | Makes an authorization decision.
The order of ACEs, and SIDs is significant; the order of permission masks
not so much. It is important to note that the more specific security
identities should be at the beginning of the SIDs array in order for this
strategy to produce intuitive authorization decisions.
First, we will iterate over permissions, then over security identities.
For each combination of permission, and identity we will test the
available ACEs until we find one which is applicable.
The first applicable ACE will make the ultimate decision for the
permission/identity combination. If it is granting, this method will return
true, if it is denying, the method will continue to check the next
permission/identity combination.
This process is repeated until either a granting ACE is found, or no
permission/identity combinations are left. Finally, we will either throw
an NoAceFoundException, or deny access.
@param AclInterface $acl
@param EntryInterface[] $aces An array of ACE to check against
@param array $masks An array of permission masks
@param SecurityIdentityInterface[] $sids An array of SecurityIdentityInterface implementations
@param bool $administrativeMode True turns off audit logging
@return bool true, or false; either granting, or denying access respectively.
@throws NoAceFoundException | [
"Makes",
"an",
"authorization",
"decision",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/PermissionGrantingStrategy.php#L137-L172 |
symfony/security-acl | Domain/PermissionGrantingStrategy.php | PermissionGrantingStrategy.isAceApplicable | private function isAceApplicable($requiredMask, EntryInterface $ace)
{
$strategy = $ace->getStrategy();
if (self::ALL === $strategy) {
return $requiredMask === ($ace->getMask() & $requiredMask);
} elseif (self::ANY === $strategy) {
return 0 !== ($ace->getMask() & $requiredMask);
} elseif (self::EQUAL === $strategy) {
return $requiredMask === $ace->getMask();
}
throw new \RuntimeException(sprintf('The strategy "%s" is not supported.', $strategy));
} | php | private function isAceApplicable($requiredMask, EntryInterface $ace)
{
$strategy = $ace->getStrategy();
if (self::ALL === $strategy) {
return $requiredMask === ($ace->getMask() & $requiredMask);
} elseif (self::ANY === $strategy) {
return 0 !== ($ace->getMask() & $requiredMask);
} elseif (self::EQUAL === $strategy) {
return $requiredMask === $ace->getMask();
}
throw new \RuntimeException(sprintf('The strategy "%s" is not supported.', $strategy));
} | [
"private",
"function",
"isAceApplicable",
"(",
"$",
"requiredMask",
",",
"EntryInterface",
"$",
"ace",
")",
"{",
"$",
"strategy",
"=",
"$",
"ace",
"->",
"getStrategy",
"(",
")",
";",
"if",
"(",
"self",
"::",
"ALL",
"===",
"$",
"strategy",
")",
"{",
"re... | Determines whether the ACE is applicable to the given permission/security
identity combination.
Per default, we support three different comparison strategies.
Strategy ALL:
The ACE will be considered applicable when all the turned-on bits in the
required mask are also turned-on in the ACE mask.
Strategy ANY:
The ACE will be considered applicable when any of the turned-on bits in
the required mask is also turned-on the in the ACE mask.
Strategy EQUAL:
The ACE will be considered applicable when the bitmasks are equal.
@param int $requiredMask
@param EntryInterface $ace
@return bool
@throws \RuntimeException if the ACE strategy is not supported | [
"Determines",
"whether",
"the",
"ACE",
"is",
"applicable",
"to",
"the",
"given",
"permission",
"/",
"security",
"identity",
"combination",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/PermissionGrantingStrategy.php#L198-L210 |
symfony/security-acl | Domain/SecurityIdentityRetrievalStrategy.php | SecurityIdentityRetrievalStrategy.getSecurityIdentities | public function getSecurityIdentities(TokenInterface $token)
{
$sids = array();
// add user security identity
if (!$token instanceof AnonymousToken) {
try {
$sids[] = UserSecurityIdentity::fromToken($token);
} catch (\InvalidArgumentException $e) {
// ignore, user has no user security identity
}
}
// add all reachable roles
foreach ($this->roleHierarchy->getReachableRoles($token->getRoles()) as $role) {
$sids[] = new RoleSecurityIdentity($role);
}
// add built-in special roles
if ($this->authenticationTrustResolver->isFullFledged($token)) {
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_FULLY);
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
} elseif ($this->authenticationTrustResolver->isRememberMe($token)) {
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
} elseif ($this->authenticationTrustResolver->isAnonymous($token)) {
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
}
return $sids;
} | php | public function getSecurityIdentities(TokenInterface $token)
{
$sids = array();
// add user security identity
if (!$token instanceof AnonymousToken) {
try {
$sids[] = UserSecurityIdentity::fromToken($token);
} catch (\InvalidArgumentException $e) {
// ignore, user has no user security identity
}
}
// add all reachable roles
foreach ($this->roleHierarchy->getReachableRoles($token->getRoles()) as $role) {
$sids[] = new RoleSecurityIdentity($role);
}
// add built-in special roles
if ($this->authenticationTrustResolver->isFullFledged($token)) {
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_FULLY);
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
} elseif ($this->authenticationTrustResolver->isRememberMe($token)) {
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
} elseif ($this->authenticationTrustResolver->isAnonymous($token)) {
$sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
}
return $sids;
} | [
"public",
"function",
"getSecurityIdentities",
"(",
"TokenInterface",
"$",
"token",
")",
"{",
"$",
"sids",
"=",
"array",
"(",
")",
";",
"// add user security identity",
"if",
"(",
"!",
"$",
"token",
"instanceof",
"AnonymousToken",
")",
"{",
"try",
"{",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/SecurityIdentityRetrievalStrategy.php#L46-L77 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.createAcl | public function createAcl(ObjectIdentityInterface $oid)
{
if (false !== $this->retrieveObjectIdentityPrimaryKey($oid)) {
$objectName = method_exists($oid, '__toString') ? $oid : get_class($oid);
throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $objectName));
}
$this->connection->beginTransaction();
try {
$this->createObjectIdentity($oid);
$pk = $this->retrieveObjectIdentityPrimaryKey($oid);
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollBack();
throw $e;
}
// re-read the ACL from the database to ensure proper caching, etc.
return $this->findAcl($oid);
} | php | public function createAcl(ObjectIdentityInterface $oid)
{
if (false !== $this->retrieveObjectIdentityPrimaryKey($oid)) {
$objectName = method_exists($oid, '__toString') ? $oid : get_class($oid);
throw new AclAlreadyExistsException(sprintf('%s is already associated with an ACL.', $objectName));
}
$this->connection->beginTransaction();
try {
$this->createObjectIdentity($oid);
$pk = $this->retrieveObjectIdentityPrimaryKey($oid);
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollBack();
throw $e;
}
// re-read the ACL from the database to ensure proper caching, etc.
return $this->findAcl($oid);
} | [
"public",
"function",
"createAcl",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"this",
"->",
"retrieveObjectIdentityPrimaryKey",
"(",
"$",
"oid",
")",
")",
"{",
"$",
"objectName",
"=",
"method_exists",
"(",
"$",
"oid... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L51-L74 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.deleteAcl | public function deleteAcl(ObjectIdentityInterface $oid)
{
$this->connection->beginTransaction();
try {
foreach ($this->findChildren($oid, true) as $childOid) {
$this->deleteAcl($childOid);
}
$oidPK = $this->retrieveObjectIdentityPrimaryKey($oid);
$this->deleteAccessControlEntries($oidPK);
$this->deleteObjectIdentityRelations($oidPK);
$this->deleteObjectIdentity($oidPK);
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollBack();
throw $e;
}
// evict the ACL from the in-memory identity map
if (isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) {
$this->propertyChanges->offsetUnset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()]);
unset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()]);
}
// evict the ACL from any caches
if (null !== $this->cache) {
$this->cache->evictFromCacheByIdentity($oid);
}
} | php | public function deleteAcl(ObjectIdentityInterface $oid)
{
$this->connection->beginTransaction();
try {
foreach ($this->findChildren($oid, true) as $childOid) {
$this->deleteAcl($childOid);
}
$oidPK = $this->retrieveObjectIdentityPrimaryKey($oid);
$this->deleteAccessControlEntries($oidPK);
$this->deleteObjectIdentityRelations($oidPK);
$this->deleteObjectIdentity($oidPK);
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollBack();
throw $e;
}
// evict the ACL from the in-memory identity map
if (isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) {
$this->propertyChanges->offsetUnset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()]);
unset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()]);
}
// evict the ACL from any caches
if (null !== $this->cache) {
$this->cache->evictFromCacheByIdentity($oid);
}
} | [
"public",
"function",
"deleteAcl",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"beginTransaction",
"(",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"findChildren",
"(",
"$",
"oid",
",",
"true",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L79-L110 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.findAcls | public function findAcls(array $oids, array $sids = array())
{
$result = parent::findAcls($oids, $sids);
foreach ($result as $oid) {
$acl = $result->offsetGet($oid);
if (false === $this->propertyChanges->contains($acl) && $acl instanceof MutableAclInterface) {
$acl->addPropertyChangedListener($this);
$this->propertyChanges->attach($acl, array());
}
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
if (false === $this->propertyChanges->contains($parentAcl) && $acl instanceof MutableAclInterface) {
$parentAcl->addPropertyChangedListener($this);
$this->propertyChanges->attach($parentAcl, array());
}
$parentAcl = $parentAcl->getParentAcl();
}
}
return $result;
} | php | public function findAcls(array $oids, array $sids = array())
{
$result = parent::findAcls($oids, $sids);
foreach ($result as $oid) {
$acl = $result->offsetGet($oid);
if (false === $this->propertyChanges->contains($acl) && $acl instanceof MutableAclInterface) {
$acl->addPropertyChangedListener($this);
$this->propertyChanges->attach($acl, array());
}
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
if (false === $this->propertyChanges->contains($parentAcl) && $acl instanceof MutableAclInterface) {
$parentAcl->addPropertyChangedListener($this);
$this->propertyChanges->attach($parentAcl, array());
}
$parentAcl = $parentAcl->getParentAcl();
}
}
return $result;
} | [
"public",
"function",
"findAcls",
"(",
"array",
"$",
"oids",
",",
"array",
"$",
"sids",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"findAcls",
"(",
"$",
"oids",
",",
"$",
"sids",
")",
";",
"foreach",
"(",
"$",
"result",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L128-L152 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.propertyChanged | public function propertyChanged($sender, $propertyName, $oldValue, $newValue)
{
if (!$sender instanceof MutableAclInterface && !$sender instanceof EntryInterface) {
throw new \InvalidArgumentException('$sender must be an instance of MutableAclInterface, or EntryInterface.');
}
if ($sender instanceof EntryInterface) {
if (null === $sender->getId()) {
return;
}
$ace = $sender;
$sender = $ace->getAcl();
} else {
$ace = null;
}
if (false === $this->propertyChanges->contains($sender)) {
throw new \InvalidArgumentException('$sender is not being tracked by this provider.');
}
$propertyChanges = $this->propertyChanges->offsetGet($sender);
if (null === $ace) {
if (isset($propertyChanges[$propertyName])) {
$oldValue = $propertyChanges[$propertyName][0];
if ($oldValue === $newValue) {
unset($propertyChanges[$propertyName]);
} else {
$propertyChanges[$propertyName] = array($oldValue, $newValue);
}
} else {
$propertyChanges[$propertyName] = array($oldValue, $newValue);
}
} else {
if (!isset($propertyChanges['aces'])) {
$propertyChanges['aces'] = new \SplObjectStorage();
}
$acePropertyChanges = $propertyChanges['aces']->contains($ace) ? $propertyChanges['aces']->offsetGet($ace) : array();
if (isset($acePropertyChanges[$propertyName])) {
$oldValue = $acePropertyChanges[$propertyName][0];
if ($oldValue === $newValue) {
unset($acePropertyChanges[$propertyName]);
} else {
$acePropertyChanges[$propertyName] = array($oldValue, $newValue);
}
} else {
$acePropertyChanges[$propertyName] = array($oldValue, $newValue);
}
if (count($acePropertyChanges) > 0) {
$propertyChanges['aces']->offsetSet($ace, $acePropertyChanges);
} else {
$propertyChanges['aces']->offsetUnset($ace);
if (0 === count($propertyChanges['aces'])) {
unset($propertyChanges['aces']);
}
}
}
$this->propertyChanges->offsetSet($sender, $propertyChanges);
} | php | public function propertyChanged($sender, $propertyName, $oldValue, $newValue)
{
if (!$sender instanceof MutableAclInterface && !$sender instanceof EntryInterface) {
throw new \InvalidArgumentException('$sender must be an instance of MutableAclInterface, or EntryInterface.');
}
if ($sender instanceof EntryInterface) {
if (null === $sender->getId()) {
return;
}
$ace = $sender;
$sender = $ace->getAcl();
} else {
$ace = null;
}
if (false === $this->propertyChanges->contains($sender)) {
throw new \InvalidArgumentException('$sender is not being tracked by this provider.');
}
$propertyChanges = $this->propertyChanges->offsetGet($sender);
if (null === $ace) {
if (isset($propertyChanges[$propertyName])) {
$oldValue = $propertyChanges[$propertyName][0];
if ($oldValue === $newValue) {
unset($propertyChanges[$propertyName]);
} else {
$propertyChanges[$propertyName] = array($oldValue, $newValue);
}
} else {
$propertyChanges[$propertyName] = array($oldValue, $newValue);
}
} else {
if (!isset($propertyChanges['aces'])) {
$propertyChanges['aces'] = new \SplObjectStorage();
}
$acePropertyChanges = $propertyChanges['aces']->contains($ace) ? $propertyChanges['aces']->offsetGet($ace) : array();
if (isset($acePropertyChanges[$propertyName])) {
$oldValue = $acePropertyChanges[$propertyName][0];
if ($oldValue === $newValue) {
unset($acePropertyChanges[$propertyName]);
} else {
$acePropertyChanges[$propertyName] = array($oldValue, $newValue);
}
} else {
$acePropertyChanges[$propertyName] = array($oldValue, $newValue);
}
if (count($acePropertyChanges) > 0) {
$propertyChanges['aces']->offsetSet($ace, $acePropertyChanges);
} else {
$propertyChanges['aces']->offsetUnset($ace);
if (0 === count($propertyChanges['aces'])) {
unset($propertyChanges['aces']);
}
}
}
$this->propertyChanges->offsetSet($sender, $propertyChanges);
} | [
"public",
"function",
"propertyChanged",
"(",
"$",
"sender",
",",
"$",
"propertyName",
",",
"$",
"oldValue",
",",
"$",
"newValue",
")",
"{",
"if",
"(",
"!",
"$",
"sender",
"instanceof",
"MutableAclInterface",
"&&",
"!",
"$",
"sender",
"instanceof",
"EntryInt... | Implementation of PropertyChangedListener.
This allows us to keep track of which values have been changed, so we don't
have to do a full introspection when ->updateAcl() is called.
@param mixed $sender
@param string $propertyName
@param mixed $oldValue
@param mixed $newValue
@throws \InvalidArgumentException | [
"Implementation",
"of",
"PropertyChangedListener",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L167-L230 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.updateAcl | public function updateAcl(MutableAclInterface $acl)
{
if (!$this->propertyChanges->contains($acl)) {
throw new \InvalidArgumentException('$acl is not tracked by this provider.');
}
$propertyChanges = $this->propertyChanges->offsetGet($acl);
// check if any changes were made to this ACL
if (0 === count($propertyChanges)) {
return;
}
$sets = $sharedPropertyChanges = array();
$this->connection->beginTransaction();
try {
if (isset($propertyChanges['entriesInheriting'])) {
$sets[] = 'entries_inheriting = '.$this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['entriesInheriting'][1]);
}
if (isset($propertyChanges['parentAcl'])) {
if (null === $propertyChanges['parentAcl'][1]) {
$sets[] = 'parent_object_identity_id = NULL';
} else {
$sets[] = 'parent_object_identity_id = '.(int) $propertyChanges['parentAcl'][1]->getId();
}
$this->regenerateAncestorRelations($acl);
$childAcls = $this->findAcls($this->findChildren($acl->getObjectIdentity(), false));
foreach ($childAcls as $childOid) {
$this->regenerateAncestorRelations($childAcls[$childOid]);
}
}
// check properties for deleted, and created ACEs, and perform deletions
// we need to perform deletions before updating existing ACEs, in order to
// preserve uniqueness of the order field
if (isset($propertyChanges['classAces'])) {
$this->updateOldAceProperty('classAces', $propertyChanges['classAces']);
}
if (isset($propertyChanges['classFieldAces'])) {
$this->updateOldFieldAceProperty('classFieldAces', $propertyChanges['classFieldAces']);
}
if (isset($propertyChanges['objectAces'])) {
$this->updateOldAceProperty('objectAces', $propertyChanges['objectAces']);
}
if (isset($propertyChanges['objectFieldAces'])) {
$this->updateOldFieldAceProperty('objectFieldAces', $propertyChanges['objectFieldAces']);
}
// this includes only updates of existing ACEs, but neither the creation, nor
// the deletion of ACEs; these are tracked by changes to the ACL's respective
// properties (classAces, classFieldAces, objectAces, objectFieldAces)
if (isset($propertyChanges['aces'])) {
$this->updateAces($propertyChanges['aces']);
}
// check properties for deleted, and created ACEs, and perform creations
if (isset($propertyChanges['classAces'])) {
$this->updateNewAceProperty('classAces', $propertyChanges['classAces']);
$sharedPropertyChanges['classAces'] = $propertyChanges['classAces'];
}
if (isset($propertyChanges['classFieldAces'])) {
$this->updateNewFieldAceProperty('classFieldAces', $propertyChanges['classFieldAces']);
$sharedPropertyChanges['classFieldAces'] = $propertyChanges['classFieldAces'];
}
if (isset($propertyChanges['objectAces'])) {
$this->updateNewAceProperty('objectAces', $propertyChanges['objectAces']);
}
if (isset($propertyChanges['objectFieldAces'])) {
$this->updateNewFieldAceProperty('objectFieldAces', $propertyChanges['objectFieldAces']);
}
// if there have been changes to shared properties, we need to synchronize other
// ACL instances for object identities of the same type that are already in-memory
if (count($sharedPropertyChanges) > 0) {
$classAcesProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Acl', 'classAces');
$classAcesProperty->setAccessible(true);
$classFieldAcesProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Acl', 'classFieldAces');
$classFieldAcesProperty->setAccessible(true);
foreach ($this->loadedAcls[$acl->getObjectIdentity()->getType()] as $sameTypeAcl) {
if (isset($sharedPropertyChanges['classAces'])) {
if ($acl !== $sameTypeAcl && $classAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classAces'][0]) {
throw new ConcurrentModificationException('The "classAces" property has been modified concurrently.');
}
$classAcesProperty->setValue($sameTypeAcl, $sharedPropertyChanges['classAces'][1]);
}
if (isset($sharedPropertyChanges['classFieldAces'])) {
if ($acl !== $sameTypeAcl && $classFieldAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classFieldAces'][0]) {
throw new ConcurrentModificationException('The "classFieldAces" property has been modified concurrently.');
}
$classFieldAcesProperty->setValue($sameTypeAcl, $sharedPropertyChanges['classFieldAces'][1]);
}
}
}
// persist any changes to the acl_object_identities table
if (count($sets) > 0) {
$this->connection->executeQuery($this->getUpdateObjectIdentitySql($acl->getId(), $sets));
}
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollBack();
throw $e;
}
$this->propertyChanges->offsetSet($acl, array());
if (null !== $this->cache) {
if (count($sharedPropertyChanges) > 0) {
// FIXME: Currently, there is no easy way to clear the cache for ACLs
// of a certain type. The problem here is that we need to make
// sure to clear the cache of all child ACLs as well, and these
// child ACLs might be of a different class type.
$this->cache->clearCache();
} else {
// if there are no shared property changes, it's sufficient to just delete
// the cache for this ACL
$this->cache->evictFromCacheByIdentity($acl->getObjectIdentity());
foreach ($this->findChildren($acl->getObjectIdentity()) as $childOid) {
$this->cache->evictFromCacheByIdentity($childOid);
}
}
}
} | php | public function updateAcl(MutableAclInterface $acl)
{
if (!$this->propertyChanges->contains($acl)) {
throw new \InvalidArgumentException('$acl is not tracked by this provider.');
}
$propertyChanges = $this->propertyChanges->offsetGet($acl);
// check if any changes were made to this ACL
if (0 === count($propertyChanges)) {
return;
}
$sets = $sharedPropertyChanges = array();
$this->connection->beginTransaction();
try {
if (isset($propertyChanges['entriesInheriting'])) {
$sets[] = 'entries_inheriting = '.$this->connection->getDatabasePlatform()->convertBooleans($propertyChanges['entriesInheriting'][1]);
}
if (isset($propertyChanges['parentAcl'])) {
if (null === $propertyChanges['parentAcl'][1]) {
$sets[] = 'parent_object_identity_id = NULL';
} else {
$sets[] = 'parent_object_identity_id = '.(int) $propertyChanges['parentAcl'][1]->getId();
}
$this->regenerateAncestorRelations($acl);
$childAcls = $this->findAcls($this->findChildren($acl->getObjectIdentity(), false));
foreach ($childAcls as $childOid) {
$this->regenerateAncestorRelations($childAcls[$childOid]);
}
}
// check properties for deleted, and created ACEs, and perform deletions
// we need to perform deletions before updating existing ACEs, in order to
// preserve uniqueness of the order field
if (isset($propertyChanges['classAces'])) {
$this->updateOldAceProperty('classAces', $propertyChanges['classAces']);
}
if (isset($propertyChanges['classFieldAces'])) {
$this->updateOldFieldAceProperty('classFieldAces', $propertyChanges['classFieldAces']);
}
if (isset($propertyChanges['objectAces'])) {
$this->updateOldAceProperty('objectAces', $propertyChanges['objectAces']);
}
if (isset($propertyChanges['objectFieldAces'])) {
$this->updateOldFieldAceProperty('objectFieldAces', $propertyChanges['objectFieldAces']);
}
// this includes only updates of existing ACEs, but neither the creation, nor
// the deletion of ACEs; these are tracked by changes to the ACL's respective
// properties (classAces, classFieldAces, objectAces, objectFieldAces)
if (isset($propertyChanges['aces'])) {
$this->updateAces($propertyChanges['aces']);
}
// check properties for deleted, and created ACEs, and perform creations
if (isset($propertyChanges['classAces'])) {
$this->updateNewAceProperty('classAces', $propertyChanges['classAces']);
$sharedPropertyChanges['classAces'] = $propertyChanges['classAces'];
}
if (isset($propertyChanges['classFieldAces'])) {
$this->updateNewFieldAceProperty('classFieldAces', $propertyChanges['classFieldAces']);
$sharedPropertyChanges['classFieldAces'] = $propertyChanges['classFieldAces'];
}
if (isset($propertyChanges['objectAces'])) {
$this->updateNewAceProperty('objectAces', $propertyChanges['objectAces']);
}
if (isset($propertyChanges['objectFieldAces'])) {
$this->updateNewFieldAceProperty('objectFieldAces', $propertyChanges['objectFieldAces']);
}
// if there have been changes to shared properties, we need to synchronize other
// ACL instances for object identities of the same type that are already in-memory
if (count($sharedPropertyChanges) > 0) {
$classAcesProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Acl', 'classAces');
$classAcesProperty->setAccessible(true);
$classFieldAcesProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Acl', 'classFieldAces');
$classFieldAcesProperty->setAccessible(true);
foreach ($this->loadedAcls[$acl->getObjectIdentity()->getType()] as $sameTypeAcl) {
if (isset($sharedPropertyChanges['classAces'])) {
if ($acl !== $sameTypeAcl && $classAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classAces'][0]) {
throw new ConcurrentModificationException('The "classAces" property has been modified concurrently.');
}
$classAcesProperty->setValue($sameTypeAcl, $sharedPropertyChanges['classAces'][1]);
}
if (isset($sharedPropertyChanges['classFieldAces'])) {
if ($acl !== $sameTypeAcl && $classFieldAcesProperty->getValue($sameTypeAcl) !== $sharedPropertyChanges['classFieldAces'][0]) {
throw new ConcurrentModificationException('The "classFieldAces" property has been modified concurrently.');
}
$classFieldAcesProperty->setValue($sameTypeAcl, $sharedPropertyChanges['classFieldAces'][1]);
}
}
}
// persist any changes to the acl_object_identities table
if (count($sets) > 0) {
$this->connection->executeQuery($this->getUpdateObjectIdentitySql($acl->getId(), $sets));
}
$this->connection->commit();
} catch (\Exception $e) {
$this->connection->rollBack();
throw $e;
}
$this->propertyChanges->offsetSet($acl, array());
if (null !== $this->cache) {
if (count($sharedPropertyChanges) > 0) {
// FIXME: Currently, there is no easy way to clear the cache for ACLs
// of a certain type. The problem here is that we need to make
// sure to clear the cache of all child ACLs as well, and these
// child ACLs might be of a different class type.
$this->cache->clearCache();
} else {
// if there are no shared property changes, it's sufficient to just delete
// the cache for this ACL
$this->cache->evictFromCacheByIdentity($acl->getObjectIdentity());
foreach ($this->findChildren($acl->getObjectIdentity()) as $childOid) {
$this->cache->evictFromCacheByIdentity($childOid);
}
}
}
} | [
"public",
"function",
"updateAcl",
"(",
"MutableAclInterface",
"$",
"acl",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"propertyChanges",
"->",
"contains",
"(",
"$",
"acl",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$acl is not ... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L235-L366 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.updateUserSecurityIdentity | public function updateUserSecurityIdentity(UserSecurityIdentity $usid, $oldUsername)
{
$this->connection->executeQuery($this->getUpdateUserSecurityIdentitySql($usid, $oldUsername));
} | php | public function updateUserSecurityIdentity(UserSecurityIdentity $usid, $oldUsername)
{
$this->connection->executeQuery($this->getUpdateUserSecurityIdentitySql($usid, $oldUsername));
} | [
"public",
"function",
"updateUserSecurityIdentity",
"(",
"UserSecurityIdentity",
"$",
"usid",
",",
"$",
"oldUsername",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"executeQuery",
"(",
"$",
"this",
"->",
"getUpdateUserSecurityIdentitySql",
"(",
"$",
"usid",
",... | Updates a user security identity when the user's username changes.
@param UserSecurityIdentity $usid
@param string $oldUsername | [
"Updates",
"a",
"user",
"security",
"identity",
"when",
"the",
"user",
"s",
"username",
"changes",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L374-L377 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getInsertAccessControlEntrySql | protected function getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $aceOrder, $securityIdentityId, $strategy, $mask, $granting, $auditSuccess, $auditFailure)
{
$query = <<<QUERY
INSERT INTO %s (
class_id,
object_identity_id,
field_name,
ace_order,
security_identity_id,
mask,
granting,
granting_strategy,
audit_success,
audit_failure
)
VALUES (%d, %s, %s, %d, %d, %d, %s, %s, %s, %s)
QUERY;
return sprintf(
$query,
$this->options['entry_table_name'],
$classId,
null === $objectIdentityId ? 'NULL' : (int) $objectIdentityId,
null === $field ? 'NULL' : $this->connection->quote($field),
$aceOrder,
$securityIdentityId,
$mask,
$this->connection->getDatabasePlatform()->convertBooleans($granting),
$this->connection->quote($strategy),
$this->connection->getDatabasePlatform()->convertBooleans($auditSuccess),
$this->connection->getDatabasePlatform()->convertBooleans($auditFailure)
);
} | php | protected function getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $aceOrder, $securityIdentityId, $strategy, $mask, $granting, $auditSuccess, $auditFailure)
{
$query = <<<QUERY
INSERT INTO %s (
class_id,
object_identity_id,
field_name,
ace_order,
security_identity_id,
mask,
granting,
granting_strategy,
audit_success,
audit_failure
)
VALUES (%d, %s, %s, %d, %d, %d, %s, %s, %s, %s)
QUERY;
return sprintf(
$query,
$this->options['entry_table_name'],
$classId,
null === $objectIdentityId ? 'NULL' : (int) $objectIdentityId,
null === $field ? 'NULL' : $this->connection->quote($field),
$aceOrder,
$securityIdentityId,
$mask,
$this->connection->getDatabasePlatform()->convertBooleans($granting),
$this->connection->quote($strategy),
$this->connection->getDatabasePlatform()->convertBooleans($auditSuccess),
$this->connection->getDatabasePlatform()->convertBooleans($auditFailure)
);
} | [
"protected",
"function",
"getInsertAccessControlEntrySql",
"(",
"$",
"classId",
",",
"$",
"objectIdentityId",
",",
"$",
"field",
",",
"$",
"aceOrder",
",",
"$",
"securityIdentityId",
",",
"$",
"strategy",
",",
"$",
"mask",
",",
"$",
"granting",
",",
"$",
"au... | Constructs the SQL for inserting an ACE.
@param int $classId
@param int|null $objectIdentityId
@param string|null $field
@param int $aceOrder
@param int $securityIdentityId
@param string $strategy
@param int $mask
@param bool $granting
@param bool $auditSuccess
@param bool $auditFailure
@return string | [
"Constructs",
"the",
"SQL",
"for",
"inserting",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L459-L491 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getInsertObjectIdentitySql | protected function getInsertObjectIdentitySql($identifier, $classId, $entriesInheriting)
{
$query = <<<QUERY
INSERT INTO %s (class_id, object_identifier, entries_inheriting)
VALUES (%d, %s, %s)
QUERY;
return sprintf(
$query,
$this->options['oid_table_name'],
$classId,
$this->connection->quote($identifier),
$this->connection->getDatabasePlatform()->convertBooleans($entriesInheriting)
);
} | php | protected function getInsertObjectIdentitySql($identifier, $classId, $entriesInheriting)
{
$query = <<<QUERY
INSERT INTO %s (class_id, object_identifier, entries_inheriting)
VALUES (%d, %s, %s)
QUERY;
return sprintf(
$query,
$this->options['oid_table_name'],
$classId,
$this->connection->quote($identifier),
$this->connection->getDatabasePlatform()->convertBooleans($entriesInheriting)
);
} | [
"protected",
"function",
"getInsertObjectIdentitySql",
"(",
"$",
"identifier",
",",
"$",
"classId",
",",
"$",
"entriesInheriting",
")",
"{",
"$",
"query",
"=",
" <<<QUERY\n INSERT INTO %s (class_id, object_identifier, entries_inheriting)\n VALUES (%d, %s, ... | Constructs the SQL for inserting an object identity.
@param string $identifier
@param int $classId
@param bool $entriesInheriting
@return string | [
"Constructs",
"the",
"SQL",
"for",
"inserting",
"an",
"object",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L536-L550 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getInsertSecurityIdentitySql | protected function getInsertSecurityIdentitySql(SecurityIdentityInterface $sid)
{
if ($sid instanceof UserSecurityIdentity) {
$identifier = $sid->getClass().'-'.$sid->getUsername();
$username = true;
} elseif ($sid instanceof RoleSecurityIdentity) {
$identifier = $sid->getRole();
$username = false;
} else {
throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.');
}
return sprintf(
'INSERT INTO %s (identifier, username) VALUES (%s, %s)',
$this->options['sid_table_name'],
$this->connection->quote($identifier),
$this->connection->getDatabasePlatform()->convertBooleans($username)
);
} | php | protected function getInsertSecurityIdentitySql(SecurityIdentityInterface $sid)
{
if ($sid instanceof UserSecurityIdentity) {
$identifier = $sid->getClass().'-'.$sid->getUsername();
$username = true;
} elseif ($sid instanceof RoleSecurityIdentity) {
$identifier = $sid->getRole();
$username = false;
} else {
throw new \InvalidArgumentException('$sid must either be an instance of UserSecurityIdentity, or RoleSecurityIdentity.');
}
return sprintf(
'INSERT INTO %s (identifier, username) VALUES (%s, %s)',
$this->options['sid_table_name'],
$this->connection->quote($identifier),
$this->connection->getDatabasePlatform()->convertBooleans($username)
);
} | [
"protected",
"function",
"getInsertSecurityIdentitySql",
"(",
"SecurityIdentityInterface",
"$",
"sid",
")",
"{",
"if",
"(",
"$",
"sid",
"instanceof",
"UserSecurityIdentity",
")",
"{",
"$",
"identifier",
"=",
"$",
"sid",
"->",
"getClass",
"(",
")",
".",
"'-'",
... | Constructs the SQL for inserting a security identity.
@param SecurityIdentityInterface $sid
@throws \InvalidArgumentException
@return string | [
"Constructs",
"the",
"SQL",
"for",
"inserting",
"a",
"security",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L561-L579 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getSelectAccessControlEntryIdSql | protected function getSelectAccessControlEntryIdSql($classId, $oid, $field, $order)
{
return sprintf(
'SELECT id FROM %s WHERE class_id = %d AND %s AND %s AND ace_order = %d',
$this->options['entry_table_name'],
$classId,
null === $oid ?
$this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id')
: 'object_identity_id = '.(int) $oid,
null === $field ?
$this->connection->getDatabasePlatform()->getIsNullExpression('field_name')
: 'field_name = '.$this->connection->quote($field),
$order
);
} | php | protected function getSelectAccessControlEntryIdSql($classId, $oid, $field, $order)
{
return sprintf(
'SELECT id FROM %s WHERE class_id = %d AND %s AND %s AND ace_order = %d',
$this->options['entry_table_name'],
$classId,
null === $oid ?
$this->connection->getDatabasePlatform()->getIsNullExpression('object_identity_id')
: 'object_identity_id = '.(int) $oid,
null === $field ?
$this->connection->getDatabasePlatform()->getIsNullExpression('field_name')
: 'field_name = '.$this->connection->quote($field),
$order
);
} | [
"protected",
"function",
"getSelectAccessControlEntryIdSql",
"(",
"$",
"classId",
",",
"$",
"oid",
",",
"$",
"field",
",",
"$",
"order",
")",
"{",
"return",
"sprintf",
"(",
"'SELECT id FROM %s WHERE class_id = %d AND %s AND %s AND ace_order = %d'",
",",
"$",
"this",
"... | Constructs the SQL for selecting an ACE.
@param int $classId
@param int $oid
@param string $field
@param int $order
@return string | [
"Constructs",
"the",
"SQL",
"for",
"selecting",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L591-L605 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getDeleteSecurityIdentityIdSql | protected function getDeleteSecurityIdentityIdSql(SecurityIdentityInterface $sid)
{
$select = $this->getSelectSecurityIdentityIdSql($sid);
$delete = preg_replace('/^SELECT id FROM/', 'DELETE FROM', $select);
return $delete;
} | php | protected function getDeleteSecurityIdentityIdSql(SecurityIdentityInterface $sid)
{
$select = $this->getSelectSecurityIdentityIdSql($sid);
$delete = preg_replace('/^SELECT id FROM/', 'DELETE FROM', $select);
return $delete;
} | [
"protected",
"function",
"getDeleteSecurityIdentityIdSql",
"(",
"SecurityIdentityInterface",
"$",
"sid",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"getSelectSecurityIdentityIdSql",
"(",
"$",
"sid",
")",
";",
"$",
"delete",
"=",
"preg_replace",
"(",
"'/^SELE... | Constructs the SQL to delete a security identity.
@param SecurityIdentityInterface $sid
@throws \InvalidArgumentException
@return string | [
"Constructs",
"the",
"SQL",
"to",
"delete",
"a",
"security",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L662-L668 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getUpdateObjectIdentitySql | protected function getUpdateObjectIdentitySql($pk, array $changes)
{
if (0 === count($changes)) {
throw new \InvalidArgumentException('There are no changes.');
}
return sprintf(
'UPDATE %s SET %s WHERE id = %d',
$this->options['oid_table_name'],
implode(', ', $changes),
$pk
);
} | php | protected function getUpdateObjectIdentitySql($pk, array $changes)
{
if (0 === count($changes)) {
throw new \InvalidArgumentException('There are no changes.');
}
return sprintf(
'UPDATE %s SET %s WHERE id = %d',
$this->options['oid_table_name'],
implode(', ', $changes),
$pk
);
} | [
"protected",
"function",
"getUpdateObjectIdentitySql",
"(",
"$",
"pk",
",",
"array",
"$",
"changes",
")",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"changes",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'There are no changes.'",... | Constructs the SQL for updating an object identity.
@param int $pk
@param array $changes
@throws \InvalidArgumentException
@return string | [
"Constructs",
"the",
"SQL",
"for",
"updating",
"an",
"object",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L680-L692 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getUpdateUserSecurityIdentitySql | protected function getUpdateUserSecurityIdentitySql(UserSecurityIdentity $usid, $oldUsername)
{
if ($usid->getUsername() == $oldUsername) {
throw new \InvalidArgumentException('There are no changes.');
}
$oldIdentifier = $usid->getClass().'-'.$oldUsername;
$newIdentifier = $usid->getClass().'-'.$usid->getUsername();
return sprintf(
'UPDATE %s SET identifier = %s WHERE identifier = %s AND username = %s',
$this->options['sid_table_name'],
$this->connection->quote($newIdentifier),
$this->connection->quote($oldIdentifier),
$this->connection->getDatabasePlatform()->convertBooleans(true)
);
} | php | protected function getUpdateUserSecurityIdentitySql(UserSecurityIdentity $usid, $oldUsername)
{
if ($usid->getUsername() == $oldUsername) {
throw new \InvalidArgumentException('There are no changes.');
}
$oldIdentifier = $usid->getClass().'-'.$oldUsername;
$newIdentifier = $usid->getClass().'-'.$usid->getUsername();
return sprintf(
'UPDATE %s SET identifier = %s WHERE identifier = %s AND username = %s',
$this->options['sid_table_name'],
$this->connection->quote($newIdentifier),
$this->connection->quote($oldIdentifier),
$this->connection->getDatabasePlatform()->convertBooleans(true)
);
} | [
"protected",
"function",
"getUpdateUserSecurityIdentitySql",
"(",
"UserSecurityIdentity",
"$",
"usid",
",",
"$",
"oldUsername",
")",
"{",
"if",
"(",
"$",
"usid",
"->",
"getUsername",
"(",
")",
"==",
"$",
"oldUsername",
")",
"{",
"throw",
"new",
"\\",
"InvalidA... | Constructs the SQL for updating a user security identity.
@param UserSecurityIdentity $usid
@param string $oldUsername
@return string | [
"Constructs",
"the",
"SQL",
"for",
"updating",
"a",
"user",
"security",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L702-L718 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.getUpdateAccessControlEntrySql | protected function getUpdateAccessControlEntrySql($pk, array $sets)
{
if (0 === count($sets)) {
throw new \InvalidArgumentException('There are no changes.');
}
return sprintf(
'UPDATE %s SET %s WHERE id = %d',
$this->options['entry_table_name'],
implode(', ', $sets),
$pk
);
} | php | protected function getUpdateAccessControlEntrySql($pk, array $sets)
{
if (0 === count($sets)) {
throw new \InvalidArgumentException('There are no changes.');
}
return sprintf(
'UPDATE %s SET %s WHERE id = %d',
$this->options['entry_table_name'],
implode(', ', $sets),
$pk
);
} | [
"protected",
"function",
"getUpdateAccessControlEntrySql",
"(",
"$",
"pk",
",",
"array",
"$",
"sets",
")",
"{",
"if",
"(",
"0",
"===",
"count",
"(",
"$",
"sets",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'There are no changes.'",
... | Constructs the SQL for updating an ACE.
@param int $pk
@param array $sets
@throws \InvalidArgumentException
@return string | [
"Constructs",
"the",
"SQL",
"for",
"updating",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L730-L742 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.createObjectIdentity | private function createObjectIdentity(ObjectIdentityInterface $oid)
{
$classId = $this->createOrRetrieveClassId($oid->getType());
$this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true));
} | php | private function createObjectIdentity(ObjectIdentityInterface $oid)
{
$classId = $this->createOrRetrieveClassId($oid->getType());
$this->connection->executeQuery($this->getInsertObjectIdentitySql($oid->getIdentifier(), $classId, true));
} | [
"private",
"function",
"createObjectIdentity",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"$",
"classId",
"=",
"$",
"this",
"->",
"createOrRetrieveClassId",
"(",
"$",
"oid",
"->",
"getType",
"(",
")",
")",
";",
"$",
"this",
"->",
"connection",
"->... | Creates the ACL for the passed object identity.
@param ObjectIdentityInterface $oid | [
"Creates",
"the",
"ACL",
"for",
"the",
"passed",
"object",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L749-L754 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.createOrRetrieveClassId | private function createOrRetrieveClassId($classType)
{
if (false !== $id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn()) {
return $id;
}
$this->connection->executeQuery($this->getInsertClassSql($classType));
return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn();
} | php | private function createOrRetrieveClassId($classType)
{
if (false !== $id = $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn()) {
return $id;
}
$this->connection->executeQuery($this->getInsertClassSql($classType));
return $this->connection->executeQuery($this->getSelectClassIdSql($classType))->fetchColumn();
} | [
"private",
"function",
"createOrRetrieveClassId",
"(",
"$",
"classType",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"id",
"=",
"$",
"this",
"->",
"connection",
"->",
"executeQuery",
"(",
"$",
"this",
"->",
"getSelectClassIdSql",
"(",
"$",
"classType",
")",
... | Returns the primary key for the passed class type.
If the type does not yet exist in the database, it will be created.
@param string $classType
@return int | [
"Returns",
"the",
"primary",
"key",
"for",
"the",
"passed",
"class",
"type",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L765-L774 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.createOrRetrieveSecurityIdentityId | private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid)
{
if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) {
return $id;
}
$this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid));
return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
} | php | private function createOrRetrieveSecurityIdentityId(SecurityIdentityInterface $sid)
{
if (false !== $id = $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn()) {
return $id;
}
$this->connection->executeQuery($this->getInsertSecurityIdentitySql($sid));
return $this->connection->executeQuery($this->getSelectSecurityIdentityIdSql($sid))->fetchColumn();
} | [
"private",
"function",
"createOrRetrieveSecurityIdentityId",
"(",
"SecurityIdentityInterface",
"$",
"sid",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"id",
"=",
"$",
"this",
"->",
"connection",
"->",
"executeQuery",
"(",
"$",
"this",
"->",
"getSelectSecurityIdentit... | Returns the primary key for the passed security identity.
If the security identity does not yet exist in the database, it will be
created.
@param SecurityIdentityInterface $sid
@return int | [
"Returns",
"the",
"primary",
"key",
"for",
"the",
"passed",
"security",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L786-L795 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.regenerateAncestorRelations | private function regenerateAncestorRelations(AclInterface $acl)
{
$pk = $acl->getId();
$this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId()));
$parentAcl = $parentAcl->getParentAcl();
}
} | php | private function regenerateAncestorRelations(AclInterface $acl)
{
$pk = $acl->getId();
$this->connection->executeQuery($this->getDeleteObjectIdentityRelationsSql($pk));
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $pk));
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
$this->connection->executeQuery($this->getInsertObjectIdentityRelationSql($pk, $parentAcl->getId()));
$parentAcl = $parentAcl->getParentAcl();
}
} | [
"private",
"function",
"regenerateAncestorRelations",
"(",
"AclInterface",
"$",
"acl",
")",
"{",
"$",
"pk",
"=",
"$",
"acl",
"->",
"getId",
"(",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"executeQuery",
"(",
"$",
"this",
"->",
"getDeleteObjectIdentity... | This regenerates the ancestor table which is used for fast read access.
@param AclInterface $acl | [
"This",
"regenerates",
"the",
"ancestor",
"table",
"which",
"is",
"used",
"for",
"fast",
"read",
"access",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L832-L844 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.updateNewFieldAceProperty | private function updateNewFieldAceProperty($name, array $changes)
{
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
foreach ($changes[1] as $field => $new) {
for ($i = 0, $c = count($new); $i < $c; ++$i) {
$ace = $new[$i];
if (null === $ace->getId()) {
if ($sids->contains($ace->getSecurityIdentity())) {
$sid = $sids->offsetGet($ace->getSecurityIdentity());
} else {
$sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
}
$oid = $ace->getAcl()->getObjectIdentity();
if ($classIds->contains($oid)) {
$classId = $classIds->offsetGet($oid);
} else {
$classId = $this->createOrRetrieveClassId($oid->getType());
}
$objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId();
$this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure()));
$aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn();
$this->loadedAces[$aceId] = $ace;
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, (int) $aceId);
}
}
}
} | php | private function updateNewFieldAceProperty($name, array $changes)
{
$sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage();
foreach ($changes[1] as $field => $new) {
for ($i = 0, $c = count($new); $i < $c; ++$i) {
$ace = $new[$i];
if (null === $ace->getId()) {
if ($sids->contains($ace->getSecurityIdentity())) {
$sid = $sids->offsetGet($ace->getSecurityIdentity());
} else {
$sid = $this->createOrRetrieveSecurityIdentityId($ace->getSecurityIdentity());
}
$oid = $ace->getAcl()->getObjectIdentity();
if ($classIds->contains($oid)) {
$classId = $classIds->offsetGet($oid);
} else {
$classId = $this->createOrRetrieveClassId($oid->getType());
}
$objectIdentityId = $name === 'classFieldAces' ? null : $ace->getAcl()->getId();
$this->connection->executeQuery($this->getInsertAccessControlEntrySql($classId, $objectIdentityId, $field, $i, $sid, $ace->getStrategy(), $ace->getMask(), $ace->isGranting(), $ace->isAuditSuccess(), $ace->isAuditFailure()));
$aceId = $this->connection->executeQuery($this->getSelectAccessControlEntryIdSql($classId, $objectIdentityId, $field, $i))->fetchColumn();
$this->loadedAces[$aceId] = $ace;
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, (int) $aceId);
}
}
}
} | [
"private",
"function",
"updateNewFieldAceProperty",
"(",
"$",
"name",
",",
"array",
"$",
"changes",
")",
"{",
"$",
"sids",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"$",
"classIds",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"foreach",... | This processes new entries changes on an ACE related property (classFieldAces, or objectFieldAces).
@param string $name
@param array $changes | [
"This",
"processes",
"new",
"entries",
"changes",
"on",
"an",
"ACE",
"related",
"property",
"(",
"classFieldAces",
"or",
"objectFieldAces",
")",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L852-L886 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.updateOldFieldAceProperty | private function updateOldFieldAceProperty($name, array $changes)
{
$currentIds = array();
foreach ($changes[1] as $field => $new) {
for ($i = 0, $c = count($new); $i < $c; ++$i) {
$ace = $new[$i];
if (null !== $ace->getId()) {
$currentIds[$ace->getId()] = true;
}
}
}
foreach ($changes[0] as $old) {
for ($i = 0, $c = count($old); $i < $c; ++$i) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
unset($this->loadedAces[$ace->getId()]);
}
}
}
} | php | private function updateOldFieldAceProperty($name, array $changes)
{
$currentIds = array();
foreach ($changes[1] as $field => $new) {
for ($i = 0, $c = count($new); $i < $c; ++$i) {
$ace = $new[$i];
if (null !== $ace->getId()) {
$currentIds[$ace->getId()] = true;
}
}
}
foreach ($changes[0] as $old) {
for ($i = 0, $c = count($old); $i < $c; ++$i) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
unset($this->loadedAces[$ace->getId()]);
}
}
}
} | [
"private",
"function",
"updateOldFieldAceProperty",
"(",
"$",
"name",
",",
"array",
"$",
"changes",
")",
"{",
"$",
"currentIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"changes",
"[",
"1",
"]",
"as",
"$",
"field",
"=>",
"$",
"new",
")",
"{... | This processes old entries changes on an ACE related property (classFieldAces, or objectFieldAces).
@param string $name
@param array $changes | [
"This",
"processes",
"old",
"entries",
"changes",
"on",
"an",
"ACE",
"related",
"property",
"(",
"classFieldAces",
"or",
"objectFieldAces",
")",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L894-L917 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.updateOldAceProperty | private function updateOldAceProperty($name, array $changes)
{
list($old, $new) = $changes;
$currentIds = array();
for ($i = 0, $c = count($new); $i < $c; ++$i) {
$ace = $new[$i];
if (null !== $ace->getId()) {
$currentIds[$ace->getId()] = true;
}
}
for ($i = 0, $c = count($old); $i < $c; ++$i) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
unset($this->loadedAces[$ace->getId()]);
}
}
} | php | private function updateOldAceProperty($name, array $changes)
{
list($old, $new) = $changes;
$currentIds = array();
for ($i = 0, $c = count($new); $i < $c; ++$i) {
$ace = $new[$i];
if (null !== $ace->getId()) {
$currentIds[$ace->getId()] = true;
}
}
for ($i = 0, $c = count($old); $i < $c; ++$i) {
$ace = $old[$i];
if (!isset($currentIds[$ace->getId()])) {
$this->connection->executeQuery($this->getDeleteAccessControlEntrySql($ace->getId()));
unset($this->loadedAces[$ace->getId()]);
}
}
} | [
"private",
"function",
"updateOldAceProperty",
"(",
"$",
"name",
",",
"array",
"$",
"changes",
")",
"{",
"list",
"(",
"$",
"old",
",",
"$",
"new",
")",
"=",
"$",
"changes",
";",
"$",
"currentIds",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
... | This processes old entries changes on an ACE related property (classAces, or objectAces).
@param string $name
@param array $changes | [
"This",
"processes",
"old",
"entries",
"changes",
"on",
"an",
"ACE",
"related",
"property",
"(",
"classAces",
"or",
"objectAces",
")",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L967-L988 |
symfony/security-acl | Dbal/MutableAclProvider.php | MutableAclProvider.updateAces | private function updateAces(\SplObjectStorage $aces)
{
foreach ($aces as $ace) {
$this->updateAce($aces, $ace);
}
} | php | private function updateAces(\SplObjectStorage $aces)
{
foreach ($aces as $ace) {
$this->updateAce($aces, $ace);
}
} | [
"private",
"function",
"updateAces",
"(",
"\\",
"SplObjectStorage",
"$",
"aces",
")",
"{",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"this",
"->",
"updateAce",
"(",
"$",
"aces",
",",
"$",
"ace",
")",
";",
"}",
"}"
] | Persists the changes which were made to ACEs to the database.
@param \SplObjectStorage $aces | [
"Persists",
"the",
"changes",
"which",
"were",
"made",
"to",
"ACEs",
"to",
"the",
"database",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/MutableAclProvider.php#L995-L1000 |
symfony/security-acl | Domain/DoctrineAclCache.php | DoctrineAclCache.evictFromCacheById | public function evictFromCacheById($aclId)
{
$lookupKey = $this->getAliasKeyForIdentity($aclId);
if (!$this->cache->contains($lookupKey)) {
return;
}
$key = $this->cache->fetch($lookupKey);
if ($this->cache->contains($key)) {
$this->cache->delete($key);
}
$this->cache->delete($lookupKey);
} | php | public function evictFromCacheById($aclId)
{
$lookupKey = $this->getAliasKeyForIdentity($aclId);
if (!$this->cache->contains($lookupKey)) {
return;
}
$key = $this->cache->fetch($lookupKey);
if ($this->cache->contains($key)) {
$this->cache->delete($key);
}
$this->cache->delete($lookupKey);
} | [
"public",
"function",
"evictFromCacheById",
"(",
"$",
"aclId",
")",
"{",
"$",
"lookupKey",
"=",
"$",
"this",
"->",
"getAliasKeyForIdentity",
"(",
"$",
"aclId",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
"->",
"contains",
"(",
"$",
"lookupKey",... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/DoctrineAclCache.php#L67-L80 |
symfony/security-acl | Domain/DoctrineAclCache.php | DoctrineAclCache.evictFromCacheByIdentity | public function evictFromCacheByIdentity(ObjectIdentityInterface $oid)
{
$key = $this->getDataKeyByIdentity($oid);
if (!$this->cache->contains($key)) {
return;
}
$this->cache->delete($key);
} | php | public function evictFromCacheByIdentity(ObjectIdentityInterface $oid)
{
$key = $this->getDataKeyByIdentity($oid);
if (!$this->cache->contains($key)) {
return;
}
$this->cache->delete($key);
} | [
"public",
"function",
"evictFromCacheByIdentity",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getDataKeyByIdentity",
"(",
"$",
"oid",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
"->",
"contains",
"("... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/DoctrineAclCache.php#L85-L93 |
symfony/security-acl | Domain/DoctrineAclCache.php | DoctrineAclCache.getFromCacheById | public function getFromCacheById($aclId)
{
$lookupKey = $this->getAliasKeyForIdentity($aclId);
if (!$this->cache->contains($lookupKey)) {
return;
}
$key = $this->cache->fetch($lookupKey);
if (!$this->cache->contains($key)) {
$this->cache->delete($lookupKey);
return;
}
return $this->unserializeAcl($this->cache->fetch($key));
} | php | public function getFromCacheById($aclId)
{
$lookupKey = $this->getAliasKeyForIdentity($aclId);
if (!$this->cache->contains($lookupKey)) {
return;
}
$key = $this->cache->fetch($lookupKey);
if (!$this->cache->contains($key)) {
$this->cache->delete($lookupKey);
return;
}
return $this->unserializeAcl($this->cache->fetch($key));
} | [
"public",
"function",
"getFromCacheById",
"(",
"$",
"aclId",
")",
"{",
"$",
"lookupKey",
"=",
"$",
"this",
"->",
"getAliasKeyForIdentity",
"(",
"$",
"aclId",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
"->",
"contains",
"(",
"$",
"lookupKey",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/DoctrineAclCache.php#L98-L113 |
symfony/security-acl | Domain/DoctrineAclCache.php | DoctrineAclCache.getFromCacheByIdentity | public function getFromCacheByIdentity(ObjectIdentityInterface $oid)
{
$key = $this->getDataKeyByIdentity($oid);
if (!$this->cache->contains($key)) {
return;
}
return $this->unserializeAcl($this->cache->fetch($key));
} | php | public function getFromCacheByIdentity(ObjectIdentityInterface $oid)
{
$key = $this->getDataKeyByIdentity($oid);
if (!$this->cache->contains($key)) {
return;
}
return $this->unserializeAcl($this->cache->fetch($key));
} | [
"public",
"function",
"getFromCacheByIdentity",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getDataKeyByIdentity",
"(",
"$",
"oid",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"cache",
"->",
"contains",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/DoctrineAclCache.php#L118-L126 |
symfony/security-acl | Domain/DoctrineAclCache.php | DoctrineAclCache.putInCache | public function putInCache(AclInterface $acl)
{
if (null === $acl->getId()) {
throw new \InvalidArgumentException('Transient ACLs cannot be cached.');
}
if (null !== $parentAcl = $acl->getParentAcl()) {
$this->putInCache($parentAcl);
}
$key = $this->getDataKeyByIdentity($acl->getObjectIdentity());
$this->cache->save($key, serialize($acl));
$this->cache->save($this->getAliasKeyForIdentity($acl->getId()), $key);
} | php | public function putInCache(AclInterface $acl)
{
if (null === $acl->getId()) {
throw new \InvalidArgumentException('Transient ACLs cannot be cached.');
}
if (null !== $parentAcl = $acl->getParentAcl()) {
$this->putInCache($parentAcl);
}
$key = $this->getDataKeyByIdentity($acl->getObjectIdentity());
$this->cache->save($key, serialize($acl));
$this->cache->save($this->getAliasKeyForIdentity($acl->getId()), $key);
} | [
"public",
"function",
"putInCache",
"(",
"AclInterface",
"$",
"acl",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"acl",
"->",
"getId",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Transient ACLs cannot be cached.'",
")",
";",
"}"... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/DoctrineAclCache.php#L131-L144 |
symfony/security-acl | Domain/DoctrineAclCache.php | DoctrineAclCache.getDataKeyByIdentity | private function getDataKeyByIdentity(ObjectIdentityInterface $oid)
{
return $this->prefix.md5($oid->getType()).sha1($oid->getType())
.'_'.md5($oid->getIdentifier()).sha1($oid->getIdentifier());
} | php | private function getDataKeyByIdentity(ObjectIdentityInterface $oid)
{
return $this->prefix.md5($oid->getType()).sha1($oid->getType())
.'_'.md5($oid->getIdentifier()).sha1($oid->getIdentifier());
} | [
"private",
"function",
"getDataKeyByIdentity",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"return",
"$",
"this",
"->",
"prefix",
".",
"md5",
"(",
"$",
"oid",
"->",
"getType",
"(",
")",
")",
".",
"sha1",
"(",
"$",
"oid",
"->",
"getType",
"(",
... | Returns the key for the object identity.
@param ObjectIdentityInterface $oid
@return string | [
"Returns",
"the",
"key",
"for",
"the",
"object",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/DoctrineAclCache.php#L212-L216 |
symfony/security-acl | Domain/Acl.php | Acl.insertClassAce | public function insertClassAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null)
{
$this->insertAce('classAces', $index, $mask, $sid, $granting, $strategy);
} | php | public function insertClassAce(SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null)
{
$this->insertAce('classAces', $index, $mask, $sid, $granting, $strategy);
} | [
"public",
"function",
"insertClassAce",
"(",
"SecurityIdentityInterface",
"$",
"sid",
",",
"$",
"mask",
",",
"$",
"index",
"=",
"0",
",",
"$",
"granting",
"=",
"true",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"insertAce",
"(",
"'... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L169-L172 |
symfony/security-acl | Domain/Acl.php | Acl.insertClassFieldAce | public function insertClassFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null)
{
$this->insertFieldAce('classFieldAces', $index, $field, $mask, $sid, $granting, $strategy);
} | php | public function insertClassFieldAce($field, SecurityIdentityInterface $sid, $mask, $index = 0, $granting = true, $strategy = null)
{
$this->insertFieldAce('classFieldAces', $index, $field, $mask, $sid, $granting, $strategy);
} | [
"public",
"function",
"insertClassFieldAce",
"(",
"$",
"field",
",",
"SecurityIdentityInterface",
"$",
"sid",
",",
"$",
"mask",
",",
"$",
"index",
"=",
"0",
",",
"$",
"granting",
"=",
"true",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"this",
"-... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L177-L180 |
symfony/security-acl | Domain/Acl.php | Acl.isFieldGranted | public function isFieldGranted($field, array $masks, array $securityIdentities, $administrativeMode = false)
{
return $this->permissionGrantingStrategy->isFieldGranted($this, $field, $masks, $securityIdentities, $administrativeMode);
} | php | public function isFieldGranted($field, array $masks, array $securityIdentities, $administrativeMode = false)
{
return $this->permissionGrantingStrategy->isFieldGranted($this, $field, $masks, $securityIdentities, $administrativeMode);
} | [
"public",
"function",
"isFieldGranted",
"(",
"$",
"field",
",",
"array",
"$",
"masks",
",",
"array",
"$",
"securityIdentities",
",",
"$",
"administrativeMode",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"permissionGrantingStrategy",
"->",
"isFieldGrant... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L209-L212 |
symfony/security-acl | Domain/Acl.php | Acl.isGranted | public function isGranted(array $masks, array $securityIdentities, $administrativeMode = false)
{
return $this->permissionGrantingStrategy->isGranted($this, $masks, $securityIdentities, $administrativeMode);
} | php | public function isGranted(array $masks, array $securityIdentities, $administrativeMode = false)
{
return $this->permissionGrantingStrategy->isGranted($this, $masks, $securityIdentities, $administrativeMode);
} | [
"public",
"function",
"isGranted",
"(",
"array",
"$",
"masks",
",",
"array",
"$",
"securityIdentities",
",",
"$",
"administrativeMode",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"permissionGrantingStrategy",
"->",
"isGranted",
"(",
"$",
"this",
",",... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L217-L220 |
symfony/security-acl | Domain/Acl.php | Acl.isSidLoaded | public function isSidLoaded($sids)
{
if (!$this->loadedSids) {
return true;
}
if (!is_array($sids)) {
$sids = array($sids);
}
foreach ($sids as $sid) {
if (!$sid instanceof SecurityIdentityInterface) {
throw new \InvalidArgumentException(
'$sid must be an instance of SecurityIdentityInterface.');
}
foreach ($this->loadedSids as $loadedSid) {
if ($loadedSid->equals($sid)) {
continue 2;
}
}
return false;
}
return true;
} | php | public function isSidLoaded($sids)
{
if (!$this->loadedSids) {
return true;
}
if (!is_array($sids)) {
$sids = array($sids);
}
foreach ($sids as $sid) {
if (!$sid instanceof SecurityIdentityInterface) {
throw new \InvalidArgumentException(
'$sid must be an instance of SecurityIdentityInterface.');
}
foreach ($this->loadedSids as $loadedSid) {
if ($loadedSid->equals($sid)) {
continue 2;
}
}
return false;
}
return true;
} | [
"public",
"function",
"isSidLoaded",
"(",
"$",
"sids",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"loadedSids",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"sids",
")",
")",
"{",
"$",
"sids",
"=",
"array",
"(",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L225-L251 |
symfony/security-acl | Domain/Acl.php | Acl.serialize | public function serialize()
{
return serialize(array(
null === $this->parentAcl ? null : $this->parentAcl->getId(),
$this->objectIdentity,
$this->classAces,
$this->classFieldAces,
$this->objectAces,
$this->objectFieldAces,
$this->id,
$this->loadedSids,
$this->entriesInheriting,
));
} | php | public function serialize()
{
return serialize(array(
null === $this->parentAcl ? null : $this->parentAcl->getId(),
$this->objectIdentity,
$this->classAces,
$this->classFieldAces,
$this->objectAces,
$this->objectFieldAces,
$this->id,
$this->loadedSids,
$this->entriesInheriting,
));
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"return",
"serialize",
"(",
"array",
"(",
"null",
"===",
"$",
"this",
"->",
"parentAcl",
"?",
"null",
":",
"$",
"this",
"->",
"parentAcl",
"->",
"getId",
"(",
")",
",",
"$",
"this",
"->",
"objectIdentit... | Implementation for the \Serializable interface.
@return string | [
"Implementation",
"for",
"the",
"\\",
"Serializable",
"interface",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L258-L271 |
symfony/security-acl | Domain/Acl.php | Acl.unserialize | public function unserialize($serialized)
{
list($this->parentAcl,
$this->objectIdentity,
$this->classAces,
$this->classFieldAces,
$this->objectAces,
$this->objectFieldAces,
$this->id,
$this->loadedSids,
$this->entriesInheriting
) = unserialize($serialized);
$this->listeners = array();
} | php | public function unserialize($serialized)
{
list($this->parentAcl,
$this->objectIdentity,
$this->classAces,
$this->classFieldAces,
$this->objectAces,
$this->objectFieldAces,
$this->id,
$this->loadedSids,
$this->entriesInheriting
) = unserialize($serialized);
$this->listeners = array();
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"parentAcl",
",",
"$",
"this",
"->",
"objectIdentity",
",",
"$",
"this",
"->",
"classAces",
",",
"$",
"this",
"->",
"classFieldAces",
",",
"$",
"this",... | Implementation for the \Serializable interface.
@param string $serialized | [
"Implementation",
"for",
"the",
"\\",
"Serializable",
"interface",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L278-L292 |
symfony/security-acl | Domain/Acl.php | Acl.setEntriesInheriting | public function setEntriesInheriting($boolean)
{
if ($this->entriesInheriting !== $boolean) {
$this->onPropertyChanged('entriesInheriting', $this->entriesInheriting, $boolean);
$this->entriesInheriting = $boolean;
}
} | php | public function setEntriesInheriting($boolean)
{
if ($this->entriesInheriting !== $boolean) {
$this->onPropertyChanged('entriesInheriting', $this->entriesInheriting, $boolean);
$this->entriesInheriting = $boolean;
}
} | [
"public",
"function",
"setEntriesInheriting",
"(",
"$",
"boolean",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entriesInheriting",
"!==",
"$",
"boolean",
")",
"{",
"$",
"this",
"->",
"onPropertyChanged",
"(",
"'entriesInheriting'",
",",
"$",
"this",
"->",
"entr... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L297-L303 |
symfony/security-acl | Domain/Acl.php | Acl.setParentAcl | public function setParentAcl(AclInterface $acl = null)
{
if (null !== $acl && null === $acl->getId()) {
throw new \InvalidArgumentException('$acl must have an ID.');
}
if ($this->parentAcl !== $acl) {
$this->onPropertyChanged('parentAcl', $this->parentAcl, $acl);
$this->parentAcl = $acl;
}
} | php | public function setParentAcl(AclInterface $acl = null)
{
if (null !== $acl && null === $acl->getId()) {
throw new \InvalidArgumentException('$acl must have an ID.');
}
if ($this->parentAcl !== $acl) {
$this->onPropertyChanged('parentAcl', $this->parentAcl, $acl);
$this->parentAcl = $acl;
}
} | [
"public",
"function",
"setParentAcl",
"(",
"AclInterface",
"$",
"acl",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"acl",
"&&",
"null",
"===",
"$",
"acl",
"->",
"getId",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L308-L318 |
symfony/security-acl | Domain/Acl.php | Acl.updateClassAce | public function updateClassAce($index, $mask, $strategy = null)
{
$this->updateAce('classAces', $index, $mask, $strategy);
} | php | public function updateClassAce($index, $mask, $strategy = null)
{
$this->updateAce('classAces', $index, $mask, $strategy);
} | [
"public",
"function",
"updateClassAce",
"(",
"$",
"index",
",",
"$",
"mask",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"updateAce",
"(",
"'classAces'",
",",
"$",
"index",
",",
"$",
"mask",
",",
"$",
"strategy",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L323-L326 |
symfony/security-acl | Domain/Acl.php | Acl.updateClassFieldAce | public function updateClassFieldAce($index, $field, $mask, $strategy = null)
{
$this->updateFieldAce('classFieldAces', $index, $field, $mask, $strategy);
} | php | public function updateClassFieldAce($index, $field, $mask, $strategy = null)
{
$this->updateFieldAce('classFieldAces', $index, $field, $mask, $strategy);
} | [
"public",
"function",
"updateClassFieldAce",
"(",
"$",
"index",
",",
"$",
"field",
",",
"$",
"mask",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"updateFieldAce",
"(",
"'classFieldAces'",
",",
"$",
"index",
",",
"$",
"field",
",",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L331-L334 |
symfony/security-acl | Domain/Acl.php | Acl.updateObjectAce | public function updateObjectAce($index, $mask, $strategy = null)
{
$this->updateAce('objectAces', $index, $mask, $strategy);
} | php | public function updateObjectAce($index, $mask, $strategy = null)
{
$this->updateAce('objectAces', $index, $mask, $strategy);
} | [
"public",
"function",
"updateObjectAce",
"(",
"$",
"index",
",",
"$",
"mask",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"updateAce",
"(",
"'objectAces'",
",",
"$",
"index",
",",
"$",
"mask",
",",
"$",
"strategy",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L339-L342 |
symfony/security-acl | Domain/Acl.php | Acl.updateObjectFieldAce | public function updateObjectFieldAce($index, $field, $mask, $strategy = null)
{
$this->updateFieldAce('objectFieldAces', $index, $field, $mask, $strategy);
} | php | public function updateObjectFieldAce($index, $field, $mask, $strategy = null)
{
$this->updateFieldAce('objectFieldAces', $index, $field, $mask, $strategy);
} | [
"public",
"function",
"updateObjectFieldAce",
"(",
"$",
"index",
",",
"$",
"field",
",",
"$",
"mask",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"updateFieldAce",
"(",
"'objectFieldAces'",
",",
"$",
"index",
",",
"$",
"field",
",",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L347-L350 |
symfony/security-acl | Domain/Acl.php | Acl.updateClassAuditing | public function updateClassAuditing($index, $auditSuccess, $auditFailure)
{
$this->updateAuditing($this->classAces, $index, $auditSuccess, $auditFailure);
} | php | public function updateClassAuditing($index, $auditSuccess, $auditFailure)
{
$this->updateAuditing($this->classAces, $index, $auditSuccess, $auditFailure);
} | [
"public",
"function",
"updateClassAuditing",
"(",
"$",
"index",
",",
"$",
"auditSuccess",
",",
"$",
"auditFailure",
")",
"{",
"$",
"this",
"->",
"updateAuditing",
"(",
"$",
"this",
"->",
"classAces",
",",
"$",
"index",
",",
"$",
"auditSuccess",
",",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L355-L358 |
symfony/security-acl | Domain/Acl.php | Acl.updateClassFieldAuditing | public function updateClassFieldAuditing($index, $field, $auditSuccess, $auditFailure)
{
if (!isset($this->classFieldAces[$field])) {
throw new \InvalidArgumentException(sprintf('There are no ACEs for field "%s".', $field));
}
$this->updateAuditing($this->classFieldAces[$field], $index, $auditSuccess, $auditFailure);
} | php | public function updateClassFieldAuditing($index, $field, $auditSuccess, $auditFailure)
{
if (!isset($this->classFieldAces[$field])) {
throw new \InvalidArgumentException(sprintf('There are no ACEs for field "%s".', $field));
}
$this->updateAuditing($this->classFieldAces[$field], $index, $auditSuccess, $auditFailure);
} | [
"public",
"function",
"updateClassFieldAuditing",
"(",
"$",
"index",
",",
"$",
"field",
",",
"$",
"auditSuccess",
",",
"$",
"auditFailure",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"classFieldAces",
"[",
"$",
"field",
"]",
")",
")",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L363-L370 |
symfony/security-acl | Domain/Acl.php | Acl.updateObjectAuditing | public function updateObjectAuditing($index, $auditSuccess, $auditFailure)
{
$this->updateAuditing($this->objectAces, $index, $auditSuccess, $auditFailure);
} | php | public function updateObjectAuditing($index, $auditSuccess, $auditFailure)
{
$this->updateAuditing($this->objectAces, $index, $auditSuccess, $auditFailure);
} | [
"public",
"function",
"updateObjectAuditing",
"(",
"$",
"index",
",",
"$",
"auditSuccess",
",",
"$",
"auditFailure",
")",
"{",
"$",
"this",
"->",
"updateAuditing",
"(",
"$",
"this",
"->",
"objectAces",
",",
"$",
"index",
",",
"$",
"auditSuccess",
",",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L375-L378 |
symfony/security-acl | Domain/Acl.php | Acl.updateObjectFieldAuditing | public function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditFailure)
{
if (!isset($this->objectFieldAces[$field])) {
throw new \InvalidArgumentException(sprintf('There are no ACEs for field "%s".', $field));
}
$this->updateAuditing($this->objectFieldAces[$field], $index, $auditSuccess, $auditFailure);
} | php | public function updateObjectFieldAuditing($index, $field, $auditSuccess, $auditFailure)
{
if (!isset($this->objectFieldAces[$field])) {
throw new \InvalidArgumentException(sprintf('There are no ACEs for field "%s".', $field));
}
$this->updateAuditing($this->objectFieldAces[$field], $index, $auditSuccess, $auditFailure);
} | [
"public",
"function",
"updateObjectFieldAuditing",
"(",
"$",
"index",
",",
"$",
"field",
",",
"$",
"auditSuccess",
",",
"$",
"auditFailure",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"objectFieldAces",
"[",
"$",
"field",
"]",
")",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L383-L390 |
symfony/security-acl | Domain/Acl.php | Acl.deleteAce | private function deleteAce($property, $index)
{
$aces = &$this->$property;
if (!isset($aces[$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$oldValue = $this->$property;
unset($aces[$index]);
$this->$property = array_values($this->$property);
$this->onPropertyChanged($property, $oldValue, $this->$property);
for ($i = $index, $c = count($this->$property); $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$i], 'aceOrder', $i + 1, $i);
}
} | php | private function deleteAce($property, $index)
{
$aces = &$this->$property;
if (!isset($aces[$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$oldValue = $this->$property;
unset($aces[$index]);
$this->$property = array_values($this->$property);
$this->onPropertyChanged($property, $oldValue, $this->$property);
for ($i = $index, $c = count($this->$property); $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$i], 'aceOrder', $i + 1, $i);
}
} | [
"private",
"function",
"deleteAce",
"(",
"$",
"property",
",",
"$",
"index",
")",
"{",
"$",
"aces",
"=",
"&",
"$",
"this",
"->",
"$",
"property",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"aces",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"n... | Deletes an ACE.
@param string $property
@param int $index
@throws \OutOfBoundsException | [
"Deletes",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L400-L415 |
symfony/security-acl | Domain/Acl.php | Acl.deleteFieldAce | private function deleteFieldAce($property, $index, $field)
{
$aces = &$this->$property;
if (!isset($aces[$field][$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$oldValue = $this->$property;
unset($aces[$field][$index]);
$aces[$field] = array_values($aces[$field]);
$this->onPropertyChanged($property, $oldValue, $this->$property);
for ($i = $index, $c = count($aces[$field]); $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$field][$i], 'aceOrder', $i + 1, $i);
}
} | php | private function deleteFieldAce($property, $index, $field)
{
$aces = &$this->$property;
if (!isset($aces[$field][$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$oldValue = $this->$property;
unset($aces[$field][$index]);
$aces[$field] = array_values($aces[$field]);
$this->onPropertyChanged($property, $oldValue, $this->$property);
for ($i = $index, $c = count($aces[$field]); $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$field][$i], 'aceOrder', $i + 1, $i);
}
} | [
"private",
"function",
"deleteFieldAce",
"(",
"$",
"property",
",",
"$",
"index",
",",
"$",
"field",
")",
"{",
"$",
"aces",
"=",
"&",
"$",
"this",
"->",
"$",
"property",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"aces",
"[",
"$",
"field",
"]",
"[",... | Deletes a field-based ACE.
@param string $property
@param int $index
@param string $field
@throws \OutOfBoundsException | [
"Deletes",
"a",
"field",
"-",
"based",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L426-L441 |
symfony/security-acl | Domain/Acl.php | Acl.insertAce | private function insertAce($property, $index, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null)
{
if ($index < 0 || $index > count($this->$property)) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property)));
}
if (!is_int($mask)) {
throw new \InvalidArgumentException('$mask must be an integer.');
}
if (null === $strategy) {
if (true === $granting) {
$strategy = PermissionGrantingStrategy::ALL;
} else {
$strategy = PermissionGrantingStrategy::ANY;
}
}
$aces = &$this->$property;
$oldValue = $this->$property;
if (isset($aces[$index])) {
$this->$property = array_merge(
array_slice($this->$property, 0, $index),
array(true),
array_slice($this->$property, $index)
);
for ($i = $index, $c = count($this->$property) - 1; $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$i + 1], 'aceOrder', $i, $i + 1);
}
}
$aces[$index] = new Entry(null, $this, $sid, $strategy, $mask, $granting, false, false);
$this->onPropertyChanged($property, $oldValue, $this->$property);
} | php | private function insertAce($property, $index, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null)
{
if ($index < 0 || $index > count($this->$property)) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property)));
}
if (!is_int($mask)) {
throw new \InvalidArgumentException('$mask must be an integer.');
}
if (null === $strategy) {
if (true === $granting) {
$strategy = PermissionGrantingStrategy::ALL;
} else {
$strategy = PermissionGrantingStrategy::ANY;
}
}
$aces = &$this->$property;
$oldValue = $this->$property;
if (isset($aces[$index])) {
$this->$property = array_merge(
array_slice($this->$property, 0, $index),
array(true),
array_slice($this->$property, $index)
);
for ($i = $index, $c = count($this->$property) - 1; $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$i + 1], 'aceOrder', $i, $i + 1);
}
}
$aces[$index] = new Entry(null, $this, $sid, $strategy, $mask, $granting, false, false);
$this->onPropertyChanged($property, $oldValue, $this->$property);
} | [
"private",
"function",
"insertAce",
"(",
"$",
"property",
",",
"$",
"index",
",",
"$",
"mask",
",",
"SecurityIdentityInterface",
"$",
"sid",
",",
"$",
"granting",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"index",
"<",
"0",
"||",
"... | Inserts an ACE.
@param string $property
@param int $index
@param int $mask
@param SecurityIdentityInterface $sid
@param bool $granting
@param string $strategy
@throws \OutOfBoundsException
@throws \InvalidArgumentException | [
"Inserts",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L456-L490 |
symfony/security-acl | Domain/Acl.php | Acl.insertFieldAce | private function insertFieldAce($property, $index, $field, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null)
{
if (0 === strlen($field)) {
throw new \InvalidArgumentException('$field cannot be empty.');
}
if (!is_int($mask)) {
throw new \InvalidArgumentException('$mask must be an integer.');
}
if (null === $strategy) {
if (true === $granting) {
$strategy = PermissionGrantingStrategy::ALL;
} else {
$strategy = PermissionGrantingStrategy::ANY;
}
}
$aces = &$this->$property;
if (!isset($aces[$field])) {
$aces[$field] = array();
}
if ($index < 0 || $index > count($aces[$field])) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property)));
}
$oldValue = $aces;
if (isset($aces[$field][$index])) {
$aces[$field] = array_merge(
array_slice($aces[$field], 0, $index),
array(true),
array_slice($aces[$field], $index)
);
for ($i = $index, $c = count($aces[$field]) - 1; $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$field][$i + 1], 'aceOrder', $i, $i + 1);
}
}
$aces[$field][$index] = new FieldEntry(null, $this, $field, $sid, $strategy, $mask, $granting, false, false);
$this->onPropertyChanged($property, $oldValue, $this->$property);
} | php | private function insertFieldAce($property, $index, $field, $mask, SecurityIdentityInterface $sid, $granting, $strategy = null)
{
if (0 === strlen($field)) {
throw new \InvalidArgumentException('$field cannot be empty.');
}
if (!is_int($mask)) {
throw new \InvalidArgumentException('$mask must be an integer.');
}
if (null === $strategy) {
if (true === $granting) {
$strategy = PermissionGrantingStrategy::ALL;
} else {
$strategy = PermissionGrantingStrategy::ANY;
}
}
$aces = &$this->$property;
if (!isset($aces[$field])) {
$aces[$field] = array();
}
if ($index < 0 || $index > count($aces[$field])) {
throw new \OutOfBoundsException(sprintf('The index must be in the interval [0, %d].', count($this->$property)));
}
$oldValue = $aces;
if (isset($aces[$field][$index])) {
$aces[$field] = array_merge(
array_slice($aces[$field], 0, $index),
array(true),
array_slice($aces[$field], $index)
);
for ($i = $index, $c = count($aces[$field]) - 1; $i < $c; ++$i) {
$this->onEntryPropertyChanged($aces[$field][$i + 1], 'aceOrder', $i, $i + 1);
}
}
$aces[$field][$index] = new FieldEntry(null, $this, $field, $sid, $strategy, $mask, $granting, false, false);
$this->onPropertyChanged($property, $oldValue, $this->$property);
} | [
"private",
"function",
"insertFieldAce",
"(",
"$",
"property",
",",
"$",
"index",
",",
"$",
"field",
",",
"$",
"mask",
",",
"SecurityIdentityInterface",
"$",
"sid",
",",
"$",
"granting",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"if",
"(",
"0",
"===... | Inserts a field-based ACE.
@param string $property
@param int $index
@param string $field
@param int $mask
@param SecurityIdentityInterface $sid
@param bool $granting
@param string $strategy
@throws \InvalidArgumentException
@throws \OutOfBoundsException | [
"Inserts",
"a",
"field",
"-",
"based",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L506-L548 |
symfony/security-acl | Domain/Acl.php | Acl.updateAce | private function updateAce($property, $index, $mask, $strategy = null)
{
$aces = &$this->$property;
if (!isset($aces[$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$ace = $aces[$index];
if ($mask !== $oldMask = $ace->getMask()) {
$this->onEntryPropertyChanged($ace, 'mask', $oldMask, $mask);
$ace->setMask($mask);
}
if (null !== $strategy && $strategy !== $oldStrategy = $ace->getStrategy()) {
$this->onEntryPropertyChanged($ace, 'strategy', $oldStrategy, $strategy);
$ace->setStrategy($strategy);
}
} | php | private function updateAce($property, $index, $mask, $strategy = null)
{
$aces = &$this->$property;
if (!isset($aces[$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$ace = $aces[$index];
if ($mask !== $oldMask = $ace->getMask()) {
$this->onEntryPropertyChanged($ace, 'mask', $oldMask, $mask);
$ace->setMask($mask);
}
if (null !== $strategy && $strategy !== $oldStrategy = $ace->getStrategy()) {
$this->onEntryPropertyChanged($ace, 'strategy', $oldStrategy, $strategy);
$ace->setStrategy($strategy);
}
} | [
"private",
"function",
"updateAce",
"(",
"$",
"property",
",",
"$",
"index",
",",
"$",
"mask",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"$",
"aces",
"=",
"&",
"$",
"this",
"->",
"$",
"property",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"aces",... | Updates an ACE.
@param string $property
@param int $index
@param int $mask
@param string $strategy
@throws \OutOfBoundsException | [
"Updates",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L560-L576 |
symfony/security-acl | Domain/Acl.php | Acl.updateAuditing | private function updateAuditing(array &$aces, $index, $auditSuccess, $auditFailure)
{
if (!isset($aces[$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
if ($auditSuccess !== $aces[$index]->isAuditSuccess()) {
$this->onEntryPropertyChanged($aces[$index], 'auditSuccess', !$auditSuccess, $auditSuccess);
$aces[$index]->setAuditSuccess($auditSuccess);
}
if ($auditFailure !== $aces[$index]->isAuditFailure()) {
$this->onEntryPropertyChanged($aces[$index], 'auditFailure', !$auditFailure, $auditFailure);
$aces[$index]->setAuditFailure($auditFailure);
}
} | php | private function updateAuditing(array &$aces, $index, $auditSuccess, $auditFailure)
{
if (!isset($aces[$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
if ($auditSuccess !== $aces[$index]->isAuditSuccess()) {
$this->onEntryPropertyChanged($aces[$index], 'auditSuccess', !$auditSuccess, $auditSuccess);
$aces[$index]->setAuditSuccess($auditSuccess);
}
if ($auditFailure !== $aces[$index]->isAuditFailure()) {
$this->onEntryPropertyChanged($aces[$index], 'auditFailure', !$auditFailure, $auditFailure);
$aces[$index]->setAuditFailure($auditFailure);
}
} | [
"private",
"function",
"updateAuditing",
"(",
"array",
"&",
"$",
"aces",
",",
"$",
"index",
",",
"$",
"auditSuccess",
",",
"$",
"auditFailure",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"aces",
"[",
"$",
"index",
"]",
")",
")",
"{",
"throw",
"ne... | Updates auditing for an ACE.
@param array &$aces
@param int $index
@param bool $auditSuccess
@param bool $auditFailure
@throws \OutOfBoundsException | [
"Updates",
"auditing",
"for",
"an",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L588-L603 |
symfony/security-acl | Domain/Acl.php | Acl.updateFieldAce | private function updateFieldAce($property, $index, $field, $mask, $strategy = null)
{
if (0 === strlen($field)) {
throw new \InvalidArgumentException('$field cannot be empty.');
}
$aces = &$this->$property;
if (!isset($aces[$field][$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$ace = $aces[$field][$index];
if ($mask !== $oldMask = $ace->getMask()) {
$this->onEntryPropertyChanged($ace, 'mask', $oldMask, $mask);
$ace->setMask($mask);
}
if (null !== $strategy && $strategy !== $oldStrategy = $ace->getStrategy()) {
$this->onEntryPropertyChanged($ace, 'strategy', $oldStrategy, $strategy);
$ace->setStrategy($strategy);
}
} | php | private function updateFieldAce($property, $index, $field, $mask, $strategy = null)
{
if (0 === strlen($field)) {
throw new \InvalidArgumentException('$field cannot be empty.');
}
$aces = &$this->$property;
if (!isset($aces[$field][$index])) {
throw new \OutOfBoundsException(sprintf('The index "%d" does not exist.', $index));
}
$ace = $aces[$field][$index];
if ($mask !== $oldMask = $ace->getMask()) {
$this->onEntryPropertyChanged($ace, 'mask', $oldMask, $mask);
$ace->setMask($mask);
}
if (null !== $strategy && $strategy !== $oldStrategy = $ace->getStrategy()) {
$this->onEntryPropertyChanged($ace, 'strategy', $oldStrategy, $strategy);
$ace->setStrategy($strategy);
}
} | [
"private",
"function",
"updateFieldAce",
"(",
"$",
"property",
",",
"$",
"index",
",",
"$",
"field",
",",
"$",
"mask",
",",
"$",
"strategy",
"=",
"null",
")",
"{",
"if",
"(",
"0",
"===",
"strlen",
"(",
"$",
"field",
")",
")",
"{",
"throw",
"new",
... | Updates a field-based ACE.
@param string $property
@param int $index
@param string $field
@param int $mask
@param string $strategy
@throws \InvalidArgumentException
@throws \OutOfBoundsException | [
"Updates",
"a",
"field",
"-",
"based",
"ACE",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L617-L637 |
symfony/security-acl | Domain/Acl.php | Acl.onPropertyChanged | private function onPropertyChanged($name, $oldValue, $newValue)
{
foreach ($this->listeners as $listener) {
$listener->propertyChanged($this, $name, $oldValue, $newValue);
}
} | php | private function onPropertyChanged($name, $oldValue, $newValue)
{
foreach ($this->listeners as $listener) {
$listener->propertyChanged($this, $name, $oldValue, $newValue);
}
} | [
"private",
"function",
"onPropertyChanged",
"(",
"$",
"name",
",",
"$",
"oldValue",
",",
"$",
"newValue",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
"->",
"propertyChanged",
"(",
"$",
"this... | Called when a property of the ACL changes.
@param string $name
@param mixed $oldValue
@param mixed $newValue | [
"Called",
"when",
"a",
"property",
"of",
"the",
"ACL",
"changes",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L646-L651 |
symfony/security-acl | Domain/Acl.php | Acl.onEntryPropertyChanged | private function onEntryPropertyChanged(EntryInterface $entry, $name, $oldValue, $newValue)
{
foreach ($this->listeners as $listener) {
$listener->propertyChanged($entry, $name, $oldValue, $newValue);
}
} | php | private function onEntryPropertyChanged(EntryInterface $entry, $name, $oldValue, $newValue)
{
foreach ($this->listeners as $listener) {
$listener->propertyChanged($entry, $name, $oldValue, $newValue);
}
} | [
"private",
"function",
"onEntryPropertyChanged",
"(",
"EntryInterface",
"$",
"entry",
",",
"$",
"name",
",",
"$",
"oldValue",
",",
"$",
"newValue",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
... | Called when a property of an ACE associated with this ACL changes.
@param EntryInterface $entry
@param string $name
@param mixed $oldValue
@param mixed $newValue | [
"Called",
"when",
"a",
"property",
"of",
"an",
"ACE",
"associated",
"with",
"this",
"ACL",
"changes",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Acl.php#L661-L666 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.findChildren | public function findChildren(ObjectIdentityInterface $parentOid, $directChildrenOnly = false)
{
$sql = $this->getFindChildrenSql($parentOid, $directChildrenOnly);
$children = array();
foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) {
$children[] = new ObjectIdentity($data['object_identifier'], $data['class_type']);
}
return $children;
} | php | public function findChildren(ObjectIdentityInterface $parentOid, $directChildrenOnly = false)
{
$sql = $this->getFindChildrenSql($parentOid, $directChildrenOnly);
$children = array();
foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) {
$children[] = new ObjectIdentity($data['object_identifier'], $data['class_type']);
}
return $children;
} | [
"public",
"function",
"findChildren",
"(",
"ObjectIdentityInterface",
"$",
"parentOid",
",",
"$",
"directChildrenOnly",
"=",
"false",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"getFindChildrenSql",
"(",
"$",
"parentOid",
",",
"$",
"directChildrenOnly",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L78-L88 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.findAcl | public function findAcl(ObjectIdentityInterface $oid, array $sids = array())
{
return $this->findAcls(array($oid), $sids)->offsetGet($oid);
} | php | public function findAcl(ObjectIdentityInterface $oid, array $sids = array())
{
return $this->findAcls(array($oid), $sids)->offsetGet($oid);
} | [
"public",
"function",
"findAcl",
"(",
"ObjectIdentityInterface",
"$",
"oid",
",",
"array",
"$",
"sids",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"findAcls",
"(",
"array",
"(",
"$",
"oid",
")",
",",
"$",
"sids",
")",
"->",
"offse... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L93-L96 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.findAcls | public function findAcls(array $oids, array $sids = array())
{
$result = new \SplObjectStorage();
$currentBatch = array();
$oidLookup = array();
for ($i = 0, $c = count($oids); $i < $c; ++$i) {
$oid = $oids[$i];
$oidLookupKey = $oid->getIdentifier().$oid->getType();
$oidLookup[$oidLookupKey] = $oid;
$aclFound = false;
// check if result already contains an ACL
if ($result->contains($oid)) {
$aclFound = true;
}
// check if this ACL has already been hydrated
if (!$aclFound && isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) {
$acl = $this->loadedAcls[$oid->getType()][$oid->getIdentifier()];
if (!$acl->isSidLoaded($sids)) {
// FIXME: we need to load ACEs for the missing SIDs. This is never
// reached by the default implementation, since we do not
// filter by SID
throw new \RuntimeException('This is not supported by the default implementation.');
} else {
$result->attach($oid, $acl);
$aclFound = true;
}
}
// check if we can locate the ACL in the cache
if (!$aclFound && null !== $this->cache) {
$acl = $this->cache->getFromCacheByIdentity($oid);
if (null !== $acl) {
if ($acl->isSidLoaded($sids)) {
// check if any of the parents has been loaded since we need to
// ensure that there is only ever one ACL per object identity
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
$parentOid = $parentAcl->getObjectIdentity();
if (isset($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()])) {
$acl->setParentAcl($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()]);
break;
} else {
$this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()] = $parentAcl;
$this->updateAceIdentityMap($parentAcl);
}
$parentAcl = $parentAcl->getParentAcl();
}
$this->loadedAcls[$oid->getType()][$oid->getIdentifier()] = $acl;
$this->updateAceIdentityMap($acl);
$result->attach($oid, $acl);
$aclFound = true;
} else {
$this->cache->evictFromCacheByIdentity($oid);
foreach ($this->findChildren($oid) as $childOid) {
$this->cache->evictFromCacheByIdentity($childOid);
}
}
}
}
// looks like we have to load the ACL from the database
if (!$aclFound) {
$currentBatch[] = $oid;
}
// Is it time to load the current batch?
$currentBatchesCount = count($currentBatch);
if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
try {
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
} catch (AclNotFoundException $e) {
if ($result->count()) {
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
$partialResultException->setPartialResult($result);
throw $partialResultException;
} else {
throw $e;
}
}
foreach ($loadedBatch as $loadedOid) {
$loadedAcl = $loadedBatch->offsetGet($loadedOid);
if (null !== $this->cache) {
$this->cache->putInCache($loadedAcl);
}
if (isset($oidLookup[$loadedOid->getIdentifier().$loadedOid->getType()])) {
$result->attach($loadedOid, $loadedAcl);
}
}
$currentBatch = array();
}
}
// check that we got ACLs for all the identities
foreach ($oids as $oid) {
if (!$result->contains($oid)) {
if (1 === count($oids)) {
$objectName = method_exists($oid, '__toString') ? $oid : get_class($oid);
throw new AclNotFoundException(sprintf('No ACL found for %s.', $objectName));
}
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
$partialResultException->setPartialResult($result);
throw $partialResultException;
}
}
return $result;
} | php | public function findAcls(array $oids, array $sids = array())
{
$result = new \SplObjectStorage();
$currentBatch = array();
$oidLookup = array();
for ($i = 0, $c = count($oids); $i < $c; ++$i) {
$oid = $oids[$i];
$oidLookupKey = $oid->getIdentifier().$oid->getType();
$oidLookup[$oidLookupKey] = $oid;
$aclFound = false;
// check if result already contains an ACL
if ($result->contains($oid)) {
$aclFound = true;
}
// check if this ACL has already been hydrated
if (!$aclFound && isset($this->loadedAcls[$oid->getType()][$oid->getIdentifier()])) {
$acl = $this->loadedAcls[$oid->getType()][$oid->getIdentifier()];
if (!$acl->isSidLoaded($sids)) {
// FIXME: we need to load ACEs for the missing SIDs. This is never
// reached by the default implementation, since we do not
// filter by SID
throw new \RuntimeException('This is not supported by the default implementation.');
} else {
$result->attach($oid, $acl);
$aclFound = true;
}
}
// check if we can locate the ACL in the cache
if (!$aclFound && null !== $this->cache) {
$acl = $this->cache->getFromCacheByIdentity($oid);
if (null !== $acl) {
if ($acl->isSidLoaded($sids)) {
// check if any of the parents has been loaded since we need to
// ensure that there is only ever one ACL per object identity
$parentAcl = $acl->getParentAcl();
while (null !== $parentAcl) {
$parentOid = $parentAcl->getObjectIdentity();
if (isset($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()])) {
$acl->setParentAcl($this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()]);
break;
} else {
$this->loadedAcls[$parentOid->getType()][$parentOid->getIdentifier()] = $parentAcl;
$this->updateAceIdentityMap($parentAcl);
}
$parentAcl = $parentAcl->getParentAcl();
}
$this->loadedAcls[$oid->getType()][$oid->getIdentifier()] = $acl;
$this->updateAceIdentityMap($acl);
$result->attach($oid, $acl);
$aclFound = true;
} else {
$this->cache->evictFromCacheByIdentity($oid);
foreach ($this->findChildren($oid) as $childOid) {
$this->cache->evictFromCacheByIdentity($childOid);
}
}
}
}
// looks like we have to load the ACL from the database
if (!$aclFound) {
$currentBatch[] = $oid;
}
// Is it time to load the current batch?
$currentBatchesCount = count($currentBatch);
if ($currentBatchesCount > 0 && (self::MAX_BATCH_SIZE === $currentBatchesCount || ($i + 1) === $c)) {
try {
$loadedBatch = $this->lookupObjectIdentities($currentBatch, $sids, $oidLookup);
} catch (AclNotFoundException $e) {
if ($result->count()) {
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
$partialResultException->setPartialResult($result);
throw $partialResultException;
} else {
throw $e;
}
}
foreach ($loadedBatch as $loadedOid) {
$loadedAcl = $loadedBatch->offsetGet($loadedOid);
if (null !== $this->cache) {
$this->cache->putInCache($loadedAcl);
}
if (isset($oidLookup[$loadedOid->getIdentifier().$loadedOid->getType()])) {
$result->attach($loadedOid, $loadedAcl);
}
}
$currentBatch = array();
}
}
// check that we got ACLs for all the identities
foreach ($oids as $oid) {
if (!$result->contains($oid)) {
if (1 === count($oids)) {
$objectName = method_exists($oid, '__toString') ? $oid : get_class($oid);
throw new AclNotFoundException(sprintf('No ACL found for %s.', $objectName));
}
$partialResultException = new NotAllAclsFoundException('The provider could not find ACLs for all object identities.');
$partialResultException->setPartialResult($result);
throw $partialResultException;
}
}
return $result;
} | [
"public",
"function",
"findAcls",
"(",
"array",
"$",
"oids",
",",
"array",
"$",
"sids",
"=",
"array",
"(",
")",
")",
"{",
"$",
"result",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"$",
"currentBatch",
"=",
"array",
"(",
")",
";",
"$",
"oi... | {@inheritdoc} | [
"{"
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L101-L221 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.getFindChildrenSql | protected function getFindChildrenSql(ObjectIdentityInterface $oid, $directChildrenOnly)
{
if (false === $directChildrenOnly) {
$query = <<<FINDCHILDREN
SELECT o.object_identifier, c.class_type
FROM
{$this->options['oid_table_name']} o
INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
WHERE
a.ancestor_id = %d AND a.object_identity_id != a.ancestor_id
FINDCHILDREN;
} else {
$query = <<<FINDCHILDREN
SELECT o.object_identifier, c.class_type
FROM {$this->options['oid_table_name']} o
INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
WHERE o.parent_object_identity_id = %d
FINDCHILDREN;
}
return sprintf($query, $this->retrieveObjectIdentityPrimaryKey($oid));
} | php | protected function getFindChildrenSql(ObjectIdentityInterface $oid, $directChildrenOnly)
{
if (false === $directChildrenOnly) {
$query = <<<FINDCHILDREN
SELECT o.object_identifier, c.class_type
FROM
{$this->options['oid_table_name']} o
INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
INNER JOIN {$this->options['oid_ancestors_table_name']} a ON a.object_identity_id = o.id
WHERE
a.ancestor_id = %d AND a.object_identity_id != a.ancestor_id
FINDCHILDREN;
} else {
$query = <<<FINDCHILDREN
SELECT o.object_identifier, c.class_type
FROM {$this->options['oid_table_name']} o
INNER JOIN {$this->options['class_table_name']} c ON c.id = o.class_id
WHERE o.parent_object_identity_id = %d
FINDCHILDREN;
}
return sprintf($query, $this->retrieveObjectIdentityPrimaryKey($oid));
} | [
"protected",
"function",
"getFindChildrenSql",
"(",
"ObjectIdentityInterface",
"$",
"oid",
",",
"$",
"directChildrenOnly",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"directChildrenOnly",
")",
"{",
"$",
"query",
"=",
" <<<FINDCHILDREN\n SELECT o.object_ide... | Constructs the SQL for retrieving child object identities for the given
object identities.
@param ObjectIdentityInterface $oid
@param bool $directChildrenOnly
@return string | [
"Constructs",
"the",
"SQL",
"for",
"retrieving",
"child",
"object",
"identities",
"for",
"the",
"given",
"object",
"identities",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L338-L360 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.getSelectObjectIdentityIdSql | protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid)
{
$query = <<<QUERY
SELECT o.id
FROM %s o
INNER JOIN %s c ON c.id = o.class_id
WHERE o.object_identifier = %s AND c.class_type = %s
QUERY;
return sprintf(
$query,
$this->options['oid_table_name'],
$this->options['class_table_name'],
$this->connection->quote((string) $oid->getIdentifier()),
$this->connection->quote((string) $oid->getType())
);
} | php | protected function getSelectObjectIdentityIdSql(ObjectIdentityInterface $oid)
{
$query = <<<QUERY
SELECT o.id
FROM %s o
INNER JOIN %s c ON c.id = o.class_id
WHERE o.object_identifier = %s AND c.class_type = %s
QUERY;
return sprintf(
$query,
$this->options['oid_table_name'],
$this->options['class_table_name'],
$this->connection->quote((string) $oid->getIdentifier()),
$this->connection->quote((string) $oid->getType())
);
} | [
"protected",
"function",
"getSelectObjectIdentityIdSql",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"$",
"query",
"=",
" <<<QUERY\n SELECT o.id\n FROM %s o\n INNER JOIN %s c ON c.id = o.class_id\n WHERE o.object_identifier = %s AND c.cla... | Constructs the SQL for retrieving the primary key of the given object
identity.
@param ObjectIdentityInterface $oid
@return string | [
"Constructs",
"the",
"SQL",
"for",
"retrieving",
"the",
"primary",
"key",
"of",
"the",
"given",
"object",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L370-L386 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.retrieveObjectIdentityPrimaryKey | final protected function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid)
{
return $this->connection->executeQuery($this->getSelectObjectIdentityIdSql($oid))->fetchColumn();
} | php | final protected function retrieveObjectIdentityPrimaryKey(ObjectIdentityInterface $oid)
{
return $this->connection->executeQuery($this->getSelectObjectIdentityIdSql($oid))->fetchColumn();
} | [
"final",
"protected",
"function",
"retrieveObjectIdentityPrimaryKey",
"(",
"ObjectIdentityInterface",
"$",
"oid",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"executeQuery",
"(",
"$",
"this",
"->",
"getSelectObjectIdentityIdSql",
"(",
"$",
"oid",
")",... | Returns the primary key of the passed object identity.
@param ObjectIdentityInterface $oid
@return int | [
"Returns",
"the",
"primary",
"key",
"of",
"the",
"passed",
"object",
"identity",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L395-L398 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.updateAceIdentityMap | private function updateAceIdentityMap(AclInterface $acl)
{
foreach (array('classAces', 'classFieldAces', 'objectAces', 'objectFieldAces') as $property) {
$reflection = new \ReflectionProperty($acl, $property);
$reflection->setAccessible(true);
$value = $reflection->getValue($acl);
if ('classAces' === $property || 'objectAces' === $property) {
$this->doUpdateAceIdentityMap($value);
} else {
foreach ($value as $field => $aces) {
$this->doUpdateAceIdentityMap($value[$field]);
}
}
$reflection->setValue($acl, $value);
$reflection->setAccessible(false);
}
} | php | private function updateAceIdentityMap(AclInterface $acl)
{
foreach (array('classAces', 'classFieldAces', 'objectAces', 'objectFieldAces') as $property) {
$reflection = new \ReflectionProperty($acl, $property);
$reflection->setAccessible(true);
$value = $reflection->getValue($acl);
if ('classAces' === $property || 'objectAces' === $property) {
$this->doUpdateAceIdentityMap($value);
} else {
foreach ($value as $field => $aces) {
$this->doUpdateAceIdentityMap($value[$field]);
}
}
$reflection->setValue($acl, $value);
$reflection->setAccessible(false);
}
} | [
"private",
"function",
"updateAceIdentityMap",
"(",
"AclInterface",
"$",
"acl",
")",
"{",
"foreach",
"(",
"array",
"(",
"'classAces'",
",",
"'classFieldAces'",
",",
"'objectAces'",
",",
"'objectFieldAces'",
")",
"as",
"$",
"property",
")",
"{",
"$",
"reflection"... | This method is called when an ACL instance is retrieved from the cache.
@param AclInterface $acl | [
"This",
"method",
"is",
"called",
"when",
"an",
"ACL",
"instance",
"is",
"retrieved",
"from",
"the",
"cache",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L405-L423 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.getAncestorIds | private function getAncestorIds(array $batch)
{
$sql = $this->getAncestorLookupSql($batch);
$ancestorIds = array();
foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) {
// FIXME: skip ancestors which are cached
// Fix: Oracle returns keys in uppercase
$ancestorIds[] = reset($data);
}
return $ancestorIds;
} | php | private function getAncestorIds(array $batch)
{
$sql = $this->getAncestorLookupSql($batch);
$ancestorIds = array();
foreach ($this->connection->executeQuery($sql)->fetchAll() as $data) {
// FIXME: skip ancestors which are cached
// Fix: Oracle returns keys in uppercase
$ancestorIds[] = reset($data);
}
return $ancestorIds;
} | [
"private",
"function",
"getAncestorIds",
"(",
"array",
"$",
"batch",
")",
"{",
"$",
"sql",
"=",
"$",
"this",
"->",
"getAncestorLookupSql",
"(",
"$",
"batch",
")",
";",
"$",
"ancestorIds",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
... | Retrieves all the ids which need to be queried from the database
including the ids of parent ACLs.
@param array $batch
@return array | [
"Retrieves",
"all",
"the",
"ids",
"which",
"need",
"to",
"be",
"queried",
"from",
"the",
"database",
"including",
"the",
"ids",
"of",
"parent",
"ACLs",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L433-L445 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.doUpdateAceIdentityMap | private function doUpdateAceIdentityMap(array &$aces)
{
foreach ($aces as $index => $ace) {
if (isset($this->loadedAces[$ace->getId()])) {
$aces[$index] = $this->loadedAces[$ace->getId()];
} else {
$this->loadedAces[$ace->getId()] = $ace;
}
}
} | php | private function doUpdateAceIdentityMap(array &$aces)
{
foreach ($aces as $index => $ace) {
if (isset($this->loadedAces[$ace->getId()])) {
$aces[$index] = $this->loadedAces[$ace->getId()];
} else {
$this->loadedAces[$ace->getId()] = $ace;
}
}
} | [
"private",
"function",
"doUpdateAceIdentityMap",
"(",
"array",
"&",
"$",
"aces",
")",
"{",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"index",
"=>",
"$",
"ace",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"loadedAces",
"[",
"$",
"ace",
"->",
... | Does either overwrite the passed ACE, or saves it in the global identity
map to ensure every ACE only gets instantiated once.
@param array &$aces | [
"Does",
"either",
"overwrite",
"the",
"passed",
"ACE",
"or",
"saves",
"it",
"in",
"the",
"global",
"identity",
"map",
"to",
"ensure",
"every",
"ACE",
"only",
"gets",
"instantiated",
"once",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L453-L462 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.lookupObjectIdentities | private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup)
{
$ancestorIds = $this->getAncestorIds($batch);
if (!$ancestorIds) {
throw new AclNotFoundException('There is no ACL for the given object identity.');
}
$sql = $this->getLookupSql($ancestorIds);
$stmt = $this->connection->executeQuery($sql);
return $this->hydrateObjectIdentities($stmt, $oidLookup, $sids);
} | php | private function lookupObjectIdentities(array $batch, array $sids, array $oidLookup)
{
$ancestorIds = $this->getAncestorIds($batch);
if (!$ancestorIds) {
throw new AclNotFoundException('There is no ACL for the given object identity.');
}
$sql = $this->getLookupSql($ancestorIds);
$stmt = $this->connection->executeQuery($sql);
return $this->hydrateObjectIdentities($stmt, $oidLookup, $sids);
} | [
"private",
"function",
"lookupObjectIdentities",
"(",
"array",
"$",
"batch",
",",
"array",
"$",
"sids",
",",
"array",
"$",
"oidLookup",
")",
"{",
"$",
"ancestorIds",
"=",
"$",
"this",
"->",
"getAncestorIds",
"(",
"$",
"batch",
")",
";",
"if",
"(",
"!",
... | This method is called for object identities which could not be retrieved
from the cache, and for which thus a database query is required.
@param array $batch
@param array $sids
@param array $oidLookup
@return \SplObjectStorage mapping object identities to ACL instances
@throws AclNotFoundException | [
"This",
"method",
"is",
"called",
"for",
"object",
"identities",
"which",
"could",
"not",
"be",
"retrieved",
"from",
"the",
"cache",
"and",
"for",
"which",
"thus",
"a",
"database",
"query",
"is",
"required",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L476-L487 |
symfony/security-acl | Dbal/AclProvider.php | AclProvider.hydrateObjectIdentities | private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, array $sids)
{
$parentIdToFill = new \SplObjectStorage();
$acls = $aces = $emptyArray = array();
$oidCache = $oidLookup;
$result = new \SplObjectStorage();
$loadedAces = &$this->loadedAces;
$loadedAcls = &$this->loadedAcls;
$permissionGrantingStrategy = $this->permissionGrantingStrategy;
// we need these to set protected properties on hydrated objects
$aclReflection = new \ReflectionClass('Symfony\Component\Security\Acl\Domain\Acl');
$aclClassAcesProperty = $aclReflection->getProperty('classAces');
$aclClassAcesProperty->setAccessible(true);
$aclClassFieldAcesProperty = $aclReflection->getProperty('classFieldAces');
$aclClassFieldAcesProperty->setAccessible(true);
$aclObjectAcesProperty = $aclReflection->getProperty('objectAces');
$aclObjectAcesProperty->setAccessible(true);
$aclObjectFieldAcesProperty = $aclReflection->getProperty('objectFieldAces');
$aclObjectFieldAcesProperty->setAccessible(true);
$aclParentAclProperty = $aclReflection->getProperty('parentAcl');
$aclParentAclProperty->setAccessible(true);
// fetchAll() consumes more memory than consecutive calls to fetch(),
// but it is faster
foreach ($stmt->fetchAll(\PDO::FETCH_NUM) as $data) {
list($aclId,
$objectIdentifier,
$parentObjectIdentityId,
$entriesInheriting,
$classType,
$aceId,
$objectIdentityId,
$fieldName,
$aceOrder,
$mask,
$granting,
$grantingStrategy,
$auditSuccess,
$auditFailure,
$username,
$securityIdentifier) = array_values($data);
// has the ACL been hydrated during this hydration cycle?
if (isset($acls[$aclId])) {
$acl = $acls[$aclId];
// has the ACL been hydrated during any previous cycle, or was possibly loaded
// from cache?
} elseif (isset($loadedAcls[$classType][$objectIdentifier])) {
$acl = $loadedAcls[$classType][$objectIdentifier];
// keep reference in local array (saves us some hash calculations)
$acls[$aclId] = $acl;
// attach ACL to the result set; even though we do not enforce that every
// object identity has only one instance, we must make sure to maintain
// referential equality with the oids passed to findAcls()
$oidCacheKey = $objectIdentifier.$classType;
if (!isset($oidCache[$oidCacheKey])) {
$oidCache[$oidCacheKey] = $acl->getObjectIdentity();
}
$result->attach($oidCache[$oidCacheKey], $acl);
// so, this hasn't been hydrated yet
} else {
// create object identity if we haven't done so yet
$oidLookupKey = $objectIdentifier.$classType;
if (!isset($oidCache[$oidLookupKey])) {
$oidCache[$oidLookupKey] = new ObjectIdentity($objectIdentifier, $classType);
}
$acl = new Acl((int) $aclId, $oidCache[$oidLookupKey], $permissionGrantingStrategy, $emptyArray, (bool) $entriesInheriting);
// keep a local, and global reference to this ACL
$loadedAcls[$classType][$objectIdentifier] = $acl;
$acls[$aclId] = $acl;
// try to fill in parent ACL, or defer until all ACLs have been hydrated
if (null !== $parentObjectIdentityId) {
if (isset($acls[$parentObjectIdentityId])) {
$aclParentAclProperty->setValue($acl, $acls[$parentObjectIdentityId]);
} else {
$parentIdToFill->attach($acl, $parentObjectIdentityId);
}
}
$result->attach($oidCache[$oidLookupKey], $acl);
}
// check if this row contains an ACE record
if (null !== $aceId) {
// have we already hydrated ACEs for this ACL?
if (!isset($aces[$aclId])) {
$aces[$aclId] = array($emptyArray, $emptyArray, $emptyArray, $emptyArray);
}
// has this ACE already been hydrated during a previous cycle, or
// possible been loaded from cache?
// It is important to only ever have one ACE instance per actual row since
// some ACEs are shared between ACL instances
if (!isset($loadedAces[$aceId])) {
if (!isset($sids[$key = ($username ? '1' : '0').$securityIdentifier])) {
if ($username) {
$sids[$key] = new UserSecurityIdentity(
substr($securityIdentifier, 1 + $pos = strpos($securityIdentifier, '-')),
substr($securityIdentifier, 0, $pos)
);
} else {
$sids[$key] = new RoleSecurityIdentity($securityIdentifier);
}
}
if (null === $fieldName) {
$loadedAces[$aceId] = new Entry((int) $aceId, $acl, $sids[$key], $grantingStrategy, (int) $mask, (bool) $granting, (bool) $auditFailure, (bool) $auditSuccess);
} else {
$loadedAces[$aceId] = new FieldEntry((int) $aceId, $acl, $fieldName, $sids[$key], $grantingStrategy, (int) $mask, (bool) $granting, (bool) $auditFailure, (bool) $auditSuccess);
}
}
$ace = $loadedAces[$aceId];
// assign ACE to the correct property
if (null === $objectIdentityId) {
if (null === $fieldName) {
$aces[$aclId][0][$aceOrder] = $ace;
} else {
$aces[$aclId][1][$fieldName][$aceOrder] = $ace;
}
} else {
if (null === $fieldName) {
$aces[$aclId][2][$aceOrder] = $ace;
} else {
$aces[$aclId][3][$fieldName][$aceOrder] = $ace;
}
}
}
}
// We do not sort on database level since we only want certain subsets to be sorted,
// and we are going to read the entire result set anyway.
// Sorting on DB level increases query time by an order of magnitude while it is
// almost negligible when we use PHPs array sort functions.
foreach ($aces as $aclId => $aceData) {
$acl = $acls[$aclId];
ksort($aceData[0]);
$aclClassAcesProperty->setValue($acl, $aceData[0]);
foreach (array_keys($aceData[1]) as $fieldName) {
ksort($aceData[1][$fieldName]);
}
$aclClassFieldAcesProperty->setValue($acl, $aceData[1]);
ksort($aceData[2]);
$aclObjectAcesProperty->setValue($acl, $aceData[2]);
foreach (array_keys($aceData[3]) as $fieldName) {
ksort($aceData[3][$fieldName]);
}
$aclObjectFieldAcesProperty->setValue($acl, $aceData[3]);
}
// fill-in parent ACLs where this hasn't been done yet cause the parent ACL was not
// yet available
$processed = 0;
foreach ($parentIdToFill as $acl) {
$parentId = $parentIdToFill->offsetGet($acl);
// let's see if we have already hydrated this
if (isset($acls[$parentId])) {
$aclParentAclProperty->setValue($acl, $acls[$parentId]);
++$processed;
continue;
}
}
// reset reflection changes
$aclClassAcesProperty->setAccessible(false);
$aclClassFieldAcesProperty->setAccessible(false);
$aclObjectAcesProperty->setAccessible(false);
$aclObjectFieldAcesProperty->setAccessible(false);
$aclParentAclProperty->setAccessible(false);
// this should never be true if the database integrity hasn't been compromised
if ($processed < count($parentIdToFill)) {
throw new \RuntimeException('Not all parent ids were populated. This implies an integrity problem.');
}
return $result;
} | php | private function hydrateObjectIdentities(Statement $stmt, array $oidLookup, array $sids)
{
$parentIdToFill = new \SplObjectStorage();
$acls = $aces = $emptyArray = array();
$oidCache = $oidLookup;
$result = new \SplObjectStorage();
$loadedAces = &$this->loadedAces;
$loadedAcls = &$this->loadedAcls;
$permissionGrantingStrategy = $this->permissionGrantingStrategy;
// we need these to set protected properties on hydrated objects
$aclReflection = new \ReflectionClass('Symfony\Component\Security\Acl\Domain\Acl');
$aclClassAcesProperty = $aclReflection->getProperty('classAces');
$aclClassAcesProperty->setAccessible(true);
$aclClassFieldAcesProperty = $aclReflection->getProperty('classFieldAces');
$aclClassFieldAcesProperty->setAccessible(true);
$aclObjectAcesProperty = $aclReflection->getProperty('objectAces');
$aclObjectAcesProperty->setAccessible(true);
$aclObjectFieldAcesProperty = $aclReflection->getProperty('objectFieldAces');
$aclObjectFieldAcesProperty->setAccessible(true);
$aclParentAclProperty = $aclReflection->getProperty('parentAcl');
$aclParentAclProperty->setAccessible(true);
// fetchAll() consumes more memory than consecutive calls to fetch(),
// but it is faster
foreach ($stmt->fetchAll(\PDO::FETCH_NUM) as $data) {
list($aclId,
$objectIdentifier,
$parentObjectIdentityId,
$entriesInheriting,
$classType,
$aceId,
$objectIdentityId,
$fieldName,
$aceOrder,
$mask,
$granting,
$grantingStrategy,
$auditSuccess,
$auditFailure,
$username,
$securityIdentifier) = array_values($data);
// has the ACL been hydrated during this hydration cycle?
if (isset($acls[$aclId])) {
$acl = $acls[$aclId];
// has the ACL been hydrated during any previous cycle, or was possibly loaded
// from cache?
} elseif (isset($loadedAcls[$classType][$objectIdentifier])) {
$acl = $loadedAcls[$classType][$objectIdentifier];
// keep reference in local array (saves us some hash calculations)
$acls[$aclId] = $acl;
// attach ACL to the result set; even though we do not enforce that every
// object identity has only one instance, we must make sure to maintain
// referential equality with the oids passed to findAcls()
$oidCacheKey = $objectIdentifier.$classType;
if (!isset($oidCache[$oidCacheKey])) {
$oidCache[$oidCacheKey] = $acl->getObjectIdentity();
}
$result->attach($oidCache[$oidCacheKey], $acl);
// so, this hasn't been hydrated yet
} else {
// create object identity if we haven't done so yet
$oidLookupKey = $objectIdentifier.$classType;
if (!isset($oidCache[$oidLookupKey])) {
$oidCache[$oidLookupKey] = new ObjectIdentity($objectIdentifier, $classType);
}
$acl = new Acl((int) $aclId, $oidCache[$oidLookupKey], $permissionGrantingStrategy, $emptyArray, (bool) $entriesInheriting);
// keep a local, and global reference to this ACL
$loadedAcls[$classType][$objectIdentifier] = $acl;
$acls[$aclId] = $acl;
// try to fill in parent ACL, or defer until all ACLs have been hydrated
if (null !== $parentObjectIdentityId) {
if (isset($acls[$parentObjectIdentityId])) {
$aclParentAclProperty->setValue($acl, $acls[$parentObjectIdentityId]);
} else {
$parentIdToFill->attach($acl, $parentObjectIdentityId);
}
}
$result->attach($oidCache[$oidLookupKey], $acl);
}
// check if this row contains an ACE record
if (null !== $aceId) {
// have we already hydrated ACEs for this ACL?
if (!isset($aces[$aclId])) {
$aces[$aclId] = array($emptyArray, $emptyArray, $emptyArray, $emptyArray);
}
// has this ACE already been hydrated during a previous cycle, or
// possible been loaded from cache?
// It is important to only ever have one ACE instance per actual row since
// some ACEs are shared between ACL instances
if (!isset($loadedAces[$aceId])) {
if (!isset($sids[$key = ($username ? '1' : '0').$securityIdentifier])) {
if ($username) {
$sids[$key] = new UserSecurityIdentity(
substr($securityIdentifier, 1 + $pos = strpos($securityIdentifier, '-')),
substr($securityIdentifier, 0, $pos)
);
} else {
$sids[$key] = new RoleSecurityIdentity($securityIdentifier);
}
}
if (null === $fieldName) {
$loadedAces[$aceId] = new Entry((int) $aceId, $acl, $sids[$key], $grantingStrategy, (int) $mask, (bool) $granting, (bool) $auditFailure, (bool) $auditSuccess);
} else {
$loadedAces[$aceId] = new FieldEntry((int) $aceId, $acl, $fieldName, $sids[$key], $grantingStrategy, (int) $mask, (bool) $granting, (bool) $auditFailure, (bool) $auditSuccess);
}
}
$ace = $loadedAces[$aceId];
// assign ACE to the correct property
if (null === $objectIdentityId) {
if (null === $fieldName) {
$aces[$aclId][0][$aceOrder] = $ace;
} else {
$aces[$aclId][1][$fieldName][$aceOrder] = $ace;
}
} else {
if (null === $fieldName) {
$aces[$aclId][2][$aceOrder] = $ace;
} else {
$aces[$aclId][3][$fieldName][$aceOrder] = $ace;
}
}
}
}
// We do not sort on database level since we only want certain subsets to be sorted,
// and we are going to read the entire result set anyway.
// Sorting on DB level increases query time by an order of magnitude while it is
// almost negligible when we use PHPs array sort functions.
foreach ($aces as $aclId => $aceData) {
$acl = $acls[$aclId];
ksort($aceData[0]);
$aclClassAcesProperty->setValue($acl, $aceData[0]);
foreach (array_keys($aceData[1]) as $fieldName) {
ksort($aceData[1][$fieldName]);
}
$aclClassFieldAcesProperty->setValue($acl, $aceData[1]);
ksort($aceData[2]);
$aclObjectAcesProperty->setValue($acl, $aceData[2]);
foreach (array_keys($aceData[3]) as $fieldName) {
ksort($aceData[3][$fieldName]);
}
$aclObjectFieldAcesProperty->setValue($acl, $aceData[3]);
}
// fill-in parent ACLs where this hasn't been done yet cause the parent ACL was not
// yet available
$processed = 0;
foreach ($parentIdToFill as $acl) {
$parentId = $parentIdToFill->offsetGet($acl);
// let's see if we have already hydrated this
if (isset($acls[$parentId])) {
$aclParentAclProperty->setValue($acl, $acls[$parentId]);
++$processed;
continue;
}
}
// reset reflection changes
$aclClassAcesProperty->setAccessible(false);
$aclClassFieldAcesProperty->setAccessible(false);
$aclObjectAcesProperty->setAccessible(false);
$aclObjectFieldAcesProperty->setAccessible(false);
$aclParentAclProperty->setAccessible(false);
// this should never be true if the database integrity hasn't been compromised
if ($processed < count($parentIdToFill)) {
throw new \RuntimeException('Not all parent ids were populated. This implies an integrity problem.');
}
return $result;
} | [
"private",
"function",
"hydrateObjectIdentities",
"(",
"Statement",
"$",
"stmt",
",",
"array",
"$",
"oidLookup",
",",
"array",
"$",
"sids",
")",
"{",
"$",
"parentIdToFill",
"=",
"new",
"\\",
"SplObjectStorage",
"(",
")",
";",
"$",
"acls",
"=",
"$",
"aces",... | This method is called to hydrate ACLs and ACEs.
This method was designed for performance; thus, a lot of code has been
inlined at the cost of readability, and maintainability.
Keep in mind that changes to this method might severely reduce the
performance of the entire ACL system.
@param Statement $stmt
@param array $oidLookup
@param array $sids
@return \SplObjectStorage
@throws \RuntimeException | [
"This",
"method",
"is",
"called",
"to",
"hydrate",
"ACLs",
"and",
"ACEs",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Dbal/AclProvider.php#L506-L694 |
symfony/security-acl | Domain/AuditLogger.php | AuditLogger.logIfNeeded | public function logIfNeeded($granted, EntryInterface $ace)
{
if (!$ace instanceof AuditableEntryInterface) {
return;
}
if ($granted && $ace->isAuditSuccess()) {
$this->doLog($granted, $ace);
} elseif (!$granted && $ace->isAuditFailure()) {
$this->doLog($granted, $ace);
}
} | php | public function logIfNeeded($granted, EntryInterface $ace)
{
if (!$ace instanceof AuditableEntryInterface) {
return;
}
if ($granted && $ace->isAuditSuccess()) {
$this->doLog($granted, $ace);
} elseif (!$granted && $ace->isAuditFailure()) {
$this->doLog($granted, $ace);
}
} | [
"public",
"function",
"logIfNeeded",
"(",
"$",
"granted",
",",
"EntryInterface",
"$",
"ace",
")",
"{",
"if",
"(",
"!",
"$",
"ace",
"instanceof",
"AuditableEntryInterface",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"granted",
"&&",
"$",
"ace",
"->",
... | Performs some checks if logging was requested.
@param bool $granted
@param EntryInterface $ace | [
"Performs",
"some",
"checks",
"if",
"logging",
"was",
"requested",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/AuditLogger.php#L31-L42 |
symfony/security-acl | Domain/Entry.php | Entry.serialize | public function serialize()
{
return serialize(array(
$this->mask,
$this->id,
$this->securityIdentity,
$this->strategy,
$this->auditFailure,
$this->auditSuccess,
$this->granting,
));
} | php | public function serialize()
{
return serialize(array(
$this->mask,
$this->id,
$this->securityIdentity,
$this->strategy,
$this->auditFailure,
$this->auditSuccess,
$this->granting,
));
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"return",
"serialize",
"(",
"array",
"(",
"$",
"this",
"->",
"mask",
",",
"$",
"this",
"->",
"id",
",",
"$",
"this",
"->",
"securityIdentity",
",",
"$",
"this",
"->",
"strategy",
",",
"$",
"this",
"->... | Implementation of \Serializable.
@return string | [
"Implementation",
"of",
"\\",
"Serializable",
"."
] | train | https://github.com/symfony/security-acl/blob/22928f6be80a37f301500c67e50f57f5b25ffaa8/Domain/Entry.php#L179-L190 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.