repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.validateInternalConflictingStrategy | public static function validateInternalConflictingStrategy($conflictingInternalUrlStrategy)
{
if (!in_array($conflictingInternalUrlStrategy, [self::STRATEGY_IGNORE, self::STRATEGY_MOVE_PREVIOUS_TO_NEW, self::STRATEGY_MOVE_NEW_TO_PREVIOUS])) {
throw new \InvalidArgumentException("Invalid \$conflictingInternalUrlStrategy '$conflictingInternalUrlStrategy'");
}
} | php | public static function validateInternalConflictingStrategy($conflictingInternalUrlStrategy)
{
if (!in_array($conflictingInternalUrlStrategy, [self::STRATEGY_IGNORE, self::STRATEGY_MOVE_PREVIOUS_TO_NEW, self::STRATEGY_MOVE_NEW_TO_PREVIOUS])) {
throw new \InvalidArgumentException("Invalid \$conflictingInternalUrlStrategy '$conflictingInternalUrlStrategy'");
}
} | [
"public",
"static",
"function",
"validateInternalConflictingStrategy",
"(",
"$",
"conflictingInternalUrlStrategy",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"conflictingInternalUrlStrategy",
",",
"[",
"self",
"::",
"STRATEGY_IGNORE",
",",
"self",
"::",
"STRATEGY... | Assert if the strategy is ok when the internal url already has a public url.
@param string $conflictingInternalUrlStrategy
@return void | [
"Assert",
"if",
"the",
"strategy",
"is",
"ok",
"when",
"the",
"internal",
"url",
"already",
"has",
"a",
"public",
"url",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L104-L109 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.hasInternalAlias | public function hasInternalAlias($publicUrl, $asObject = false, $mode = null)
{
$ret = null;
if (isset($this->batch[$publicUrl])) {
$alias = $this->batch[$publicUrl];
} else {
$alias = $this->repository->findOneByPublicUrl($publicUrl, $mode);
}
if ($alias) {
$ret = ($asObject ? $alias : $alias->getInternalUrl());
}
return $ret;
} | php | public function hasInternalAlias($publicUrl, $asObject = false, $mode = null)
{
$ret = null;
if (isset($this->batch[$publicUrl])) {
$alias = $this->batch[$publicUrl];
} else {
$alias = $this->repository->findOneByPublicUrl($publicUrl, $mode);
}
if ($alias) {
$ret = ($asObject ? $alias : $alias->getInternalUrl());
}
return $ret;
} | [
"public",
"function",
"hasInternalAlias",
"(",
"$",
"publicUrl",
",",
"$",
"asObject",
"=",
"false",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"batch",
"[",
"$",
"publicUrl",
... | Checks if the passed public url is currently mapped to an internal url
@param string $publicUrl
@param bool $asObject
@param null|integer $mode
@return null|string|UrlAlias | [
"Checks",
"if",
"the",
"passed",
"public",
"url",
"is",
"currently",
"mapped",
"to",
"an",
"internal",
"url"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L119-L132 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.hasPublicAlias | public function hasPublicAlias($internalUrl, $asObject = false, $mode = UrlAlias::REWRITE)
{
$ret = null;
if ($alias = $this->repository->findOneByInternalUrl($internalUrl, $mode)) {
$ret = ($asObject ? $alias : $alias->getPublicUrl());
}
return $ret;
} | php | public function hasPublicAlias($internalUrl, $asObject = false, $mode = UrlAlias::REWRITE)
{
$ret = null;
if ($alias = $this->repository->findOneByInternalUrl($internalUrl, $mode)) {
$ret = ($asObject ? $alias : $alias->getPublicUrl());
}
return $ret;
} | [
"public",
"function",
"hasPublicAlias",
"(",
"$",
"internalUrl",
",",
"$",
"asObject",
"=",
"false",
",",
"$",
"mode",
"=",
"UrlAlias",
"::",
"REWRITE",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"if",
"(",
"$",
"alias",
"=",
"$",
"this",
"->",
"reposit... | Check if the passed internal URL has a public url alias.
@param string $internalUrl
@param bool $asObject
@param integer $mode
@return null|string|UrlAlias | [
"Check",
"if",
"the",
"passed",
"internal",
"URL",
"has",
"a",
"public",
"url",
"alias",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L143-L152 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.findAlias | public function findAlias($publicUrl, $internalUrl)
{
$ret = null;
$params = ['public_url' => $publicUrl, 'internal_url' => $internalUrl];
if ($alias = $this->getRepository()->findOneBy($params)) {
$ret = $alias;
}
return $ret;
} | php | public function findAlias($publicUrl, $internalUrl)
{
$ret = null;
$params = ['public_url' => $publicUrl, 'internal_url' => $internalUrl];
if ($alias = $this->getRepository()->findOneBy($params)) {
$ret = $alias;
}
return $ret;
} | [
"public",
"function",
"findAlias",
"(",
"$",
"publicUrl",
",",
"$",
"internalUrl",
")",
"{",
"$",
"ret",
"=",
"null",
";",
"$",
"params",
"=",
"[",
"'public_url'",
"=>",
"$",
"publicUrl",
",",
"'internal_url'",
"=>",
"$",
"internalUrl",
"]",
";",
"if",
... | Find an alias matching both public and internal url
@param string $publicUrl
@param string $internalUrl
@return null|UrlAlias | [
"Find",
"an",
"alias",
"matching",
"both",
"public",
"and",
"internal",
"url"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L161-L171 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.save | protected function save(UrlAlias $alias)
{
$this->manager->persist($alias);
if ($this->isBatch) {
$this->batch[$alias->getPublicUrl()] = $alias;
} else {
$this->manager->flush($alias);
}
} | php | protected function save(UrlAlias $alias)
{
$this->manager->persist($alias);
if ($this->isBatch) {
$this->batch[$alias->getPublicUrl()] = $alias;
} else {
$this->manager->flush($alias);
}
} | [
"protected",
"function",
"save",
"(",
"UrlAlias",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"manager",
"->",
"persist",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isBatch",
")",
"{",
"$",
"this",
"->",
"batch",
"[",
"$",
"alias",
... | Persist the URL alias.
@param \Zicht\Bundle\UrlBundle\Entity\UrlAlias $alias
@return void | [
"Persist",
"the",
"URL",
"alias",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L384-L393 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php | Aliasing.mapContent | public function mapContent($contentType, $mode, $content, $hosts)
{
$rewriter = new Rewriter($this);
$rewriter->setLocalDomains($hosts);
foreach ($this->contentMappers as $mapper) {
if ($mapper->supports($contentType)) {
return $mapper->processAliasing($content, $mode, $rewriter);
}
}
return $content;
} | php | public function mapContent($contentType, $mode, $content, $hosts)
{
$rewriter = new Rewriter($this);
$rewriter->setLocalDomains($hosts);
foreach ($this->contentMappers as $mapper) {
if ($mapper->supports($contentType)) {
return $mapper->processAliasing($content, $mode, $rewriter);
}
}
return $content;
} | [
"public",
"function",
"mapContent",
"(",
"$",
"contentType",
",",
"$",
"mode",
",",
"$",
"content",
",",
"$",
"hosts",
")",
"{",
"$",
"rewriter",
"=",
"new",
"Rewriter",
"(",
"$",
"this",
")",
";",
"$",
"rewriter",
"->",
"setLocalDomains",
"(",
"$",
... | Transform internal URLS to public URLS using our defined mappers
@param string $contentType
@param string $mode
@param string $content
@param string[] $hosts
@return string | [
"Transform",
"internal",
"URLS",
"to",
"public",
"URLS",
"using",
"our",
"defined",
"mappers"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L485-L497 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Rewriter.php | Rewriter.extractPath | public function extractPath($url)
{
$parts = $this->parseUrl($url);
if (!isset($parts['path'])) {
return null;
}
// ignore non-http schemes
if (isset($parts['scheme']) && !in_array($parts['scheme'], ['http', 'https'])) {
return null;
}
return $parts['path'];
} | php | public function extractPath($url)
{
$parts = $this->parseUrl($url);
if (!isset($parts['path'])) {
return null;
}
// ignore non-http schemes
if (isset($parts['scheme']) && !in_array($parts['scheme'], ['http', 'https'])) {
return null;
}
return $parts['path'];
} | [
"public",
"function",
"extractPath",
"(",
"$",
"url",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"parseUrl",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parts",
"[",
"'path'",
"]",
")",
")",
"{",
"return",
"null",
";",
"... | Extract the path of the URL which is considered for aliasing.
@param string $url
@return string|null | [
"Extract",
"the",
"path",
"of",
"the",
"URL",
"which",
"is",
"considered",
"for",
"aliasing",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Rewriter.php#L130-L143 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.transMultiple | public function transMultiple($messages, $parameters = [], $domain = null, $locale = null)
{
foreach ($messages as $message) {
yield $this->translator->trans($message, $parameters, $domain, $locale);
}
} | php | public function transMultiple($messages, $parameters = [], $domain = null, $locale = null)
{
foreach ($messages as $message) {
yield $this->translator->trans($message, $parameters, $domain, $locale);
}
} | [
"public",
"function",
"transMultiple",
"(",
"$",
"messages",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"domain",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"message",
")",
"{",
"yield",
... | Translate multiple strings
@param array $messages
@param array $parameters
@param null $domain
@param null $locale
@return \Generator | [
"Translate",
"multiple",
"strings"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L177-L182 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.formHasErrors | public function formHasErrors(FormView $form)
{
if ($form->vars['errors']->count()) {
return true;
}
foreach ($form->children as $child) {
if ($this->formHasErrors($child)) {
return true;
}
}
return false;
} | php | public function formHasErrors(FormView $form)
{
if ($form->vars['errors']->count()) {
return true;
}
foreach ($form->children as $child) {
if ($this->formHasErrors($child)) {
return true;
}
}
return false;
} | [
"public",
"function",
"formHasErrors",
"(",
"FormView",
"$",
"form",
")",
"{",
"if",
"(",
"$",
"form",
"->",
"vars",
"[",
"'errors'",
"]",
"->",
"count",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"form",
"->",
"children",
... | Returns true when the form, or any of its children, has one or more errors.
@param FormView $form
@return bool | [
"Returns",
"true",
"when",
"the",
"form",
"or",
"any",
"of",
"its",
"children",
"has",
"one",
"or",
"more",
"errors",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L202-L215 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.jsonDecode | public function jsonDecode($string, $assoc = false)
{
if (is_string($string)) {
return json_decode($string, $assoc);
}
return null;
} | php | public function jsonDecode($string, $assoc = false)
{
if (is_string($string)) {
return json_decode($string, $assoc);
}
return null;
} | [
"public",
"function",
"jsonDecode",
"(",
"$",
"string",
",",
"$",
"assoc",
"=",
"false",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"string",
")",
")",
"{",
"return",
"json_decode",
"(",
"$",
"string",
",",
"$",
"assoc",
")",
";",
"}",
"return",
"... | Call the php json_decode
@param string $string
@param bool $assoc
@return mixed|null | [
"Call",
"the",
"php",
"json_decode"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L224-L230 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.where | public function where($items, array $keyValuePairs, $comparator = 'eq', $booleanOperator = 'and')
{
if (is_array($items)) {
$items = new ArrayCollection($items);
}
if ($items instanceof PersistentCollection && !$items->isInitialized()) {
$items->initialize();
}
$whereMethod = $booleanOperator . 'Where';
$eb = new ExpressionBuilder();
$criteria = new Criteria();
foreach ($keyValuePairs as $key => $value) {
if (is_array($value)) {
if ($comparator === 'eq') {
$criteria->$whereMethod($eb->in($key, $value));
continue;
} elseif ($comparator === 'neq') {
$criteria->$whereMethod($eb->notIn($key, $value));
continue;
}
}
$criteria->$whereMethod($eb->$comparator($key, $value));
}
return $items->matching($criteria);
} | php | public function where($items, array $keyValuePairs, $comparator = 'eq', $booleanOperator = 'and')
{
if (is_array($items)) {
$items = new ArrayCollection($items);
}
if ($items instanceof PersistentCollection && !$items->isInitialized()) {
$items->initialize();
}
$whereMethod = $booleanOperator . 'Where';
$eb = new ExpressionBuilder();
$criteria = new Criteria();
foreach ($keyValuePairs as $key => $value) {
if (is_array($value)) {
if ($comparator === 'eq') {
$criteria->$whereMethod($eb->in($key, $value));
continue;
} elseif ($comparator === 'neq') {
$criteria->$whereMethod($eb->notIn($key, $value));
continue;
}
}
$criteria->$whereMethod($eb->$comparator($key, $value));
}
return $items->matching($criteria);
} | [
"public",
"function",
"where",
"(",
"$",
"items",
",",
"array",
"$",
"keyValuePairs",
",",
"$",
"comparator",
"=",
"'eq'",
",",
"$",
"booleanOperator",
"=",
"'and'",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"items",
")",
")",
"{",
"$",
"items",
"="... | Filter a collection based on properties of the collection's items
@param array|Collection $items
@param array $keyValuePairs
@param string $comparator
@param string $booleanOperator
@return \Doctrine\Common\Collections\Collection | [
"Filter",
"a",
"collection",
"based",
"on",
"properties",
"of",
"the",
"collection",
"s",
"items"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L256-L283 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.whereSplit | public function whereSplit($items, $keyValuePairs)
{
return array(
$this->notWhere($items, $keyValuePairs),
$this->where($items, $keyValuePairs)
);
} | php | public function whereSplit($items, $keyValuePairs)
{
return array(
$this->notWhere($items, $keyValuePairs),
$this->where($items, $keyValuePairs)
);
} | [
"public",
"function",
"whereSplit",
"(",
"$",
"items",
",",
"$",
"keyValuePairs",
")",
"{",
"return",
"array",
"(",
"$",
"this",
"->",
"notWhere",
"(",
"$",
"items",
",",
"$",
"keyValuePairs",
")",
",",
"$",
"this",
"->",
"where",
"(",
"$",
"items",
... | Splits a list in two collections, one matching the criteria, and the rest
@param array|Collection $items
@param array $keyValuePairs
@return array | [
"Splits",
"a",
"list",
"in",
"two",
"collections",
"one",
"matching",
"the",
"criteria",
"and",
"the",
"rest"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L304-L310 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.urlToFormParameters | public function urlToFormParameters($url)
{
$query = parse_url($url, PHP_URL_QUERY);
$vars = array();
parse_str($query, $vars);
return $this->valuesToFormParameters($vars, null);
} | php | public function urlToFormParameters($url)
{
$query = parse_url($url, PHP_URL_QUERY);
$vars = array();
parse_str($query, $vars);
return $this->valuesToFormParameters($vars, null);
} | [
"public",
"function",
"urlToFormParameters",
"(",
"$",
"url",
")",
"{",
"$",
"query",
"=",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_QUERY",
")",
";",
"$",
"vars",
"=",
"array",
"(",
")",
";",
"parse_str",
"(",
"$",
"query",
",",
"$",
"vars",
")",
... | Url to form parameters
@param string $url
@return array | [
"Url",
"to",
"form",
"parameters"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L338-L344 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.valuesToFormParameters | private function valuesToFormParameters($values, $parent)
{
$ret = array();
foreach ($values as $key => $value) {
if (null !== $parent) {
$keyName = sprintf('%s[%s]', $parent, $key);
} else {
$keyName = $key;
}
if (is_scalar($value)) {
$ret[$keyName] = $value;
} else {
$ret = array_merge($ret, $this->valuesToFormParameters($value, $keyName));
}
}
return $ret;
} | php | private function valuesToFormParameters($values, $parent)
{
$ret = array();
foreach ($values as $key => $value) {
if (null !== $parent) {
$keyName = sprintf('%s[%s]', $parent, $key);
} else {
$keyName = $key;
}
if (is_scalar($value)) {
$ret[$keyName] = $value;
} else {
$ret = array_merge($ret, $this->valuesToFormParameters($value, $keyName));
}
}
return $ret;
} | [
"private",
"function",
"valuesToFormParameters",
"(",
"$",
"values",
",",
"$",
"parent",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"!==",
"$"... | Prepares a nested array for use in form fields.
@param mixed[] $values
@param string $parent
@return array | [
"Prepares",
"a",
"nested",
"array",
"for",
"use",
"in",
"form",
"fields",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L353-L369 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.embeddedImage | public function embeddedImage($filename)
{
if (is_file($filename) && preg_match('/[.](?P<extension>[a-zA-Z0-9]+)$/', $filename, $matches)) {
return sprintf('data:image/%s;base64,%s', $matches['extension'], base64_encode(file_get_contents($filename)));
}
return null;
} | php | public function embeddedImage($filename)
{
if (is_file($filename) && preg_match('/[.](?P<extension>[a-zA-Z0-9]+)$/', $filename, $matches)) {
return sprintf('data:image/%s;base64,%s', $matches['extension'], base64_encode(file_get_contents($filename)));
}
return null;
} | [
"public",
"function",
"embeddedImage",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"filename",
")",
"&&",
"preg_match",
"(",
"'/[.](?P<extension>[a-zA-Z0-9]+)$/'",
",",
"$",
"filename",
",",
"$",
"matches",
")",
")",
"{",
"return",
"sprin... | Given an existing file, returns an embedded data stream, or null when the file does not exist
For example
{{ embedded_image('foo.jpg') }}
--> "data:image/jpg;base64,BLABLABLA"
@param string $filename
@return null|string | [
"Given",
"an",
"existing",
"file",
"returns",
"an",
"embedded",
"data",
"stream",
"or",
"null",
"when",
"the",
"file",
"does",
"not",
"exist"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L396-L403 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.isGranted | public function isGranted($role, $object = null, $field = null)
{
if (null !== $field) {
$object = new FieldVote($object, $field);
}
return $this->authChecker->isGranted($role, $object);
} | php | public function isGranted($role, $object = null, $field = null)
{
if (null !== $field) {
$object = new FieldVote($object, $field);
}
return $this->authChecker->isGranted($role, $object);
} | [
"public",
"function",
"isGranted",
"(",
"$",
"role",
",",
"$",
"object",
"=",
"null",
",",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"field",
")",
"{",
"$",
"object",
"=",
"new",
"FieldVote",
"(",
"$",
"object",
",",
"$"... | The template may assume that the role will be denied when there is no security context, therefore we override
the default behaviour here.
@param string $role
@param mixed $object
@param mixed $field
@return bool | [
"The",
"template",
"may",
"assume",
"that",
"the",
"role",
"will",
"be",
"denied",
"when",
"there",
"is",
"no",
"security",
"context",
"therefore",
"we",
"override",
"the",
"default",
"behaviour",
"here",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L414-L420 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.gaTrackEvent | public function gaTrackEvent($values = null)
{
$values = func_get_args();
array_unshift($values, '_trackEvent');
return sprintf(
' onclick="_gaq.push(%s);"',
htmlspecialchars(json_encode(array_values($values)))
);
} | php | public function gaTrackEvent($values = null)
{
$values = func_get_args();
array_unshift($values, '_trackEvent');
return sprintf(
' onclick="_gaq.push(%s);"',
htmlspecialchars(json_encode(array_values($values)))
);
} | [
"public",
"function",
"gaTrackEvent",
"(",
"$",
"values",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"func_get_args",
"(",
")",
";",
"array_unshift",
"(",
"$",
"values",
",",
"'_trackEvent'",
")",
";",
"return",
"sprintf",
"(",
"' onclick=\"_gaq.push(%s);\"'",... | Formats some values as an 'onclick' attribute for Google Analytics
@param null $values
@return string | [
"Formats",
"some",
"values",
"as",
"an",
"onclick",
"attribute",
"for",
"Google",
"Analytics"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L447-L456 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.sortByType | public function sortByType($collection, $types)
{
if ($collection instanceof \Traversable) {
$collection = iterator_to_array($collection);
}
// store a map of the original sorting, so the usort can use this to keep the original sorting if the types are
// equal
$idToIndexMap = array();
foreach ($collection as $index => $item) {
$idToIndexMap[$item->getId()] = $index;
}
$numTypes = count($types);
usort(
$collection,
function ($left, $right) use ($types, $idToIndexMap, $numTypes) {
$localClassNameLeft = Str::classname(get_class($left));
$localClassNameRight = Str::classname(get_class($right));
// if same type, use original sorting
if ($localClassNameRight === $localClassNameLeft) {
$indexLeft = $idToIndexMap[$left->getId()];
$indexRight = $idToIndexMap[$right->getId()];
} else {
$indexLeft = array_search($localClassNameLeft, $types);
$indexRight = array_search($localClassNameRight, $types);
// assume that types that aren't defined, should come last.
if (false === $indexLeft) {
$indexLeft = $numTypes + 1;
}
if (false === $indexRight) {
$indexRight = $numTypes + 1;
}
}
if ($indexLeft < $indexRight) {
return -1;
}
if ($indexLeft > $indexRight) {
return 1;
}
return 0;
}
);
return $collection;
} | php | public function sortByType($collection, $types)
{
if ($collection instanceof \Traversable) {
$collection = iterator_to_array($collection);
}
// store a map of the original sorting, so the usort can use this to keep the original sorting if the types are
// equal
$idToIndexMap = array();
foreach ($collection as $index => $item) {
$idToIndexMap[$item->getId()] = $index;
}
$numTypes = count($types);
usort(
$collection,
function ($left, $right) use ($types, $idToIndexMap, $numTypes) {
$localClassNameLeft = Str::classname(get_class($left));
$localClassNameRight = Str::classname(get_class($right));
// if same type, use original sorting
if ($localClassNameRight === $localClassNameLeft) {
$indexLeft = $idToIndexMap[$left->getId()];
$indexRight = $idToIndexMap[$right->getId()];
} else {
$indexLeft = array_search($localClassNameLeft, $types);
$indexRight = array_search($localClassNameRight, $types);
// assume that types that aren't defined, should come last.
if (false === $indexLeft) {
$indexLeft = $numTypes + 1;
}
if (false === $indexRight) {
$indexRight = $numTypes + 1;
}
}
if ($indexLeft < $indexRight) {
return -1;
}
if ($indexLeft > $indexRight) {
return 1;
}
return 0;
}
);
return $collection;
} | [
"public",
"function",
"sortByType",
"(",
"$",
"collection",
",",
"$",
"types",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"\\",
"Traversable",
")",
"{",
"$",
"collection",
"=",
"iterator_to_array",
"(",
"$",
"collection",
")",
";",
"}",
"// stor... | Sort by type
@param array|object $collection
@param array $types
@return array | [
"Sort",
"by",
"type"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L465-L514 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.strDash | public function strDash($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::dash($str);
} | php | public function strDash($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::dash($str);
} | [
"public",
"function",
"strDash",
"(",
"$",
"str",
",",
"$",
"camelFirst",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"camelFirst",
")",
"{",
"$",
"str",
"=",
"StrUtil",
"::",
"camel",
"(",
"$",
"str",
")",
";",
"}",
"return",
"StrUtil",
"::",
"dash",
... | Dash to CamelCase
@param string $str
@param bool $camelFirst
@return string | [
"Dash",
"to",
"CamelCase"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L523-L529 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.strUscore | public function strUscore($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::uscore($str);
} | php | public function strUscore($str, $camelFirst = true)
{
if ($camelFirst) {
$str = StrUtil::camel($str);
}
return StrUtil::uscore($str);
} | [
"public",
"function",
"strUscore",
"(",
"$",
"str",
",",
"$",
"camelFirst",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"camelFirst",
")",
"{",
"$",
"str",
"=",
"StrUtil",
"::",
"camel",
"(",
"$",
"str",
")",
";",
"}",
"return",
"StrUtil",
"::",
"uscore... | CamelCased to under_score
@param string $str
@param bool $camelFirst
@return string | [
"CamelCased",
"to",
"under_score"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L538-L544 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.truncate | public function truncate($str, $length, $ellipsis = '...')
{
$result = '';
foreach (preg_split('/\b/U', $str) as $part) {
if (strlen($result . $part) > $length) {
$result = rtrim($result) . $ellipsis;
break;
} else {
$result .= $part;
}
}
return $result;
} | php | public function truncate($str, $length, $ellipsis = '...')
{
$result = '';
foreach (preg_split('/\b/U', $str) as $part) {
if (strlen($result . $part) > $length) {
$result = rtrim($result) . $ellipsis;
break;
} else {
$result .= $part;
}
}
return $result;
} | [
"public",
"function",
"truncate",
"(",
"$",
"str",
",",
"$",
"length",
",",
"$",
"ellipsis",
"=",
"'...'",
")",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"preg_split",
"(",
"'/\\b/U'",
",",
"$",
"str",
")",
"as",
"$",
"part",
")",
"{",
... | Truncate text at a maximum length, splitting by words, and add an ellipsis "...".
@param string $str
@param int $length
@param string $ellipsis
@return string | [
"Truncate",
"text",
"at",
"a",
"maximum",
"length",
"splitting",
"by",
"words",
"and",
"add",
"an",
"ellipsis",
"...",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L650-L663 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.truncateHtml | public function truncateHtml($html, $length, $ellipsis = '...')
{
return $this->truncate(html_entity_decode(strip_tags($html), null, 'UTF-8'), $length, $ellipsis);
} | php | public function truncateHtml($html, $length, $ellipsis = '...')
{
return $this->truncate(html_entity_decode(strip_tags($html), null, 'UTF-8'), $length, $ellipsis);
} | [
"public",
"function",
"truncateHtml",
"(",
"$",
"html",
",",
"$",
"length",
",",
"$",
"ellipsis",
"=",
"'...'",
")",
"{",
"return",
"$",
"this",
"->",
"truncate",
"(",
"html_entity_decode",
"(",
"strip_tags",
"(",
"$",
"html",
")",
",",
"null",
",",
"'... | Truncates html as text
@param string $html
@param int $length
@param string $ellipsis
@return string | [
"Truncates",
"html",
"as",
"text"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L673-L676 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php | Extension.dump | public function dump($var, $mode = null)
{
if (null === $mode && class_exists('Zicht\Util\Debug')) {
return htmlspecialchars(Debug::dump($var));
} else {
switch ($mode) {
case 'export':
VarDumper::dump($var);
break;
default:
var_dump($var);
break;
}
}
return null;
} | php | public function dump($var, $mode = null)
{
if (null === $mode && class_exists('Zicht\Util\Debug')) {
return htmlspecialchars(Debug::dump($var));
} else {
switch ($mode) {
case 'export':
VarDumper::dump($var);
break;
default:
var_dump($var);
break;
}
}
return null;
} | [
"public",
"function",
"dump",
"(",
"$",
"var",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"mode",
"&&",
"class_exists",
"(",
"'Zicht\\Util\\Debug'",
")",
")",
"{",
"return",
"htmlspecialchars",
"(",
"Debug",
"::",
"dump",
"... | Dumps given variable in styled format
@param mixed $var
@param string $mode
@return mixed | [
"Dumps",
"given",
"variable",
"in",
"styled",
"format"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php#L773-L788 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Entity/Repository/StaticReferenceRepository.php | StaticReferenceRepository.getAll | public function getAll($locale)
{
$qb = $this->createQueryBuilder('r');
$qb->addSelect('t');
$qb->innerJoin('r.translations', 't');
$qb->andWhere('t.locale=:locale');
$qb->setParameter(':locale', $locale);
return $qb->getQuery()->execute();
} | php | public function getAll($locale)
{
$qb = $this->createQueryBuilder('r');
$qb->addSelect('t');
$qb->innerJoin('r.translations', 't');
$qb->andWhere('t.locale=:locale');
$qb->setParameter(':locale', $locale);
return $qb->getQuery()->execute();
} | [
"public",
"function",
"getAll",
"(",
"$",
"locale",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'r'",
")",
";",
"$",
"qb",
"->",
"addSelect",
"(",
"'t'",
")",
";",
"$",
"qb",
"->",
"innerJoin",
"(",
"'r.translations'",
",... | Returns the references for the specified locale
@param string $locale
@return mixed | [
"Returns",
"the",
"references",
"for",
"the",
"specified",
"locale"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Entity/Repository/StaticReferenceRepository.php#L20-L30 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php | AbstractAliasingTransformer.transform | public function transform($data)
{
if (self::MODE_TO_PUBLIC === (self::MODE_TO_PUBLIC & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC);
} else {
return $data;
}
} | php | public function transform($data)
{
if (self::MODE_TO_PUBLIC === (self::MODE_TO_PUBLIC & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC);
} else {
return $data;
}
} | [
"public",
"function",
"transform",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"self",
"::",
"MODE_TO_PUBLIC",
"===",
"(",
"self",
"::",
"MODE_TO_PUBLIC",
"&",
"$",
"this",
"->",
"mode",
")",
")",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"data",... | Transforms a string containing internal urls to string to public urls.
@param string $data
@return null|string | [
"Transforms",
"a",
"string",
"containing",
"internal",
"urls",
"to",
"string",
"to",
"public",
"urls",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php#L45-L52 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php | AbstractAliasingTransformer.reverseTransform | public function reverseTransform($data)
{
if (self::MODE_TO_INTERNAL === (self::MODE_TO_INTERNAL & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_PUBLIC_TO_INTERNAL);
} else {
return $data;
}
} | php | public function reverseTransform($data)
{
if (self::MODE_TO_INTERNAL === (self::MODE_TO_INTERNAL & $this->mode)) {
return $this->map($data, UrlMapperInterface::MODE_PUBLIC_TO_INTERNAL);
} else {
return $data;
}
} | [
"public",
"function",
"reverseTransform",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"self",
"::",
"MODE_TO_INTERNAL",
"===",
"(",
"self",
"::",
"MODE_TO_INTERNAL",
"&",
"$",
"this",
"->",
"mode",
")",
")",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$"... | Tranforms a string containing public urls to string with internal urls.
@param string $data
@return null|string | [
"Tranforms",
"a",
"string",
"containing",
"public",
"urls",
"to",
"string",
"with",
"internal",
"urls",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php#L60-L67 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php | AbstractAliasingTransformer.map | final public function map($data, $mode)
{
if (null === $data) {
return $data;
}
return $this->doMap($data, $mode);
} | php | final public function map($data, $mode)
{
if (null === $data) {
return $data;
}
return $this->doMap($data, $mode);
} | [
"final",
"public",
"function",
"map",
"(",
"$",
"data",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"data",
")",
"{",
"return",
"$",
"data",
";",
"}",
"return",
"$",
"this",
"->",
"doMap",
"(",
"$",
"data",
",",
"$",
"mode",
")",... | Wraps the doMap to defend for the 'null'-value case
@param string $data
@param string $mode
@return string | [
"Wraps",
"the",
"doMap",
"to",
"defend",
"for",
"the",
"null",
"-",
"value",
"case"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/AbstractAliasingTransformer.php#L76-L83 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Admin/AliasOverviewType.php | AliasOverviewType.getUrlAliases | protected function getUrlAliases($object)
{
try {
$internalUrl = $this->provider->url($object);
} catch (UnsupportedException $exception) {
return [];
}
return $this
->doctrine
->getRepository('ZichtUrlBundle:UrlAlias')
->findAllByInternalUrl($internalUrl);
} | php | protected function getUrlAliases($object)
{
try {
$internalUrl = $this->provider->url($object);
} catch (UnsupportedException $exception) {
return [];
}
return $this
->doctrine
->getRepository('ZichtUrlBundle:UrlAlias')
->findAllByInternalUrl($internalUrl);
} | [
"protected",
"function",
"getUrlAliases",
"(",
"$",
"object",
")",
"{",
"try",
"{",
"$",
"internalUrl",
"=",
"$",
"this",
"->",
"provider",
"->",
"url",
"(",
"$",
"object",
")",
";",
"}",
"catch",
"(",
"UnsupportedException",
"$",
"exception",
")",
"{",
... | Returns all UrlAlias entities associated to an object
@param mixed $object
@return mixed | [
"Returns",
"all",
"UrlAlias",
"entities",
"associated",
"to",
"an",
"object"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Admin/AliasOverviewType.php#L88-L100 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Form/DataTransformer/TextTransformer.php | TextTransformer.doMap | protected function doMap($text, $mode)
{
$map = $this->aliasing->getAliasingMap([$text], $mode);
if (count($map) === 1) {
return current($map);
}
return $text;
} | php | protected function doMap($text, $mode)
{
$map = $this->aliasing->getAliasingMap([$text], $mode);
if (count($map) === 1) {
return current($map);
}
return $text;
} | [
"protected",
"function",
"doMap",
"(",
"$",
"text",
",",
"$",
"mode",
")",
"{",
"$",
"map",
"=",
"$",
"this",
"->",
"aliasing",
"->",
"getAliasingMap",
"(",
"[",
"$",
"text",
"]",
",",
"$",
"mode",
")",
";",
"if",
"(",
"count",
"(",
"$",
"map",
... | Delegates the text mapping to the aliasing service.
@param string $text
@param string $mode
@return mixed|null | [
"Delegates",
"the",
"text",
"mapping",
"to",
"the",
"aliasing",
"service",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Form/DataTransformer/TextTransformer.php#L19-L28 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php | DbStaticProvider.addAll | public function addAll()
{
// Make sure refs are not null any more, else it keeps checking on every static ref
$this->refs = [];
/** @var StaticReference $repos */
$references = $this->em->getRepository('ZichtUrlBundle:StaticReference')->getAll($this->getLocale());
foreach ($references as $static_reference) {
foreach ($static_reference->getTranslations() as $translation) {
$this->refs[$static_reference->getMachineName()][$translation->getLocale()] = $translation->getUrl();
}
}
} | php | public function addAll()
{
// Make sure refs are not null any more, else it keeps checking on every static ref
$this->refs = [];
/** @var StaticReference $repos */
$references = $this->em->getRepository('ZichtUrlBundle:StaticReference')->getAll($this->getLocale());
foreach ($references as $static_reference) {
foreach ($static_reference->getTranslations() as $translation) {
$this->refs[$static_reference->getMachineName()][$translation->getLocale()] = $translation->getUrl();
}
}
} | [
"public",
"function",
"addAll",
"(",
")",
"{",
"// Make sure refs are not null any more, else it keeps checking on every static ref",
"$",
"this",
"->",
"refs",
"=",
"[",
"]",
";",
"/** @var StaticReference $repos */",
"$",
"references",
"=",
"$",
"this",
"->",
"em",
"-... | Add the array as references
@return void | [
"Add",
"the",
"array",
"as",
"references"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php#L59-L72 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php | DbStaticProvider.getLocale | public function getLocale()
{
if (null !== ($request = $this->getMasterRequest())) {
$locale = $request->get('_locale');
}
if (!isset($locale)) {
$locale = $this->fallback_locale;
}
return $locale;
} | php | public function getLocale()
{
if (null !== ($request = $this->getMasterRequest())) {
$locale = $request->get('_locale');
}
if (!isset($locale)) {
$locale = $this->fallback_locale;
}
return $locale;
} | [
"public",
"function",
"getLocale",
"(",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"request",
"=",
"$",
"this",
"->",
"getMasterRequest",
"(",
")",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"request",
"->",
"get",
"(",
"'_locale'",
")",
";",
"}",
... | Returns the locale parameter for the current request, if any.
@return mixed | [
"Returns",
"the",
"locale",
"parameter",
"for",
"the",
"current",
"request",
"if",
"any",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/DbStaticProvider.php#L106-L117 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php | UriParser.parsePost | public function parsePost(array $post)
{
$ret = [];
foreach ($post as $key => $value) {
if ($key) {
$external = $this->translateKeyOutput($key);
$ret[$key] = [];
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = $value;
}
}
}
return $ret;
} | php | public function parsePost(array $post)
{
$ret = [];
foreach ($post as $key => $value) {
if ($key) {
$external = $this->translateKeyOutput($key);
$ret[$key] = [];
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = $value;
}
}
}
return $ret;
} | [
"public",
"function",
"parsePost",
"(",
"array",
"$",
"post",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"post",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"external",
"=",
"$",
"... | POST keys are not translated, but do translate the values
@param array $post
@return array | [
"POST",
"keys",
"are",
"not",
"translated",
"but",
"do",
"translate",
"the",
"values"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php#L50-L67 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php | UriParser.parseUri | public function parseUri($uri)
{
$ret = [];
foreach (explode($this->seperators['param'], $uri) as $params) {
if ($params) {
@list($key, $values) = explode($this->seperators['key_value'], $params, 2);
$external = $key;
if ($internal = $this->translateKeyInput($key)) {
$key = $internal;
}
$ret[$key] = [];
foreach (explode($this->seperators['value'], $values) as $value) {
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = urldecode($value);
}
}
}
}
return $ret;
} | php | public function parseUri($uri)
{
$ret = [];
foreach (explode($this->seperators['param'], $uri) as $params) {
if ($params) {
@list($key, $values) = explode($this->seperators['key_value'], $params, 2);
$external = $key;
if ($internal = $this->translateKeyInput($key)) {
$key = $internal;
}
$ret[$key] = [];
foreach (explode($this->seperators['value'], $values) as $value) {
if (strlen($value) > 0) {
if ($internal = $this->translateValueInput($external, $value)) {
$value = $internal;
}
$ret[$key][] = urldecode($value);
}
}
}
}
return $ret;
} | [
"public",
"function",
"parseUri",
"(",
"$",
"uri",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"$",
"this",
"->",
"seperators",
"[",
"'param'",
"]",
",",
"$",
"uri",
")",
"as",
"$",
"params",
")",
"{",
"if",
"(",
"... | Parse the uri
@param string $uri
@return array | [
"Parse",
"the",
"uri"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/UriParser.php#L75-L98 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/DelegatingProvider.php | DelegatingProvider.addProvider | public function addProvider(Provider $provider, $priority = 0)
{
$this->providers[$priority][] = $provider;
ksort($this->providers);
} | php | public function addProvider(Provider $provider, $priority = 0)
{
$this->providers[$priority][] = $provider;
ksort($this->providers);
} | [
"public",
"function",
"addProvider",
"(",
"Provider",
"$",
"provider",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"providers",
"[",
"$",
"priority",
"]",
"[",
"]",
"=",
"$",
"provider",
";",
"ksort",
"(",
"$",
"this",
"->",
"provide... | Add a provider with the specified priority. Higher priority means exactly that ;)
@param Provider $provider
@param int $priority
@return void | [
"Add",
"a",
"provider",
"with",
"the",
"specified",
"priority",
".",
"Higher",
"priority",
"means",
"exactly",
"that",
";",
")"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/DelegatingProvider.php#L36-L40 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php | UrlValidator.validate | public function validate($url)
{
if (null !== ($headers = $this->getHeader($url))) {
$statusCode = $this->getStatusCode($headers);
// see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
return ($statusCode >= 200 && $statusCode < 300);
}
return false;
} | php | public function validate($url)
{
if (null !== ($headers = $this->getHeader($url))) {
$statusCode = $this->getStatusCode($headers);
// see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
return ($statusCode >= 200 && $statusCode < 300);
}
return false;
} | [
"public",
"function",
"validate",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"headers",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"$",
"url",
")",
")",
")",
"{",
"$",
"statusCode",
"=",
"$",
"this",
"->",
"getStatusCode",
"(",
... | Returns true when url does not return error codes or not found.
@param string $url
@return boolean | [
"Returns",
"true",
"when",
"url",
"does",
"not",
"return",
"error",
"codes",
"or",
"not",
"found",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php#L16-L24 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php | UrlValidator.getStatusCode | protected function getStatusCode(array $headers)
{
$status = 0;
foreach ($headers as $header) {
if (preg_match('#^HTTP/(?:[^\s]+)\s(?P<code>\d+)\s#', $header, $match)) {
$status = (int)$match['code'];
}
}
return $status;
} | php | protected function getStatusCode(array $headers)
{
$status = 0;
foreach ($headers as $header) {
if (preg_match('#^HTTP/(?:[^\s]+)\s(?P<code>\d+)\s#', $header, $match)) {
$status = (int)$match['code'];
}
}
return $status;
} | [
"protected",
"function",
"getStatusCode",
"(",
"array",
"$",
"headers",
")",
"{",
"$",
"status",
"=",
"0",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#^HTTP/(?:[^\\s]+)\\s(?P<code>\\d+)\\s#'",
",",
"$"... | Parse the headers array and search for the status pattern
@param array $headers
@return int | [
"Parse",
"the",
"headers",
"array",
"and",
"search",
"for",
"the",
"status",
"pattern"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Service/UrlValidator.php#L47-L56 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php | Aliaser.createAlias | public function createAlias($record, $action = ['VIEW'])
{
$internalUrl = $this->provider->url($record);
if (in_array($internalUrl, $this->recursionProtection)) {
return false;
}
$this->recursionProtection[] = $internalUrl;
if ($this->shouldGenerateAlias($record, $action)) {
// Don't save an alias if the generated public alias is null
if (null !== ($generatedAlias = $this->aliasingStrategy->generatePublicAlias($record))) {
return $this->aliasing->addAlias(
$generatedAlias,
$internalUrl,
UrlAlias::REWRITE,
$this->conflictingPublicUrlStrategy,
$this->conflictingInternalUrlStrategy
);
}
}
return false;
} | php | public function createAlias($record, $action = ['VIEW'])
{
$internalUrl = $this->provider->url($record);
if (in_array($internalUrl, $this->recursionProtection)) {
return false;
}
$this->recursionProtection[] = $internalUrl;
if ($this->shouldGenerateAlias($record, $action)) {
// Don't save an alias if the generated public alias is null
if (null !== ($generatedAlias = $this->aliasingStrategy->generatePublicAlias($record))) {
return $this->aliasing->addAlias(
$generatedAlias,
$internalUrl,
UrlAlias::REWRITE,
$this->conflictingPublicUrlStrategy,
$this->conflictingInternalUrlStrategy
);
}
}
return false;
} | [
"public",
"function",
"createAlias",
"(",
"$",
"record",
",",
"$",
"action",
"=",
"[",
"'VIEW'",
"]",
")",
"{",
"$",
"internalUrl",
"=",
"$",
"this",
"->",
"provider",
"->",
"url",
"(",
"$",
"record",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"int... | Create an alias for the provided object.
@param mixed $record
@param array $action
@return bool Whether or not an alias was created. | [
"Create",
"an",
"alias",
"for",
"the",
"provided",
"object",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php#L97-L121 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php | Aliaser.shouldGenerateAlias | public function shouldGenerateAlias($record, array $action = ['VIEW'])
{
// without security, everything is considered public
if (null === $this->decisionManager) {
return true;
}
return $this->decisionManager->decide(new AnonymousToken('main', 'anonymous'), $action, $record);
} | php | public function shouldGenerateAlias($record, array $action = ['VIEW'])
{
// without security, everything is considered public
if (null === $this->decisionManager) {
return true;
}
return $this->decisionManager->decide(new AnonymousToken('main', 'anonymous'), $action, $record);
} | [
"public",
"function",
"shouldGenerateAlias",
"(",
"$",
"record",
",",
"array",
"$",
"action",
"=",
"[",
"'VIEW'",
"]",
")",
"{",
"// without security, everything is considered public",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"decisionManager",
")",
"{",
"re... | Determines whether an alias should be generated for the given record.
@param mixed $record
@param array $action
@return bool | [
"Determines",
"whether",
"an",
"alias",
"should",
"be",
"generated",
"for",
"the",
"given",
"record",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php#L131-L139 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php | Aliaser.removeScheduledAliases | public function removeScheduledAliases()
{
foreach ($this->scheduledRemoveAlias as $alias) {
$this->aliasing->removeAlias($alias);
}
$this->scheduledRemoveAlias = [];
} | php | public function removeScheduledAliases()
{
foreach ($this->scheduledRemoveAlias as $alias) {
$this->aliasing->removeAlias($alias);
}
$this->scheduledRemoveAlias = [];
} | [
"public",
"function",
"removeScheduledAliases",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"scheduledRemoveAlias",
"as",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"aliasing",
"->",
"removeAlias",
"(",
"$",
"alias",
")",
";",
"}",
"$",
"this",
"->... | Remove scheduled aliases
Example:
$aliaser->removeAlias($page, true);
# alias for $page is scheduled for removal, i.e. not yet actually removed
$aliaser->removeScheduledAliases()
# now the alias for $page is removed
@return void | [
"Remove",
"scheduled",
"aliases"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliaser.php#L171-L178 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/DefaultAliasingStrategy.php | DefaultAliasingStrategy.generatePublicAlias | public function generatePublicAlias($subject, $currentAlias = '')
{
if (is_object($subject)) {
if ($subject instanceof Aliasable) {
$subject = (string)$subject->getAliasTitle();
} elseif (method_exists($subject, 'getTitle')) {
$subject = (string)$subject->getTitle();
} else {
$subject = (string)$subject;
}
}
if (!is_string($subject)) {
throw new \InvalidArgumentException('Expected a string or object as subject, got ' . gettype($subject));
}
if ($alias = $this->toAlias($subject)) {
return $this->basePath . $alias;
}
return null;
} | php | public function generatePublicAlias($subject, $currentAlias = '')
{
if (is_object($subject)) {
if ($subject instanceof Aliasable) {
$subject = (string)$subject->getAliasTitle();
} elseif (method_exists($subject, 'getTitle')) {
$subject = (string)$subject->getTitle();
} else {
$subject = (string)$subject;
}
}
if (!is_string($subject)) {
throw new \InvalidArgumentException('Expected a string or object as subject, got ' . gettype($subject));
}
if ($alias = $this->toAlias($subject)) {
return $this->basePath . $alias;
}
return null;
} | [
"public",
"function",
"generatePublicAlias",
"(",
"$",
"subject",
",",
"$",
"currentAlias",
"=",
"''",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"subject",
")",
")",
"{",
"if",
"(",
"$",
"subject",
"instanceof",
"Aliasable",
")",
"{",
"$",
"subject",
... | Returns the calculated public alias for the specified object.
@param string $subject
@param string $currentAlias
@return null|string
@throws \InvalidArgumentException | [
"Returns",
"the",
"calculated",
"public",
"alias",
"for",
"the",
"specified",
"object",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/DefaultAliasingStrategy.php#L33-L52 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/Params.php | Params.with | public function with($key, $value, $multiple = true)
{
$ret = clone $this;
$ret = self::doWith($ret, $key, $value, $multiple);
return $ret;
} | php | public function with($key, $value, $multiple = true)
{
$ret = clone $this;
$ret = self::doWith($ret, $key, $value, $multiple);
return $ret;
} | [
"public",
"function",
"with",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"multiple",
"=",
"true",
")",
"{",
"$",
"ret",
"=",
"clone",
"$",
"this",
";",
"$",
"ret",
"=",
"self",
"::",
"doWith",
"(",
"$",
"ret",
",",
"$",
"key",
",",
"$",
"v... | Duplicates the current instance with one value changed.
- If the value already exists, the value is removed;
- If the value does not exist, it is added;
- If the value exists, and 'multiple' is false, it is replaced.
- If the value does not exists, and 'multiple' is false, it is added.
The $multiple parameter is typically useful for paging or other parameters.
@param string $key
@param string $value
@param bool $multiple
@return Params | [
"Duplicates",
"the",
"current",
"instance",
"with",
"one",
"value",
"changed",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/Params.php#L89-L95 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/Params.php | Params.getOne | public function getOne($key, $default = null)
{
$ret = $default;
$all = $this->get($key);
if (count($all) > 0) {
$ret = array_shift($all);
}
return $ret;
} | php | public function getOne($key, $default = null)
{
$ret = $default;
$all = $this->get($key);
if (count($all) > 0) {
$ret = array_shift($all);
}
return $ret;
} | [
"public",
"function",
"getOne",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"ret",
"=",
"$",
"default",
";",
"$",
"all",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"count",
"(",
"$",
"all",
")",... | Returns a single value, and defaults to the given default parameter if not available.
@param string $key
@param mixed $default
@return mixed | [
"Returns",
"a",
"single",
"value",
"and",
"defaults",
"to",
"the",
"given",
"default",
"parameter",
"if",
"not",
"available",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/Params.php#L139-L148 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Url/Params/Params.php | Params.without | public function without($keys)
{
if (is_scalar($keys)) {
$keys = [$keys];
}
$ret = clone $this;
foreach ($keys as $key) {
$ret->removeKey($key);
}
return $ret;
} | php | public function without($keys)
{
if (is_scalar($keys)) {
$keys = [$keys];
}
$ret = clone $this;
foreach ($keys as $key) {
$ret->removeKey($key);
}
return $ret;
} | [
"public",
"function",
"without",
"(",
"$",
"keys",
")",
"{",
"if",
"(",
"is_scalar",
"(",
"$",
"keys",
")",
")",
"{",
"$",
"keys",
"=",
"[",
"$",
"keys",
"]",
";",
"}",
"$",
"ret",
"=",
"clone",
"$",
"this",
";",
"foreach",
"(",
"$",
"keys",
... | Duplicates the current instance with one or more sets of values removed
@param mixed $keys
@return Params | [
"Duplicates",
"the",
"current",
"instance",
"with",
"one",
"or",
"more",
"sets",
"of",
"values",
"removed"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Url/Params/Params.php#L157-L168 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.resolve | private function resolve($entity)
{
foreach ($this->namespaces as $namespace) {
$className = $namespace . '\\' . ucfirst($entity);
if (class_exists($className)) {
return $className;
}
}
return null;
} | php | private function resolve($entity)
{
foreach ($this->namespaces as $namespace) {
$className = $namespace . '\\' . ucfirst($entity);
if (class_exists($className)) {
return $className;
}
}
return null;
} | [
"private",
"function",
"resolve",
"(",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"namespace",
")",
"{",
"$",
"className",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"ucfirst",
"(",
"$",
"entity",
")",
";",
"... | Resolve the entity name to any of the configured namespaces.
Returns null if not found.
@param string $entity
@return null|string | [
"Resolve",
"the",
"entity",
"name",
"to",
"any",
"of",
"the",
"configured",
"namespaces",
".",
"Returns",
"null",
"if",
"not",
"found",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L99-L108 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.current | protected function current()
{
if (count($this->stack)) {
return $this->stack[count($this->stack) -1];
}
return null;
} | php | protected function current()
{
if (count($this->stack)) {
return $this->stack[count($this->stack) -1];
}
return null;
} | [
"protected",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"return",
"$",
"this",
"->",
"stack",
"[",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
"-",
"1",
"]",
";",
"}",
"return",
... | Returns the top of the stack.
@return mixed | [
"Returns",
"the",
"top",
"of",
"the",
"stack",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L116-L122 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.end | public function end($setter = null)
{
if (!count($this->stack)) {
throw new \UnexpectedValueException("Stack is empty. Did you call end() too many times?");
}
$current = array_pop($this->stack);
if ($parent = $this->current()) {
$parentClassName = get_class($parent);
$entityLocalName = Str::classname(get_class($current));
if ($current instanceof $parentClassName) {
if (method_exists($parent, 'addChildren')) {
call_user_func(array($parent, 'addChildren'), $current);
}
}
if (is_null($setter)) {
foreach (array('set', 'add') as $methodPrefix) {
$methodName = $methodPrefix . $entityLocalName;
if (method_exists($parent, $methodName)) {
$setter = $methodName;
break;
}
}
}
if (!is_null($setter)) {
call_user_func(array($parent, $setter), $current);
}
$parentClassNames = array_merge(class_parents($parentClassName), array($parentClassName));
foreach (array_reverse($parentClassNames) as $lParentClassName) {
$lParentClass = Str::classname($lParentClassName);
$parentSetter = 'set' . $lParentClass;
if ($lParentClassName == get_class($current)) {
$parentSetter = 'setParent';
}
if (method_exists($current, $parentSetter)) {
call_user_func(
array($current, $parentSetter),
$parent
);
break;
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $parent);
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $current);
}
return $this;
} | php | public function end($setter = null)
{
if (!count($this->stack)) {
throw new \UnexpectedValueException("Stack is empty. Did you call end() too many times?");
}
$current = array_pop($this->stack);
if ($parent = $this->current()) {
$parentClassName = get_class($parent);
$entityLocalName = Str::classname(get_class($current));
if ($current instanceof $parentClassName) {
if (method_exists($parent, 'addChildren')) {
call_user_func(array($parent, 'addChildren'), $current);
}
}
if (is_null($setter)) {
foreach (array('set', 'add') as $methodPrefix) {
$methodName = $methodPrefix . $entityLocalName;
if (method_exists($parent, $methodName)) {
$setter = $methodName;
break;
}
}
}
if (!is_null($setter)) {
call_user_func(array($parent, $setter), $current);
}
$parentClassNames = array_merge(class_parents($parentClassName), array($parentClassName));
foreach (array_reverse($parentClassNames) as $lParentClassName) {
$lParentClass = Str::classname($lParentClassName);
$parentSetter = 'set' . $lParentClass;
if ($lParentClassName == get_class($current)) {
$parentSetter = 'setParent';
}
if (method_exists($current, $parentSetter)) {
call_user_func(
array($current, $parentSetter),
$parent
);
break;
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $parent);
}
}
foreach ($this->alwaysDo as $callable) {
call_user_func($callable, $current);
}
return $this;
} | [
"public",
"function",
"end",
"(",
"$",
"setter",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"Stack is empty. Did you call end() too many times?\"",
")... | Returns one level up in the tree.
@param null $setter
@return Builder | [
"Returns",
"one",
"level",
"up",
"in",
"the",
"tree",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L142-L195 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php | Builder.peek | public function peek()
{
$c = count($this->stack);
if ($c == 0) {
throw new \UnexpectedValueException("The stack is empty. You should probably peek() before the last end() call.");
}
$ret = $this->stack[$c -1];
return $ret;
} | php | public function peek()
{
$c = count($this->stack);
if ($c == 0) {
throw new \UnexpectedValueException("The stack is empty. You should probably peek() before the last end() call.");
}
$ret = $this->stack[$c -1];
return $ret;
} | [
"public",
"function",
"peek",
"(",
")",
"{",
"$",
"c",
"=",
"count",
"(",
"$",
"this",
"->",
"stack",
")",
";",
"if",
"(",
"$",
"c",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"\"The stack is empty. You should probably peek... | Returns the object that is currently the subject of building
@return mixed
@throws \UnexpectedValueException | [
"Returns",
"the",
"object",
"that",
"is",
"currently",
"the",
"subject",
"of",
"building"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Fixture/Builder.php#L204-L212 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php | CreateAliasSubscriber.addRecord | protected function addRecord($entity, array $action = [])
{
if ($entity instanceof $this->className) {
if (false !== ($index = array_search($entity, array_column($this->records, 0), true))) {
if (!in_array($this->records[$index], $action)) {
$this->records[$index][] = $action;
}
} else {
$this->records[] = [$entity, $action];
}
}
} | php | protected function addRecord($entity, array $action = [])
{
if ($entity instanceof $this->className) {
if (false !== ($index = array_search($entity, array_column($this->records, 0), true))) {
if (!in_array($this->records[$index], $action)) {
$this->records[$index][] = $action;
}
} else {
$this->records[] = [$entity, $action];
}
}
} | [
"protected",
"function",
"addRecord",
"(",
"$",
"entity",
",",
"array",
"$",
"action",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"entity",
"instanceof",
"$",
"this",
"->",
"className",
")",
"{",
"if",
"(",
"false",
"!==",
"(",
"$",
"index",
"=",
"ar... | Add a entity to record list for postFlush processing.
@param object $entity
@param array $action | [
"Add",
"a",
"entity",
"to",
"record",
"list",
"for",
"postFlush",
"processing",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php#L48-L59 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php | CreateAliasSubscriber.postFlush | public function postFlush()
{
if (!$this->enabled || $this->isHandling) {
return;
}
$this->isHandling = true;
$aliaser = $this->container->get($this->aliaserServiceId);
while (list($record, $action) = array_shift($this->records)) {
$aliaser->createAlias($record, $action);
}
$this->isHandling = false;
} | php | public function postFlush()
{
if (!$this->enabled || $this->isHandling) {
return;
}
$this->isHandling = true;
$aliaser = $this->container->get($this->aliaserServiceId);
while (list($record, $action) = array_shift($this->records)) {
$aliaser->createAlias($record, $action);
}
$this->isHandling = false;
} | [
"public",
"function",
"postFlush",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
"||",
"$",
"this",
"->",
"isHandling",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"isHandling",
"=",
"true",
";",
"$",
"aliaser",
"=",
"$",
"this"... | Create the aliases
@return void | [
"Create",
"the",
"aliases"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/CreateAliasSubscriber.php#L90-L105 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Pager/Pager.php | Pager.itemAt | private function itemAt($i)
{
return array(
'index' => $i,
'title' => $i + 1,
'is_previous' => $i == ($this->currentPage - 1),
'is_current' => $i == $this->currentPage,
'is_next' => $i == ($this->currentPage + 1)
);
} | php | private function itemAt($i)
{
return array(
'index' => $i,
'title' => $i + 1,
'is_previous' => $i == ($this->currentPage - 1),
'is_current' => $i == $this->currentPage,
'is_next' => $i == ($this->currentPage + 1)
);
} | [
"private",
"function",
"itemAt",
"(",
"$",
"i",
")",
"{",
"return",
"array",
"(",
"'index'",
"=>",
"$",
"i",
",",
"'title'",
"=>",
"$",
"i",
"+",
"1",
",",
"'is_previous'",
"=>",
"$",
"i",
"==",
"(",
"$",
"this",
"->",
"currentPage",
"-",
"1",
")... | Meta data helper function, returns the following meta data for each of the requested pages.
- title: The displayable title for the current page (e.g. "1" for page 0)
- is_previous: Whether the page is the previous page
- is_current
- is_next: Whether the page is the next page
@param int $i
@return array | [
"Meta",
"data",
"helper",
"function",
"returns",
"the",
"following",
"meta",
"data",
"for",
"each",
"of",
"the",
"requested",
"pages",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Pager/Pager.php#L239-L248 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php | AbstractCronCommand.exceptionHandler | public function exceptionHandler(Exception $exception)
{
$this->logger->addError($exception->getMessage(), array($exception->getFile(), $exception->getLine()));
exit(-1);
} | php | public function exceptionHandler(Exception $exception)
{
$this->logger->addError($exception->getMessage(), array($exception->getFile(), $exception->getLine()));
exit(-1);
} | [
"public",
"function",
"exceptionHandler",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addError",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"array",
"(",
"$",
"exception",
"->",
"getFile",
"(",
")",
",... | Exception handler; will log the exception and exit the script.
@param \Exception $exception
@return void | [
"Exception",
"handler",
";",
"will",
"log",
"the",
"exception",
"and",
"exit",
"the",
"script",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php#L86-L90 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php | AbstractCronCommand.errorHandler | public function errorHandler($errno, $errstr, $file, $line)
{
switch ($errno) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
$this->logger->addError($errstr, array($file, $line));
exit();
break;
case E_WARNING:
case E_USER_WARNING:
$this->logger->addWarning($errstr, array($file, $line));
break;
default:
$this->logger->addInfo($errstr, array($file, $line));
break;
}
} | php | public function errorHandler($errno, $errstr, $file, $line)
{
switch ($errno) {
case E_USER_ERROR:
case E_ERROR:
case E_RECOVERABLE_ERROR:
$this->logger->addError($errstr, array($file, $line));
exit();
break;
case E_WARNING:
case E_USER_WARNING:
$this->logger->addWarning($errstr, array($file, $line));
break;
default:
$this->logger->addInfo($errstr, array($file, $line));
break;
}
} | [
"public",
"function",
"errorHandler",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"file",
",",
"$",
"line",
")",
"{",
"switch",
"(",
"$",
"errno",
")",
"{",
"case",
"E_USER_ERROR",
":",
"case",
"E_ERROR",
":",
"case",
"E_RECOVERABLE_ERROR",
":",
"... | Error handler; will log the error and exit the script.
@param int $errno
@param string $errstr
@param string $file
@param int $line
@return void | [
"Error",
"handler",
";",
"will",
"log",
"the",
"error",
"and",
"exit",
"the",
"script",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php#L102-L119 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php | AbstractCronCommand.getMutexFile | protected function getMutexFile()
{
$file = false;
if (true === $this->mutex) {
$file = $this->getContainer()->getParameter('kernel.cache_dir')
. '/'
. Str::dash(lcfirst(Str::classname(get_class($this))))
. '.lock';
} elseif ($this->mutex) {
$file = $this->mutex;
}
return $file;
} | php | protected function getMutexFile()
{
$file = false;
if (true === $this->mutex) {
$file = $this->getContainer()->getParameter('kernel.cache_dir')
. '/'
. Str::dash(lcfirst(Str::classname(get_class($this))))
. '.lock';
} elseif ($this->mutex) {
$file = $this->mutex;
}
return $file;
} | [
"protected",
"function",
"getMutexFile",
"(",
")",
"{",
"$",
"file",
"=",
"false",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"mutex",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kernel... | Returns a path to the file which can be used as a mutex.
@return bool|string | [
"Returns",
"a",
"path",
"to",
"the",
"file",
"which",
"can",
"be",
"used",
"as",
"a",
"mutex",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/AbstractCronCommand.php#L199-L212 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.onKernelResponse | public function onKernelResponse(Event\FilterResponseEvent $e)
{
if ($e->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$response = $e->getResponse();
// only do anything if the response has a Location header
if (false !== ($location = $response->headers->get('location', false))) {
$absolutePrefix = $e->getRequest()->getSchemeAndHttpHost();
if (parse_url($location, PHP_URL_SCHEME)) {
if (substr($location, 0, strlen($absolutePrefix)) === $absolutePrefix) {
$relative = substr($location, strlen($absolutePrefix));
} else {
$relative = null;
}
} else {
$relative = $location;
}
// Possible suffix for the rewrite URL
$suffix = '';
/**
* Catches the following situation:
*
* Some redirect URLs might contain extra URL parameters in the form of:
*
* /nl/page/666/terms=FOO/tag=BAR
*
* (E.g. some SOLR implementations use this URL scheme)
*
* The relative URL above is then incorrect and the public alias can not be found.
*
* Remove /terms=FOO/tag=BAR from the relative path and attach to clean URL if found.
*
*/
if (preg_match('/^(\/[a-z]{2,2}\/page\/\d+)(.*)$/', $relative, $matches)) {
list(, $relative, $suffix) = $matches;
} elseif (preg_match('/^(\/page\/\d+)(.*)$/', $relative, $matches)) {
/* For old sites that don't have the locale in the URI */
list(, $relative, $suffix) = $matches;
}
if (null !== $relative && null !== ($url = $this->aliasing->hasPublicAlias($relative))) {
$rewrite = $absolutePrefix . $url . $suffix;
$response->headers->set('location', $rewrite);
}
}
$this->rewriteResponse($e->getRequest(), $response);
}
} | php | public function onKernelResponse(Event\FilterResponseEvent $e)
{
if ($e->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$response = $e->getResponse();
// only do anything if the response has a Location header
if (false !== ($location = $response->headers->get('location', false))) {
$absolutePrefix = $e->getRequest()->getSchemeAndHttpHost();
if (parse_url($location, PHP_URL_SCHEME)) {
if (substr($location, 0, strlen($absolutePrefix)) === $absolutePrefix) {
$relative = substr($location, strlen($absolutePrefix));
} else {
$relative = null;
}
} else {
$relative = $location;
}
// Possible suffix for the rewrite URL
$suffix = '';
/**
* Catches the following situation:
*
* Some redirect URLs might contain extra URL parameters in the form of:
*
* /nl/page/666/terms=FOO/tag=BAR
*
* (E.g. some SOLR implementations use this URL scheme)
*
* The relative URL above is then incorrect and the public alias can not be found.
*
* Remove /terms=FOO/tag=BAR from the relative path and attach to clean URL if found.
*
*/
if (preg_match('/^(\/[a-z]{2,2}\/page\/\d+)(.*)$/', $relative, $matches)) {
list(, $relative, $suffix) = $matches;
} elseif (preg_match('/^(\/page\/\d+)(.*)$/', $relative, $matches)) {
/* For old sites that don't have the locale in the URI */
list(, $relative, $suffix) = $matches;
}
if (null !== $relative && null !== ($url = $this->aliasing->hasPublicAlias($relative))) {
$rewrite = $absolutePrefix . $url . $suffix;
$response->headers->set('location', $rewrite);
}
}
$this->rewriteResponse($e->getRequest(), $response);
}
} | [
"public",
"function",
"onKernelResponse",
"(",
"Event",
"\\",
"FilterResponseEvent",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getRequestType",
"(",
")",
"===",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
")",
"{",
"$",
"response",
"=",
"$",
"e",
... | Listens to redirect responses, to replace any internal url with a public one.
@param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $e
@return void | [
"Listens",
"to",
"redirect",
"responses",
"to",
"replace",
"any",
"internal",
"url",
"with",
"a",
"public",
"one",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L46-L97 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.isExcluded | protected function isExcluded($url)
{
$ret = false;
foreach ($this->excludePatterns as $pattern) {
if (preg_match($pattern, $url)) {
$ret = true;
break;
}
}
return $ret;
} | php | protected function isExcluded($url)
{
$ret = false;
foreach ($this->excludePatterns as $pattern) {
if (preg_match($pattern, $url)) {
$ret = true;
break;
}
}
return $ret;
} | [
"protected",
"function",
"isExcluded",
"(",
"$",
"url",
")",
"{",
"$",
"ret",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"excludePatterns",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"url",
")",... | Returns true if the URL matches any of the exclude patterns
@param string $url
@return bool | [
"Returns",
"true",
"if",
"the",
"URL",
"matches",
"any",
"of",
"the",
"exclude",
"patterns"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L127-L137 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.onKernelRequest | public function onKernelRequest(Event\GetResponseEvent $event)
{
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$request = $event->getRequest();
$publicUrl = rawurldecode($request->getRequestUri());
if ($this->isExcluded($publicUrl)) {
// don't process urls which are marked as excluded.
return;
}
if ($this->isParamsEnabled) {
if (false !== ($queryMark = strpos($publicUrl, '?'))) {
$originalUrl = $publicUrl;
$publicUrl = substr($originalUrl, 0, $queryMark);
$queryString = substr($originalUrl, $queryMark);
} else {
$queryString = null;
}
$parts = explode('/', $publicUrl);
$params = [];
while (false !== strpos(end($parts), '=')) {
array_push($params, array_pop($parts));
}
if ($params) {
$publicUrl = join('/', $parts);
$parser = new UriParser();
$request->query->add($parser->parseUri(join('/', array_reverse($params))));
if (!$this->aliasing->hasInternalAlias($publicUrl, false)) {
$this->rewriteRequest($event, $publicUrl . $queryString);
return;
}
}
}
/** @var UrlAlias $url */
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true)) {
switch ($url->getMode()) {
case UrlAlias::REWRITE:
$this->rewriteRequest($event, $url->getInternalUrl());
break;
case UrlAlias::MOVE:
case UrlAlias::ALIAS:
$event->setResponse(new RedirectResponse($url->getInternalUrl(), $url->getMode()));
break;
default:
throw new \UnexpectedValueException(
sprintf(
'Invalid mode %s for UrlAlias %s.',
$url->getMode(),
json_encode($url)
)
);
}
} elseif (strpos($publicUrl, '?') !== false) {
// allow aliases to receive the query string.
$publicUrl = substr($publicUrl, 0, strpos($publicUrl, '?'));
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true, UrlAlias::REWRITE)) {
$this->rewriteRequest($event, $url->getInternalUrl());
return;
}
}
}
} | php | public function onKernelRequest(Event\GetResponseEvent $event)
{
if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
$request = $event->getRequest();
$publicUrl = rawurldecode($request->getRequestUri());
if ($this->isExcluded($publicUrl)) {
// don't process urls which are marked as excluded.
return;
}
if ($this->isParamsEnabled) {
if (false !== ($queryMark = strpos($publicUrl, '?'))) {
$originalUrl = $publicUrl;
$publicUrl = substr($originalUrl, 0, $queryMark);
$queryString = substr($originalUrl, $queryMark);
} else {
$queryString = null;
}
$parts = explode('/', $publicUrl);
$params = [];
while (false !== strpos(end($parts), '=')) {
array_push($params, array_pop($parts));
}
if ($params) {
$publicUrl = join('/', $parts);
$parser = new UriParser();
$request->query->add($parser->parseUri(join('/', array_reverse($params))));
if (!$this->aliasing->hasInternalAlias($publicUrl, false)) {
$this->rewriteRequest($event, $publicUrl . $queryString);
return;
}
}
}
/** @var UrlAlias $url */
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true)) {
switch ($url->getMode()) {
case UrlAlias::REWRITE:
$this->rewriteRequest($event, $url->getInternalUrl());
break;
case UrlAlias::MOVE:
case UrlAlias::ALIAS:
$event->setResponse(new RedirectResponse($url->getInternalUrl(), $url->getMode()));
break;
default:
throw new \UnexpectedValueException(
sprintf(
'Invalid mode %s for UrlAlias %s.',
$url->getMode(),
json_encode($url)
)
);
}
} elseif (strpos($publicUrl, '?') !== false) {
// allow aliases to receive the query string.
$publicUrl = substr($publicUrl, 0, strpos($publicUrl, '?'));
if ($url = $this->aliasing->hasInternalAlias($publicUrl, true, UrlAlias::REWRITE)) {
$this->rewriteRequest($event, $url->getInternalUrl());
return;
}
}
}
} | [
"public",
"function",
"onKernelRequest",
"(",
"Event",
"\\",
"GetResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getRequestType",
"(",
")",
"===",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
")",
"{",
"$",
"request",
"=",
"$",
"eve... | Listens to master requests and translates the URL to an internal url, if there is an alias available
@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
@return void
@throws \UnexpectedValueException | [
"Listens",
"to",
"master",
"requests",
"and",
"translates",
"the",
"URL",
"to",
"an",
"internal",
"url",
"if",
"there",
"is",
"an",
"alias",
"available"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L147-L216 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.rewriteRequest | public function rewriteRequest($event, $url)
{
// override the request's REQUEST_URI
$event->getRequest()->initialize(
$event->getRequest()->query->all(),
$event->getRequest()->request->all(),
$event->getRequest()->attributes->all(),
$event->getRequest()->cookies->all(),
$event->getRequest()->files->all(),
[
'ORIGINAL_REQUEST_URI' => $event->getRequest()->server->get('REQUEST_URI'),
'REQUEST_URI' => $url
] + $event->getRequest()->server->all(),
$event->getRequest()->getContent()
);
// route the request
$subEvent = new Event\GetResponseEvent(
$event->getKernel(),
$event->getRequest(),
$event->getRequestType()
);
$this->router->onKernelRequest($subEvent);
} | php | public function rewriteRequest($event, $url)
{
// override the request's REQUEST_URI
$event->getRequest()->initialize(
$event->getRequest()->query->all(),
$event->getRequest()->request->all(),
$event->getRequest()->attributes->all(),
$event->getRequest()->cookies->all(),
$event->getRequest()->files->all(),
[
'ORIGINAL_REQUEST_URI' => $event->getRequest()->server->get('REQUEST_URI'),
'REQUEST_URI' => $url
] + $event->getRequest()->server->all(),
$event->getRequest()->getContent()
);
// route the request
$subEvent = new Event\GetResponseEvent(
$event->getKernel(),
$event->getRequest(),
$event->getRequestType()
);
$this->router->onKernelRequest($subEvent);
} | [
"public",
"function",
"rewriteRequest",
"(",
"$",
"event",
",",
"$",
"url",
")",
"{",
"// override the request's REQUEST_URI",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"initialize",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"query",
"->... | Route the request to the specified URL.
@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
@param string $url
@return void | [
"Route",
"the",
"request",
"to",
"the",
"specified",
"URL",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L226-L249 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php | Listener.rewriteResponse | protected function rewriteResponse(Request $request, Response $response)
{
// for debugging purposes. Might need to be configurable.
if ($request->query->get('__disable_aliasing')) {
return;
}
if (preg_match('!^/admin/!', $request->getRequestUri())) {
// don't bother here.
return;
}
if ($response->getContent()) {
$contentType = current(explode(';', $response->headers->get('content-type', 'text/html')));
$response->setContent(
$this->aliasing->mapContent(
$contentType,
UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC,
$response->getContent(),
[$request->getHttpHost()]
)
);
}
} | php | protected function rewriteResponse(Request $request, Response $response)
{
// for debugging purposes. Might need to be configurable.
if ($request->query->get('__disable_aliasing')) {
return;
}
if (preg_match('!^/admin/!', $request->getRequestUri())) {
// don't bother here.
return;
}
if ($response->getContent()) {
$contentType = current(explode(';', $response->headers->get('content-type', 'text/html')));
$response->setContent(
$this->aliasing->mapContent(
$contentType,
UrlMapperInterface::MODE_INTERNAL_TO_PUBLIC,
$response->getContent(),
[$request->getHttpHost()]
)
);
}
} | [
"protected",
"function",
"rewriteResponse",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"// for debugging purposes. Might need to be configurable.",
"if",
"(",
"$",
"request",
"->",
"query",
"->",
"get",
"(",
"'__disable_aliasing'",
")"... | Rewrite URL's from internal naming to public aliases in the response.
@param Request $request
@param Response $response
@return void | [
"Rewrite",
"URL",
"s",
"from",
"internal",
"naming",
"to",
"public",
"aliases",
"in",
"the",
"response",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Listener.php#L259-L281 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Controller/SitemapController.php | SitemapController.sitemapAction | public function sitemapAction(Request $request)
{
$urls = $this->get('zicht_url.sitemap_provider')->all($this->get('security.authorization_checker'));
return new Response(
$this->renderView('ZichtUrlBundle:Sitemap:sitemap.xml.twig', ['urls' => $urls]),
200,
[
'content-type' => 'text/xml'
]
);
} | php | public function sitemapAction(Request $request)
{
$urls = $this->get('zicht_url.sitemap_provider')->all($this->get('security.authorization_checker'));
return new Response(
$this->renderView('ZichtUrlBundle:Sitemap:sitemap.xml.twig', ['urls' => $urls]),
200,
[
'content-type' => 'text/xml'
]
);
} | [
"public",
"function",
"sitemapAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"urls",
"=",
"$",
"this",
"->",
"get",
"(",
"'zicht_url.sitemap_provider'",
")",
"->",
"all",
"(",
"$",
"this",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
"... | Render basic sitemap from all database urls
@param Request $request
@return Response
@Route("/sitemap.{_format}", defaults={"_format": "xml"}) | [
"Render",
"basic",
"sitemap",
"from",
"all",
"database",
"urls"
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Controller/SitemapController.php#L23-L34 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Logging/Listener.php | Listener.onKernelException | public function onKernelException(GetResponseForExceptionEvent $event)
{
$this->log = $this->logging->createLog($event->getRequest(), $event->getException()->getMessage());
} | php | public function onKernelException(GetResponseForExceptionEvent $event)
{
$this->log = $this->logging->createLog($event->getRequest(), $event->getException()->getMessage());
} | [
"public",
"function",
"onKernelException",
"(",
"GetResponseForExceptionEvent",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"log",
"=",
"$",
"this",
"->",
"logging",
"->",
"createLog",
"(",
"$",
"event",
"->",
"getRequest",
"(",
")",
",",
"$",
"event",
"->"... | Create log entry if a kernelexception occurs.
@param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
@return void | [
"Create",
"log",
"entry",
"if",
"a",
"kernelexception",
"occurs",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Logging/Listener.php#L38-L41 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSet.php | SortedSet.remove | public function remove($value)
{
foreach ($this->values as $i => $v) {
if ($value == $v) {
unset($this->values[$i]);
break;
}
}
$this->stateChanged();
} | php | public function remove($value)
{
foreach ($this->values as $i => $v) {
if ($value == $v) {
unset($this->values[$i]);
break;
}
}
$this->stateChanged();
} | [
"public",
"function",
"remove",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"i",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"$",
"v",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"values",
... | Removes a value from the set, if present
@param int|float|string|bool $value
@return void | [
"Removes",
"a",
"value",
"from",
"the",
"set",
"if",
"present"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSet.php#L108-L117 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSet.php | SortedSet.stateChanged | private function stateChanged()
{
if (count($this->values)) {
$this->values = array_unique(array_values($this->values));
sort($this->values);
}
} | php | private function stateChanged()
{
if (count($this->values)) {
$this->values = array_unique(array_values($this->values));
sort($this->values);
}
} | [
"private",
"function",
"stateChanged",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"values",
")",
")",
"{",
"$",
"this",
"->",
"values",
"=",
"array_unique",
"(",
"array_values",
"(",
"$",
"this",
"->",
"values",
")",
")",
";",
"sort",... | Ensured uniqueness and sorted values
@return void | [
"Ensured",
"uniqueness",
"and",
"sorted",
"values"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSet.php#L136-L142 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/DependencyInjection/ZichtFrameworkExtraExtension.php | ZichtFrameworkExtraExtension.addUglifyConfiguration | public function addUglifyConfiguration($uglifyConfigFile, $isDebug, ContainerBuilder $container)
{
if (!is_file($uglifyConfigFile)) {
throw new InvalidConfigurationException(
"zicht_framework_extra.uglify setting '$uglifyConfigFile' is not a file"
);
}
$container->addResource(new FileResource($uglifyConfigFile));
try {
$uglifyConfig = Yaml::parse(file_get_contents($uglifyConfigFile));
} catch (\Exception $e) {
throw new InvalidConfigurationException(
"zicht_framework_extra.uglify setting '$uglifyConfigFile' could not be read",
0,
$e
);
}
$global = new Definition(
'Zicht\Bundle\FrameworkExtraBundle\Twig\UglifyGlobal',
array(
$uglifyConfig,
$isDebug
)
);
$global->addTag('twig.global');
$global->addMethodCall('setDebug', array($isDebug));
$container->getDefinition('zicht_twig_extension')->addMethodCall('setGlobal', array('zicht_uglify', $global));
} | php | public function addUglifyConfiguration($uglifyConfigFile, $isDebug, ContainerBuilder $container)
{
if (!is_file($uglifyConfigFile)) {
throw new InvalidConfigurationException(
"zicht_framework_extra.uglify setting '$uglifyConfigFile' is not a file"
);
}
$container->addResource(new FileResource($uglifyConfigFile));
try {
$uglifyConfig = Yaml::parse(file_get_contents($uglifyConfigFile));
} catch (\Exception $e) {
throw new InvalidConfigurationException(
"zicht_framework_extra.uglify setting '$uglifyConfigFile' could not be read",
0,
$e
);
}
$global = new Definition(
'Zicht\Bundle\FrameworkExtraBundle\Twig\UglifyGlobal',
array(
$uglifyConfig,
$isDebug
)
);
$global->addTag('twig.global');
$global->addMethodCall('setDebug', array($isDebug));
$container->getDefinition('zicht_twig_extension')->addMethodCall('setGlobal', array('zicht_uglify', $global));
} | [
"public",
"function",
"addUglifyConfiguration",
"(",
"$",
"uglifyConfigFile",
",",
"$",
"isDebug",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"uglifyConfigFile",
")",
")",
"{",
"throw",
"new",
"InvalidConfigurationE... | Adds the uglify configuration
@param string $uglifyConfigFile
@param boolean $isDebug
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container
@return void
@throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException | [
"Adds",
"the",
"uglify",
"configuration"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/DependencyInjection/ZichtFrameworkExtraExtension.php#L32-L63 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/DependencyInjection/ZichtFrameworkExtraExtension.php | ZichtFrameworkExtraExtension.addRequirejsConfiguration | public function addRequirejsConfiguration($requirejsConfigFile, $isDebug, ContainerBuilder $container)
{
if (!is_file($requirejsConfigFile)) {
throw new InvalidConfigurationException(
"zicht_framework_extra.requirejs setting '$requirejsConfigFile' is not a file"
);
}
$container->addResource(new FileResource($requirejsConfigFile));
try {
$requirejsConfig = Yaml::parse($requirejsConfigFile);
} catch (\Exception $e) {
throw new InvalidConfigurationException(
"zicht_framework_extra.requirejs setting '$requirejsConfigFile' could not be read",
0,
$e
);
}
$global = new Definition(
'Zicht\Bundle\FrameworkExtraBundle\Twig\RequirejsGlobal',
array(
$requirejsConfig,
$isDebug
)
);
$global->addTag('twig.global');
$global->addMethodCall('setDebug', array($isDebug));
$container->getDefinition('zicht_twig_extension')->addMethodCall('setGlobal', array('zicht_requirejs', $global));
} | php | public function addRequirejsConfiguration($requirejsConfigFile, $isDebug, ContainerBuilder $container)
{
if (!is_file($requirejsConfigFile)) {
throw new InvalidConfigurationException(
"zicht_framework_extra.requirejs setting '$requirejsConfigFile' is not a file"
);
}
$container->addResource(new FileResource($requirejsConfigFile));
try {
$requirejsConfig = Yaml::parse($requirejsConfigFile);
} catch (\Exception $e) {
throw new InvalidConfigurationException(
"zicht_framework_extra.requirejs setting '$requirejsConfigFile' could not be read",
0,
$e
);
}
$global = new Definition(
'Zicht\Bundle\FrameworkExtraBundle\Twig\RequirejsGlobal',
array(
$requirejsConfig,
$isDebug
)
);
$global->addTag('twig.global');
$global->addMethodCall('setDebug', array($isDebug));
$container->getDefinition('zicht_twig_extension')->addMethodCall('setGlobal', array('zicht_requirejs', $global));
} | [
"public",
"function",
"addRequirejsConfiguration",
"(",
"$",
"requirejsConfigFile",
",",
"$",
"isDebug",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"requirejsConfigFile",
")",
")",
"{",
"throw",
"new",
"InvalidConfi... | Adds the requirejs configuration
@param string $requirejsConfigFile
@param boolean $isDebug
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container
@return void
@throws \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException | [
"Adds",
"the",
"requirejs",
"configuration"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/DependencyInjection/ZichtFrameworkExtraExtension.php#L75-L104 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.add | public function add($key, $value)
{
if (!isset($this->values[$key])) {
$this->values[$key] = new SortedSet();
}
$this->values[$key]->add($value);
$this->stateChanged();
} | php | public function add($key, $value)
{
if (!isset($this->values[$key])) {
$this->values[$key] = new SortedSet();
}
$this->values[$key]->add($value);
$this->stateChanged();
} | [
"public",
"function",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"=",
"new",
"SortedS... | Add a value to the given map key.
@param string $key
@param int|float|string|bool $value
@return void | [
"Add",
"a",
"value",
"to",
"the",
"given",
"map",
"key",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L54-L61 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.replace | public function replace($key, $values)
{
$this->values[$key] = new SortedSet($values);
$this->stateChanged();
} | php | public function replace($key, $values)
{
$this->values[$key] = new SortedSet($values);
$this->stateChanged();
} | [
"public",
"function",
"replace",
"(",
"$",
"key",
",",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"=",
"new",
"SortedSet",
"(",
"$",
"values",
")",
";",
"$",
"this",
"->",
"stateChanged",
"(",
")",
";",
"}"
] | Replaces the map key with the specified set of values.
@param string $key
@param array $values
@return void | [
"Replaces",
"the",
"map",
"key",
"with",
"the",
"specified",
"set",
"of",
"values",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L71-L75 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.get | public function get($key)
{
if (isset($this->values[$key])) {
return $this->values[$key]->toArray();
}
return array();
} | php | public function get($key)
{
if (isset($this->values[$key])) {
return $this->values[$key]->toArray();
}
return array();
} | [
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"->",
"toArray",
"(",
")",
";",
"}... | Returns the set of values associated with the given key as an array.
Returns an empty array if the key is not present.
@param string $key
@return array | [
"Returns",
"the",
"set",
"of",
"values",
"associated",
"with",
"the",
"given",
"key",
"as",
"an",
"array",
".",
"Returns",
"an",
"empty",
"array",
"if",
"the",
"key",
"is",
"not",
"present",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L85-L92 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.contains | public function contains($key, $value)
{
if (isset($this->values[$key])) {
return $this->values[$key]->contains($value);
}
return false;
} | php | public function contains($key, $value)
{
if (isset($this->values[$key])) {
return $this->values[$key]->contains($value);
}
return false;
} | [
"public",
"function",
"contains",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"->",
"conta... | Checks if a value is associated with the given key.
@param string $key
@param int|float|string|bool $value
@return bool | [
"Checks",
"if",
"a",
"value",
"is",
"associated",
"with",
"the",
"given",
"key",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L102-L109 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.remove | public function remove($key, $value)
{
if (isset($this->values[$key])) {
$this->values[$key]->remove($value);
}
$this->stateChanged();
} | php | public function remove($key, $value)
{
if (isset($this->values[$key])) {
$this->values[$key]->remove($value);
}
$this->stateChanged();
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
"->",
"remove",
"(",
"... | Removes the given value from the map associated with the given key.
@param string $key
@param int|float|string|bool $value
@return void | [
"Removes",
"the",
"given",
"value",
"from",
"the",
"map",
"associated",
"with",
"the",
"given",
"key",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L131-L137 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.removeKey | public function removeKey($key)
{
if (isset($this->values[$key])) {
unset($this->values[$key]);
}
$this->stateChanged();
} | php | public function removeKey($key)
{
if (isset($this->values[$key])) {
unset($this->values[$key]);
}
$this->stateChanged();
} | [
"public",
"function",
"removeKey",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"values",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"thi... | Removes an entire set of values associated with the given key.
@param string $key
@return void | [
"Removes",
"an",
"entire",
"set",
"of",
"values",
"associated",
"with",
"the",
"given",
"key",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L146-L152 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.merge | public function merge($key, $values)
{
foreach ((array)$values as $value) {
$this->add($key, $value);
}
$this->stateChanged();
} | php | public function merge($key, $values)
{
foreach ((array)$values as $value) {
$this->add($key, $value);
}
$this->stateChanged();
} | [
"public",
"function",
"merge",
"(",
"$",
"key",
",",
"$",
"values",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"t... | Merges a set of values into the given key's set.
@param string $key
@param \Traversable $values
@return void | [
"Merges",
"a",
"set",
"of",
"values",
"into",
"the",
"given",
"key",
"s",
"set",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L162-L168 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.mergeAll | public function mergeAll(array $values)
{
foreach ($values as $key => $value) {
$this->merge($key, $value);
}
} | php | public function mergeAll(array $values)
{
foreach ($values as $key => $value) {
$this->merge($key, $value);
}
} | [
"public",
"function",
"mergeAll",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"merge",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Merge an entire map into the current map.
@param array $values
@return void | [
"Merge",
"an",
"entire",
"map",
"into",
"the",
"current",
"map",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L177-L182 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.toArray | public function toArray()
{
$ret = array();
foreach (array_keys($this->values) as $key) {
$ret[$key] = $this->get($key);
}
return $ret;
} | php | public function toArray()
{
$ret = array();
foreach (array_keys($this->values) as $key) {
$ret[$key] = $this->get($key);
}
return $ret;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"values",
")",
"as",
"$",
"key",
")",
"{",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
... | Returns the map as an array, with all values representing the set of
values associated with that key as an array
@return array | [
"Returns",
"the",
"map",
"as",
"an",
"array",
"with",
"all",
"values",
"representing",
"the",
"set",
"of",
"values",
"associated",
"with",
"that",
"key",
"as",
"an",
"array"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L191-L199 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php | SortedSetMap.stateChanged | private function stateChanged()
{
$keys = array_keys($this->values);
foreach ($keys as $key) {
if (!count($this->values[$key])) {
unset($this->values[$key]);
}
}
ksort($this->values);
} | php | private function stateChanged()
{
$keys = array_keys($this->values);
foreach ($keys as $key) {
if (!count($this->values[$key])) {
unset($this->values[$key]);
}
}
ksort($this->values);
} | [
"private",
"function",
"stateChanged",
"(",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"values",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"values",
... | Ensures all empty sets are removed, and sorts the sets by key name.
@return void | [
"Ensures",
"all",
"empty",
"sets",
"are",
"removed",
"and",
"sorts",
"the",
"sets",
"by",
"key",
"name",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Util/SortedSetMap.php#L207-L216 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Twig/ControlStructures/WithNode.php | WithNode.compileArgument | public function compileArgument($compiler, $argument)
{
if (empty($argument['name'])) {
$compiler
->write('(array) ')
->subcompile($argument['value']);
} else {
$compiler
->write('array(')
->repr($argument['name'])
->raw(' => ')
->subcompile($argument['value'])
->raw(')');
}
} | php | public function compileArgument($compiler, $argument)
{
if (empty($argument['name'])) {
$compiler
->write('(array) ')
->subcompile($argument['value']);
} else {
$compiler
->write('array(')
->repr($argument['name'])
->raw(' => ')
->subcompile($argument['value'])
->raw(')');
}
} | [
"public",
"function",
"compileArgument",
"(",
"$",
"compiler",
",",
"$",
"argument",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"argument",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"compiler",
"->",
"write",
"(",
"'(array) '",
")",
"->",
"subcompile",
"(",... | Compiles the 'with' argument.
@param Twig_Compiler $compiler
@param mixed $argument
@return void | [
"Compiles",
"the",
"with",
"argument",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Twig/ControlStructures/WithNode.php#L113-L127 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Helper/AnnotationRegistry.php | AnnotationRegistry.addAnnotation | public function addAnnotation($name, $value, $priority = 0)
{
$annotation = $this->getAnnotation($name);
$new_annotation = array('name' => $name, 'value' => $value, 'priority' => $priority);
if (!empty($annotation)) {
if ($priority > $annotation['value']['priority']) {
$this->setAnnotation($annotation['key'], $new_annotation);
}
} else {
$this->annotations[]= $new_annotation;
}
} | php | public function addAnnotation($name, $value, $priority = 0)
{
$annotation = $this->getAnnotation($name);
$new_annotation = array('name' => $name, 'value' => $value, 'priority' => $priority);
if (!empty($annotation)) {
if ($priority > $annotation['value']['priority']) {
$this->setAnnotation($annotation['key'], $new_annotation);
}
} else {
$this->annotations[]= $new_annotation;
}
} | [
"public",
"function",
"addAnnotation",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"annotation",
"=",
"$",
"this",
"->",
"getAnnotation",
"(",
"$",
"name",
")",
";",
"$",
"new_annotation",
"=",
"array",
"(",
"'... | Add an annotation.
@param string $name
@param mixed $value
@param int $priority
@return void | [
"Add",
"an",
"annotation",
"."
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/AnnotationRegistry.php#L39-L50 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/DependencyInjection/ZichtUrlExtension.php | ZichtUrlExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$config = $this->processConfiguration(new Configuration(), $configs);
if (!empty($config['unalias_subscriber'])) {
// deprecation, remove in next major
trigger_error('unalias_subscriber is no longer used. This has moved to form transformers.', E_USER_DEPRECATED);
}
if (isset($config['static_ref'])) {
$container->getDefinition('zicht_url.static_refs')->addMethodCall('addAll', [$config['static_ref']]);
}
if (!empty($config['aliasing']) && $config['aliasing']['enabled'] === true) {
$this->loadAliasingConfig($container, $config['aliasing'], $loader);
$container->setAlias('zicht_url.sitemap_provider', new Alias('zicht_url.alias_sitemap_provider'));
} else {
$container->setAlias('zicht_url.sitemap_provider', new Alias('zicht_url.provider'));
}
if (!empty($config['logging'])) {
$loader->load('logging.xml');
}
if (!empty($config['admin'])) {
$loader->load('admin.xml');
}
if (!empty($aliasingConfig) && $config['caching']['enabled'] === true) {
$loader->load('cache.xml');
$subscriberDefinition = $container->getDefinition('zicht_url.cache_subscriber');
$subscriberDefinition->replaceArgument(1, $config['caching']['entities']);
}
if (!empty($config['db_static_ref']) && $config['db_static_ref']['enabled'] === true) {
$loader->load('db.xml');
}
if ($container->hasDefinition('zicht_url.aliasing')) {
$container->getDefinition('zicht_url.twig_extension')->addArgument(new Reference('zicht_url.aliasing'));
}
if ($container->hasDefinition('zicht_url.mapper.html')) {
$container->getDefinition('zicht_url.mapper.html')->addMethodCall('addAttributes', [$config['html_attributes']]);
}
if ($container->hasDefinition('zicht_url.listener.strict_public_url')) {
$container->getDefinition('zicht_url.listener.strict_public_url')->replaceArgument(0, $config['strict_public_url']);
}
if ($container->hasDefinition('zicht_url.validator.contains_url_alias')) {
$container->getDefinition('zicht_url.validator.contains_url_alias')->replaceArgument(1, $config['strict_public_url']);
}
$formResources = $container->getParameter('twig.form.resources');
$formResources[] = 'ZichtUrlBundle::form_theme.html.twig';
$container->setParameter('twig.form.resources', $formResources);
} | php | public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$config = $this->processConfiguration(new Configuration(), $configs);
if (!empty($config['unalias_subscriber'])) {
// deprecation, remove in next major
trigger_error('unalias_subscriber is no longer used. This has moved to form transformers.', E_USER_DEPRECATED);
}
if (isset($config['static_ref'])) {
$container->getDefinition('zicht_url.static_refs')->addMethodCall('addAll', [$config['static_ref']]);
}
if (!empty($config['aliasing']) && $config['aliasing']['enabled'] === true) {
$this->loadAliasingConfig($container, $config['aliasing'], $loader);
$container->setAlias('zicht_url.sitemap_provider', new Alias('zicht_url.alias_sitemap_provider'));
} else {
$container->setAlias('zicht_url.sitemap_provider', new Alias('zicht_url.provider'));
}
if (!empty($config['logging'])) {
$loader->load('logging.xml');
}
if (!empty($config['admin'])) {
$loader->load('admin.xml');
}
if (!empty($aliasingConfig) && $config['caching']['enabled'] === true) {
$loader->load('cache.xml');
$subscriberDefinition = $container->getDefinition('zicht_url.cache_subscriber');
$subscriberDefinition->replaceArgument(1, $config['caching']['entities']);
}
if (!empty($config['db_static_ref']) && $config['db_static_ref']['enabled'] === true) {
$loader->load('db.xml');
}
if ($container->hasDefinition('zicht_url.aliasing')) {
$container->getDefinition('zicht_url.twig_extension')->addArgument(new Reference('zicht_url.aliasing'));
}
if ($container->hasDefinition('zicht_url.mapper.html')) {
$container->getDefinition('zicht_url.mapper.html')->addMethodCall('addAttributes', [$config['html_attributes']]);
}
if ($container->hasDefinition('zicht_url.listener.strict_public_url')) {
$container->getDefinition('zicht_url.listener.strict_public_url')->replaceArgument(0, $config['strict_public_url']);
}
if ($container->hasDefinition('zicht_url.validator.contains_url_alias')) {
$container->getDefinition('zicht_url.validator.contains_url_alias')->replaceArgument(1, $config['strict_public_url']);
}
$formResources = $container->getParameter('twig.form.resources');
$formResources[] = 'ZichtUrlBundle::form_theme.html.twig';
$container->setParameter('twig.form.resources', $formResources);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
... | Responds to the twig configuration parameter.
@param array $configs
@param ContainerBuilder $container
@return void | [
"Responds",
"to",
"the",
"twig",
"configuration",
"parameter",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/DependencyInjection/ZichtUrlExtension.php#L27-L83 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/DependencyInjection/ZichtUrlExtension.php | ZichtUrlExtension.loadAliasingConfig | protected function loadAliasingConfig(ContainerBuilder $container, $aliasingConfig, $loader)
{
$loader->load('aliasing.xml');
$listenerDefinition = $container->getDefinition('zicht_url.aliasing_listener');
if ($aliasingConfig['exclude_patterns']) {
$listenerDefinition->addMethodCall('setExcludePatterns', [$aliasingConfig['exclude_patterns']]);
}
$listenerDefinition->addMethodCall('setIsParamsEnabled', [$aliasingConfig['enable_params']]);
if ($aliasingConfig['automatic_entities']) {
$automaticAliasDoctrineDefinition = $container->getDefinition('zicht_url.aliasing.doctrine.subscriber');
foreach ($aliasingConfig['automatic_entities'] as $entityClass) {
$automaticAliasDoctrineDefinition->addMethodCall('addEntityClass', [$entityClass]);
}
}
} | php | protected function loadAliasingConfig(ContainerBuilder $container, $aliasingConfig, $loader)
{
$loader->load('aliasing.xml');
$listenerDefinition = $container->getDefinition('zicht_url.aliasing_listener');
if ($aliasingConfig['exclude_patterns']) {
$listenerDefinition->addMethodCall('setExcludePatterns', [$aliasingConfig['exclude_patterns']]);
}
$listenerDefinition->addMethodCall('setIsParamsEnabled', [$aliasingConfig['enable_params']]);
if ($aliasingConfig['automatic_entities']) {
$automaticAliasDoctrineDefinition = $container->getDefinition('zicht_url.aliasing.doctrine.subscriber');
foreach ($aliasingConfig['automatic_entities'] as $entityClass) {
$automaticAliasDoctrineDefinition->addMethodCall('addEntityClass', [$entityClass]);
}
}
} | [
"protected",
"function",
"loadAliasingConfig",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"aliasingConfig",
",",
"$",
"loader",
")",
"{",
"$",
"loader",
"->",
"load",
"(",
"'aliasing.xml'",
")",
";",
"$",
"listenerDefinition",
"=",
"$",
"container",
... | Load the aliasing config.
@param ContainerBuilder $container
@param array $aliasingConfig
@param XmlFileLoader $loader
@return void | [
"Load",
"the",
"aliasing",
"config",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/DependencyInjection/ZichtUrlExtension.php#L93-L111 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Twig/UrlExtension.php | UrlExtension.objectUrl | public function objectUrl($object, $defaultIfNotFound = null)
{
try {
$ret = $this->provider->url($object);
} catch (UnsupportedException $e) {
if (null === $defaultIfNotFound) {
throw $e;
} else {
if (true === $defaultIfNotFound) {
$ret = (string)$object;
} else {
$ret = $defaultIfNotFound;
}
}
}
return $ret;
} | php | public function objectUrl($object, $defaultIfNotFound = null)
{
try {
$ret = $this->provider->url($object);
} catch (UnsupportedException $e) {
if (null === $defaultIfNotFound) {
throw $e;
} else {
if (true === $defaultIfNotFound) {
$ret = (string)$object;
} else {
$ret = $defaultIfNotFound;
}
}
}
return $ret;
} | [
"public",
"function",
"objectUrl",
"(",
"$",
"object",
",",
"$",
"defaultIfNotFound",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"provider",
"->",
"url",
"(",
"$",
"object",
")",
";",
"}",
"catch",
"(",
"UnsupportedException... | Returns an url based on the passed object.
@param object $object
@param mixed $defaultIfNotFound
@return string | [
"Returns",
"an",
"url",
"based",
"on",
"the",
"passed",
"object",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Twig/UrlExtension.php#L74-L90 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Twig/UrlExtension.php | UrlExtension.staticRef | public function staticRef($name, $params = null)
{
$name = (string)$name;
if (!isset($this->static_refs[$name])) {
try {
$this->static_refs[$name] = $this->provider->url($name);
} catch (UnsupportedException $e) {
$this->static_refs[$name] = '/[static_reference: ' . $name . ']';
}
}
$ret = $this->static_refs[$name];
if ($params) {
$ret .= '?' . http_build_query($params, 0, '&');
}
return $ret;
} | php | public function staticRef($name, $params = null)
{
$name = (string)$name;
if (!isset($this->static_refs[$name])) {
try {
$this->static_refs[$name] = $this->provider->url($name);
} catch (UnsupportedException $e) {
$this->static_refs[$name] = '/[static_reference: ' . $name . ']';
}
}
$ret = $this->static_refs[$name];
if ($params) {
$ret .= '?' . http_build_query($params, 0, '&');
}
return $ret;
} | [
"public",
"function",
"staticRef",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"(",
"string",
")",
"$",
"name",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"static_refs",
"[",
"$",
"name",
"]",
")",
... | Returns a static reference, i.e. an url that is provided based on a simple string.
@param string $name
@param array $params
@return string | [
"Returns",
"a",
"static",
"reference",
"i",
".",
"e",
".",
"an",
"url",
"that",
"is",
"provided",
"based",
"on",
"a",
"simple",
"string",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Twig/UrlExtension.php#L100-L117 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Logging/Logging.php | Logging.createLog | public function createLog(Request $request, $message)
{
return new ErrorLog(
$message,
new \DateTime(),
$request->headers->get('referer', null),
$request->headers->get('user-agent', null),
$request->getClientIp(),
$request->getRequestUri()
);
} | php | public function createLog(Request $request, $message)
{
return new ErrorLog(
$message,
new \DateTime(),
$request->headers->get('referer', null),
$request->headers->get('user-agent', null),
$request->getClientIp(),
$request->getRequestUri()
);
} | [
"public",
"function",
"createLog",
"(",
"Request",
"$",
"request",
",",
"$",
"message",
")",
"{",
"return",
"new",
"ErrorLog",
"(",
"$",
"message",
",",
"new",
"\\",
"DateTime",
"(",
")",
",",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'refere... | Create a log entry for the passed request.
@param \Symfony\Component\HttpFoundation\Request $request
@param string $message
@return \Zicht\Bundle\UrlBundle\Entity\ErrorLog | [
"Create",
"a",
"log",
"entry",
"for",
"the",
"passed",
"request",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Logging/Logging.php#L32-L42 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Logging/Logging.php | Logging.flush | public function flush($entry)
{
$this->manager->persist($entry);
$this->manager->flush($entry);
} | php | public function flush($entry)
{
$this->manager->persist($entry);
$this->manager->flush($entry);
} | [
"public",
"function",
"flush",
"(",
"$",
"entry",
")",
"{",
"$",
"this",
"->",
"manager",
"->",
"persist",
"(",
"$",
"entry",
")",
";",
"$",
"this",
"->",
"manager",
"->",
"flush",
"(",
"$",
"entry",
")",
";",
"}"
] | Persist the log and flush the manager.
@param ErrorLog $entry
@return void | [
"Persist",
"the",
"log",
"and",
"flush",
"the",
"manager",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Logging/Logging.php#L51-L55 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/RemoveAliasSubscriber.php | RemoveAliasSubscriber.preRemove | public function preRemove($e)
{
$entity = $e->getObject();
if ($entity instanceof $this->className) {
// schedule alias removal (this needs to be done before the entity is removed and loses its id)
$this->container->get($this->aliaserServiceId)->removeAlias($entity, true);
}
} | php | public function preRemove($e)
{
$entity = $e->getObject();
if ($entity instanceof $this->className) {
// schedule alias removal (this needs to be done before the entity is removed and loses its id)
$this->container->get($this->aliaserServiceId)->removeAlias($entity, true);
}
} | [
"public",
"function",
"preRemove",
"(",
"$",
"e",
")",
"{",
"$",
"entity",
"=",
"$",
"e",
"->",
"getObject",
"(",
")",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"$",
"this",
"->",
"className",
")",
"{",
"// schedule alias removal (this needs to be done be... | Schedule an object's alias to be deleted.
@param LifecycleEventArgs $e
@return void | [
"Schedule",
"an",
"object",
"s",
"alias",
"to",
"be",
"deleted",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Doctrine/RemoveAliasSubscriber.php#L34-L42 | train |
zicht/url-bundle | src/Zicht/Bundle/UrlBundle/Controller/StaticReferenceController.php | StaticReferenceController.redirectAction | public function redirectAction(Request $request, $name, $code = 301)
{
return new RedirectResponse(
$this->get('zicht_url.provider')->url($name),
$code
);
} | php | public function redirectAction(Request $request, $name, $code = 301)
{
return new RedirectResponse(
$this->get('zicht_url.provider')->url($name),
$code
);
} | [
"public",
"function",
"redirectAction",
"(",
"Request",
"$",
"request",
",",
"$",
"name",
",",
"$",
"code",
"=",
"301",
")",
"{",
"return",
"new",
"RedirectResponse",
"(",
"$",
"this",
"->",
"get",
"(",
"'zicht_url.provider'",
")",
"->",
"url",
"(",
"$",... | Redirects to the url provided by the main url provider service.
@param Request $request
@param string $name
@param int $code
@return \Symfony\Component\HttpFoundation\RedirectResponse
@Route("/_static-ref/{name}") | [
"Redirects",
"to",
"the",
"url",
"provided",
"by",
"the",
"main",
"url",
"provider",
"service",
"."
] | 4638524124c84b61c02d5194f8a28f34e9eb9845 | https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Controller/StaticReferenceController.php#L28-L34 | train |
zicht/framework-extra-bundle | src/Zicht/Bundle/FrameworkExtraBundle/Command/ValidateEntityCommand.php | ValidateEntityCommand.getAllEntities | protected function getAllEntities()
{
$allMeta = $this
->getContainer()
->get('doctrine')
->getManager()
->getMetadataFactory()
->getAllMetadata();
/** @var \Doctrine\ORM\Mapping\ClassMetadata $meta */
foreach ($allMeta as $meta) {
if (!$meta->isMappedSuperclass && empty($meta->subClasses)) {
yield $meta->getName();
}
}
} | php | protected function getAllEntities()
{
$allMeta = $this
->getContainer()
->get('doctrine')
->getManager()
->getMetadataFactory()
->getAllMetadata();
/** @var \Doctrine\ORM\Mapping\ClassMetadata $meta */
foreach ($allMeta as $meta) {
if (!$meta->isMappedSuperclass && empty($meta->subClasses)) {
yield $meta->getName();
}
}
} | [
"protected",
"function",
"getAllEntities",
"(",
")",
"{",
"$",
"allMeta",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'doctrine'",
")",
"->",
"getManager",
"(",
")",
"->",
"getMetadataFactory",
"(",
")",
"->",
"getAllMetadata",
"("... | get all entities
@return \Generator | [
"get",
"all",
"entities"
] | 8482ca491aabdec565b15bf6c10c588a98c458a5 | https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Command/ValidateEntityCommand.php#L63-L78 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.translateMessage | protected function translateMessage($message, array $parameters = array())
{
return $this->translator->trans($message, $parameters, $this->transDomain);
} | php | protected function translateMessage($message, array $parameters = array())
{
return $this->translator->trans($message, $parameters, $this->transDomain);
} | [
"protected",
"function",
"translateMessage",
"(",
"$",
"message",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"$",
"message",
",",
"$",
"parameters",
",",
"$",
"this",
... | Translate a single message
@param string $message
@return string
@codeCoverageIgnore | [
"Translate",
"a",
"single",
"message"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L107-L110 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.siftQueue | public function siftQueue()
{
foreach ($this->queue as $name => $form) {
$blockName = $form->getConfig()->getOption('block_name');
if ('_token' == $name || 'entry' == $blockName || $form->getParent()) {
unset($this->queue[$name]);
}
}
return $this;
} | php | public function siftQueue()
{
foreach ($this->queue as $name => $form) {
$blockName = $form->getConfig()->getOption('block_name');
if ('_token' == $name || 'entry' == $blockName || $form->getParent()) {
unset($this->queue[$name]);
}
}
return $this;
} | [
"public",
"function",
"siftQueue",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"queue",
"as",
"$",
"name",
"=>",
"$",
"form",
")",
"{",
"$",
"blockName",
"=",
"$",
"form",
"->",
"getConfig",
"(",
")",
"->",
"getOption",
"(",
"'block_name'",
")"... | Removes from the queue elements which are not parent forms and should not be processes
@return $this | [
"Removes",
"from",
"the",
"queue",
"elements",
"which",
"are",
"not",
"parent",
"forms",
"and",
"should",
"not",
"be",
"processes"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L198-L208 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.createJsModel | public function createJsModel(Form $form)
{
$this->currentElement = $form;
$conf = $form->getConfig();
// If field is disabled or has no any validations
if (false === $conf->getOption('js_validation')) {
return null;
}
$model = new JsFormElement;
$model->id = $this->getElementId($form);
$model->name = $form->getName();
$model->type = get_class($conf->getType()->getInnerType());
$model->invalidMessage = $this->translateMessage(
$conf->getOption('invalid_message'),
$conf->getOption('invalid_message_parameters')
);
$model->transformers = $this->normalizeViewTransformers(
$form,
$this->parseTransformers($conf->getViewTransformers())
);
$model->bubbling = $conf->getOption('error_bubbling');
$model->data = $this->getValidationData($form);
$model->children = $this->processChildren($form);
$prototype = $form->getConfig()->getAttribute('prototype');
if ($prototype) {
$model->prototype = $this->createJsModel($prototype);
}
// Return self id to add it as child to the parent model
return $model;
} | php | public function createJsModel(Form $form)
{
$this->currentElement = $form;
$conf = $form->getConfig();
// If field is disabled or has no any validations
if (false === $conf->getOption('js_validation')) {
return null;
}
$model = new JsFormElement;
$model->id = $this->getElementId($form);
$model->name = $form->getName();
$model->type = get_class($conf->getType()->getInnerType());
$model->invalidMessage = $this->translateMessage(
$conf->getOption('invalid_message'),
$conf->getOption('invalid_message_parameters')
);
$model->transformers = $this->normalizeViewTransformers(
$form,
$this->parseTransformers($conf->getViewTransformers())
);
$model->bubbling = $conf->getOption('error_bubbling');
$model->data = $this->getValidationData($form);
$model->children = $this->processChildren($form);
$prototype = $form->getConfig()->getAttribute('prototype');
if ($prototype) {
$model->prototype = $this->createJsModel($prototype);
}
// Return self id to add it as child to the parent model
return $model;
} | [
"public",
"function",
"createJsModel",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"this",
"->",
"currentElement",
"=",
"$",
"form",
";",
"$",
"conf",
"=",
"$",
"form",
"->",
"getConfig",
"(",
")",
";",
"// If field is disabled or has no any validations",
"if",
... | The main function that creates nested model
@param Form $form
@return null|JsFormElement | [
"The",
"main",
"function",
"that",
"creates",
"nested",
"model"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L234-L267 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.processChildren | protected function processChildren($form)
{
$result = array();
// If this field has children - process them
foreach ($form as $name => $child) {
if ($this->isProcessableElement($child)) {
$childModel = $this->createJsModel($child);
if (null !== $childModel) {
$result[$name] = $childModel;
}
}
}
return $result;
} | php | protected function processChildren($form)
{
$result = array();
// If this field has children - process them
foreach ($form as $name => $child) {
if ($this->isProcessableElement($child)) {
$childModel = $this->createJsModel($child);
if (null !== $childModel) {
$result[$name] = $childModel;
}
}
}
return $result;
} | [
"protected",
"function",
"processChildren",
"(",
"$",
"form",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// If this field has children - process them",
"foreach",
"(",
"$",
"form",
"as",
"$",
"name",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"$"... | Create the JsFormElement for all the children of specified element
@param null|Form $form
@return array | [
"Create",
"the",
"JsFormElement",
"for",
"all",
"the",
"children",
"of",
"specified",
"element"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L276-L290 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.getElementId | protected function getElementId(Form $form)
{
/** @var Form $parent */
$parent = $form->getParent();
if (null !== $parent) {
return $this->getElementId($parent) . '_' . $form->getName();
} else {
return $form->getName();
}
} | php | protected function getElementId(Form $form)
{
/** @var Form $parent */
$parent = $form->getParent();
if (null !== $parent) {
return $this->getElementId($parent) . '_' . $form->getName();
} else {
return $form->getName();
}
} | [
"protected",
"function",
"getElementId",
"(",
"Form",
"$",
"form",
")",
"{",
"/** @var Form $parent */",
"$",
"parent",
"=",
"$",
"form",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"parent",
")",
"{",
"return",
"$",
"this",
"->",
... | Generate an Id for the element by merging the current element name
with all the parents names
@param Form $form
@return string | [
"Generate",
"an",
"Id",
"for",
"the",
"element",
"by",
"merging",
"the",
"current",
"element",
"name",
"with",
"all",
"the",
"parents",
"names"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L300-L309 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.getValidationGroups | protected function getValidationGroups(Form $form)
{
$result = array('Default');
$groups = $form->getConfig()->getOption('validation_groups');
if (empty($groups)) {
// Try to get groups from a parent
if ($form->getParent()) {
$result = $this->getValidationGroups($form->getParent());
}
} elseif (is_array($groups)) {
// If groups is an array - return groups as is
$result = $groups;
} elseif ($groups instanceof \Closure) {
// If groups is a Closure - return the form class name to look for javascript
$result = $this->getElementId($form);
}
return $result;
} | php | protected function getValidationGroups(Form $form)
{
$result = array('Default');
$groups = $form->getConfig()->getOption('validation_groups');
if (empty($groups)) {
// Try to get groups from a parent
if ($form->getParent()) {
$result = $this->getValidationGroups($form->getParent());
}
} elseif (is_array($groups)) {
// If groups is an array - return groups as is
$result = $groups;
} elseif ($groups instanceof \Closure) {
// If groups is a Closure - return the form class name to look for javascript
$result = $this->getElementId($form);
}
return $result;
} | [
"protected",
"function",
"getValidationGroups",
"(",
"Form",
"$",
"form",
")",
"{",
"$",
"result",
"=",
"array",
"(",
"'Default'",
")",
";",
"$",
"groups",
"=",
"$",
"form",
"->",
"getConfig",
"(",
")",
"->",
"getOption",
"(",
"'validation_groups'",
")",
... | Get validation groups for the specified form
@param Form|FormInterface $form
@return array|string | [
"Get",
"validation",
"groups",
"for",
"the",
"specified",
"form"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L421-L440 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.parseTransformers | protected function parseTransformers(array $transformers)
{
$result = array();
foreach ($transformers as $trans) {
$item = array();
$reflect = new \ReflectionClass($trans);
$properties = $reflect->getProperties();
foreach ($properties as $prop) {
$item[$prop->getName()] = $this->getTransformerParam($trans, $prop->getName());
}
$item['name'] = get_class($trans);
$result[] = $item;
}
return $result;
} | php | protected function parseTransformers(array $transformers)
{
$result = array();
foreach ($transformers as $trans) {
$item = array();
$reflect = new \ReflectionClass($trans);
$properties = $reflect->getProperties();
foreach ($properties as $prop) {
$item[$prop->getName()] = $this->getTransformerParam($trans, $prop->getName());
}
$item['name'] = get_class($trans);
$result[] = $item;
}
return $result;
} | [
"protected",
"function",
"parseTransformers",
"(",
"array",
"$",
"transformers",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"transformers",
"as",
"$",
"trans",
")",
"{",
"$",
"item",
"=",
"array",
"(",
")",
";",
"$",
"... | Convert transformers objects to data arrays
@param array $transformers
@return array | [
"Convert",
"transformers",
"objects",
"to",
"data",
"arrays"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L487-L504 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.getTransformerParam | protected function getTransformerParam(DataTransformerInterface $transformer, $paramName)
{
$reflection = new \ReflectionProperty($transformer, $paramName);
$reflection->setAccessible(true);
$value = $reflection->getValue($transformer);
$result = null;
if ('transformers' === $paramName && is_array($value)) {
$result = $this->parseTransformers($value);
} elseif (is_scalar($value) || is_array($value)) {
$result = $value;
} elseif ($value instanceof ChoiceListInterface) {
$result = array_values($value->getChoices());
}
return $result;
} | php | protected function getTransformerParam(DataTransformerInterface $transformer, $paramName)
{
$reflection = new \ReflectionProperty($transformer, $paramName);
$reflection->setAccessible(true);
$value = $reflection->getValue($transformer);
$result = null;
if ('transformers' === $paramName && is_array($value)) {
$result = $this->parseTransformers($value);
} elseif (is_scalar($value) || is_array($value)) {
$result = $value;
} elseif ($value instanceof ChoiceListInterface) {
$result = array_values($value->getChoices());
}
return $result;
} | [
"protected",
"function",
"getTransformerParam",
"(",
"DataTransformerInterface",
"$",
"transformer",
",",
"$",
"paramName",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionProperty",
"(",
"$",
"transformer",
",",
"$",
"paramName",
")",
";",
"$",
"refle... | Get the specified non-public transformer property
@param DataTransformerInterface $transformer
@param string $paramName
@return mixed | [
"Get",
"the",
"specified",
"non",
"-",
"public",
"transformer",
"property"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L514-L530 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.parseGetters | protected function parseGetters(array $getters)
{
$result = array();
foreach ($getters as $getter) {
$result[$getter->getName()] = $this->parseConstraints((array)$getter->getConstraints());
}
return $result;
} | php | protected function parseGetters(array $getters)
{
$result = array();
foreach ($getters as $getter) {
$result[$getter->getName()] = $this->parseConstraints((array)$getter->getConstraints());
}
return $result;
} | [
"protected",
"function",
"parseGetters",
"(",
"array",
"$",
"getters",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"getters",
"as",
"$",
"getter",
")",
"{",
"$",
"result",
"[",
"$",
"getter",
"->",
"getName",
"(",
")",
... | Converts list of the GetterMetadata objects to a data array
@param GetterMetadata[] $getters
@return array | [
"Converts",
"list",
"of",
"the",
"GetterMetadata",
"objects",
"to",
"a",
"data",
"array"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L539-L547 | train |
formapro/JsFormValidatorBundle | Factory/JsFormValidatorFactory.php | JsFormValidatorFactory.parseConstraints | protected function parseConstraints(array $constraints)
{
$result = array();
foreach ($constraints as $item) {
// Translate messages if need and add to result
foreach ($item as $propName => $propValue) {
if (false !== strpos(strtolower($propName), 'message')) {
$item->{$propName} = $this->translateMessage($propValue);
}
}
if ($item instanceof \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity) {
$item = new UniqueEntity($item, $this->currentElement->getConfig()->getDataClass());
}
$result[get_class($item)][] = $item;
}
return $result;
} | php | protected function parseConstraints(array $constraints)
{
$result = array();
foreach ($constraints as $item) {
// Translate messages if need and add to result
foreach ($item as $propName => $propValue) {
if (false !== strpos(strtolower($propName), 'message')) {
$item->{$propName} = $this->translateMessage($propValue);
}
}
if ($item instanceof \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity) {
$item = new UniqueEntity($item, $this->currentElement->getConfig()->getDataClass());
}
$result[get_class($item)][] = $item;
}
return $result;
} | [
"protected",
"function",
"parseConstraints",
"(",
"array",
"$",
"constraints",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"item",
")",
"{",
"// Translate messages if need and add to result",
"foreach",
"(... | Converts list of constraints objects to a data array
@param array $constraints
@return array | [
"Converts",
"list",
"of",
"constraints",
"objects",
"to",
"a",
"data",
"array"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Factory/JsFormValidatorFactory.php#L556-L575 | train |
formapro/JsFormValidatorBundle | Model/JsModelAbstract.php | JsModelAbstract.phpValueToJs | public static function phpValueToJs($value)
{
// For object which has own __toString method
if ($value instanceof JsModelAbstract) {
return $value->toJsString();
}
// For object which has own __toString method
elseif (is_object($value) && method_exists($value, '__toString')) {
return self::phpValueToJs($value->__toString());
}
// For an object or associative array
elseif (is_object($value) || (is_array($value) && array_values($value) !== $value)) {
$jsObject = array();
foreach ($value as $paramName => $paramValue) {
$paramName = addcslashes($paramName, '\'\\');
$jsObject[] = "'$paramName':" . self::phpValueToJs($paramValue);
}
return sprintf('{%1$s}', implode($jsObject, ','));
}
// For a sequential array
elseif (is_array($value)) {
$jsArray = array();
foreach ($value as $item) {
$jsArray[] = self::phpValueToJs($item);
}
return sprintf('[%1$s]', implode($jsArray, ','));
}
// For string
elseif (is_string($value)) {
$value = addcslashes($value, '\'\\');
return "'$value'";
}
// For boolean
elseif (is_bool($value)) {
return true === $value ? 'true' : 'false';
}
// For numbers
elseif (is_numeric($value)) {
return $value;
}
// For null
elseif (is_null($value)) {
return 'null';
}
// Otherwise
else {
return 'undefined';
}
} | php | public static function phpValueToJs($value)
{
// For object which has own __toString method
if ($value instanceof JsModelAbstract) {
return $value->toJsString();
}
// For object which has own __toString method
elseif (is_object($value) && method_exists($value, '__toString')) {
return self::phpValueToJs($value->__toString());
}
// For an object or associative array
elseif (is_object($value) || (is_array($value) && array_values($value) !== $value)) {
$jsObject = array();
foreach ($value as $paramName => $paramValue) {
$paramName = addcslashes($paramName, '\'\\');
$jsObject[] = "'$paramName':" . self::phpValueToJs($paramValue);
}
return sprintf('{%1$s}', implode($jsObject, ','));
}
// For a sequential array
elseif (is_array($value)) {
$jsArray = array();
foreach ($value as $item) {
$jsArray[] = self::phpValueToJs($item);
}
return sprintf('[%1$s]', implode($jsArray, ','));
}
// For string
elseif (is_string($value)) {
$value = addcslashes($value, '\'\\');
return "'$value'";
}
// For boolean
elseif (is_bool($value)) {
return true === $value ? 'true' : 'false';
}
// For numbers
elseif (is_numeric($value)) {
return $value;
}
// For null
elseif (is_null($value)) {
return 'null';
}
// Otherwise
else {
return 'undefined';
}
} | [
"public",
"static",
"function",
"phpValueToJs",
"(",
"$",
"value",
")",
"{",
"// For object which has own __toString method",
"if",
"(",
"$",
"value",
"instanceof",
"JsModelAbstract",
")",
"{",
"return",
"$",
"value",
"->",
"toJsString",
"(",
")",
";",
"}",
"// ... | Convert php value to the Javascript formatted string
@param mixed $value
@return string | [
"Convert",
"php",
"value",
"to",
"the",
"Javascript",
"formatted",
"string"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Model/JsModelAbstract.php#L39-L90 | train |
formapro/JsFormValidatorBundle | Controller/AjaxController.php | AjaxController.checkUniqueEntityAction | public function checkUniqueEntityAction(Request $request)
{
$data = $request->request->all();
foreach ($data['data'] as $value) {
// If field(s) has an empty value and it should be ignored
if ((bool) $data['ignoreNull'] && ('' === $value || is_null($value))) {
// Just return a positive result
return new JsonResponse(true);
}
}
$entity = $this
->get('doctrine')
->getRepository($data['entityName'])
->{$data['repositoryMethod']}($data['data'])
;
return new JsonResponse(empty($entity));
} | php | public function checkUniqueEntityAction(Request $request)
{
$data = $request->request->all();
foreach ($data['data'] as $value) {
// If field(s) has an empty value and it should be ignored
if ((bool) $data['ignoreNull'] && ('' === $value || is_null($value))) {
// Just return a positive result
return new JsonResponse(true);
}
}
$entity = $this
->get('doctrine')
->getRepository($data['entityName'])
->{$data['repositoryMethod']}($data['data'])
;
return new JsonResponse(empty($entity));
} | [
"public",
"function",
"checkUniqueEntityAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"[",
"'data'",
"]",
"as",
"$",
"value",
")",
"{",
"... | This is simplified analog for the UniqueEntity validator
@param \Symfony\Component\HttpFoundation\Request $request
@return JsonResponse | [
"This",
"is",
"simplified",
"analog",
"for",
"the",
"UniqueEntity",
"validator"
] | c1cb6b0d40506c6056dc20d3d8378964f76b896f | https://github.com/formapro/JsFormValidatorBundle/blob/c1cb6b0d40506c6056dc20d3d8378964f76b896f/Controller/AjaxController.php#L24-L42 | train |
vitalets/x-editable-yii | EditableSaver.php | EditableSaver.checkErrors | public function checkErrors()
{
if ($this->model->hasErrors()) {
$msg = array();
foreach($this->model->getErrors() as $attribute => $errors) {
$msg = array_merge($msg, $errors);
}
//todo: show several messages. should be checked in x-editable js
//$this->error(join("\n", $msg));
$this->error($msg[0]);
}
} | php | public function checkErrors()
{
if ($this->model->hasErrors()) {
$msg = array();
foreach($this->model->getErrors() as $attribute => $errors) {
$msg = array_merge($msg, $errors);
}
//todo: show several messages. should be checked in x-editable js
//$this->error(join("\n", $msg));
$this->error($msg[0]);
}
} | [
"public",
"function",
"checkErrors",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"model",
"->",
"hasErrors",
"(",
")",
")",
"{",
"$",
"msg",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"model",
"->",
"getErrors",
"(",
")",
"a... | errors as CHttpException
@param $msg
@throws CHttpException | [
"errors",
"as",
"CHttpException"
] | 06faae330f3bdb150cf33dfb7e7e0c731e376647 | https://github.com/vitalets/x-editable-yii/blob/06faae330f3bdb150cf33dfb7e7e0c731e376647/EditableSaver.php#L196-L207 | train |
sskaje/mqtt | mqtt/Message.php | Message.Create | static public function Create($message_type, MQTT $mqtt)
{
if (!isset(Message::$name[$message_type])) {
throw new Exception('Message type not defined');
}
$class = __NAMESPACE__ . '\\Message\\' . self::$name[$message_type];
return new $class($mqtt);
} | php | static public function Create($message_type, MQTT $mqtt)
{
if (!isset(Message::$name[$message_type])) {
throw new Exception('Message type not defined');
}
$class = __NAMESPACE__ . '\\Message\\' . self::$name[$message_type];
return new $class($mqtt);
} | [
"static",
"public",
"function",
"Create",
"(",
"$",
"message_type",
",",
"MQTT",
"$",
"mqtt",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"Message",
"::",
"$",
"name",
"[",
"$",
"message_type",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Mess... | Create Message Object
@param int $message_type
@param MQTT $mqtt
@return mixed
@throws Exception | [
"Create",
"Message",
"Object"
] | 38cf01a177ed8e6ff387cdefcf11ba42594e330f | https://github.com/sskaje/mqtt/blob/38cf01a177ed8e6ff387cdefcf11ba42594e330f/mqtt/Message.php#L130-L139 | train |
sskaje/mqtt | mqtt/SocketClient.php | SocketClient.set_blocking | public function set_blocking()
{
if (!$this->socket || !is_resource($this->socket)) return false;
Debug::Log(Debug::DEBUG, 'SOCKET: blocking mode: ON');
stream_set_blocking($this->socket, true);
return true;
} | php | public function set_blocking()
{
if (!$this->socket || !is_resource($this->socket)) return false;
Debug::Log(Debug::DEBUG, 'SOCKET: blocking mode: ON');
stream_set_blocking($this->socket, true);
return true;
} | [
"public",
"function",
"set_blocking",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"socket",
"||",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"return",
"false",
";",
"Debug",
"::",
"Log",
"(",
"Debug",
"::",
"DEBUG",
",",
... | Set Blocking Mode | [
"Set",
"Blocking",
"Mode"
] | 38cf01a177ed8e6ff387cdefcf11ba42594e330f | https://github.com/sskaje/mqtt/blob/38cf01a177ed8e6ff387cdefcf11ba42594e330f/mqtt/SocketClient.php#L136-L142 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.