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/Util/SuluNodeHelper.php
SuluNodeHelper.getLanguagesForNode
public function getLanguagesForNode(NodeInterface $node) { $languages = []; foreach ($node->getProperties() as $property) { /* @var PropertyInterface $property */ preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-changer/', $property->getName(), $matches); if ($matches) { $languages[$matches[1]] = $matches[1]; } } return array_values($languages); }
php
public function getLanguagesForNode(NodeInterface $node) { $languages = []; foreach ($node->getProperties() as $property) { /* @var PropertyInterface $property */ preg_match('/^' . $this->languageNamespace . ':([a-zA-Z_]*?)-changer/', $property->getName(), $matches); if ($matches) { $languages[$matches[1]] = $matches[1]; } } return array_values($languages); }
[ "public", "function", "getLanguagesForNode", "(", "NodeInterface", "$", "node", ")", "{", "$", "languages", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "/* @var PropertyInterface $property */", "preg_match", "(", "'/^'", ".", "$", "this", "->", "languageNamespace", ".", "':([a-zA-Z_]*?)-changer/'", ",", "$", "property", "->", "getName", "(", ")", ",", "$", "matches", ")", ";", "if", "(", "$", "matches", ")", "{", "$", "languages", "[", "$", "matches", "[", "1", "]", "]", "=", "$", "matches", "[", "1", "]", ";", "}", "}", "return", "array_values", "(", "$", "languages", ")", ";", "}" ]
Return the languages that are currently registered on the given PHPCR node. @param NodeInterface $node @return array
[ "Return", "the", "languages", "that", "are", "currently", "registered", "on", "the", "given", "PHPCR", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/SuluNodeHelper.php#L84-L97
train
sulu/sulu
src/Sulu/Component/Util/SuluNodeHelper.php
SuluNodeHelper.getStructureTypeForNode
public function getStructureTypeForNode(NodeInterface $node) { $mixinTypes = $node->getPropertyValueWithDefault('jcr:mixinTypes', []); if (in_array('sulu:' . Structure::TYPE_PAGE, $mixinTypes)) { return Structure::TYPE_PAGE; } if (in_array('sulu:' . Structure::TYPE_SNIPPET, $mixinTypes)) { return Structure::TYPE_SNIPPET; } return; }
php
public function getStructureTypeForNode(NodeInterface $node) { $mixinTypes = $node->getPropertyValueWithDefault('jcr:mixinTypes', []); if (in_array('sulu:' . Structure::TYPE_PAGE, $mixinTypes)) { return Structure::TYPE_PAGE; } if (in_array('sulu:' . Structure::TYPE_SNIPPET, $mixinTypes)) { return Structure::TYPE_SNIPPET; } return; }
[ "public", "function", "getStructureTypeForNode", "(", "NodeInterface", "$", "node", ")", "{", "$", "mixinTypes", "=", "$", "node", "->", "getPropertyValueWithDefault", "(", "'jcr:mixinTypes'", ",", "[", "]", ")", ";", "if", "(", "in_array", "(", "'sulu:'", ".", "Structure", "::", "TYPE_PAGE", ",", "$", "mixinTypes", ")", ")", "{", "return", "Structure", "::", "TYPE_PAGE", ";", "}", "if", "(", "in_array", "(", "'sulu:'", ".", "Structure", "::", "TYPE_SNIPPET", ",", "$", "mixinTypes", ")", ")", "{", "return", "Structure", "::", "TYPE_SNIPPET", ";", "}", "return", ";", "}" ]
Return the structure type for the given node. @param NodeInterface $node @return string
[ "Return", "the", "structure", "type", "for", "the", "given", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/SuluNodeHelper.php#L106-L119
train
sulu/sulu
src/Sulu/Component/Util/SuluNodeHelper.php
SuluNodeHelper.getBaseSnippetPath
public function getBaseSnippetPath($type = null) { $path = '/' . $this->getPath('base') . '/' . $this->getPath('snippet'); if ($type) { $path .= '/' . $type; } return $path; }
php
public function getBaseSnippetPath($type = null) { $path = '/' . $this->getPath('base') . '/' . $this->getPath('snippet'); if ($type) { $path .= '/' . $type; } return $path; }
[ "public", "function", "getBaseSnippetPath", "(", "$", "type", "=", "null", ")", "{", "$", "path", "=", "'/'", ".", "$", "this", "->", "getPath", "(", "'base'", ")", ".", "'/'", ".", "$", "this", "->", "getPath", "(", "'snippet'", ")", ";", "if", "(", "$", "type", ")", "{", "$", "path", ".=", "'/'", ".", "$", "type", ";", "}", "return", "$", "path", ";", "}" ]
Returns the path for the base snippet of the given type resp. of all types if not given. @param string $type @return string
[ "Returns", "the", "path", "for", "the", "base", "snippet", "of", "the", "given", "type", "resp", ".", "of", "all", "types", "if", "not", "given", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/SuluNodeHelper.php#L197-L206
train
sulu/sulu
src/Sulu/Component/Util/SuluNodeHelper.php
SuluNodeHelper.getBaseSnippetUuid
public function getBaseSnippetUuid($type = null) { try { return $this->session->getNode($this->getBaseSnippetPath($type))->getIdentifier(); } catch (PathNotFoundException $e) { $snippetStructures = array_map(function(StructureMetadata $structureMetadata) { return $structureMetadata->getName(); }, $this->structureMetadataFactory->getStructures('snippet')); if (in_array($type, $snippetStructures)) { return null; } throw new \InvalidArgumentException(sprintf( 'Snippet type "%s" not available, available snippet types are: [%s]', $type, implode(', ', $snippetStructures) )); } }
php
public function getBaseSnippetUuid($type = null) { try { return $this->session->getNode($this->getBaseSnippetPath($type))->getIdentifier(); } catch (PathNotFoundException $e) { $snippetStructures = array_map(function(StructureMetadata $structureMetadata) { return $structureMetadata->getName(); }, $this->structureMetadataFactory->getStructures('snippet')); if (in_array($type, $snippetStructures)) { return null; } throw new \InvalidArgumentException(sprintf( 'Snippet type "%s" not available, available snippet types are: [%s]', $type, implode(', ', $snippetStructures) )); } }
[ "public", "function", "getBaseSnippetUuid", "(", "$", "type", "=", "null", ")", "{", "try", "{", "return", "$", "this", "->", "session", "->", "getNode", "(", "$", "this", "->", "getBaseSnippetPath", "(", "$", "type", ")", ")", "->", "getIdentifier", "(", ")", ";", "}", "catch", "(", "PathNotFoundException", "$", "e", ")", "{", "$", "snippetStructures", "=", "array_map", "(", "function", "(", "StructureMetadata", "$", "structureMetadata", ")", "{", "return", "$", "structureMetadata", "->", "getName", "(", ")", ";", "}", ",", "$", "this", "->", "structureMetadataFactory", "->", "getStructures", "(", "'snippet'", ")", ")", ";", "if", "(", "in_array", "(", "$", "type", ",", "$", "snippetStructures", ")", ")", "{", "return", "null", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Snippet type \"%s\" not available, available snippet types are: [%s]'", ",", "$", "type", ",", "implode", "(", "', '", ",", "$", "snippetStructures", ")", ")", ")", ";", "}", "}" ]
Returns the uuid for the base snippet of the given type resp. of all types if not given. @param string $type @return string
[ "Returns", "the", "uuid", "for", "the", "base", "snippet", "of", "the", "given", "type", "resp", ".", "of", "all", "types", "if", "not", "given", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/SuluNodeHelper.php#L215-L234
train
sulu/sulu
src/Sulu/Component/Util/SuluNodeHelper.php
SuluNodeHelper.extractSnippetTypeFromPath
public function extractSnippetTypeFromPath($path) { if ('/' !== substr($path, 0, 1)) { throw new \InvalidArgumentException( sprintf( 'Path must be absolute, got "%s"', $path ) ); } $snippetsPath = $this->getBaseSnippetPath() . '/'; $newPath = PathHelper::getParentPath($path); $newPath = substr($newPath, strlen($snippetsPath)); if (false === $newPath) { throw new \InvalidArgumentException( sprintf( 'Cannot extract snippet template type from path "%s"', $path ) ); } return $newPath; }
php
public function extractSnippetTypeFromPath($path) { if ('/' !== substr($path, 0, 1)) { throw new \InvalidArgumentException( sprintf( 'Path must be absolute, got "%s"', $path ) ); } $snippetsPath = $this->getBaseSnippetPath() . '/'; $newPath = PathHelper::getParentPath($path); $newPath = substr($newPath, strlen($snippetsPath)); if (false === $newPath) { throw new \InvalidArgumentException( sprintf( 'Cannot extract snippet template type from path "%s"', $path ) ); } return $newPath; }
[ "public", "function", "extractSnippetTypeFromPath", "(", "$", "path", ")", "{", "if", "(", "'/'", "!==", "substr", "(", "$", "path", ",", "0", ",", "1", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Path must be absolute, got \"%s\"'", ",", "$", "path", ")", ")", ";", "}", "$", "snippetsPath", "=", "$", "this", "->", "getBaseSnippetPath", "(", ")", ".", "'/'", ";", "$", "newPath", "=", "PathHelper", "::", "getParentPath", "(", "$", "path", ")", ";", "$", "newPath", "=", "substr", "(", "$", "newPath", ",", "strlen", "(", "$", "snippetsPath", ")", ")", ";", "if", "(", "false", "===", "$", "newPath", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Cannot extract snippet template type from path \"%s\"'", ",", "$", "path", ")", ")", ";", "}", "return", "$", "newPath", ";", "}" ]
Extract the snippet path from the given path. @param string $path @return string @throws \InvalidArgumentException
[ "Extract", "the", "snippet", "path", "from", "the", "given", "path", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/SuluNodeHelper.php#L245-L270
train
sulu/sulu
src/Sulu/Component/Util/SuluNodeHelper.php
SuluNodeHelper.getTranslatedProperty
public function getTranslatedProperty($property, $locale, $prefix = null) { return new TranslatedProperty($property, $locale, $this->languageNamespace, $prefix); }
php
public function getTranslatedProperty($property, $locale, $prefix = null) { return new TranslatedProperty($property, $locale, $this->languageNamespace, $prefix); }
[ "public", "function", "getTranslatedProperty", "(", "$", "property", ",", "$", "locale", ",", "$", "prefix", "=", "null", ")", "{", "return", "new", "TranslatedProperty", "(", "$", "property", ",", "$", "locale", ",", "$", "this", "->", "languageNamespace", ",", "$", "prefix", ")", ";", "}" ]
Return translated property. @param \Sulu\Component\Content\Compat\PropertyInterface $property @param string $locale @param string $prefix @return \Sulu\Component\Content\Compat\PropertyInterface
[ "Return", "translated", "property", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Util/SuluNodeHelper.php#L314-L317
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Api/Operator.php
Operator.getValues
public function getValues() { $values = $this->entity->getValues(); $result = []; if ($values) { foreach ($values as $value) { $result[] = new OperatorValue($value, $this->locale); } return $result; } return; }
php
public function getValues() { $values = $this->entity->getValues(); $result = []; if ($values) { foreach ($values as $value) { $result[] = new OperatorValue($value, $this->locale); } return $result; } return; }
[ "public", "function", "getValues", "(", ")", "{", "$", "values", "=", "$", "this", "->", "entity", "->", "getValues", "(", ")", ";", "$", "result", "=", "[", "]", ";", "if", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "result", "[", "]", "=", "new", "OperatorValue", "(", "$", "value", ",", "$", "this", "->", "locale", ")", ";", "}", "return", "$", "result", ";", "}", "return", ";", "}" ]
Get values. @return \Doctrine\Common\Collections\Collection @VirtualProperty @SerializedName("values")
[ "Get", "values", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Api/Operator.php#L220-L233
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/EventListener/AppendAnalyticsListener.php
AppendAnalyticsListener.onResponse
public function onResponse(FilterResponseEvent $event) { if ($this->preview || 0 !== strpos($event->getResponse()->headers->get('Content-Type'), 'text/html') || null === $this->requestAnalyzer->getPortalInformation() ) { return; } $portalUrl = $this->requestAnalyzer->getAttribute('urlExpression'); $analyticsArray = $this->analyticsRepository->findByUrl( $portalUrl, $this->requestAnalyzer->getPortalInformation()->getWebspaceKey(), $this->environment ); $analyticsContent = []; foreach ($analyticsArray as $analytics) { $analyticsContent = $this->generateAnalyticsContent($analyticsContent, $analytics); } $response = $event->getResponse(); $response->setContent($this->setAnalyticsContent($response->getContent(), $analyticsContent)); }
php
public function onResponse(FilterResponseEvent $event) { if ($this->preview || 0 !== strpos($event->getResponse()->headers->get('Content-Type'), 'text/html') || null === $this->requestAnalyzer->getPortalInformation() ) { return; } $portalUrl = $this->requestAnalyzer->getAttribute('urlExpression'); $analyticsArray = $this->analyticsRepository->findByUrl( $portalUrl, $this->requestAnalyzer->getPortalInformation()->getWebspaceKey(), $this->environment ); $analyticsContent = []; foreach ($analyticsArray as $analytics) { $analyticsContent = $this->generateAnalyticsContent($analyticsContent, $analytics); } $response = $event->getResponse(); $response->setContent($this->setAnalyticsContent($response->getContent(), $analyticsContent)); }
[ "public", "function", "onResponse", "(", "FilterResponseEvent", "$", "event", ")", "{", "if", "(", "$", "this", "->", "preview", "||", "0", "!==", "strpos", "(", "$", "event", "->", "getResponse", "(", ")", "->", "headers", "->", "get", "(", "'Content-Type'", ")", ",", "'text/html'", ")", "||", "null", "===", "$", "this", "->", "requestAnalyzer", "->", "getPortalInformation", "(", ")", ")", "{", "return", ";", "}", "$", "portalUrl", "=", "$", "this", "->", "requestAnalyzer", "->", "getAttribute", "(", "'urlExpression'", ")", ";", "$", "analyticsArray", "=", "$", "this", "->", "analyticsRepository", "->", "findByUrl", "(", "$", "portalUrl", ",", "$", "this", "->", "requestAnalyzer", "->", "getPortalInformation", "(", ")", "->", "getWebspaceKey", "(", ")", ",", "$", "this", "->", "environment", ")", ";", "$", "analyticsContent", "=", "[", "]", ";", "foreach", "(", "$", "analyticsArray", "as", "$", "analytics", ")", "{", "$", "analyticsContent", "=", "$", "this", "->", "generateAnalyticsContent", "(", "$", "analyticsContent", ",", "$", "analytics", ")", ";", "}", "$", "response", "=", "$", "event", "->", "getResponse", "(", ")", ";", "$", "response", "->", "setContent", "(", "$", "this", "->", "setAnalyticsContent", "(", "$", "response", "->", "getContent", "(", ")", ",", "$", "analyticsContent", ")", ")", ";", "}" ]
Appends analytics scripts into body. @param FilterResponseEvent $event
[ "Appends", "analytics", "scripts", "into", "body", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/EventListener/AppendAnalyticsListener.php#L95-L119
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/EventListener/AppendAnalyticsListener.php
AppendAnalyticsListener.generateAnalyticsContent
protected function generateAnalyticsContent(array $analyticsContent, Analytics $analytics) { foreach (array_keys(self::$positions) as $position) { $template = 'SuluWebsiteBundle:Analytics:' . $analytics->getType() . '/' . $position . '.html.twig'; if (!$this->engine->exists($template)) { continue; } $content = $this->engine->render($template, ['analytics' => $analytics]); if (!$content) { continue; } if (!array_key_exists($position, $analyticsContent)) { $analyticsContent[$position] = ''; } $analyticsContent[$position] .= $content; } return $analyticsContent; }
php
protected function generateAnalyticsContent(array $analyticsContent, Analytics $analytics) { foreach (array_keys(self::$positions) as $position) { $template = 'SuluWebsiteBundle:Analytics:' . $analytics->getType() . '/' . $position . '.html.twig'; if (!$this->engine->exists($template)) { continue; } $content = $this->engine->render($template, ['analytics' => $analytics]); if (!$content) { continue; } if (!array_key_exists($position, $analyticsContent)) { $analyticsContent[$position] = ''; } $analyticsContent[$position] .= $content; } return $analyticsContent; }
[ "protected", "function", "generateAnalyticsContent", "(", "array", "$", "analyticsContent", ",", "Analytics", "$", "analytics", ")", "{", "foreach", "(", "array_keys", "(", "self", "::", "$", "positions", ")", "as", "$", "position", ")", "{", "$", "template", "=", "'SuluWebsiteBundle:Analytics:'", ".", "$", "analytics", "->", "getType", "(", ")", ".", "'/'", ".", "$", "position", ".", "'.html.twig'", ";", "if", "(", "!", "$", "this", "->", "engine", "->", "exists", "(", "$", "template", ")", ")", "{", "continue", ";", "}", "$", "content", "=", "$", "this", "->", "engine", "->", "render", "(", "$", "template", ",", "[", "'analytics'", "=>", "$", "analytics", "]", ")", ";", "if", "(", "!", "$", "content", ")", "{", "continue", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "position", ",", "$", "analyticsContent", ")", ")", "{", "$", "analyticsContent", "[", "$", "position", "]", "=", "''", ";", "}", "$", "analyticsContent", "[", "$", "position", "]", ".=", "$", "content", ";", "}", "return", "$", "analyticsContent", ";", "}" ]
Generate content for each possible position. @param array $analyticsContent @param Analytics $analytics @return array
[ "Generate", "content", "for", "each", "possible", "position", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/EventListener/AppendAnalyticsListener.php#L129-L151
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/EventListener/AppendAnalyticsListener.php
AppendAnalyticsListener.setAnalyticsContent
protected function setAnalyticsContent($responseContent, array $analyticsContent) { foreach ($analyticsContent as $id => $content) { if (!$content) { continue; } $responseContent = preg_replace( self::$positions[$id]['regex'], sprintf(self::$positions[$id]['sprintf'], $content), $responseContent ); } return $responseContent; }
php
protected function setAnalyticsContent($responseContent, array $analyticsContent) { foreach ($analyticsContent as $id => $content) { if (!$content) { continue; } $responseContent = preg_replace( self::$positions[$id]['regex'], sprintf(self::$positions[$id]['sprintf'], $content), $responseContent ); } return $responseContent; }
[ "protected", "function", "setAnalyticsContent", "(", "$", "responseContent", ",", "array", "$", "analyticsContent", ")", "{", "foreach", "(", "$", "analyticsContent", "as", "$", "id", "=>", "$", "content", ")", "{", "if", "(", "!", "$", "content", ")", "{", "continue", ";", "}", "$", "responseContent", "=", "preg_replace", "(", "self", "::", "$", "positions", "[", "$", "id", "]", "[", "'regex'", "]", ",", "sprintf", "(", "self", "::", "$", "positions", "[", "$", "id", "]", "[", "'sprintf'", "]", ",", "$", "content", ")", ",", "$", "responseContent", ")", ";", "}", "return", "$", "responseContent", ";", "}" ]
Set the generated content for each position. @param string $responseContent @param array $analyticsContent @return string
[ "Set", "the", "generated", "content", "for", "each", "position", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/EventListener/AppendAnalyticsListener.php#L161-L176
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Entity/FilterTranslation.php
FilterTranslation.setFilter
public function setFilter(\Sulu\Bundle\ResourceBundle\Entity\Filter $filter) { $this->filter = $filter; return $this; }
php
public function setFilter(\Sulu\Bundle\ResourceBundle\Entity\Filter $filter) { $this->filter = $filter; return $this; }
[ "public", "function", "setFilter", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ResourceBundle", "\\", "Entity", "\\", "Filter", "$", "filter", ")", "{", "$", "this", "->", "filter", "=", "$", "filter", ";", "return", "$", "this", ";", "}" ]
Set filter. @param \Sulu\Bundle\ResourceBundle\Entity\Filter $filter @return FilterTranslation
[ "Set", "filter", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Entity/FilterTranslation.php#L162-L167
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/Storage/LocalStorage.php
LocalStorage.getUniqueFileName
private function getUniqueFileName(string $folder, string $fileName, int $counter = 0): string { $newFileName = $fileName; if ($counter > 0) { $fileNameParts = explode('.', $fileName, 2); $newFileName = $fileNameParts[0] . '-' . $counter; if (isset($fileNameParts[1])) { $newFileName .= '.' . $fileNameParts[1]; } } $filePath = $this->getPathByFolderAndFileName($folder, $newFileName); $this->logger->debug('Check FilePath: ' . $filePath); if (!$this->filesystem->exists($filePath)) { return $newFileName; } ++$counter; return $this->getUniqueFileName($folder, $fileName, $counter); }
php
private function getUniqueFileName(string $folder, string $fileName, int $counter = 0): string { $newFileName = $fileName; if ($counter > 0) { $fileNameParts = explode('.', $fileName, 2); $newFileName = $fileNameParts[0] . '-' . $counter; if (isset($fileNameParts[1])) { $newFileName .= '.' . $fileNameParts[1]; } } $filePath = $this->getPathByFolderAndFileName($folder, $newFileName); $this->logger->debug('Check FilePath: ' . $filePath); if (!$this->filesystem->exists($filePath)) { return $newFileName; } ++$counter; return $this->getUniqueFileName($folder, $fileName, $counter); }
[ "private", "function", "getUniqueFileName", "(", "string", "$", "folder", ",", "string", "$", "fileName", ",", "int", "$", "counter", "=", "0", ")", ":", "string", "{", "$", "newFileName", "=", "$", "fileName", ";", "if", "(", "$", "counter", ">", "0", ")", "{", "$", "fileNameParts", "=", "explode", "(", "'.'", ",", "$", "fileName", ",", "2", ")", ";", "$", "newFileName", "=", "$", "fileNameParts", "[", "0", "]", ".", "'-'", ".", "$", "counter", ";", "if", "(", "isset", "(", "$", "fileNameParts", "[", "1", "]", ")", ")", "{", "$", "newFileName", ".=", "'.'", ".", "$", "fileNameParts", "[", "1", "]", ";", "}", "}", "$", "filePath", "=", "$", "this", "->", "getPathByFolderAndFileName", "(", "$", "folder", ",", "$", "newFileName", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'Check FilePath: '", ".", "$", "filePath", ")", ";", "if", "(", "!", "$", "this", "->", "filesystem", "->", "exists", "(", "$", "filePath", ")", ")", "{", "return", "$", "newFileName", ";", "}", "++", "$", "counter", ";", "return", "$", "this", "->", "getUniqueFileName", "(", "$", "folder", ",", "$", "fileName", ",", "$", "counter", ")", ";", "}" ]
Get a unique filename in path.
[ "Get", "a", "unique", "filename", "in", "path", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/Storage/LocalStorage.php#L124-L148
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.cgetAction
public function cgetAction(Request $request) { $locale = $this->getLocale($request); // if the type parameter is falsy, assign NULL to $type $type = $request->query->get('type', null) ?: null; $idsString = $request->get('ids'); if ($idsString) { $ids = explode(',', $idsString); $snippets = $this->snippetRepository->getSnippetsByUuids($ids, $locale); $total = count($snippets); } else { $snippets = $this->snippetRepository->getSnippets( $locale, $type, $this->listRestHelper->getOffset(), $this->listRestHelper->getLimit(), $this->listRestHelper->getSearchPattern(), $this->listRestHelper->getSortColumn(), $this->listRestHelper->getSortOrder() ); $total = $this->snippetRepository->getSnippetsAmount( $locale, $type, $this->listRestHelper->getSearchPattern(), $this->listRestHelper->getSortColumn(), $this->listRestHelper->getSortOrder() ); } $data = new ListRepresentation( $snippets, 'snippets', 'get_snippets', $request->query->all(), $this->listRestHelper->getPage(), $this->listRestHelper->getLimit(), $total ); return $this->viewHandler->handle(View::create($data)); }
php
public function cgetAction(Request $request) { $locale = $this->getLocale($request); // if the type parameter is falsy, assign NULL to $type $type = $request->query->get('type', null) ?: null; $idsString = $request->get('ids'); if ($idsString) { $ids = explode(',', $idsString); $snippets = $this->snippetRepository->getSnippetsByUuids($ids, $locale); $total = count($snippets); } else { $snippets = $this->snippetRepository->getSnippets( $locale, $type, $this->listRestHelper->getOffset(), $this->listRestHelper->getLimit(), $this->listRestHelper->getSearchPattern(), $this->listRestHelper->getSortColumn(), $this->listRestHelper->getSortOrder() ); $total = $this->snippetRepository->getSnippetsAmount( $locale, $type, $this->listRestHelper->getSearchPattern(), $this->listRestHelper->getSortColumn(), $this->listRestHelper->getSortOrder() ); } $data = new ListRepresentation( $snippets, 'snippets', 'get_snippets', $request->query->all(), $this->listRestHelper->getPage(), $this->listRestHelper->getLimit(), $total ); return $this->viewHandler->handle(View::create($data)); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", "$", "request", ")", ";", "// if the type parameter is falsy, assign NULL to $type", "$", "type", "=", "$", "request", "->", "query", "->", "get", "(", "'type'", ",", "null", ")", "?", ":", "null", ";", "$", "idsString", "=", "$", "request", "->", "get", "(", "'ids'", ")", ";", "if", "(", "$", "idsString", ")", "{", "$", "ids", "=", "explode", "(", "','", ",", "$", "idsString", ")", ";", "$", "snippets", "=", "$", "this", "->", "snippetRepository", "->", "getSnippetsByUuids", "(", "$", "ids", ",", "$", "locale", ")", ";", "$", "total", "=", "count", "(", "$", "snippets", ")", ";", "}", "else", "{", "$", "snippets", "=", "$", "this", "->", "snippetRepository", "->", "getSnippets", "(", "$", "locale", ",", "$", "type", ",", "$", "this", "->", "listRestHelper", "->", "getOffset", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getLimit", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getSearchPattern", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getSortColumn", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getSortOrder", "(", ")", ")", ";", "$", "total", "=", "$", "this", "->", "snippetRepository", "->", "getSnippetsAmount", "(", "$", "locale", ",", "$", "type", ",", "$", "this", "->", "listRestHelper", "->", "getSearchPattern", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getSortColumn", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getSortOrder", "(", ")", ")", ";", "}", "$", "data", "=", "new", "ListRepresentation", "(", "$", "snippets", ",", "'snippets'", ",", "'get_snippets'", ",", "$", "request", "->", "query", "->", "all", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getPage", "(", ")", ",", "$", "this", "->", "listRestHelper", "->", "getLimit", "(", ")", ",", "$", "total", ")", ";", "return", "$", "this", "->", "viewHandler", "->", "handle", "(", "View", "::", "create", "(", "$", "data", ")", ")", ";", "}" ]
Returns list of snippets. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Returns", "list", "of", "snippets", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L145-L189
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.getAction
public function getAction(Request $request, $id = null) { $locale = $this->getLocale($request); $snippet = $this->findDocument($id, $locale); $view = View::create($snippet); return $this->viewHandler->handle($view); }
php
public function getAction(Request $request, $id = null) { $locale = $this->getLocale($request); $snippet = $this->findDocument($id, $locale); $view = View::create($snippet); return $this->viewHandler->handle($view); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ",", "$", "id", "=", "null", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", "$", "request", ")", ";", "$", "snippet", "=", "$", "this", "->", "findDocument", "(", "$", "id", ",", "$", "locale", ")", ";", "$", "view", "=", "View", "::", "create", "(", "$", "snippet", ")", ";", "return", "$", "this", "->", "viewHandler", "->", "handle", "(", "$", "view", ")", ";", "}" ]
Returns snippet by ID. @param Request $request @param string $id @return \Symfony\Component\HttpFoundation\Response @Get(defaults={"id" = ""})
[ "Returns", "snippet", "by", "ID", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L201-L209
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.postAction
public function postAction(Request $request) { $document = $this->documentManager->create(Structure::TYPE_SNIPPET); $form = $this->processForm($request, $document); return $this->handleView($form->getData()); }
php
public function postAction(Request $request) { $document = $this->documentManager->create(Structure::TYPE_SNIPPET); $form = $this->processForm($request, $document); return $this->handleView($form->getData()); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ")", "{", "$", "document", "=", "$", "this", "->", "documentManager", "->", "create", "(", "Structure", "::", "TYPE_SNIPPET", ")", ";", "$", "form", "=", "$", "this", "->", "processForm", "(", "$", "request", ",", "$", "document", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "form", "->", "getData", "(", ")", ")", ";", "}" ]
Saves a new snippet. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Saves", "a", "new", "snippet", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L218-L224
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.putAction
public function putAction(Request $request, $id) { $document = $this->findDocument($id, $this->getLocale($request)); $this->requestHashChecker->checkHash($request, $document, $document->getUuid()); if (!$this->checkAreaSnippet($request, $document)) { return new JsonResponse( [ 'structures' => [], 'other' => [], 'isDefault' => true, ], 409 ); } $this->processForm($request, $document); return $this->handleView($document); }
php
public function putAction(Request $request, $id) { $document = $this->findDocument($id, $this->getLocale($request)); $this->requestHashChecker->checkHash($request, $document, $document->getUuid()); if (!$this->checkAreaSnippet($request, $document)) { return new JsonResponse( [ 'structures' => [], 'other' => [], 'isDefault' => true, ], 409 ); } $this->processForm($request, $document); return $this->handleView($document); }
[ "public", "function", "putAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "document", "=", "$", "this", "->", "findDocument", "(", "$", "id", ",", "$", "this", "->", "getLocale", "(", "$", "request", ")", ")", ";", "$", "this", "->", "requestHashChecker", "->", "checkHash", "(", "$", "request", ",", "$", "document", ",", "$", "document", "->", "getUuid", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "checkAreaSnippet", "(", "$", "request", ",", "$", "document", ")", ")", "{", "return", "new", "JsonResponse", "(", "[", "'structures'", "=>", "[", "]", ",", "'other'", "=>", "[", "]", ",", "'isDefault'", "=>", "true", ",", "]", ",", "409", ")", ";", "}", "$", "this", "->", "processForm", "(", "$", "request", ",", "$", "document", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "document", ")", ";", "}" ]
Saves a new existing snippet. @param Request $request @param string $id @return \Symfony\Component\HttpFoundation\Response
[ "Saves", "a", "new", "existing", "snippet", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L234-L253
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.deleteAction
public function deleteAction(Request $request, $id) { $locale = $this->getLocale($request); $webspaceKey = $request->query->get('webspace', null); $references = $this->snippetRepository->getReferences($id); if (count($references) > 0) { $force = $request->headers->get('SuluForceRemove', false); if ($force) { $this->contentMapper->delete($id, $webspaceKey, true); } else { return $this->getReferentialIntegrityResponse($webspaceKey, $references, $id, $locale); } } else { $this->contentMapper->delete($id, $webspaceKey); } return new JsonResponse(); }
php
public function deleteAction(Request $request, $id) { $locale = $this->getLocale($request); $webspaceKey = $request->query->get('webspace', null); $references = $this->snippetRepository->getReferences($id); if (count($references) > 0) { $force = $request->headers->get('SuluForceRemove', false); if ($force) { $this->contentMapper->delete($id, $webspaceKey, true); } else { return $this->getReferentialIntegrityResponse($webspaceKey, $references, $id, $locale); } } else { $this->contentMapper->delete($id, $webspaceKey); } return new JsonResponse(); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", "$", "request", ")", ";", "$", "webspaceKey", "=", "$", "request", "->", "query", "->", "get", "(", "'webspace'", ",", "null", ")", ";", "$", "references", "=", "$", "this", "->", "snippetRepository", "->", "getReferences", "(", "$", "id", ")", ";", "if", "(", "count", "(", "$", "references", ")", ">", "0", ")", "{", "$", "force", "=", "$", "request", "->", "headers", "->", "get", "(", "'SuluForceRemove'", ",", "false", ")", ";", "if", "(", "$", "force", ")", "{", "$", "this", "->", "contentMapper", "->", "delete", "(", "$", "id", ",", "$", "webspaceKey", ",", "true", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getReferentialIntegrityResponse", "(", "$", "webspaceKey", ",", "$", "references", ",", "$", "id", ",", "$", "locale", ")", ";", "}", "}", "else", "{", "$", "this", "->", "contentMapper", "->", "delete", "(", "$", "id", ",", "$", "webspaceKey", ")", ";", "}", "return", "new", "JsonResponse", "(", ")", ";", "}" ]
Deletes an existing Snippet. @param Request $request @param string $id @return JsonResponse
[ "Deletes", "an", "existing", "Snippet", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L263-L282
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.postTriggerAction
public function postTriggerAction($id, Request $request) { $view = null; $snippet = null; $locale = $this->getLocale($request); $action = $this->getRequestParameter($request, 'action', true); try { switch ($action) { case 'copy-locale': $destLocales = explode(',', $this->getRequestParameter($request, 'dest', true)); // call repository method $snippet = $this->snippetRepository->copyLocale( $id, $this->getUser()->getId(), $locale, $destLocales ); // publish the snippet in every dest locale, otherwise it's not in the live workspace. foreach ($destLocales as $destLocale) { $destSnippet = $this->findDocument($id, $destLocale); $this->documentManager->publish($destSnippet, $destLocale); } // flush all published snippets $this->documentManager->flush(); break; default: throw new RestException('Unrecognized action: ' . $action); } // prepare view $view = View::create( $this->decorateSnippet($snippet->toArray(), $locale), null !== $snippet ? 200 : 204 ); } catch (RestException $exc) { $view = View::create($exc->toArray(), 400); } return $this->viewHandler->handle($view); }
php
public function postTriggerAction($id, Request $request) { $view = null; $snippet = null; $locale = $this->getLocale($request); $action = $this->getRequestParameter($request, 'action', true); try { switch ($action) { case 'copy-locale': $destLocales = explode(',', $this->getRequestParameter($request, 'dest', true)); // call repository method $snippet = $this->snippetRepository->copyLocale( $id, $this->getUser()->getId(), $locale, $destLocales ); // publish the snippet in every dest locale, otherwise it's not in the live workspace. foreach ($destLocales as $destLocale) { $destSnippet = $this->findDocument($id, $destLocale); $this->documentManager->publish($destSnippet, $destLocale); } // flush all published snippets $this->documentManager->flush(); break; default: throw new RestException('Unrecognized action: ' . $action); } // prepare view $view = View::create( $this->decorateSnippet($snippet->toArray(), $locale), null !== $snippet ? 200 : 204 ); } catch (RestException $exc) { $view = View::create($exc->toArray(), 400); } return $this->viewHandler->handle($view); }
[ "public", "function", "postTriggerAction", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "view", "=", "null", ";", "$", "snippet", "=", "null", ";", "$", "locale", "=", "$", "this", "->", "getLocale", "(", "$", "request", ")", ";", "$", "action", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'action'", ",", "true", ")", ";", "try", "{", "switch", "(", "$", "action", ")", "{", "case", "'copy-locale'", ":", "$", "destLocales", "=", "explode", "(", "','", ",", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'dest'", ",", "true", ")", ")", ";", "// call repository method", "$", "snippet", "=", "$", "this", "->", "snippetRepository", "->", "copyLocale", "(", "$", "id", ",", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ",", "$", "locale", ",", "$", "destLocales", ")", ";", "// publish the snippet in every dest locale, otherwise it's not in the live workspace.", "foreach", "(", "$", "destLocales", "as", "$", "destLocale", ")", "{", "$", "destSnippet", "=", "$", "this", "->", "findDocument", "(", "$", "id", ",", "$", "destLocale", ")", ";", "$", "this", "->", "documentManager", "->", "publish", "(", "$", "destSnippet", ",", "$", "destLocale", ")", ";", "}", "// flush all published snippets", "$", "this", "->", "documentManager", "->", "flush", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "RestException", "(", "'Unrecognized action: '", ".", "$", "action", ")", ";", "}", "// prepare view", "$", "view", "=", "View", "::", "create", "(", "$", "this", "->", "decorateSnippet", "(", "$", "snippet", "->", "toArray", "(", ")", ",", "$", "locale", ")", ",", "null", "!==", "$", "snippet", "?", "200", ":", "204", ")", ";", "}", "catch", "(", "RestException", "$", "exc", ")", "{", "$", "view", "=", "View", "::", "create", "(", "$", "exc", "->", "toArray", "(", ")", ",", "400", ")", ";", "}", "return", "$", "this", "->", "viewHandler", "->", "handle", "(", "$", "view", ")", ";", "}" ]
trigger a action for given snippet specified over get-action parameter. @Post("/snippets/{id}") @param string $id @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "trigger", "a", "action", "for", "given", "snippet", "specified", "over", "get", "-", "action", "parameter", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L294-L339
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.decorateSnippet
private function decorateSnippet(array $snippet, $locale) { return array_merge( $snippet, [ '_links' => [ 'self' => $this->urlGenerator->generate( 'get_snippet', ['id' => $snippet['id'], 'language' => $locale] ), 'delete' => $this->urlGenerator->generate( 'delete_snippet', ['id' => $snippet['id'], 'language' => $locale] ), 'new' => $this->urlGenerator->generate('post_snippet', ['language' => $locale]), 'update' => $this->urlGenerator->generate( 'put_snippet', ['id' => $snippet['id'], 'language' => $locale] ), ], ] ); }
php
private function decorateSnippet(array $snippet, $locale) { return array_merge( $snippet, [ '_links' => [ 'self' => $this->urlGenerator->generate( 'get_snippet', ['id' => $snippet['id'], 'language' => $locale] ), 'delete' => $this->urlGenerator->generate( 'delete_snippet', ['id' => $snippet['id'], 'language' => $locale] ), 'new' => $this->urlGenerator->generate('post_snippet', ['language' => $locale]), 'update' => $this->urlGenerator->generate( 'put_snippet', ['id' => $snippet['id'], 'language' => $locale] ), ], ] ); }
[ "private", "function", "decorateSnippet", "(", "array", "$", "snippet", ",", "$", "locale", ")", "{", "return", "array_merge", "(", "$", "snippet", ",", "[", "'_links'", "=>", "[", "'self'", "=>", "$", "this", "->", "urlGenerator", "->", "generate", "(", "'get_snippet'", ",", "[", "'id'", "=>", "$", "snippet", "[", "'id'", "]", ",", "'language'", "=>", "$", "locale", "]", ")", ",", "'delete'", "=>", "$", "this", "->", "urlGenerator", "->", "generate", "(", "'delete_snippet'", ",", "[", "'id'", "=>", "$", "snippet", "[", "'id'", "]", ",", "'language'", "=>", "$", "locale", "]", ")", ",", "'new'", "=>", "$", "this", "->", "urlGenerator", "->", "generate", "(", "'post_snippet'", ",", "[", "'language'", "=>", "$", "locale", "]", ")", ",", "'update'", "=>", "$", "this", "->", "urlGenerator", "->", "generate", "(", "'put_snippet'", ",", "[", "'id'", "=>", "$", "snippet", "[", "'id'", "]", ",", "'language'", "=>", "$", "locale", "]", ")", ",", "]", ",", "]", ")", ";", "}" ]
Decorate snippet for HATEOAS.
[ "Decorate", "snippet", "for", "HATEOAS", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L358-L380
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
SnippetController.getReferentialIntegrityResponse
private function getReferentialIntegrityResponse($webspace, $references, $id, $locale) { $data = [ 'structures' => [], 'other' => [], 'isDefault' => $this->defaultSnippetManager->isDefault($id), ]; foreach ($references as $reference) { if ($reference->getParent()->isNodeType('sulu:page')) { $content = $this->contentMapper->load( $reference->getParent()->getIdentifier(), $webspace, $locale, true ); $data['structures'][] = $content->toArray(); } else { $data['other'][] = $reference->getParent()->getPath(); } } return new JsonResponse($data, 409); }
php
private function getReferentialIntegrityResponse($webspace, $references, $id, $locale) { $data = [ 'structures' => [], 'other' => [], 'isDefault' => $this->defaultSnippetManager->isDefault($id), ]; foreach ($references as $reference) { if ($reference->getParent()->isNodeType('sulu:page')) { $content = $this->contentMapper->load( $reference->getParent()->getIdentifier(), $webspace, $locale, true ); $data['structures'][] = $content->toArray(); } else { $data['other'][] = $reference->getParent()->getPath(); } } return new JsonResponse($data, 409); }
[ "private", "function", "getReferentialIntegrityResponse", "(", "$", "webspace", ",", "$", "references", ",", "$", "id", ",", "$", "locale", ")", "{", "$", "data", "=", "[", "'structures'", "=>", "[", "]", ",", "'other'", "=>", "[", "]", ",", "'isDefault'", "=>", "$", "this", "->", "defaultSnippetManager", "->", "isDefault", "(", "$", "id", ")", ",", "]", ";", "foreach", "(", "$", "references", "as", "$", "reference", ")", "{", "if", "(", "$", "reference", "->", "getParent", "(", ")", "->", "isNodeType", "(", "'sulu:page'", ")", ")", "{", "$", "content", "=", "$", "this", "->", "contentMapper", "->", "load", "(", "$", "reference", "->", "getParent", "(", ")", "->", "getIdentifier", "(", ")", ",", "$", "webspace", ",", "$", "locale", ",", "true", ")", ";", "$", "data", "[", "'structures'", "]", "[", "]", "=", "$", "content", "->", "toArray", "(", ")", ";", "}", "else", "{", "$", "data", "[", "'other'", "]", "[", "]", "=", "$", "reference", "->", "getParent", "(", ")", "->", "getPath", "(", ")", ";", "}", "}", "return", "new", "JsonResponse", "(", "$", "data", ",", "409", ")", ";", "}" ]
Return a response for the case where there is an referential integrity violation. It will return a 409 (Conflict) response with an array of structures which reference the node and an array of "other" nodes (i.e. non-structures) which reference the node. @param string $webspace @param NodeInterface[] $references @param string $id @return Response
[ "Return", "a", "response", "for", "the", "case", "where", "there", "is", "an", "referential", "integrity", "violation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php#L418-L441
train
sulu/sulu
src/Sulu/Component/Content/Query/ContentQueryExecutor.php
ContentQueryExecutor.createSql2Query
private function createSql2Query($sql2, $limit = null, $offset = null) { $queryManager = $this->sessionManager->getSession()->getWorkspace()->getQueryManager(); $query = $queryManager->createQuery($sql2, 'JCR-SQL2'); if ($limit) { $query->setLimit($limit); } if ($offset) { $query->setOffset($offset); } return $query; }
php
private function createSql2Query($sql2, $limit = null, $offset = null) { $queryManager = $this->sessionManager->getSession()->getWorkspace()->getQueryManager(); $query = $queryManager->createQuery($sql2, 'JCR-SQL2'); if ($limit) { $query->setLimit($limit); } if ($offset) { $query->setOffset($offset); } return $query; }
[ "private", "function", "createSql2Query", "(", "$", "sql2", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "queryManager", "=", "$", "this", "->", "sessionManager", "->", "getSession", "(", ")", "->", "getWorkspace", "(", ")", "->", "getQueryManager", "(", ")", ";", "$", "query", "=", "$", "queryManager", "->", "createQuery", "(", "$", "sql2", ",", "'JCR-SQL2'", ")", ";", "if", "(", "$", "limit", ")", "{", "$", "query", "->", "setLimit", "(", "$", "limit", ")", ";", "}", "if", "(", "$", "offset", ")", "{", "$", "query", "->", "setOffset", "(", "$", "offset", ")", ";", "}", "return", "$", "query", ";", "}" ]
returns a sql2 query.
[ "returns", "a", "sql2", "query", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Query/ContentQueryExecutor.php#L138-L151
train
sulu/sulu
src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php
CustomUrlSubscriber.handlePersist
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); if (!($document instanceof CustomUrlBehavior)) { return; } $webspaceKey = $this->inspector->getWebspace($document); $domain = $this->generator->generate($document->getBaseDomain(), $document->getDomainParts()); $locale = $this->webspaceManager->findWebspaceByKey($webspaceKey)->getLocalization( $document->getTargetLocale() ); $route = $this->createRoute( $domain, $document, $locale, $event->getLocale(), $this->getRoutesPath($webspaceKey) ); $this->updateOldReferrers($document, $route, $event->getLocale()); }
php
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); if (!($document instanceof CustomUrlBehavior)) { return; } $webspaceKey = $this->inspector->getWebspace($document); $domain = $this->generator->generate($document->getBaseDomain(), $document->getDomainParts()); $locale = $this->webspaceManager->findWebspaceByKey($webspaceKey)->getLocalization( $document->getTargetLocale() ); $route = $this->createRoute( $domain, $document, $locale, $event->getLocale(), $this->getRoutesPath($webspaceKey) ); $this->updateOldReferrers($document, $route, $event->getLocale()); }
[ "public", "function", "handlePersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "(", "$", "document", "instanceof", "CustomUrlBehavior", ")", ")", "{", "return", ";", "}", "$", "webspaceKey", "=", "$", "this", "->", "inspector", "->", "getWebspace", "(", "$", "document", ")", ";", "$", "domain", "=", "$", "this", "->", "generator", "->", "generate", "(", "$", "document", "->", "getBaseDomain", "(", ")", ",", "$", "document", "->", "getDomainParts", "(", ")", ")", ";", "$", "locale", "=", "$", "this", "->", "webspaceManager", "->", "findWebspaceByKey", "(", "$", "webspaceKey", ")", "->", "getLocalization", "(", "$", "document", "->", "getTargetLocale", "(", ")", ")", ";", "$", "route", "=", "$", "this", "->", "createRoute", "(", "$", "domain", ",", "$", "document", ",", "$", "locale", ",", "$", "event", "->", "getLocale", "(", ")", ",", "$", "this", "->", "getRoutesPath", "(", "$", "webspaceKey", ")", ")", ";", "$", "this", "->", "updateOldReferrers", "(", "$", "document", ",", "$", "route", ",", "$", "event", "->", "getLocale", "(", ")", ")", ";", "}" ]
Creates routes for persisted custom-url. @param PersistEvent $event
[ "Creates", "routes", "for", "persisted", "custom", "-", "url", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php#L91-L112
train
sulu/sulu
src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php
CustomUrlSubscriber.createRoute
protected function createRoute( $domain, CustomUrlBehavior $document, Localization $locale, $persistedLocale, $routesPath ) { $path = sprintf('%s/%s', $routesPath, $domain); $routeDocument = $this->findOrCreateRoute($path, $persistedLocale, $document, $domain); $routeDocument->setTargetDocument($document); $routeDocument->setLocale($locale->getLocale()); $routeDocument->setHistory(false); $this->documentManager->persist( $routeDocument, $persistedLocale, [ 'path' => $path, 'auto_create' => true, ] ); $this->documentManager->publish($routeDocument, $persistedLocale); return $routeDocument; }
php
protected function createRoute( $domain, CustomUrlBehavior $document, Localization $locale, $persistedLocale, $routesPath ) { $path = sprintf('%s/%s', $routesPath, $domain); $routeDocument = $this->findOrCreateRoute($path, $persistedLocale, $document, $domain); $routeDocument->setTargetDocument($document); $routeDocument->setLocale($locale->getLocale()); $routeDocument->setHistory(false); $this->documentManager->persist( $routeDocument, $persistedLocale, [ 'path' => $path, 'auto_create' => true, ] ); $this->documentManager->publish($routeDocument, $persistedLocale); return $routeDocument; }
[ "protected", "function", "createRoute", "(", "$", "domain", ",", "CustomUrlBehavior", "$", "document", ",", "Localization", "$", "locale", ",", "$", "persistedLocale", ",", "$", "routesPath", ")", "{", "$", "path", "=", "sprintf", "(", "'%s/%s'", ",", "$", "routesPath", ",", "$", "domain", ")", ";", "$", "routeDocument", "=", "$", "this", "->", "findOrCreateRoute", "(", "$", "path", ",", "$", "persistedLocale", ",", "$", "document", ",", "$", "domain", ")", ";", "$", "routeDocument", "->", "setTargetDocument", "(", "$", "document", ")", ";", "$", "routeDocument", "->", "setLocale", "(", "$", "locale", "->", "getLocale", "(", ")", ")", ";", "$", "routeDocument", "->", "setHistory", "(", "false", ")", ";", "$", "this", "->", "documentManager", "->", "persist", "(", "$", "routeDocument", ",", "$", "persistedLocale", ",", "[", "'path'", "=>", "$", "path", ",", "'auto_create'", "=>", "true", ",", "]", ")", ";", "$", "this", "->", "documentManager", "->", "publish", "(", "$", "routeDocument", ",", "$", "persistedLocale", ")", ";", "return", "$", "routeDocument", ";", "}" ]
Create route-document for given domain. @param string $domain @param CustomUrlBehavior $document @param Localization $locale @param string $persistedLocale @param string $routesPath @return RouteDocument @throws ResourceLocatorAlreadyExistsException
[ "Create", "route", "-", "document", "for", "given", "domain", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php#L159-L183
train
sulu/sulu
src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php
CustomUrlSubscriber.findOrCreateRoute
protected function findOrCreateRoute($path, $locale, CustomUrlBehavior $document, $route) { try { /** @var RouteDocument $routeDocument */ $routeDocument = $this->documentManager->find($path, $locale); } catch (DocumentNotFoundException $ex) { return $this->documentManager->create('custom_url_route'); } if (!$routeDocument instanceof RouteDocument || $routeDocument->getTargetDocument()->getUuid() !== $document->getUuid() ) { throw new ResourceLocatorAlreadyExistsException($route, $document->getTitle()); } return $routeDocument; }
php
protected function findOrCreateRoute($path, $locale, CustomUrlBehavior $document, $route) { try { /** @var RouteDocument $routeDocument */ $routeDocument = $this->documentManager->find($path, $locale); } catch (DocumentNotFoundException $ex) { return $this->documentManager->create('custom_url_route'); } if (!$routeDocument instanceof RouteDocument || $routeDocument->getTargetDocument()->getUuid() !== $document->getUuid() ) { throw new ResourceLocatorAlreadyExistsException($route, $document->getTitle()); } return $routeDocument; }
[ "protected", "function", "findOrCreateRoute", "(", "$", "path", ",", "$", "locale", ",", "CustomUrlBehavior", "$", "document", ",", "$", "route", ")", "{", "try", "{", "/** @var RouteDocument $routeDocument */", "$", "routeDocument", "=", "$", "this", "->", "documentManager", "->", "find", "(", "$", "path", ",", "$", "locale", ")", ";", "}", "catch", "(", "DocumentNotFoundException", "$", "ex", ")", "{", "return", "$", "this", "->", "documentManager", "->", "create", "(", "'custom_url_route'", ")", ";", "}", "if", "(", "!", "$", "routeDocument", "instanceof", "RouteDocument", "||", "$", "routeDocument", "->", "getTargetDocument", "(", ")", "->", "getUuid", "(", ")", "!==", "$", "document", "->", "getUuid", "(", ")", ")", "{", "throw", "new", "ResourceLocatorAlreadyExistsException", "(", "$", "route", ",", "$", "document", "->", "getTitle", "(", ")", ")", ";", "}", "return", "$", "routeDocument", ";", "}" ]
Find or create route-document for given path. @param string $path @param string $locale @param CustomUrlBehavior $document @param string $route @return RouteDocument @throws ResourceLocatorAlreadyExistsException
[ "Find", "or", "create", "route", "-", "document", "for", "given", "path", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php#L197-L213
train
sulu/sulu
src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php
CustomUrlSubscriber.handleRemove
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!($document instanceof CustomUrlBehavior)) { return; } foreach ($this->inspector->getReferrers($document) as $referrer) { if ($referrer instanceof RouteBehavior) { $this->documentManager->remove($referrer); } } }
php
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!($document instanceof CustomUrlBehavior)) { return; } foreach ($this->inspector->getReferrers($document) as $referrer) { if ($referrer instanceof RouteBehavior) { $this->documentManager->remove($referrer); } } }
[ "public", "function", "handleRemove", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "(", "$", "document", "instanceof", "CustomUrlBehavior", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "inspector", "->", "getReferrers", "(", "$", "document", ")", "as", "$", "referrer", ")", "{", "if", "(", "$", "referrer", "instanceof", "RouteBehavior", ")", "{", "$", "this", "->", "documentManager", "->", "remove", "(", "$", "referrer", ")", ";", "}", "}", "}" ]
Removes the routes for the given document. @param RemoveEvent $event
[ "Removes", "the", "routes", "for", "the", "given", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/CustomUrl/Document/Subscriber/CustomUrlSubscriber.php#L220-L232
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Entity/DomainRepository.php
DomainRepository.findByUrlAndEnvironment
public function findByUrlAndEnvironment($url, $environment) { $queryBuilder = $this->createQueryBuilder('u') ->where('u.url = :url') ->andWhere('u.environment = :environment'); $query = $queryBuilder->getQuery(); $query->setParameter('url', $url); $query->setParameter('environment', $environment); try { return $query->getSingleResult(); } catch (NoResultException $ex) { return; } }
php
public function findByUrlAndEnvironment($url, $environment) { $queryBuilder = $this->createQueryBuilder('u') ->where('u.url = :url') ->andWhere('u.environment = :environment'); $query = $queryBuilder->getQuery(); $query->setParameter('url', $url); $query->setParameter('environment', $environment); try { return $query->getSingleResult(); } catch (NoResultException $ex) { return; } }
[ "public", "function", "findByUrlAndEnvironment", "(", "$", "url", ",", "$", "environment", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'u'", ")", "->", "where", "(", "'u.url = :url'", ")", "->", "andWhere", "(", "'u.environment = :environment'", ")", ";", "$", "query", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'url'", ",", "$", "url", ")", ";", "$", "query", "->", "setParameter", "(", "'environment'", ",", "$", "environment", ")", ";", "try", "{", "return", "$", "query", "->", "getSingleResult", "(", ")", ";", "}", "catch", "(", "NoResultException", "$", "ex", ")", "{", "return", ";", "}", "}" ]
Returns domain with given url and environment. @param string $url @param string $environment @return Domain
[ "Returns", "domain", "with", "given", "url", "and", "environment", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Entity/DomainRepository.php#L30-L45
train
sulu/sulu
src/Sulu/Component/Webspace/PortalInformation.php
PortalInformation.getHostLength
private function getHostLength() { $hostLength = strpos($this->url, '/'); $hostLength = (false === $hostLength) ? strlen($this->url) : $hostLength; return $hostLength; }
php
private function getHostLength() { $hostLength = strpos($this->url, '/'); $hostLength = (false === $hostLength) ? strlen($this->url) : $hostLength; return $hostLength; }
[ "private", "function", "getHostLength", "(", ")", "{", "$", "hostLength", "=", "strpos", "(", "$", "this", "->", "url", ",", "'/'", ")", ";", "$", "hostLength", "=", "(", "false", "===", "$", "hostLength", ")", "?", "strlen", "(", "$", "this", "->", "url", ")", ":", "$", "hostLength", ";", "return", "$", "hostLength", ";", "}" ]
Calculate the length of the host part of the URL. @return int
[ "Calculate", "the", "length", "of", "the", "host", "part", "of", "the", "URL", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/PortalInformation.php#L351-L357
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/Transformation/PasteTransformation.php
PasteTransformation.createMask
protected function createMask($maskPath, $width, $height) { $mask = $this->imagine->open($maskPath); $mask->resize( new Box( $width ?: 1, $height ?: 1 ) ); return $mask; }
php
protected function createMask($maskPath, $width, $height) { $mask = $this->imagine->open($maskPath); $mask->resize( new Box( $width ?: 1, $height ?: 1 ) ); return $mask; }
[ "protected", "function", "createMask", "(", "$", "maskPath", ",", "$", "width", ",", "$", "height", ")", "{", "$", "mask", "=", "$", "this", "->", "imagine", "->", "open", "(", "$", "maskPath", ")", ";", "$", "mask", "->", "resize", "(", "new", "Box", "(", "$", "width", "?", ":", "1", ",", "$", "height", "?", ":", "1", ")", ")", ";", "return", "$", "mask", ";", "}" ]
Create mask. @param $maskPath @param $width @param $height @return ImageInterface
[ "Create", "mask", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/Transformation/PasteTransformation.php#L102-L113
train
sulu/sulu
src/Sulu/Bundle/AdminBundle/Admin/JsConfigPool.php
JsConfigPool.addConfigParams
public function addConfigParams(JsConfigInterface $params) { $this->pool = array_merge($this->pool, [$params->getName() => $params->getParameters()]); }
php
public function addConfigParams(JsConfigInterface $params) { $this->pool = array_merge($this->pool, [$params->getName() => $params->getParameters()]); }
[ "public", "function", "addConfigParams", "(", "JsConfigInterface", "$", "params", ")", "{", "$", "this", "->", "pool", "=", "array_merge", "(", "$", "this", "->", "pool", ",", "[", "$", "params", "->", "getName", "(", ")", "=>", "$", "params", "->", "getParameters", "(", ")", "]", ")", ";", "}" ]
Adds a new config parameter. @param $params
[ "Adds", "a", "new", "config", "parameter", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AdminBundle/Admin/JsConfigPool.php#L41-L44
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/Metadata/ListXmlLoader.php
ListXmlLoader.loadPropertyMetadata
private function loadPropertyMetadata(\DOMXPath $xpath, \DOMNode $propertyNode) { $propertyMetadata = null; switch ($propertyNode->nodeName) { case 'concatenation-property': $propertyMetadata = $this->loadConcatenationPropertyMetadata($xpath, $propertyNode); break; case 'identity-property': $propertyMetadata = $this->loadIdentityPropertyMetadata($xpath, $propertyNode); break; case 'group-concat-property': $propertyMetadata = $this->loadGroupConcatPropertyMetadata($xpath, $propertyNode); break; case 'case-property': $propertyMetadata = $this->loadCasePropertyMetadata($xpath, $propertyNode); break; case 'count-property': $propertyMetadata = $this->loadCountPropertyMetadata($xpath, $propertyNode); break; case 'property': $propertyMetadata = $this->loadSinglePropertyMetadata($xpath, $propertyNode); break; default: throw new \InvalidArgumentException(sprintf( 'The tag "%s" cannot be handled by this loader', $propertyNode->nodeName )); } if (null !== $translation = XmlUtil::getValueFromXPath('@translation', $xpath, $propertyNode)) { $propertyMetadata->setTranslation($translation); } if (null !== $type = XmlUtil::getValueFromXPath('@type', $xpath, $propertyNode)) { $propertyMetadata->setType($type); } $propertyMetadata->setVisibility( XmlUtil::getValueFromXPath( '@visibility', $xpath, $propertyNode, FieldDescriptorInterface::VISIBILITY_NO ) ); $propertyMetadata->setSearchability( XmlUtil::getValueFromXPath( '@searchability', $xpath, $propertyNode, FieldDescriptorInterface::SEARCHABILITY_NEVER ) ); $propertyMetadata->setSortable( XmlUtil::getBooleanValueFromXPath('@sortable', $xpath, $propertyNode, true) ); $propertyMetadata->setFilterType(XmlUtil::getValueFromXPath('@filter-type', $xpath, $propertyNode)); $propertyMetadata->setFilterTypeParameters($this->getFilterTypeParameters($xpath, $propertyNode)); return $propertyMetadata; }
php
private function loadPropertyMetadata(\DOMXPath $xpath, \DOMNode $propertyNode) { $propertyMetadata = null; switch ($propertyNode->nodeName) { case 'concatenation-property': $propertyMetadata = $this->loadConcatenationPropertyMetadata($xpath, $propertyNode); break; case 'identity-property': $propertyMetadata = $this->loadIdentityPropertyMetadata($xpath, $propertyNode); break; case 'group-concat-property': $propertyMetadata = $this->loadGroupConcatPropertyMetadata($xpath, $propertyNode); break; case 'case-property': $propertyMetadata = $this->loadCasePropertyMetadata($xpath, $propertyNode); break; case 'count-property': $propertyMetadata = $this->loadCountPropertyMetadata($xpath, $propertyNode); break; case 'property': $propertyMetadata = $this->loadSinglePropertyMetadata($xpath, $propertyNode); break; default: throw new \InvalidArgumentException(sprintf( 'The tag "%s" cannot be handled by this loader', $propertyNode->nodeName )); } if (null !== $translation = XmlUtil::getValueFromXPath('@translation', $xpath, $propertyNode)) { $propertyMetadata->setTranslation($translation); } if (null !== $type = XmlUtil::getValueFromXPath('@type', $xpath, $propertyNode)) { $propertyMetadata->setType($type); } $propertyMetadata->setVisibility( XmlUtil::getValueFromXPath( '@visibility', $xpath, $propertyNode, FieldDescriptorInterface::VISIBILITY_NO ) ); $propertyMetadata->setSearchability( XmlUtil::getValueFromXPath( '@searchability', $xpath, $propertyNode, FieldDescriptorInterface::SEARCHABILITY_NEVER ) ); $propertyMetadata->setSortable( XmlUtil::getBooleanValueFromXPath('@sortable', $xpath, $propertyNode, true) ); $propertyMetadata->setFilterType(XmlUtil::getValueFromXPath('@filter-type', $xpath, $propertyNode)); $propertyMetadata->setFilterTypeParameters($this->getFilterTypeParameters($xpath, $propertyNode)); return $propertyMetadata; }
[ "private", "function", "loadPropertyMetadata", "(", "\\", "DOMXPath", "$", "xpath", ",", "\\", "DOMNode", "$", "propertyNode", ")", "{", "$", "propertyMetadata", "=", "null", ";", "switch", "(", "$", "propertyNode", "->", "nodeName", ")", "{", "case", "'concatenation-property'", ":", "$", "propertyMetadata", "=", "$", "this", "->", "loadConcatenationPropertyMetadata", "(", "$", "xpath", ",", "$", "propertyNode", ")", ";", "break", ";", "case", "'identity-property'", ":", "$", "propertyMetadata", "=", "$", "this", "->", "loadIdentityPropertyMetadata", "(", "$", "xpath", ",", "$", "propertyNode", ")", ";", "break", ";", "case", "'group-concat-property'", ":", "$", "propertyMetadata", "=", "$", "this", "->", "loadGroupConcatPropertyMetadata", "(", "$", "xpath", ",", "$", "propertyNode", ")", ";", "break", ";", "case", "'case-property'", ":", "$", "propertyMetadata", "=", "$", "this", "->", "loadCasePropertyMetadata", "(", "$", "xpath", ",", "$", "propertyNode", ")", ";", "break", ";", "case", "'count-property'", ":", "$", "propertyMetadata", "=", "$", "this", "->", "loadCountPropertyMetadata", "(", "$", "xpath", ",", "$", "propertyNode", ")", ";", "break", ";", "case", "'property'", ":", "$", "propertyMetadata", "=", "$", "this", "->", "loadSinglePropertyMetadata", "(", "$", "xpath", ",", "$", "propertyNode", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The tag \"%s\" cannot be handled by this loader'", ",", "$", "propertyNode", "->", "nodeName", ")", ")", ";", "}", "if", "(", "null", "!==", "$", "translation", "=", "XmlUtil", "::", "getValueFromXPath", "(", "'@translation'", ",", "$", "xpath", ",", "$", "propertyNode", ")", ")", "{", "$", "propertyMetadata", "->", "setTranslation", "(", "$", "translation", ")", ";", "}", "if", "(", "null", "!==", "$", "type", "=", "XmlUtil", "::", "getValueFromXPath", "(", "'@type'", ",", "$", "xpath", ",", "$", "propertyNode", ")", ")", "{", "$", "propertyMetadata", "->", "setType", "(", "$", "type", ")", ";", "}", "$", "propertyMetadata", "->", "setVisibility", "(", "XmlUtil", "::", "getValueFromXPath", "(", "'@visibility'", ",", "$", "xpath", ",", "$", "propertyNode", ",", "FieldDescriptorInterface", "::", "VISIBILITY_NO", ")", ")", ";", "$", "propertyMetadata", "->", "setSearchability", "(", "XmlUtil", "::", "getValueFromXPath", "(", "'@searchability'", ",", "$", "xpath", ",", "$", "propertyNode", ",", "FieldDescriptorInterface", "::", "SEARCHABILITY_NEVER", ")", ")", ";", "$", "propertyMetadata", "->", "setSortable", "(", "XmlUtil", "::", "getBooleanValueFromXPath", "(", "'@sortable'", ",", "$", "xpath", ",", "$", "propertyNode", ",", "true", ")", ")", ";", "$", "propertyMetadata", "->", "setFilterType", "(", "XmlUtil", "::", "getValueFromXPath", "(", "'@filter-type'", ",", "$", "xpath", ",", "$", "propertyNode", ")", ")", ";", "$", "propertyMetadata", "->", "setFilterTypeParameters", "(", "$", "this", "->", "getFilterTypeParameters", "(", "$", "xpath", ",", "$", "propertyNode", ")", ")", ";", "return", "$", "propertyMetadata", ";", "}" ]
Extracts attributes from dom-node to create a new property-metadata object. @param \DOMXPath $xpath @param \DOMNode $propertyNode @return AbstractPropertyMetadata
[ "Extracts", "attributes", "from", "dom", "-", "node", "to", "create", "a", "new", "property", "-", "metadata", "object", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/Metadata/ListXmlLoader.php#L76-L136
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/Metadata/ListXmlLoader.php
ListXmlLoader.getFilterTypeParameters
protected function getFilterTypeParameters(\DOMXPath $xpath, \DOMNode $propertyNode) { $parameters = []; foreach ($xpath->query('x:filter-type-parameters/x:parameter', $propertyNode) as $parameterNode) { $key = XmlUtil::getValueFromXPath('@key', $xpath, $parameterNode); $parameters[$key] = $this->parameterBag->resolveValue(trim($parameterNode->nodeValue)); } return $parameters; }
php
protected function getFilterTypeParameters(\DOMXPath $xpath, \DOMNode $propertyNode) { $parameters = []; foreach ($xpath->query('x:filter-type-parameters/x:parameter', $propertyNode) as $parameterNode) { $key = XmlUtil::getValueFromXPath('@key', $xpath, $parameterNode); $parameters[$key] = $this->parameterBag->resolveValue(trim($parameterNode->nodeValue)); } return $parameters; }
[ "protected", "function", "getFilterTypeParameters", "(", "\\", "DOMXPath", "$", "xpath", ",", "\\", "DOMNode", "$", "propertyNode", ")", "{", "$", "parameters", "=", "[", "]", ";", "foreach", "(", "$", "xpath", "->", "query", "(", "'x:filter-type-parameters/x:parameter'", ",", "$", "propertyNode", ")", "as", "$", "parameterNode", ")", "{", "$", "key", "=", "XmlUtil", "::", "getValueFromXPath", "(", "'@key'", ",", "$", "xpath", ",", "$", "parameterNode", ")", ";", "$", "parameters", "[", "$", "key", "]", "=", "$", "this", "->", "parameterBag", "->", "resolveValue", "(", "trim", "(", "$", "parameterNode", "->", "nodeValue", ")", ")", ";", "}", "return", "$", "parameters", ";", "}" ]
Extracts filter type parameters from dom-node. @param \DOMXPath $xpath @param \DOMNode $propertyNode @return array
[ "Extracts", "filter", "type", "parameters", "from", "dom", "-", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/Metadata/ListXmlLoader.php#L236-L245
train
sulu/sulu
src/Sulu/Bundle/LocationBundle/Controller/GeolocatorController.php
GeolocatorController.queryAction
public function queryAction(Request $request) { $geolocatorName = $request->get('providerName'); $query = $request->get('query'); try { $geolocator = $this->geolocatorManager->get($geolocatorName); } catch (GeolocatorNotFoundException $e) { throw new NotFoundHttpException( sprintf( 'Wrapped "%s"', $e->getMessage() ), $e ); } $res = $geolocator->locate($query); return new JsonResponse(['_embedded' => ['locations' => $res->toArray()]]); }
php
public function queryAction(Request $request) { $geolocatorName = $request->get('providerName'); $query = $request->get('query'); try { $geolocator = $this->geolocatorManager->get($geolocatorName); } catch (GeolocatorNotFoundException $e) { throw new NotFoundHttpException( sprintf( 'Wrapped "%s"', $e->getMessage() ), $e ); } $res = $geolocator->locate($query); return new JsonResponse(['_embedded' => ['locations' => $res->toArray()]]); }
[ "public", "function", "queryAction", "(", "Request", "$", "request", ")", "{", "$", "geolocatorName", "=", "$", "request", "->", "get", "(", "'providerName'", ")", ";", "$", "query", "=", "$", "request", "->", "get", "(", "'query'", ")", ";", "try", "{", "$", "geolocator", "=", "$", "this", "->", "geolocatorManager", "->", "get", "(", "$", "geolocatorName", ")", ";", "}", "catch", "(", "GeolocatorNotFoundException", "$", "e", ")", "{", "throw", "new", "NotFoundHttpException", "(", "sprintf", "(", "'Wrapped \"%s\"'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ",", "$", "e", ")", ";", "}", "$", "res", "=", "$", "geolocator", "->", "locate", "(", "$", "query", ")", ";", "return", "new", "JsonResponse", "(", "[", "'_embedded'", "=>", "[", "'locations'", "=>", "$", "res", "->", "toArray", "(", ")", "]", "]", ")", ";", "}" ]
Query the configured geolocation service. @param Request $request @return JsonResponse
[ "Query", "the", "configured", "geolocation", "service", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/LocationBundle/Controller/GeolocatorController.php#L45-L65
train
sulu/sulu
src/Sulu/Bundle/MarkupBundle/Markup/LinkTag.php
LinkTag.preload
private function preload($attributesByTag, $locale, $published = true) { $hrefsByType = []; foreach ($attributesByTag as $attributes) { $provider = $this->getValue($attributes, 'provider', self::DEFAULT_PROVIDER); if (!array_key_exists($provider, $hrefsByType)) { $hrefsByType[$provider] = []; } $hrefsByType[$provider][] = $attributes['href']; } $result = []; foreach ($hrefsByType as $provider => $hrefs) { $items = $this->linkProviderPool->getProvider($provider)->preload( array_unique($hrefs), $locale, $published ); foreach ($items as $item) { $result[$provider . '-' . $item->getId()] = $item; } } return $result; }
php
private function preload($attributesByTag, $locale, $published = true) { $hrefsByType = []; foreach ($attributesByTag as $attributes) { $provider = $this->getValue($attributes, 'provider', self::DEFAULT_PROVIDER); if (!array_key_exists($provider, $hrefsByType)) { $hrefsByType[$provider] = []; } $hrefsByType[$provider][] = $attributes['href']; } $result = []; foreach ($hrefsByType as $provider => $hrefs) { $items = $this->linkProviderPool->getProvider($provider)->preload( array_unique($hrefs), $locale, $published ); foreach ($items as $item) { $result[$provider . '-' . $item->getId()] = $item; } } return $result; }
[ "private", "function", "preload", "(", "$", "attributesByTag", ",", "$", "locale", ",", "$", "published", "=", "true", ")", "{", "$", "hrefsByType", "=", "[", "]", ";", "foreach", "(", "$", "attributesByTag", "as", "$", "attributes", ")", "{", "$", "provider", "=", "$", "this", "->", "getValue", "(", "$", "attributes", ",", "'provider'", ",", "self", "::", "DEFAULT_PROVIDER", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "provider", ",", "$", "hrefsByType", ")", ")", "{", "$", "hrefsByType", "[", "$", "provider", "]", "=", "[", "]", ";", "}", "$", "hrefsByType", "[", "$", "provider", "]", "[", "]", "=", "$", "attributes", "[", "'href'", "]", ";", "}", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "hrefsByType", "as", "$", "provider", "=>", "$", "hrefs", ")", "{", "$", "items", "=", "$", "this", "->", "linkProviderPool", "->", "getProvider", "(", "$", "provider", ")", "->", "preload", "(", "array_unique", "(", "$", "hrefs", ")", ",", "$", "locale", ",", "$", "published", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "result", "[", "$", "provider", ".", "'-'", ".", "$", "item", "->", "getId", "(", ")", "]", "=", "$", "item", ";", "}", "}", "return", "$", "result", ";", "}" ]
Return items for given attributes. @param array $attributesByTag @param string $locale @param bool $published @return LinkItem[]
[ "Return", "items", "for", "given", "attributes", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MarkupBundle/Markup/LinkTag.php#L111-L137
train
sulu/sulu
src/Sulu/Bundle/MarkupBundle/Markup/LinkTag.php
LinkTag.getValue
private function getValue(array $attributes, $name, $default = null) { if (array_key_exists($name, $attributes) && !empty($attributes[$name])) { return $attributes[$name]; } return $default; }
php
private function getValue(array $attributes, $name, $default = null) { if (array_key_exists($name, $attributes) && !empty($attributes[$name])) { return $attributes[$name]; } return $default; }
[ "private", "function", "getValue", "(", "array", "$", "attributes", ",", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "attributes", ")", "&&", "!", "empty", "(", "$", "attributes", "[", "$", "name", "]", ")", ")", "{", "return", "$", "attributes", "[", "$", "name", "]", ";", "}", "return", "$", "default", ";", "}" ]
Returns attribute identified by name or default if not exists. @param array $attributes @param string $name @param mixed $default @return mixed
[ "Returns", "attribute", "identified", "by", "name", "or", "default", "if", "not", "exists", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MarkupBundle/Markup/LinkTag.php#L148-L155
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Repository/ResourceLocatorRepository.php
ResourceLocatorRepository.getBasePath
private function getBasePath($uuid = null, $default = 1) { if (null !== $uuid) { return str_replace('{uuid}', $uuid, $this->apiBasePath[2]); } else { return $this->apiBasePath[$default]; } }
php
private function getBasePath($uuid = null, $default = 1) { if (null !== $uuid) { return str_replace('{uuid}', $uuid, $this->apiBasePath[2]); } else { return $this->apiBasePath[$default]; } }
[ "private", "function", "getBasePath", "(", "$", "uuid", "=", "null", ",", "$", "default", "=", "1", ")", "{", "if", "(", "null", "!==", "$", "uuid", ")", "{", "return", "str_replace", "(", "'{uuid}'", ",", "$", "uuid", ",", "$", "this", "->", "apiBasePath", "[", "2", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "apiBasePath", "[", "$", "default", "]", ";", "}", "}" ]
returns base path fo given uuid. @param null|string $uuid @param int $default @return string
[ "returns", "base", "path", "fo", "given", "uuid", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Repository/ResourceLocatorRepository.php#L139-L146
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Content/SnippetContent.php
SnippetContent.getSnippets
private function getSnippets(PropertyInterface $property) { /** @var PageBridge $page */ $page = $property->getStructure(); $webspaceKey = $page->getWebspaceKey(); $locale = $page->getLanguageCode(); $shadowLocale = null; if ($page->getIsShadow()) { $shadowLocale = $page->getShadowBaseLanguage(); } $refs = $property->getValue(); $ids = $this->getUuids($refs); $snippetType = $this->getParameterValue($property->getParams(), 'snippetType'); $default = $this->getParameterValue($property->getParams(), 'default', false); $snippetArea = $default; if (true === $snippetArea || 'true' === $snippetArea) { $snippetArea = $snippetType; } if (empty($ids) && $snippetArea && $this->defaultEnabled) { $ids = $this->loadSnippetAreaIds($webspaceKey, $snippetArea, $locale); } return $this->snippetResolver->resolve($ids, $webspaceKey, $locale, $shadowLocale); }
php
private function getSnippets(PropertyInterface $property) { /** @var PageBridge $page */ $page = $property->getStructure(); $webspaceKey = $page->getWebspaceKey(); $locale = $page->getLanguageCode(); $shadowLocale = null; if ($page->getIsShadow()) { $shadowLocale = $page->getShadowBaseLanguage(); } $refs = $property->getValue(); $ids = $this->getUuids($refs); $snippetType = $this->getParameterValue($property->getParams(), 'snippetType'); $default = $this->getParameterValue($property->getParams(), 'default', false); $snippetArea = $default; if (true === $snippetArea || 'true' === $snippetArea) { $snippetArea = $snippetType; } if (empty($ids) && $snippetArea && $this->defaultEnabled) { $ids = $this->loadSnippetAreaIds($webspaceKey, $snippetArea, $locale); } return $this->snippetResolver->resolve($ids, $webspaceKey, $locale, $shadowLocale); }
[ "private", "function", "getSnippets", "(", "PropertyInterface", "$", "property", ")", "{", "/** @var PageBridge $page */", "$", "page", "=", "$", "property", "->", "getStructure", "(", ")", ";", "$", "webspaceKey", "=", "$", "page", "->", "getWebspaceKey", "(", ")", ";", "$", "locale", "=", "$", "page", "->", "getLanguageCode", "(", ")", ";", "$", "shadowLocale", "=", "null", ";", "if", "(", "$", "page", "->", "getIsShadow", "(", ")", ")", "{", "$", "shadowLocale", "=", "$", "page", "->", "getShadowBaseLanguage", "(", ")", ";", "}", "$", "refs", "=", "$", "property", "->", "getValue", "(", ")", ";", "$", "ids", "=", "$", "this", "->", "getUuids", "(", "$", "refs", ")", ";", "$", "snippetType", "=", "$", "this", "->", "getParameterValue", "(", "$", "property", "->", "getParams", "(", ")", ",", "'snippetType'", ")", ";", "$", "default", "=", "$", "this", "->", "getParameterValue", "(", "$", "property", "->", "getParams", "(", ")", ",", "'default'", ",", "false", ")", ";", "$", "snippetArea", "=", "$", "default", ";", "if", "(", "true", "===", "$", "snippetArea", "||", "'true'", "===", "$", "snippetArea", ")", "{", "$", "snippetArea", "=", "$", "snippetType", ";", "}", "if", "(", "empty", "(", "$", "ids", ")", "&&", "$", "snippetArea", "&&", "$", "this", "->", "defaultEnabled", ")", "{", "$", "ids", "=", "$", "this", "->", "loadSnippetAreaIds", "(", "$", "webspaceKey", ",", "$", "snippetArea", ",", "$", "locale", ")", ";", "}", "return", "$", "this", "->", "snippetResolver", "->", "resolve", "(", "$", "ids", ",", "$", "webspaceKey", ",", "$", "locale", ",", "$", "shadowLocale", ")", ";", "}" ]
Returns snippets with given property value.
[ "Returns", "snippets", "with", "given", "property", "value", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Content/SnippetContent.php#L168-L195
train
sulu/sulu
src/Sulu/Bundle/SnippetBundle/Content/SnippetContent.php
SnippetContent.getParameterValue
private function getParameterValue(array $parameter, $name, $default = null) { if (!array_key_exists($name, $parameter)) { return $default; } return $parameter[$name]->getValue(); }
php
private function getParameterValue(array $parameter, $name, $default = null) { if (!array_key_exists($name, $parameter)) { return $default; } return $parameter[$name]->getValue(); }
[ "private", "function", "getParameterValue", "(", "array", "$", "parameter", ",", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "parameter", ")", ")", "{", "return", "$", "default", ";", "}", "return", "$", "parameter", "[", "$", "name", "]", "->", "getValue", "(", ")", ";", "}" ]
Returns value of parameter. If parameter not exists the default will be returned. @param PropertyParameter[] $parameter @param string $name @param mixed $default @return mixed
[ "Returns", "value", "of", "parameter", ".", "If", "parameter", "not", "exists", "the", "default", "will", "be", "returned", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Content/SnippetContent.php#L230-L237
train
sulu/sulu
src/Sulu/Component/Export/Export.php
Export.getPropertyData
protected function getPropertyData(PropertyMetadata $property, $propertyValue) { return $this->createProperty( $property->getName(), $this->exportManager->export($property->getType(), $propertyValue), $this->exportManager->getOptions($property->getType(), $this->format), $property->getType() ); }
php
protected function getPropertyData(PropertyMetadata $property, $propertyValue) { return $this->createProperty( $property->getName(), $this->exportManager->export($property->getType(), $propertyValue), $this->exportManager->getOptions($property->getType(), $this->format), $property->getType() ); }
[ "protected", "function", "getPropertyData", "(", "PropertyMetadata", "$", "property", ",", "$", "propertyValue", ")", "{", "return", "$", "this", "->", "createProperty", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "this", "->", "exportManager", "->", "export", "(", "$", "property", "->", "getType", "(", ")", ",", "$", "propertyValue", ")", ",", "$", "this", "->", "exportManager", "->", "getOptions", "(", "$", "property", "->", "getType", "(", ")", ",", "$", "this", "->", "format", ")", ",", "$", "property", "->", "getType", "(", ")", ")", ";", "}" ]
Creates and returns a property-array. @param PropertyMetadata $property @param PropertyValue $propertyValue @return array
[ "Creates", "and", "returns", "a", "property", "-", "array", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Export/Export.php#L86-L94
train
sulu/sulu
src/Sulu/Component/Export/Export.php
Export.getBlockPropertyData
protected function getBlockPropertyData(BlockMetadata $property, $propertyValue) { $children = []; $blockDataList = $this->exportManager->export($property->getType(), $propertyValue); foreach ($blockDataList as $blockData) { $blockType = $blockData['type']; $block = $this->getPropertiesContentData( $property->getComponentByName($blockType)->getChildren(), $blockData ); $block['type'] = $this->createProperty( 'type', $blockType, $this->exportManager->getOptions($property->getType(), $this->format), $property->getType() . '_type' ); $children[] = $block; } return $this->createProperty( $property->getName(), null, $this->exportManager->getOptions($property->getType(), $this->format), $property->getType(), $children ); }
php
protected function getBlockPropertyData(BlockMetadata $property, $propertyValue) { $children = []; $blockDataList = $this->exportManager->export($property->getType(), $propertyValue); foreach ($blockDataList as $blockData) { $blockType = $blockData['type']; $block = $this->getPropertiesContentData( $property->getComponentByName($blockType)->getChildren(), $blockData ); $block['type'] = $this->createProperty( 'type', $blockType, $this->exportManager->getOptions($property->getType(), $this->format), $property->getType() . '_type' ); $children[] = $block; } return $this->createProperty( $property->getName(), null, $this->exportManager->getOptions($property->getType(), $this->format), $property->getType(), $children ); }
[ "protected", "function", "getBlockPropertyData", "(", "BlockMetadata", "$", "property", ",", "$", "propertyValue", ")", "{", "$", "children", "=", "[", "]", ";", "$", "blockDataList", "=", "$", "this", "->", "exportManager", "->", "export", "(", "$", "property", "->", "getType", "(", ")", ",", "$", "propertyValue", ")", ";", "foreach", "(", "$", "blockDataList", "as", "$", "blockData", ")", "{", "$", "blockType", "=", "$", "blockData", "[", "'type'", "]", ";", "$", "block", "=", "$", "this", "->", "getPropertiesContentData", "(", "$", "property", "->", "getComponentByName", "(", "$", "blockType", ")", "->", "getChildren", "(", ")", ",", "$", "blockData", ")", ";", "$", "block", "[", "'type'", "]", "=", "$", "this", "->", "createProperty", "(", "'type'", ",", "$", "blockType", ",", "$", "this", "->", "exportManager", "->", "getOptions", "(", "$", "property", "->", "getType", "(", ")", ",", "$", "this", "->", "format", ")", ",", "$", "property", "->", "getType", "(", ")", ".", "'_type'", ")", ";", "$", "children", "[", "]", "=", "$", "block", ";", "}", "return", "$", "this", "->", "createProperty", "(", "$", "property", "->", "getName", "(", ")", ",", "null", ",", "$", "this", "->", "exportManager", "->", "getOptions", "(", "$", "property", "->", "getType", "(", ")", ",", "$", "this", "->", "format", ")", ",", "$", "property", "->", "getType", "(", ")", ",", "$", "children", ")", ";", "}" ]
Creates and Returns a property-array for content-type Block. @param BlockMetadata $property @param PropertyValue $propertyValue @return array
[ "Creates", "and", "Returns", "a", "property", "-", "array", "for", "content", "-", "type", "Block", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Export/Export.php#L104-L135
train
sulu/sulu
src/Sulu/Component/Export/Export.php
Export.getPropertiesContentData
protected function getPropertiesContentData($properties, $propertyValues) { $contentData = []; foreach ($properties as $property) { if ($this->exportManager->hasExport($property->getType(), $this->format)) { if (!isset($propertyValues[$property->getName()])) { continue; } $propertyValue = $propertyValues[$property->getName()]; if ($property instanceof BlockMetadata) { $data = $this->getBlockPropertyData($property, $propertyValue); } else { $data = $this->getPropertyData($property, $propertyValue); } $contentData[$property->getName()] = $data; } } return $contentData; }
php
protected function getPropertiesContentData($properties, $propertyValues) { $contentData = []; foreach ($properties as $property) { if ($this->exportManager->hasExport($property->getType(), $this->format)) { if (!isset($propertyValues[$property->getName()])) { continue; } $propertyValue = $propertyValues[$property->getName()]; if ($property instanceof BlockMetadata) { $data = $this->getBlockPropertyData($property, $propertyValue); } else { $data = $this->getPropertyData($property, $propertyValue); } $contentData[$property->getName()] = $data; } } return $contentData; }
[ "protected", "function", "getPropertiesContentData", "(", "$", "properties", ",", "$", "propertyValues", ")", "{", "$", "contentData", "=", "[", "]", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "if", "(", "$", "this", "->", "exportManager", "->", "hasExport", "(", "$", "property", "->", "getType", "(", ")", ",", "$", "this", "->", "format", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "propertyValues", "[", "$", "property", "->", "getName", "(", ")", "]", ")", ")", "{", "continue", ";", "}", "$", "propertyValue", "=", "$", "propertyValues", "[", "$", "property", "->", "getName", "(", ")", "]", ";", "if", "(", "$", "property", "instanceof", "BlockMetadata", ")", "{", "$", "data", "=", "$", "this", "->", "getBlockPropertyData", "(", "$", "property", ",", "$", "propertyValue", ")", ";", "}", "else", "{", "$", "data", "=", "$", "this", "->", "getPropertyData", "(", "$", "property", ",", "$", "propertyValue", ")", ";", "}", "$", "contentData", "[", "$", "property", "->", "getName", "(", ")", "]", "=", "$", "data", ";", "}", "}", "return", "$", "contentData", ";", "}" ]
Returns the Content as a flat array. @param PropertyMetadata[] $properties @param $propertyValues @return array
[ "Returns", "the", "Content", "as", "a", "flat", "array", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Export/Export.php#L173-L196
train
sulu/sulu
src/Sulu/Component/Export/Export.php
Export.getContentData
protected function getContentData($document, $locale) { /** @var BasePageDocument $loadedDocument */ $loadedDocument = $this->documentManager->find($document->getUuid(), $locale); /** @var \Sulu\Component\Content\Metadata\StructureMetadata $metaData */ $metaData = $this->documentInspector->getStructureMetadata($document); $propertyValues = $loadedDocument->getStructure()->toArray(); $properties = $metaData->getProperties(); $contentData = $this->getPropertiesContentData($properties, $propertyValues); return $contentData; }
php
protected function getContentData($document, $locale) { /** @var BasePageDocument $loadedDocument */ $loadedDocument = $this->documentManager->find($document->getUuid(), $locale); /** @var \Sulu\Component\Content\Metadata\StructureMetadata $metaData */ $metaData = $this->documentInspector->getStructureMetadata($document); $propertyValues = $loadedDocument->getStructure()->toArray(); $properties = $metaData->getProperties(); $contentData = $this->getPropertiesContentData($properties, $propertyValues); return $contentData; }
[ "protected", "function", "getContentData", "(", "$", "document", ",", "$", "locale", ")", "{", "/** @var BasePageDocument $loadedDocument */", "$", "loadedDocument", "=", "$", "this", "->", "documentManager", "->", "find", "(", "$", "document", "->", "getUuid", "(", ")", ",", "$", "locale", ")", ";", "/** @var \\Sulu\\Component\\Content\\Metadata\\StructureMetadata $metaData */", "$", "metaData", "=", "$", "this", "->", "documentInspector", "->", "getStructureMetadata", "(", "$", "document", ")", ";", "$", "propertyValues", "=", "$", "loadedDocument", "->", "getStructure", "(", ")", "->", "toArray", "(", ")", ";", "$", "properties", "=", "$", "metaData", "->", "getProperties", "(", ")", ";", "$", "contentData", "=", "$", "this", "->", "getPropertiesContentData", "(", "$", "properties", ",", "$", "propertyValues", ")", ";", "return", "$", "contentData", ";", "}" ]
Returns a array of the given content data of the document. @param $document @param $locale @return array @throws DocumentManagerException
[ "Returns", "a", "array", "of", "the", "given", "content", "data", "of", "the", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Export/Export.php#L208-L222
train
sulu/sulu
src/Sulu/Component/Export/Export.php
Export.getTemplate
protected function getTemplate($format) { if (!isset($this->formatFilePaths[$format])) { throw new \Exception(sprintf('No format "%s" configured for Snippet export', $format)); } $templatePath = $this->formatFilePaths[$format]; if (!$this->templating->exists($templatePath)) { throw new \Exception(sprintf('No template file "%s" found for Snippet export', $format)); } return $templatePath; }
php
protected function getTemplate($format) { if (!isset($this->formatFilePaths[$format])) { throw new \Exception(sprintf('No format "%s" configured for Snippet export', $format)); } $templatePath = $this->formatFilePaths[$format]; if (!$this->templating->exists($templatePath)) { throw new \Exception(sprintf('No template file "%s" found for Snippet export', $format)); } return $templatePath; }
[ "protected", "function", "getTemplate", "(", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "formatFilePaths", "[", "$", "format", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'No format \"%s\" configured for Snippet export'", ",", "$", "format", ")", ")", ";", "}", "$", "templatePath", "=", "$", "this", "->", "formatFilePaths", "[", "$", "format", "]", ";", "if", "(", "!", "$", "this", "->", "templating", "->", "exists", "(", "$", "templatePath", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'No template file \"%s\" found for Snippet export'", ",", "$", "format", ")", ")", ";", "}", "return", "$", "templatePath", ";", "}" ]
Returns export template for given format like XLIFF1.2. @param $format @return string @throws \Exception
[ "Returns", "export", "template", "for", "given", "format", "like", "XLIFF1", ".", "2", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Export/Export.php#L233-L246
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php
MappingSubscriber.persistReference
private function persistReference( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, $fieldMapping ) { $referenceDocument = $accessor->get($fieldName); if (!$referenceDocument) { return; } if ($fieldMapping['multiple']) { throw new \InvalidArgumentException( sprintf( 'Mapping references as multiple not currently supported (when mapping "%s")', $fieldName ) ); } try { $referenceNode = $this->documentRegistry->getNodeForDocument($referenceDocument); $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $node->setProperty($phpcrName, $referenceNode); } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
php
private function persistReference( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, $fieldMapping ) { $referenceDocument = $accessor->get($fieldName); if (!$referenceDocument) { return; } if ($fieldMapping['multiple']) { throw new \InvalidArgumentException( sprintf( 'Mapping references as multiple not currently supported (when mapping "%s")', $fieldName ) ); } try { $referenceNode = $this->documentRegistry->getNodeForDocument($referenceDocument); $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $node->setProperty($phpcrName, $referenceNode); } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
[ "private", "function", "persistReference", "(", "NodeInterface", "$", "node", ",", "DocumentAccessor", "$", "accessor", ",", "$", "fieldName", ",", "$", "locale", ",", "$", "fieldMapping", ")", "{", "$", "referenceDocument", "=", "$", "accessor", "->", "get", "(", "$", "fieldName", ")", ";", "if", "(", "!", "$", "referenceDocument", ")", "{", "return", ";", "}", "if", "(", "$", "fieldMapping", "[", "'multiple'", "]", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Mapping references as multiple not currently supported (when mapping \"%s\")'", ",", "$", "fieldName", ")", ")", ";", "}", "try", "{", "$", "referenceNode", "=", "$", "this", "->", "documentRegistry", "->", "getNodeForDocument", "(", "$", "referenceDocument", ")", ";", "$", "phpcrName", "=", "$", "this", "->", "encoder", "->", "encode", "(", "$", "fieldMapping", "[", "'encoding'", "]", ",", "$", "fieldMapping", "[", "'property'", "]", ",", "$", "locale", ")", ";", "$", "node", "->", "setProperty", "(", "$", "phpcrName", ",", "$", "referenceNode", ")", ";", "}", "catch", "(", "InvalidLocaleException", "$", "ex", ")", "{", "// arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding)", "return", ";", "}", "}" ]
Persist a reference field type. @param NodeInterface $node @param DocumentAccessor $accessor @param mixed $fieldName @param mixed $locale @param mixed $fieldMapping
[ "Persist", "a", "reference", "field", "type", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php#L120-L150
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php
MappingSubscriber.persistGeneric
private function persistGeneric( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $value = $accessor->get($fieldName); $this->validateFieldValue($value, $fieldName, $fieldMapping); $node->setProperty($phpcrName, $value); } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
php
private function persistGeneric( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $value = $accessor->get($fieldName); $this->validateFieldValue($value, $fieldName, $fieldMapping); $node->setProperty($phpcrName, $value); } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
[ "private", "function", "persistGeneric", "(", "NodeInterface", "$", "node", ",", "DocumentAccessor", "$", "accessor", ",", "$", "fieldName", ",", "$", "locale", ",", "array", "$", "fieldMapping", ")", "{", "try", "{", "$", "phpcrName", "=", "$", "this", "->", "encoder", "->", "encode", "(", "$", "fieldMapping", "[", "'encoding'", "]", ",", "$", "fieldMapping", "[", "'property'", "]", ",", "$", "locale", ")", ";", "$", "value", "=", "$", "accessor", "->", "get", "(", "$", "fieldName", ")", ";", "$", "this", "->", "validateFieldValue", "(", "$", "value", ",", "$", "fieldName", ",", "$", "fieldMapping", ")", ";", "$", "node", "->", "setProperty", "(", "$", "phpcrName", ",", "$", "value", ")", ";", "}", "catch", "(", "InvalidLocaleException", "$", "ex", ")", "{", "// arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding)", "return", ";", "}", "}" ]
Persist "scalar" field types. @param NodeInterface $node @param DocumentAccessor $accessor @param mixed $fieldName @param mixed $locale @param array $fieldMapping
[ "Persist", "scalar", "field", "types", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php#L161-L177
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php
MappingSubscriber.hydrateReferenceField
private function hydrateReferenceField( NodeInterface $node, $document, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping, array $options ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $referencedNode = $node->getPropertyValueWithDefault( $phpcrName, $this->getDefaultValue($fieldMapping) ); if ($referencedNode) { $accessor->set( $fieldName, $this->proxyFactory->createProxyForNode($document, $referencedNode, $options) ); } } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
php
private function hydrateReferenceField( NodeInterface $node, $document, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping, array $options ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $referencedNode = $node->getPropertyValueWithDefault( $phpcrName, $this->getDefaultValue($fieldMapping) ); if ($referencedNode) { $accessor->set( $fieldName, $this->proxyFactory->createProxyForNode($document, $referencedNode, $options) ); } } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
[ "private", "function", "hydrateReferenceField", "(", "NodeInterface", "$", "node", ",", "$", "document", ",", "DocumentAccessor", "$", "accessor", ",", "$", "fieldName", ",", "$", "locale", ",", "array", "$", "fieldMapping", ",", "array", "$", "options", ")", "{", "try", "{", "$", "phpcrName", "=", "$", "this", "->", "encoder", "->", "encode", "(", "$", "fieldMapping", "[", "'encoding'", "]", ",", "$", "fieldMapping", "[", "'property'", "]", ",", "$", "locale", ")", ";", "$", "referencedNode", "=", "$", "node", "->", "getPropertyValueWithDefault", "(", "$", "phpcrName", ",", "$", "this", "->", "getDefaultValue", "(", "$", "fieldMapping", ")", ")", ";", "if", "(", "$", "referencedNode", ")", "{", "$", "accessor", "->", "set", "(", "$", "fieldName", ",", "$", "this", "->", "proxyFactory", "->", "createProxyForNode", "(", "$", "document", ",", "$", "referencedNode", ",", "$", "options", ")", ")", ";", "}", "}", "catch", "(", "InvalidLocaleException", "$", "ex", ")", "{", "// arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding)", "return", ";", "}", "}" ]
Hydrate reference field types. @param NodeInterface $node @param mixed $document @param DocumentAccessor $accessor @param mixed $fieldName @param mixed $locale @param array $fieldMapping @param array $options
[ "Hydrate", "reference", "field", "types", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php#L265-L291
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php
MappingSubscriber.hydrateGenericField
private function hydrateGenericField( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $value = $node->getPropertyValueWithDefault( $phpcrName, $this->getDefaultValue($fieldMapping) ); $accessor->set($fieldName, $value); } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
php
private function hydrateGenericField( NodeInterface $node, DocumentAccessor $accessor, $fieldName, $locale, array $fieldMapping ) { try { $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale); $value = $node->getPropertyValueWithDefault( $phpcrName, $this->getDefaultValue($fieldMapping) ); $accessor->set($fieldName, $value); } catch (InvalidLocaleException $ex) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return; } }
[ "private", "function", "hydrateGenericField", "(", "NodeInterface", "$", "node", ",", "DocumentAccessor", "$", "accessor", ",", "$", "fieldName", ",", "$", "locale", ",", "array", "$", "fieldMapping", ")", "{", "try", "{", "$", "phpcrName", "=", "$", "this", "->", "encoder", "->", "encode", "(", "$", "fieldMapping", "[", "'encoding'", "]", ",", "$", "fieldMapping", "[", "'property'", "]", ",", "$", "locale", ")", ";", "$", "value", "=", "$", "node", "->", "getPropertyValueWithDefault", "(", "$", "phpcrName", ",", "$", "this", "->", "getDefaultValue", "(", "$", "fieldMapping", ")", ")", ";", "$", "accessor", "->", "set", "(", "$", "fieldName", ",", "$", "value", ")", ";", "}", "catch", "(", "InvalidLocaleException", "$", "ex", ")", "{", "// arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding)", "return", ";", "}", "}" ]
Hydrate "scalar" field types. @param NodeInterface $node @param DocumentAccessor $accessor @param mixed $fieldName @param mixed $locale @param array $fieldMapping
[ "Hydrate", "scalar", "field", "types", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php#L302-L320
train
sulu/sulu
src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php
WebspaceSerializeEventSubscriber.appendPortalInformation
private function appendPortalInformation(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $portalInformation = $this->webspaceManager->getPortalInformationsByWebspaceKey( $this->environment, $webspace->getKey() ); $portalInformation = $context->accept(array_values($portalInformation)); $visitor->addData('portalInformation', $portalInformation); }
php
private function appendPortalInformation(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $portalInformation = $this->webspaceManager->getPortalInformationsByWebspaceKey( $this->environment, $webspace->getKey() ); $portalInformation = $context->accept(array_values($portalInformation)); $visitor->addData('portalInformation', $portalInformation); }
[ "private", "function", "appendPortalInformation", "(", "Webspace", "$", "webspace", ",", "Context", "$", "context", ",", "JsonSerializationVisitor", "$", "visitor", ")", "{", "$", "portalInformation", "=", "$", "this", "->", "webspaceManager", "->", "getPortalInformationsByWebspaceKey", "(", "$", "this", "->", "environment", ",", "$", "webspace", "->", "getKey", "(", ")", ")", ";", "$", "portalInformation", "=", "$", "context", "->", "accept", "(", "array_values", "(", "$", "portalInformation", ")", ")", ";", "$", "visitor", "->", "addData", "(", "'portalInformation'", ",", "$", "portalInformation", ")", ";", "}" ]
Extract portal-information and add them to serialization. @param Webspace $webspace @param Context $context @param JsonSerializationVisitor $visitor
[ "Extract", "portal", "-", "information", "and", "add", "them", "to", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php#L94-L103
train
sulu/sulu
src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php
WebspaceSerializeEventSubscriber.appendUrls
private function appendUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $urls = $this->webspaceUrlProvider->getUrls($webspace, $this->environment); $urls = $context->accept($urls); $visitor->addData('urls', $urls); }
php
private function appendUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $urls = $this->webspaceUrlProvider->getUrls($webspace, $this->environment); $urls = $context->accept($urls); $visitor->addData('urls', $urls); }
[ "private", "function", "appendUrls", "(", "Webspace", "$", "webspace", ",", "Context", "$", "context", ",", "JsonSerializationVisitor", "$", "visitor", ")", "{", "$", "urls", "=", "$", "this", "->", "webspaceUrlProvider", "->", "getUrls", "(", "$", "webspace", ",", "$", "this", "->", "environment", ")", ";", "$", "urls", "=", "$", "context", "->", "accept", "(", "$", "urls", ")", ";", "$", "visitor", "->", "addData", "(", "'urls'", ",", "$", "urls", ")", ";", "}" ]
Extract urls and add them to serialization. @param Webspace $webspace @param Context $context @param JsonSerializationVisitor $visitor
[ "Extract", "urls", "and", "add", "them", "to", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php#L112-L117
train
sulu/sulu
src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php
WebspaceSerializeEventSubscriber.appendCustomUrls
private function appendCustomUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $customUrls = []; foreach ($webspace->getPortals() as $portal) { $customUrls = array_merge( $customUrls, $this->getCustomUrlsForEnvironment($portal, $portal->getEnvironment($this->environment), $context) ); } $customUrls = $context->accept($customUrls); $visitor->addData('customUrls', $customUrls); }
php
private function appendCustomUrls(Webspace $webspace, Context $context, JsonSerializationVisitor $visitor) { $customUrls = []; foreach ($webspace->getPortals() as $portal) { $customUrls = array_merge( $customUrls, $this->getCustomUrlsForEnvironment($portal, $portal->getEnvironment($this->environment), $context) ); } $customUrls = $context->accept($customUrls); $visitor->addData('customUrls', $customUrls); }
[ "private", "function", "appendCustomUrls", "(", "Webspace", "$", "webspace", ",", "Context", "$", "context", ",", "JsonSerializationVisitor", "$", "visitor", ")", "{", "$", "customUrls", "=", "[", "]", ";", "foreach", "(", "$", "webspace", "->", "getPortals", "(", ")", "as", "$", "portal", ")", "{", "$", "customUrls", "=", "array_merge", "(", "$", "customUrls", ",", "$", "this", "->", "getCustomUrlsForEnvironment", "(", "$", "portal", ",", "$", "portal", "->", "getEnvironment", "(", "$", "this", "->", "environment", ")", ",", "$", "context", ")", ")", ";", "}", "$", "customUrls", "=", "$", "context", "->", "accept", "(", "$", "customUrls", ")", ";", "$", "visitor", "->", "addData", "(", "'customUrls'", ",", "$", "customUrls", ")", ";", "}" ]
Extract custom-url and add them to serialization. @param Webspace $webspace @param Context $context @param JsonSerializationVisitor $visitor
[ "Extract", "custom", "-", "url", "and", "add", "them", "to", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php#L126-L138
train
sulu/sulu
src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php
WebspaceSerializeEventSubscriber.getCustomUrlsForEnvironment
private function getCustomUrlsForEnvironment(Portal $portal, Environment $environment, Context $context) { $customUrls = []; foreach ($environment->getCustomUrls() as $customUrl) { $customUrl = $context->accept($customUrl); $customUrl['locales'] = $context->accept($portal->getLocalizations()); $customUrls[] = $customUrl; } return $customUrls; }
php
private function getCustomUrlsForEnvironment(Portal $portal, Environment $environment, Context $context) { $customUrls = []; foreach ($environment->getCustomUrls() as $customUrl) { $customUrl = $context->accept($customUrl); $customUrl['locales'] = $context->accept($portal->getLocalizations()); $customUrls[] = $customUrl; } return $customUrls; }
[ "private", "function", "getCustomUrlsForEnvironment", "(", "Portal", "$", "portal", ",", "Environment", "$", "environment", ",", "Context", "$", "context", ")", "{", "$", "customUrls", "=", "[", "]", ";", "foreach", "(", "$", "environment", "->", "getCustomUrls", "(", ")", "as", "$", "customUrl", ")", "{", "$", "customUrl", "=", "$", "context", "->", "accept", "(", "$", "customUrl", ")", ";", "$", "customUrl", "[", "'locales'", "]", "=", "$", "context", "->", "accept", "(", "$", "portal", "->", "getLocalizations", "(", ")", ")", ";", "$", "customUrls", "[", "]", "=", "$", "customUrl", ";", "}", "return", "$", "customUrls", ";", "}" ]
Returns custom-url data with the connected locales. @param Portal $portal @param Environment $environment @param Context $context @return array
[ "Returns", "custom", "-", "url", "data", "with", "the", "connected", "locales", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/EventListener/WebspaceSerializeEventSubscriber.php#L149-L159
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Search/EventListener/HitListener.php
HitListener.onHit
public function onHit(HitEvent $event) { if (false === $event->getMetadata()->reflection->isSubclassOf(BasePageDocument::class)) { return; } $document = $event->getHit()->getDocument(); if ('/' !== $document->getUrl()[0]) { // is absolute URL return; } $url = sprintf( '%s/%s', rtrim($this->requestAnalyzer->getResourceLocatorPrefix(), '/'), ltrim($document->getUrl(), '/') ); $document->setUrl($url); }
php
public function onHit(HitEvent $event) { if (false === $event->getMetadata()->reflection->isSubclassOf(BasePageDocument::class)) { return; } $document = $event->getHit()->getDocument(); if ('/' !== $document->getUrl()[0]) { // is absolute URL return; } $url = sprintf( '%s/%s', rtrim($this->requestAnalyzer->getResourceLocatorPrefix(), '/'), ltrim($document->getUrl(), '/') ); $document->setUrl($url); }
[ "public", "function", "onHit", "(", "HitEvent", "$", "event", ")", "{", "if", "(", "false", "===", "$", "event", "->", "getMetadata", "(", ")", "->", "reflection", "->", "isSubclassOf", "(", "BasePageDocument", "::", "class", ")", ")", "{", "return", ";", "}", "$", "document", "=", "$", "event", "->", "getHit", "(", ")", "->", "getDocument", "(", ")", ";", "if", "(", "'/'", "!==", "$", "document", "->", "getUrl", "(", ")", "[", "0", "]", ")", "{", "// is absolute URL", "return", ";", "}", "$", "url", "=", "sprintf", "(", "'%s/%s'", ",", "rtrim", "(", "$", "this", "->", "requestAnalyzer", "->", "getResourceLocatorPrefix", "(", ")", ",", "'/'", ")", ",", "ltrim", "(", "$", "document", "->", "getUrl", "(", ")", ",", "'/'", ")", ")", ";", "$", "document", "->", "setUrl", "(", "$", "url", ")", ";", "}" ]
Prefix url of document with current resourcelocator prefix. @param HitEvent $event
[ "Prefix", "url", "of", "document", "with", "current", "resourcelocator", "prefix", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Search/EventListener/HitListener.php#L39-L59
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Serializer/Subscriber/PathSubscriber.php
PathSubscriber.onPostSerialize
public function onPostSerialize(ObjectEvent $event) { $visitor = $event->getVisitor(); $document = $event->getObject(); if (!$document instanceof PathBehavior || !$this->documentRegistry->hasDocument($document)) { return; } $visitor->addData('path', $this->documentInspector->getContentPath($document)); }
php
public function onPostSerialize(ObjectEvent $event) { $visitor = $event->getVisitor(); $document = $event->getObject(); if (!$document instanceof PathBehavior || !$this->documentRegistry->hasDocument($document)) { return; } $visitor->addData('path', $this->documentInspector->getContentPath($document)); }
[ "public", "function", "onPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "document", "=", "$", "event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "PathBehavior", "||", "!", "$", "this", "->", "documentRegistry", "->", "hasDocument", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "visitor", "->", "addData", "(", "'path'", ",", "$", "this", "->", "documentInspector", "->", "getContentPath", "(", "$", "document", ")", ")", ";", "}" ]
Adds the relative path to the serialization. @param ObjectEvent $event
[ "Adds", "the", "relative", "path", "to", "the", "serialization", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Serializer/Subscriber/PathSubscriber.php#L61-L71
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/WebspaceController.php
WebspaceController.cgetAction
public function cgetAction(Request $request) { $checkForPermissions = $request->get('checkForPermissions', true); $locale = $this->getRequestParameter($request, 'locale', true); $webspaces = []; $securityChecker = $this->get('sulu_security.security_checker'); foreach ($this->get('sulu_core.webspace.webspace_manager')->getWebspaceCollection() as $webspace) { if ($checkForPermissions) { $securityContext = $this->getSecurityContextByWebspace($webspace->getKey()); if (!$securityChecker->hasPermission(new SecurityCondition($securityContext), PermissionTypes::VIEW)) { continue; } } $webspaces[] = $webspace; } $context = new Context(); $context->setAttribute('locale', $locale); $view = $this->view(new CollectionRepresentation($webspaces, 'webspaces')); $view->setContext($context); return $this->handleView($view); }
php
public function cgetAction(Request $request) { $checkForPermissions = $request->get('checkForPermissions', true); $locale = $this->getRequestParameter($request, 'locale', true); $webspaces = []; $securityChecker = $this->get('sulu_security.security_checker'); foreach ($this->get('sulu_core.webspace.webspace_manager')->getWebspaceCollection() as $webspace) { if ($checkForPermissions) { $securityContext = $this->getSecurityContextByWebspace($webspace->getKey()); if (!$securityChecker->hasPermission(new SecurityCondition($securityContext), PermissionTypes::VIEW)) { continue; } } $webspaces[] = $webspace; } $context = new Context(); $context->setAttribute('locale', $locale); $view = $this->view(new CollectionRepresentation($webspaces, 'webspaces')); $view->setContext($context); return $this->handleView($view); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ")", "{", "$", "checkForPermissions", "=", "$", "request", "->", "get", "(", "'checkForPermissions'", ",", "true", ")", ";", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "true", ")", ";", "$", "webspaces", "=", "[", "]", ";", "$", "securityChecker", "=", "$", "this", "->", "get", "(", "'sulu_security.security_checker'", ")", ";", "foreach", "(", "$", "this", "->", "get", "(", "'sulu_core.webspace.webspace_manager'", ")", "->", "getWebspaceCollection", "(", ")", "as", "$", "webspace", ")", "{", "if", "(", "$", "checkForPermissions", ")", "{", "$", "securityContext", "=", "$", "this", "->", "getSecurityContextByWebspace", "(", "$", "webspace", "->", "getKey", "(", ")", ")", ";", "if", "(", "!", "$", "securityChecker", "->", "hasPermission", "(", "new", "SecurityCondition", "(", "$", "securityContext", ")", ",", "PermissionTypes", "::", "VIEW", ")", ")", "{", "continue", ";", "}", "}", "$", "webspaces", "[", "]", "=", "$", "webspace", ";", "}", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setAttribute", "(", "'locale'", ",", "$", "locale", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "new", "CollectionRepresentation", "(", "$", "webspaces", ",", "'webspaces'", ")", ")", ";", "$", "view", "->", "setContext", "(", "$", "context", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Returns webspaces. @return Response
[ "Returns", "webspaces", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/WebspaceController.php#L38-L62
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/WebspaceController.php
WebspaceController.getAction
public function getAction($webspaceKey) { return $this->handleView( $this->view($this->get('sulu_core.webspace.webspace_manager')->findWebspaceByKey($webspaceKey)) ); }
php
public function getAction($webspaceKey) { return $this->handleView( $this->view($this->get('sulu_core.webspace.webspace_manager')->findWebspaceByKey($webspaceKey)) ); }
[ "public", "function", "getAction", "(", "$", "webspaceKey", ")", "{", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "this", "->", "get", "(", "'sulu_core.webspace.webspace_manager'", ")", "->", "findWebspaceByKey", "(", "$", "webspaceKey", ")", ")", ")", ";", "}" ]
Returns webspace config by key. @param string $webspaceKey @return Response
[ "Returns", "webspace", "config", "by", "key", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/WebspaceController.php#L71-L76
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/SmartContentItemController.php
SmartContentItemController.getItemsAction
public function getItemsAction(Request $request) { // prepare filters and options $providerAlias = $this->getRequestParameter($request, 'provider', true); $filters = $request->query->all(); $filters['excluded'] = array_filter(explode(',', $this->getRequestParameter($request, 'excluded'))); if (isset($filters['categories'])) { $filters['categories'] = explode(',', $this->getRequestParameter($request, 'categories')); } if (isset($filters['tags'])) { $filters['tags'] = explode(',', $this->getRequestParameter($request, 'tags')); } if (isset($filters['sortBy'])) { $filters['sortBy'] = explode(',', $this->getRequestParameter($request, 'sortBy')); } $filters = array_filter($filters); $options = [ 'webspaceKey' => $this->getRequestParameter($request, 'webspace'), 'locale' => $this->getLocale($request), ]; // resolve tags if they exists in filters if (isset($filters['tags'])) { $filters['tags'] = $this->get('sulu_tag.tag_manager')->resolveTagNames($filters['tags']); } // prepare provider $dataProviderPool = $this->get('sulu_page.smart_content.data_provider_pool'); $provider = $dataProviderPool->get($providerAlias); $params = array_merge( $provider->getDefaultPropertyParameter(), $this->getParams(json_decode($request->get('params', '{}'), true)) ); // resolve datasource and items $data = $provider->resolveDataItems( $filters, $params, $options, (isset($filters['limitResult']) ? $filters['limitResult'] : null) ); $items = $data->getItems(); $datasource = $provider->resolveDatasource($request->get('dataSource'), [], $options); return $this->handleView($this->view(new ItemCollectionRepresentation($items, $datasource))); }
php
public function getItemsAction(Request $request) { // prepare filters and options $providerAlias = $this->getRequestParameter($request, 'provider', true); $filters = $request->query->all(); $filters['excluded'] = array_filter(explode(',', $this->getRequestParameter($request, 'excluded'))); if (isset($filters['categories'])) { $filters['categories'] = explode(',', $this->getRequestParameter($request, 'categories')); } if (isset($filters['tags'])) { $filters['tags'] = explode(',', $this->getRequestParameter($request, 'tags')); } if (isset($filters['sortBy'])) { $filters['sortBy'] = explode(',', $this->getRequestParameter($request, 'sortBy')); } $filters = array_filter($filters); $options = [ 'webspaceKey' => $this->getRequestParameter($request, 'webspace'), 'locale' => $this->getLocale($request), ]; // resolve tags if they exists in filters if (isset($filters['tags'])) { $filters['tags'] = $this->get('sulu_tag.tag_manager')->resolveTagNames($filters['tags']); } // prepare provider $dataProviderPool = $this->get('sulu_page.smart_content.data_provider_pool'); $provider = $dataProviderPool->get($providerAlias); $params = array_merge( $provider->getDefaultPropertyParameter(), $this->getParams(json_decode($request->get('params', '{}'), true)) ); // resolve datasource and items $data = $provider->resolveDataItems( $filters, $params, $options, (isset($filters['limitResult']) ? $filters['limitResult'] : null) ); $items = $data->getItems(); $datasource = $provider->resolveDatasource($request->get('dataSource'), [], $options); return $this->handleView($this->view(new ItemCollectionRepresentation($items, $datasource))); }
[ "public", "function", "getItemsAction", "(", "Request", "$", "request", ")", "{", "// prepare filters and options", "$", "providerAlias", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'provider'", ",", "true", ")", ";", "$", "filters", "=", "$", "request", "->", "query", "->", "all", "(", ")", ";", "$", "filters", "[", "'excluded'", "]", "=", "array_filter", "(", "explode", "(", "','", ",", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'excluded'", ")", ")", ")", ";", "if", "(", "isset", "(", "$", "filters", "[", "'categories'", "]", ")", ")", "{", "$", "filters", "[", "'categories'", "]", "=", "explode", "(", "','", ",", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'categories'", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "filters", "[", "'tags'", "]", ")", ")", "{", "$", "filters", "[", "'tags'", "]", "=", "explode", "(", "','", ",", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'tags'", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "filters", "[", "'sortBy'", "]", ")", ")", "{", "$", "filters", "[", "'sortBy'", "]", "=", "explode", "(", "','", ",", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'sortBy'", ")", ")", ";", "}", "$", "filters", "=", "array_filter", "(", "$", "filters", ")", ";", "$", "options", "=", "[", "'webspaceKey'", "=>", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'webspace'", ")", ",", "'locale'", "=>", "$", "this", "->", "getLocale", "(", "$", "request", ")", ",", "]", ";", "// resolve tags if they exists in filters", "if", "(", "isset", "(", "$", "filters", "[", "'tags'", "]", ")", ")", "{", "$", "filters", "[", "'tags'", "]", "=", "$", "this", "->", "get", "(", "'sulu_tag.tag_manager'", ")", "->", "resolveTagNames", "(", "$", "filters", "[", "'tags'", "]", ")", ";", "}", "// prepare provider", "$", "dataProviderPool", "=", "$", "this", "->", "get", "(", "'sulu_page.smart_content.data_provider_pool'", ")", ";", "$", "provider", "=", "$", "dataProviderPool", "->", "get", "(", "$", "providerAlias", ")", ";", "$", "params", "=", "array_merge", "(", "$", "provider", "->", "getDefaultPropertyParameter", "(", ")", ",", "$", "this", "->", "getParams", "(", "json_decode", "(", "$", "request", "->", "get", "(", "'params'", ",", "'{}'", ")", ",", "true", ")", ")", ")", ";", "// resolve datasource and items", "$", "data", "=", "$", "provider", "->", "resolveDataItems", "(", "$", "filters", ",", "$", "params", ",", "$", "options", ",", "(", "isset", "(", "$", "filters", "[", "'limitResult'", "]", ")", "?", "$", "filters", "[", "'limitResult'", "]", ":", "null", ")", ")", ";", "$", "items", "=", "$", "data", "->", "getItems", "(", ")", ";", "$", "datasource", "=", "$", "provider", "->", "resolveDatasource", "(", "$", "request", "->", "get", "(", "'dataSource'", ")", ",", "[", "]", ",", "$", "options", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "new", "ItemCollectionRepresentation", "(", "$", "items", ",", "$", "datasource", ")", ")", ")", ";", "}" ]
Resolves filter for smart-content UI. @param Request $request @return \Symfony\Component\HttpFoundation\Response @throws \Sulu\Component\Rest\Exception\MissingParameterException @throws \Sulu\Component\SmartContent\Exception\DataProviderNotExistsException
[ "Resolves", "filter", "for", "smart", "-", "content", "UI", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/SmartContentItemController.php#L37-L83
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/SmartContentItemController.php
SmartContentItemController.getParams
private function getParams(array $params) { $result = []; foreach ($params as $name => $item) { $value = $item['value']; if ('collection' === $item['type']) { $value = $this->getParams($value); } $result[$name] = new PropertyParameter($name, $value, $item['type']); } return $result; }
php
private function getParams(array $params) { $result = []; foreach ($params as $name => $item) { $value = $item['value']; if ('collection' === $item['type']) { $value = $this->getParams($value); } $result[$name] = new PropertyParameter($name, $value, $item['type']); } return $result; }
[ "private", "function", "getParams", "(", "array", "$", "params", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "name", "=>", "$", "item", ")", "{", "$", "value", "=", "$", "item", "[", "'value'", "]", ";", "if", "(", "'collection'", "===", "$", "item", "[", "'type'", "]", ")", "{", "$", "value", "=", "$", "this", "->", "getParams", "(", "$", "value", ")", ";", "}", "$", "result", "[", "$", "name", "]", "=", "new", "PropertyParameter", "(", "$", "name", ",", "$", "value", ",", "$", "item", "[", "'type'", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns property-parameter. @param array $params @return PropertyParameter[]
[ "Returns", "property", "-", "parameter", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/SmartContentItemController.php#L92-L105
train
sulu/sulu
src/Sulu/Component/CustomUrl/Routing/CustomUrlRouteProvider.php
CustomUrlRouteProvider.addHistoryRedirectToRouteCollection
private function addHistoryRedirectToRouteCollection( Request $request, RouteDocument $routeDocument, RouteCollection $collection, $webspaceKey ) { $resourceSegment = PathHelper::relativizePath( $routeDocument->getTargetDocument()->getPath(), $this->getRoutesPath($webspaceKey) ); $url = sprintf('%s://%s', $request->getScheme(), $resourceSegment); $collection->add( uniqid('custom_url_route_', true), new Route( $this->decodePathInfo($request->getPathInfo()), [ '_controller' => 'SuluWebsiteBundle:Redirect:redirect', '_finalized' => true, 'url' => $url, ] ) ); return $collection; }
php
private function addHistoryRedirectToRouteCollection( Request $request, RouteDocument $routeDocument, RouteCollection $collection, $webspaceKey ) { $resourceSegment = PathHelper::relativizePath( $routeDocument->getTargetDocument()->getPath(), $this->getRoutesPath($webspaceKey) ); $url = sprintf('%s://%s', $request->getScheme(), $resourceSegment); $collection->add( uniqid('custom_url_route_', true), new Route( $this->decodePathInfo($request->getPathInfo()), [ '_controller' => 'SuluWebsiteBundle:Redirect:redirect', '_finalized' => true, 'url' => $url, ] ) ); return $collection; }
[ "private", "function", "addHistoryRedirectToRouteCollection", "(", "Request", "$", "request", ",", "RouteDocument", "$", "routeDocument", ",", "RouteCollection", "$", "collection", ",", "$", "webspaceKey", ")", "{", "$", "resourceSegment", "=", "PathHelper", "::", "relativizePath", "(", "$", "routeDocument", "->", "getTargetDocument", "(", ")", "->", "getPath", "(", ")", ",", "$", "this", "->", "getRoutesPath", "(", "$", "webspaceKey", ")", ")", ";", "$", "url", "=", "sprintf", "(", "'%s://%s'", ",", "$", "request", "->", "getScheme", "(", ")", ",", "$", "resourceSegment", ")", ";", "$", "collection", "->", "add", "(", "uniqid", "(", "'custom_url_route_'", ",", "true", ")", ",", "new", "Route", "(", "$", "this", "->", "decodePathInfo", "(", "$", "request", "->", "getPathInfo", "(", ")", ")", ",", "[", "'_controller'", "=>", "'SuluWebsiteBundle:Redirect:redirect'", ",", "'_finalized'", "=>", "true", ",", "'url'", "=>", "$", "url", ",", "]", ")", ")", ";", "return", "$", "collection", ";", "}" ]
Add redirect to current custom-url. @param Request $request @param RouteDocument $routeDocument @param RouteCollection $collection @param string $webspaceKey @return RouteCollection
[ "Add", "redirect", "to", "current", "custom", "-", "url", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/CustomUrl/Routing/CustomUrlRouteProvider.php#L131-L157
train
sulu/sulu
src/Sulu/Component/Content/SmartContent/PageDataProvider.php
PageDataProvider.loadPaginated
private function loadPaginated(array $options, $limit, $page, $pageSize) { $pageSize = intval($pageSize); $offset = ($page - 1) * $pageSize; $position = $pageSize * $page; if (null !== $limit && $position >= $limit) { $pageSize = $limit - $offset; $loadLimit = $pageSize; } else { $loadLimit = $pageSize + 1; } return $this->contentQueryExecutor->execute( $options['webspaceKey'], [$options['locale']], $this->contentQueryBuilder, true, -1, $loadLimit, $offset ); }
php
private function loadPaginated(array $options, $limit, $page, $pageSize) { $pageSize = intval($pageSize); $offset = ($page - 1) * $pageSize; $position = $pageSize * $page; if (null !== $limit && $position >= $limit) { $pageSize = $limit - $offset; $loadLimit = $pageSize; } else { $loadLimit = $pageSize + 1; } return $this->contentQueryExecutor->execute( $options['webspaceKey'], [$options['locale']], $this->contentQueryBuilder, true, -1, $loadLimit, $offset ); }
[ "private", "function", "loadPaginated", "(", "array", "$", "options", ",", "$", "limit", ",", "$", "page", ",", "$", "pageSize", ")", "{", "$", "pageSize", "=", "intval", "(", "$", "pageSize", ")", ";", "$", "offset", "=", "(", "$", "page", "-", "1", ")", "*", "$", "pageSize", ";", "$", "position", "=", "$", "pageSize", "*", "$", "page", ";", "if", "(", "null", "!==", "$", "limit", "&&", "$", "position", ">=", "$", "limit", ")", "{", "$", "pageSize", "=", "$", "limit", "-", "$", "offset", ";", "$", "loadLimit", "=", "$", "pageSize", ";", "}", "else", "{", "$", "loadLimit", "=", "$", "pageSize", "+", "1", ";", "}", "return", "$", "this", "->", "contentQueryExecutor", "->", "execute", "(", "$", "options", "[", "'webspaceKey'", "]", ",", "[", "$", "options", "[", "'locale'", "]", "]", ",", "$", "this", "->", "contentQueryBuilder", ",", "true", ",", "-", "1", ",", "$", "loadLimit", ",", "$", "offset", ")", ";", "}" ]
Load paginated data. @param array $options @param int $limit @param int $page @param int $pageSize @return array
[ "Load", "paginated", "data", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/SmartContent/PageDataProvider.php#L295-L317
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php
ContentMapperSubscriber.handlePreRemove
public function handlePreRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $event = $this->getDeleteEvent($document); $this->deleteEvents[spl_object_hash($document)] = $event; $this->eventDispatcher->dispatch( ContentEvents::NODE_PRE_DELETE, $event ); }
php
public function handlePreRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $event = $this->getDeleteEvent($document); $this->deleteEvents[spl_object_hash($document)] = $event; $this->eventDispatcher->dispatch( ContentEvents::NODE_PRE_DELETE, $event ); }
[ "public", "function", "handlePreRemove", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "event", "=", "$", "this", "->", "getDeleteEvent", "(", "$", "document", ")", ";", "$", "this", "->", "deleteEvents", "[", "spl_object_hash", "(", "$", "document", ")", "]", "=", "$", "event", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ContentEvents", "::", "NODE_PRE_DELETE", ",", "$", "event", ")", ";", "}" ]
Dispatches the deprecated pre remove event. @param RemoveEvent $event
[ "Dispatches", "the", "deprecated", "pre", "remove", "event", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php#L106-L120
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php
ContentMapperSubscriber.handlePostRemove
public function handlePostRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $oid = spl_object_hash($document); $event = $this->deleteEvents[$oid]; $this->eventDispatcher->dispatch( ContentEvents::NODE_POST_DELETE, $event ); unset($this->deleteEvents[$oid]); }
php
public function handlePostRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $oid = spl_object_hash($document); $event = $this->deleteEvents[$oid]; $this->eventDispatcher->dispatch( ContentEvents::NODE_POST_DELETE, $event ); unset($this->deleteEvents[$oid]); }
[ "public", "function", "handlePostRemove", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "$", "event", "=", "$", "this", "->", "deleteEvents", "[", "$", "oid", "]", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ContentEvents", "::", "NODE_POST_DELETE", ",", "$", "event", ")", ";", "unset", "(", "$", "this", "->", "deleteEvents", "[", "$", "oid", "]", ")", ";", "}" ]
Dispatches the deprected post remove event. @param RemoveEvent $event
[ "Dispatches", "the", "deprected", "post", "remove", "event", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php#L127-L144
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php
ContentMapperSubscriber.handlePersist
public function handlePersist(PersistEvent $event) { if (!$this->supports($event->getDocument())) { return; } $this->persistEvents[] = $event; }
php
public function handlePersist(PersistEvent $event) { if (!$this->supports($event->getDocument())) { return; } $this->persistEvents[] = $event; }
[ "public", "function", "handlePersist", "(", "PersistEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "event", "->", "getDocument", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "persistEvents", "[", "]", "=", "$", "event", ";", "}" ]
Saves all persisted documents to dispatch the deprecated post save event later when flushed. @param PersistEvent $event
[ "Saves", "all", "persisted", "documents", "to", "dispatch", "the", "deprecated", "post", "save", "event", "later", "when", "flushed", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php#L151-L158
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php
ContentMapperSubscriber.handleFlush
public function handleFlush(FlushEvent $event) { foreach ($this->persistEvents as $persistEvent) { $document = $persistEvent->getDocument(); $structure = $this->documentToStructure($document); $event = new ContentNodeEvent($this->documentInspector->getNode($document), $structure); $this->eventDispatcher->dispatch(ContentEvents::NODE_POST_SAVE, $event); } $this->persistEvents = []; }
php
public function handleFlush(FlushEvent $event) { foreach ($this->persistEvents as $persistEvent) { $document = $persistEvent->getDocument(); $structure = $this->documentToStructure($document); $event = new ContentNodeEvent($this->documentInspector->getNode($document), $structure); $this->eventDispatcher->dispatch(ContentEvents::NODE_POST_SAVE, $event); } $this->persistEvents = []; }
[ "public", "function", "handleFlush", "(", "FlushEvent", "$", "event", ")", "{", "foreach", "(", "$", "this", "->", "persistEvents", "as", "$", "persistEvent", ")", "{", "$", "document", "=", "$", "persistEvent", "->", "getDocument", "(", ")", ";", "$", "structure", "=", "$", "this", "->", "documentToStructure", "(", "$", "document", ")", ";", "$", "event", "=", "new", "ContentNodeEvent", "(", "$", "this", "->", "documentInspector", "->", "getNode", "(", "$", "document", ")", ",", "$", "structure", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ContentEvents", "::", "NODE_POST_SAVE", ",", "$", "event", ")", ";", "}", "$", "this", "->", "persistEvents", "=", "[", "]", ";", "}" ]
Dispatches the deprecated post save event for every persisted document. @param FlushEvent $event
[ "Dispatches", "the", "deprecated", "post", "save", "event", "for", "every", "persisted", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/Compat/ContentMapperSubscriber.php#L165-L176
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/EmailType.php
EmailType.addEmail
public function addEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails) { $this->emails[] = $emails; return $this; }
php
public function addEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails) { $this->emails[] = $emails; return $this; }
[ "public", "function", "addEmail", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ContactBundle", "\\", "Entity", "\\", "Email", "$", "emails", ")", "{", "$", "this", "->", "emails", "[", "]", "=", "$", "emails", ";", "return", "$", "this", ";", "}" ]
Add emails. @param \Sulu\Bundle\ContactBundle\Entity\Email $emails @return EmailType
[ "Add", "emails", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/EmailType.php#L99-L104
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/EmailType.php
EmailType.removeEmail
public function removeEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails) { $this->emails->removeElement($emails); }
php
public function removeEmail(\Sulu\Bundle\ContactBundle\Entity\Email $emails) { $this->emails->removeElement($emails); }
[ "public", "function", "removeEmail", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ContactBundle", "\\", "Entity", "\\", "Email", "$", "emails", ")", "{", "$", "this", "->", "emails", "->", "removeElement", "(", "$", "emails", ")", ";", "}" ]
Remove emails. @param \Sulu\Bundle\ContactBundle\Entity\Email $emails
[ "Remove", "emails", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/EmailType.php#L111-L114
train
sulu/sulu
src/Sulu/Component/Content/Metadata/Loader/AbstractLoader.php
AbstractLoader.loadStructureTags
protected function loadStructureTags($path, $xpath) { $result = []; foreach ($xpath->query($path) as $node) { $tag = [ 'name' => null, 'attributes' => [], ]; foreach ($node->attributes as $key => $attr) { if (in_array($key, ['name'])) { $tag[$key] = $attr->value; } else { $tag['attributes'][$key] = $attr->value; } } if (!isset($tag['name'])) { // this should not happen because of the XSD validation throw new \InvalidArgumentException('Tag does not have a name in template definition'); } $result[] = $tag; } return $result; }
php
protected function loadStructureTags($path, $xpath) { $result = []; foreach ($xpath->query($path) as $node) { $tag = [ 'name' => null, 'attributes' => [], ]; foreach ($node->attributes as $key => $attr) { if (in_array($key, ['name'])) { $tag[$key] = $attr->value; } else { $tag['attributes'][$key] = $attr->value; } } if (!isset($tag['name'])) { // this should not happen because of the XSD validation throw new \InvalidArgumentException('Tag does not have a name in template definition'); } $result[] = $tag; } return $result; }
[ "protected", "function", "loadStructureTags", "(", "$", "path", ",", "$", "xpath", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "xpath", "->", "query", "(", "$", "path", ")", "as", "$", "node", ")", "{", "$", "tag", "=", "[", "'name'", "=>", "null", ",", "'attributes'", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "node", "->", "attributes", "as", "$", "key", "=>", "$", "attr", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "[", "'name'", "]", ")", ")", "{", "$", "tag", "[", "$", "key", "]", "=", "$", "attr", "->", "value", ";", "}", "else", "{", "$", "tag", "[", "'attributes'", "]", "[", "$", "key", "]", "=", "$", "attr", "->", "value", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "tag", "[", "'name'", "]", ")", ")", "{", "// this should not happen because of the XSD validation", "throw", "new", "\\", "InvalidArgumentException", "(", "'Tag does not have a name in template definition'", ")", ";", "}", "$", "result", "[", "]", "=", "$", "tag", ";", "}", "return", "$", "result", ";", "}" ]
Loads the tags for the structure. @param $path @param \DOMXPath $xpath @return array @throws \InvalidArgumentException
[ "Loads", "the", "tags", "for", "the", "structure", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Loader/AbstractLoader.php#L92-L119
train
sulu/sulu
src/Sulu/Component/Content/Metadata/Loader/AbstractLoader.php
AbstractLoader.loadStructureAreas
protected function loadStructureAreas($path, $xpath) { $result = []; foreach ($xpath->query($path) as $node) { $area = []; foreach ($node->attributes as $key => $attr) { if (in_array($key, ['key'])) { $area[$key] = $attr->value; } else { $area['attributes'][$key] = $attr->value; } } $meta = $this->loadMeta('x:meta/x:*', $xpath, $node); $area['title'] = $meta['title']; if (!isset($area['key'])) { // this should not happen because of the XSD validation throw new \InvalidArgumentException('Zone does not have a key in the attributes'); } $result[] = $area; } return $result; }
php
protected function loadStructureAreas($path, $xpath) { $result = []; foreach ($xpath->query($path) as $node) { $area = []; foreach ($node->attributes as $key => $attr) { if (in_array($key, ['key'])) { $area[$key] = $attr->value; } else { $area['attributes'][$key] = $attr->value; } } $meta = $this->loadMeta('x:meta/x:*', $xpath, $node); $area['title'] = $meta['title']; if (!isset($area['key'])) { // this should not happen because of the XSD validation throw new \InvalidArgumentException('Zone does not have a key in the attributes'); } $result[] = $area; } return $result; }
[ "protected", "function", "loadStructureAreas", "(", "$", "path", ",", "$", "xpath", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "xpath", "->", "query", "(", "$", "path", ")", "as", "$", "node", ")", "{", "$", "area", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "attributes", "as", "$", "key", "=>", "$", "attr", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "[", "'key'", "]", ")", ")", "{", "$", "area", "[", "$", "key", "]", "=", "$", "attr", "->", "value", ";", "}", "else", "{", "$", "area", "[", "'attributes'", "]", "[", "$", "key", "]", "=", "$", "attr", "->", "value", ";", "}", "}", "$", "meta", "=", "$", "this", "->", "loadMeta", "(", "'x:meta/x:*'", ",", "$", "xpath", ",", "$", "node", ")", ";", "$", "area", "[", "'title'", "]", "=", "$", "meta", "[", "'title'", "]", ";", "if", "(", "!", "isset", "(", "$", "area", "[", "'key'", "]", ")", ")", "{", "// this should not happen because of the XSD validation", "throw", "new", "\\", "InvalidArgumentException", "(", "'Zone does not have a key in the attributes'", ")", ";", "}", "$", "result", "[", "]", "=", "$", "area", ";", "}", "return", "$", "result", ";", "}" ]
Loads the areas for the structure. @param $path @param \DOMXPath $xpath @return array @throws \InvalidArgumentException
[ "Loads", "the", "areas", "for", "the", "structure", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Loader/AbstractLoader.php#L131-L158
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/User/UserProvider.php
UserProvider.getSystem
private function getSystem() { $system = $this->suluSystem; $request = $this->requestStack->getCurrentRequest(); if (null !== $request && $request->attributes->has('_sulu') && null !== ($webspace = $request->attributes->get('_sulu')->getAttribute('webspace')) && null !== ($security = $webspace->getSecurity()) ) { $system = $security->getSystem(); } return $system; }
php
private function getSystem() { $system = $this->suluSystem; $request = $this->requestStack->getCurrentRequest(); if (null !== $request && $request->attributes->has('_sulu') && null !== ($webspace = $request->attributes->get('_sulu')->getAttribute('webspace')) && null !== ($security = $webspace->getSecurity()) ) { $system = $security->getSystem(); } return $system; }
[ "private", "function", "getSystem", "(", ")", "{", "$", "system", "=", "$", "this", "->", "suluSystem", ";", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "if", "(", "null", "!==", "$", "request", "&&", "$", "request", "->", "attributes", "->", "has", "(", "'_sulu'", ")", "&&", "null", "!==", "(", "$", "webspace", "=", "$", "request", "->", "attributes", "->", "get", "(", "'_sulu'", ")", "->", "getAttribute", "(", "'webspace'", ")", ")", "&&", "null", "!==", "(", "$", "security", "=", "$", "webspace", "->", "getSecurity", "(", ")", ")", ")", "{", "$", "system", "=", "$", "security", "->", "getSystem", "(", ")", ";", "}", "return", "$", "system", ";", "}" ]
Returns the required system for the current request. @return string
[ "Returns", "the", "required", "system", "for", "the", "current", "request", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/User/UserProvider.php#L127-L141
train
sulu/sulu
src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php
PhpcrMapper.iterateRouteNodes
private function iterateRouteNodes( NodeInterface $node, $callback, $webspaceKey, $languageCode, $segmentKey = null ) { if ($node->isNew()) { return null; } $routePath = $this->sessionManager->getRoutePath($webspaceKey, $languageCode); // search for references with name 'content' foreach ($node->getReferences('sulu:content') as $ref) { if ($ref instanceof \PHPCR\PropertyInterface) { $routeNode = $ref->getParent(); if (0 !== strpos($routeNode->getPath(), $routePath)) { continue; } $resourceLocator = $this->getResourceLocator( $ref->getParent()->getPath(), $webspaceKey, $languageCode, $segmentKey ); $result = $callback($resourceLocator, $routeNode); if (false !== $result) { return $result; } } } return null; }
php
private function iterateRouteNodes( NodeInterface $node, $callback, $webspaceKey, $languageCode, $segmentKey = null ) { if ($node->isNew()) { return null; } $routePath = $this->sessionManager->getRoutePath($webspaceKey, $languageCode); // search for references with name 'content' foreach ($node->getReferences('sulu:content') as $ref) { if ($ref instanceof \PHPCR\PropertyInterface) { $routeNode = $ref->getParent(); if (0 !== strpos($routeNode->getPath(), $routePath)) { continue; } $resourceLocator = $this->getResourceLocator( $ref->getParent()->getPath(), $webspaceKey, $languageCode, $segmentKey ); $result = $callback($resourceLocator, $routeNode); if (false !== $result) { return $result; } } } return null; }
[ "private", "function", "iterateRouteNodes", "(", "NodeInterface", "$", "node", ",", "$", "callback", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", "=", "null", ")", "{", "if", "(", "$", "node", "->", "isNew", "(", ")", ")", "{", "return", "null", ";", "}", "$", "routePath", "=", "$", "this", "->", "sessionManager", "->", "getRoutePath", "(", "$", "webspaceKey", ",", "$", "languageCode", ")", ";", "// search for references with name 'content'", "foreach", "(", "$", "node", "->", "getReferences", "(", "'sulu:content'", ")", "as", "$", "ref", ")", "{", "if", "(", "$", "ref", "instanceof", "\\", "PHPCR", "\\", "PropertyInterface", ")", "{", "$", "routeNode", "=", "$", "ref", "->", "getParent", "(", ")", ";", "if", "(", "0", "!==", "strpos", "(", "$", "routeNode", "->", "getPath", "(", ")", ",", "$", "routePath", ")", ")", "{", "continue", ";", "}", "$", "resourceLocator", "=", "$", "this", "->", "getResourceLocator", "(", "$", "ref", "->", "getParent", "(", ")", "->", "getPath", "(", ")", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "$", "result", "=", "$", "callback", "(", "$", "resourceLocator", ",", "$", "routeNode", ")", ";", "if", "(", "false", "!==", "$", "result", ")", "{", "return", "$", "result", ";", "}", "}", "}", "return", "null", ";", "}" ]
Iterates over all route nodes assigned by the given node, and executes the callback on it. @param NodeInterface $node @param callable $callback will be called foreach route node (stops and return value if not false) @param string $webspaceKey @param string $languageCode @param string $segmentKey @return \PHPCR\NodeInterface
[ "Iterates", "over", "all", "route", "nodes", "assigned", "by", "the", "given", "node", "and", "executes", "the", "callback", "on", "it", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php#L148-L184
train
sulu/sulu
src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php
PhpcrMapper.getWebspaceRouteNode
private function getWebspaceRouteNode($webspaceKey, $languageCode, $segmentKey) { return $this->sessionManager->getRouteNode($webspaceKey, $languageCode, $segmentKey); }
php
private function getWebspaceRouteNode($webspaceKey, $languageCode, $segmentKey) { return $this->sessionManager->getRouteNode($webspaceKey, $languageCode, $segmentKey); }
[ "private", "function", "getWebspaceRouteNode", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", "{", "return", "$", "this", "->", "sessionManager", "->", "getRouteNode", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "}" ]
Returns base node of routes from phpcr. @param string $webspaceKey current session @param string $languageCode @param string $segmentKey @return \PHPCR\NodeInterface base node of routes
[ "Returns", "base", "node", "of", "routes", "from", "phpcr", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php#L391-L394
train
sulu/sulu
src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php
PhpcrMapper.getWebspaceRouteNodeBasePath
private function getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey) { return $this->sessionManager->getRoutePath($webspaceKey, $languageCode, $segmentKey); }
php
private function getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey) { return $this->sessionManager->getRoutePath($webspaceKey, $languageCode, $segmentKey); }
[ "private", "function", "getWebspaceRouteNodeBasePath", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", "{", "return", "$", "this", "->", "sessionManager", "->", "getRoutePath", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "}" ]
Returns base path of routes from phpcr. @param string $webspaceKey current session @param string $languageCode @param string $segmentKey @return string
[ "Returns", "base", "path", "of", "routes", "from", "phpcr", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php#L405-L408
train
sulu/sulu
src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php
PhpcrMapper.getPath
private function getPath($relPath, $webspaceKey, $languageCode, $segmentKey) { $basePath = $this->getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey); return '/' . ltrim($basePath, '/') . ('' !== $relPath ? '/' . ltrim($relPath, '/') : ''); }
php
private function getPath($relPath, $webspaceKey, $languageCode, $segmentKey) { $basePath = $this->getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey); return '/' . ltrim($basePath, '/') . ('' !== $relPath ? '/' . ltrim($relPath, '/') : ''); }
[ "private", "function", "getPath", "(", "$", "relPath", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", "{", "$", "basePath", "=", "$", "this", "->", "getWebspaceRouteNodeBasePath", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "return", "'/'", ".", "ltrim", "(", "$", "basePath", ",", "'/'", ")", ".", "(", "''", "!==", "$", "relPath", "?", "'/'", ".", "ltrim", "(", "$", "relPath", ",", "'/'", ")", ":", "''", ")", ";", "}" ]
Returns the abspath. @param string $relPath @param string $webspaceKey @param string $languageCode @param string $segmentKey @return string
[ "Returns", "the", "abspath", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php#L420-L425
train
sulu/sulu
src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php
PhpcrMapper.getResourceLocator
private function getResourceLocator($path, $webspaceKey, $languageCode, $segmentKey) { $basePath = $this->getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey); if ($path === $basePath) { return '/'; } if (false !== strpos($path, $basePath . '/')) { $result = str_replace($basePath . '/', '/', $path); if (0 === strpos($result, '/')) { return $result; } } return false; }
php
private function getResourceLocator($path, $webspaceKey, $languageCode, $segmentKey) { $basePath = $this->getWebspaceRouteNodeBasePath($webspaceKey, $languageCode, $segmentKey); if ($path === $basePath) { return '/'; } if (false !== strpos($path, $basePath . '/')) { $result = str_replace($basePath . '/', '/', $path); if (0 === strpos($result, '/')) { return $result; } } return false; }
[ "private", "function", "getResourceLocator", "(", "$", "path", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", "{", "$", "basePath", "=", "$", "this", "->", "getWebspaceRouteNodeBasePath", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "if", "(", "$", "path", "===", "$", "basePath", ")", "{", "return", "'/'", ";", "}", "if", "(", "false", "!==", "strpos", "(", "$", "path", ",", "$", "basePath", ".", "'/'", ")", ")", "{", "$", "result", "=", "str_replace", "(", "$", "basePath", ".", "'/'", ",", "'/'", ",", "$", "path", ")", ";", "if", "(", "0", "===", "strpos", "(", "$", "result", ",", "'/'", ")", ")", "{", "return", "$", "result", ";", "}", "}", "return", "false", ";", "}" ]
Returns resource-locator. @param string $path @param string $webspaceKey @param string $languageCode @param string $segmentKey @return string
[ "Returns", "resource", "-", "locator", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/ResourceLocator/Mapper/PhpcrMapper.php#L437-L452
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/RobotSubscriber.php
RobotSubscriber.handleMetadataLoad
public function handleMetadataLoad(MetadataLoadEvent $event) { $metadata = $event->getMetadata(); if (false === $metadata->getReflectionClass()->isSubclassOf(RobotBehavior::class)) { return; } $metadata->addFieldMapping( 'noFollow', [ 'encoding' => 'system', 'property' => 'noFollow', ] ); $metadata->addFieldMapping( 'noIndex', [ 'encoding' => 'system', 'property' => 'noIndex', ] ); }
php
public function handleMetadataLoad(MetadataLoadEvent $event) { $metadata = $event->getMetadata(); if (false === $metadata->getReflectionClass()->isSubclassOf(RobotBehavior::class)) { return; } $metadata->addFieldMapping( 'noFollow', [ 'encoding' => 'system', 'property' => 'noFollow', ] ); $metadata->addFieldMapping( 'noIndex', [ 'encoding' => 'system', 'property' => 'noIndex', ] ); }
[ "public", "function", "handleMetadataLoad", "(", "MetadataLoadEvent", "$", "event", ")", "{", "$", "metadata", "=", "$", "event", "->", "getMetadata", "(", ")", ";", "if", "(", "false", "===", "$", "metadata", "->", "getReflectionClass", "(", ")", "->", "isSubclassOf", "(", "RobotBehavior", "::", "class", ")", ")", "{", "return", ";", "}", "$", "metadata", "->", "addFieldMapping", "(", "'noFollow'", ",", "[", "'encoding'", "=>", "'system'", ",", "'property'", "=>", "'noFollow'", ",", "]", ")", ";", "$", "metadata", "->", "addFieldMapping", "(", "'noIndex'", ",", "[", "'encoding'", "=>", "'system'", ",", "'property'", "=>", "'noIndex'", ",", "]", ")", ";", "}" ]
Append mapping for robot fields. @param MetadataLoadEvent $event
[ "Append", "mapping", "for", "robot", "fields", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/RobotSubscriber.php#L36-L59
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php
MediaImageExtractor.convertPdfToImage
private function convertPdfToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); $command = $this->ghostScriptPath . ' -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile=' . $temporaryFilePath . ' ' . '-dJPEGQ=100 -r300x300 -q ' . $temporaryFilePath . ' -c quit 2> /dev/null'; shell_exec($command); $output = file_get_contents($temporaryFilePath); unlink($temporaryFilePath); if (!$output) { throw new GhostScriptNotFoundException( 'Ghostscript was not found at "' . $this->ghostScriptPath . '"' ); } return $this->createTemporaryResource($output); }
php
private function convertPdfToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); $command = $this->ghostScriptPath . ' -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile=' . $temporaryFilePath . ' ' . '-dJPEGQ=100 -r300x300 -q ' . $temporaryFilePath . ' -c quit 2> /dev/null'; shell_exec($command); $output = file_get_contents($temporaryFilePath); unlink($temporaryFilePath); if (!$output) { throw new GhostScriptNotFoundException( 'Ghostscript was not found at "' . $this->ghostScriptPath . '"' ); } return $this->createTemporaryResource($output); }
[ "private", "function", "convertPdfToImage", "(", "$", "resource", ")", "{", "$", "temporaryFilePath", "=", "$", "this", "->", "createTemporaryFile", "(", "$", "resource", ")", ";", "$", "command", "=", "$", "this", "->", "ghostScriptPath", ".", "' -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile='", ".", "$", "temporaryFilePath", ".", "' '", ".", "'-dJPEGQ=100 -r300x300 -q '", ".", "$", "temporaryFilePath", ".", "' -c quit 2> /dev/null'", ";", "shell_exec", "(", "$", "command", ")", ";", "$", "output", "=", "file_get_contents", "(", "$", "temporaryFilePath", ")", ";", "unlink", "(", "$", "temporaryFilePath", ")", ";", "if", "(", "!", "$", "output", ")", "{", "throw", "new", "GhostScriptNotFoundException", "(", "'Ghostscript was not found at \"'", ".", "$", "this", "->", "ghostScriptPath", ".", "'\"'", ")", ";", "}", "return", "$", "this", "->", "createTemporaryResource", "(", "$", "output", ")", ";", "}" ]
Converts the first page of pdf to an image using ghostscript. @param resource $resource @return resource @throws GhostScriptNotFoundException
[ "Converts", "the", "first", "page", "of", "pdf", "to", "an", "image", "using", "ghostscript", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php#L78-L99
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php
MediaImageExtractor.convertPsdToImage
private function convertPsdToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); try { $image = $this->imagine->open($temporaryFilePath); $image = $image->layers()[0]; unlink($temporaryFilePath); return $this->createTemporaryResource($image->get('png')); } catch (RuntimeException $e) { unlink($temporaryFilePath); throw new InvalidMimeTypeForPreviewException('image/vnd.adobe.photoshop'); } }
php
private function convertPsdToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); try { $image = $this->imagine->open($temporaryFilePath); $image = $image->layers()[0]; unlink($temporaryFilePath); return $this->createTemporaryResource($image->get('png')); } catch (RuntimeException $e) { unlink($temporaryFilePath); throw new InvalidMimeTypeForPreviewException('image/vnd.adobe.photoshop'); } }
[ "private", "function", "convertPsdToImage", "(", "$", "resource", ")", "{", "$", "temporaryFilePath", "=", "$", "this", "->", "createTemporaryFile", "(", "$", "resource", ")", ";", "try", "{", "$", "image", "=", "$", "this", "->", "imagine", "->", "open", "(", "$", "temporaryFilePath", ")", ";", "$", "image", "=", "$", "image", "->", "layers", "(", ")", "[", "0", "]", ";", "unlink", "(", "$", "temporaryFilePath", ")", ";", "return", "$", "this", "->", "createTemporaryResource", "(", "$", "image", "->", "get", "(", "'png'", ")", ")", ";", "}", "catch", "(", "RuntimeException", "$", "e", ")", "{", "unlink", "(", "$", "temporaryFilePath", ")", ";", "throw", "new", "InvalidMimeTypeForPreviewException", "(", "'image/vnd.adobe.photoshop'", ")", ";", "}", "}" ]
Converts a PSD to a png using imagine. Only works with Imagick and not with GD. @param resource $resource @return resource @throws InvalidMimeTypeForPreviewException
[ "Converts", "a", "PSD", "to", "a", "png", "using", "imagine", ".", "Only", "works", "with", "Imagick", "and", "not", "with", "GD", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php#L110-L126
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php
MediaImageExtractor.convertVideoToImage
private function convertVideoToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); $this->videoThumbnail->generate($temporaryFilePath, '00:00:02:01', $temporaryFilePath); $extractedImage = file_get_contents($temporaryFilePath); unlink($temporaryFilePath); return $this->createTemporaryResource($extractedImage); }
php
private function convertVideoToImage($resource) { $temporaryFilePath = $this->createTemporaryFile($resource); $this->videoThumbnail->generate($temporaryFilePath, '00:00:02:01', $temporaryFilePath); $extractedImage = file_get_contents($temporaryFilePath); unlink($temporaryFilePath); return $this->createTemporaryResource($extractedImage); }
[ "private", "function", "convertVideoToImage", "(", "$", "resource", ")", "{", "$", "temporaryFilePath", "=", "$", "this", "->", "createTemporaryFile", "(", "$", "resource", ")", ";", "$", "this", "->", "videoThumbnail", "->", "generate", "(", "$", "temporaryFilePath", ",", "'00:00:02:01'", ",", "$", "temporaryFilePath", ")", ";", "$", "extractedImage", "=", "file_get_contents", "(", "$", "temporaryFilePath", ")", ";", "unlink", "(", "$", "temporaryFilePath", ")", ";", "return", "$", "this", "->", "createTemporaryResource", "(", "$", "extractedImage", ")", ";", "}" ]
Converts one frame of a video to an image using FFMPEG. @param resource $resource @return resource
[ "Converts", "one", "frame", "of", "a", "video", "to", "an", "image", "using", "FFMPEG", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php#L135-L144
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php
MediaImageExtractor.createTemporaryResource
private function createTemporaryResource(string $content) { $tempResource = fopen('php://memory', 'r+'); fwrite($tempResource, $content); rewind($tempResource); return $tempResource; }
php
private function createTemporaryResource(string $content) { $tempResource = fopen('php://memory', 'r+'); fwrite($tempResource, $content); rewind($tempResource); return $tempResource; }
[ "private", "function", "createTemporaryResource", "(", "string", "$", "content", ")", "{", "$", "tempResource", "=", "fopen", "(", "'php://memory'", ",", "'r+'", ")", ";", "fwrite", "(", "$", "tempResource", ",", "$", "content", ")", ";", "rewind", "(", "$", "tempResource", ")", ";", "return", "$", "tempResource", ";", "}" ]
Create temporary resource which will removed on fclose or end of process. @param string $content @return resource
[ "Create", "temporary", "resource", "which", "will", "removed", "on", "fclose", "or", "end", "of", "process", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php#L153-L160
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php
MediaImageExtractor.createTemporaryFile
private function createTemporaryFile($resource) { $path = tempnam(sys_get_temp_dir(), 'media'); $tempResource = fopen($path, 'w'); stream_copy_to_stream($resource, $tempResource); return $path; }
php
private function createTemporaryFile($resource) { $path = tempnam(sys_get_temp_dir(), 'media'); $tempResource = fopen($path, 'w'); stream_copy_to_stream($resource, $tempResource); return $path; }
[ "private", "function", "createTemporaryFile", "(", "$", "resource", ")", "{", "$", "path", "=", "tempnam", "(", "sys_get_temp_dir", "(", ")", ",", "'media'", ")", ";", "$", "tempResource", "=", "fopen", "(", "$", "path", ",", "'w'", ")", ";", "stream_copy_to_stream", "(", "$", "resource", ",", "$", "tempResource", ")", ";", "return", "$", "path", ";", "}" ]
Returns the path to a temporary file containing the given content. @param resource $resource @return string
[ "Returns", "the", "path", "to", "a", "temporary", "file", "containing", "the", "given", "content", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/ImageConverter/MediaImageExtractor.php#L169-L177
train
sulu/sulu
src/Sulu/Component/Content/Types/BlockContentType.php
BlockContentType.doWrite
private function doWrite( NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport = false ) { if ($property->getIsBlock()) { /** @var BlockPropertyInterface $blockProperty */ $blockProperty = $property; while (!($blockProperty instanceof BlockPropertyInterface)) { $blockProperty = $blockProperty->getProperty(); } $data = $blockProperty->getValue(); if (!$blockProperty->getIsMultiple()) { $data = [$data]; } $data = array_filter($data); $len = count($data); // init properties $typeProperty = new Property('type', '', 'text_line'); $lengthProperty = new Property('length', '', 'text_line'); //save length $lengthProperty->setValue($len); $contentType = $this->contentTypeManager->get($lengthProperty->getContentTypeName()); $contentType->write( $node, new BlockPropertyWrapper($lengthProperty, $property), $userId, $webspaceKey, $languageCode, $segmentKey ); for ($i = 0; $i < $len; ++$i) { $blockPropertyType = $blockProperty->getProperties($i); // save type property $this->writeProperty( $typeProperty, $property, $blockPropertyType->getName(), $i, $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport ); foreach ($blockProperty->getProperties($i)->getChildProperties() as $subProperty) { $this->writeProperty( $subProperty, $property, $subProperty->getValue(), $i, $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport ); } } } else { throw new UnexpectedPropertyType($property, $this); } }
php
private function doWrite( NodeInterface $node, PropertyInterface $property, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport = false ) { if ($property->getIsBlock()) { /** @var BlockPropertyInterface $blockProperty */ $blockProperty = $property; while (!($blockProperty instanceof BlockPropertyInterface)) { $blockProperty = $blockProperty->getProperty(); } $data = $blockProperty->getValue(); if (!$blockProperty->getIsMultiple()) { $data = [$data]; } $data = array_filter($data); $len = count($data); // init properties $typeProperty = new Property('type', '', 'text_line'); $lengthProperty = new Property('length', '', 'text_line'); //save length $lengthProperty->setValue($len); $contentType = $this->contentTypeManager->get($lengthProperty->getContentTypeName()); $contentType->write( $node, new BlockPropertyWrapper($lengthProperty, $property), $userId, $webspaceKey, $languageCode, $segmentKey ); for ($i = 0; $i < $len; ++$i) { $blockPropertyType = $blockProperty->getProperties($i); // save type property $this->writeProperty( $typeProperty, $property, $blockPropertyType->getName(), $i, $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport ); foreach ($blockProperty->getProperties($i)->getChildProperties() as $subProperty) { $this->writeProperty( $subProperty, $property, $subProperty->getValue(), $i, $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport ); } } } else { throw new UnexpectedPropertyType($property, $this); } }
[ "private", "function", "doWrite", "(", "NodeInterface", "$", "node", ",", "PropertyInterface", "$", "property", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ",", "$", "isImport", "=", "false", ")", "{", "if", "(", "$", "property", "->", "getIsBlock", "(", ")", ")", "{", "/** @var BlockPropertyInterface $blockProperty */", "$", "blockProperty", "=", "$", "property", ";", "while", "(", "!", "(", "$", "blockProperty", "instanceof", "BlockPropertyInterface", ")", ")", "{", "$", "blockProperty", "=", "$", "blockProperty", "->", "getProperty", "(", ")", ";", "}", "$", "data", "=", "$", "blockProperty", "->", "getValue", "(", ")", ";", "if", "(", "!", "$", "blockProperty", "->", "getIsMultiple", "(", ")", ")", "{", "$", "data", "=", "[", "$", "data", "]", ";", "}", "$", "data", "=", "array_filter", "(", "$", "data", ")", ";", "$", "len", "=", "count", "(", "$", "data", ")", ";", "// init properties", "$", "typeProperty", "=", "new", "Property", "(", "'type'", ",", "''", ",", "'text_line'", ")", ";", "$", "lengthProperty", "=", "new", "Property", "(", "'length'", ",", "''", ",", "'text_line'", ")", ";", "//save length", "$", "lengthProperty", "->", "setValue", "(", "$", "len", ")", ";", "$", "contentType", "=", "$", "this", "->", "contentTypeManager", "->", "get", "(", "$", "lengthProperty", "->", "getContentTypeName", "(", ")", ")", ";", "$", "contentType", "->", "write", "(", "$", "node", ",", "new", "BlockPropertyWrapper", "(", "$", "lengthProperty", ",", "$", "property", ")", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "++", "$", "i", ")", "{", "$", "blockPropertyType", "=", "$", "blockProperty", "->", "getProperties", "(", "$", "i", ")", ";", "// save type property", "$", "this", "->", "writeProperty", "(", "$", "typeProperty", ",", "$", "property", ",", "$", "blockPropertyType", "->", "getName", "(", ")", ",", "$", "i", ",", "$", "node", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ",", "$", "isImport", ")", ";", "foreach", "(", "$", "blockProperty", "->", "getProperties", "(", "$", "i", ")", "->", "getChildProperties", "(", ")", "as", "$", "subProperty", ")", "{", "$", "this", "->", "writeProperty", "(", "$", "subProperty", ",", "$", "property", ",", "$", "subProperty", "->", "getValue", "(", ")", ",", "$", "i", ",", "$", "node", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ",", "$", "isImport", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "UnexpectedPropertyType", "(", "$", "property", ",", "$", "this", ")", ";", "}", "}" ]
Save the value from given property. @param NodeInterface $node @param PropertyInterface $property @param $userId @param $webspaceKey @param $languageCode @param $segmentKey @param bool $isImport @throws UnexpectedPropertyType
[ "Save", "the", "value", "from", "given", "property", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/BlockContentType.php#L169-L246
train
sulu/sulu
src/Sulu/Component/Content/Types/BlockContentType.php
BlockContentType.writeProperty
private function writeProperty( PropertyInterface $property, PropertyInterface $blockProperty, $value, $index, NodeInterface $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport = false ) { // save sub property $contentType = $this->contentTypeManager->get($property->getContentTypeName()); $blockPropertyWrapper = new BlockPropertyWrapper($property, $blockProperty, $index); $blockPropertyWrapper->setValue($value); if ($isImport && $contentType instanceof ContentTypeExportInterface) { return $contentType->importData( new SuluNode($node), $blockPropertyWrapper, $value, $userId, $webspaceKey, $languageCode, $segmentKey ); } $contentType->write( new SuluNode($node), $blockPropertyWrapper, $userId, $webspaceKey, $languageCode, $segmentKey ); }
php
private function writeProperty( PropertyInterface $property, PropertyInterface $blockProperty, $value, $index, NodeInterface $node, $userId, $webspaceKey, $languageCode, $segmentKey, $isImport = false ) { // save sub property $contentType = $this->contentTypeManager->get($property->getContentTypeName()); $blockPropertyWrapper = new BlockPropertyWrapper($property, $blockProperty, $index); $blockPropertyWrapper->setValue($value); if ($isImport && $contentType instanceof ContentTypeExportInterface) { return $contentType->importData( new SuluNode($node), $blockPropertyWrapper, $value, $userId, $webspaceKey, $languageCode, $segmentKey ); } $contentType->write( new SuluNode($node), $blockPropertyWrapper, $userId, $webspaceKey, $languageCode, $segmentKey ); }
[ "private", "function", "writeProperty", "(", "PropertyInterface", "$", "property", ",", "PropertyInterface", "$", "blockProperty", ",", "$", "value", ",", "$", "index", ",", "NodeInterface", "$", "node", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ",", "$", "isImport", "=", "false", ")", "{", "// save sub property", "$", "contentType", "=", "$", "this", "->", "contentTypeManager", "->", "get", "(", "$", "property", "->", "getContentTypeName", "(", ")", ")", ";", "$", "blockPropertyWrapper", "=", "new", "BlockPropertyWrapper", "(", "$", "property", ",", "$", "blockProperty", ",", "$", "index", ")", ";", "$", "blockPropertyWrapper", "->", "setValue", "(", "$", "value", ")", ";", "if", "(", "$", "isImport", "&&", "$", "contentType", "instanceof", "ContentTypeExportInterface", ")", "{", "return", "$", "contentType", "->", "importData", "(", "new", "SuluNode", "(", "$", "node", ")", ",", "$", "blockPropertyWrapper", ",", "$", "value", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "}", "$", "contentType", "->", "write", "(", "new", "SuluNode", "(", "$", "node", ")", ",", "$", "blockPropertyWrapper", ",", "$", "userId", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "segmentKey", ")", ";", "}" ]
write a property to node.
[ "write", "a", "property", "to", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Types/BlockContentType.php#L251-L288
train
sulu/sulu
src/Sulu/Bundle/LocationBundle/DependencyInjection/SuluLocationExtension.php
SuluLocationExtension.configureMapManager
private function configureMapManager($config, ContainerBuilder $container) { $mapManager = $container->getDefinition('sulu_location.map_manager'); foreach ($config['enabled_providers'] as $enabledProviderName) { $providerConfig = $config['providers'][$enabledProviderName]; $mapManager->addMethodCall('registerProvider', [ $enabledProviderName, $providerConfig, ]); } foreach ($config['geolocators'] as $geoLocatorName => $geoLocatorOptions) { $mapManager->addMethodCall('registerGeolocator', [ $geoLocatorName, $geoLocatorOptions, ]); } $mapManager->addMethodCall('setDefaultProviderName', [$config['default_provider']]); }
php
private function configureMapManager($config, ContainerBuilder $container) { $mapManager = $container->getDefinition('sulu_location.map_manager'); foreach ($config['enabled_providers'] as $enabledProviderName) { $providerConfig = $config['providers'][$enabledProviderName]; $mapManager->addMethodCall('registerProvider', [ $enabledProviderName, $providerConfig, ]); } foreach ($config['geolocators'] as $geoLocatorName => $geoLocatorOptions) { $mapManager->addMethodCall('registerGeolocator', [ $geoLocatorName, $geoLocatorOptions, ]); } $mapManager->addMethodCall('setDefaultProviderName', [$config['default_provider']]); }
[ "private", "function", "configureMapManager", "(", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "mapManager", "=", "$", "container", "->", "getDefinition", "(", "'sulu_location.map_manager'", ")", ";", "foreach", "(", "$", "config", "[", "'enabled_providers'", "]", "as", "$", "enabledProviderName", ")", "{", "$", "providerConfig", "=", "$", "config", "[", "'providers'", "]", "[", "$", "enabledProviderName", "]", ";", "$", "mapManager", "->", "addMethodCall", "(", "'registerProvider'", ",", "[", "$", "enabledProviderName", ",", "$", "providerConfig", ",", "]", ")", ";", "}", "foreach", "(", "$", "config", "[", "'geolocators'", "]", "as", "$", "geoLocatorName", "=>", "$", "geoLocatorOptions", ")", "{", "$", "mapManager", "->", "addMethodCall", "(", "'registerGeolocator'", ",", "[", "$", "geoLocatorName", ",", "$", "geoLocatorOptions", ",", "]", ")", ";", "}", "$", "mapManager", "->", "addMethodCall", "(", "'setDefaultProviderName'", ",", "[", "$", "config", "[", "'default_provider'", "]", "]", ")", ";", "}" ]
Configure the map manager - register the providers and geolocators with the map manager class. @param array $config - Resolved configuration @param ContainerBuilder
[ "Configure", "the", "map", "manager", "-", "register", "the", "providers", "and", "geolocators", "with", "the", "map", "manager", "class", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/LocationBundle/DependencyInjection/SuluLocationExtension.php#L45-L65
train
sulu/sulu
src/Sulu/Bundle/LocationBundle/DependencyInjection/SuluLocationExtension.php
SuluLocationExtension.configureGeolocators
private function configureGeolocators($config, $container) { $geolocatorName = $config['geolocator']; $container->setParameter('sulu_location.geolocator.name', $geolocatorName); $nominatim = function($config, $container) { $endpoint = $config['geolocators']['nominatim']['endpoint']; $container->setParameter('sulu_location.geolocator.service.nominatim.endpoint', $endpoint); }; $google = function($config, $container) { $apiKey = $config['geolocators']['google']['api_key']; $container->setParameter('sulu_location.geolocator.service.google.api_key', $apiKey); }; $nominatim($config, $container); $google($config, $container); }
php
private function configureGeolocators($config, $container) { $geolocatorName = $config['geolocator']; $container->setParameter('sulu_location.geolocator.name', $geolocatorName); $nominatim = function($config, $container) { $endpoint = $config['geolocators']['nominatim']['endpoint']; $container->setParameter('sulu_location.geolocator.service.nominatim.endpoint', $endpoint); }; $google = function($config, $container) { $apiKey = $config['geolocators']['google']['api_key']; $container->setParameter('sulu_location.geolocator.service.google.api_key', $apiKey); }; $nominatim($config, $container); $google($config, $container); }
[ "private", "function", "configureGeolocators", "(", "$", "config", ",", "$", "container", ")", "{", "$", "geolocatorName", "=", "$", "config", "[", "'geolocator'", "]", ";", "$", "container", "->", "setParameter", "(", "'sulu_location.geolocator.name'", ",", "$", "geolocatorName", ")", ";", "$", "nominatim", "=", "function", "(", "$", "config", ",", "$", "container", ")", "{", "$", "endpoint", "=", "$", "config", "[", "'geolocators'", "]", "[", "'nominatim'", "]", "[", "'endpoint'", "]", ";", "$", "container", "->", "setParameter", "(", "'sulu_location.geolocator.service.nominatim.endpoint'", ",", "$", "endpoint", ")", ";", "}", ";", "$", "google", "=", "function", "(", "$", "config", ",", "$", "container", ")", "{", "$", "apiKey", "=", "$", "config", "[", "'geolocators'", "]", "[", "'google'", "]", "[", "'api_key'", "]", ";", "$", "container", "->", "setParameter", "(", "'sulu_location.geolocator.service.google.api_key'", ",", "$", "apiKey", ")", ";", "}", ";", "$", "nominatim", "(", "$", "config", ",", "$", "container", ")", ";", "$", "google", "(", "$", "config", ",", "$", "container", ")", ";", "}" ]
Configure the geolocator services. @param array $config - Resolved configuration @param ContainerBuilder
[ "Configure", "the", "geolocator", "services", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/LocationBundle/DependencyInjection/SuluLocationExtension.php#L73-L90
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/EventListener/LastLoginListener.php
LastLoginListener.updateLastLogin
protected function updateLastLogin($user) { if ($user instanceof BaseUser) { $user->setLastLogin(new \DateTime()); $this->entityManager->flush(); } }
php
protected function updateLastLogin($user) { if ($user instanceof BaseUser) { $user->setLastLogin(new \DateTime()); $this->entityManager->flush(); } }
[ "protected", "function", "updateLastLogin", "(", "$", "user", ")", "{", "if", "(", "$", "user", "instanceof", "BaseUser", ")", "{", "$", "user", "->", "setLastLogin", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "$", "this", "->", "entityManager", "->", "flush", "(", ")", ";", "}", "}" ]
Update the users last login. @param UserInterface $user
[ "Update", "the", "users", "last", "login", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/EventListener/LastLoginListener.php#L67-L73
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Phpcr/QuerySubscriber.php
QuerySubscriber.handleCreate
public function handleCreate(QueryCreateEvent $event) { $innerQuery = $event->getInnerQuery(); if (is_string($innerQuery)) { $phpcrQuery = $this->getQueryManager()->createQuery($innerQuery, QueryInterface::JCR_SQL2); } elseif ($innerQuery instanceof QueryInterface) { $phpcrQuery = $innerQuery; } else { throw new \InvalidArgumentException(sprintf( 'Expected inner query to be either a string or a PHPCR query object, got: "%s"', is_object($innerQuery) ? get_class($innerQuery) : gettype($innerQuery) )); } $event->setQuery( new Query( $phpcrQuery, $this->eventDispatcher, $event->getLocale(), $event->getOptions(), $event->getPrimarySelector() ) ); }
php
public function handleCreate(QueryCreateEvent $event) { $innerQuery = $event->getInnerQuery(); if (is_string($innerQuery)) { $phpcrQuery = $this->getQueryManager()->createQuery($innerQuery, QueryInterface::JCR_SQL2); } elseif ($innerQuery instanceof QueryInterface) { $phpcrQuery = $innerQuery; } else { throw new \InvalidArgumentException(sprintf( 'Expected inner query to be either a string or a PHPCR query object, got: "%s"', is_object($innerQuery) ? get_class($innerQuery) : gettype($innerQuery) )); } $event->setQuery( new Query( $phpcrQuery, $this->eventDispatcher, $event->getLocale(), $event->getOptions(), $event->getPrimarySelector() ) ); }
[ "public", "function", "handleCreate", "(", "QueryCreateEvent", "$", "event", ")", "{", "$", "innerQuery", "=", "$", "event", "->", "getInnerQuery", "(", ")", ";", "if", "(", "is_string", "(", "$", "innerQuery", ")", ")", "{", "$", "phpcrQuery", "=", "$", "this", "->", "getQueryManager", "(", ")", "->", "createQuery", "(", "$", "innerQuery", ",", "QueryInterface", "::", "JCR_SQL2", ")", ";", "}", "elseif", "(", "$", "innerQuery", "instanceof", "QueryInterface", ")", "{", "$", "phpcrQuery", "=", "$", "innerQuery", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Expected inner query to be either a string or a PHPCR query object, got: \"%s\"'", ",", "is_object", "(", "$", "innerQuery", ")", "?", "get_class", "(", "$", "innerQuery", ")", ":", "gettype", "(", "$", "innerQuery", ")", ")", ")", ";", "}", "$", "event", "->", "setQuery", "(", "new", "Query", "(", "$", "phpcrQuery", ",", "$", "this", "->", "eventDispatcher", ",", "$", "event", "->", "getLocale", "(", ")", ",", "$", "event", "->", "getOptions", "(", ")", ",", "$", "event", "->", "getPrimarySelector", "(", ")", ")", ")", ";", "}" ]
Create a new Sulu Query object. @param QueryCreateEvent $event
[ "Create", "a", "new", "Sulu", "Query", "object", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Phpcr/QuerySubscriber.php#L67-L91
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Phpcr/QuerySubscriber.php
QuerySubscriber.handleQueryExecute
public function handleQueryExecute(QueryExecuteEvent $event) { $query = $event->getQuery(); $locale = $query->getLocale(); $phpcrResult = $query->getPhpcrQuery()->execute(); $event->setResult( new QueryResultCollection($phpcrResult, $this->eventDispatcher, $locale, $event->getOptions()) ); }
php
public function handleQueryExecute(QueryExecuteEvent $event) { $query = $event->getQuery(); $locale = $query->getLocale(); $phpcrResult = $query->getPhpcrQuery()->execute(); $event->setResult( new QueryResultCollection($phpcrResult, $this->eventDispatcher, $locale, $event->getOptions()) ); }
[ "public", "function", "handleQueryExecute", "(", "QueryExecuteEvent", "$", "event", ")", "{", "$", "query", "=", "$", "event", "->", "getQuery", "(", ")", ";", "$", "locale", "=", "$", "query", "->", "getLocale", "(", ")", ";", "$", "phpcrResult", "=", "$", "query", "->", "getPhpcrQuery", "(", ")", "->", "execute", "(", ")", ";", "$", "event", "->", "setResult", "(", "new", "QueryResultCollection", "(", "$", "phpcrResult", ",", "$", "this", "->", "eventDispatcher", ",", "$", "locale", ",", "$", "event", "->", "getOptions", "(", ")", ")", ")", ";", "}" ]
Handle query execution. @param QueryExecuteEvent $event
[ "Handle", "query", "execution", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Phpcr/QuerySubscriber.php#L98-L107
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/ContactRepository.php
ContactRepository.addSorting
private function addSorting($qb, $sorting, $prefix = 'u') { // Add order by foreach ($sorting as $k => $d) { $qb->addOrderBy($prefix . '.' . $k, $d); } return $qb; }
php
private function addSorting($qb, $sorting, $prefix = 'u') { // Add order by foreach ($sorting as $k => $d) { $qb->addOrderBy($prefix . '.' . $k, $d); } return $qb; }
[ "private", "function", "addSorting", "(", "$", "qb", ",", "$", "sorting", ",", "$", "prefix", "=", "'u'", ")", "{", "// Add order by", "foreach", "(", "$", "sorting", "as", "$", "k", "=>", "$", "d", ")", "{", "$", "qb", "->", "addOrderBy", "(", "$", "prefix", ".", "'.'", ".", "$", "k", ",", "$", "d", ")", ";", "}", "return", "$", "qb", ";", "}" ]
Add sorting to querybuilder. @param QueryBuilder $qb @param array $sorting @param string $prefix @return QueryBuilder
[ "Add", "sorting", "to", "querybuilder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/ContactRepository.php#L324-L332
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/ContactRepository.php
ContactRepository.addPagination
private function addPagination($qb, $offset, $limit) { // Add pagination $qb->setFirstResult($offset); $qb->setMaxResults($limit); return $qb; }
php
private function addPagination($qb, $offset, $limit) { // Add pagination $qb->setFirstResult($offset); $qb->setMaxResults($limit); return $qb; }
[ "private", "function", "addPagination", "(", "$", "qb", ",", "$", "offset", ",", "$", "limit", ")", "{", "// Add pagination", "$", "qb", "->", "setFirstResult", "(", "$", "offset", ")", ";", "$", "qb", "->", "setMaxResults", "(", "$", "limit", ")", ";", "return", "$", "qb", ";", "}" ]
add pagination to querybuilder. @param QueryBuilder $qb @param int|null $limit Page size for Pagination @param int|null $offset Offset for Pagination @return QueryBuilder
[ "add", "pagination", "to", "querybuilder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/ContactRepository.php#L343-L350
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/ContactRepository.php
ContactRepository.addWhere
private function addWhere($qb, $where, $prefix = '') { $prefix = '' !== $prefix ? $prefix . '.' : ''; $and = $qb->expr()->andX(); foreach ($where as $k => $v) { $and->add($qb->expr()->eq($prefix . $k, "'" . $v . "'")); } $qb->where($and); return $qb; }
php
private function addWhere($qb, $where, $prefix = '') { $prefix = '' !== $prefix ? $prefix . '.' : ''; $and = $qb->expr()->andX(); foreach ($where as $k => $v) { $and->add($qb->expr()->eq($prefix . $k, "'" . $v . "'")); } $qb->where($and); return $qb; }
[ "private", "function", "addWhere", "(", "$", "qb", ",", "$", "where", ",", "$", "prefix", "=", "''", ")", "{", "$", "prefix", "=", "''", "!==", "$", "prefix", "?", "$", "prefix", ".", "'.'", ":", "''", ";", "$", "and", "=", "$", "qb", "->", "expr", "(", ")", "->", "andX", "(", ")", ";", "foreach", "(", "$", "where", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "and", "->", "add", "(", "$", "qb", "->", "expr", "(", ")", "->", "eq", "(", "$", "prefix", ".", "$", "k", ",", "\"'\"", ".", "$", "v", ".", "\"'\"", ")", ")", ";", "}", "$", "qb", "->", "where", "(", "$", "and", ")", ";", "return", "$", "qb", ";", "}" ]
add where to querybuilder. @param QueryBuilder $qb @param array $where @param string $prefix @return QueryBuilder
[ "add", "where", "to", "querybuilder", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/ContactRepository.php#L361-L371
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Teaser/TeaserContentType.php
TeaserContentType.getValue
private function getValue(PropertyInterface $property) { $default = ['presentAs' => null, 'items' => []]; if (!is_array($property->getValue())) { return $default; } return array_merge($default, $property->getValue()); }
php
private function getValue(PropertyInterface $property) { $default = ['presentAs' => null, 'items' => []]; if (!is_array($property->getValue())) { return $default; } return array_merge($default, $property->getValue()); }
[ "private", "function", "getValue", "(", "PropertyInterface", "$", "property", ")", "{", "$", "default", "=", "[", "'presentAs'", "=>", "null", ",", "'items'", "=>", "[", "]", "]", ";", "if", "(", "!", "is_array", "(", "$", "property", "->", "getValue", "(", ")", ")", ")", "{", "return", "$", "default", ";", "}", "return", "array_merge", "(", "$", "default", ",", "$", "property", "->", "getValue", "(", ")", ")", ";", "}" ]
Returns property-value merged with defaults. @param PropertyInterface $property @return array
[ "Returns", "property", "-", "value", "merged", "with", "defaults", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Teaser/TeaserContentType.php#L191-L199
train
sulu/sulu
src/Sulu/Component/DocumentManager/ClassNameInflector.php
ClassNameInflector.getUserClassName
public static function getUserClassName($className) { if (null === self::$inflector) { static::$inflector = new ProxyManagerClassNameInflector(''); } return static::$inflector->getUserClassName($className); }
php
public static function getUserClassName($className) { if (null === self::$inflector) { static::$inflector = new ProxyManagerClassNameInflector(''); } return static::$inflector->getUserClassName($className); }
[ "public", "static", "function", "getUserClassName", "(", "$", "className", ")", "{", "if", "(", "null", "===", "self", "::", "$", "inflector", ")", "{", "static", "::", "$", "inflector", "=", "new", "ProxyManagerClassNameInflector", "(", "''", ")", ";", "}", "return", "static", "::", "$", "inflector", "->", "getUserClassName", "(", "$", "className", ")", ";", "}" ]
Return the "real" class name if the given class name is a proxy class name. @param string $className @return string
[ "Return", "the", "real", "class", "name", "if", "the", "given", "class", "name", "is", "a", "proxy", "class", "name", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/ClassNameInflector.php#L37-L44
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Controller/CustomerController.php
CustomerController.cgetAction
public function cgetAction(Request $request) { $ids = array_filter(explode(',', $request->get('ids', ''))); $result = $this->getCustomerManager()->findByIds($ids); $list = new CollectionRepresentation( $result, self::$entityKey ); $view = $this->view($list, 200); return $this->handleView($view); }
php
public function cgetAction(Request $request) { $ids = array_filter(explode(',', $request->get('ids', ''))); $result = $this->getCustomerManager()->findByIds($ids); $list = new CollectionRepresentation( $result, self::$entityKey ); $view = $this->view($list, 200); return $this->handleView($view); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ")", "{", "$", "ids", "=", "array_filter", "(", "explode", "(", "','", ",", "$", "request", "->", "get", "(", "'ids'", ",", "''", ")", ")", ")", ";", "$", "result", "=", "$", "this", "->", "getCustomerManager", "(", ")", "->", "findByIds", "(", "$", "ids", ")", ";", "$", "list", "=", "new", "CollectionRepresentation", "(", "$", "result", ",", "self", "::", "$", "entityKey", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "list", ",", "200", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Returns list of contacts and organizations. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "Returns", "list", "of", "contacts", "and", "organizations", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Controller/CustomerController.php#L33-L46
train
sulu/sulu
src/Sulu/Component/Webspace/Environment.php
Environment.addUrl
public function addUrl(Url $url) { $this->urls[] = $url; $url->setEnvironment($this->getType()); if ($url->isMain() || !$this->mainUrl) { $this->setMainUrl($url); } }
php
public function addUrl(Url $url) { $this->urls[] = $url; $url->setEnvironment($this->getType()); if ($url->isMain() || !$this->mainUrl) { $this->setMainUrl($url); } }
[ "public", "function", "addUrl", "(", "Url", "$", "url", ")", "{", "$", "this", "->", "urls", "[", "]", "=", "$", "url", ";", "$", "url", "->", "setEnvironment", "(", "$", "this", "->", "getType", "(", ")", ")", ";", "if", "(", "$", "url", "->", "isMain", "(", ")", "||", "!", "$", "this", "->", "mainUrl", ")", "{", "$", "this", "->", "setMainUrl", "(", "$", "url", ")", ";", "}", "}" ]
Adds a new url to this environment. @param $url Url The url to add
[ "Adds", "a", "new", "url", "to", "this", "environment", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Environment.php#L67-L76
train
sulu/sulu
src/Sulu/Component/Webspace/Environment.php
Environment.setMainUrl
private function setMainUrl(Url $url) { if (null !== $this->mainUrl) { $this->mainUrl->setMain(false); } $this->mainUrl = $url; $this->mainUrl->setMain(true); }
php
private function setMainUrl(Url $url) { if (null !== $this->mainUrl) { $this->mainUrl->setMain(false); } $this->mainUrl = $url; $this->mainUrl->setMain(true); }
[ "private", "function", "setMainUrl", "(", "Url", "$", "url", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "mainUrl", ")", "{", "$", "this", "->", "mainUrl", "->", "setMain", "(", "false", ")", ";", "}", "$", "this", "->", "mainUrl", "=", "$", "url", ";", "$", "this", "->", "mainUrl", "->", "setMain", "(", "true", ")", ";", "}" ]
Sets the main url. @param Url $url
[ "Sets", "the", "main", "url", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Environment.php#L83-L91
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.handleHydrate
public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $node = $event->getNode(); $property = $this->getResourceSegmentProperty($document); if (!$property) { // do not set a resource segment if the document has no structure return; } $locale = $this->documentInspector->getOriginalLocale($document); $segment = $node->getPropertyValueWithDefault( $this->encoder->localizedSystemName( $property->getName(), $locale ), '' ); $document->setResourceSegment($segment); }
php
public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } $node = $event->getNode(); $property = $this->getResourceSegmentProperty($document); if (!$property) { // do not set a resource segment if the document has no structure return; } $locale = $this->documentInspector->getOriginalLocale($document); $segment = $node->getPropertyValueWithDefault( $this->encoder->localizedSystemName( $property->getName(), $locale ), '' ); $document->setResourceSegment($segment); }
[ "public", "function", "handleHydrate", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "property", "=", "$", "this", "->", "getResourceSegmentProperty", "(", "$", "document", ")", ";", "if", "(", "!", "$", "property", ")", "{", "// do not set a resource segment if the document has no structure", "return", ";", "}", "$", "locale", "=", "$", "this", "->", "documentInspector", "->", "getOriginalLocale", "(", "$", "document", ")", ";", "$", "segment", "=", "$", "node", "->", "getPropertyValueWithDefault", "(", "$", "this", "->", "encoder", "->", "localizedSystemName", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "locale", ")", ",", "''", ")", ";", "$", "document", "->", "setResourceSegment", "(", "$", "segment", ")", ";", "}" ]
Sets the ResourceSegment of the document. @param AbstractMappingEvent $event
[ "Sets", "the", "ResourceSegment", "of", "the", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L130-L156
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.handlePersistDocument
public function handlePersistDocument(PersistEvent $event) { /** @var ResourceSegmentBehavior $document */ $document = $event->getDocument(); if (!$this->supports($document)) { return; } $property = $this->getResourceSegmentProperty($document); // check if a property for the resource segment is available, this prevents the code from failing in case there // is no such property for some reason (e.g. the document doesn't have a structure) if ($property) { $this->persistDocument($document, $property); } }
php
public function handlePersistDocument(PersistEvent $event) { /** @var ResourceSegmentBehavior $document */ $document = $event->getDocument(); if (!$this->supports($document)) { return; } $property = $this->getResourceSegmentProperty($document); // check if a property for the resource segment is available, this prevents the code from failing in case there // is no such property for some reason (e.g. the document doesn't have a structure) if ($property) { $this->persistDocument($document, $property); } }
[ "public", "function", "handlePersistDocument", "(", "PersistEvent", "$", "event", ")", "{", "/** @var ResourceSegmentBehavior $document */", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "property", "=", "$", "this", "->", "getResourceSegmentProperty", "(", "$", "document", ")", ";", "// check if a property for the resource segment is available, this prevents the code from failing in case there", "// is no such property for some reason (e.g. the document doesn't have a structure)", "if", "(", "$", "property", ")", "{", "$", "this", "->", "persistDocument", "(", "$", "document", ",", "$", "property", ")", ";", "}", "}" ]
Sets the ResourceSegment on the Structure. @param PersistEvent $event
[ "Sets", "the", "ResourceSegment", "on", "the", "Structure", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L163-L178
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.handlePersistRoute
public function handlePersistRoute(PublishEvent $event) { /** @var ResourceSegmentBehavior $document */ $document = $event->getDocument(); if (!$this->supports($document)) { return; } if (!$event->getLocale()) { return; } if ($document instanceof HomeDocument) { return; } if ($document instanceof RedirectTypeBehavior && RedirectType::NONE !== $document->getRedirectType()) { return; } $this->persistRoute($document); }
php
public function handlePersistRoute(PublishEvent $event) { /** @var ResourceSegmentBehavior $document */ $document = $event->getDocument(); if (!$this->supports($document)) { return; } if (!$event->getLocale()) { return; } if ($document instanceof HomeDocument) { return; } if ($document instanceof RedirectTypeBehavior && RedirectType::NONE !== $document->getRedirectType()) { return; } $this->persistRoute($document); }
[ "public", "function", "handlePersistRoute", "(", "PublishEvent", "$", "event", ")", "{", "/** @var ResourceSegmentBehavior $document */", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "if", "(", "!", "$", "event", "->", "getLocale", "(", ")", ")", "{", "return", ";", "}", "if", "(", "$", "document", "instanceof", "HomeDocument", ")", "{", "return", ";", "}", "if", "(", "$", "document", "instanceof", "RedirectTypeBehavior", "&&", "RedirectType", "::", "NONE", "!==", "$", "document", "->", "getRedirectType", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "persistRoute", "(", "$", "document", ")", ";", "}" ]
Creates or updates the route for the document. @param PublishEvent $event
[ "Creates", "or", "updates", "the", "route", "for", "the", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L185-L207
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.updateMovedDocument
public function updateMovedDocument(MoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof ResourceSegmentBehavior) { return; } $webspaceKey = $this->documentInspector->getWebspace($event->getDocument()); if (!$webspaceKey) { return; } $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey); if (ResourceLocatorStrategyInterface::INPUT_TYPE_LEAF !== $resourceLocatorStrategy->getInputType()) { return; } $this->updateRoute($document, true); }
php
public function updateMovedDocument(MoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof ResourceSegmentBehavior) { return; } $webspaceKey = $this->documentInspector->getWebspace($event->getDocument()); if (!$webspaceKey) { return; } $resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey); if (ResourceLocatorStrategyInterface::INPUT_TYPE_LEAF !== $resourceLocatorStrategy->getInputType()) { return; } $this->updateRoute($document, true); }
[ "public", "function", "updateMovedDocument", "(", "MoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ResourceSegmentBehavior", ")", "{", "return", ";", "}", "$", "webspaceKey", "=", "$", "this", "->", "documentInspector", "->", "getWebspace", "(", "$", "event", "->", "getDocument", "(", ")", ")", ";", "if", "(", "!", "$", "webspaceKey", ")", "{", "return", ";", "}", "$", "resourceLocatorStrategy", "=", "$", "this", "->", "resourceLocatorStrategyPool", "->", "getStrategyByWebspaceKey", "(", "$", "webspaceKey", ")", ";", "if", "(", "ResourceLocatorStrategyInterface", "::", "INPUT_TYPE_LEAF", "!==", "$", "resourceLocatorStrategy", "->", "getInputType", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "updateRoute", "(", "$", "document", ",", "true", ")", ";", "}" ]
Moves the routes for all localizations of the document in the event. @param MoveEvent $event
[ "Moves", "the", "routes", "for", "all", "localizations", "of", "the", "document", "in", "the", "event", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L214-L232
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.updateCopiedDocument
public function updateCopiedDocument(CopyEvent $event) { $document = $event->getDocument(); if (!$document instanceof ResourceSegmentBehavior) { return; } $this->updateRoute( $this->documentManager->find( $event->getCopiedPath(), $this->documentInspector->getLocale($document) ), false ); }
php
public function updateCopiedDocument(CopyEvent $event) { $document = $event->getDocument(); if (!$document instanceof ResourceSegmentBehavior) { return; } $this->updateRoute( $this->documentManager->find( $event->getCopiedPath(), $this->documentInspector->getLocale($document) ), false ); }
[ "public", "function", "updateCopiedDocument", "(", "CopyEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ResourceSegmentBehavior", ")", "{", "return", ";", "}", "$", "this", "->", "updateRoute", "(", "$", "this", "->", "documentManager", "->", "find", "(", "$", "event", "->", "getCopiedPath", "(", ")", ",", "$", "this", "->", "documentInspector", "->", "getLocale", "(", "$", "document", ")", ")", ",", "false", ")", ";", "}" ]
Copy the routes for all localization of the document in the event. @param CopyEvent $event
[ "Copy", "the", "routes", "for", "all", "localization", "of", "the", "document", "in", "the", "event", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L239-L253
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.getResourceSegmentProperty
private function getResourceSegmentProperty($document) { $structure = $this->documentInspector->getStructureMetadata($document); if (!$structure) { return; } $property = $structure->getPropertyByTagName('sulu.rlp'); if (!$property) { throw new \RuntimeException( sprintf( 'Structure "%s" does not have a "sulu.rlp" tag which is required for documents implementing the ' . 'ResourceSegmentBehavior. In "%s"', $structure->name, $structure->resource ) ); } return $property; }
php
private function getResourceSegmentProperty($document) { $structure = $this->documentInspector->getStructureMetadata($document); if (!$structure) { return; } $property = $structure->getPropertyByTagName('sulu.rlp'); if (!$property) { throw new \RuntimeException( sprintf( 'Structure "%s" does not have a "sulu.rlp" tag which is required for documents implementing the ' . 'ResourceSegmentBehavior. In "%s"', $structure->name, $structure->resource ) ); } return $property; }
[ "private", "function", "getResourceSegmentProperty", "(", "$", "document", ")", "{", "$", "structure", "=", "$", "this", "->", "documentInspector", "->", "getStructureMetadata", "(", "$", "document", ")", ";", "if", "(", "!", "$", "structure", ")", "{", "return", ";", "}", "$", "property", "=", "$", "structure", "->", "getPropertyByTagName", "(", "'sulu.rlp'", ")", ";", "if", "(", "!", "$", "property", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Structure \"%s\" does not have a \"sulu.rlp\" tag which is required for documents implementing the '", ".", "'ResourceSegmentBehavior. In \"%s\"'", ",", "$", "structure", "->", "name", ",", "$", "structure", "->", "resource", ")", ")", ";", "}", "return", "$", "property", ";", "}" ]
Returns the property of the document's structure containing the ResourceSegment. @param $document @return PropertyMetadata
[ "Returns", "the", "property", "of", "the", "document", "s", "structure", "containing", "the", "ResourceSegment", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L262-L284
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php
ResourceSegmentSubscriber.persistDocument
private function persistDocument(ResourceSegmentBehavior $document, PropertyMetadata $property) { $document->getStructure()->getProperty( $property->getName() )->setValue($document->getResourceSegment()); }
php
private function persistDocument(ResourceSegmentBehavior $document, PropertyMetadata $property) { $document->getStructure()->getProperty( $property->getName() )->setValue($document->getResourceSegment()); }
[ "private", "function", "persistDocument", "(", "ResourceSegmentBehavior", "$", "document", ",", "PropertyMetadata", "$", "property", ")", "{", "$", "document", "->", "getStructure", "(", ")", "->", "getProperty", "(", "$", "property", "->", "getName", "(", ")", ")", "->", "setValue", "(", "$", "document", "->", "getResourceSegment", "(", ")", ")", ";", "}" ]
Sets the ResourceSegment to the given property of the given document. @param ResourceSegmentBehavior $document @param PropertyMetadata $property
[ "Sets", "the", "ResourceSegment", "to", "the", "given", "property", "of", "the", "given", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L292-L297
train