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
sulu/sulu
src/Sulu/Component/Content/SmartContent/QueryBuilder.php
QueryBuilder.buildAudienceTargeting
private function buildAudienceTargeting($targetGroupId, $locale) { if (!$targetGroupId) { return; } $structure = $this->structureManager->getStructure('excerpt'); $property = new TranslatedProperty( $structure->getProperty('audience_targeting_groups'), $locale, $this->languageNamespace, 'excerpt' ); return 'page.[' . $property->getName() . '] = ' . $targetGroupId; }
php
private function buildAudienceTargeting($targetGroupId, $locale) { if (!$targetGroupId) { return; } $structure = $this->structureManager->getStructure('excerpt'); $property = new TranslatedProperty( $structure->getProperty('audience_targeting_groups'), $locale, $this->languageNamespace, 'excerpt' ); return 'page.[' . $property->getName() . '] = ' . $targetGroupId; }
[ "private", "function", "buildAudienceTargeting", "(", "$", "targetGroupId", ",", "$", "locale", ")", "{", "if", "(", "!", "$", "targetGroupId", ")", "{", "return", ";", "}", "$", "structure", "=", "$", "this", "->", "structureManager", "->", "getStructure", "(", "'excerpt'", ")", ";", "$", "property", "=", "new", "TranslatedProperty", "(", "$", "structure", "->", "getProperty", "(", "'audience_targeting_groups'", ")", ",", "$", "locale", ",", "$", "this", "->", "languageNamespace", ",", "'excerpt'", ")", ";", "return", "'page.['", ".", "$", "property", "->", "getName", "(", ")", ".", "'] = '", ".", "$", "targetGroupId", ";", "}" ]
Returns the where part for the audience targeting. @param string $targetGroupId @param string $locale @return string
[ "Returns", "the", "where", "part", "for", "the", "audience", "targeting", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/SmartContent/QueryBuilder.php#L284-L300
train
sulu/sulu
src/Sulu/Component/Content/SmartContent/QueryBuilder.php
QueryBuilder.buildTagsWhere
private function buildTagsWhere($tags, $operator, $languageCode) { $structure = $this->structureManager->getStructure('excerpt'); $sql2Where = []; if ($structure->hasProperty('tags')) { $property = new TranslatedProperty( $structure->getProperty('tags'), $languageCode, $this->languageNamespace, 'excerpt' ); foreach ($tags as $tag) { $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $tag; } if (count($sql2Where) > 0) { return '(' . implode(' ' . strtoupper($operator) . ' ', $sql2Where) . ')'; } } return ''; }
php
private function buildTagsWhere($tags, $operator, $languageCode) { $structure = $this->structureManager->getStructure('excerpt'); $sql2Where = []; if ($structure->hasProperty('tags')) { $property = new TranslatedProperty( $structure->getProperty('tags'), $languageCode, $this->languageNamespace, 'excerpt' ); foreach ($tags as $tag) { $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $tag; } if (count($sql2Where) > 0) { return '(' . implode(' ' . strtoupper($operator) . ' ', $sql2Where) . ')'; } } return ''; }
[ "private", "function", "buildTagsWhere", "(", "$", "tags", ",", "$", "operator", ",", "$", "languageCode", ")", "{", "$", "structure", "=", "$", "this", "->", "structureManager", "->", "getStructure", "(", "'excerpt'", ")", ";", "$", "sql2Where", "=", "[", "]", ";", "if", "(", "$", "structure", "->", "hasProperty", "(", "'tags'", ")", ")", "{", "$", "property", "=", "new", "TranslatedProperty", "(", "$", "structure", "->", "getProperty", "(", "'tags'", ")", ",", "$", "languageCode", ",", "$", "this", "->", "languageNamespace", ",", "'excerpt'", ")", ";", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "sql2Where", "[", "]", "=", "'page.['", ".", "$", "property", "->", "getName", "(", ")", ".", "'] = '", ".", "$", "tag", ";", "}", "if", "(", "count", "(", "$", "sql2Where", ")", ">", "0", ")", "{", "return", "'('", ".", "implode", "(", "' '", ".", "strtoupper", "(", "$", "operator", ")", ".", "' '", ",", "$", "sql2Where", ")", ".", "')'", ";", "}", "}", "return", "''", ";", "}" ]
build tags where clauses.
[ "build", "tags", "where", "clauses", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/SmartContent/QueryBuilder.php#L305-L328
train
sulu/sulu
src/Sulu/Component/Content/SmartContent/QueryBuilder.php
QueryBuilder.buildCategoriesWhere
private function buildCategoriesWhere($categories, $operator, $languageCode) { $structure = $this->structureManager->getStructure('excerpt'); $sql2Where = []; if ($structure->hasProperty('categories')) { $property = new TranslatedProperty( $structure->getProperty('categories'), $languageCode, $this->languageNamespace, 'excerpt' ); foreach ($categories as $category) { $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $category; } if (count($sql2Where) > 0) { return '(' . implode(' ' . strtoupper($operator) . ' ', $sql2Where) . ')'; } } return ''; }
php
private function buildCategoriesWhere($categories, $operator, $languageCode) { $structure = $this->structureManager->getStructure('excerpt'); $sql2Where = []; if ($structure->hasProperty('categories')) { $property = new TranslatedProperty( $structure->getProperty('categories'), $languageCode, $this->languageNamespace, 'excerpt' ); foreach ($categories as $category) { $sql2Where[] = 'page.[' . $property->getName() . '] = ' . $category; } if (count($sql2Where) > 0) { return '(' . implode(' ' . strtoupper($operator) . ' ', $sql2Where) . ')'; } } return ''; }
[ "private", "function", "buildCategoriesWhere", "(", "$", "categories", ",", "$", "operator", ",", "$", "languageCode", ")", "{", "$", "structure", "=", "$", "this", "->", "structureManager", "->", "getStructure", "(", "'excerpt'", ")", ";", "$", "sql2Where", "=", "[", "]", ";", "if", "(", "$", "structure", "->", "hasProperty", "(", "'categories'", ")", ")", "{", "$", "property", "=", "new", "TranslatedProperty", "(", "$", "structure", "->", "getProperty", "(", "'categories'", ")", ",", "$", "languageCode", ",", "$", "this", "->", "languageNamespace", ",", "'excerpt'", ")", ";", "foreach", "(", "$", "categories", "as", "$", "category", ")", "{", "$", "sql2Where", "[", "]", "=", "'page.['", ".", "$", "property", "->", "getName", "(", ")", ".", "'] = '", ".", "$", "category", ";", "}", "if", "(", "count", "(", "$", "sql2Where", ")", ">", "0", ")", "{", "return", "'('", ".", "implode", "(", "' '", ".", "strtoupper", "(", "$", "operator", ")", ".", "' '", ",", "$", "sql2Where", ")", ".", "')'", ";", "}", "}", "return", "''", ";", "}" ]
build categories where clauses.
[ "build", "categories", "where", "clauses", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/SmartContent/QueryBuilder.php#L333-L355
train
sulu/sulu
src/Sulu/Component/Content/SmartContent/QueryBuilder.php
QueryBuilder.buildPageSelector
protected function buildPageSelector() { $idsWhere = []; foreach ($this->ids as $id) { $idsWhere[] = sprintf("page.[jcr:uuid] = '%s'", $id); } return '(' . implode(' OR ', $idsWhere) . ')'; }
php
protected function buildPageSelector() { $idsWhere = []; foreach ($this->ids as $id) { $idsWhere[] = sprintf("page.[jcr:uuid] = '%s'", $id); } return '(' . implode(' OR ', $idsWhere) . ')'; }
[ "protected", "function", "buildPageSelector", "(", ")", "{", "$", "idsWhere", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "ids", "as", "$", "id", ")", "{", "$", "idsWhere", "[", "]", "=", "sprintf", "(", "\"page.[jcr:uuid] = '%s'\"", ",", "$", "id", ")", ";", "}", "return", "'('", ".", "implode", "(", "' OR '", ",", "$", "idsWhere", ")", ".", "')'", ";", "}" ]
build select for uuids.
[ "build", "select", "for", "uuids", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/SmartContent/QueryBuilder.php#L389-L397
train
sulu/sulu
src/Sulu/Component/Content/SmartContent/QueryBuilder.php
QueryBuilder.buildPageExclude
private function buildPageExclude() { $idsWhere = []; foreach ($this->excluded as $id) { $idsWhere[] = sprintf("(NOT page.[jcr:uuid] = '%s')", $id); } return $idsWhere; }
php
private function buildPageExclude() { $idsWhere = []; foreach ($this->excluded as $id) { $idsWhere[] = sprintf("(NOT page.[jcr:uuid] = '%s')", $id); } return $idsWhere; }
[ "private", "function", "buildPageExclude", "(", ")", "{", "$", "idsWhere", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "excluded", "as", "$", "id", ")", "{", "$", "idsWhere", "[", "]", "=", "sprintf", "(", "\"(NOT page.[jcr:uuid] = '%s')\"", ",", "$", "id", ")", ";", "}", "return", "$", "idsWhere", ";", "}" ]
build sql for exluded Pages.
[ "build", "sql", "for", "exluded", "Pages", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/SmartContent/QueryBuilder.php#L402-L410
train
sulu/sulu
src/Sulu/Bundle/AudienceTargetingBundle/Serializer/Subscriber/TargetGroupSerializeSubscriber.php
TargetGroupSerializeSubscriber.onPostDeserialize
public function onPostDeserialize(ObjectEvent $event) { /** @var TargetGroupInterface $targetGroup */ $targetGroup = $event->getObject(); if (!$targetGroup instanceof TargetGroupInterface) { return; } /* @var TargetGroupWebspaceInterface $webspace */ if ($targetGroup->getWebspaces()) { foreach ($targetGroup->getWebspaces() as $webspace) { $webspace->setTargetGroup($targetGroup); } } if ($targetGroup->getRules()) { foreach ($targetGroup->getRules() as $rule) { $rule->setTargetGroup($targetGroup); } } }
php
public function onPostDeserialize(ObjectEvent $event) { /** @var TargetGroupInterface $targetGroup */ $targetGroup = $event->getObject(); if (!$targetGroup instanceof TargetGroupInterface) { return; } /* @var TargetGroupWebspaceInterface $webspace */ if ($targetGroup->getWebspaces()) { foreach ($targetGroup->getWebspaces() as $webspace) { $webspace->setTargetGroup($targetGroup); } } if ($targetGroup->getRules()) { foreach ($targetGroup->getRules() as $rule) { $rule->setTargetGroup($targetGroup); } } }
[ "public", "function", "onPostDeserialize", "(", "ObjectEvent", "$", "event", ")", "{", "/** @var TargetGroupInterface $targetGroup */", "$", "targetGroup", "=", "$", "event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "targetGroup", "instanceof", "TargetGroupInterface", ")", "{", "return", ";", "}", "/* @var TargetGroupWebspaceInterface $webspace */", "if", "(", "$", "targetGroup", "->", "getWebspaces", "(", ")", ")", "{", "foreach", "(", "$", "targetGroup", "->", "getWebspaces", "(", ")", "as", "$", "webspace", ")", "{", "$", "webspace", "->", "setTargetGroup", "(", "$", "targetGroup", ")", ";", "}", "}", "if", "(", "$", "targetGroup", "->", "getRules", "(", ")", ")", "{", "foreach", "(", "$", "targetGroup", "->", "getRules", "(", ")", "as", "$", "rule", ")", "{", "$", "rule", "->", "setTargetGroup", "(", "$", "targetGroup", ")", ";", "}", "}", "}" ]
Called after a target group was deserialized. @param ObjectEvent $event
[ "Called", "after", "a", "target", "group", "was", "deserialized", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/Serializer/Subscriber/TargetGroupSerializeSubscriber.php#L44-L65
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php
FilterListBuilder.handleCreatedExpressions
protected function handleCreatedExpressions(array $expressions, $conjunction) { $expressionCounter = count($expressions); switch ($expressionCounter) { case 0: // no expressions - nothing to do break; case 1: $this->listBuilder->addExpression($expressions[0]); break; default: $conjunctionExpression = $this->createConjunctionExpression($expressions, $conjunction); $this->listBuilder->addExpression($conjunctionExpression); break; } }
php
protected function handleCreatedExpressions(array $expressions, $conjunction) { $expressionCounter = count($expressions); switch ($expressionCounter) { case 0: // no expressions - nothing to do break; case 1: $this->listBuilder->addExpression($expressions[0]); break; default: $conjunctionExpression = $this->createConjunctionExpression($expressions, $conjunction); $this->listBuilder->addExpression($conjunctionExpression); break; } }
[ "protected", "function", "handleCreatedExpressions", "(", "array", "$", "expressions", ",", "$", "conjunction", ")", "{", "$", "expressionCounter", "=", "count", "(", "$", "expressions", ")", ";", "switch", "(", "$", "expressionCounter", ")", "{", "case", "0", ":", "// no expressions - nothing to do", "break", ";", "case", "1", ":", "$", "this", "->", "listBuilder", "->", "addExpression", "(", "$", "expressions", "[", "0", "]", ")", ";", "break", ";", "default", ":", "$", "conjunctionExpression", "=", "$", "this", "->", "createConjunctionExpression", "(", "$", "expressions", ",", "$", "conjunction", ")", ";", "$", "this", "->", "listBuilder", "->", "addExpression", "(", "$", "conjunctionExpression", ")", ";", "break", ";", "}", "}" ]
Handles the previouse created expressions and passes the over to the listbuilder. @param ExpressionInterface[] $expressions @param string $conjunction
[ "Handles", "the", "previouse", "created", "expressions", "and", "passes", "the", "over", "to", "the", "listbuilder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php#L97-L111
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php
FilterListBuilder.createConjunctionExpression
protected function createConjunctionExpression(array $expressions, $conjunction) { // create the appropriate expression if (ListBuilderInterface::CONJUNCTION_AND === strtoupper($conjunction)) { return $this->listBuilder->createAndExpression($expressions); } return $this->listBuilder->createOrExpression($expressions); }
php
protected function createConjunctionExpression(array $expressions, $conjunction) { // create the appropriate expression if (ListBuilderInterface::CONJUNCTION_AND === strtoupper($conjunction)) { return $this->listBuilder->createAndExpression($expressions); } return $this->listBuilder->createOrExpression($expressions); }
[ "protected", "function", "createConjunctionExpression", "(", "array", "$", "expressions", ",", "$", "conjunction", ")", "{", "// create the appropriate expression", "if", "(", "ListBuilderInterface", "::", "CONJUNCTION_AND", "===", "strtoupper", "(", "$", "conjunction", ")", ")", "{", "return", "$", "this", "->", "listBuilder", "->", "createAndExpression", "(", "$", "expressions", ")", ";", "}", "return", "$", "this", "->", "listBuilder", "->", "createOrExpression", "(", "$", "expressions", ")", ";", "}" ]
Creates a conjunction expression based on the given expressions and conjunction. @param ExpressionInterface[] $expressions @param string $conjunction @return ConjunctionExpressionInterface
[ "Creates", "a", "conjunction", "expression", "based", "on", "the", "given", "expressions", "and", "conjunction", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php#L121-L129
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php
FilterListBuilder.createExpression
protected function createExpression(Condition $condition, $fieldDescriptor) { $value = $this->getValue($condition); // relative date for cases like "within a week" or "within this month" if ('between' === $condition->getOperator() && DataTypes::DATETIME_TYPE === $condition->getType()) { $this->expressions[] = $this->listBuilder->createBetweenExpression($fieldDescriptor, [$value, new \DateTime()]); } else { $this->expressions[] = $this->listBuilder->createWhereExpression( $fieldDescriptor, $value, $condition->getOperator() ); } }
php
protected function createExpression(Condition $condition, $fieldDescriptor) { $value = $this->getValue($condition); // relative date for cases like "within a week" or "within this month" if ('between' === $condition->getOperator() && DataTypes::DATETIME_TYPE === $condition->getType()) { $this->expressions[] = $this->listBuilder->createBetweenExpression($fieldDescriptor, [$value, new \DateTime()]); } else { $this->expressions[] = $this->listBuilder->createWhereExpression( $fieldDescriptor, $value, $condition->getOperator() ); } }
[ "protected", "function", "createExpression", "(", "Condition", "$", "condition", ",", "$", "fieldDescriptor", ")", "{", "$", "value", "=", "$", "this", "->", "getValue", "(", "$", "condition", ")", ";", "// relative date for cases like \"within a week\" or \"within this month\"", "if", "(", "'between'", "===", "$", "condition", "->", "getOperator", "(", ")", "&&", "DataTypes", "::", "DATETIME_TYPE", "===", "$", "condition", "->", "getType", "(", ")", ")", "{", "$", "this", "->", "expressions", "[", "]", "=", "$", "this", "->", "listBuilder", "->", "createBetweenExpression", "(", "$", "fieldDescriptor", ",", "[", "$", "value", ",", "new", "\\", "DateTime", "(", ")", "]", ")", ";", "}", "else", "{", "$", "this", "->", "expressions", "[", "]", "=", "$", "this", "->", "listBuilder", "->", "createWhereExpression", "(", "$", "fieldDescriptor", ",", "$", "value", ",", "$", "condition", "->", "getOperator", "(", ")", ")", ";", "}", "}" ]
Creates expressions from conditions and add them to the expressions array. @param Condition $condition @param FieldDescriptorInterface $fieldDescriptor
[ "Creates", "expressions", "from", "conditions", "and", "add", "them", "to", "the", "expressions", "array", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php#L162-L176
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php
FilterListBuilder.getValue
protected function getValue(Condition $condition) { $value = $condition->getValue(); $type = $condition->getType(); switch ($type) { case DataTypes::UNDEFINED_TYPE: case DataTypes::STRING_TYPE: case DataTypes::TAGS_TYPE: case DataTypes::AUTO_COMPLETE_TYPE: return $value; case DataTypes::NUMBER_TYPE: if (is_numeric($value)) { return floatval($value); } throw new ConditionTypeMismatchException($condition->getId(), $value, $type); case DataTypes::BOOLEAN_TYPE: return $this->getBoolean($value); case DataTypes::DATETIME_TYPE: try { return new \DateTime($value); } catch (\Exception $ex) { throw new ConditionTypeMismatchException($condition->getId(), $value, $type); } default: throw new ConditionTypeMismatchException($condition->getId(), $value, $type); } }
php
protected function getValue(Condition $condition) { $value = $condition->getValue(); $type = $condition->getType(); switch ($type) { case DataTypes::UNDEFINED_TYPE: case DataTypes::STRING_TYPE: case DataTypes::TAGS_TYPE: case DataTypes::AUTO_COMPLETE_TYPE: return $value; case DataTypes::NUMBER_TYPE: if (is_numeric($value)) { return floatval($value); } throw new ConditionTypeMismatchException($condition->getId(), $value, $type); case DataTypes::BOOLEAN_TYPE: return $this->getBoolean($value); case DataTypes::DATETIME_TYPE: try { return new \DateTime($value); } catch (\Exception $ex) { throw new ConditionTypeMismatchException($condition->getId(), $value, $type); } default: throw new ConditionTypeMismatchException($condition->getId(), $value, $type); } }
[ "protected", "function", "getValue", "(", "Condition", "$", "condition", ")", "{", "$", "value", "=", "$", "condition", "->", "getValue", "(", ")", ";", "$", "type", "=", "$", "condition", "->", "getType", "(", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "DataTypes", "::", "UNDEFINED_TYPE", ":", "case", "DataTypes", "::", "STRING_TYPE", ":", "case", "DataTypes", "::", "TAGS_TYPE", ":", "case", "DataTypes", "::", "AUTO_COMPLETE_TYPE", ":", "return", "$", "value", ";", "case", "DataTypes", "::", "NUMBER_TYPE", ":", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "floatval", "(", "$", "value", ")", ";", "}", "throw", "new", "ConditionTypeMismatchException", "(", "$", "condition", "->", "getId", "(", ")", ",", "$", "value", ",", "$", "type", ")", ";", "case", "DataTypes", "::", "BOOLEAN_TYPE", ":", "return", "$", "this", "->", "getBoolean", "(", "$", "value", ")", ";", "case", "DataTypes", "::", "DATETIME_TYPE", ":", "try", "{", "return", "new", "\\", "DateTime", "(", "$", "value", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "throw", "new", "ConditionTypeMismatchException", "(", "$", "condition", "->", "getId", "(", ")", ",", "$", "value", ",", "$", "type", ")", ";", "}", "default", ":", "throw", "new", "ConditionTypeMismatchException", "(", "$", "condition", "->", "getId", "(", ")", ",", "$", "value", ",", "$", "type", ")", ";", "}", "}" ]
Parses and returns the value of a condition. @param Condition $condition @return mixed @throws ConditionTypeMismatchException
[ "Parses", "and", "returns", "the", "value", "of", "a", "condition", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterListBuilder.php#L187-L215
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/RoleSettingRepository.php
RoleSettingRepository.findSettingValue
public function findSettingValue($roleId, $key) { $queryBuilder = $this->createQueryBuilder('s') ->select('s.value') ->join('s.role', 'r') ->where('r.id = :roleId') ->andWhere('s.key = :key') ->setParameters(['roleId' => $roleId, 'key' => $key]); try { return json_decode($queryBuilder->getQuery()->getSingleScalarResult(), true); } catch (NoResultException $e) { return; } }
php
public function findSettingValue($roleId, $key) { $queryBuilder = $this->createQueryBuilder('s') ->select('s.value') ->join('s.role', 'r') ->where('r.id = :roleId') ->andWhere('s.key = :key') ->setParameters(['roleId' => $roleId, 'key' => $key]); try { return json_decode($queryBuilder->getQuery()->getSingleScalarResult(), true); } catch (NoResultException $e) { return; } }
[ "public", "function", "findSettingValue", "(", "$", "roleId", ",", "$", "key", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'s'", ")", "->", "select", "(", "'s.value'", ")", "->", "join", "(", "'s.role'", ",", "'r'", ")", "->", "where", "(", "'r.id = :roleId'", ")", "->", "andWhere", "(", "'s.key = :key'", ")", "->", "setParameters", "(", "[", "'roleId'", "=>", "$", "roleId", ",", "'key'", "=>", "$", "key", "]", ")", ";", "try", "{", "return", "json_decode", "(", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getSingleScalarResult", "(", ")", ",", "true", ")", ";", "}", "catch", "(", "NoResultException", "$", "e", ")", "{", "return", ";", "}", "}" ]
Returns value of given role-setting. @param int $roleId @param string $key @return mixed|null
[ "Returns", "value", "of", "given", "role", "-", "setting", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/RoleSettingRepository.php#L31-L45
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/RoleSettingRepository.php
RoleSettingRepository.findSetting
public function findSetting($roleId, $key) { $queryBuilder = $this->createQueryBuilder('s') ->join('s.role', 'r') ->where('r.id = :roleId') ->andWhere('s.key = :key') ->setParameters(['roleId' => $roleId, 'key' => $key]); try { return $queryBuilder->getQuery()->getSingleResult(); } catch (NoResultException $e) { return; } }
php
public function findSetting($roleId, $key) { $queryBuilder = $this->createQueryBuilder('s') ->join('s.role', 'r') ->where('r.id = :roleId') ->andWhere('s.key = :key') ->setParameters(['roleId' => $roleId, 'key' => $key]); try { return $queryBuilder->getQuery()->getSingleResult(); } catch (NoResultException $e) { return; } }
[ "public", "function", "findSetting", "(", "$", "roleId", ",", "$", "key", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'s'", ")", "->", "join", "(", "'s.role'", ",", "'r'", ")", "->", "where", "(", "'r.id = :roleId'", ")", "->", "andWhere", "(", "'s.key = :key'", ")", "->", "setParameters", "(", "[", "'roleId'", "=>", "$", "roleId", ",", "'key'", "=>", "$", "key", "]", ")", ";", "try", "{", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NoResultException", "$", "e", ")", "{", "return", ";", "}", "}" ]
Returns role-setting object. @param int $roleId @param string $key @return RoleSettingInterface|null
[ "Returns", "role", "-", "setting", "object", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/RoleSettingRepository.php#L55-L68
train
sulu/sulu
src/Sulu/Bundle/LocationBundle/Geolocator/GeolocatorManager.php
GeolocatorManager.get
public function get($name) { if (!isset($this->geolocators[$name])) { throw new GeolocatorNotFoundException( sprintf( 'Attempt to retrieve unknown geolocator "%s"', $name ) ); } return $this->container->get($this->geolocators[$name]); }
php
public function get($name) { if (!isset($this->geolocators[$name])) { throw new GeolocatorNotFoundException( sprintf( 'Attempt to retrieve unknown geolocator "%s"', $name ) ); } return $this->container->get($this->geolocators[$name]); }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "geolocators", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "GeolocatorNotFoundException", "(", "sprintf", "(", "'Attempt to retrieve unknown geolocator \"%s\"'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "container", "->", "get", "(", "$", "this", "->", "geolocators", "[", "$", "name", "]", ")", ";", "}" ]
Retrieve the named name. @param string $name @return GeolocatorInterface
[ "Retrieve", "the", "named", "name", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/LocationBundle/Geolocator/GeolocatorManager.php#L55-L67
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.cgetAction
public function cgetAction(Request $request) { $serializationGroups = []; $locale = $this->getLocale($request); if ('true' == $request->get('flat')) { $list = $this->getList($request, $locale); } else { if (true == $request->get('bySystem')) { $contacts = $this->getContactsByUserSystem(); $serializationGroups[] = 'select'; } else { $contacts = $this->getDoctrine()->getRepository( $this->container->getParameter('sulu.model.contact.class') )->findAll(); $serializationGroups = array_merge( $serializationGroups, static::$contactSerializationGroups ); } // convert to api-contacts $apiContacts = []; foreach ($contacts as $contact) { $apiContacts[] = $this->getContactManager()->getContact($contact, $locale); } $exclusion = null; if (count($serializationGroups) > 0) { $exclusion = new Exclusion($serializationGroups); } $list = new CollectionRepresentation($apiContacts, self::$entityKey, null, $exclusion, $exclusion); } $view = $this->view($list, 200); // set serialization groups if (count($serializationGroups) > 0) { $context = new Context(); $context->setGroups($serializationGroups); $view->setContext($context); } return $this->handleView($view); }
php
public function cgetAction(Request $request) { $serializationGroups = []; $locale = $this->getLocale($request); if ('true' == $request->get('flat')) { $list = $this->getList($request, $locale); } else { if (true == $request->get('bySystem')) { $contacts = $this->getContactsByUserSystem(); $serializationGroups[] = 'select'; } else { $contacts = $this->getDoctrine()->getRepository( $this->container->getParameter('sulu.model.contact.class') )->findAll(); $serializationGroups = array_merge( $serializationGroups, static::$contactSerializationGroups ); } // convert to api-contacts $apiContacts = []; foreach ($contacts as $contact) { $apiContacts[] = $this->getContactManager()->getContact($contact, $locale); } $exclusion = null; if (count($serializationGroups) > 0) { $exclusion = new Exclusion($serializationGroups); } $list = new CollectionRepresentation($apiContacts, self::$entityKey, null, $exclusion, $exclusion); } $view = $this->view($list, 200); // set serialization groups if (count($serializationGroups) > 0) { $context = new Context(); $context->setGroups($serializationGroups); $view->setContext($context); } return $this->handleView($view); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ")", "{", "$", "serializationGroups", "=", "[", "]", ";", "$", "locale", "=", "$", "this", "->", "getLocale", "(", "$", "request", ")", ";", "if", "(", "'true'", "==", "$", "request", "->", "get", "(", "'flat'", ")", ")", "{", "$", "list", "=", "$", "this", "->", "getList", "(", "$", "request", ",", "$", "locale", ")", ";", "}", "else", "{", "if", "(", "true", "==", "$", "request", "->", "get", "(", "'bySystem'", ")", ")", "{", "$", "contacts", "=", "$", "this", "->", "getContactsByUserSystem", "(", ")", ";", "$", "serializationGroups", "[", "]", "=", "'select'", ";", "}", "else", "{", "$", "contacts", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'sulu.model.contact.class'", ")", ")", "->", "findAll", "(", ")", ";", "$", "serializationGroups", "=", "array_merge", "(", "$", "serializationGroups", ",", "static", "::", "$", "contactSerializationGroups", ")", ";", "}", "// convert to api-contacts", "$", "apiContacts", "=", "[", "]", ";", "foreach", "(", "$", "contacts", "as", "$", "contact", ")", "{", "$", "apiContacts", "[", "]", "=", "$", "this", "->", "getContactManager", "(", ")", "->", "getContact", "(", "$", "contact", ",", "$", "locale", ")", ";", "}", "$", "exclusion", "=", "null", ";", "if", "(", "count", "(", "$", "serializationGroups", ")", ">", "0", ")", "{", "$", "exclusion", "=", "new", "Exclusion", "(", "$", "serializationGroups", ")", ";", "}", "$", "list", "=", "new", "CollectionRepresentation", "(", "$", "apiContacts", ",", "self", "::", "$", "entityKey", ",", "null", ",", "$", "exclusion", ",", "$", "exclusion", ")", ";", "}", "$", "view", "=", "$", "this", "->", "view", "(", "$", "list", ",", "200", ")", ";", "// set serialization groups", "if", "(", "count", "(", "$", "serializationGroups", ")", ">", "0", ")", "{", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "$", "serializationGroups", ")", ";", "$", "view", "->", "setContext", "(", "$", "context", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
lists all contacts optional parameter 'flat' calls listAction. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "lists", "all", "contacts", "optional", "parameter", "flat", "calls", "listAction", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L181-L225
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.getList
private function getList(Request $request, $locale) { /** @var RestHelperInterface $restHelper */ $restHelper = $this->getRestHelper(); /** @var DoctrineListBuilderFactory $factory */ $factory = $this->get('sulu_core.doctrine_list_builder_factory'); $listBuilder = $factory->create($this->container->getParameter('sulu.model.contact.class')); $restHelper->initializeListBuilder($listBuilder, $this->getFieldDescriptors()); $listResponse = $this->prepareListResponse($listBuilder, $locale); return new ListRepresentation( $listResponse, self::$entityKey, 'get_contacts', $request->query->all(), $listBuilder->getCurrentPage(), $listBuilder->getLimit(), $listBuilder->count() ); }
php
private function getList(Request $request, $locale) { /** @var RestHelperInterface $restHelper */ $restHelper = $this->getRestHelper(); /** @var DoctrineListBuilderFactory $factory */ $factory = $this->get('sulu_core.doctrine_list_builder_factory'); $listBuilder = $factory->create($this->container->getParameter('sulu.model.contact.class')); $restHelper->initializeListBuilder($listBuilder, $this->getFieldDescriptors()); $listResponse = $this->prepareListResponse($listBuilder, $locale); return new ListRepresentation( $listResponse, self::$entityKey, 'get_contacts', $request->query->all(), $listBuilder->getCurrentPage(), $listBuilder->getLimit(), $listBuilder->count() ); }
[ "private", "function", "getList", "(", "Request", "$", "request", ",", "$", "locale", ")", "{", "/** @var RestHelperInterface $restHelper */", "$", "restHelper", "=", "$", "this", "->", "getRestHelper", "(", ")", ";", "/** @var DoctrineListBuilderFactory $factory */", "$", "factory", "=", "$", "this", "->", "get", "(", "'sulu_core.doctrine_list_builder_factory'", ")", ";", "$", "listBuilder", "=", "$", "factory", "->", "create", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'sulu.model.contact.class'", ")", ")", ";", "$", "restHelper", "->", "initializeListBuilder", "(", "$", "listBuilder", ",", "$", "this", "->", "getFieldDescriptors", "(", ")", ")", ";", "$", "listResponse", "=", "$", "this", "->", "prepareListResponse", "(", "$", "listBuilder", ",", "$", "locale", ")", ";", "return", "new", "ListRepresentation", "(", "$", "listResponse", ",", "self", "::", "$", "entityKey", ",", "'get_contacts'", ",", "$", "request", "->", "query", "->", "all", "(", ")", ",", "$", "listBuilder", "->", "getCurrentPage", "(", ")", ",", "$", "listBuilder", "->", "getLimit", "(", ")", ",", "$", "listBuilder", "->", "count", "(", ")", ")", ";", "}" ]
Returns list for cget. @param Request $request @param string $locale @return ListRepresentation
[ "Returns", "list", "for", "cget", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L235-L257
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.prepareListResponse
private function prepareListResponse(DoctrineListBuilder $listBuilder, $locale) { $listResponse = $listBuilder->execute(); $listResponse = $this->addAvatars($listResponse, $locale); $ids = $listBuilder->getIds(); if (null !== $ids) { $comparator = $this->getComparator(); // the @ is necessary in case of a PHP bug https://bugs.php.net/bug.php?id=50688 @usort( $listResponse, function($a, $b) use ($comparator, $ids) { return $comparator->compare($a['id'], $b['id'], $ids); } ); } return $listResponse; }
php
private function prepareListResponse(DoctrineListBuilder $listBuilder, $locale) { $listResponse = $listBuilder->execute(); $listResponse = $this->addAvatars($listResponse, $locale); $ids = $listBuilder->getIds(); if (null !== $ids) { $comparator = $this->getComparator(); // the @ is necessary in case of a PHP bug https://bugs.php.net/bug.php?id=50688 @usort( $listResponse, function($a, $b) use ($comparator, $ids) { return $comparator->compare($a['id'], $b['id'], $ids); } ); } return $listResponse; }
[ "private", "function", "prepareListResponse", "(", "DoctrineListBuilder", "$", "listBuilder", ",", "$", "locale", ")", "{", "$", "listResponse", "=", "$", "listBuilder", "->", "execute", "(", ")", ";", "$", "listResponse", "=", "$", "this", "->", "addAvatars", "(", "$", "listResponse", ",", "$", "locale", ")", ";", "$", "ids", "=", "$", "listBuilder", "->", "getIds", "(", ")", ";", "if", "(", "null", "!==", "$", "ids", ")", "{", "$", "comparator", "=", "$", "this", "->", "getComparator", "(", ")", ";", "// the @ is necessary in case of a PHP bug https://bugs.php.net/bug.php?id=50688", "@", "usort", "(", "$", "listResponse", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "comparator", ",", "$", "ids", ")", "{", "return", "$", "comparator", "->", "compare", "(", "$", "a", "[", "'id'", "]", ",", "$", "b", "[", "'id'", "]", ",", "$", "ids", ")", ";", "}", ")", ";", "}", "return", "$", "listResponse", ";", "}" ]
Prepare list response. @param DoctrineListBuilder $listBuilder @param string $locale @return array
[ "Prepare", "list", "response", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L267-L285
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.deleteAction
public function deleteAction($id) { try { $deleteCallback = $this->getContactManager()->delete(); $view = $this->responseDelete($id, $deleteCallback); } catch (EntityNotFoundException $e) { $view = $this->view($e->toArray(), 404); } return $this->handleView($view); }
php
public function deleteAction($id) { try { $deleteCallback = $this->getContactManager()->delete(); $view = $this->responseDelete($id, $deleteCallback); } catch (EntityNotFoundException $e) { $view = $this->view($e->toArray(), 404); } return $this->handleView($view); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "try", "{", "$", "deleteCallback", "=", "$", "this", "->", "getContactManager", "(", ")", "->", "delete", "(", ")", ";", "$", "view", "=", "$", "this", "->", "responseDelete", "(", "$", "id", ",", "$", "deleteCallback", ")", ";", "}", "catch", "(", "EntityNotFoundException", "$", "e", ")", "{", "$", "view", "=", "$", "this", "->", "view", "(", "$", "e", "->", "toArray", "(", ")", ",", "404", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Deletes a Contact with the given ID from database. @param int $id @return \Symfony\Component\HttpFoundation\Response
[ "Deletes", "a", "Contact", "with", "the", "given", "ID", "from", "database", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L294-L304
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.getAction
public function getAction($id) { $contactManager = $this->getContactManager(); $locale = $this->getUser()->getLocale(); try { $view = $this->responseGetById( $id, function($id) use ($contactManager, $locale) { return $contactManager->getById($id, $locale); } ); $context = new Context(); $context->setGroups(static::$contactSerializationGroups); $view->setContext($context); } catch (EntityNotFoundException $e) { $view = $this->view($e->toArray(), 404); } return $this->handleView($view); }
php
public function getAction($id) { $contactManager = $this->getContactManager(); $locale = $this->getUser()->getLocale(); try { $view = $this->responseGetById( $id, function($id) use ($contactManager, $locale) { return $contactManager->getById($id, $locale); } ); $context = new Context(); $context->setGroups(static::$contactSerializationGroups); $view->setContext($context); } catch (EntityNotFoundException $e) { $view = $this->view($e->toArray(), 404); } return $this->handleView($view); }
[ "public", "function", "getAction", "(", "$", "id", ")", "{", "$", "contactManager", "=", "$", "this", "->", "getContactManager", "(", ")", ";", "$", "locale", "=", "$", "this", "->", "getUser", "(", ")", "->", "getLocale", "(", ")", ";", "try", "{", "$", "view", "=", "$", "this", "->", "responseGetById", "(", "$", "id", ",", "function", "(", "$", "id", ")", "use", "(", "$", "contactManager", ",", "$", "locale", ")", "{", "return", "$", "contactManager", "->", "getById", "(", "$", "id", ",", "$", "locale", ")", ";", "}", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "static", "::", "$", "contactSerializationGroups", ")", ";", "$", "view", "->", "setContext", "(", "$", "context", ")", ";", "}", "catch", "(", "EntityNotFoundException", "$", "e", ")", "{", "$", "view", "=", "$", "this", "->", "view", "(", "$", "e", "->", "toArray", "(", ")", ",", "404", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Shows the contact with the given Id. @param $id @return \Symfony\Component\HttpFoundation\Response
[ "Shows", "the", "contact", "with", "the", "given", "Id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L313-L334
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.postAction
public function postAction(Request $request) { try { $this->checkArguments($request); $contact = $this->getContactManager()->save( $request->request->all() ); $apiContact = $this->getContactManager()->getContact( $contact, $this->getLocale($request) ); $view = $this->view($apiContact, 200); $context = new Context(); $context->setGroups(static::$contactSerializationGroups); $view->setContext($context); } catch (EntityNotFoundException $enfe) { $view = $this->view($enfe->toArray(), 404); } catch (MissingArgumentException $maex) { $view = $this->view($maex->toArray(), 400); } catch (RestException $re) { $view = $this->view($re->toArray(), 400); } return $this->handleView($view); }
php
public function postAction(Request $request) { try { $this->checkArguments($request); $contact = $this->getContactManager()->save( $request->request->all() ); $apiContact = $this->getContactManager()->getContact( $contact, $this->getLocale($request) ); $view = $this->view($apiContact, 200); $context = new Context(); $context->setGroups(static::$contactSerializationGroups); $view->setContext($context); } catch (EntityNotFoundException $enfe) { $view = $this->view($enfe->toArray(), 404); } catch (MissingArgumentException $maex) { $view = $this->view($maex->toArray(), 400); } catch (RestException $re) { $view = $this->view($re->toArray(), 400); } return $this->handleView($view); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "this", "->", "checkArguments", "(", "$", "request", ")", ";", "$", "contact", "=", "$", "this", "->", "getContactManager", "(", ")", "->", "save", "(", "$", "request", "->", "request", "->", "all", "(", ")", ")", ";", "$", "apiContact", "=", "$", "this", "->", "getContactManager", "(", ")", "->", "getContact", "(", "$", "contact", ",", "$", "this", "->", "getLocale", "(", "$", "request", ")", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "apiContact", ",", "200", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "static", "::", "$", "contactSerializationGroups", ")", ";", "$", "view", "->", "setContext", "(", "$", "context", ")", ";", "}", "catch", "(", "EntityNotFoundException", "$", "enfe", ")", "{", "$", "view", "=", "$", "this", "->", "view", "(", "$", "enfe", "->", "toArray", "(", ")", ",", "404", ")", ";", "}", "catch", "(", "MissingArgumentException", "$", "maex", ")", "{", "$", "view", "=", "$", "this", "->", "view", "(", "$", "maex", "->", "toArray", "(", ")", ",", "400", ")", ";", "}", "catch", "(", "RestException", "$", "re", ")", "{", "$", "view", "=", "$", "this", "->", "view", "(", "$", "re", "->", "toArray", "(", ")", ",", "400", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Creates a new contact. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Creates", "a", "new", "contact", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L343-L367
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.getContactsByUserSystem
protected function getContactsByUserSystem() { $repo = $this->get('sulu_security.user_repository'); $users = $repo->findUserBySystem($this->getParameter('sulu_security.system')); $contacts = []; foreach ($users as $user) { $contacts[] = $user->getContact(); } return $contacts; }
php
protected function getContactsByUserSystem() { $repo = $this->get('sulu_security.user_repository'); $users = $repo->findUserBySystem($this->getParameter('sulu_security.system')); $contacts = []; foreach ($users as $user) { $contacts[] = $user->getContact(); } return $contacts; }
[ "protected", "function", "getContactsByUserSystem", "(", ")", "{", "$", "repo", "=", "$", "this", "->", "get", "(", "'sulu_security.user_repository'", ")", ";", "$", "users", "=", "$", "repo", "->", "findUserBySystem", "(", "$", "this", "->", "getParameter", "(", "'sulu_security.system'", ")", ")", ";", "$", "contacts", "=", "[", "]", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "contacts", "[", "]", "=", "$", "user", "->", "getContact", "(", ")", ";", "}", "return", "$", "contacts", ";", "}" ]
Returns a list of contacts which have a user in the sulu system.
[ "Returns", "a", "list", "of", "contacts", "which", "have", "a", "user", "in", "the", "sulu", "system", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L439-L450
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/ContactController.php
ContactController.addAvatars
private function addAvatars($contacts, $locale) { $ids = array_filter(array_column($contacts, 'avatar')); $avatars = $this->get('sulu_media.media_manager')->getFormatUrls($ids, $locale); foreach ($contacts as $key => $contact) { if (array_key_exists('avatar', $contact) && $contact['avatar'] && array_key_exists($contact['avatar'], $avatars) ) { $contacts[$key]['avatar'] = $avatars[$contact['avatar']]; } } return $contacts; }
php
private function addAvatars($contacts, $locale) { $ids = array_filter(array_column($contacts, 'avatar')); $avatars = $this->get('sulu_media.media_manager')->getFormatUrls($ids, $locale); foreach ($contacts as $key => $contact) { if (array_key_exists('avatar', $contact) && $contact['avatar'] && array_key_exists($contact['avatar'], $avatars) ) { $contacts[$key]['avatar'] = $avatars[$contact['avatar']]; } } return $contacts; }
[ "private", "function", "addAvatars", "(", "$", "contacts", ",", "$", "locale", ")", "{", "$", "ids", "=", "array_filter", "(", "array_column", "(", "$", "contacts", ",", "'avatar'", ")", ")", ";", "$", "avatars", "=", "$", "this", "->", "get", "(", "'sulu_media.media_manager'", ")", "->", "getFormatUrls", "(", "$", "ids", ",", "$", "locale", ")", ";", "foreach", "(", "$", "contacts", "as", "$", "key", "=>", "$", "contact", ")", "{", "if", "(", "array_key_exists", "(", "'avatar'", ",", "$", "contact", ")", "&&", "$", "contact", "[", "'avatar'", "]", "&&", "array_key_exists", "(", "$", "contact", "[", "'avatar'", "]", ",", "$", "avatars", ")", ")", "{", "$", "contacts", "[", "$", "key", "]", "[", "'avatar'", "]", "=", "$", "avatars", "[", "$", "contact", "[", "'avatar'", "]", "]", ";", "}", "}", "return", "$", "contacts", ";", "}" ]
Takes an array of contacts and resets the avatar containing the media id with the actual urls to the avatars thumbnail. @param array $contacts @param string $locale @return array
[ "Takes", "an", "array", "of", "contacts", "and", "resets", "the", "avatar", "containing", "the", "media", "id", "with", "the", "actual", "urls", "to", "the", "avatars", "thumbnail", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/ContactController.php#L469-L483
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/Expression/Doctrine/DoctrineInExpression.php
DoctrineInExpression.filterNullValues
protected function filterNullValues(array $values) { $result = array_filter( $values, function($val) { return $val || 0 === $val || false === $val; } ); return $result; }
php
protected function filterNullValues(array $values) { $result = array_filter( $values, function($val) { return $val || 0 === $val || false === $val; } ); return $result; }
[ "protected", "function", "filterNullValues", "(", "array", "$", "values", ")", "{", "$", "result", "=", "array_filter", "(", "$", "values", ",", "function", "(", "$", "val", ")", "{", "return", "$", "val", "||", "0", "===", "$", "val", "||", "false", "===", "$", "val", ";", "}", ")", ";", "return", "$", "result", ";", "}" ]
Returns a new array without null values. @param array $values @return array
[ "Returns", "a", "new", "array", "without", "null", "values", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/Expression/Doctrine/DoctrineInExpression.php#L79-L89
train
sulu/sulu
src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php
AudienceTargetingCacheListener.setTargetGroupHeader
private function setTargetGroupHeader(Request $request, CacheInvalidation $kernel) { $hadValidTargetGroup = true; $visitorTargetGroup = $request->cookies->get(static::TARGET_GROUP_COOKIE); $visitorSession = $request->cookies->get(static::VISITOR_SESSION_COOKIE); if (null === $visitorTargetGroup || null === $visitorSession) { $hadValidTargetGroup = false; $visitorTargetGroup = $this->requestTargetGroup($request, $kernel, $visitorTargetGroup); } if ($request->isMethodCacheable()) { // add the target group as separate header to vary on it $request->headers->set(static::TARGET_GROUP_HEADER, (string) $visitorTargetGroup); } return $hadValidTargetGroup; }
php
private function setTargetGroupHeader(Request $request, CacheInvalidation $kernel) { $hadValidTargetGroup = true; $visitorTargetGroup = $request->cookies->get(static::TARGET_GROUP_COOKIE); $visitorSession = $request->cookies->get(static::VISITOR_SESSION_COOKIE); if (null === $visitorTargetGroup || null === $visitorSession) { $hadValidTargetGroup = false; $visitorTargetGroup = $this->requestTargetGroup($request, $kernel, $visitorTargetGroup); } if ($request->isMethodCacheable()) { // add the target group as separate header to vary on it $request->headers->set(static::TARGET_GROUP_HEADER, (string) $visitorTargetGroup); } return $hadValidTargetGroup; }
[ "private", "function", "setTargetGroupHeader", "(", "Request", "$", "request", ",", "CacheInvalidation", "$", "kernel", ")", "{", "$", "hadValidTargetGroup", "=", "true", ";", "$", "visitorTargetGroup", "=", "$", "request", "->", "cookies", "->", "get", "(", "static", "::", "TARGET_GROUP_COOKIE", ")", ";", "$", "visitorSession", "=", "$", "request", "->", "cookies", "->", "get", "(", "static", "::", "VISITOR_SESSION_COOKIE", ")", ";", "if", "(", "null", "===", "$", "visitorTargetGroup", "||", "null", "===", "$", "visitorSession", ")", "{", "$", "hadValidTargetGroup", "=", "false", ";", "$", "visitorTargetGroup", "=", "$", "this", "->", "requestTargetGroup", "(", "$", "request", ",", "$", "kernel", ",", "$", "visitorTargetGroup", ")", ";", "}", "if", "(", "$", "request", "->", "isMethodCacheable", "(", ")", ")", "{", "// add the target group as separate header to vary on it", "$", "request", "->", "headers", "->", "set", "(", "static", "::", "TARGET_GROUP_HEADER", ",", "(", "string", ")", "$", "visitorTargetGroup", ")", ";", "}", "return", "$", "hadValidTargetGroup", ";", "}" ]
Sets the target group header based on an existing cookie, so that the application can adapt the content according to it. If the cookie didn't exist yet, another request is fired in order to set the value for the cookie. Returns true if the cookie was already set and false otherwise. @param Request $request @param CacheInvalidation $kernel @return bool
[ "Sets", "the", "target", "group", "header", "based", "on", "an", "existing", "cookie", "so", "that", "the", "application", "can", "adapt", "the", "content", "according", "to", "it", ".", "If", "the", "cookie", "didn", "t", "exist", "yet", "another", "request", "is", "fired", "in", "order", "to", "set", "the", "value", "for", "the", "cookie", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php#L89-L106
train
sulu/sulu
src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php
AudienceTargetingCacheListener.requestTargetGroup
private function requestTargetGroup(Request $request, CacheInvalidation $kernel, int $currentTargetGroup = null) { $targetGroupRequest = Request::create( static::TARGET_GROUP_URL, Request::METHOD_GET, [], [], [], $request->server->all() ); if ($currentTargetGroup) { $targetGroupRequest->headers->set(static::TARGET_GROUP_HEADER, $currentTargetGroup); } $targetGroupRequest->headers->set(static::USER_CONTEXT_URL_HEADER, $request->getUri()); $targetGroupResponse = $kernel->handle($targetGroupRequest); return $targetGroupResponse->headers->get(static::TARGET_GROUP_HEADER); }
php
private function requestTargetGroup(Request $request, CacheInvalidation $kernel, int $currentTargetGroup = null) { $targetGroupRequest = Request::create( static::TARGET_GROUP_URL, Request::METHOD_GET, [], [], [], $request->server->all() ); if ($currentTargetGroup) { $targetGroupRequest->headers->set(static::TARGET_GROUP_HEADER, $currentTargetGroup); } $targetGroupRequest->headers->set(static::USER_CONTEXT_URL_HEADER, $request->getUri()); $targetGroupResponse = $kernel->handle($targetGroupRequest); return $targetGroupResponse->headers->get(static::TARGET_GROUP_HEADER); }
[ "private", "function", "requestTargetGroup", "(", "Request", "$", "request", ",", "CacheInvalidation", "$", "kernel", ",", "int", "$", "currentTargetGroup", "=", "null", ")", "{", "$", "targetGroupRequest", "=", "Request", "::", "create", "(", "static", "::", "TARGET_GROUP_URL", ",", "Request", "::", "METHOD_GET", ",", "[", "]", ",", "[", "]", ",", "[", "]", ",", "$", "request", "->", "server", "->", "all", "(", ")", ")", ";", "if", "(", "$", "currentTargetGroup", ")", "{", "$", "targetGroupRequest", "->", "headers", "->", "set", "(", "static", "::", "TARGET_GROUP_HEADER", ",", "$", "currentTargetGroup", ")", ";", "}", "$", "targetGroupRequest", "->", "headers", "->", "set", "(", "static", "::", "USER_CONTEXT_URL_HEADER", ",", "$", "request", "->", "getUri", "(", ")", ")", ";", "$", "targetGroupResponse", "=", "$", "kernel", "->", "handle", "(", "$", "targetGroupRequest", ")", ";", "return", "$", "targetGroupResponse", "->", "headers", "->", "get", "(", "static", "::", "TARGET_GROUP_HEADER", ")", ";", "}" ]
Sends a request to the application to determine the target group of the current visitor. @param Request $request @param CacheInvalidation $kernel @param null|int $currentTargetGroup @return string
[ "Sends", "a", "request", "to", "the", "application", "to", "determine", "the", "target", "group", "of", "the", "current", "visitor", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php#L117-L137
train
sulu/sulu
src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php
AudienceTargetingCacheListener.setTargetGroupCookie
private function setTargetGroupCookie(Response $response, Request $request) { $response->headers->setCookie( new Cookie( static::TARGET_GROUP_COOKIE, $request->headers->get(static::TARGET_GROUP_HEADER), static::TARGET_GROUP_COOKIE_LIFETIME ) ); $response->headers->setCookie( new Cookie( static::VISITOR_SESSION_COOKIE, time() ) ); }
php
private function setTargetGroupCookie(Response $response, Request $request) { $response->headers->setCookie( new Cookie( static::TARGET_GROUP_COOKIE, $request->headers->get(static::TARGET_GROUP_HEADER), static::TARGET_GROUP_COOKIE_LIFETIME ) ); $response->headers->setCookie( new Cookie( static::VISITOR_SESSION_COOKIE, time() ) ); }
[ "private", "function", "setTargetGroupCookie", "(", "Response", "$", "response", ",", "Request", "$", "request", ")", "{", "$", "response", "->", "headers", "->", "setCookie", "(", "new", "Cookie", "(", "static", "::", "TARGET_GROUP_COOKIE", ",", "$", "request", "->", "headers", "->", "get", "(", "static", "::", "TARGET_GROUP_HEADER", ")", ",", "static", "::", "TARGET_GROUP_COOKIE_LIFETIME", ")", ")", ";", "$", "response", "->", "headers", "->", "setCookie", "(", "new", "Cookie", "(", "static", "::", "VISITOR_SESSION_COOKIE", ",", "time", "(", ")", ")", ")", ";", "}" ]
Set the cookie for the target group from the request. Should only be set in case the cookie was not set before. @param Response $response @param Request $request
[ "Set", "the", "cookie", "for", "the", "target", "group", "from", "the", "request", ".", "Should", "only", "be", "set", "in", "case", "the", "cookie", "was", "not", "set", "before", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/EventListener/AudienceTargetingCacheListener.php#L145-L161
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/FallbackLocalizationSubscriber.php
FallbackLocalizationSubscriber.getAvailableLocalization
public function getAvailableLocalization(StructureBehavior $document, $locale) { $availableLocales = $this->inspector->getLocales($document); if (in_array($locale, $availableLocales)) { return $locale; } $fallbackLocale = null; if ($document instanceof WebspaceBehavior) { $fallbackLocale = $this->localizationFinder->findAvailableLocale( $this->inspector->getWebspace($document), $availableLocales, $locale ); } if (!$fallbackLocale) { $fallbackLocale = reset($availableLocales); } if (!$fallbackLocale) { $fallbackLocale = $this->documentRegistry->getDefaultLocale(); } return $fallbackLocale; }
php
public function getAvailableLocalization(StructureBehavior $document, $locale) { $availableLocales = $this->inspector->getLocales($document); if (in_array($locale, $availableLocales)) { return $locale; } $fallbackLocale = null; if ($document instanceof WebspaceBehavior) { $fallbackLocale = $this->localizationFinder->findAvailableLocale( $this->inspector->getWebspace($document), $availableLocales, $locale ); } if (!$fallbackLocale) { $fallbackLocale = reset($availableLocales); } if (!$fallbackLocale) { $fallbackLocale = $this->documentRegistry->getDefaultLocale(); } return $fallbackLocale; }
[ "public", "function", "getAvailableLocalization", "(", "StructureBehavior", "$", "document", ",", "$", "locale", ")", "{", "$", "availableLocales", "=", "$", "this", "->", "inspector", "->", "getLocales", "(", "$", "document", ")", ";", "if", "(", "in_array", "(", "$", "locale", ",", "$", "availableLocales", ")", ")", "{", "return", "$", "locale", ";", "}", "$", "fallbackLocale", "=", "null", ";", "if", "(", "$", "document", "instanceof", "WebspaceBehavior", ")", "{", "$", "fallbackLocale", "=", "$", "this", "->", "localizationFinder", "->", "findAvailableLocale", "(", "$", "this", "->", "inspector", "->", "getWebspace", "(", "$", "document", ")", ",", "$", "availableLocales", ",", "$", "locale", ")", ";", "}", "if", "(", "!", "$", "fallbackLocale", ")", "{", "$", "fallbackLocale", "=", "reset", "(", "$", "availableLocales", ")", ";", "}", "if", "(", "!", "$", "fallbackLocale", ")", "{", "$", "fallbackLocale", "=", "$", "this", "->", "documentRegistry", "->", "getDefaultLocale", "(", ")", ";", "}", "return", "$", "fallbackLocale", ";", "}" ]
Return available localizations. @param StructureBehavior $document @param string $locale @return string
[ "Return", "available", "localizations", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/FallbackLocalizationSubscriber.php#L106-L133
train
sulu/sulu
src/Sulu/Component/Persistence/EventSubscriber/ORM/UserBlameSubscriber.php
UserBlameSubscriber.loadClassMetadata
public function loadClassMetadata(LoadClassMetadataEventArgs $event) { $metadata = $event->getClassMetadata(); $reflection = $metadata->getReflectionClass(); if (null !== $reflection && $reflection->implementsInterface('Sulu\Component\Persistence\Model\UserBlameInterface')) { if (!$metadata->hasAssociation(self::CREATOR_FIELD)) { $metadata->mapManyToOne([ 'fieldName' => self::CREATOR_FIELD, 'targetEntity' => $this->userClass, 'joinColumns' => [ [ 'name' => 'idUsersCreator', 'onDelete' => 'SET NULL', 'referencedColumnName' => 'id', 'nullable' => true, ], ], ]); } if (!$metadata->hasAssociation(self::CHANGER_FIELD)) { $metadata->mapManyToOne([ 'fieldName' => self::CHANGER_FIELD, 'targetEntity' => $this->userClass, 'joinColumns' => [ [ 'name' => 'idUsersChanger', 'onDelete' => 'SET NULL', 'referencedColumnName' => 'id', 'nullable' => true, ], ], ]); } } }
php
public function loadClassMetadata(LoadClassMetadataEventArgs $event) { $metadata = $event->getClassMetadata(); $reflection = $metadata->getReflectionClass(); if (null !== $reflection && $reflection->implementsInterface('Sulu\Component\Persistence\Model\UserBlameInterface')) { if (!$metadata->hasAssociation(self::CREATOR_FIELD)) { $metadata->mapManyToOne([ 'fieldName' => self::CREATOR_FIELD, 'targetEntity' => $this->userClass, 'joinColumns' => [ [ 'name' => 'idUsersCreator', 'onDelete' => 'SET NULL', 'referencedColumnName' => 'id', 'nullable' => true, ], ], ]); } if (!$metadata->hasAssociation(self::CHANGER_FIELD)) { $metadata->mapManyToOne([ 'fieldName' => self::CHANGER_FIELD, 'targetEntity' => $this->userClass, 'joinColumns' => [ [ 'name' => 'idUsersChanger', 'onDelete' => 'SET NULL', 'referencedColumnName' => 'id', 'nullable' => true, ], ], ]); } } }
[ "public", "function", "loadClassMetadata", "(", "LoadClassMetadataEventArgs", "$", "event", ")", "{", "$", "metadata", "=", "$", "event", "->", "getClassMetadata", "(", ")", ";", "$", "reflection", "=", "$", "metadata", "->", "getReflectionClass", "(", ")", ";", "if", "(", "null", "!==", "$", "reflection", "&&", "$", "reflection", "->", "implementsInterface", "(", "'Sulu\\Component\\Persistence\\Model\\UserBlameInterface'", ")", ")", "{", "if", "(", "!", "$", "metadata", "->", "hasAssociation", "(", "self", "::", "CREATOR_FIELD", ")", ")", "{", "$", "metadata", "->", "mapManyToOne", "(", "[", "'fieldName'", "=>", "self", "::", "CREATOR_FIELD", ",", "'targetEntity'", "=>", "$", "this", "->", "userClass", ",", "'joinColumns'", "=>", "[", "[", "'name'", "=>", "'idUsersCreator'", ",", "'onDelete'", "=>", "'SET NULL'", ",", "'referencedColumnName'", "=>", "'id'", ",", "'nullable'", "=>", "true", ",", "]", ",", "]", ",", "]", ")", ";", "}", "if", "(", "!", "$", "metadata", "->", "hasAssociation", "(", "self", "::", "CHANGER_FIELD", ")", ")", "{", "$", "metadata", "->", "mapManyToOne", "(", "[", "'fieldName'", "=>", "self", "::", "CHANGER_FIELD", ",", "'targetEntity'", "=>", "$", "this", "->", "userClass", ",", "'joinColumns'", "=>", "[", "[", "'name'", "=>", "'idUsersChanger'", ",", "'onDelete'", "=>", "'SET NULL'", ",", "'referencedColumnName'", "=>", "'id'", ",", "'nullable'", "=>", "true", ",", "]", ",", "]", ",", "]", ")", ";", "}", "}", "}" ]
Map creator and changer fields to User objects. @param LoadClassMetadataEventArgs $event
[ "Map", "creator", "and", "changer", "fields", "to", "User", "objects", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Persistence/EventSubscriber/ORM/UserBlameSubscriber.php#L74-L110
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Teaser/TeaserManager.php
TeaserManager.sortTeasers
private function sortTeasers(array $teasers, array $result, array $positions, array $items) { foreach ($teasers as $teaser) { $index = $positions[sprintf('%s;%s', $teaser->getType(), $teaser->getId())]; $result[$index] = $teaser; $item = $items[$index]; if (['type', 'id'] !== array_keys($item)) { $result[$index] = $result[$index]->merge($item); } } return $result; }
php
private function sortTeasers(array $teasers, array $result, array $positions, array $items) { foreach ($teasers as $teaser) { $index = $positions[sprintf('%s;%s', $teaser->getType(), $teaser->getId())]; $result[$index] = $teaser; $item = $items[$index]; if (['type', 'id'] !== array_keys($item)) { $result[$index] = $result[$index]->merge($item); } } return $result; }
[ "private", "function", "sortTeasers", "(", "array", "$", "teasers", ",", "array", "$", "result", ",", "array", "$", "positions", ",", "array", "$", "items", ")", "{", "foreach", "(", "$", "teasers", "as", "$", "teaser", ")", "{", "$", "index", "=", "$", "positions", "[", "sprintf", "(", "'%s;%s'", ",", "$", "teaser", "->", "getType", "(", ")", ",", "$", "teaser", "->", "getId", "(", ")", ")", "]", ";", "$", "result", "[", "$", "index", "]", "=", "$", "teaser", ";", "$", "item", "=", "$", "items", "[", "$", "index", "]", ";", "if", "(", "[", "'type'", ",", "'id'", "]", "!==", "array_keys", "(", "$", "item", ")", ")", "{", "$", "result", "[", "$", "index", "]", "=", "$", "result", "[", "$", "index", "]", "->", "merge", "(", "$", "item", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns sorted teaser by given position array. @param Teaser[] $teasers @param array $result @param array $positions @return array
[ "Returns", "sorted", "teaser", "by", "given", "position", "array", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Teaser/TeaserManager.php#L64-L77
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Teaser/TeaserManager.php
TeaserManager.sortItems
private function sortItems($items) { $ids = []; $positions = []; $index = 0; foreach ($items as $item) { if (!array_key_exists($item['type'], $ids)) { $ids[$item['type']] = []; } $ids[$item['type']][] = $item['id']; $positions[sprintf('%s;%s', $item['type'], $item['id'])] = $index++; } return [$ids, $positions]; }
php
private function sortItems($items) { $ids = []; $positions = []; $index = 0; foreach ($items as $item) { if (!array_key_exists($item['type'], $ids)) { $ids[$item['type']] = []; } $ids[$item['type']][] = $item['id']; $positions[sprintf('%s;%s', $item['type'], $item['id'])] = $index++; } return [$ids, $positions]; }
[ "private", "function", "sortItems", "(", "$", "items", ")", "{", "$", "ids", "=", "[", "]", ";", "$", "positions", "=", "[", "]", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "item", "[", "'type'", "]", ",", "$", "ids", ")", ")", "{", "$", "ids", "[", "$", "item", "[", "'type'", "]", "]", "=", "[", "]", ";", "}", "$", "ids", "[", "$", "item", "[", "'type'", "]", "]", "[", "]", "=", "$", "item", "[", "'id'", "]", ";", "$", "positions", "[", "sprintf", "(", "'%s;%s'", ",", "$", "item", "[", "'type'", "]", ",", "$", "item", "[", "'id'", "]", ")", "]", "=", "$", "index", "++", ";", "}", "return", "[", "$", "ids", ",", "$", "positions", "]", ";", "}" ]
Returns items sorted by type. @param array $items @return array
[ "Returns", "items", "sorted", "by", "type", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Teaser/TeaserManager.php#L86-L100
train
sulu/sulu
src/Sulu/Component/Content/Metadata/ItemMetadata.php
ItemMetadata.getChild
public function getChild($name) { if (!isset($this->children[$name])) { throw new \InvalidArgumentException(sprintf( 'Unknown child "%s" in structure "%s" loaded from: "%s". Children: "%s"', $name, $this->name, $this->resource, implode('", "', array_keys($this->children)) )); } return $this->children[$name]; }
php
public function getChild($name) { if (!isset($this->children[$name])) { throw new \InvalidArgumentException(sprintf( 'Unknown child "%s" in structure "%s" loaded from: "%s". Children: "%s"', $name, $this->name, $this->resource, implode('", "', array_keys($this->children)) )); } return $this->children[$name]; }
[ "public", "function", "getChild", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "children", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Unknown child \"%s\" in structure \"%s\" loaded from: \"%s\". Children: \"%s\"'", ",", "$", "name", ",", "$", "this", "->", "name", ",", "$", "this", "->", "resource", ",", "implode", "(", "'\", \"'", ",", "array_keys", "(", "$", "this", "->", "children", ")", ")", ")", ")", ";", "}", "return", "$", "this", "->", "children", "[", "$", "name", "]", ";", "}" ]
Return the named property. @param string $name @return ItemMetadata
[ "Return", "the", "named", "property", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/ItemMetadata.php#L170-L180
train
sulu/sulu
src/Sulu/Component/Content/Metadata/ItemMetadata.php
ItemMetadata.addChild
public function addChild(self $child) { if (isset($this->children[$child->name])) { throw new \InvalidArgumentException(sprintf( 'Child with key "%s" already exists', $child->name )); } $this->children[$child->name] = $child; }
php
public function addChild(self $child) { if (isset($this->children[$child->name])) { throw new \InvalidArgumentException(sprintf( 'Child with key "%s" already exists', $child->name )); } $this->children[$child->name] = $child; }
[ "public", "function", "addChild", "(", "self", "$", "child", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "children", "[", "$", "child", "->", "name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Child with key \"%s\" already exists'", ",", "$", "child", "->", "name", ")", ")", ";", "}", "$", "this", "->", "children", "[", "$", "child", "->", "name", "]", "=", "$", "child", ";", "}" ]
Adds a child item. @param ItemMetadata $child
[ "Adds", "a", "child", "item", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/ItemMetadata.php#L200-L210
train
sulu/sulu
src/Sulu/Component/Content/Metadata/ItemMetadata.php
ItemMetadata.getParameter
public function getParameter($name) { if (!isset($this->parameters[$name])) { throw new \InvalidArgumentException(sprintf( 'Unknown parameter "%s", known parameters: "%s"', $name, implode('", "', array_keys($this->parameters)) )); } return $this->parameters[$name]; }
php
public function getParameter($name) { if (!isset($this->parameters[$name])) { throw new \InvalidArgumentException(sprintf( 'Unknown parameter "%s", known parameters: "%s"', $name, implode('", "', array_keys($this->parameters)) )); } return $this->parameters[$name]; }
[ "public", "function", "getParameter", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "parameters", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Unknown parameter \"%s\", known parameters: \"%s\"'", ",", "$", "name", ",", "implode", "(", "'\", \"'", ",", "array_keys", "(", "$", "this", "->", "parameters", ")", ")", ")", ")", ";", "}", "return", "$", "this", "->", "parameters", "[", "$", "name", "]", ";", "}" ]
Return the paramter with the given name. @param string $name @return mixed
[ "Return", "the", "paramter", "with", "the", "given", "name", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/ItemMetadata.php#L243-L253
train
sulu/sulu
src/Sulu/Component/Content/Metadata/ItemMetadata.php
ItemMetadata.getTag
public function getTag($tagName) { foreach ($this->tags as $tag) { if ($tag['name'] === $tagName) { return $tag; } } throw new \InvalidArgumentException(sprintf( 'Unknown tag "%s"', $tagName )); }
php
public function getTag($tagName) { foreach ($this->tags as $tag) { if ($tag['name'] === $tagName) { return $tag; } } throw new \InvalidArgumentException(sprintf( 'Unknown tag "%s"', $tagName )); }
[ "public", "function", "getTag", "(", "$", "tagName", ")", "{", "foreach", "(", "$", "this", "->", "tags", "as", "$", "tag", ")", "{", "if", "(", "$", "tag", "[", "'name'", "]", "===", "$", "tagName", ")", "{", "return", "$", "tag", ";", "}", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Unknown tag \"%s\"'", ",", "$", "tagName", ")", ")", ";", "}" ]
Return the named tag. @param string $tagName @throws \InvalidArgumentException @return array
[ "Return", "the", "named", "tag", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/ItemMetadata.php#L284-L295
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php
SecuritySubscriber.handlePersist
public function handlePersist(PersistEvent $event) { /** @var SecurityBehavior $document */ $document = $event->getDocument(); if (!$this->supports($document) || !$document->getPermissions()) { return; } $node = $event->getNode(); foreach ($document->getPermissions() as $roleId => $permission) { // TODO use PropertyEncoder, once it is refactored $node->setProperty('sec:role-' . $roleId, $this->getAllowedPermissions($permission)); } }
php
public function handlePersist(PersistEvent $event) { /** @var SecurityBehavior $document */ $document = $event->getDocument(); if (!$this->supports($document) || !$document->getPermissions()) { return; } $node = $event->getNode(); foreach ($document->getPermissions() as $roleId => $permission) { // TODO use PropertyEncoder, once it is refactored $node->setProperty('sec:role-' . $roleId, $this->getAllowedPermissions($permission)); } }
[ "public", "function", "handlePersist", "(", "PersistEvent", "$", "event", ")", "{", "/** @var SecurityBehavior $document */", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", "||", "!", "$", "document", "->", "getPermissions", "(", ")", ")", "{", "return", ";", "}", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "foreach", "(", "$", "document", "->", "getPermissions", "(", ")", "as", "$", "roleId", "=>", "$", "permission", ")", "{", "// TODO use PropertyEncoder, once it is refactored", "$", "node", "->", "setProperty", "(", "'sec:role-'", ".", "$", "roleId", ",", "$", "this", "->", "getAllowedPermissions", "(", "$", "permission", ")", ")", ";", "}", "}" ]
Adds the security information to the node. @param PersistEvent $event
[ "Adds", "the", "security", "information", "to", "the", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php#L64-L79
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php
SecuritySubscriber.handleHydrate
public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); if (!$this->supports($document)) { return; } $permissions = []; foreach ($node->getProperties('sec:*') as $property) { /** @var PropertyInterface $property */ $roleId = substr($property->getName(), 9); // remove the "sec:role-" prefix $allowedPermissions = $property->getValue(); foreach ($this->permissions as $permission => $value) { $permissions[$roleId][$permission] = in_array($permission, $allowedPermissions); } } $document->setPermissions($permissions); }
php
public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); if (!$this->supports($document)) { return; } $permissions = []; foreach ($node->getProperties('sec:*') as $property) { /** @var PropertyInterface $property */ $roleId = substr($property->getName(), 9); // remove the "sec:role-" prefix $allowedPermissions = $property->getValue(); foreach ($this->permissions as $permission => $value) { $permissions[$roleId][$permission] = in_array($permission, $allowedPermissions); } } $document->setPermissions($permissions); }
[ "public", "function", "handleHydrate", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "permissions", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "getProperties", "(", "'sec:*'", ")", "as", "$", "property", ")", "{", "/** @var PropertyInterface $property */", "$", "roleId", "=", "substr", "(", "$", "property", "->", "getName", "(", ")", ",", "9", ")", ";", "// remove the \"sec:role-\" prefix", "$", "allowedPermissions", "=", "$", "property", "->", "getValue", "(", ")", ";", "foreach", "(", "$", "this", "->", "permissions", "as", "$", "permission", "=>", "$", "value", ")", "{", "$", "permissions", "[", "$", "roleId", "]", "[", "$", "permission", "]", "=", "in_array", "(", "$", "permission", ",", "$", "allowedPermissions", ")", ";", "}", "}", "$", "document", "->", "setPermissions", "(", "$", "permissions", ")", ";", "}" ]
Adds the security information to the hydrated object. @param HydrateEvent $event
[ "Adds", "the", "security", "information", "to", "the", "hydrated", "object", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php#L86-L108
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php
SecuritySubscriber.getAllowedPermissions
private function getAllowedPermissions($permissions) { $allowedPermissions = []; foreach ($permissions as $permission => $allowed) { if ($allowed) { $allowedPermissions[] = $permission; } } return $allowedPermissions; }
php
private function getAllowedPermissions($permissions) { $allowedPermissions = []; foreach ($permissions as $permission => $allowed) { if ($allowed) { $allowedPermissions[] = $permission; } } return $allowedPermissions; }
[ "private", "function", "getAllowedPermissions", "(", "$", "permissions", ")", "{", "$", "allowedPermissions", "=", "[", "]", ";", "foreach", "(", "$", "permissions", "as", "$", "permission", "=>", "$", "allowed", ")", "{", "if", "(", "$", "allowed", ")", "{", "$", "allowedPermissions", "[", "]", "=", "$", "permission", ";", "}", "}", "return", "$", "allowedPermissions", ";", "}" ]
Extracts the keys of the allowed permissions into an own array. @param $permissions @return array
[ "Extracts", "the", "keys", "of", "the", "allowed", "permissions", "into", "an", "own", "array", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/SecuritySubscriber.php#L117-L127
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/Path/AbstractFilingSubscriber.php
AbstractFilingSubscriber.createNode
private function createNode(NodeInterface $node, $pathSegment, $uuid) { if ($node->hasNode($pathSegment)) { return $node->getNode($pathSegment); } $node = $node->addNode($pathSegment); $node->addMixin('mix:referenceable'); $node->setProperty('jcr:uuid', $uuid); return $node; }
php
private function createNode(NodeInterface $node, $pathSegment, $uuid) { if ($node->hasNode($pathSegment)) { return $node->getNode($pathSegment); } $node = $node->addNode($pathSegment); $node->addMixin('mix:referenceable'); $node->setProperty('jcr:uuid', $uuid); return $node; }
[ "private", "function", "createNode", "(", "NodeInterface", "$", "node", ",", "$", "pathSegment", ",", "$", "uuid", ")", "{", "if", "(", "$", "node", "->", "hasNode", "(", "$", "pathSegment", ")", ")", "{", "return", "$", "node", "->", "getNode", "(", "$", "pathSegment", ")", ";", "}", "$", "node", "=", "$", "node", "->", "addNode", "(", "$", "pathSegment", ")", ";", "$", "node", "->", "addMixin", "(", "'mix:referenceable'", ")", ";", "$", "node", "->", "setProperty", "(", "'jcr:uuid'", ",", "$", "uuid", ")", ";", "return", "$", "node", ";", "}" ]
Adds a node with the given path segment as a node name to the given node. @param NodeInterface $node @param string $pathSegment @param string $uuid @return mixed
[ "Adds", "a", "node", "with", "the", "given", "path", "segment", "as", "a", "node", "name", "to", "the", "given", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/Path/AbstractFilingSubscriber.php#L113-L124
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php
AnalyticsController.cgetAction
public function cgetAction(Request $request, $webspace) { $entities = $this->get('sulu_website.analytics.manager')->findAll($webspace); $list = new RouteAwareRepresentation( new CollectionRepresentation($entities, self::RESULT_KEY), 'cget_webspace_analytics', array_merge($request->request->all(), ['webspace' => $webspace]) ); return $this->handleView($this->view($list, 200)); }
php
public function cgetAction(Request $request, $webspace) { $entities = $this->get('sulu_website.analytics.manager')->findAll($webspace); $list = new RouteAwareRepresentation( new CollectionRepresentation($entities, self::RESULT_KEY), 'cget_webspace_analytics', array_merge($request->request->all(), ['webspace' => $webspace]) ); return $this->handleView($this->view($list, 200)); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ",", "$", "webspace", ")", "{", "$", "entities", "=", "$", "this", "->", "get", "(", "'sulu_website.analytics.manager'", ")", "->", "findAll", "(", "$", "webspace", ")", ";", "$", "list", "=", "new", "RouteAwareRepresentation", "(", "new", "CollectionRepresentation", "(", "$", "entities", ",", "self", "::", "RESULT_KEY", ")", ",", "'cget_webspace_analytics'", ",", "array_merge", "(", "$", "request", "->", "request", "->", "all", "(", ")", ",", "[", "'webspace'", "=>", "$", "webspace", "]", ")", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "list", ",", "200", ")", ")", ";", "}" ]
Returns webspace analytics by webspace key. @param Request $request @param string $webspace @return Response
[ "Returns", "webspace", "analytics", "by", "webspace", "key", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php#L38-L49
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php
AnalyticsController.getAction
public function getAction($webspace, $id) { $entity = $this->get('sulu_website.analytics.manager')->find($id); return $this->handleView($this->view($entity, 200)); }
php
public function getAction($webspace, $id) { $entity = $this->get('sulu_website.analytics.manager')->find($id); return $this->handleView($this->view($entity, 200)); }
[ "public", "function", "getAction", "(", "$", "webspace", ",", "$", "id", ")", "{", "$", "entity", "=", "$", "this", "->", "get", "(", "'sulu_website.analytics.manager'", ")", "->", "find", "(", "$", "id", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "entity", ",", "200", ")", ")", ";", "}" ]
Returns a single analytics by id. @param string $webspace @param int $id @return Response
[ "Returns", "a", "single", "analytics", "by", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php#L59-L64
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php
AnalyticsController.postAction
public function postAction(Request $request, $webspace) { $data = $request->request->all(); $data['content'] = $this->buildContent($data); $entity = $this->get('sulu_website.analytics.manager')->create($webspace, $data); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view($entity, 200)); }
php
public function postAction(Request $request, $webspace) { $data = $request->request->all(); $data['content'] = $this->buildContent($data); $entity = $this->get('sulu_website.analytics.manager')->create($webspace, $data); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view($entity, 200)); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ",", "$", "webspace", ")", "{", "$", "data", "=", "$", "request", "->", "request", "->", "all", "(", ")", ";", "$", "data", "[", "'content'", "]", "=", "$", "this", "->", "buildContent", "(", "$", "data", ")", ";", "$", "entity", "=", "$", "this", "->", "get", "(", "'sulu_website.analytics.manager'", ")", "->", "create", "(", "$", "webspace", ",", "$", "data", ")", ";", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'sulu_website.http_cache.clearer'", ")", "->", "clear", "(", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "entity", ",", "200", ")", ")", ";", "}" ]
Creates a analytics for given webspace. @param Request $request @param string $webspace @return Response
[ "Creates", "a", "analytics", "for", "given", "webspace", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php#L74-L84
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php
AnalyticsController.putAction
public function putAction(Request $request, $webspace, $id) { $data = $request->request->all(); $data['content'] = $this->buildContent($data); $entity = $this->get('sulu_website.analytics.manager')->update($id, $data); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view($entity, 200)); }
php
public function putAction(Request $request, $webspace, $id) { $data = $request->request->all(); $data['content'] = $this->buildContent($data); $entity = $this->get('sulu_website.analytics.manager')->update($id, $data); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view($entity, 200)); }
[ "public", "function", "putAction", "(", "Request", "$", "request", ",", "$", "webspace", ",", "$", "id", ")", "{", "$", "data", "=", "$", "request", "->", "request", "->", "all", "(", ")", ";", "$", "data", "[", "'content'", "]", "=", "$", "this", "->", "buildContent", "(", "$", "data", ")", ";", "$", "entity", "=", "$", "this", "->", "get", "(", "'sulu_website.analytics.manager'", ")", "->", "update", "(", "$", "id", ",", "$", "data", ")", ";", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'sulu_website.http_cache.clearer'", ")", "->", "clear", "(", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "entity", ",", "200", ")", ")", ";", "}" ]
Updates analytics with given id. @param Request $request @param string $webspace @param int $id @return Response
[ "Updates", "analytics", "with", "given", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php#L95-L105
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php
AnalyticsController.deleteAction
public function deleteAction($webspace, $id) { $this->get('sulu_website.analytics.manager')->remove($id); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view(null, 204)); }
php
public function deleteAction($webspace, $id) { $this->get('sulu_website.analytics.manager')->remove($id); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view(null, 204)); }
[ "public", "function", "deleteAction", "(", "$", "webspace", ",", "$", "id", ")", "{", "$", "this", "->", "get", "(", "'sulu_website.analytics.manager'", ")", "->", "remove", "(", "$", "id", ")", ";", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'sulu_website.http_cache.clearer'", ")", "->", "clear", "(", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "null", ",", "204", ")", ")", ";", "}" ]
Removes given analytics. @param string $webspace @param int $id @return Response
[ "Removes", "given", "analytics", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php#L115-L122
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php
AnalyticsController.cdeleteAction
public function cdeleteAction(Request $request, $webspace) { $ids = array_filter(explode(',', $request->get('ids', ''))); $this->get('sulu_website.analytics.manager')->removeMultiple($ids); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view(null, 204)); }
php
public function cdeleteAction(Request $request, $webspace) { $ids = array_filter(explode(',', $request->get('ids', ''))); $this->get('sulu_website.analytics.manager')->removeMultiple($ids); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('sulu_website.http_cache.clearer')->clear(); return $this->handleView($this->view(null, 204)); }
[ "public", "function", "cdeleteAction", "(", "Request", "$", "request", ",", "$", "webspace", ")", "{", "$", "ids", "=", "array_filter", "(", "explode", "(", "','", ",", "$", "request", "->", "get", "(", "'ids'", ",", "''", ")", ")", ")", ";", "$", "this", "->", "get", "(", "'sulu_website.analytics.manager'", ")", "->", "removeMultiple", "(", "$", "ids", ")", ";", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'sulu_website.http_cache.clearer'", ")", "->", "clear", "(", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "null", ",", "204", ")", ")", ";", "}" ]
Removes a list of analytics. @param Request $request @param $webspace @return Response
[ "Removes", "a", "list", "of", "analytics", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Controller/AnalyticsController.php#L132-L141
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/DataFixtures/ORM/Operators/LoadOperators.php
LoadOperators.getTypeForString
protected function getTypeForString($type) { switch ($type) { case 'string': return DataTypes::STRING_TYPE; case 'number': return DataTypes::NUMBER_TYPE; case 'date': case 'datetime': return DataTypes::DATETIME_TYPE; case 'boolean': return DataTypes::BOOLEAN_TYPE; case 'tags': return DataTypes::TAGS_TYPE; case 'auto-complete': return DataTypes::AUTO_COMPLETE_TYPE; default: return DataTypes::UNDEFINED_TYPE; } }
php
protected function getTypeForString($type) { switch ($type) { case 'string': return DataTypes::STRING_TYPE; case 'number': return DataTypes::NUMBER_TYPE; case 'date': case 'datetime': return DataTypes::DATETIME_TYPE; case 'boolean': return DataTypes::BOOLEAN_TYPE; case 'tags': return DataTypes::TAGS_TYPE; case 'auto-complete': return DataTypes::AUTO_COMPLETE_TYPE; default: return DataTypes::UNDEFINED_TYPE; } }
[ "protected", "function", "getTypeForString", "(", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'string'", ":", "return", "DataTypes", "::", "STRING_TYPE", ";", "case", "'number'", ":", "return", "DataTypes", "::", "NUMBER_TYPE", ";", "case", "'date'", ":", "case", "'datetime'", ":", "return", "DataTypes", "::", "DATETIME_TYPE", ";", "case", "'boolean'", ":", "return", "DataTypes", "::", "BOOLEAN_TYPE", ";", "case", "'tags'", ":", "return", "DataTypes", "::", "TAGS_TYPE", ";", "case", "'auto-complete'", ":", "return", "DataTypes", "::", "AUTO_COMPLETE_TYPE", ";", "default", ":", "return", "DataTypes", "::", "UNDEFINED_TYPE", ";", "}", "}" ]
Returns integer for string type. @param string $type @returns integer
[ "Returns", "integer", "for", "string", "type", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/DataFixtures/ORM/Operators/LoadOperators.php#L136-L155
train
sulu/sulu
src/Sulu/Component/DocumentManager/Slugifier/NodeNameSlugifier.php
NodeNameSlugifier.slugify
public function slugify($text) { $text = $this->slugifier->slugify($text); // jackrabbit can not handle node-names which contains a number followed by "e" e.g. 10e $text = preg_replace('((\d+)([eE]))', '$1-$2', $text); return $text; }
php
public function slugify($text) { $text = $this->slugifier->slugify($text); // jackrabbit can not handle node-names which contains a number followed by "e" e.g. 10e $text = preg_replace('((\d+)([eE]))', '$1-$2', $text); return $text; }
[ "public", "function", "slugify", "(", "$", "text", ")", "{", "$", "text", "=", "$", "this", "->", "slugifier", "->", "slugify", "(", "$", "text", ")", ";", "// jackrabbit can not handle node-names which contains a number followed by \"e\" e.g. 10e", "$", "text", "=", "preg_replace", "(", "'((\\d+)([eE]))'", ",", "'$1-$2'", ",", "$", "text", ")", ";", "return", "$", "text", ";", "}" ]
Slugifies given string to a valid node-name. @param string $text @return string
[ "Slugifies", "given", "string", "to", "a", "valid", "node", "-", "name", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Slugifier/NodeNameSlugifier.php#L41-L49
train
sulu/sulu
src/Sulu/Bundle/TagBundle/Controller/TagController.php
TagController.getAction
public function getAction($id) { $view = $this->responseGetById( $id, function($id) { return $this->getManager()->findById($id); } ); $context = new Context(); $context->setGroups(['partialTag']); $view->setContext($context); return $this->handleView($view); }
php
public function getAction($id) { $view = $this->responseGetById( $id, function($id) { return $this->getManager()->findById($id); } ); $context = new Context(); $context->setGroups(['partialTag']); $view->setContext($context); return $this->handleView($view); }
[ "public", "function", "getAction", "(", "$", "id", ")", "{", "$", "view", "=", "$", "this", "->", "responseGetById", "(", "$", "id", ",", "function", "(", "$", "id", ")", "{", "return", "$", "this", "->", "getManager", "(", ")", "->", "findById", "(", "$", "id", ")", ";", "}", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "[", "'partialTag'", "]", ")", ";", "$", "view", "->", "setContext", "(", "$", "context", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Returns a single tag with the given id. @param $id @return Response
[ "Returns", "a", "single", "tag", "with", "the", "given", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/TagBundle/Controller/TagController.php#L62-L76
train
sulu/sulu
src/Sulu/Bundle/TagBundle/Controller/TagController.php
TagController.cgetAction
public function cgetAction(Request $request) { if ('true' == $request->get('flat')) { /** @var RestHelperInterface $restHelper */ $restHelper = $this->get('sulu_core.doctrine_rest_helper'); /** @var DoctrineListBuilderFactory $factory */ $factory = $this->get('sulu_core.doctrine_list_builder_factory'); $tagEntityName = $this->getParameter('sulu.model.tag.class'); $fieldDescriptors = $this->get('sulu_core.list_builder.field_descriptor_factory') ->getFieldDescriptors('tags'); $listBuilder = $factory->create($tagEntityName); $names = array_filter(explode(',', $request->get('names', ''))); if (count($names) > 0) { $listBuilder->in($fieldDescriptors['name'], $names); } $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors); $list = new ListRepresentation( $listBuilder->execute(), self::$entityKey, 'get_tags', $request->query->all(), $listBuilder->getCurrentPage(), $listBuilder->getLimit(), $listBuilder->count() ); $view = $this->view($list, 200); } else { $list = new CollectionRepresentation($this->getManager()->findAll(), self::$entityKey); $context = new Context(); $context->setGroups(['partialTag']); $view = $this->view($list, 200)->setContext($context); } return $this->handleView($view); }
php
public function cgetAction(Request $request) { if ('true' == $request->get('flat')) { /** @var RestHelperInterface $restHelper */ $restHelper = $this->get('sulu_core.doctrine_rest_helper'); /** @var DoctrineListBuilderFactory $factory */ $factory = $this->get('sulu_core.doctrine_list_builder_factory'); $tagEntityName = $this->getParameter('sulu.model.tag.class'); $fieldDescriptors = $this->get('sulu_core.list_builder.field_descriptor_factory') ->getFieldDescriptors('tags'); $listBuilder = $factory->create($tagEntityName); $names = array_filter(explode(',', $request->get('names', ''))); if (count($names) > 0) { $listBuilder->in($fieldDescriptors['name'], $names); } $restHelper->initializeListBuilder($listBuilder, $fieldDescriptors); $list = new ListRepresentation( $listBuilder->execute(), self::$entityKey, 'get_tags', $request->query->all(), $listBuilder->getCurrentPage(), $listBuilder->getLimit(), $listBuilder->count() ); $view = $this->view($list, 200); } else { $list = new CollectionRepresentation($this->getManager()->findAll(), self::$entityKey); $context = new Context(); $context->setGroups(['partialTag']); $view = $this->view($list, 200)->setContext($context); } return $this->handleView($view); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ")", "{", "if", "(", "'true'", "==", "$", "request", "->", "get", "(", "'flat'", ")", ")", "{", "/** @var RestHelperInterface $restHelper */", "$", "restHelper", "=", "$", "this", "->", "get", "(", "'sulu_core.doctrine_rest_helper'", ")", ";", "/** @var DoctrineListBuilderFactory $factory */", "$", "factory", "=", "$", "this", "->", "get", "(", "'sulu_core.doctrine_list_builder_factory'", ")", ";", "$", "tagEntityName", "=", "$", "this", "->", "getParameter", "(", "'sulu.model.tag.class'", ")", ";", "$", "fieldDescriptors", "=", "$", "this", "->", "get", "(", "'sulu_core.list_builder.field_descriptor_factory'", ")", "->", "getFieldDescriptors", "(", "'tags'", ")", ";", "$", "listBuilder", "=", "$", "factory", "->", "create", "(", "$", "tagEntityName", ")", ";", "$", "names", "=", "array_filter", "(", "explode", "(", "','", ",", "$", "request", "->", "get", "(", "'names'", ",", "''", ")", ")", ")", ";", "if", "(", "count", "(", "$", "names", ")", ">", "0", ")", "{", "$", "listBuilder", "->", "in", "(", "$", "fieldDescriptors", "[", "'name'", "]", ",", "$", "names", ")", ";", "}", "$", "restHelper", "->", "initializeListBuilder", "(", "$", "listBuilder", ",", "$", "fieldDescriptors", ")", ";", "$", "list", "=", "new", "ListRepresentation", "(", "$", "listBuilder", "->", "execute", "(", ")", ",", "self", "::", "$", "entityKey", ",", "'get_tags'", ",", "$", "request", "->", "query", "->", "all", "(", ")", ",", "$", "listBuilder", "->", "getCurrentPage", "(", ")", ",", "$", "listBuilder", "->", "getLimit", "(", ")", ",", "$", "listBuilder", "->", "count", "(", ")", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "list", ",", "200", ")", ";", "}", "else", "{", "$", "list", "=", "new", "CollectionRepresentation", "(", "$", "this", "->", "getManager", "(", ")", "->", "findAll", "(", ")", ",", "self", "::", "$", "entityKey", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "[", "'partialTag'", "]", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "list", ",", "200", ")", "->", "setContext", "(", "$", "context", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
returns all tags. @param Request $request @return Response
[ "returns", "all", "tags", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/TagBundle/Controller/TagController.php#L85-L126
train
sulu/sulu
src/Sulu/Bundle/TagBundle/Controller/TagController.php
TagController.postAction
public function postAction(Request $request) { $name = $request->get('name'); try { if (null == $name) { throw new MissingArgumentException(self::$entityName, 'name'); } $tag = $this->getManager()->save($this->getData($request)); $context = new Context(); $context->setGroups(['partialTag']); $view = $this->view($tag)->setContext($context); } catch (TagAlreadyExistsException $exc) { $cvExistsException = new ConstraintViolationException( 'A tag with the name "' . $exc->getName() . '"already exists!', 'name', ConstraintViolationException::EXCEPTION_CODE_NON_UNIQUE_NAME ); $view = $this->view($cvExistsException->toArray(), 400); } catch (RestException $exc) { $view = $this->view($exc->toArray(), 400); } return $this->handleView($view); }
php
public function postAction(Request $request) { $name = $request->get('name'); try { if (null == $name) { throw new MissingArgumentException(self::$entityName, 'name'); } $tag = $this->getManager()->save($this->getData($request)); $context = new Context(); $context->setGroups(['partialTag']); $view = $this->view($tag)->setContext($context); } catch (TagAlreadyExistsException $exc) { $cvExistsException = new ConstraintViolationException( 'A tag with the name "' . $exc->getName() . '"already exists!', 'name', ConstraintViolationException::EXCEPTION_CODE_NON_UNIQUE_NAME ); $view = $this->view($cvExistsException->toArray(), 400); } catch (RestException $exc) { $view = $this->view($exc->toArray(), 400); } return $this->handleView($view); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ")", "{", "$", "name", "=", "$", "request", "->", "get", "(", "'name'", ")", ";", "try", "{", "if", "(", "null", "==", "$", "name", ")", "{", "throw", "new", "MissingArgumentException", "(", "self", "::", "$", "entityName", ",", "'name'", ")", ";", "}", "$", "tag", "=", "$", "this", "->", "getManager", "(", ")", "->", "save", "(", "$", "this", "->", "getData", "(", "$", "request", ")", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "[", "'partialTag'", "]", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "tag", ")", "->", "setContext", "(", "$", "context", ")", ";", "}", "catch", "(", "TagAlreadyExistsException", "$", "exc", ")", "{", "$", "cvExistsException", "=", "new", "ConstraintViolationException", "(", "'A tag with the name \"'", ".", "$", "exc", "->", "getName", "(", ")", ".", "'\"already exists!'", ",", "'name'", ",", "ConstraintViolationException", "::", "EXCEPTION_CODE_NON_UNIQUE_NAME", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "cvExistsException", "->", "toArray", "(", ")", ",", "400", ")", ";", "}", "catch", "(", "RestException", "$", "exc", ")", "{", "$", "view", "=", "$", "this", "->", "view", "(", "$", "exc", "->", "toArray", "(", ")", ",", "400", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Inserts a new tag. @param \Symfony\Component\HttpFoundation\Request $request @throws \Doctrine\DBAL\DBALException @throws \Exception @return \Symfony\Component\HttpFoundation\Response @throws \Doctrine\DBAL\DBALException @throws \Exception
[ "Inserts", "a", "new", "tag", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/TagBundle/Controller/TagController.php#L141-L167
train
sulu/sulu
src/Sulu/Bundle/TagBundle/Controller/TagController.php
TagController.deleteAction
public function deleteAction($id) { $delete = function($id) { try { $this->getManager()->delete($id); } catch (TagNotFoundException $tnfe) { throw new EntityNotFoundException(self::$entityName, $id); } }; $view = $this->responseDelete($id, $delete); return $this->handleView($view); }
php
public function deleteAction($id) { $delete = function($id) { try { $this->getManager()->delete($id); } catch (TagNotFoundException $tnfe) { throw new EntityNotFoundException(self::$entityName, $id); } }; $view = $this->responseDelete($id, $delete); return $this->handleView($view); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "$", "delete", "=", "function", "(", "$", "id", ")", "{", "try", "{", "$", "this", "->", "getManager", "(", ")", "->", "delete", "(", "$", "id", ")", ";", "}", "catch", "(", "TagNotFoundException", "$", "tnfe", ")", "{", "throw", "new", "EntityNotFoundException", "(", "self", "::", "$", "entityName", ",", "$", "id", ")", ";", "}", "}", ";", "$", "view", "=", "$", "this", "->", "responseDelete", "(", "$", "id", ",", "$", "delete", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Deletes the tag with the given ID. @param $id @return Response
[ "Deletes", "the", "tag", "with", "the", "given", "ID", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/TagBundle/Controller/TagController.php#L218-L231
train
sulu/sulu
src/Sulu/Bundle/TagBundle/Controller/TagController.php
TagController.postMergeAction
public function postMergeAction(Request $request) { try { $srcTagIds = explode(',', $request->get('src')); $destTagId = $request->get('dest'); $destTag = $this->getManager()->merge($srcTagIds, $destTagId); $view = $this->view( null, 303, [ 'location' => $this->get('router')->generate('get_tag', ['id' => $destTag->getId()]), ] ); } catch (TagNotFoundException $exc) { $entityNotFoundException = new EntityNotFoundException(self::$entityName, $exc->getId()); $view = $this->view($entityNotFoundException->toArray(), 404); } return $this->handleView($view); }
php
public function postMergeAction(Request $request) { try { $srcTagIds = explode(',', $request->get('src')); $destTagId = $request->get('dest'); $destTag = $this->getManager()->merge($srcTagIds, $destTagId); $view = $this->view( null, 303, [ 'location' => $this->get('router')->generate('get_tag', ['id' => $destTag->getId()]), ] ); } catch (TagNotFoundException $exc) { $entityNotFoundException = new EntityNotFoundException(self::$entityName, $exc->getId()); $view = $this->view($entityNotFoundException->toArray(), 404); } return $this->handleView($view); }
[ "public", "function", "postMergeAction", "(", "Request", "$", "request", ")", "{", "try", "{", "$", "srcTagIds", "=", "explode", "(", "','", ",", "$", "request", "->", "get", "(", "'src'", ")", ")", ";", "$", "destTagId", "=", "$", "request", "->", "get", "(", "'dest'", ")", ";", "$", "destTag", "=", "$", "this", "->", "getManager", "(", ")", "->", "merge", "(", "$", "srcTagIds", ",", "$", "destTagId", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "null", ",", "303", ",", "[", "'location'", "=>", "$", "this", "->", "get", "(", "'router'", ")", "->", "generate", "(", "'get_tag'", ",", "[", "'id'", "=>", "$", "destTag", "->", "getId", "(", ")", "]", ")", ",", "]", ")", ";", "}", "catch", "(", "TagNotFoundException", "$", "exc", ")", "{", "$", "entityNotFoundException", "=", "new", "EntityNotFoundException", "(", "self", "::", "$", "entityName", ",", "$", "exc", "->", "getId", "(", ")", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "entityNotFoundException", "->", "toArray", "(", ")", ",", "404", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
POST Route annotation. @Post("/tags/merge") @param Request $request @return Response
[ "POST", "Route", "annotation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/TagBundle/Controller/TagController.php#L242-L263
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Serializer/Subscriber/StructureSubscriber.php
StructureSubscriber.addStructureProperties
private function addStructureProperties( StructureMetadata $structureMetadata, StructureBehavior $document, VisitorInterface $visitor ) { /** @var ManagedStructure $structure */ $structure = $document->getStructure(); $data = $structure->toArray(); foreach ($structureMetadata->getProperties() as $name => $property) { if ('title' === $name || !array_key_exists($name, $data) || $property->hasTag('sulu.rlp')) { continue; } $visitor->addData($name, $data[$name]); } }
php
private function addStructureProperties( StructureMetadata $structureMetadata, StructureBehavior $document, VisitorInterface $visitor ) { /** @var ManagedStructure $structure */ $structure = $document->getStructure(); $data = $structure->toArray(); foreach ($structureMetadata->getProperties() as $name => $property) { if ('title' === $name || !array_key_exists($name, $data) || $property->hasTag('sulu.rlp')) { continue; } $visitor->addData($name, $data[$name]); } }
[ "private", "function", "addStructureProperties", "(", "StructureMetadata", "$", "structureMetadata", ",", "StructureBehavior", "$", "document", ",", "VisitorInterface", "$", "visitor", ")", "{", "/** @var ManagedStructure $structure */", "$", "structure", "=", "$", "document", "->", "getStructure", "(", ")", ";", "$", "data", "=", "$", "structure", "->", "toArray", "(", ")", ";", "foreach", "(", "$", "structureMetadata", "->", "getProperties", "(", ")", "as", "$", "name", "=>", "$", "property", ")", "{", "if", "(", "'title'", "===", "$", "name", "||", "!", "array_key_exists", "(", "$", "name", ",", "$", "data", ")", "||", "$", "property", "->", "hasTag", "(", "'sulu.rlp'", ")", ")", "{", "continue", ";", "}", "$", "visitor", "->", "addData", "(", "$", "name", ",", "$", "data", "[", "$", "name", "]", ")", ";", "}", "}" ]
Adds the properties of the structure to the serialization. @param StructureBehavior $document @param VisitorInterface $visitor
[ "Adds", "the", "properties", "of", "the", "structure", "to", "the", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Serializer/Subscriber/StructureSubscriber.php#L114-L129
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Serializer/Subscriber/StructureSubscriber.php
StructureSubscriber.addBreadcrumb
private function addBreadcrumb(StructureBehavior $document, VisitorInterface $visitor) { $items = []; $parentDocument = $this->inspector->getParent($document); while ($parentDocument instanceof StructureBehavior) { $item = []; if ($parentDocument instanceof UuidBehavior) { $item['uuid'] = $parentDocument->getUuid(); } $item['title'] = $parentDocument->getStructure()->getProperty('title')->getValue(); $items[] = $item; $parentDocument = $this->inspector->getParent($parentDocument); } $items = array_reverse($items); array_walk( $items, function(&$item, $index) { $item['depth'] = $index; } ); $visitor->addData('breadcrumb', $items); }
php
private function addBreadcrumb(StructureBehavior $document, VisitorInterface $visitor) { $items = []; $parentDocument = $this->inspector->getParent($document); while ($parentDocument instanceof StructureBehavior) { $item = []; if ($parentDocument instanceof UuidBehavior) { $item['uuid'] = $parentDocument->getUuid(); } $item['title'] = $parentDocument->getStructure()->getProperty('title')->getValue(); $items[] = $item; $parentDocument = $this->inspector->getParent($parentDocument); } $items = array_reverse($items); array_walk( $items, function(&$item, $index) { $item['depth'] = $index; } ); $visitor->addData('breadcrumb', $items); }
[ "private", "function", "addBreadcrumb", "(", "StructureBehavior", "$", "document", ",", "VisitorInterface", "$", "visitor", ")", "{", "$", "items", "=", "[", "]", ";", "$", "parentDocument", "=", "$", "this", "->", "inspector", "->", "getParent", "(", "$", "document", ")", ";", "while", "(", "$", "parentDocument", "instanceof", "StructureBehavior", ")", "{", "$", "item", "=", "[", "]", ";", "if", "(", "$", "parentDocument", "instanceof", "UuidBehavior", ")", "{", "$", "item", "[", "'uuid'", "]", "=", "$", "parentDocument", "->", "getUuid", "(", ")", ";", "}", "$", "item", "[", "'title'", "]", "=", "$", "parentDocument", "->", "getStructure", "(", ")", "->", "getProperty", "(", "'title'", ")", "->", "getValue", "(", ")", ";", "$", "items", "[", "]", "=", "$", "item", ";", "$", "parentDocument", "=", "$", "this", "->", "inspector", "->", "getParent", "(", "$", "parentDocument", ")", ";", "}", "$", "items", "=", "array_reverse", "(", "$", "items", ")", ";", "array_walk", "(", "$", "items", ",", "function", "(", "&", "$", "item", ",", "$", "index", ")", "{", "$", "item", "[", "'depth'", "]", "=", "$", "index", ";", "}", ")", ";", "$", "visitor", "->", "addData", "(", "'breadcrumb'", ",", "$", "items", ")", ";", "}" ]
Adds the breadcrumb to the serialization. @param StructureBehavior $document @param VisitorInterface $visitor
[ "Adds", "the", "breadcrumb", "to", "the", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Serializer/Subscriber/StructureSubscriber.php#L137-L164
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201512090753.php
Version201512090753.upgradeNode
private function upgradeNode(NodeInterface $node) { foreach ($node->getProperties('i18n:-*') as $property) { $property->remove(); } foreach ($node->getNodes() as $childNode) { $this->upgradeNode($childNode); } }
php
private function upgradeNode(NodeInterface $node) { foreach ($node->getProperties('i18n:-*') as $property) { $property->remove(); } foreach ($node->getNodes() as $childNode) { $this->upgradeNode($childNode); } }
[ "private", "function", "upgradeNode", "(", "NodeInterface", "$", "node", ")", "{", "foreach", "(", "$", "node", "->", "getProperties", "(", "'i18n:-*'", ")", "as", "$", "property", ")", "{", "$", "property", "->", "remove", "(", ")", ";", "}", "foreach", "(", "$", "node", "->", "getNodes", "(", ")", "as", "$", "childNode", ")", "{", "$", "this", "->", "upgradeNode", "(", "$", "childNode", ")", ";", "}", "}" ]
Removes non translated properties. @param NodeInterface $node
[ "Removes", "non", "translated", "properties", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201512090753.php#L45-L54
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Search/Metadata/StructureProvider.php
StructureProvider.getMetadataForObject
public function getMetadataForObject($object) { if (!$object instanceof StructureBehavior) { return; } $documentMetadata = $this->metadataFactory->getMetadataForClass(get_class($object)); $structure = $this->structureFactory->getStructureMetadata( $documentMetadata->getAlias(), $object->getStructureType() ); return $this->getMetadata($documentMetadata, $structure); }
php
public function getMetadataForObject($object) { if (!$object instanceof StructureBehavior) { return; } $documentMetadata = $this->metadataFactory->getMetadataForClass(get_class($object)); $structure = $this->structureFactory->getStructureMetadata( $documentMetadata->getAlias(), $object->getStructureType() ); return $this->getMetadata($documentMetadata, $structure); }
[ "public", "function", "getMetadataForObject", "(", "$", "object", ")", "{", "if", "(", "!", "$", "object", "instanceof", "StructureBehavior", ")", "{", "return", ";", "}", "$", "documentMetadata", "=", "$", "this", "->", "metadataFactory", "->", "getMetadataForClass", "(", "get_class", "(", "$", "object", ")", ")", ";", "$", "structure", "=", "$", "this", "->", "structureFactory", "->", "getStructureMetadata", "(", "$", "documentMetadata", "->", "getAlias", "(", ")", ",", "$", "object", "->", "getStructureType", "(", ")", ")", ";", "return", "$", "this", "->", "getMetadata", "(", "$", "documentMetadata", ",", "$", "structure", ")", ";", "}" ]
loads metadata for a given class if its derived from StructureInterface. @param object $object @return IndexMetadataInterface|null
[ "loads", "metadata", "for", "a", "given", "class", "if", "its", "derived", "from", "StructureInterface", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Search/Metadata/StructureProvider.php#L104-L117
train
sulu/sulu
src/Sulu/Bundle/RouteBundle/Routing/RouteProvider.php
RouteProvider.findRouteByPath
private function findRouteByPath($path, $locale) { $path = '/' . ltrim($path, '/'); if (!array_key_exists($path, $this->routeCache)) { $this->routeCache[$path] = $this->routeRepository->findByPath($path, $locale); } return $this->routeCache[$path]; }
php
private function findRouteByPath($path, $locale) { $path = '/' . ltrim($path, '/'); if (!array_key_exists($path, $this->routeCache)) { $this->routeCache[$path] = $this->routeRepository->findByPath($path, $locale); } return $this->routeCache[$path]; }
[ "private", "function", "findRouteByPath", "(", "$", "path", ",", "$", "locale", ")", "{", "$", "path", "=", "'/'", ".", "ltrim", "(", "$", "path", ",", "'/'", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "path", ",", "$", "this", "->", "routeCache", ")", ")", "{", "$", "this", "->", "routeCache", "[", "$", "path", "]", "=", "$", "this", "->", "routeRepository", "->", "findByPath", "(", "$", "path", ",", "$", "locale", ")", ";", "}", "return", "$", "this", "->", "routeCache", "[", "$", "path", "]", ";", "}" ]
Find route and cache it. @param string $path @param string $locale @return SuluRoute
[ "Find", "route", "and", "cache", "it", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/RouteBundle/Routing/RouteProvider.php#L148-L156
train
sulu/sulu
src/Sulu/Bundle/RouteBundle/Routing/RouteProvider.php
RouteProvider.createRoute
protected function createRoute(RouteInterface $route, Request $request) { $routePath = $this->decodePathInfo($request->getPathInfo()); if ($route->isHistory()) { return new Route( $routePath, [ '_controller' => 'SuluWebsiteBundle:Redirect:redirect', 'url' => $request->getSchemeAndHttpHost() . $this->requestAnalyzer->getResourceLocatorPrefix() . $route->getTarget()->getPath() . ($request->getQueryString() ? ('?' . $request->getQueryString()) : ''), ] ); } $symfonyRoute = $this->proxyFactory->createProxy( Route::class, function(&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use ( $routePath, $route, $request ) { $initializer = null; // disable initialization $wrappedObject = new Route( $routePath, $this->routeDefaultsProvider->getByEntity( $route->getEntityClass(), $route->getEntityId(), $request->getLocale() ) ); return true; } ); return $this->symfonyRouteCache[$route->getId()] = $symfonyRoute; }
php
protected function createRoute(RouteInterface $route, Request $request) { $routePath = $this->decodePathInfo($request->getPathInfo()); if ($route->isHistory()) { return new Route( $routePath, [ '_controller' => 'SuluWebsiteBundle:Redirect:redirect', 'url' => $request->getSchemeAndHttpHost() . $this->requestAnalyzer->getResourceLocatorPrefix() . $route->getTarget()->getPath() . ($request->getQueryString() ? ('?' . $request->getQueryString()) : ''), ] ); } $symfonyRoute = $this->proxyFactory->createProxy( Route::class, function(&$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer) use ( $routePath, $route, $request ) { $initializer = null; // disable initialization $wrappedObject = new Route( $routePath, $this->routeDefaultsProvider->getByEntity( $route->getEntityClass(), $route->getEntityId(), $request->getLocale() ) ); return true; } ); return $this->symfonyRouteCache[$route->getId()] = $symfonyRoute; }
[ "protected", "function", "createRoute", "(", "RouteInterface", "$", "route", ",", "Request", "$", "request", ")", "{", "$", "routePath", "=", "$", "this", "->", "decodePathInfo", "(", "$", "request", "->", "getPathInfo", "(", ")", ")", ";", "if", "(", "$", "route", "->", "isHistory", "(", ")", ")", "{", "return", "new", "Route", "(", "$", "routePath", ",", "[", "'_controller'", "=>", "'SuluWebsiteBundle:Redirect:redirect'", ",", "'url'", "=>", "$", "request", "->", "getSchemeAndHttpHost", "(", ")", ".", "$", "this", "->", "requestAnalyzer", "->", "getResourceLocatorPrefix", "(", ")", ".", "$", "route", "->", "getTarget", "(", ")", "->", "getPath", "(", ")", ".", "(", "$", "request", "->", "getQueryString", "(", ")", "?", "(", "'?'", ".", "$", "request", "->", "getQueryString", "(", ")", ")", ":", "''", ")", ",", "]", ")", ";", "}", "$", "symfonyRoute", "=", "$", "this", "->", "proxyFactory", "->", "createProxy", "(", "Route", "::", "class", ",", "function", "(", "&", "$", "wrappedObject", ",", "LazyLoadingInterface", "$", "proxy", ",", "$", "method", ",", "array", "$", "parameters", ",", "&", "$", "initializer", ")", "use", "(", "$", "routePath", ",", "$", "route", ",", "$", "request", ")", "{", "$", "initializer", "=", "null", ";", "// disable initialization", "$", "wrappedObject", "=", "new", "Route", "(", "$", "routePath", ",", "$", "this", "->", "routeDefaultsProvider", "->", "getByEntity", "(", "$", "route", "->", "getEntityClass", "(", ")", ",", "$", "route", "->", "getEntityId", "(", ")", ",", "$", "request", "->", "getLocale", "(", ")", ")", ")", ";", "return", "true", ";", "}", ")", ";", "return", "$", "this", "->", "symfonyRouteCache", "[", "$", "route", "->", "getId", "(", ")", "]", "=", "$", "symfonyRoute", ";", "}" ]
Will create a symfony route. @param RouteInterface $route @param Request $request @return Route
[ "Will", "create", "a", "symfony", "route", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/RouteBundle/Routing/RouteProvider.php#L205-L244
train
sulu/sulu
src/Sulu/Bundle/RouteBundle/Routing/RouteProvider.php
RouteProvider.stripFormatExtension
private function stripFormatExtension($path, $format) { $extension = '.' . $format; if (substr($path, -strlen($extension)) === $extension) { $path = substr($path, 0, strlen($path) - strlen($extension)); } return $path; }
php
private function stripFormatExtension($path, $format) { $extension = '.' . $format; if (substr($path, -strlen($extension)) === $extension) { $path = substr($path, 0, strlen($path) - strlen($extension)); } return $path; }
[ "private", "function", "stripFormatExtension", "(", "$", "path", ",", "$", "format", ")", "{", "$", "extension", "=", "'.'", ".", "$", "format", ";", "if", "(", "substr", "(", "$", "path", ",", "-", "strlen", "(", "$", "extension", ")", ")", "===", "$", "extension", ")", "{", "$", "path", "=", "substr", "(", "$", "path", ",", "0", ",", "strlen", "(", "$", "path", ")", "-", "strlen", "(", "$", "extension", ")", ")", ";", "}", "return", "$", "path", ";", "}" ]
Return the given path without the format extension. @param string $path @param string $format @return string
[ "Return", "the", "given", "path", "without", "the", "format", "extension", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/RouteBundle/Routing/RouteProvider.php#L271-L279
train
sulu/sulu
src/Sulu/Bundle/CategoryBundle/Twig/CategoryTwigExtension.php
CategoryTwigExtension.getCategoriesFunction
public function getCategoriesFunction($locale, $parentKey = null) { return $this->memoizeCache->memoizeById( 'sulu_categories', func_get_args(), function($locale, $parentKey = null) { $entities = $this->categoryManager->findChildrenByParentKey($parentKey); $categories = $this->categoryManager->getApiObjects($entities, $locale); $context = SerializationContext::create(); $context->setSerializeNull(true); return $this->serializer->serialize($categories, 'array', $context); } ); }
php
public function getCategoriesFunction($locale, $parentKey = null) { return $this->memoizeCache->memoizeById( 'sulu_categories', func_get_args(), function($locale, $parentKey = null) { $entities = $this->categoryManager->findChildrenByParentKey($parentKey); $categories = $this->categoryManager->getApiObjects($entities, $locale); $context = SerializationContext::create(); $context->setSerializeNull(true); return $this->serializer->serialize($categories, 'array', $context); } ); }
[ "public", "function", "getCategoriesFunction", "(", "$", "locale", ",", "$", "parentKey", "=", "null", ")", "{", "return", "$", "this", "->", "memoizeCache", "->", "memoizeById", "(", "'sulu_categories'", ",", "func_get_args", "(", ")", ",", "function", "(", "$", "locale", ",", "$", "parentKey", "=", "null", ")", "{", "$", "entities", "=", "$", "this", "->", "categoryManager", "->", "findChildrenByParentKey", "(", "$", "parentKey", ")", ";", "$", "categories", "=", "$", "this", "->", "categoryManager", "->", "getApiObjects", "(", "$", "entities", ",", "$", "locale", ")", ";", "$", "context", "=", "SerializationContext", "::", "create", "(", ")", ";", "$", "context", "->", "setSerializeNull", "(", "true", ")", ";", "return", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "categories", ",", "'array'", ",", "$", "context", ")", ";", "}", ")", ";", "}" ]
Returns an array of serialized categories. If parentKey is set, only the children of the category which is assigned to the given key are returned. @param string $locale @param string $parentKey key of parent category @return array
[ "Returns", "an", "array", "of", "serialized", "categories", ".", "If", "parentKey", "is", "set", "only", "the", "children", "of", "the", "category", "which", "is", "assigned", "to", "the", "given", "key", "are", "returned", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/CategoryBundle/Twig/CategoryTwigExtension.php#L79-L93
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php
Version201511240843.findDateProperties
private function findDateProperties(StructureMetadata $structureMetadata, array &$properties) { $structureName = $structureMetadata->getName(); foreach ($structureMetadata->getProperties() as $property) { if ('date' === $property->getType()) { $properties[$structureName][] = ['property' => $property]; } elseif ($property instanceof BlockMetadata) { $this->findDateBlockProperties($property, $structureName, $properties); } } }
php
private function findDateProperties(StructureMetadata $structureMetadata, array &$properties) { $structureName = $structureMetadata->getName(); foreach ($structureMetadata->getProperties() as $property) { if ('date' === $property->getType()) { $properties[$structureName][] = ['property' => $property]; } elseif ($property instanceof BlockMetadata) { $this->findDateBlockProperties($property, $structureName, $properties); } } }
[ "private", "function", "findDateProperties", "(", "StructureMetadata", "$", "structureMetadata", ",", "array", "&", "$", "properties", ")", "{", "$", "structureName", "=", "$", "structureMetadata", "->", "getName", "(", ")", ";", "foreach", "(", "$", "structureMetadata", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "if", "(", "'date'", "===", "$", "property", "->", "getType", "(", ")", ")", "{", "$", "properties", "[", "$", "structureName", "]", "[", "]", "=", "[", "'property'", "=>", "$", "property", "]", ";", "}", "elseif", "(", "$", "property", "instanceof", "BlockMetadata", ")", "{", "$", "this", "->", "findDateBlockProperties", "(", "$", "property", ",", "$", "structureName", ",", "$", "properties", ")", ";", "}", "}", "}" ]
Returns all properties which are a date field. @param StructureMetadata $structureMetadata The metadata in which the date fields are searched @param array $properties The properties which are date fields are added to this array
[ "Returns", "all", "properties", "which", "are", "a", "date", "field", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php#L140-L150
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php
Version201511240843.findDateBlockProperties
private function findDateBlockProperties(BlockMetadata $property, $structureName, array &$properties) { $result = ['property' => $property, 'components' => []]; foreach ($property->getComponents() as $component) { $componentResult = ['component' => $component, 'children' => []]; foreach ($component->getChildren() as $childProperty) { if ('date' === $childProperty->getType()) { $componentResult['children'][$childProperty->getName()] = $childProperty; } } if (count($componentResult['children']) > 0) { $result['components'][$component->getName()] = $componentResult; } } if (count($result['components']) > 0) { $properties[$structureName][] = $result; } }
php
private function findDateBlockProperties(BlockMetadata $property, $structureName, array &$properties) { $result = ['property' => $property, 'components' => []]; foreach ($property->getComponents() as $component) { $componentResult = ['component' => $component, 'children' => []]; foreach ($component->getChildren() as $childProperty) { if ('date' === $childProperty->getType()) { $componentResult['children'][$childProperty->getName()] = $childProperty; } } if (count($componentResult['children']) > 0) { $result['components'][$component->getName()] = $componentResult; } } if (count($result['components']) > 0) { $properties[$structureName][] = $result; } }
[ "private", "function", "findDateBlockProperties", "(", "BlockMetadata", "$", "property", ",", "$", "structureName", ",", "array", "&", "$", "properties", ")", "{", "$", "result", "=", "[", "'property'", "=>", "$", "property", ",", "'components'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "property", "->", "getComponents", "(", ")", "as", "$", "component", ")", "{", "$", "componentResult", "=", "[", "'component'", "=>", "$", "component", ",", "'children'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "component", "->", "getChildren", "(", ")", "as", "$", "childProperty", ")", "{", "if", "(", "'date'", "===", "$", "childProperty", "->", "getType", "(", ")", ")", "{", "$", "componentResult", "[", "'children'", "]", "[", "$", "childProperty", "->", "getName", "(", ")", "]", "=", "$", "childProperty", ";", "}", "}", "if", "(", "count", "(", "$", "componentResult", "[", "'children'", "]", ")", ">", "0", ")", "{", "$", "result", "[", "'components'", "]", "[", "$", "component", "->", "getName", "(", ")", "]", "=", "$", "componentResult", ";", "}", "}", "if", "(", "count", "(", "$", "result", "[", "'components'", "]", ")", ">", "0", ")", "{", "$", "properties", "[", "$", "structureName", "]", "[", "]", "=", "$", "result", ";", "}", "}" ]
Adds the block property to the list, if it contains a date field. @param BlockMetadata $property The block property to check @param string $structureName The name of the structure the property belongs to @param array $properties The list of properties, to which the block is added if it is a date field
[ "Adds", "the", "block", "property", "to", "the", "list", "if", "it", "contains", "a", "date", "field", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php#L159-L178
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php
Version201511240843.iterateStructureNodes
private function iterateStructureNodes(StructureMetadata $structureMetadata, array $properties, $up) { foreach ($this->localizationManager->getLocalizations() as $localization) { $rows = $this->session->getWorkspace()->getQueryManager()->createQuery( sprintf( 'SELECT * FROM [nt:unstructured] WHERE [%s] = "%s" OR [%s] = "%s"', $this->propertyEncoder->localizedSystemName('template', $localization->getLocale()), $structureMetadata->getName(), 'template', $structureMetadata->getName() ), 'JCR-SQL2' )->execute(); foreach ($rows->getNodes() as $node) { $this->upgradeNode($node, $localization->getLocale(), $properties, $up); } } }
php
private function iterateStructureNodes(StructureMetadata $structureMetadata, array $properties, $up) { foreach ($this->localizationManager->getLocalizations() as $localization) { $rows = $this->session->getWorkspace()->getQueryManager()->createQuery( sprintf( 'SELECT * FROM [nt:unstructured] WHERE [%s] = "%s" OR [%s] = "%s"', $this->propertyEncoder->localizedSystemName('template', $localization->getLocale()), $structureMetadata->getName(), 'template', $structureMetadata->getName() ), 'JCR-SQL2' )->execute(); foreach ($rows->getNodes() as $node) { $this->upgradeNode($node, $localization->getLocale(), $properties, $up); } } }
[ "private", "function", "iterateStructureNodes", "(", "StructureMetadata", "$", "structureMetadata", ",", "array", "$", "properties", ",", "$", "up", ")", "{", "foreach", "(", "$", "this", "->", "localizationManager", "->", "getLocalizations", "(", ")", "as", "$", "localization", ")", "{", "$", "rows", "=", "$", "this", "->", "session", "->", "getWorkspace", "(", ")", "->", "getQueryManager", "(", ")", "->", "createQuery", "(", "sprintf", "(", "'SELECT * FROM [nt:unstructured] WHERE [%s] = \"%s\" OR [%s] = \"%s\"'", ",", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "'template'", ",", "$", "localization", "->", "getLocale", "(", ")", ")", ",", "$", "structureMetadata", "->", "getName", "(", ")", ",", "'template'", ",", "$", "structureMetadata", "->", "getName", "(", ")", ")", ",", "'JCR-SQL2'", ")", "->", "execute", "(", ")", ";", "foreach", "(", "$", "rows", "->", "getNodes", "(", ")", "as", "$", "node", ")", "{", "$", "this", "->", "upgradeNode", "(", "$", "node", ",", "$", "localization", "->", "getLocale", "(", ")", ",", "$", "properties", ",", "$", "up", ")", ";", "}", "}", "}" ]
Iterates over all nodes of the given type, and upgrades them. @param StructureMetadata $structureMetadata The structure metadata, whose pages have to be upgraded @param array $properties The properties which are or contain date fields @param bool $up
[ "Iterates", "over", "all", "nodes", "of", "the", "given", "type", "and", "upgrades", "them", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php#L187-L205
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php
Version201511240843.upgradeBlockProperty
private function upgradeBlockProperty( BlockMetadata $blockProperty, array $components, NodeInterface $node, $locale, $up ) { $componentNames = array_map( function($item) { return $item['component']->getName(); }, $components ); $lengthName = sprintf('i18n:%s-%s-length', $locale, $blockProperty->getName()); $length = $node->getPropertyValue($lengthName); for ($i = 0; $i < $length; ++$i) { $type = $node->getPropertyValue(sprintf('i18n:%s-%s-type#%s', $locale, $blockProperty->getName(), $i)); if (!in_array($type, $componentNames)) { continue; } foreach ($components[$type]['children'] as $child) { $name = sprintf('i18n:%s-%s-%s#%s', $locale, $blockProperty->getName(), $child->getName(), $i); if (!$node->hasProperty($name)) { continue; } $value = $node->getPropertyValue($name); if ($up) { $value = $this->upgradeDate($value); } else { $value = $this->downgradeDate($value); } $node->setProperty($name, $value); } } }
php
private function upgradeBlockProperty( BlockMetadata $blockProperty, array $components, NodeInterface $node, $locale, $up ) { $componentNames = array_map( function($item) { return $item['component']->getName(); }, $components ); $lengthName = sprintf('i18n:%s-%s-length', $locale, $blockProperty->getName()); $length = $node->getPropertyValue($lengthName); for ($i = 0; $i < $length; ++$i) { $type = $node->getPropertyValue(sprintf('i18n:%s-%s-type#%s', $locale, $blockProperty->getName(), $i)); if (!in_array($type, $componentNames)) { continue; } foreach ($components[$type]['children'] as $child) { $name = sprintf('i18n:%s-%s-%s#%s', $locale, $blockProperty->getName(), $child->getName(), $i); if (!$node->hasProperty($name)) { continue; } $value = $node->getPropertyValue($name); if ($up) { $value = $this->upgradeDate($value); } else { $value = $this->downgradeDate($value); } $node->setProperty($name, $value); } } }
[ "private", "function", "upgradeBlockProperty", "(", "BlockMetadata", "$", "blockProperty", ",", "array", "$", "components", ",", "NodeInterface", "$", "node", ",", "$", "locale", ",", "$", "up", ")", "{", "$", "componentNames", "=", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "[", "'component'", "]", "->", "getName", "(", ")", ";", "}", ",", "$", "components", ")", ";", "$", "lengthName", "=", "sprintf", "(", "'i18n:%s-%s-length'", ",", "$", "locale", ",", "$", "blockProperty", "->", "getName", "(", ")", ")", ";", "$", "length", "=", "$", "node", "->", "getPropertyValue", "(", "$", "lengthName", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "++", "$", "i", ")", "{", "$", "type", "=", "$", "node", "->", "getPropertyValue", "(", "sprintf", "(", "'i18n:%s-%s-type#%s'", ",", "$", "locale", ",", "$", "blockProperty", "->", "getName", "(", ")", ",", "$", "i", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "componentNames", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "components", "[", "$", "type", "]", "[", "'children'", "]", "as", "$", "child", ")", "{", "$", "name", "=", "sprintf", "(", "'i18n:%s-%s-%s#%s'", ",", "$", "locale", ",", "$", "blockProperty", "->", "getName", "(", ")", ",", "$", "child", "->", "getName", "(", ")", ",", "$", "i", ")", ";", "if", "(", "!", "$", "node", "->", "hasProperty", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "node", "->", "getPropertyValue", "(", "$", "name", ")", ";", "if", "(", "$", "up", ")", "{", "$", "value", "=", "$", "this", "->", "upgradeDate", "(", "$", "value", ")", ";", "}", "else", "{", "$", "value", "=", "$", "this", "->", "downgradeDate", "(", "$", "value", ")", ";", "}", "$", "node", "->", "setProperty", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}", "}" ]
Upgrades the given block property to the new date representation. @param BlockMetadata $blockProperty @param array $components @param NodeInterface $node @param string $locale @param bool $up
[ "Upgrades", "the", "given", "block", "property", "to", "the", "new", "date", "representation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php#L245-L286
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php
Version201511240843.upgradeProperty
private function upgradeProperty(PropertyMetadata $property, NodeInterface $node, $locale, $up) { $name = sprintf('i18n:%s-%s', $locale, $property->getName()); if (!$node->hasProperty($name)) { return; } $value = $node->getPropertyValue($name); if ($up) { $value = $this->upgradeDate($value); } else { $value = $this->downgradeDate($value); } $node->setProperty($name, $value); }
php
private function upgradeProperty(PropertyMetadata $property, NodeInterface $node, $locale, $up) { $name = sprintf('i18n:%s-%s', $locale, $property->getName()); if (!$node->hasProperty($name)) { return; } $value = $node->getPropertyValue($name); if ($up) { $value = $this->upgradeDate($value); } else { $value = $this->downgradeDate($value); } $node->setProperty($name, $value); }
[ "private", "function", "upgradeProperty", "(", "PropertyMetadata", "$", "property", ",", "NodeInterface", "$", "node", ",", "$", "locale", ",", "$", "up", ")", "{", "$", "name", "=", "sprintf", "(", "'i18n:%s-%s'", ",", "$", "locale", ",", "$", "property", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "$", "node", "->", "hasProperty", "(", "$", "name", ")", ")", "{", "return", ";", "}", "$", "value", "=", "$", "node", "->", "getPropertyValue", "(", "$", "name", ")", ";", "if", "(", "$", "up", ")", "{", "$", "value", "=", "$", "this", "->", "upgradeDate", "(", "$", "value", ")", ";", "}", "else", "{", "$", "value", "=", "$", "this", "->", "downgradeDate", "(", "$", "value", ")", ";", "}", "$", "node", "->", "setProperty", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Upgrades the given property to the new date representation. @param PropertyMetadata $property @param NodeInterface $node @param bool $up
[ "Upgrades", "the", "given", "property", "to", "the", "new", "date", "representation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php#L295-L311
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php
Version201511240843.upgradeDate
private function upgradeDate(&$value) { if ($value instanceof \DateTime) { return $value; } $value = \DateTime::createFromFormat('Y-m-d', $value); return $value; }
php
private function upgradeDate(&$value) { if ($value instanceof \DateTime) { return $value; } $value = \DateTime::createFromFormat('Y-m-d', $value); return $value; }
[ "private", "function", "upgradeDate", "(", "&", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "\\", "DateTime", "::", "createFromFormat", "(", "'Y-m-d'", ",", "$", "value", ")", ";", "return", "$", "value", ";", "}" ]
Upgrades the given date to the new representation. @param string $value The date to change @return string
[ "Upgrades", "the", "given", "date", "to", "the", "new", "representation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Resources/phpcr-migrations/Version201511240843.php#L320-L329
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Entity/OperatorValueTranslation.php
OperatorValueTranslation.setOperatorValue
public function setOperatorValue(\Sulu\Bundle\ResourceBundle\Entity\OperatorValue $operatorValue) { $this->operatorValue = $operatorValue; return $this; }
php
public function setOperatorValue(\Sulu\Bundle\ResourceBundle\Entity\OperatorValue $operatorValue) { $this->operatorValue = $operatorValue; return $this; }
[ "public", "function", "setOperatorValue", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ResourceBundle", "\\", "Entity", "\\", "OperatorValue", "$", "operatorValue", ")", "{", "$", "this", "->", "operatorValue", "=", "$", "operatorValue", ";", "return", "$", "this", ";", "}" ]
Set operatorValue. @param \Sulu\Bundle\ResourceBundle\Entity\OperatorValue $operatorValue @return OperatorValueTranslation
[ "Set", "operatorValue", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Entity/OperatorValueTranslation.php#L162-L167
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.applyTransformations
private function applyTransformations(ImageInterface $image, $tansformations) { foreach ($tansformations as $transformation) { if (!isset($transformation['effect'])) { throw new ImageProxyInvalidFormatOptionsException('Effect not found'); } $image = $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($transformation) { return $this->transformationPool->get($transformation['effect'])->execute( $layer, $transformation['parameters'] ); } ); } return $image; }
php
private function applyTransformations(ImageInterface $image, $tansformations) { foreach ($tansformations as $transformation) { if (!isset($transformation['effect'])) { throw new ImageProxyInvalidFormatOptionsException('Effect not found'); } $image = $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($transformation) { return $this->transformationPool->get($transformation['effect'])->execute( $layer, $transformation['parameters'] ); } ); } return $image; }
[ "private", "function", "applyTransformations", "(", "ImageInterface", "$", "image", ",", "$", "tansformations", ")", "{", "foreach", "(", "$", "tansformations", "as", "$", "transformation", ")", "{", "if", "(", "!", "isset", "(", "$", "transformation", "[", "'effect'", "]", ")", ")", "{", "throw", "new", "ImageProxyInvalidFormatOptionsException", "(", "'Effect not found'", ")", ";", "}", "$", "image", "=", "$", "this", "->", "modifyAllLayers", "(", "$", "image", ",", "function", "(", "ImageInterface", "$", "layer", ")", "use", "(", "$", "transformation", ")", "{", "return", "$", "this", "->", "transformationPool", "->", "get", "(", "$", "transformation", "[", "'effect'", "]", ")", "->", "execute", "(", "$", "layer", ",", "$", "transformation", "[", "'parameters'", "]", ")", ";", "}", ")", ";", "}", "return", "$", "image", ";", "}" ]
Applies an array of transformations on a passed image. @param ImageInterface $image @param $tansformations @throws ImageProxyInvalidFormatOptionsException @return ImageInterface The modified image
[ "Applies", "an", "array", "of", "transformations", "on", "a", "passed", "image", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L169-L187
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.applyFormatCrop
private function applyFormatCrop(ImageInterface $image, array $cropParameters) { return $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($cropParameters) { return $this->cropper->crop( $layer, $cropParameters['x'], $cropParameters['y'], $cropParameters['width'], $cropParameters['height'] ); } ); }
php
private function applyFormatCrop(ImageInterface $image, array $cropParameters) { return $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($cropParameters) { return $this->cropper->crop( $layer, $cropParameters['x'], $cropParameters['y'], $cropParameters['width'], $cropParameters['height'] ); } ); }
[ "private", "function", "applyFormatCrop", "(", "ImageInterface", "$", "image", ",", "array", "$", "cropParameters", ")", "{", "return", "$", "this", "->", "modifyAllLayers", "(", "$", "image", ",", "function", "(", "ImageInterface", "$", "layer", ")", "use", "(", "$", "cropParameters", ")", "{", "return", "$", "this", "->", "cropper", "->", "crop", "(", "$", "layer", ",", "$", "cropParameters", "[", "'x'", "]", ",", "$", "cropParameters", "[", "'y'", "]", ",", "$", "cropParameters", "[", "'width'", "]", ",", "$", "cropParameters", "[", "'height'", "]", ")", ";", "}", ")", ";", "}" ]
Crops a given image according to given parameters. @param ImageInterface $image The image to crop @param array $cropParameters The parameters which define the area to crop @return ImageInterface The cropped image
[ "Crops", "a", "given", "image", "according", "to", "given", "parameters", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L197-L211
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.applyFocus
private function applyFocus(ImageInterface $image, FileVersion $fileVersion, array $scale) { return $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($fileVersion, $scale) { return $this->focus->focus( $layer, $fileVersion->getFocusPointX(), $fileVersion->getFocusPointY(), $scale['x'], $scale['y'] ); } ); }
php
private function applyFocus(ImageInterface $image, FileVersion $fileVersion, array $scale) { return $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($fileVersion, $scale) { return $this->focus->focus( $layer, $fileVersion->getFocusPointX(), $fileVersion->getFocusPointY(), $scale['x'], $scale['y'] ); } ); }
[ "private", "function", "applyFocus", "(", "ImageInterface", "$", "image", ",", "FileVersion", "$", "fileVersion", ",", "array", "$", "scale", ")", "{", "return", "$", "this", "->", "modifyAllLayers", "(", "$", "image", ",", "function", "(", "ImageInterface", "$", "layer", ")", "use", "(", "$", "fileVersion", ",", "$", "scale", ")", "{", "return", "$", "this", "->", "focus", "->", "focus", "(", "$", "layer", ",", "$", "fileVersion", "->", "getFocusPointX", "(", ")", ",", "$", "fileVersion", "->", "getFocusPointY", "(", ")", ",", "$", "scale", "[", "'x'", "]", ",", "$", "scale", "[", "'y'", "]", ")", ";", "}", ")", ";", "}" ]
Crops the given image according to the focus point defined in the file version. @param ImageInterface $image @param FileVersion $fileVersion @param array $scale @return ImageInterface
[ "Crops", "the", "given", "image", "according", "to", "the", "focus", "point", "defined", "in", "the", "file", "version", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L222-L236
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.applyScale
private function applyScale(ImageInterface $image, $scale) { return $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($scale) { return $this->scaler->scale( $layer, $scale['x'], $scale['y'], $scale['mode'], $scale['forceRatio'], $scale['retina'] ); } ); }
php
private function applyScale(ImageInterface $image, $scale) { return $this->modifyAllLayers( $image, function(ImageInterface $layer) use ($scale) { return $this->scaler->scale( $layer, $scale['x'], $scale['y'], $scale['mode'], $scale['forceRatio'], $scale['retina'] ); } ); }
[ "private", "function", "applyScale", "(", "ImageInterface", "$", "image", ",", "$", "scale", ")", "{", "return", "$", "this", "->", "modifyAllLayers", "(", "$", "image", ",", "function", "(", "ImageInterface", "$", "layer", ")", "use", "(", "$", "scale", ")", "{", "return", "$", "this", "->", "scaler", "->", "scale", "(", "$", "layer", ",", "$", "scale", "[", "'x'", "]", ",", "$", "scale", "[", "'y'", "]", ",", "$", "scale", "[", "'mode'", "]", ",", "$", "scale", "[", "'forceRatio'", "]", ",", "$", "scale", "[", "'retina'", "]", ")", ";", "}", ")", ";", "}" ]
Scales a given image according to the information passed as the second argument. @param ImageInterface $image @param $scale @return ImageInterface
[ "Scales", "a", "given", "image", "according", "to", "the", "information", "passed", "as", "the", "second", "argument", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L246-L261
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.toRGB
private function toRGB(ImageInterface $image) { if ('cmyk' == $image->palette()->name()) { $image->usePalette(new RGB()); } return $image; }
php
private function toRGB(ImageInterface $image) { if ('cmyk' == $image->palette()->name()) { $image->usePalette(new RGB()); } return $image; }
[ "private", "function", "toRGB", "(", "ImageInterface", "$", "image", ")", "{", "if", "(", "'cmyk'", "==", "$", "image", "->", "palette", "(", ")", "->", "name", "(", ")", ")", "{", "$", "image", "->", "usePalette", "(", "new", "RGB", "(", ")", ")", ";", "}", "return", "$", "image", ";", "}" ]
Ensures that the color mode of the passed image is RGB. @param ImageInterface $image @return ImageInterface $image The modified image
[ "Ensures", "that", "the", "color", "mode", "of", "the", "passed", "image", "is", "RGB", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L270-L277
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.getCropParameters
private function getCropParameters(ImageInterface $image, $formatOptions, array $format) { if (isset($formatOptions)) { $parameters = [ 'x' => $formatOptions->getCropX(), 'y' => $formatOptions->getCropY(), 'width' => $formatOptions->getCropWidth(), 'height' => $formatOptions->getCropHeight(), ]; if ($this->cropper->isValid( $image, $parameters['x'], $parameters['y'], $parameters['width'], $parameters['height'], $format ) ) { return $parameters; } } return; }
php
private function getCropParameters(ImageInterface $image, $formatOptions, array $format) { if (isset($formatOptions)) { $parameters = [ 'x' => $formatOptions->getCropX(), 'y' => $formatOptions->getCropY(), 'width' => $formatOptions->getCropWidth(), 'height' => $formatOptions->getCropHeight(), ]; if ($this->cropper->isValid( $image, $parameters['x'], $parameters['y'], $parameters['width'], $parameters['height'], $format ) ) { return $parameters; } } return; }
[ "private", "function", "getCropParameters", "(", "ImageInterface", "$", "image", ",", "$", "formatOptions", ",", "array", "$", "format", ")", "{", "if", "(", "isset", "(", "$", "formatOptions", ")", ")", "{", "$", "parameters", "=", "[", "'x'", "=>", "$", "formatOptions", "->", "getCropX", "(", ")", ",", "'y'", "=>", "$", "formatOptions", "->", "getCropY", "(", ")", ",", "'width'", "=>", "$", "formatOptions", "->", "getCropWidth", "(", ")", ",", "'height'", "=>", "$", "formatOptions", "->", "getCropHeight", "(", ")", ",", "]", ";", "if", "(", "$", "this", "->", "cropper", "->", "isValid", "(", "$", "image", ",", "$", "parameters", "[", "'x'", "]", ",", "$", "parameters", "[", "'y'", "]", ",", "$", "parameters", "[", "'width'", "]", ",", "$", "parameters", "[", "'height'", "]", ",", "$", "format", ")", ")", "{", "return", "$", "parameters", ";", "}", "}", "return", ";", "}" ]
Constructs the parameters for the cropper. Returns null when the image should not be cropped. @param ImageInterface $image @param FormatOptions $formatOptions @param array $format @return array The crop parameters or null
[ "Constructs", "the", "parameters", "for", "the", "cropper", ".", "Returns", "null", "when", "the", "image", "should", "not", "be", "cropped", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L303-L327
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.modifyAllLayers
private function modifyAllLayers(ImageInterface $image, callable $modifier) { if (count($image->layers())) { $countLayer = 0; $image->layers()->coalesce(); /** @var ImageInterface $temporaryImage */ $temporaryImage = null; foreach ($image->layers() as $layer) { ++$countLayer; $layer = call_user_func($modifier, $layer); if (1 === $countLayer) { $temporaryImage = $layer; // use first layer as main image } else { $temporaryImage->layers()->add($layer); } } $image = $temporaryImage; } else { $image = call_user_func($modifier, $image); } return $image; }
php
private function modifyAllLayers(ImageInterface $image, callable $modifier) { if (count($image->layers())) { $countLayer = 0; $image->layers()->coalesce(); /** @var ImageInterface $temporaryImage */ $temporaryImage = null; foreach ($image->layers() as $layer) { ++$countLayer; $layer = call_user_func($modifier, $layer); if (1 === $countLayer) { $temporaryImage = $layer; // use first layer as main image } else { $temporaryImage->layers()->add($layer); } } $image = $temporaryImage; } else { $image = call_user_func($modifier, $image); } return $image; }
[ "private", "function", "modifyAllLayers", "(", "ImageInterface", "$", "image", ",", "callable", "$", "modifier", ")", "{", "if", "(", "count", "(", "$", "image", "->", "layers", "(", ")", ")", ")", "{", "$", "countLayer", "=", "0", ";", "$", "image", "->", "layers", "(", ")", "->", "coalesce", "(", ")", ";", "/** @var ImageInterface $temporaryImage */", "$", "temporaryImage", "=", "null", ";", "foreach", "(", "$", "image", "->", "layers", "(", ")", "as", "$", "layer", ")", "{", "++", "$", "countLayer", ";", "$", "layer", "=", "call_user_func", "(", "$", "modifier", ",", "$", "layer", ")", ";", "if", "(", "1", "===", "$", "countLayer", ")", "{", "$", "temporaryImage", "=", "$", "layer", ";", "// use first layer as main image", "}", "else", "{", "$", "temporaryImage", "->", "layers", "(", ")", "->", "add", "(", "$", "layer", ")", ";", "}", "}", "$", "image", "=", "$", "temporaryImage", ";", "}", "else", "{", "$", "image", "=", "call_user_func", "(", "$", "modifier", ",", "$", "image", ")", ";", "}", "return", "$", "image", ";", "}" ]
Applies a callback to every layer of an image and returns the resulting image. @param ImageInterface $image @param callable $modifier The callable to apply to all layers @return ImageInterface
[ "Applies", "a", "callback", "to", "every", "layer", "of", "an", "image", "and", "returns", "the", "resulting", "image", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L337-L360
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php
ImagineImageConverter.getFormat
private function getFormat($formatKey) { if (!isset($this->formats[$formatKey])) { throw new ImageProxyInvalidImageFormat('Format was not found'); } return $this->formats[$formatKey]; }
php
private function getFormat($formatKey) { if (!isset($this->formats[$formatKey])) { throw new ImageProxyInvalidImageFormat('Format was not found'); } return $this->formats[$formatKey]; }
[ "private", "function", "getFormat", "(", "$", "formatKey", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "formats", "[", "$", "formatKey", "]", ")", ")", "{", "throw", "new", "ImageProxyInvalidImageFormat", "(", "'Format was not found'", ")", ";", "}", "return", "$", "this", "->", "formats", "[", "$", "formatKey", "]", ";", "}" ]
Return the options for the given format. @param $formatKey @return array @throws ImageProxyInvalidImageFormat
[ "Return", "the", "options", "for", "the", "given", "format", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/ImagineImageConverter.php#L371-L378
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Entity/AnalyticsRepository.php
AnalyticsRepository.findByWebspaceKey
public function findByWebspaceKey($webspaceKey) { $queryBuilder = $this->createQueryBuilder('a') ->addSelect('domains') ->leftJoin('a.domains', 'domains') ->where('a.webspaceKey = :webspaceKey') ->andWhere('a.allDomains = TRUE OR domains.environment = :environment') ->orderBy('a.id', 'ASC'); $query = $queryBuilder->getQuery(); $query->setParameter('webspaceKey', $webspaceKey); $query->setParameter('environment', $this->environment); return $query->getResult(); }
php
public function findByWebspaceKey($webspaceKey) { $queryBuilder = $this->createQueryBuilder('a') ->addSelect('domains') ->leftJoin('a.domains', 'domains') ->where('a.webspaceKey = :webspaceKey') ->andWhere('a.allDomains = TRUE OR domains.environment = :environment') ->orderBy('a.id', 'ASC'); $query = $queryBuilder->getQuery(); $query->setParameter('webspaceKey', $webspaceKey); $query->setParameter('environment', $this->environment); return $query->getResult(); }
[ "public", "function", "findByWebspaceKey", "(", "$", "webspaceKey", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'a'", ")", "->", "addSelect", "(", "'domains'", ")", "->", "leftJoin", "(", "'a.domains'", ",", "'domains'", ")", "->", "where", "(", "'a.webspaceKey = :webspaceKey'", ")", "->", "andWhere", "(", "'a.allDomains = TRUE OR domains.environment = :environment'", ")", "->", "orderBy", "(", "'a.id'", ",", "'ASC'", ")", ";", "$", "query", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'webspaceKey'", ",", "$", "webspaceKey", ")", ";", "$", "query", "->", "setParameter", "(", "'environment'", ",", "$", "this", "->", "environment", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Returns list of analytics filterd by webspace key and environment. @param string $webspaceKey @return Analytics[]
[ "Returns", "list", "of", "analytics", "filterd", "by", "webspace", "key", "and", "environment", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Entity/AnalyticsRepository.php#L41-L55
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Entity/AnalyticsRepository.php
AnalyticsRepository.findById
public function findById($id) { $queryBuilder = $this->createQueryBuilder('a') ->addSelect('domains') ->leftJoin('a.domains', 'domains') ->where('a.id = :id'); $query = $queryBuilder->getQuery(); $query->setParameter('id', $id); return $query->getSingleResult(); }
php
public function findById($id) { $queryBuilder = $this->createQueryBuilder('a') ->addSelect('domains') ->leftJoin('a.domains', 'domains') ->where('a.id = :id'); $query = $queryBuilder->getQuery(); $query->setParameter('id', $id); return $query->getSingleResult(); }
[ "public", "function", "findById", "(", "$", "id", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'a'", ")", "->", "addSelect", "(", "'domains'", ")", "->", "leftJoin", "(", "'a.domains'", ",", "'domains'", ")", "->", "where", "(", "'a.id = :id'", ")", ";", "$", "query", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'id'", ",", "$", "id", ")", ";", "return", "$", "query", "->", "getSingleResult", "(", ")", ";", "}" ]
Returns analytics by id. @param int $id @return Analytics
[ "Returns", "analytics", "by", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Entity/AnalyticsRepository.php#L64-L75
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Serializer/Subscriber/WorkflowStageSubscriber.php
WorkflowStageSubscriber.onPostSerialize
public function onPostSerialize(ObjectEvent $event) { /** @var RedirectTypeBehavior $document */ $document = $event->getObject(); if (!$document instanceof WorkflowStageBehavior) { return; } $visitor = $event->getVisitor(); $visitor->addData('publishedState', WorkflowStage::PUBLISHED === $document->getWorkflowStage()); }
php
public function onPostSerialize(ObjectEvent $event) { /** @var RedirectTypeBehavior $document */ $document = $event->getObject(); if (!$document instanceof WorkflowStageBehavior) { return; } $visitor = $event->getVisitor(); $visitor->addData('publishedState', WorkflowStage::PUBLISHED === $document->getWorkflowStage()); }
[ "public", "function", "onPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "/** @var RedirectTypeBehavior $document */", "$", "document", "=", "$", "event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "WorkflowStageBehavior", ")", "{", "return", ";", "}", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "visitor", "->", "addData", "(", "'publishedState'", ",", "WorkflowStage", "::", "PUBLISHED", "===", "$", "document", "->", "getWorkflowStage", "(", ")", ")", ";", "}" ]
Adds the published state to the serialization. @param ObjectEvent $event
[ "Adds", "the", "published", "state", "to", "the", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Serializer/Subscriber/WorkflowStageSubscriber.php#L45-L56
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Teaser/Teaser.php
Teaser.merge
public function merge(array $item) { $this->title = $this->getValue('title', $item, $this->getTitle()); $this->description = $this->getValue('description', $item, $this->getDescription()); $this->moreText = $this->getValue('moreText', $item, $this->getMoreText()); $this->url = $this->getValue('url', $item, $this->getUrl()); $this->mediaId = $this->getValue('mediaId', $item, $this->getMediaId()); return $this; }
php
public function merge(array $item) { $this->title = $this->getValue('title', $item, $this->getTitle()); $this->description = $this->getValue('description', $item, $this->getDescription()); $this->moreText = $this->getValue('moreText', $item, $this->getMoreText()); $this->url = $this->getValue('url', $item, $this->getUrl()); $this->mediaId = $this->getValue('mediaId', $item, $this->getMediaId()); return $this; }
[ "public", "function", "merge", "(", "array", "$", "item", ")", "{", "$", "this", "->", "title", "=", "$", "this", "->", "getValue", "(", "'title'", ",", "$", "item", ",", "$", "this", "->", "getTitle", "(", ")", ")", ";", "$", "this", "->", "description", "=", "$", "this", "->", "getValue", "(", "'description'", ",", "$", "item", ",", "$", "this", "->", "getDescription", "(", ")", ")", ";", "$", "this", "->", "moreText", "=", "$", "this", "->", "getValue", "(", "'moreText'", ",", "$", "item", ",", "$", "this", "->", "getMoreText", "(", ")", ")", ";", "$", "this", "->", "url", "=", "$", "this", "->", "getValue", "(", "'url'", ",", "$", "item", ",", "$", "this", "->", "getUrl", "(", ")", ")", ";", "$", "this", "->", "mediaId", "=", "$", "this", "->", "getValue", "(", "'mediaId'", ",", "$", "item", ",", "$", "this", "->", "getMediaId", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Merges given data with this teaser. @param array $item @return Teaser
[ "Merges", "given", "data", "with", "this", "teaser", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Teaser/Teaser.php#L185-L194
train
sulu/sulu
src/Sulu/Component/Content/Repository/Serializer/SerializerEventListener.php
SerializerEventListener.onPostSerialize
public function onPostSerialize(ObjectEvent $event) { /** @var Content $content */ $content = $event->getObject(); /** @var JsonSerializationVisitor $visitor */ $visitor = $event->getVisitor(); if (!($content instanceof Content)) { return; } foreach ($content->getData() as $key => $value) { $visitor->setData($key, $value); } $visitor->setData('publishedState', (WorkflowStage::PUBLISHED === $content->getWorkflowStage())); if (RedirectType::EXTERNAL === $content->getNodeType()) { $visitor->setData('linked', 'external'); } elseif (RedirectType::INTERNAL === $content->getNodeType()) { $visitor->setData('linked', 'internal'); } if (null !== $content->getLocalizationType()) { $visitor->setData('type', $content->getLocalizationType()->toArray()); } $visitor->setData( '_permissions', $this->accessControlManager->getUserPermissionByArray( $content->getLocale(), PageAdmin::SECURITY_CONTEXT_PREFIX . $content->getWebspaceKey(), $content->getPermissions(), $this->tokenStorage->getToken()->getUser() ) ); }
php
public function onPostSerialize(ObjectEvent $event) { /** @var Content $content */ $content = $event->getObject(); /** @var JsonSerializationVisitor $visitor */ $visitor = $event->getVisitor(); if (!($content instanceof Content)) { return; } foreach ($content->getData() as $key => $value) { $visitor->setData($key, $value); } $visitor->setData('publishedState', (WorkflowStage::PUBLISHED === $content->getWorkflowStage())); if (RedirectType::EXTERNAL === $content->getNodeType()) { $visitor->setData('linked', 'external'); } elseif (RedirectType::INTERNAL === $content->getNodeType()) { $visitor->setData('linked', 'internal'); } if (null !== $content->getLocalizationType()) { $visitor->setData('type', $content->getLocalizationType()->toArray()); } $visitor->setData( '_permissions', $this->accessControlManager->getUserPermissionByArray( $content->getLocale(), PageAdmin::SECURITY_CONTEXT_PREFIX . $content->getWebspaceKey(), $content->getPermissions(), $this->tokenStorage->getToken()->getUser() ) ); }
[ "public", "function", "onPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "/** @var Content $content */", "$", "content", "=", "$", "event", "->", "getObject", "(", ")", ";", "/** @var JsonSerializationVisitor $visitor */", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "if", "(", "!", "(", "$", "content", "instanceof", "Content", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "content", "->", "getData", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "visitor", "->", "setData", "(", "$", "key", ",", "$", "value", ")", ";", "}", "$", "visitor", "->", "setData", "(", "'publishedState'", ",", "(", "WorkflowStage", "::", "PUBLISHED", "===", "$", "content", "->", "getWorkflowStage", "(", ")", ")", ")", ";", "if", "(", "RedirectType", "::", "EXTERNAL", "===", "$", "content", "->", "getNodeType", "(", ")", ")", "{", "$", "visitor", "->", "setData", "(", "'linked'", ",", "'external'", ")", ";", "}", "elseif", "(", "RedirectType", "::", "INTERNAL", "===", "$", "content", "->", "getNodeType", "(", ")", ")", "{", "$", "visitor", "->", "setData", "(", "'linked'", ",", "'internal'", ")", ";", "}", "if", "(", "null", "!==", "$", "content", "->", "getLocalizationType", "(", ")", ")", "{", "$", "visitor", "->", "setData", "(", "'type'", ",", "$", "content", "->", "getLocalizationType", "(", ")", "->", "toArray", "(", ")", ")", ";", "}", "$", "visitor", "->", "setData", "(", "'_permissions'", ",", "$", "this", "->", "accessControlManager", "->", "getUserPermissionByArray", "(", "$", "content", "->", "getLocale", "(", ")", ",", "PageAdmin", "::", "SECURITY_CONTEXT_PREFIX", ".", "$", "content", "->", "getWebspaceKey", "(", ")", ",", "$", "content", "->", "getPermissions", "(", ")", ",", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ")", ")", ";", "}" ]
Add data for serialization of content objects. @param ObjectEvent $event
[ "Add", "data", "for", "serialization", "of", "content", "objects", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/Serializer/SerializerEventListener.php#L67-L103
train
sulu/sulu
src/Sulu/Component/Localization/Provider/LocalizationProvider.php
LocalizationProvider.parse
private function parse($locale) { $parts = explode('_', $locale); $localization = new Localization(); $localization->setLanguage($parts[0]); if (count($parts) > 1) { $localization->setCountry($parts[1]); } return $localization; }
php
private function parse($locale) { $parts = explode('_', $locale); $localization = new Localization(); $localization->setLanguage($parts[0]); if (count($parts) > 1) { $localization->setCountry($parts[1]); } return $localization; }
[ "private", "function", "parse", "(", "$", "locale", ")", "{", "$", "parts", "=", "explode", "(", "'_'", ",", "$", "locale", ")", ";", "$", "localization", "=", "new", "Localization", "(", ")", ";", "$", "localization", "->", "setLanguage", "(", "$", "parts", "[", "0", "]", ")", ";", "if", "(", "count", "(", "$", "parts", ")", ">", "1", ")", "{", "$", "localization", "->", "setCountry", "(", "$", "parts", "[", "1", "]", ")", ";", "}", "return", "$", "localization", ";", "}" ]
Converts locale string to localization object. @param string $locale E.g. de_at or de @return Localization
[ "Converts", "locale", "string", "to", "localization", "object", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Localization/Provider/LocalizationProvider.php#L54-L65
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.generateTreeByPath
private function generateTreeByPath(array $contents, $uuid) { $childrenByPath = []; foreach ($contents as $content) { $path = PathHelper::getParentPath($content->getPath()); if (!isset($childrenByPath[$path])) { $childrenByPath[$path] = []; } $order = $content['order']; while (isset($childrenByPath[$path][$order])) { ++$order; } $childrenByPath[$path][$order] = $content; } foreach ($contents as $content) { if (!isset($childrenByPath[$content->getPath()])) { if ($content->getId() === $uuid) { $content->setChildren([]); } continue; } ksort($childrenByPath[$content->getPath()]); $content->setChildren(array_values($childrenByPath[$content->getPath()])); } if (!array_key_exists('/', $childrenByPath) || !is_array($childrenByPath['/'])) { return []; } ksort($childrenByPath['/']); return array_values($childrenByPath['/']); }
php
private function generateTreeByPath(array $contents, $uuid) { $childrenByPath = []; foreach ($contents as $content) { $path = PathHelper::getParentPath($content->getPath()); if (!isset($childrenByPath[$path])) { $childrenByPath[$path] = []; } $order = $content['order']; while (isset($childrenByPath[$path][$order])) { ++$order; } $childrenByPath[$path][$order] = $content; } foreach ($contents as $content) { if (!isset($childrenByPath[$content->getPath()])) { if ($content->getId() === $uuid) { $content->setChildren([]); } continue; } ksort($childrenByPath[$content->getPath()]); $content->setChildren(array_values($childrenByPath[$content->getPath()])); } if (!array_key_exists('/', $childrenByPath) || !is_array($childrenByPath['/'])) { return []; } ksort($childrenByPath['/']); return array_values($childrenByPath['/']); }
[ "private", "function", "generateTreeByPath", "(", "array", "$", "contents", ",", "$", "uuid", ")", "{", "$", "childrenByPath", "=", "[", "]", ";", "foreach", "(", "$", "contents", "as", "$", "content", ")", "{", "$", "path", "=", "PathHelper", "::", "getParentPath", "(", "$", "content", "->", "getPath", "(", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "childrenByPath", "[", "$", "path", "]", ")", ")", "{", "$", "childrenByPath", "[", "$", "path", "]", "=", "[", "]", ";", "}", "$", "order", "=", "$", "content", "[", "'order'", "]", ";", "while", "(", "isset", "(", "$", "childrenByPath", "[", "$", "path", "]", "[", "$", "order", "]", ")", ")", "{", "++", "$", "order", ";", "}", "$", "childrenByPath", "[", "$", "path", "]", "[", "$", "order", "]", "=", "$", "content", ";", "}", "foreach", "(", "$", "contents", "as", "$", "content", ")", "{", "if", "(", "!", "isset", "(", "$", "childrenByPath", "[", "$", "content", "->", "getPath", "(", ")", "]", ")", ")", "{", "if", "(", "$", "content", "->", "getId", "(", ")", "===", "$", "uuid", ")", "{", "$", "content", "->", "setChildren", "(", "[", "]", ")", ";", "}", "continue", ";", "}", "ksort", "(", "$", "childrenByPath", "[", "$", "content", "->", "getPath", "(", ")", "]", ")", ";", "$", "content", "->", "setChildren", "(", "array_values", "(", "$", "childrenByPath", "[", "$", "content", "->", "getPath", "(", ")", "]", ")", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'/'", ",", "$", "childrenByPath", ")", "||", "!", "is_array", "(", "$", "childrenByPath", "[", "'/'", "]", ")", ")", "{", "return", "[", "]", ";", "}", "ksort", "(", "$", "childrenByPath", "[", "'/'", "]", ")", ";", "return", "array_values", "(", "$", "childrenByPath", "[", "'/'", "]", ")", ";", "}" ]
Generates a content-tree with paths of given content array. @param Content[] $contents @return Content[]
[ "Generates", "a", "content", "-", "tree", "with", "paths", "of", "given", "content", "array", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L309-L348
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolvePathByUuid
private function resolvePathByUuid($uuid) { $queryBuilder = new QueryBuilder($this->qomFactory); $queryBuilder ->select('node', 'jcr:uuid', 'uuid') ->from($this->qomFactory->selector('node', 'nt:unstructured')) ->where( $this->qomFactory->comparison( $this->qomFactory->propertyValue('node', 'jcr:uuid'), '=', $this->qomFactory->literal($uuid) ) ); $rows = $queryBuilder->execute(); if (1 !== count(iterator_to_array($rows->getRows()))) { throw new ItemNotFoundException(); } return $rows->getRows()->current()->getPath(); }
php
private function resolvePathByUuid($uuid) { $queryBuilder = new QueryBuilder($this->qomFactory); $queryBuilder ->select('node', 'jcr:uuid', 'uuid') ->from($this->qomFactory->selector('node', 'nt:unstructured')) ->where( $this->qomFactory->comparison( $this->qomFactory->propertyValue('node', 'jcr:uuid'), '=', $this->qomFactory->literal($uuid) ) ); $rows = $queryBuilder->execute(); if (1 !== count(iterator_to_array($rows->getRows()))) { throw new ItemNotFoundException(); } return $rows->getRows()->current()->getPath(); }
[ "private", "function", "resolvePathByUuid", "(", "$", "uuid", ")", "{", "$", "queryBuilder", "=", "new", "QueryBuilder", "(", "$", "this", "->", "qomFactory", ")", ";", "$", "queryBuilder", "->", "select", "(", "'node'", ",", "'jcr:uuid'", ",", "'uuid'", ")", "->", "from", "(", "$", "this", "->", "qomFactory", "->", "selector", "(", "'node'", ",", "'nt:unstructured'", ")", ")", "->", "where", "(", "$", "this", "->", "qomFactory", "->", "comparison", "(", "$", "this", "->", "qomFactory", "->", "propertyValue", "(", "'node'", ",", "'jcr:uuid'", ")", ",", "'='", ",", "$", "this", "->", "qomFactory", "->", "literal", "(", "$", "uuid", ")", ")", ")", ";", "$", "rows", "=", "$", "queryBuilder", "->", "execute", "(", ")", ";", "if", "(", "1", "!==", "count", "(", "iterator_to_array", "(", "$", "rows", "->", "getRows", "(", ")", ")", ")", ")", "{", "throw", "new", "ItemNotFoundException", "(", ")", ";", "}", "return", "$", "rows", "->", "getRows", "(", ")", "->", "current", "(", ")", "->", "getPath", "(", ")", ";", "}" ]
Resolve path for node with given uuid. @param string $uuid @return string @throws ItemNotFoundException
[ "Resolve", "path", "for", "node", "with", "given", "uuid", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L359-L381
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolveQueryBuilder
private function resolveQueryBuilder( QueryBuilder $queryBuilder, $locale, $locales, MappingInterface $mapping, UserInterface $user = null ) { return array_values( array_filter( array_map( function(Row $row) use ($mapping, $locale, $locales, $user) { return $this->resolveContent($row, $locale, $locales, $mapping, $user); }, iterator_to_array($queryBuilder->execute()) ) ) ); }
php
private function resolveQueryBuilder( QueryBuilder $queryBuilder, $locale, $locales, MappingInterface $mapping, UserInterface $user = null ) { return array_values( array_filter( array_map( function(Row $row) use ($mapping, $locale, $locales, $user) { return $this->resolveContent($row, $locale, $locales, $mapping, $user); }, iterator_to_array($queryBuilder->execute()) ) ) ); }
[ "private", "function", "resolveQueryBuilder", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "locale", ",", "$", "locales", ",", "MappingInterface", "$", "mapping", ",", "UserInterface", "$", "user", "=", "null", ")", "{", "return", "array_values", "(", "array_filter", "(", "array_map", "(", "function", "(", "Row", "$", "row", ")", "use", "(", "$", "mapping", ",", "$", "locale", ",", "$", "locales", ",", "$", "user", ")", "{", "return", "$", "this", "->", "resolveContent", "(", "$", "row", ",", "$", "locale", ",", "$", "locales", ",", "$", "mapping", ",", "$", "user", ")", ";", "}", ",", "iterator_to_array", "(", "$", "queryBuilder", "->", "execute", "(", ")", ")", ")", ")", ")", ";", "}" ]
Resolves query results to content. @param QueryBuilder $queryBuilder @param string $locale @param MappingInterface $mapping @param UserInterface $user @return Content[]
[ "Resolves", "query", "results", "to", "content", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L393-L410
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.getQueryBuilder
private function getQueryBuilder($locale, $locales, UserInterface $user = null) { $queryBuilder = new QueryBuilder($this->qomFactory); $queryBuilder ->select('node', 'jcr:uuid', 'uuid') ->addSelect('node', $this->getPropertyName('nodeType', $locale), 'nodeType') ->addSelect('node', $this->getPropertyName('internal_link', $locale), 'internalLink') ->addSelect('node', $this->getPropertyName('state', $locale), 'state') ->addSelect('node', $this->getPropertyName('shadow-on', $locale), 'shadowOn') ->addSelect('node', $this->getPropertyName('shadow-base', $locale), 'shadowBase') ->addSelect('node', $this->propertyEncoder->systemName('order'), 'order') ->from($this->qomFactory->selector('node', 'nt:unstructured')) ->orderBy($this->qomFactory->propertyValue('node', 'sulu:order')); $this->appendSingleMapping($queryBuilder, 'template', $locales); $this->appendSingleMapping($queryBuilder, 'shadow-on', $locales); $this->appendSingleMapping($queryBuilder, 'state', $locales); if (null !== $user) { foreach ($user->getRoleObjects() as $role) { $queryBuilder->addSelect( 'node', sprintf('sec:%s', 'role-' . $role->getId()), sprintf('role%s', $role->getId()) ); } } return $queryBuilder; }
php
private function getQueryBuilder($locale, $locales, UserInterface $user = null) { $queryBuilder = new QueryBuilder($this->qomFactory); $queryBuilder ->select('node', 'jcr:uuid', 'uuid') ->addSelect('node', $this->getPropertyName('nodeType', $locale), 'nodeType') ->addSelect('node', $this->getPropertyName('internal_link', $locale), 'internalLink') ->addSelect('node', $this->getPropertyName('state', $locale), 'state') ->addSelect('node', $this->getPropertyName('shadow-on', $locale), 'shadowOn') ->addSelect('node', $this->getPropertyName('shadow-base', $locale), 'shadowBase') ->addSelect('node', $this->propertyEncoder->systemName('order'), 'order') ->from($this->qomFactory->selector('node', 'nt:unstructured')) ->orderBy($this->qomFactory->propertyValue('node', 'sulu:order')); $this->appendSingleMapping($queryBuilder, 'template', $locales); $this->appendSingleMapping($queryBuilder, 'shadow-on', $locales); $this->appendSingleMapping($queryBuilder, 'state', $locales); if (null !== $user) { foreach ($user->getRoleObjects() as $role) { $queryBuilder->addSelect( 'node', sprintf('sec:%s', 'role-' . $role->getId()), sprintf('role%s', $role->getId()) ); } } return $queryBuilder; }
[ "private", "function", "getQueryBuilder", "(", "$", "locale", ",", "$", "locales", ",", "UserInterface", "$", "user", "=", "null", ")", "{", "$", "queryBuilder", "=", "new", "QueryBuilder", "(", "$", "this", "->", "qomFactory", ")", ";", "$", "queryBuilder", "->", "select", "(", "'node'", ",", "'jcr:uuid'", ",", "'uuid'", ")", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "getPropertyName", "(", "'nodeType'", ",", "$", "locale", ")", ",", "'nodeType'", ")", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "getPropertyName", "(", "'internal_link'", ",", "$", "locale", ")", ",", "'internalLink'", ")", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "getPropertyName", "(", "'state'", ",", "$", "locale", ")", ",", "'state'", ")", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "getPropertyName", "(", "'shadow-on'", ",", "$", "locale", ")", ",", "'shadowOn'", ")", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "getPropertyName", "(", "'shadow-base'", ",", "$", "locale", ")", ",", "'shadowBase'", ")", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "propertyEncoder", "->", "systemName", "(", "'order'", ")", ",", "'order'", ")", "->", "from", "(", "$", "this", "->", "qomFactory", "->", "selector", "(", "'node'", ",", "'nt:unstructured'", ")", ")", "->", "orderBy", "(", "$", "this", "->", "qomFactory", "->", "propertyValue", "(", "'node'", ",", "'sulu:order'", ")", ")", ";", "$", "this", "->", "appendSingleMapping", "(", "$", "queryBuilder", ",", "'template'", ",", "$", "locales", ")", ";", "$", "this", "->", "appendSingleMapping", "(", "$", "queryBuilder", ",", "'shadow-on'", ",", "$", "locales", ")", ";", "$", "this", "->", "appendSingleMapping", "(", "$", "queryBuilder", ",", "'state'", ",", "$", "locales", ")", ";", "if", "(", "null", "!==", "$", "user", ")", "{", "foreach", "(", "$", "user", "->", "getRoleObjects", "(", ")", "as", "$", "role", ")", "{", "$", "queryBuilder", "->", "addSelect", "(", "'node'", ",", "sprintf", "(", "'sec:%s'", ",", "'role-'", ".", "$", "role", "->", "getId", "(", ")", ")", ",", "sprintf", "(", "'role%s'", ",", "$", "role", "->", "getId", "(", ")", ")", ")", ";", "}", "}", "return", "$", "queryBuilder", ";", "}" ]
Returns QueryBuilder with basic select and where statements. @param string $locale @param string[] $locales @param UserInterface $user @return QueryBuilder
[ "Returns", "QueryBuilder", "with", "basic", "select", "and", "where", "statements", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L421-L451
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.getLocalesByWebspaceKey
private function getLocalesByWebspaceKey($webspaceKey) { $webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey); return array_map( function(Localization $localization) { return $localization->getLocale(); }, $webspace->getAllLocalizations() ); }
php
private function getLocalesByWebspaceKey($webspaceKey) { $webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey); return array_map( function(Localization $localization) { return $localization->getLocale(); }, $webspace->getAllLocalizations() ); }
[ "private", "function", "getLocalesByWebspaceKey", "(", "$", "webspaceKey", ")", "{", "$", "webspace", "=", "$", "this", "->", "webspaceManager", "->", "findWebspaceByKey", "(", "$", "webspaceKey", ")", ";", "return", "array_map", "(", "function", "(", "Localization", "$", "localization", ")", "{", "return", "$", "localization", "->", "getLocale", "(", ")", ";", "}", ",", "$", "webspace", "->", "getAllLocalizations", "(", ")", ")", ";", "}" ]
Returns array of locales for given webspace key. @param string $webspaceKey @return string[]
[ "Returns", "array", "of", "locales", "for", "given", "webspace", "key", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L469-L479
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.getLocalesByPortalKey
private function getLocalesByPortalKey($portalKey) { $portal = $this->webspaceManager->findPortalByKey($portalKey); return array_map( function(Localization $localization) { return $localization->getLocale(); }, $portal->getLocalizations() ); }
php
private function getLocalesByPortalKey($portalKey) { $portal = $this->webspaceManager->findPortalByKey($portalKey); return array_map( function(Localization $localization) { return $localization->getLocale(); }, $portal->getLocalizations() ); }
[ "private", "function", "getLocalesByPortalKey", "(", "$", "portalKey", ")", "{", "$", "portal", "=", "$", "this", "->", "webspaceManager", "->", "findPortalByKey", "(", "$", "portalKey", ")", ";", "return", "array_map", "(", "function", "(", "Localization", "$", "localization", ")", "{", "return", "$", "localization", "->", "getLocale", "(", ")", ";", "}", ",", "$", "portal", "->", "getLocalizations", "(", ")", ")", ";", "}" ]
Returns array of locales for given portal key. @param string $portalKey @return string[]
[ "Returns", "array", "of", "locales", "for", "given", "portal", "key", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L488-L498
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.appendMapping
private function appendMapping(QueryBuilder $queryBuilder, MappingInterface $mapping, $locale, $locales) { if ($mapping->onlyPublished()) { $queryBuilder->andWhere( $this->qomFactory->comparison( $this->qomFactory->propertyValue( 'node', $this->propertyEncoder->localizedSystemName('state', $locale) ), '=', $this->qomFactory->literal(WorkflowStage::PUBLISHED) ) ); } $properties = $mapping->getProperties(); foreach ($properties as $propertyName) { $this->appendSingleMapping($queryBuilder, $propertyName, $locales); } if ($mapping->resolveUrl()) { $this->appendUrlMapping($queryBuilder, $locales); } }
php
private function appendMapping(QueryBuilder $queryBuilder, MappingInterface $mapping, $locale, $locales) { if ($mapping->onlyPublished()) { $queryBuilder->andWhere( $this->qomFactory->comparison( $this->qomFactory->propertyValue( 'node', $this->propertyEncoder->localizedSystemName('state', $locale) ), '=', $this->qomFactory->literal(WorkflowStage::PUBLISHED) ) ); } $properties = $mapping->getProperties(); foreach ($properties as $propertyName) { $this->appendSingleMapping($queryBuilder, $propertyName, $locales); } if ($mapping->resolveUrl()) { $this->appendUrlMapping($queryBuilder, $locales); } }
[ "private", "function", "appendMapping", "(", "QueryBuilder", "$", "queryBuilder", ",", "MappingInterface", "$", "mapping", ",", "$", "locale", ",", "$", "locales", ")", "{", "if", "(", "$", "mapping", "->", "onlyPublished", "(", ")", ")", "{", "$", "queryBuilder", "->", "andWhere", "(", "$", "this", "->", "qomFactory", "->", "comparison", "(", "$", "this", "->", "qomFactory", "->", "propertyValue", "(", "'node'", ",", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "'state'", ",", "$", "locale", ")", ")", ",", "'='", ",", "$", "this", "->", "qomFactory", "->", "literal", "(", "WorkflowStage", "::", "PUBLISHED", ")", ")", ")", ";", "}", "$", "properties", "=", "$", "mapping", "->", "getProperties", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "propertyName", ")", "{", "$", "this", "->", "appendSingleMapping", "(", "$", "queryBuilder", ",", "$", "propertyName", ",", "$", "locales", ")", ";", "}", "if", "(", "$", "mapping", "->", "resolveUrl", "(", ")", ")", "{", "$", "this", "->", "appendUrlMapping", "(", "$", "queryBuilder", ",", "$", "locales", ")", ";", "}", "}" ]
Append mapping selects to given query-builder. @param QueryBuilder $queryBuilder @param MappingInterface $mapping Includes array of property names @param string $locale @param string[] $locales
[ "Append", "mapping", "selects", "to", "given", "query", "-", "builder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L523-L546
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.appendSingleMapping
private function appendSingleMapping(QueryBuilder $queryBuilder, $propertyName, $locales) { foreach ($locales as $locale) { $alias = sprintf('%s%s', $locale, str_replace('-', '_', ucfirst($propertyName))); $queryBuilder->addSelect( 'node', $this->propertyEncoder->localizedContentName($propertyName, $locale), $alias ); } }
php
private function appendSingleMapping(QueryBuilder $queryBuilder, $propertyName, $locales) { foreach ($locales as $locale) { $alias = sprintf('%s%s', $locale, str_replace('-', '_', ucfirst($propertyName))); $queryBuilder->addSelect( 'node', $this->propertyEncoder->localizedContentName($propertyName, $locale), $alias ); } }
[ "private", "function", "appendSingleMapping", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "propertyName", ",", "$", "locales", ")", "{", "foreach", "(", "$", "locales", "as", "$", "locale", ")", "{", "$", "alias", "=", "sprintf", "(", "'%s%s'", ",", "$", "locale", ",", "str_replace", "(", "'-'", ",", "'_'", ",", "ucfirst", "(", "$", "propertyName", ")", ")", ")", ";", "$", "queryBuilder", "->", "addSelect", "(", "'node'", ",", "$", "this", "->", "propertyEncoder", "->", "localizedContentName", "(", "$", "propertyName", ",", "$", "locale", ")", ",", "$", "alias", ")", ";", "}", "}" ]
Append mapping selects for a single property to given query-builder. @param QueryBuilder $queryBuilder @param string $propertyName @param string[] $locales
[ "Append", "mapping", "selects", "for", "a", "single", "property", "to", "given", "query", "-", "builder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L555-L566
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.appendUrlMapping
private function appendUrlMapping(QueryBuilder $queryBuilder, $locales) { $structures = $this->structureManager->getStructures(Structure::TYPE_PAGE); $urlNames = []; foreach ($structures as $structure) { if (!$structure->hasTag('sulu.rlp')) { continue; } $propertyName = $structure->getPropertyByTagName('sulu.rlp')->getName(); if (!in_array($propertyName, $urlNames)) { $this->appendSingleMapping($queryBuilder, $propertyName, $locales); $urlNames[] = $propertyName; } } }
php
private function appendUrlMapping(QueryBuilder $queryBuilder, $locales) { $structures = $this->structureManager->getStructures(Structure::TYPE_PAGE); $urlNames = []; foreach ($structures as $structure) { if (!$structure->hasTag('sulu.rlp')) { continue; } $propertyName = $structure->getPropertyByTagName('sulu.rlp')->getName(); if (!in_array($propertyName, $urlNames)) { $this->appendSingleMapping($queryBuilder, $propertyName, $locales); $urlNames[] = $propertyName; } } }
[ "private", "function", "appendUrlMapping", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "locales", ")", "{", "$", "structures", "=", "$", "this", "->", "structureManager", "->", "getStructures", "(", "Structure", "::", "TYPE_PAGE", ")", ";", "$", "urlNames", "=", "[", "]", ";", "foreach", "(", "$", "structures", "as", "$", "structure", ")", "{", "if", "(", "!", "$", "structure", "->", "hasTag", "(", "'sulu.rlp'", ")", ")", "{", "continue", ";", "}", "$", "propertyName", "=", "$", "structure", "->", "getPropertyByTagName", "(", "'sulu.rlp'", ")", "->", "getName", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "propertyName", ",", "$", "urlNames", ")", ")", "{", "$", "this", "->", "appendSingleMapping", "(", "$", "queryBuilder", ",", "$", "propertyName", ",", "$", "locales", ")", ";", "$", "urlNames", "[", "]", "=", "$", "propertyName", ";", "}", "}", "}" ]
Append mapping for url to given query-builder. @param QueryBuilder $queryBuilder @param string[] $locales
[ "Append", "mapping", "for", "url", "to", "given", "query", "-", "builder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L574-L591
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolveAvailableLocales
private function resolveAvailableLocales(Row $row) { $locales = []; foreach ($row->getValues() as $key => $value) { if (preg_match('/^node.([a-zA-Z_]*?)Template/', $key, $matches) && '' !== $value && !$row->getValue(sprintf('node.%sShadow_on', $matches[1])) ) { $locales[] = $matches[1]; } } return $locales; }
php
private function resolveAvailableLocales(Row $row) { $locales = []; foreach ($row->getValues() as $key => $value) { if (preg_match('/^node.([a-zA-Z_]*?)Template/', $key, $matches) && '' !== $value && !$row->getValue(sprintf('node.%sShadow_on', $matches[1])) ) { $locales[] = $matches[1]; } } return $locales; }
[ "private", "function", "resolveAvailableLocales", "(", "Row", "$", "row", ")", "{", "$", "locales", "=", "[", "]", ";", "foreach", "(", "$", "row", "->", "getValues", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "preg_match", "(", "'/^node.([a-zA-Z_]*?)Template/'", ",", "$", "key", ",", "$", "matches", ")", "&&", "''", "!==", "$", "value", "&&", "!", "$", "row", "->", "getValue", "(", "sprintf", "(", "'node.%sShadow_on'", ",", "$", "matches", "[", "1", "]", ")", ")", ")", "{", "$", "locales", "[", "]", "=", "$", "matches", "[", "1", "]", ";", "}", "}", "return", "$", "locales", ";", "}" ]
Resolves all available localizations for given row. @param Row $row @return string[]
[ "Resolves", "all", "available", "localizations", "for", "given", "row", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L705-L717
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolveInternalLinkContent
public function resolveInternalLinkContent( Row $row, $locale, $webspaceKey, MappingInterface $mapping, StructureType $type = null, UserInterface $user = null ) { $linkedContent = $this->find($row->getValue('internalLink'), $locale, $webspaceKey, $mapping); $data = $linkedContent->getData(); // properties which are in the intersection of the data and non // fallback properties should be handled on the original row. $properties = array_intersect(self::$nonFallbackProperties, array_keys($data)); foreach ($properties as $property) { $data[$property] = $this->resolveProperty($row, $property, $locale); } $content = new Content( $locale, $webspaceKey, $row->getValue('uuid'), $this->resolvePath($row, $webspaceKey), $row->getValue('state'), $row->getValue('nodeType'), $this->resolveHasChildren($row), $this->resolveProperty($row, 'template', $locale), $data, $this->resolvePermissions($row, $user), $type ); if (!$content->getTemplate() || !$this->structureManager->getStructure($content->getTemplate())) { $content->setBrokenTemplate(); } return $content; }
php
public function resolveInternalLinkContent( Row $row, $locale, $webspaceKey, MappingInterface $mapping, StructureType $type = null, UserInterface $user = null ) { $linkedContent = $this->find($row->getValue('internalLink'), $locale, $webspaceKey, $mapping); $data = $linkedContent->getData(); // properties which are in the intersection of the data and non // fallback properties should be handled on the original row. $properties = array_intersect(self::$nonFallbackProperties, array_keys($data)); foreach ($properties as $property) { $data[$property] = $this->resolveProperty($row, $property, $locale); } $content = new Content( $locale, $webspaceKey, $row->getValue('uuid'), $this->resolvePath($row, $webspaceKey), $row->getValue('state'), $row->getValue('nodeType'), $this->resolveHasChildren($row), $this->resolveProperty($row, 'template', $locale), $data, $this->resolvePermissions($row, $user), $type ); if (!$content->getTemplate() || !$this->structureManager->getStructure($content->getTemplate())) { $content->setBrokenTemplate(); } return $content; }
[ "public", "function", "resolveInternalLinkContent", "(", "Row", "$", "row", ",", "$", "locale", ",", "$", "webspaceKey", ",", "MappingInterface", "$", "mapping", ",", "StructureType", "$", "type", "=", "null", ",", "UserInterface", "$", "user", "=", "null", ")", "{", "$", "linkedContent", "=", "$", "this", "->", "find", "(", "$", "row", "->", "getValue", "(", "'internalLink'", ")", ",", "$", "locale", ",", "$", "webspaceKey", ",", "$", "mapping", ")", ";", "$", "data", "=", "$", "linkedContent", "->", "getData", "(", ")", ";", "// properties which are in the intersection of the data and non", "// fallback properties should be handled on the original row.", "$", "properties", "=", "array_intersect", "(", "self", "::", "$", "nonFallbackProperties", ",", "array_keys", "(", "$", "data", ")", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "data", "[", "$", "property", "]", "=", "$", "this", "->", "resolveProperty", "(", "$", "row", ",", "$", "property", ",", "$", "locale", ")", ";", "}", "$", "content", "=", "new", "Content", "(", "$", "locale", ",", "$", "webspaceKey", ",", "$", "row", "->", "getValue", "(", "'uuid'", ")", ",", "$", "this", "->", "resolvePath", "(", "$", "row", ",", "$", "webspaceKey", ")", ",", "$", "row", "->", "getValue", "(", "'state'", ")", ",", "$", "row", "->", "getValue", "(", "'nodeType'", ")", ",", "$", "this", "->", "resolveHasChildren", "(", "$", "row", ")", ",", "$", "this", "->", "resolveProperty", "(", "$", "row", ",", "'template'", ",", "$", "locale", ")", ",", "$", "data", ",", "$", "this", "->", "resolvePermissions", "(", "$", "row", ",", "$", "user", ")", ",", "$", "type", ")", ";", "if", "(", "!", "$", "content", "->", "getTemplate", "(", ")", "||", "!", "$", "this", "->", "structureManager", "->", "getStructure", "(", "$", "content", "->", "getTemplate", "(", ")", ")", ")", "{", "$", "content", "->", "setBrokenTemplate", "(", ")", ";", "}", "return", "$", "content", ";", "}" ]
Resolve a single result row which is an internal link to a content object. @param Row $row @param string $locale @param string $webspaceKey @param MappingInterface $mapping Includes array of property names @param StructureType $type @param UserInterface $user @return Content
[ "Resolve", "a", "single", "result", "row", "which", "is", "an", "internal", "link", "to", "a", "content", "object", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L731-L767
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolveProperty
private function resolveProperty(Row $row, $name, $locale, $shadowLocale = null) { if (array_key_exists(sprintf('node.%s', $name), $row->getValues())) { return $row->getValue($name); } if (null !== $shadowLocale && !in_array($name, self::$nonFallbackProperties)) { $locale = $shadowLocale; } $name = sprintf('%s%s', $locale, str_replace('-', '_', ucfirst($name))); try { return $row->getValue($name); } catch (ItemNotFoundException $e) { // the default value of a non existing property in jackalope is an empty string return ''; } }
php
private function resolveProperty(Row $row, $name, $locale, $shadowLocale = null) { if (array_key_exists(sprintf('node.%s', $name), $row->getValues())) { return $row->getValue($name); } if (null !== $shadowLocale && !in_array($name, self::$nonFallbackProperties)) { $locale = $shadowLocale; } $name = sprintf('%s%s', $locale, str_replace('-', '_', ucfirst($name))); try { return $row->getValue($name); } catch (ItemNotFoundException $e) { // the default value of a non existing property in jackalope is an empty string return ''; } }
[ "private", "function", "resolveProperty", "(", "Row", "$", "row", ",", "$", "name", ",", "$", "locale", ",", "$", "shadowLocale", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "sprintf", "(", "'node.%s'", ",", "$", "name", ")", ",", "$", "row", "->", "getValues", "(", ")", ")", ")", "{", "return", "$", "row", "->", "getValue", "(", "$", "name", ")", ";", "}", "if", "(", "null", "!==", "$", "shadowLocale", "&&", "!", "in_array", "(", "$", "name", ",", "self", "::", "$", "nonFallbackProperties", ")", ")", "{", "$", "locale", "=", "$", "shadowLocale", ";", "}", "$", "name", "=", "sprintf", "(", "'%s%s'", ",", "$", "locale", ",", "str_replace", "(", "'-'", ",", "'_'", ",", "ucfirst", "(", "$", "name", ")", ")", ")", ";", "try", "{", "return", "$", "row", "->", "getValue", "(", "$", "name", ")", ";", "}", "catch", "(", "ItemNotFoundException", "$", "e", ")", "{", "// the default value of a non existing property in jackalope is an empty string", "return", "''", ";", "}", "}" ]
Resolve a property and follow shadow locale if it has one. @param Row $row @param string $name @param string $locale @param string $shadowLocale @return mixed
[ "Resolve", "a", "property", "and", "follow", "shadow", "locale", "if", "it", "has", "one", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L779-L797
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolveUrl
private function resolveUrl(Row $row, $locale) { if (WorkflowStage::PUBLISHED !== $this->resolveProperty($row, $locale . 'State', $locale)) { return; } $template = $this->resolveProperty($row, 'template', $locale); if (empty($template)) { return; } $structure = $this->structureManager->getStructure($template); if (!$structure || !$structure->hasTag('sulu.rlp')) { return; } $propertyName = $structure->getPropertyByTagName('sulu.rlp')->getName(); return $this->resolveProperty($row, $propertyName, $locale); }
php
private function resolveUrl(Row $row, $locale) { if (WorkflowStage::PUBLISHED !== $this->resolveProperty($row, $locale . 'State', $locale)) { return; } $template = $this->resolveProperty($row, 'template', $locale); if (empty($template)) { return; } $structure = $this->structureManager->getStructure($template); if (!$structure || !$structure->hasTag('sulu.rlp')) { return; } $propertyName = $structure->getPropertyByTagName('sulu.rlp')->getName(); return $this->resolveProperty($row, $propertyName, $locale); }
[ "private", "function", "resolveUrl", "(", "Row", "$", "row", ",", "$", "locale", ")", "{", "if", "(", "WorkflowStage", "::", "PUBLISHED", "!==", "$", "this", "->", "resolveProperty", "(", "$", "row", ",", "$", "locale", ".", "'State'", ",", "$", "locale", ")", ")", "{", "return", ";", "}", "$", "template", "=", "$", "this", "->", "resolveProperty", "(", "$", "row", ",", "'template'", ",", "$", "locale", ")", ";", "if", "(", "empty", "(", "$", "template", ")", ")", "{", "return", ";", "}", "$", "structure", "=", "$", "this", "->", "structureManager", "->", "getStructure", "(", "$", "template", ")", ";", "if", "(", "!", "$", "structure", "||", "!", "$", "structure", "->", "hasTag", "(", "'sulu.rlp'", ")", ")", "{", "return", ";", "}", "$", "propertyName", "=", "$", "structure", "->", "getPropertyByTagName", "(", "'sulu.rlp'", ")", "->", "getName", "(", ")", ";", "return", "$", "this", "->", "resolveProperty", "(", "$", "row", ",", "$", "propertyName", ",", "$", "locale", ")", ";", "}" ]
Resolve url property. @param Row $row @param string $locale @return string
[ "Resolve", "url", "property", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L807-L826
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolvePath
private function resolvePath(Row $row, $webspaceKey) { return '/' . ltrim(str_replace($this->sessionManager->getContentPath($webspaceKey), '', $row->getPath()), '/'); }
php
private function resolvePath(Row $row, $webspaceKey) { return '/' . ltrim(str_replace($this->sessionManager->getContentPath($webspaceKey), '', $row->getPath()), '/'); }
[ "private", "function", "resolvePath", "(", "Row", "$", "row", ",", "$", "webspaceKey", ")", "{", "return", "'/'", ".", "ltrim", "(", "str_replace", "(", "$", "this", "->", "sessionManager", "->", "getContentPath", "(", "$", "webspaceKey", ")", ",", "''", ",", "$", "row", "->", "getPath", "(", ")", ")", ",", "'/'", ")", ";", "}" ]
Resolves path for given row. @param Row $row @param string $webspaceKey @return string
[ "Resolves", "path", "for", "given", "row", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L836-L839
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolvePermissions
private function resolvePermissions(Row $row, UserInterface $user = null) { $permissions = []; if (null !== $user) { foreach ($user->getRoleObjects() as $role) { foreach (array_filter(explode(' ', $row->getValue(sprintf('role%s', $role->getId())))) as $permission) { $permissions[$role->getId()][$permission] = true; } } } return $permissions; }
php
private function resolvePermissions(Row $row, UserInterface $user = null) { $permissions = []; if (null !== $user) { foreach ($user->getRoleObjects() as $role) { foreach (array_filter(explode(' ', $row->getValue(sprintf('role%s', $role->getId())))) as $permission) { $permissions[$role->getId()][$permission] = true; } } } return $permissions; }
[ "private", "function", "resolvePermissions", "(", "Row", "$", "row", ",", "UserInterface", "$", "user", "=", "null", ")", "{", "$", "permissions", "=", "[", "]", ";", "if", "(", "null", "!==", "$", "user", ")", "{", "foreach", "(", "$", "user", "->", "getRoleObjects", "(", ")", "as", "$", "role", ")", "{", "foreach", "(", "array_filter", "(", "explode", "(", "' '", ",", "$", "row", "->", "getValue", "(", "sprintf", "(", "'role%s'", ",", "$", "role", "->", "getId", "(", ")", ")", ")", ")", ")", "as", "$", "permission", ")", "{", "$", "permissions", "[", "$", "role", "->", "getId", "(", ")", "]", "[", "$", "permission", "]", "=", "true", ";", "}", "}", "}", "return", "$", "permissions", ";", "}" ]
Resolves permissions for given user. @param Row $row @param UserInterface $user @return array
[ "Resolves", "permissions", "for", "given", "user", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L849-L861
train
sulu/sulu
src/Sulu/Component/Content/Repository/ContentRepository.php
ContentRepository.resolveHasChildren
private function resolveHasChildren(Row $row) { $queryBuilder = new QueryBuilder($this->qomFactory); $queryBuilder ->select('node', 'jcr:uuid', 'uuid') ->from($this->qomFactory->selector('node', 'nt:unstructured')) ->where($this->qomFactory->childNode('node', $row->getPath())) ->setMaxResults(1); $result = $queryBuilder->execute(); return count(iterator_to_array($result->getRows())) > 0; }
php
private function resolveHasChildren(Row $row) { $queryBuilder = new QueryBuilder($this->qomFactory); $queryBuilder ->select('node', 'jcr:uuid', 'uuid') ->from($this->qomFactory->selector('node', 'nt:unstructured')) ->where($this->qomFactory->childNode('node', $row->getPath())) ->setMaxResults(1); $result = $queryBuilder->execute(); return count(iterator_to_array($result->getRows())) > 0; }
[ "private", "function", "resolveHasChildren", "(", "Row", "$", "row", ")", "{", "$", "queryBuilder", "=", "new", "QueryBuilder", "(", "$", "this", "->", "qomFactory", ")", ";", "$", "queryBuilder", "->", "select", "(", "'node'", ",", "'jcr:uuid'", ",", "'uuid'", ")", "->", "from", "(", "$", "this", "->", "qomFactory", "->", "selector", "(", "'node'", ",", "'nt:unstructured'", ")", ")", "->", "where", "(", "$", "this", "->", "qomFactory", "->", "childNode", "(", "'node'", ",", "$", "row", "->", "getPath", "(", ")", ")", ")", "->", "setMaxResults", "(", "1", ")", ";", "$", "result", "=", "$", "queryBuilder", "->", "execute", "(", ")", ";", "return", "count", "(", "iterator_to_array", "(", "$", "result", "->", "getRows", "(", ")", ")", ")", ">", "0", ";", "}" ]
Resolve property has-children with given node. @param Row $row @return bool
[ "Resolve", "property", "has", "-", "children", "with", "given", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/ContentRepository.php#L870-L883
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Serializer/Subscriber/ShadowLocaleSubscriber.php
ShadowLocaleSubscriber.onPostSerialize
public function onPostSerialize(ObjectEvent $event) { $document = $event->getObject(); if (!$document instanceof ShadowLocaleBehavior || !$this->documentRegistry->hasDocument($document)) { return; } $visitor = $event->getVisitor(); $visitor->addData('shadowLocales', $this->documentInspector->getShadowLocales($document)); }
php
public function onPostSerialize(ObjectEvent $event) { $document = $event->getObject(); if (!$document instanceof ShadowLocaleBehavior || !$this->documentRegistry->hasDocument($document)) { return; } $visitor = $event->getVisitor(); $visitor->addData('shadowLocales', $this->documentInspector->getShadowLocales($document)); }
[ "public", "function", "onPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ShadowLocaleBehavior", "||", "!", "$", "this", "->", "documentRegistry", "->", "hasDocument", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "visitor", "->", "addData", "(", "'shadowLocales'", ",", "$", "this", "->", "documentInspector", "->", "getShadowLocales", "(", "$", "document", ")", ")", ";", "}" ]
Adds the enabled shadow languages to the serialization. @param ObjectEvent $event
[ "Adds", "the", "enabled", "shadow", "languages", "to", "the", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Serializer/Subscriber/ShadowLocaleSubscriber.php#L61-L72
train
sulu/sulu
src/Sulu/Component/Webspace/StructureProvider/WebspaceStructureProvider.php
WebspaceStructureProvider.loadStructures
protected function loadStructures($webspaceKey) { $structures = []; $keys = []; foreach ($this->structureManager->getStructures() as $page) { /* @var PageBridge $page */ $template = sprintf('%s.html.twig', $page->getView()); if ($this->templateExists($template)) { $keys[] = $page->getKey(); $structures[] = $page; } } $this->cache->save($webspaceKey, $keys); return $structures; }
php
protected function loadStructures($webspaceKey) { $structures = []; $keys = []; foreach ($this->structureManager->getStructures() as $page) { /* @var PageBridge $page */ $template = sprintf('%s.html.twig', $page->getView()); if ($this->templateExists($template)) { $keys[] = $page->getKey(); $structures[] = $page; } } $this->cache->save($webspaceKey, $keys); return $structures; }
[ "protected", "function", "loadStructures", "(", "$", "webspaceKey", ")", "{", "$", "structures", "=", "[", "]", ";", "$", "keys", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "structureManager", "->", "getStructures", "(", ")", "as", "$", "page", ")", "{", "/* @var PageBridge $page */", "$", "template", "=", "sprintf", "(", "'%s.html.twig'", ",", "$", "page", "->", "getView", "(", ")", ")", ";", "if", "(", "$", "this", "->", "templateExists", "(", "$", "template", ")", ")", "{", "$", "keys", "[", "]", "=", "$", "page", "->", "getKey", "(", ")", ";", "$", "structures", "[", "]", "=", "$", "page", ";", "}", "}", "$", "this", "->", "cache", "->", "save", "(", "$", "webspaceKey", ",", "$", "keys", ")", ";", "return", "$", "structures", ";", "}" ]
Returns and caches structures for given webspace. @param string $webspaceKey @return array
[ "Returns", "and", "caches", "structures", "for", "given", "webspace", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/StructureProvider/WebspaceStructureProvider.php#L79-L95
train
sulu/sulu
src/Sulu/Component/Webspace/StructureProvider/WebspaceStructureProvider.php
WebspaceStructureProvider.templateExists
protected function templateExists($template) { $loader = $this->twig->getLoader(); if (method_exists($loader, 'exists')) { return $loader->exists($template); } try { // cast possible TemplateReferenceInterface to string because the // EngineInterface supports them but Twig_LoaderInterface does not $loader->getSource($template)->getCode(); } catch (\Twig_Error_Loader $e) { return false; } return true; }
php
protected function templateExists($template) { $loader = $this->twig->getLoader(); if (method_exists($loader, 'exists')) { return $loader->exists($template); } try { // cast possible TemplateReferenceInterface to string because the // EngineInterface supports them but Twig_LoaderInterface does not $loader->getSource($template)->getCode(); } catch (\Twig_Error_Loader $e) { return false; } return true; }
[ "protected", "function", "templateExists", "(", "$", "template", ")", "{", "$", "loader", "=", "$", "this", "->", "twig", "->", "getLoader", "(", ")", ";", "if", "(", "method_exists", "(", "$", "loader", ",", "'exists'", ")", ")", "{", "return", "$", "loader", "->", "exists", "(", "$", "template", ")", ";", "}", "try", "{", "// cast possible TemplateReferenceInterface to string because the", "// EngineInterface supports them but Twig_LoaderInterface does not", "$", "loader", "->", "getSource", "(", "$", "template", ")", "->", "getCode", "(", ")", ";", "}", "catch", "(", "\\", "Twig_Error_Loader", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
checks if a template with given name exists. @param string $template @return bool
[ "checks", "if", "a", "template", "with", "given", "name", "exists", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/StructureProvider/WebspaceStructureProvider.php#L104-L120
train
sulu/sulu
src/Sulu/Component/Util/TextUtils.php
TextUtils.truncate
public static function truncate($text, $length, $suffix = '...') { $strlen = mb_strlen($text, 'UTF-8'); if ($strlen > $length) { $truncatedLength = $length - strlen($suffix); $text = mb_substr($text, 0, $truncatedLength, 'UTF-8') . $suffix; } return $text; }
php
public static function truncate($text, $length, $suffix = '...') { $strlen = mb_strlen($text, 'UTF-8'); if ($strlen > $length) { $truncatedLength = $length - strlen($suffix); $text = mb_substr($text, 0, $truncatedLength, 'UTF-8') . $suffix; } return $text; }
[ "public", "static", "function", "truncate", "(", "$", "text", ",", "$", "length", ",", "$", "suffix", "=", "'...'", ")", "{", "$", "strlen", "=", "mb_strlen", "(", "$", "text", ",", "'UTF-8'", ")", ";", "if", "(", "$", "strlen", ">", "$", "length", ")", "{", "$", "truncatedLength", "=", "$", "length", "-", "strlen", "(", "$", "suffix", ")", ";", "$", "text", "=", "mb_substr", "(", "$", "text", ",", "0", ",", "$", "truncatedLength", ",", "'UTF-8'", ")", ".", "$", "suffix", ";", "}", "return", "$", "text", ";", "}" ]
UTF-8 safe text truncation. @param string $text - Text to truncate @param int $length - Length to truncate to @param string $suffix - This string will replace the last characters of the text @return string
[ "UTF", "-", "8", "safe", "text", "truncation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/TextUtils.php#L28-L38
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/Doctrine/DoctrineListBuilder.php
DoctrineListBuilder.findIdsByGivenCriteria
protected function findIdsByGivenCriteria() { $select = $this->getSelectAs($this->idField); $subQueryBuilder = $this->createSubQueryBuilder($select); if (null != $this->limit) { $subQueryBuilder->setMaxResults($this->limit)->setFirstResult($this->limit * ($this->page - 1)); } foreach ($this->sortFields as $index => $sortField) { if ($sortField->getName() !== $this->idField->getName()) { $subQueryBuilder->addSelect($this->getSelectAs($sortField)); } } $this->assignSortFields($subQueryBuilder); $this->assignParameters($this->queryBuilder); $ids = $subQueryBuilder->getQuery()->getArrayResult(); // if no results are found - return if (count($ids) < 1) { return []; } $ids = array_map( function($array) { return $array[$this->idField->getName()]; }, $ids ); return $ids; }
php
protected function findIdsByGivenCriteria() { $select = $this->getSelectAs($this->idField); $subQueryBuilder = $this->createSubQueryBuilder($select); if (null != $this->limit) { $subQueryBuilder->setMaxResults($this->limit)->setFirstResult($this->limit * ($this->page - 1)); } foreach ($this->sortFields as $index => $sortField) { if ($sortField->getName() !== $this->idField->getName()) { $subQueryBuilder->addSelect($this->getSelectAs($sortField)); } } $this->assignSortFields($subQueryBuilder); $this->assignParameters($this->queryBuilder); $ids = $subQueryBuilder->getQuery()->getArrayResult(); // if no results are found - return if (count($ids) < 1) { return []; } $ids = array_map( function($array) { return $array[$this->idField->getName()]; }, $ids ); return $ids; }
[ "protected", "function", "findIdsByGivenCriteria", "(", ")", "{", "$", "select", "=", "$", "this", "->", "getSelectAs", "(", "$", "this", "->", "idField", ")", ";", "$", "subQueryBuilder", "=", "$", "this", "->", "createSubQueryBuilder", "(", "$", "select", ")", ";", "if", "(", "null", "!=", "$", "this", "->", "limit", ")", "{", "$", "subQueryBuilder", "->", "setMaxResults", "(", "$", "this", "->", "limit", ")", "->", "setFirstResult", "(", "$", "this", "->", "limit", "*", "(", "$", "this", "->", "page", "-", "1", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "sortFields", "as", "$", "index", "=>", "$", "sortField", ")", "{", "if", "(", "$", "sortField", "->", "getName", "(", ")", "!==", "$", "this", "->", "idField", "->", "getName", "(", ")", ")", "{", "$", "subQueryBuilder", "->", "addSelect", "(", "$", "this", "->", "getSelectAs", "(", "$", "sortField", ")", ")", ";", "}", "}", "$", "this", "->", "assignSortFields", "(", "$", "subQueryBuilder", ")", ";", "$", "this", "->", "assignParameters", "(", "$", "this", "->", "queryBuilder", ")", ";", "$", "ids", "=", "$", "subQueryBuilder", "->", "getQuery", "(", ")", "->", "getArrayResult", "(", ")", ";", "// if no results are found - return", "if", "(", "count", "(", "$", "ids", ")", "<", "1", ")", "{", "return", "[", "]", ";", "}", "$", "ids", "=", "array_map", "(", "function", "(", "$", "array", ")", "{", "return", "$", "array", "[", "$", "this", "->", "idField", "->", "getName", "(", ")", "]", ";", "}", ",", "$", "ids", ")", ";", "return", "$", "ids", ";", "}" ]
Function that finds all IDs of entities that match the search criteria. @return array
[ "Function", "that", "finds", "all", "IDs", "of", "entities", "that", "match", "the", "search", "criteria", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/Doctrine/DoctrineListBuilder.php#L265-L297
train