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/Webspace/Manager/WebspaceManager.php
WebspaceManager.setOptions
public function setOptions($options) { $this->options = [ 'config_dir' => null, 'cache_dir' => null, 'debug' => false, 'cache_class' => 'WebspaceCollectionCache', 'base_class' => 'WebspaceCollection', ]; // overwrite the default values with the given options $this->options = array_merge($this->options, $options); }
php
public function setOptions($options) { $this->options = [ 'config_dir' => null, 'cache_dir' => null, 'debug' => false, 'cache_class' => 'WebspaceCollectionCache', 'base_class' => 'WebspaceCollection', ]; // overwrite the default values with the given options $this->options = array_merge($this->options, $options); }
[ "public", "function", "setOptions", "(", "$", "options", ")", "{", "$", "this", "->", "options", "=", "[", "'config_dir'", "=>", "null", ",", "'cache_dir'", "=>", "null", ",", "'debug'", "=>", "false", ",", "'cache_class'", "=>", "'WebspaceCollectionCache'", ",", "'base_class'", "=>", "'WebspaceCollection'", ",", "]", ";", "// overwrite the default values with the given options", "$", "this", "->", "options", "=", "array_merge", "(", "$", "this", "->", "options", ",", "$", "options", ")", ";", "}" ]
Sets the options for the manager. @param $options
[ "Sets", "the", "options", "for", "the", "manager", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Manager/WebspaceManager.php#L335-L347
train
sulu/sulu
src/Sulu/Component/Webspace/Manager/WebspaceManager.php
WebspaceManager.isFromDomain
protected function isFromDomain($url, $domain) { if (!$domain) { return true; } $parsedUrl = parse_url($url); // if domain or subdomain if ( isset($parsedUrl['host']) && ( $parsedUrl['host'] == $domain || fnmatch('*.' . $domain, $parsedUrl['host']) ) ) { return true; } return false; }
php
protected function isFromDomain($url, $domain) { if (!$domain) { return true; } $parsedUrl = parse_url($url); // if domain or subdomain if ( isset($parsedUrl['host']) && ( $parsedUrl['host'] == $domain || fnmatch('*.' . $domain, $parsedUrl['host']) ) ) { return true; } return false; }
[ "protected", "function", "isFromDomain", "(", "$", "url", ",", "$", "domain", ")", "{", "if", "(", "!", "$", "domain", ")", "{", "return", "true", ";", "}", "$", "parsedUrl", "=", "parse_url", "(", "$", "url", ")", ";", "// if domain or subdomain", "if", "(", "isset", "(", "$", "parsedUrl", "[", "'host'", "]", ")", "&&", "(", "$", "parsedUrl", "[", "'host'", "]", "==", "$", "domain", "||", "fnmatch", "(", "'*.'", ".", "$", "domain", ",", "$", "parsedUrl", "[", "'host'", "]", ")", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Url is from domain. @param $url @param $domain @return array
[ "Url", "is", "from", "domain", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Manager/WebspaceManager.php#L357-L376
train
sulu/sulu
src/Sulu/Component/Webspace/Manager/WebspaceManager.php
WebspaceManager.createResourceLocatorUrl
private function createResourceLocatorUrl($scheme, $portalUrl, $resourceLocator) { if (false !== strpos($portalUrl, '/')) { // trim slash when resourceLocator is not domain root $resourceLocator = rtrim($resourceLocator, '/'); } return rtrim(sprintf('%s://%s', $scheme, $portalUrl), '/') . $resourceLocator; }
php
private function createResourceLocatorUrl($scheme, $portalUrl, $resourceLocator) { if (false !== strpos($portalUrl, '/')) { // trim slash when resourceLocator is not domain root $resourceLocator = rtrim($resourceLocator, '/'); } return rtrim(sprintf('%s://%s', $scheme, $portalUrl), '/') . $resourceLocator; }
[ "private", "function", "createResourceLocatorUrl", "(", "$", "scheme", ",", "$", "portalUrl", ",", "$", "resourceLocator", ")", "{", "if", "(", "false", "!==", "strpos", "(", "$", "portalUrl", ",", "'/'", ")", ")", "{", "// trim slash when resourceLocator is not domain root", "$", "resourceLocator", "=", "rtrim", "(", "$", "resourceLocator", ",", "'/'", ")", ";", "}", "return", "rtrim", "(", "sprintf", "(", "'%s://%s'", ",", "$", "scheme", ",", "$", "portalUrl", ")", ",", "'/'", ")", ".", "$", "resourceLocator", ";", "}" ]
Return a valid resource locator url. @param string $scheme @param string $portalUrl @param string $resourceLocator @return string
[ "Return", "a", "valid", "resource", "locator", "url", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Manager/WebspaceManager.php#L400-L408
train
sulu/sulu
src/Sulu/Component/Content/Metadata/Loader/StructureXmlLoader.php
StructureXmlLoader.loadTemplateAttributes
protected function loadTemplateAttributes($resource, \DOMXPath $xpath, $type) { if ('page' === $type || 'home' === $type) { $result = [ 'key' => $this->getValueFromXPath('/x:template/x:key', $xpath), 'view' => $this->getValueFromXPath('/x:template/x:view', $xpath), 'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath), 'internal' => $this->getValueFromXPath('/x:template/x:internal', $xpath), 'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath), 'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath), 'areas' => $this->loadStructureAreas('/x:template/x:areas/x:area', $xpath), 'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath), ]; $result = array_filter( $result, function($value) { return null !== $value; } ); foreach (['key', 'view', 'controller', 'cacheLifetime'] as $requiredProperty) { if (!isset($result[$requiredProperty])) { throw new InvalidXmlException( $type, sprintf( 'Property "%s" is required in XML template file "%s"', $requiredProperty, $resource ) ); } } } else { $result = [ 'key' => $this->getValueFromXPath('/x:template/x:key', $xpath), 'view' => $this->getValueFromXPath('/x:template/x:view', $xpath), 'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath), 'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath), 'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath), 'areas' => $this->loadStructureAreas('/x:template/x:areas/x:area', $xpath), 'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath), ]; $result = array_filter( $result, function($value) { return null !== $value; } ); if (count($result) < 1) { throw new InvalidXmlException($result['key']); } } return $result; }
php
protected function loadTemplateAttributes($resource, \DOMXPath $xpath, $type) { if ('page' === $type || 'home' === $type) { $result = [ 'key' => $this->getValueFromXPath('/x:template/x:key', $xpath), 'view' => $this->getValueFromXPath('/x:template/x:view', $xpath), 'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath), 'internal' => $this->getValueFromXPath('/x:template/x:internal', $xpath), 'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath), 'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath), 'areas' => $this->loadStructureAreas('/x:template/x:areas/x:area', $xpath), 'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath), ]; $result = array_filter( $result, function($value) { return null !== $value; } ); foreach (['key', 'view', 'controller', 'cacheLifetime'] as $requiredProperty) { if (!isset($result[$requiredProperty])) { throw new InvalidXmlException( $type, sprintf( 'Property "%s" is required in XML template file "%s"', $requiredProperty, $resource ) ); } } } else { $result = [ 'key' => $this->getValueFromXPath('/x:template/x:key', $xpath), 'view' => $this->getValueFromXPath('/x:template/x:view', $xpath), 'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath), 'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath), 'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath), 'areas' => $this->loadStructureAreas('/x:template/x:areas/x:area', $xpath), 'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath), ]; $result = array_filter( $result, function($value) { return null !== $value; } ); if (count($result) < 1) { throw new InvalidXmlException($result['key']); } } return $result; }
[ "protected", "function", "loadTemplateAttributes", "(", "$", "resource", ",", "\\", "DOMXPath", "$", "xpath", ",", "$", "type", ")", "{", "if", "(", "'page'", "===", "$", "type", "||", "'home'", "===", "$", "type", ")", "{", "$", "result", "=", "[", "'key'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:key'", ",", "$", "xpath", ")", ",", "'view'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:view'", ",", "$", "xpath", ")", ",", "'controller'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:controller'", ",", "$", "xpath", ")", ",", "'internal'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:internal'", ",", "$", "xpath", ")", ",", "'cacheLifetime'", "=>", "$", "this", "->", "loadCacheLifetime", "(", "'/x:template/x:cacheLifetime'", ",", "$", "xpath", ")", ",", "'tags'", "=>", "$", "this", "->", "loadStructureTags", "(", "'/x:template/x:tag'", ",", "$", "xpath", ")", ",", "'areas'", "=>", "$", "this", "->", "loadStructureAreas", "(", "'/x:template/x:areas/x:area'", ",", "$", "xpath", ")", ",", "'meta'", "=>", "$", "this", "->", "loadMeta", "(", "'/x:template/x:meta/x:*'", ",", "$", "xpath", ")", ",", "]", ";", "$", "result", "=", "array_filter", "(", "$", "result", ",", "function", "(", "$", "value", ")", "{", "return", "null", "!==", "$", "value", ";", "}", ")", ";", "foreach", "(", "[", "'key'", ",", "'view'", ",", "'controller'", ",", "'cacheLifetime'", "]", "as", "$", "requiredProperty", ")", "{", "if", "(", "!", "isset", "(", "$", "result", "[", "$", "requiredProperty", "]", ")", ")", "{", "throw", "new", "InvalidXmlException", "(", "$", "type", ",", "sprintf", "(", "'Property \"%s\" is required in XML template file \"%s\"'", ",", "$", "requiredProperty", ",", "$", "resource", ")", ")", ";", "}", "}", "}", "else", "{", "$", "result", "=", "[", "'key'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:key'", ",", "$", "xpath", ")", ",", "'view'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:view'", ",", "$", "xpath", ")", ",", "'controller'", "=>", "$", "this", "->", "getValueFromXPath", "(", "'/x:template/x:controller'", ",", "$", "xpath", ")", ",", "'cacheLifetime'", "=>", "$", "this", "->", "loadCacheLifetime", "(", "'/x:template/x:cacheLifetime'", ",", "$", "xpath", ")", ",", "'tags'", "=>", "$", "this", "->", "loadStructureTags", "(", "'/x:template/x:tag'", ",", "$", "xpath", ")", ",", "'areas'", "=>", "$", "this", "->", "loadStructureAreas", "(", "'/x:template/x:areas/x:area'", ",", "$", "xpath", ")", ",", "'meta'", "=>", "$", "this", "->", "loadMeta", "(", "'/x:template/x:meta/x:*'", ",", "$", "xpath", ")", ",", "]", ";", "$", "result", "=", "array_filter", "(", "$", "result", ",", "function", "(", "$", "value", ")", "{", "return", "null", "!==", "$", "value", ";", "}", ")", ";", "if", "(", "count", "(", "$", "result", ")", "<", "1", ")", "{", "throw", "new", "InvalidXmlException", "(", "$", "result", "[", "'key'", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Load template attributes.
[ "Load", "template", "attributes", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Loader/StructureXmlLoader.php#L225-L282
train
sulu/sulu
src/Sulu/Component/Content/Metadata/Loader/StructureXmlLoader.php
StructureXmlLoader.loadCacheLifetime
private function loadCacheLifetime($path, \DOMXPath $xpath) { $nodeList = $xpath->query($path); if (!$nodeList->length) { return [ 'type' => CacheLifetimeResolverInterface::TYPE_SECONDS, 'value' => 0, ]; } // get first node $node = $nodeList->item(0); $type = $node->getAttribute('type'); if ('' === $type) { $type = CacheLifetimeResolverInterface::TYPE_SECONDS; } $value = $node->nodeValue; if (!$this->cacheLifetimeResolver->supports($type, $value)) { throw new \InvalidArgumentException( sprintf('CacheLifetime "%s" with type "%s" not supported.', $value, $type) ); } return [ 'type' => $type, 'value' => $value, ]; }
php
private function loadCacheLifetime($path, \DOMXPath $xpath) { $nodeList = $xpath->query($path); if (!$nodeList->length) { return [ 'type' => CacheLifetimeResolverInterface::TYPE_SECONDS, 'value' => 0, ]; } // get first node $node = $nodeList->item(0); $type = $node->getAttribute('type'); if ('' === $type) { $type = CacheLifetimeResolverInterface::TYPE_SECONDS; } $value = $node->nodeValue; if (!$this->cacheLifetimeResolver->supports($type, $value)) { throw new \InvalidArgumentException( sprintf('CacheLifetime "%s" with type "%s" not supported.', $value, $type) ); } return [ 'type' => $type, 'value' => $value, ]; }
[ "private", "function", "loadCacheLifetime", "(", "$", "path", ",", "\\", "DOMXPath", "$", "xpath", ")", "{", "$", "nodeList", "=", "$", "xpath", "->", "query", "(", "$", "path", ")", ";", "if", "(", "!", "$", "nodeList", "->", "length", ")", "{", "return", "[", "'type'", "=>", "CacheLifetimeResolverInterface", "::", "TYPE_SECONDS", ",", "'value'", "=>", "0", ",", "]", ";", "}", "// get first node", "$", "node", "=", "$", "nodeList", "->", "item", "(", "0", ")", ";", "$", "type", "=", "$", "node", "->", "getAttribute", "(", "'type'", ")", ";", "if", "(", "''", "===", "$", "type", ")", "{", "$", "type", "=", "CacheLifetimeResolverInterface", "::", "TYPE_SECONDS", ";", "}", "$", "value", "=", "$", "node", "->", "nodeValue", ";", "if", "(", "!", "$", "this", "->", "cacheLifetimeResolver", "->", "supports", "(", "$", "type", ",", "$", "value", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'CacheLifetime \"%s\" with type \"%s\" not supported.'", ",", "$", "value", ",", "$", "type", ")", ")", ";", "}", "return", "[", "'type'", "=>", "$", "type", ",", "'value'", "=>", "$", "value", ",", "]", ";", "}" ]
Load cache lifetime metadata. @param $path @param \DOMXPath $xpath @return array
[ "Load", "cache", "lifetime", "metadata", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Loader/StructureXmlLoader.php#L292-L322
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/Expression/Doctrine/DoctrineBetweenExpression.php
DoctrineBetweenExpression.getStatement
public function getStatement(QueryBuilder $queryBuilder) { $paramName1 = $this->getFieldName() . $this->getUniqueId(); $paramName2 = $this->getFieldName() . $this->getUniqueId(); $queryBuilder->setParameter($paramName1, $this->getStart()); $queryBuilder->setParameter($paramName2, $this->getEnd()); return $this->field->getSelect() . ' BETWEEN :' . $paramName1 . ' AND :' . $paramName2; }
php
public function getStatement(QueryBuilder $queryBuilder) { $paramName1 = $this->getFieldName() . $this->getUniqueId(); $paramName2 = $this->getFieldName() . $this->getUniqueId(); $queryBuilder->setParameter($paramName1, $this->getStart()); $queryBuilder->setParameter($paramName2, $this->getEnd()); return $this->field->getSelect() . ' BETWEEN :' . $paramName1 . ' AND :' . $paramName2; }
[ "public", "function", "getStatement", "(", "QueryBuilder", "$", "queryBuilder", ")", "{", "$", "paramName1", "=", "$", "this", "->", "getFieldName", "(", ")", ".", "$", "this", "->", "getUniqueId", "(", ")", ";", "$", "paramName2", "=", "$", "this", "->", "getFieldName", "(", ")", ".", "$", "this", "->", "getUniqueId", "(", ")", ";", "$", "queryBuilder", "->", "setParameter", "(", "$", "paramName1", ",", "$", "this", "->", "getStart", "(", ")", ")", ";", "$", "queryBuilder", "->", "setParameter", "(", "$", "paramName2", ",", "$", "this", "->", "getEnd", "(", ")", ")", ";", "return", "$", "this", "->", "field", "->", "getSelect", "(", ")", ".", "' BETWEEN :'", ".", "$", "paramName1", ".", "' AND :'", ".", "$", "paramName2", ";", "}" ]
Returns a statement for an expression. @param QueryBuilder $queryBuilder @return string
[ "Returns", "a", "statement", "for", "an", "expression", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/Expression/Doctrine/DoctrineBetweenExpression.php#L61-L69
train
sulu/sulu
src/Sulu/Component/DocumentManager/Metadata.php
Metadata.addFieldMapping
public function addFieldMapping($name, $mapping) { $mapping = array_merge([ 'encoding' => 'content', 'property' => $name, 'type' => null, 'mapped' => true, 'multiple' => false, 'default' => null, ], $mapping); $this->fieldMappings[$name] = $mapping; }
php
public function addFieldMapping($name, $mapping) { $mapping = array_merge([ 'encoding' => 'content', 'property' => $name, 'type' => null, 'mapped' => true, 'multiple' => false, 'default' => null, ], $mapping); $this->fieldMappings[$name] = $mapping; }
[ "public", "function", "addFieldMapping", "(", "$", "name", ",", "$", "mapping", ")", "{", "$", "mapping", "=", "array_merge", "(", "[", "'encoding'", "=>", "'content'", ",", "'property'", "=>", "$", "name", ",", "'type'", "=>", "null", ",", "'mapped'", "=>", "true", ",", "'multiple'", "=>", "false", ",", "'default'", "=>", "null", ",", "]", ",", "$", "mapping", ")", ";", "$", "this", "->", "fieldMappings", "[", "$", "name", "]", "=", "$", "mapping", ";", "}" ]
Add a field mapping for field with given name, for example. ```` $metadata->addFieldMapping(array( 'encoding' => 'content', 'property' => 'phpcr_property_name', )); ```` @param string $name Name of field/property in the mapped class @param array $mapping { @var string Encoding type to use, @see \Sulu\Component\DocumentManager\PropertyEncoder::encode() @var string PHPCR property name (excluding the prefix) @var string Type of field (leave blank to determine automatically) @var bool If the field should be mapped. Set to false to manually persist and hydrate the data. }
[ "Add", "a", "field", "mapping", "for", "field", "with", "given", "name", "for", "example", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Metadata.php#L75-L87
train
sulu/sulu
src/Sulu/Component/DocumentManager/Metadata.php
Metadata.getReflectionClass
public function getReflectionClass() { if ($this->reflection) { return $this->reflection; } if (!$this->class) { throw new \InvalidArgumentException( 'Cannot retrieve ReflectionClass on metadata which has no class attribute' ); } $this->reflection = new \ReflectionClass($this->class); return $this->reflection; }
php
public function getReflectionClass() { if ($this->reflection) { return $this->reflection; } if (!$this->class) { throw new \InvalidArgumentException( 'Cannot retrieve ReflectionClass on metadata which has no class attribute' ); } $this->reflection = new \ReflectionClass($this->class); return $this->reflection; }
[ "public", "function", "getReflectionClass", "(", ")", "{", "if", "(", "$", "this", "->", "reflection", ")", "{", "return", "$", "this", "->", "reflection", ";", "}", "if", "(", "!", "$", "this", "->", "class", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Cannot retrieve ReflectionClass on metadata which has no class attribute'", ")", ";", "}", "$", "this", "->", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "this", "->", "class", ")", ";", "return", "$", "this", "->", "reflection", ";", "}" ]
Returns reflection-class. @return \ReflectionClass
[ "Returns", "reflection", "-", "class", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Metadata.php#L125-L140
train
sulu/sulu
src/Sulu/Bundle/DocumentManagerBundle/DataFixtures/DocumentExecutor.php
DocumentExecutor.execute
public function execute(array $fixtures, $purge = true, $initialize = true, OutputInterface $output = null) { $output = $output ?: new NullOutput(); if (true === $initialize) { $output->writeln('<comment>Initializing repository</comment>'); $this->initializer->initialize($output, $purge); } $output->writeln('<comment>Loading fixtures</comment>'); foreach ($fixtures as $fixture) { $output->writeln(sprintf( ' - %s<info>loading "</info>%s<info>"</info>', $fixture instanceof OrderedFixtureInterface ? '[' . $fixture->getOrder() . ']' : '', get_class($fixture) )); $fixture->load($this->documentManager); $this->documentManager->clear(); } }
php
public function execute(array $fixtures, $purge = true, $initialize = true, OutputInterface $output = null) { $output = $output ?: new NullOutput(); if (true === $initialize) { $output->writeln('<comment>Initializing repository</comment>'); $this->initializer->initialize($output, $purge); } $output->writeln('<comment>Loading fixtures</comment>'); foreach ($fixtures as $fixture) { $output->writeln(sprintf( ' - %s<info>loading "</info>%s<info>"</info>', $fixture instanceof OrderedFixtureInterface ? '[' . $fixture->getOrder() . ']' : '', get_class($fixture) )); $fixture->load($this->documentManager); $this->documentManager->clear(); } }
[ "public", "function", "execute", "(", "array", "$", "fixtures", ",", "$", "purge", "=", "true", ",", "$", "initialize", "=", "true", ",", "OutputInterface", "$", "output", "=", "null", ")", "{", "$", "output", "=", "$", "output", "?", ":", "new", "NullOutput", "(", ")", ";", "if", "(", "true", "===", "$", "initialize", ")", "{", "$", "output", "->", "writeln", "(", "'<comment>Initializing repository</comment>'", ")", ";", "$", "this", "->", "initializer", "->", "initialize", "(", "$", "output", ",", "$", "purge", ")", ";", "}", "$", "output", "->", "writeln", "(", "'<comment>Loading fixtures</comment>'", ")", ";", "foreach", "(", "$", "fixtures", "as", "$", "fixture", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "' - %s<info>loading \"</info>%s<info>\"</info>'", ",", "$", "fixture", "instanceof", "OrderedFixtureInterface", "?", "'['", ".", "$", "fixture", "->", "getOrder", "(", ")", ".", "']'", ":", "''", ",", "get_class", "(", "$", "fixture", ")", ")", ")", ";", "$", "fixture", "->", "load", "(", "$", "this", "->", "documentManager", ")", ";", "$", "this", "->", "documentManager", "->", "clear", "(", ")", ";", "}", "}" ]
Load the given fixture classes. @param array $fixtures @param mixed $purge @param mixed $initialize @param OutputInterface $output
[ "Load", "the", "given", "fixture", "classes", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/DocumentManagerBundle/DataFixtures/DocumentExecutor.php#L59-L79
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/EventListener/RouterListener.php
RouterListener.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); // This call is required in all cases, because the default router needs our webspace information // Would be nice to also only call this if the _requestAnalyzer attribute is set, but it's set on the next line $this->requestAnalyzer->analyze($request); $this->baseRouteListener->onKernelRequest($event); if (false !== $request->attributes->get(static::REQUEST_ANALYZER, true)) { $this->requestAnalyzer->validate($request); } }
php
public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); // This call is required in all cases, because the default router needs our webspace information // Would be nice to also only call this if the _requestAnalyzer attribute is set, but it's set on the next line $this->requestAnalyzer->analyze($request); $this->baseRouteListener->onKernelRequest($event); if (false !== $request->attributes->get(static::REQUEST_ANALYZER, true)) { $this->requestAnalyzer->validate($request); } }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "// This call is required in all cases, because the default router needs our webspace information", "// Would be nice to also only call this if the _requestAnalyzer attribute is set, but it's set on the next line", "$", "this", "->", "requestAnalyzer", "->", "analyze", "(", "$", "request", ")", ";", "$", "this", "->", "baseRouteListener", "->", "onKernelRequest", "(", "$", "event", ")", ";", "if", "(", "false", "!==", "$", "request", "->", "attributes", "->", "get", "(", "static", "::", "REQUEST_ANALYZER", ",", "true", ")", ")", "{", "$", "this", "->", "requestAnalyzer", "->", "validate", "(", "$", "request", ")", ";", "}", "}" ]
Analyzes the request before passing the event to the default RouterListener from symfony and validates the result afterwards. @param GetResponseEvent $event
[ "Analyzes", "the", "request", "before", "passing", "the", "event", "to", "the", "default", "RouterListener", "from", "symfony", "and", "validates", "the", "result", "afterwards", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/EventListener/RouterListener.php#L52-L63
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getParent
public function getParent() { $account = $this->entity->getParent(); if ($account) { return new self($account, $this->locale); } return; }
php
public function getParent() { $account = $this->entity->getParent(); if ($account) { return new self($account, $this->locale); } return; }
[ "public", "function", "getParent", "(", ")", "{", "$", "account", "=", "$", "this", "->", "entity", "->", "getParent", "(", ")", ";", "if", "(", "$", "account", ")", "{", "return", "new", "self", "(", "$", "account", ",", "$", "this", "->", "locale", ")", ";", "}", "return", ";", "}" ]
Get parent. @return AccountInterface @VirtualProperty @SerializedName("parent") @Groups({"fullAccount"})
[ "Get", "parent", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L205-L213
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getSocialMediaProfiles
public function getSocialMediaProfiles() { $socialMediaProfiles = []; if ($this->entity->getSocialMediaProfiles()) { foreach ($this->entity->getSocialMediaProfiles() as $socialMediaProfile) { $socialMediaProfiles[] = $socialMediaProfile; } } return $socialMediaProfiles; }
php
public function getSocialMediaProfiles() { $socialMediaProfiles = []; if ($this->entity->getSocialMediaProfiles()) { foreach ($this->entity->getSocialMediaProfiles() as $socialMediaProfile) { $socialMediaProfiles[] = $socialMediaProfile; } } return $socialMediaProfiles; }
[ "public", "function", "getSocialMediaProfiles", "(", ")", "{", "$", "socialMediaProfiles", "=", "[", "]", ";", "if", "(", "$", "this", "->", "entity", "->", "getSocialMediaProfiles", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "entity", "->", "getSocialMediaProfiles", "(", ")", "as", "$", "socialMediaProfile", ")", "{", "$", "socialMediaProfiles", "[", "]", "=", "$", "socialMediaProfile", ";", "}", "}", "return", "$", "socialMediaProfiles", ";", "}" ]
Get social media profiles. @return SocialMediaProfileEntity[] @VirtualProperty @SerializedName("socialMediaProfiles") @Groups({"fullAccount"})
[ "Get", "social", "media", "profiles", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L482-L492
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getBankAccounts
public function getBankAccounts() { $bankAccounts = []; if ($this->entity->getBankAccounts()) { foreach ($this->entity->getBankAccounts() as $bankAccount) { /* @var BankAccountEntity $bankAccount */ $bankAccounts[] = new BankAccount($bankAccount); } } return $bankAccounts; }
php
public function getBankAccounts() { $bankAccounts = []; if ($this->entity->getBankAccounts()) { foreach ($this->entity->getBankAccounts() as $bankAccount) { /* @var BankAccountEntity $bankAccount */ $bankAccounts[] = new BankAccount($bankAccount); } } return $bankAccounts; }
[ "public", "function", "getBankAccounts", "(", ")", "{", "$", "bankAccounts", "=", "[", "]", ";", "if", "(", "$", "this", "->", "entity", "->", "getBankAccounts", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "entity", "->", "getBankAccounts", "(", ")", "as", "$", "bankAccount", ")", "{", "/* @var BankAccountEntity $bankAccount */", "$", "bankAccounts", "[", "]", "=", "new", "BankAccount", "(", "$", "bankAccount", ")", ";", "}", "}", "return", "$", "bankAccounts", ";", "}" ]
Get bankAccounts. @return BankAccountEntity[] @VirtualProperty @SerializedName("bankAccounts") @Groups({"fullAccount"})
[ "Get", "bankAccounts", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L607-L618
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getAccountContacts
public function getAccountContacts() { $accountContacts = []; if ($this->entity->getAccountContacts()) { foreach ($this->entity->getAccountContacts() as $AccountContact) { $accountContacts[] = new AccountContact($AccountContact, $this->locale); } } return $accountContacts; }
php
public function getAccountContacts() { $accountContacts = []; if ($this->entity->getAccountContacts()) { foreach ($this->entity->getAccountContacts() as $AccountContact) { $accountContacts[] = new AccountContact($AccountContact, $this->locale); } } return $accountContacts; }
[ "public", "function", "getAccountContacts", "(", ")", "{", "$", "accountContacts", "=", "[", "]", ";", "if", "(", "$", "this", "->", "entity", "->", "getAccountContacts", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "entity", "->", "getAccountContacts", "(", ")", "as", "$", "AccountContact", ")", "{", "$", "accountContacts", "[", "]", "=", "new", "AccountContact", "(", "$", "AccountContact", ",", "$", "this", "->", "locale", ")", ";", "}", "}", "return", "$", "accountContacts", ";", "}" ]
Get accountContacts. @return AccountContact[] @VirtualProperty @SerializedName("accountContacts") @Groups({"fullAccount"})
[ "Get", "accountContacts", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L689-L699
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getMainContact
public function getMainContact() { if ($this->entity->getMainContact()) { return new Contact($this->entity->getMainContact(), $this->locale); } }
php
public function getMainContact() { if ($this->entity->getMainContact()) { return new Contact($this->entity->getMainContact(), $this->locale); } }
[ "public", "function", "getMainContact", "(", ")", "{", "if", "(", "$", "this", "->", "entity", "->", "getMainContact", "(", ")", ")", "{", "return", "new", "Contact", "(", "$", "this", "->", "entity", "->", "getMainContact", "(", ")", ",", "$", "this", "->", "locale", ")", ";", "}", "}" ]
Get mainContact. @return Account @VirtualProperty @SerializedName("mainContact") @Groups({"fullAccount"})
[ "Get", "mainContact", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L804-L809
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getAccountAddresses
public function getAccountAddresses() { $accountAddresses = []; if ($this->entity->getAccountAddresses()) { foreach ($this->entity->getAccountAddresses() as $adr) { $accountAddress[] = new AccountAddress($adr); } } return $accountAddresses; }
php
public function getAccountAddresses() { $accountAddresses = []; if ($this->entity->getAccountAddresses()) { foreach ($this->entity->getAccountAddresses() as $adr) { $accountAddress[] = new AccountAddress($adr); } } return $accountAddresses; }
[ "public", "function", "getAccountAddresses", "(", ")", "{", "$", "accountAddresses", "=", "[", "]", ";", "if", "(", "$", "this", "->", "entity", "->", "getAccountAddresses", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "entity", "->", "getAccountAddresses", "(", ")", "as", "$", "adr", ")", "{", "$", "accountAddress", "[", "]", "=", "new", "AccountAddress", "(", "$", "adr", ")", ";", "}", "}", "return", "$", "accountAddresses", ";", "}" ]
Get accountAddresses. @return AccountAddress[] @VirtualProperty @SerializedName("accountAddresses")
[ "Get", "accountAddresses", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L950-L960
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getAddresses
public function getAddresses() { $accountAddresses = $this->entity->getAccountAddresses(); $addresses = []; if (!is_null($accountAddresses)) { /** @var ContactAddress $accountAddress */ foreach ($accountAddresses as $accountAddress) { $address = $accountAddress->getAddress(); $address->setPrimaryAddress($accountAddress->getMain()); $addresses[] = new Address($address, $this->locale); } } return $addresses; }
php
public function getAddresses() { $accountAddresses = $this->entity->getAccountAddresses(); $addresses = []; if (!is_null($accountAddresses)) { /** @var ContactAddress $accountAddress */ foreach ($accountAddresses as $accountAddress) { $address = $accountAddress->getAddress(); $address->setPrimaryAddress($accountAddress->getMain()); $addresses[] = new Address($address, $this->locale); } } return $addresses; }
[ "public", "function", "getAddresses", "(", ")", "{", "$", "accountAddresses", "=", "$", "this", "->", "entity", "->", "getAccountAddresses", "(", ")", ";", "$", "addresses", "=", "[", "]", ";", "if", "(", "!", "is_null", "(", "$", "accountAddresses", ")", ")", "{", "/** @var ContactAddress $accountAddress */", "foreach", "(", "$", "accountAddresses", "as", "$", "accountAddress", ")", "{", "$", "address", "=", "$", "accountAddress", "->", "getAddress", "(", ")", ";", "$", "address", "->", "setPrimaryAddress", "(", "$", "accountAddress", "->", "getMain", "(", ")", ")", ";", "$", "addresses", "[", "]", "=", "new", "Address", "(", "$", "address", ",", "$", "this", "->", "locale", ")", ";", "}", "}", "return", "$", "addresses", ";", "}" ]
returns addresses. @VirtualProperty @SerializedName("addresses") @Groups({"fullAccount"})
[ "returns", "addresses", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L969-L984
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getMainAddress
public function getMainAddress() { $accountAddresses = $this->entity->getAccountAddresses(); if (!is_null($accountAddresses)) { /** @var AccountAddressEntity $accountAddress */ foreach ($accountAddresses as $accountAddress) { if ($accountAddress->getMain()) { return $accountAddress->getAddress(); } } } return; }
php
public function getMainAddress() { $accountAddresses = $this->entity->getAccountAddresses(); if (!is_null($accountAddresses)) { /** @var AccountAddressEntity $accountAddress */ foreach ($accountAddresses as $accountAddress) { if ($accountAddress->getMain()) { return $accountAddress->getAddress(); } } } return; }
[ "public", "function", "getMainAddress", "(", ")", "{", "$", "accountAddresses", "=", "$", "this", "->", "entity", "->", "getAccountAddresses", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "accountAddresses", ")", ")", "{", "/** @var AccountAddressEntity $accountAddress */", "foreach", "(", "$", "accountAddresses", "as", "$", "accountAddress", ")", "{", "if", "(", "$", "accountAddress", "->", "getMain", "(", ")", ")", "{", "return", "$", "accountAddress", "->", "getAddress", "(", ")", ";", "}", "}", "}", "return", ";", "}" ]
Returns the main address. @return mixed @VirtualProperty @SerializedName("mainAddress") @Groups({"fullAccount", "partialAccount"})
[ "Returns", "the", "main", "address", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L994-L1008
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Api/Account.php
Account.getLogo
public function getLogo() { if ($this->logo) { return [ 'id' => $this->logo->getId(), 'url' => $this->logo->getUrl(), 'thumbnails' => $this->logo->getFormats(), ]; } return; }
php
public function getLogo() { if ($this->logo) { return [ 'id' => $this->logo->getId(), 'url' => $this->logo->getUrl(), 'thumbnails' => $this->logo->getFormats(), ]; } return; }
[ "public", "function", "getLogo", "(", ")", "{", "if", "(", "$", "this", "->", "logo", ")", "{", "return", "[", "'id'", "=>", "$", "this", "->", "logo", "->", "getId", "(", ")", ",", "'url'", "=>", "$", "this", "->", "logo", "->", "getUrl", "(", ")", ",", "'thumbnails'", "=>", "$", "this", "->", "logo", "->", "getFormats", "(", ")", ",", "]", ";", "}", "return", ";", "}" ]
Get the accounts logo and return the array of different formats. @return Media @VirtualProperty @SerializedName("logo") @Groups({"fullAccount"})
[ "Get", "the", "accounts", "logo", "and", "return", "the", "array", "of", "different", "formats", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Api/Account.php#L1052-L1063
train
sulu/sulu
src/Sulu/Component/PHPCR/PathCleanup.php
PathCleanup.cleanup
public function cleanup($dirty, $languageCode = null) { $replacers = $this->replacers['default']; if (null !== $languageCode) { $replacers = array_merge( $replacers, (isset($this->replacers[$languageCode]) ? $this->replacers[$languageCode] : []) ); } if (count($replacers) > 0) { foreach ($replacers as $key => $value) { $dirty = str_replace($key, $value, $dirty); } } $clean = strtolower($dirty); // Inspired by ZOOLU // delete problematic characters $clean = str_replace('%2F', '/', urlencode(preg_replace('/([^A-za-z0-9 -_\/])/', '', $clean))); // replace multiple dash with one $clean = preg_replace('/([-]+)/', '-', $clean); // remove dash after slash $clean = preg_replace('/\/[-]+/', '/', $clean); // delete dash at the beginning or end $clean = preg_replace('/^([-])/', '', $clean); $clean = preg_replace('/([-])$/', '', $clean); // remove double slashes $clean = str_replace('//', '/', $clean); return $clean; }
php
public function cleanup($dirty, $languageCode = null) { $replacers = $this->replacers['default']; if (null !== $languageCode) { $replacers = array_merge( $replacers, (isset($this->replacers[$languageCode]) ? $this->replacers[$languageCode] : []) ); } if (count($replacers) > 0) { foreach ($replacers as $key => $value) { $dirty = str_replace($key, $value, $dirty); } } $clean = strtolower($dirty); // Inspired by ZOOLU // delete problematic characters $clean = str_replace('%2F', '/', urlencode(preg_replace('/([^A-za-z0-9 -_\/])/', '', $clean))); // replace multiple dash with one $clean = preg_replace('/([-]+)/', '-', $clean); // remove dash after slash $clean = preg_replace('/\/[-]+/', '/', $clean); // delete dash at the beginning or end $clean = preg_replace('/^([-])/', '', $clean); $clean = preg_replace('/([-])$/', '', $clean); // remove double slashes $clean = str_replace('//', '/', $clean); return $clean; }
[ "public", "function", "cleanup", "(", "$", "dirty", ",", "$", "languageCode", "=", "null", ")", "{", "$", "replacers", "=", "$", "this", "->", "replacers", "[", "'default'", "]", ";", "if", "(", "null", "!==", "$", "languageCode", ")", "{", "$", "replacers", "=", "array_merge", "(", "$", "replacers", ",", "(", "isset", "(", "$", "this", "->", "replacers", "[", "$", "languageCode", "]", ")", "?", "$", "this", "->", "replacers", "[", "$", "languageCode", "]", ":", "[", "]", ")", ")", ";", "}", "if", "(", "count", "(", "$", "replacers", ")", ">", "0", ")", "{", "foreach", "(", "$", "replacers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "dirty", "=", "str_replace", "(", "$", "key", ",", "$", "value", ",", "$", "dirty", ")", ";", "}", "}", "$", "clean", "=", "strtolower", "(", "$", "dirty", ")", ";", "// Inspired by ZOOLU", "// delete problematic characters", "$", "clean", "=", "str_replace", "(", "'%2F'", ",", "'/'", ",", "urlencode", "(", "preg_replace", "(", "'/([^A-za-z0-9 -_\\/])/'", ",", "''", ",", "$", "clean", ")", ")", ")", ";", "// replace multiple dash with one", "$", "clean", "=", "preg_replace", "(", "'/([-]+)/'", ",", "'-'", ",", "$", "clean", ")", ";", "// remove dash after slash", "$", "clean", "=", "preg_replace", "(", "'/\\/[-]+/'", ",", "'/'", ",", "$", "clean", ")", ";", "// delete dash at the beginning or end", "$", "clean", "=", "preg_replace", "(", "'/^([-])/'", ",", "''", ",", "$", "clean", ")", ";", "$", "clean", "=", "preg_replace", "(", "'/([-])$/'", ",", "''", ",", "$", "clean", ")", ";", "// remove double slashes", "$", "clean", "=", "str_replace", "(", "'//'", ",", "'/'", ",", "$", "clean", ")", ";", "return", "$", "clean", ";", "}" ]
returns a clean string. @param string $dirty dirty string to cleanup @param string $languageCode @return string clean string
[ "returns", "a", "clean", "string", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/PHPCR/PathCleanup.php#L56-L93
train
sulu/sulu
src/Sulu/Component/Content/Metadata/PropertiesMetadata.php
PropertiesMetadata.getProperty
public function getProperty($name) { if (!isset($this->properties[$name])) { throw new \InvalidArgumentException( sprintf( 'Unknown model property "%s", in structure "%s". Known model properties: "%s". Loaded from "%s"', $name, $this->getName(), implode('", "', array_keys($this->properties)), $this->resource ) ); } return $this->properties[$name]; }
php
public function getProperty($name) { if (!isset($this->properties[$name])) { throw new \InvalidArgumentException( sprintf( 'Unknown model property "%s", in structure "%s". Known model properties: "%s". Loaded from "%s"', $name, $this->getName(), implode('", "', array_keys($this->properties)), $this->resource ) ); } return $this->properties[$name]; }
[ "public", "function", "getProperty", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "properties", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Unknown model property \"%s\", in structure \"%s\". Known model properties: \"%s\". Loaded from \"%s\"'", ",", "$", "name", ",", "$", "this", "->", "getName", "(", ")", ",", "implode", "(", "'\", \"'", ",", "array_keys", "(", "$", "this", "->", "properties", ")", ")", ",", "$", "this", "->", "resource", ")", ")", ";", "}", "return", "$", "this", "->", "properties", "[", "$", "name", "]", ";", "}" ]
Return a model property. @see StructureMetadata::getProperties() @param string $name @return PropertyMetadata
[ "Return", "a", "model", "property", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/PropertiesMetadata.php#L56-L71
train
sulu/sulu
src/Sulu/Component/Content/Metadata/PropertiesMetadata.php
PropertiesMetadata.getPropertyByTagName
public function getPropertyByTagName($tagName, $highest = true) { $properties = $this->getPropertiesByTagName($tagName); if (!$properties) { throw new \InvalidArgumentException( sprintf( 'No property with tag "%s" exists. In structure "%s" loaded from "%s"', $tagName, $this->name, $this->resource ) ); } return reset($properties); }
php
public function getPropertyByTagName($tagName, $highest = true) { $properties = $this->getPropertiesByTagName($tagName); if (!$properties) { throw new \InvalidArgumentException( sprintf( 'No property with tag "%s" exists. In structure "%s" loaded from "%s"', $tagName, $this->name, $this->resource ) ); } return reset($properties); }
[ "public", "function", "getPropertyByTagName", "(", "$", "tagName", ",", "$", "highest", "=", "true", ")", "{", "$", "properties", "=", "$", "this", "->", "getPropertiesByTagName", "(", "$", "tagName", ")", ";", "if", "(", "!", "$", "properties", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'No property with tag \"%s\" exists. In structure \"%s\" loaded from \"%s\"'", ",", "$", "tagName", ",", "$", "this", "->", "name", ",", "$", "this", "->", "resource", ")", ")", ";", "}", "return", "reset", "(", "$", "properties", ")", ";", "}" ]
Return true if the structure contains a property with the given tag name. @param string $tagName @return PropertyMetadata
[ "Return", "true", "if", "the", "structure", "contains", "a", "property", "with", "the", "given", "tag", "name", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/PropertiesMetadata.php#L135-L151
train
sulu/sulu
src/Sulu/Component/Content/Metadata/PropertiesMetadata.php
PropertiesMetadata.getPropertiesByTagName
public function getPropertiesByTagName($tagName) { $properties = []; foreach ($this->properties as $property) { foreach ($property->tags as $tag) { if ($tag['name'] == $tagName) { $properties[$property->name] = $property; } } } return $properties; }
php
public function getPropertiesByTagName($tagName) { $properties = []; foreach ($this->properties as $property) { foreach ($property->tags as $tag) { if ($tag['name'] == $tagName) { $properties[$property->name] = $property; } } } return $properties; }
[ "public", "function", "getPropertiesByTagName", "(", "$", "tagName", ")", "{", "$", "properties", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "properties", "as", "$", "property", ")", "{", "foreach", "(", "$", "property", "->", "tags", "as", "$", "tag", ")", "{", "if", "(", "$", "tag", "[", "'name'", "]", "==", "$", "tagName", ")", "{", "$", "properties", "[", "$", "property", "->", "name", "]", "=", "$", "property", ";", "}", "}", "}", "return", "$", "properties", ";", "}" ]
Return all properties with the given tag name. @param string $tagName @return PropertyMetadata[]
[ "Return", "all", "properties", "with", "the", "given", "tag", "name", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/PropertiesMetadata.php#L173-L186
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Teaser/ContentTeaserProvider.php
ContentTeaserProvider.getMedia
private function getMedia(Document $document, $field) { $images = json_decode($document->getField($field)->getValue(), true); if (!array_key_exists('ids', $images) || 0 === count($images['ids'])) { return; } return $images['ids'][0]; }
php
private function getMedia(Document $document, $field) { $images = json_decode($document->getField($field)->getValue(), true); if (!array_key_exists('ids', $images) || 0 === count($images['ids'])) { return; } return $images['ids'][0]; }
[ "private", "function", "getMedia", "(", "Document", "$", "document", ",", "$", "field", ")", "{", "$", "images", "=", "json_decode", "(", "$", "document", "->", "getField", "(", "$", "field", ")", "->", "getValue", "(", ")", ",", "true", ")", ";", "if", "(", "!", "array_key_exists", "(", "'ids'", ",", "$", "images", ")", "||", "0", "===", "count", "(", "$", "images", "[", "'ids'", "]", ")", ")", "{", "return", ";", "}", "return", "$", "images", "[", "'ids'", "]", "[", "0", "]", ";", "}" ]
Returns media-id. @param Document $document @param string $field @return int|null
[ "Returns", "media", "-", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Teaser/ContentTeaserProvider.php#L121-L130
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
UserRepository.findUserByUsername
public function findUserByUsername($username) { $qb = $this->createQueryBuilder('user') ->where('user.username=:username'); $query = $qb->getQuery(); $query->setParameter('username', $username); return $query->getSingleResult(); }
php
public function findUserByUsername($username) { $qb = $this->createQueryBuilder('user') ->where('user.username=:username'); $query = $qb->getQuery(); $query->setParameter('username', $username); return $query->getSingleResult(); }
[ "public", "function", "findUserByUsername", "(", "$", "username", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'user'", ")", "->", "where", "(", "'user.username=:username'", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'username'", ",", "$", "username", ")", ";", "return", "$", "query", "->", "getSingleResult", "(", ")", ";", "}" ]
Finds a user for the given username. This method throws UsernameNotFoundException if the user is not found. @param string $username The username @return UserInterface @throws NoResultException if the user is not found
[ "Finds", "a", "user", "for", "the", "given", "username", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php#L156-L165
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
UserRepository.findAllUsersByRoleId
public function findAllUsersByRoleId($roleId) { $qb = $this->createQueryBuilder('user') ->leftJoin('user.userRoles', 'userRole') ->leftJoin('userRole.role', 'role') ->where('role=:roleId'); $query = $qb->getQuery(); $query->setParameter('roleId', $roleId); return $query->getResult(); }
php
public function findAllUsersByRoleId($roleId) { $qb = $this->createQueryBuilder('user') ->leftJoin('user.userRoles', 'userRole') ->leftJoin('userRole.role', 'role') ->where('role=:roleId'); $query = $qb->getQuery(); $query->setParameter('roleId', $roleId); return $query->getResult(); }
[ "public", "function", "findAllUsersByRoleId", "(", "$", "roleId", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'user'", ")", "->", "leftJoin", "(", "'user.userRoles'", ",", "'userRole'", ")", "->", "leftJoin", "(", "'userRole.role'", ",", "'role'", ")", "->", "where", "(", "'role=:roleId'", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'roleId'", ",", "$", "roleId", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Finds all users for the role with the given id. @param int $roleId @return array
[ "Finds", "all", "users", "for", "the", "role", "with", "the", "given", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php#L174-L185
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
UserRepository.findUserByEmail
public function findUserByEmail($email) { $qb = $this->createQueryBuilder('user') ->where('user.email=:email'); $query = $qb->getQuery(); $query->setParameter('email', $email); return $query->getSingleResult(); }
php
public function findUserByEmail($email) { $qb = $this->createQueryBuilder('user') ->where('user.email=:email'); $query = $qb->getQuery(); $query->setParameter('email', $email); return $query->getSingleResult(); }
[ "public", "function", "findUserByEmail", "(", "$", "email", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'user'", ")", "->", "where", "(", "'user.email=:email'", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'email'", ",", "$", "email", ")", ";", "return", "$", "query", "->", "getSingleResult", "(", ")", ";", "}" ]
Finds a user for a given email. @param string $email The email-address @return UserInterface @throws NoResultException if the user is not found
[ "Finds", "a", "user", "for", "a", "given", "email", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php#L196-L205
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
UserRepository.findUserByToken
public function findUserByToken($token) { $qb = $this->createQueryBuilder('user') ->where('user.passwordResetToken=:token'); $query = $qb->getQuery(); $query->setParameter('token', $token); return $query->getSingleResult(); }
php
public function findUserByToken($token) { $qb = $this->createQueryBuilder('user') ->where('user.passwordResetToken=:token'); $query = $qb->getQuery(); $query->setParameter('token', $token); return $query->getSingleResult(); }
[ "public", "function", "findUserByToken", "(", "$", "token", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'user'", ")", "->", "where", "(", "'user.passwordResetToken=:token'", ")", ";", "$", "query", "=", "$", "qb", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'token'", ",", "$", "token", ")", ";", "return", "$", "query", "->", "getSingleResult", "(", ")", ";", "}" ]
Finds a user for a given password-reset-token. @param string $token the reset-token @return UserInterface @throws NoResultException if the user is not found
[ "Finds", "a", "user", "for", "a", "given", "password", "-", "reset", "-", "token", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php#L216-L225
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php
UserRepository.findUserBySystem
public function findUserBySystem($system) { $queryBuilder = $this->createQueryBuilder('user') ->select('user', 'contact') ->leftJoin('user.userRoles', 'userRoles') ->leftJoin('user.contact', 'contact') ->leftJoin('userRoles.role', 'role') ->where('role.system = :system'); $query = $queryBuilder->getQuery(); $query->setParameter('system', $system); return $query->getResult(); }
php
public function findUserBySystem($system) { $queryBuilder = $this->createQueryBuilder('user') ->select('user', 'contact') ->leftJoin('user.userRoles', 'userRoles') ->leftJoin('user.contact', 'contact') ->leftJoin('userRoles.role', 'role') ->where('role.system = :system'); $query = $queryBuilder->getQuery(); $query->setParameter('system', $system); return $query->getResult(); }
[ "public", "function", "findUserBySystem", "(", "$", "system", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'user'", ")", "->", "select", "(", "'user'", ",", "'contact'", ")", "->", "leftJoin", "(", "'user.userRoles'", ",", "'userRoles'", ")", "->", "leftJoin", "(", "'user.contact'", ",", "'contact'", ")", "->", "leftJoin", "(", "'userRoles.role'", ",", "'role'", ")", "->", "where", "(", "'role.system = :system'", ")", ";", "$", "query", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'system'", ",", "$", "system", ")", ";", "return", "$", "query", "->", "getResult", "(", ")", ";", "}" ]
Returns all users with the given system including their contacts. @param string $system @return User[]
[ "Returns", "all", "users", "with", "the", "given", "system", "including", "their", "contacts", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/UserRepository.php#L281-L294
train
sulu/sulu
src/Sulu/Bundle/SearchBundle/Controller/SearchController.php
SearchController.searchAction
public function searchAction(Request $request) { $queryString = $request->query->get('q'); $index = $request->query->get('index', null); $locale = $request->query->get('locale', null); $page = $this->listRestHelper->getPage(); $limit = $this->listRestHelper->getLimit(); $startTime = microtime(true); $indexes = $index ? [$index] : $this->getAllowedIndexes(); $query = $this->searchManager->createSearch($queryString); if ($locale) { $query->locale($locale); } $query->indexes($indexes); $query->setLimit($limit); $time = microtime(true) - $startTime; $adapter = new ArrayAdapter(iterator_to_array($query->execute())); $pager = new Pagerfanta($adapter); $pager->setMaxPerPage($limit); $pager->setCurrentPage($page); $representation = new SearchResultRepresentation( new CollectionRepresentation($pager->getCurrentPageResults(), 'result'), 'sulu_search_search', [ 'locale' => $locale, 'query' => $query, 'index' => $index, ], (int) $page, (int) $limit, $pager->getNbPages(), 'page', 'limit', false, $adapter->getNbResults(), $this->getIndexTotals($adapter->getArray()), number_format($time, 8) ); $view = View::create($representation); $context = new Context(); $context->enableMaxDepth(); $view->setContext($context); return $this->viewHandler->handle($view); }
php
public function searchAction(Request $request) { $queryString = $request->query->get('q'); $index = $request->query->get('index', null); $locale = $request->query->get('locale', null); $page = $this->listRestHelper->getPage(); $limit = $this->listRestHelper->getLimit(); $startTime = microtime(true); $indexes = $index ? [$index] : $this->getAllowedIndexes(); $query = $this->searchManager->createSearch($queryString); if ($locale) { $query->locale($locale); } $query->indexes($indexes); $query->setLimit($limit); $time = microtime(true) - $startTime; $adapter = new ArrayAdapter(iterator_to_array($query->execute())); $pager = new Pagerfanta($adapter); $pager->setMaxPerPage($limit); $pager->setCurrentPage($page); $representation = new SearchResultRepresentation( new CollectionRepresentation($pager->getCurrentPageResults(), 'result'), 'sulu_search_search', [ 'locale' => $locale, 'query' => $query, 'index' => $index, ], (int) $page, (int) $limit, $pager->getNbPages(), 'page', 'limit', false, $adapter->getNbResults(), $this->getIndexTotals($adapter->getArray()), number_format($time, 8) ); $view = View::create($representation); $context = new Context(); $context->enableMaxDepth(); $view->setContext($context); return $this->viewHandler->handle($view); }
[ "public", "function", "searchAction", "(", "Request", "$", "request", ")", "{", "$", "queryString", "=", "$", "request", "->", "query", "->", "get", "(", "'q'", ")", ";", "$", "index", "=", "$", "request", "->", "query", "->", "get", "(", "'index'", ",", "null", ")", ";", "$", "locale", "=", "$", "request", "->", "query", "->", "get", "(", "'locale'", ",", "null", ")", ";", "$", "page", "=", "$", "this", "->", "listRestHelper", "->", "getPage", "(", ")", ";", "$", "limit", "=", "$", "this", "->", "listRestHelper", "->", "getLimit", "(", ")", ";", "$", "startTime", "=", "microtime", "(", "true", ")", ";", "$", "indexes", "=", "$", "index", "?", "[", "$", "index", "]", ":", "$", "this", "->", "getAllowedIndexes", "(", ")", ";", "$", "query", "=", "$", "this", "->", "searchManager", "->", "createSearch", "(", "$", "queryString", ")", ";", "if", "(", "$", "locale", ")", "{", "$", "query", "->", "locale", "(", "$", "locale", ")", ";", "}", "$", "query", "->", "indexes", "(", "$", "indexes", ")", ";", "$", "query", "->", "setLimit", "(", "$", "limit", ")", ";", "$", "time", "=", "microtime", "(", "true", ")", "-", "$", "startTime", ";", "$", "adapter", "=", "new", "ArrayAdapter", "(", "iterator_to_array", "(", "$", "query", "->", "execute", "(", ")", ")", ")", ";", "$", "pager", "=", "new", "Pagerfanta", "(", "$", "adapter", ")", ";", "$", "pager", "->", "setMaxPerPage", "(", "$", "limit", ")", ";", "$", "pager", "->", "setCurrentPage", "(", "$", "page", ")", ";", "$", "representation", "=", "new", "SearchResultRepresentation", "(", "new", "CollectionRepresentation", "(", "$", "pager", "->", "getCurrentPageResults", "(", ")", ",", "'result'", ")", ",", "'sulu_search_search'", ",", "[", "'locale'", "=>", "$", "locale", ",", "'query'", "=>", "$", "query", ",", "'index'", "=>", "$", "index", ",", "]", ",", "(", "int", ")", "$", "page", ",", "(", "int", ")", "$", "limit", ",", "$", "pager", "->", "getNbPages", "(", ")", ",", "'page'", ",", "'limit'", ",", "false", ",", "$", "adapter", "->", "getNbResults", "(", ")", ",", "$", "this", "->", "getIndexTotals", "(", "$", "adapter", "->", "getArray", "(", ")", ")", ",", "number_format", "(", "$", "time", ",", "8", ")", ")", ";", "$", "view", "=", "View", "::", "create", "(", "$", "representation", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "enableMaxDepth", "(", ")", ";", "$", "view", "->", "setContext", "(", "$", "context", ")", ";", "return", "$", "this", "->", "viewHandler", "->", "handle", "(", "$", "view", ")", ";", "}" ]
Perform a search and return a JSON response. @param Request $request @return Response
[ "Perform", "a", "search", "and", "return", "a", "JSON", "response", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SearchBundle/Controller/SearchController.php#L97-L150
train
sulu/sulu
src/Sulu/Bundle/SearchBundle/Controller/SearchController.php
SearchController.indexesAction
public function indexesAction() { return $this->viewHandler->handle( View::create( array_map( function($indexName) { $indexConfiguration = $this->indexConfigurationProvider->getIndexConfiguration($indexName); return $indexConfiguration ?: new IndexConfiguration($indexName); }, $this->getAllowedIndexes() ) ) ); }
php
public function indexesAction() { return $this->viewHandler->handle( View::create( array_map( function($indexName) { $indexConfiguration = $this->indexConfigurationProvider->getIndexConfiguration($indexName); return $indexConfiguration ?: new IndexConfiguration($indexName); }, $this->getAllowedIndexes() ) ) ); }
[ "public", "function", "indexesAction", "(", ")", "{", "return", "$", "this", "->", "viewHandler", "->", "handle", "(", "View", "::", "create", "(", "array_map", "(", "function", "(", "$", "indexName", ")", "{", "$", "indexConfiguration", "=", "$", "this", "->", "indexConfigurationProvider", "->", "getIndexConfiguration", "(", "$", "indexName", ")", ";", "return", "$", "indexConfiguration", "?", ":", "new", "IndexConfiguration", "(", "$", "indexName", ")", ";", "}", ",", "$", "this", "->", "getAllowedIndexes", "(", ")", ")", ")", ")", ";", "}" ]
Return a JSON encoded scalar array of index names. @return Response
[ "Return", "a", "JSON", "encoded", "scalar", "array", "of", "index", "names", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SearchBundle/Controller/SearchController.php#L157-L171
train
sulu/sulu
src/Sulu/Bundle/SearchBundle/Controller/SearchController.php
SearchController.getIndexTotals
private function getIndexTotals($hits) { $indexNames = $this->searchManager->getIndexNames(); $indexCount = array_combine( $indexNames, array_fill(0, count($indexNames), 0) ); foreach ($hits as $hit) { ++$indexCount[$hit->getDocument()->getIndex()]; } return $indexCount; }
php
private function getIndexTotals($hits) { $indexNames = $this->searchManager->getIndexNames(); $indexCount = array_combine( $indexNames, array_fill(0, count($indexNames), 0) ); foreach ($hits as $hit) { ++$indexCount[$hit->getDocument()->getIndex()]; } return $indexCount; }
[ "private", "function", "getIndexTotals", "(", "$", "hits", ")", "{", "$", "indexNames", "=", "$", "this", "->", "searchManager", "->", "getIndexNames", "(", ")", ";", "$", "indexCount", "=", "array_combine", "(", "$", "indexNames", ",", "array_fill", "(", "0", ",", "count", "(", "$", "indexNames", ")", ",", "0", ")", ")", ";", "foreach", "(", "$", "hits", "as", "$", "hit", ")", "{", "++", "$", "indexCount", "[", "$", "hit", "->", "getDocument", "(", ")", "->", "getIndex", "(", ")", "]", ";", "}", "return", "$", "indexCount", ";", "}" ]
Return the category totals for the search results. @param Hit[] @return array
[ "Return", "the", "category", "totals", "for", "the", "search", "results", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SearchBundle/Controller/SearchController.php#L180-L193
train
sulu/sulu
src/Sulu/Component/Webspace/Portal.php
Portal.addLocalization
public function addLocalization(Localization $localization) { $this->localizations[] = $localization; if ($localization->isDefault()) { $this->setDefaultLocalization($localization); } if ($localization->isXDefault()) { $this->setXDefaultLocalization($localization); } }
php
public function addLocalization(Localization $localization) { $this->localizations[] = $localization; if ($localization->isDefault()) { $this->setDefaultLocalization($localization); } if ($localization->isXDefault()) { $this->setXDefaultLocalization($localization); } }
[ "public", "function", "addLocalization", "(", "Localization", "$", "localization", ")", "{", "$", "this", "->", "localizations", "[", "]", "=", "$", "localization", ";", "if", "(", "$", "localization", "->", "isDefault", "(", ")", ")", "{", "$", "this", "->", "setDefaultLocalization", "(", "$", "localization", ")", ";", "}", "if", "(", "$", "localization", "->", "isXDefault", "(", ")", ")", "{", "$", "this", "->", "setXDefaultLocalization", "(", "$", "localization", ")", ";", "}", "}" ]
Adds the given language to the portal. @param Localization $localization
[ "Adds", "the", "given", "language", "to", "the", "portal", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Portal.php#L109-L120
train
sulu/sulu
src/Sulu/Component/Webspace/Portal.php
Portal.setEnvironments
public function setEnvironments(array $environments) { $this->environments = []; foreach ($environments as $environment) { $this->addEnvironment($environment); } }
php
public function setEnvironments(array $environments) { $this->environments = []; foreach ($environments as $environment) { $this->addEnvironment($environment); } }
[ "public", "function", "setEnvironments", "(", "array", "$", "environments", ")", "{", "$", "this", "->", "environments", "=", "[", "]", ";", "foreach", "(", "$", "environments", "as", "$", "environment", ")", "{", "$", "this", "->", "addEnvironment", "(", "$", "environment", ")", ";", "}", "}" ]
Sets the environments for this portal. @param \Sulu\Component\Webspace\Environment[] $environments
[ "Sets", "the", "environments", "for", "this", "portal", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Portal.php#L204-L211
train
sulu/sulu
src/Sulu/Component/Webspace/Portal.php
Portal.getEnvironment
public function getEnvironment($type) { if (!isset($this->environments[$type])) { throw new EnvironmentNotFoundException($this, $type); } return $this->environments[$type]; }
php
public function getEnvironment($type) { if (!isset($this->environments[$type])) { throw new EnvironmentNotFoundException($this, $type); } return $this->environments[$type]; }
[ "public", "function", "getEnvironment", "(", "$", "type", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "environments", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "EnvironmentNotFoundException", "(", "$", "this", ",", "$", "type", ")", ";", "}", "return", "$", "this", "->", "environments", "[", "$", "type", "]", ";", "}" ]
Returns the environment with the given type, and throws an exception if the environment does not exist. @param string $type @throws Exception\EnvironmentNotFoundException @return \Sulu\Component\Webspace\Environment
[ "Returns", "the", "environment", "with", "the", "given", "type", "and", "throws", "an", "exception", "if", "the", "environment", "does", "not", "exist", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Portal.php#L232-L239
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.getLanguage
private function getLanguage(Request $request) { $locale = $this->getRequestParameter($request, 'locale', false, null); if ($locale) { return $locale; } return $this->getRequestParameter($request, 'language', true); }
php
private function getLanguage(Request $request) { $locale = $this->getRequestParameter($request, 'locale', false, null); if ($locale) { return $locale; } return $this->getRequestParameter($request, 'language', true); }
[ "private", "function", "getLanguage", "(", "Request", "$", "request", ")", "{", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "false", ",", "null", ")", ";", "if", "(", "$", "locale", ")", "{", "return", "$", "locale", ";", "}", "return", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'language'", ",", "true", ")", ";", "}" ]
returns language code from request. @param Request $request @return string
[ "returns", "language", "code", "from", "request", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L72-L81
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.getAction
public function getAction(Request $request, $id) { if (null !== $request->get('fields')) { return $this->getContent($request, $id); } return $this->getSingleNode($request, $id); }
php
public function getAction(Request $request, $id) { if (null !== $request->get('fields')) { return $this->getContent($request, $id); } return $this->getSingleNode($request, $id); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "if", "(", "null", "!==", "$", "request", "->", "get", "(", "'fields'", ")", ")", "{", "return", "$", "this", "->", "getContent", "(", "$", "request", ",", "$", "id", ")", ";", "}", "return", "$", "this", "->", "getSingleNode", "(", "$", "request", ",", "$", "id", ")", ";", "}" ]
returns a content item with given UUID as JSON String. @param Request $request @param string $id @return \Symfony\Component\HttpFoundation\Response
[ "returns", "a", "content", "item", "with", "given", "UUID", "as", "JSON", "String", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L146-L153
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.getContent
private function getContent(Request $request, $id) { $properties = array_filter(explode(',', $request->get('fields', ''))); $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false); $excludeShadows = $this->getBooleanRequestParameter($request, 'exclude-shadows', false, false); $webspaceNodes = $this->getRequestParameter($request, 'webspace-nodes'); $locale = $this->getRequestParameter($request, 'language', true); $webspaceKey = $this->getRequestParameter($request, 'webspace'); $user = $this->getUser(); $mapping = MappingBuilder::create() ->setHydrateGhost(!$excludeGhosts) ->setHydrateShadow(!$excludeShadows) ->setResolveConcreteLocales(true) ->addProperties($properties) ->getMapping(); $data = $this->get('sulu_page.content_repository')->find($id, $locale, $webspaceKey, $mapping, $user); $view = $this->view($data); return $this->handleView($view); }
php
private function getContent(Request $request, $id) { $properties = array_filter(explode(',', $request->get('fields', ''))); $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false); $excludeShadows = $this->getBooleanRequestParameter($request, 'exclude-shadows', false, false); $webspaceNodes = $this->getRequestParameter($request, 'webspace-nodes'); $locale = $this->getRequestParameter($request, 'language', true); $webspaceKey = $this->getRequestParameter($request, 'webspace'); $user = $this->getUser(); $mapping = MappingBuilder::create() ->setHydrateGhost(!$excludeGhosts) ->setHydrateShadow(!$excludeShadows) ->setResolveConcreteLocales(true) ->addProperties($properties) ->getMapping(); $data = $this->get('sulu_page.content_repository')->find($id, $locale, $webspaceKey, $mapping, $user); $view = $this->view($data); return $this->handleView($view); }
[ "private", "function", "getContent", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "properties", "=", "array_filter", "(", "explode", "(", "','", ",", "$", "request", "->", "get", "(", "'fields'", ",", "''", ")", ")", ")", ";", "$", "excludeGhosts", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'exclude-ghosts'", ",", "false", ",", "false", ")", ";", "$", "excludeShadows", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'exclude-shadows'", ",", "false", ",", "false", ")", ";", "$", "webspaceNodes", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'webspace-nodes'", ")", ";", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'language'", ",", "true", ")", ";", "$", "webspaceKey", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'webspace'", ")", ";", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "$", "mapping", "=", "MappingBuilder", "::", "create", "(", ")", "->", "setHydrateGhost", "(", "!", "$", "excludeGhosts", ")", "->", "setHydrateShadow", "(", "!", "$", "excludeShadows", ")", "->", "setResolveConcreteLocales", "(", "true", ")", "->", "addProperties", "(", "$", "properties", ")", "->", "getMapping", "(", ")", ";", "$", "data", "=", "$", "this", "->", "get", "(", "'sulu_page.content_repository'", ")", "->", "find", "(", "$", "id", ",", "$", "locale", ",", "$", "webspaceKey", ",", "$", "mapping", ",", "$", "user", ")", ";", "$", "view", "=", "$", "this", "->", "view", "(", "$", "data", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Returns single content. @param Request $request @param $id @return \Symfony\Component\HttpFoundation\Response @throws \Sulu\Component\Rest\Exception\MissingParameterException @throws \Sulu\Component\Rest\Exception\ParameterDataTypeException
[ "Returns", "single", "content", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L166-L188
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.getTreeContent
private function getTreeContent( $id, $locale, $webspaceKey, $webspaceNodes, MappingInterface $mapping, UserInterface $user ) { if (!in_array($webspaceNodes, [static::WEBSPACE_NODE_SINGLE, static::WEBSPACE_NODES_ALL, null])) { throw new ParameterDataTypeException(get_class($this), 'webspace-nodes'); } try { $contents = $this->get('sulu_page.content_repository')->findParentsWithSiblingsByUuid( $id, $locale, $webspaceKey, $mapping, $user ); } catch (ItemNotFoundException $e) { throw new EntityNotFoundException('node', $id, $e); } if ($webspaceNodes === static::WEBSPACE_NODES_ALL) { $contents = $this->getWebspaceNodes($mapping, $contents, $locale, $user); } elseif ($webspaceNodes === static::WEBSPACE_NODE_SINGLE) { $contents = $this->getWebspaceNode($mapping, $contents, $webspaceKey, $locale, $user); } $view = $this->view(new CollectionRepresentation($contents, static::$relationName)); return $this->handleView($view); }
php
private function getTreeContent( $id, $locale, $webspaceKey, $webspaceNodes, MappingInterface $mapping, UserInterface $user ) { if (!in_array($webspaceNodes, [static::WEBSPACE_NODE_SINGLE, static::WEBSPACE_NODES_ALL, null])) { throw new ParameterDataTypeException(get_class($this), 'webspace-nodes'); } try { $contents = $this->get('sulu_page.content_repository')->findParentsWithSiblingsByUuid( $id, $locale, $webspaceKey, $mapping, $user ); } catch (ItemNotFoundException $e) { throw new EntityNotFoundException('node', $id, $e); } if ($webspaceNodes === static::WEBSPACE_NODES_ALL) { $contents = $this->getWebspaceNodes($mapping, $contents, $locale, $user); } elseif ($webspaceNodes === static::WEBSPACE_NODE_SINGLE) { $contents = $this->getWebspaceNode($mapping, $contents, $webspaceKey, $locale, $user); } $view = $this->view(new CollectionRepresentation($contents, static::$relationName)); return $this->handleView($view); }
[ "private", "function", "getTreeContent", "(", "$", "id", ",", "$", "locale", ",", "$", "webspaceKey", ",", "$", "webspaceNodes", ",", "MappingInterface", "$", "mapping", ",", "UserInterface", "$", "user", ")", "{", "if", "(", "!", "in_array", "(", "$", "webspaceNodes", ",", "[", "static", "::", "WEBSPACE_NODE_SINGLE", ",", "static", "::", "WEBSPACE_NODES_ALL", ",", "null", "]", ")", ")", "{", "throw", "new", "ParameterDataTypeException", "(", "get_class", "(", "$", "this", ")", ",", "'webspace-nodes'", ")", ";", "}", "try", "{", "$", "contents", "=", "$", "this", "->", "get", "(", "'sulu_page.content_repository'", ")", "->", "findParentsWithSiblingsByUuid", "(", "$", "id", ",", "$", "locale", ",", "$", "webspaceKey", ",", "$", "mapping", ",", "$", "user", ")", ";", "}", "catch", "(", "ItemNotFoundException", "$", "e", ")", "{", "throw", "new", "EntityNotFoundException", "(", "'node'", ",", "$", "id", ",", "$", "e", ")", ";", "}", "if", "(", "$", "webspaceNodes", "===", "static", "::", "WEBSPACE_NODES_ALL", ")", "{", "$", "contents", "=", "$", "this", "->", "getWebspaceNodes", "(", "$", "mapping", ",", "$", "contents", ",", "$", "locale", ",", "$", "user", ")", ";", "}", "elseif", "(", "$", "webspaceNodes", "===", "static", "::", "WEBSPACE_NODE_SINGLE", ")", "{", "$", "contents", "=", "$", "this", "->", "getWebspaceNode", "(", "$", "mapping", ",", "$", "contents", ",", "$", "webspaceKey", ",", "$", "locale", ",", "$", "user", ")", ";", "}", "$", "view", "=", "$", "this", "->", "view", "(", "new", "CollectionRepresentation", "(", "$", "contents", ",", "static", "::", "$", "relationName", ")", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
Returns tree response for given id. @param string $id @param string $locale @param string $webspaceKey @param bool $webspaceNodes @param MappingInterface $mapping @param UserInterface $user @return Response @throws ParameterDataTypeException @throws EntityNotFoundException
[ "Returns", "tree", "response", "for", "given", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L205-L238
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.getTreeForUuid
private function getTreeForUuid(Request $request, $id) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request, false); $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false); $excludeShadows = $this->getBooleanRequestParameter($request, 'exclude-shadows', false, false); try { if (null !== $id && '' !== $id) { $result = $this->getRepository()->getNodesTree( $id, $webspace, $language, $excludeGhosts, $excludeShadows ); } elseif (null !== $webspace) { $result = $this->getRepository()->getWebspaceNode($webspace, $language); } else { $result = $this->getRepository()->getWebspaceNodes($language); } } catch (DocumentNotFoundException $ex) { // TODO return 404 and handle this edge case on client side return $this->redirect( $this->generateUrl( 'get_nodes', [ 'tree' => 'false', 'depth' => 1, 'language' => $language, 'webspace' => $webspace, 'exclude-ghosts' => $excludeGhosts, ] ) ); } return $this->handleView( $this->view($result) ); }
php
private function getTreeForUuid(Request $request, $id) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request, false); $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false); $excludeShadows = $this->getBooleanRequestParameter($request, 'exclude-shadows', false, false); try { if (null !== $id && '' !== $id) { $result = $this->getRepository()->getNodesTree( $id, $webspace, $language, $excludeGhosts, $excludeShadows ); } elseif (null !== $webspace) { $result = $this->getRepository()->getWebspaceNode($webspace, $language); } else { $result = $this->getRepository()->getWebspaceNodes($language); } } catch (DocumentNotFoundException $ex) { // TODO return 404 and handle this edge case on client side return $this->redirect( $this->generateUrl( 'get_nodes', [ 'tree' => 'false', 'depth' => 1, 'language' => $language, 'webspace' => $webspace, 'exclude-ghosts' => $excludeGhosts, ] ) ); } return $this->handleView( $this->view($result) ); }
[ "private", "function", "getTreeForUuid", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "webspace", "=", "$", "this", "->", "getWebspace", "(", "$", "request", ",", "false", ")", ";", "$", "excludeGhosts", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'exclude-ghosts'", ",", "false", ",", "false", ")", ";", "$", "excludeShadows", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'exclude-shadows'", ",", "false", ",", "false", ")", ";", "try", "{", "if", "(", "null", "!==", "$", "id", "&&", "''", "!==", "$", "id", ")", "{", "$", "result", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getNodesTree", "(", "$", "id", ",", "$", "webspace", ",", "$", "language", ",", "$", "excludeGhosts", ",", "$", "excludeShadows", ")", ";", "}", "elseif", "(", "null", "!==", "$", "webspace", ")", "{", "$", "result", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getWebspaceNode", "(", "$", "webspace", ",", "$", "language", ")", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getWebspaceNodes", "(", "$", "language", ")", ";", "}", "}", "catch", "(", "DocumentNotFoundException", "$", "ex", ")", "{", "// TODO return 404 and handle this edge case on client side", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'get_nodes'", ",", "[", "'tree'", "=>", "'false'", ",", "'depth'", "=>", "1", ",", "'language'", "=>", "$", "language", ",", "'webspace'", "=>", "$", "webspace", ",", "'exclude-ghosts'", "=>", "$", "excludeGhosts", ",", "]", ")", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "result", ")", ")", ";", "}" ]
Returns a tree along the given path with the siblings of all nodes on the path. This functionality is required for preloading the content navigation. @param Request $request @param string $id @return \Symfony\Component\HttpFoundation\Response
[ "Returns", "a", "tree", "along", "the", "given", "path", "with", "the", "siblings", "of", "all", "nodes", "on", "the", "path", ".", "This", "functionality", "is", "required", "for", "preloading", "the", "content", "navigation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L301-L341
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.getNodesByIds
private function getNodesByIds(Request $request, $idString) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request, false); $result = $this->getRepository()->getNodesByIds( preg_split('/[,]/', $idString, -1, PREG_SPLIT_NO_EMPTY), $webspace, $language ); return $this->handleView($this->view($result)); }
php
private function getNodesByIds(Request $request, $idString) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request, false); $result = $this->getRepository()->getNodesByIds( preg_split('/[,]/', $idString, -1, PREG_SPLIT_NO_EMPTY), $webspace, $language ); return $this->handleView($this->view($result)); }
[ "private", "function", "getNodesByIds", "(", "Request", "$", "request", ",", "$", "idString", ")", "{", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "webspace", "=", "$", "this", "->", "getWebspace", "(", "$", "request", ",", "false", ")", ";", "$", "result", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getNodesByIds", "(", "preg_split", "(", "'/[,]/'", ",", "$", "idString", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ",", "$", "webspace", ",", "$", "language", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "result", ")", ")", ";", "}" ]
Returns nodes by given ids. @param Request $request @param array $idString @return \Symfony\Component\HttpFoundation\Response
[ "Returns", "nodes", "by", "given", "ids", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L351-L363
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.indexAction
public function indexAction(Request $request) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request); $result = $this->getRepository()->getIndexNode($webspace, $language); return $this->handleView($this->view($result)); }
php
public function indexAction(Request $request) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request); $result = $this->getRepository()->getIndexNode($webspace, $language); return $this->handleView($this->view($result)); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "webspace", "=", "$", "this", "->", "getWebspace", "(", "$", "request", ")", ";", "$", "result", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getIndexNode", "(", "$", "webspace", ",", "$", "language", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "result", ")", ")", ";", "}" ]
returns a content item for startpage. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "returns", "a", "content", "item", "for", "startpage", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L372-L380
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.cgetAction
public function cgetAction(Request $request) { if (null !== $request->get('fields')) { return $this->cgetContent($request); } return $this->cgetNodes($request); }
php
public function cgetAction(Request $request) { if (null !== $request->get('fields')) { return $this->cgetContent($request); } return $this->cgetNodes($request); }
[ "public", "function", "cgetAction", "(", "Request", "$", "request", ")", "{", "if", "(", "null", "!==", "$", "request", "->", "get", "(", "'fields'", ")", ")", "{", "return", "$", "this", "->", "cgetContent", "(", "$", "request", ")", ";", "}", "return", "$", "this", "->", "cgetNodes", "(", "$", "request", ")", ";", "}" ]
returns all content items as JSON String. @param Request $request @return \Symfony\Component\HttpFoundation\Response
[ "returns", "all", "content", "items", "as", "JSON", "String", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L389-L396
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.cgetNodes
public function cgetNodes(Request $request) { $tree = $this->getBooleanRequestParameter($request, 'tree', false, false); $ids = $this->getRequestParameter($request, 'ids'); if (true === $tree) { return $this->getTreeForUuid($request, $this->getRequestParameter($request, 'id', false, null)); } elseif (null !== $ids) { return $this->getNodesByIds($request, $ids); } $language = $this->getLanguage($request); $webspace = $this->getWebspace($request); $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false); $parentUuid = $request->get('parentId'); $depth = $request->get('depth', 1); $depth = intval($depth); $flat = $request->get('flat', 'true'); $flat = ('true' === $flat); // TODO pagination $result = $this->getRepository()->getNodes( $parentUuid, $webspace, $language, $depth, $flat, false, $excludeGhosts ); return $this->handleView($this->view($result)); }
php
public function cgetNodes(Request $request) { $tree = $this->getBooleanRequestParameter($request, 'tree', false, false); $ids = $this->getRequestParameter($request, 'ids'); if (true === $tree) { return $this->getTreeForUuid($request, $this->getRequestParameter($request, 'id', false, null)); } elseif (null !== $ids) { return $this->getNodesByIds($request, $ids); } $language = $this->getLanguage($request); $webspace = $this->getWebspace($request); $excludeGhosts = $this->getBooleanRequestParameter($request, 'exclude-ghosts', false, false); $parentUuid = $request->get('parentId'); $depth = $request->get('depth', 1); $depth = intval($depth); $flat = $request->get('flat', 'true'); $flat = ('true' === $flat); // TODO pagination $result = $this->getRepository()->getNodes( $parentUuid, $webspace, $language, $depth, $flat, false, $excludeGhosts ); return $this->handleView($this->view($result)); }
[ "public", "function", "cgetNodes", "(", "Request", "$", "request", ")", "{", "$", "tree", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'tree'", ",", "false", ",", "false", ")", ";", "$", "ids", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'ids'", ")", ";", "if", "(", "true", "===", "$", "tree", ")", "{", "return", "$", "this", "->", "getTreeForUuid", "(", "$", "request", ",", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'id'", ",", "false", ",", "null", ")", ")", ";", "}", "elseif", "(", "null", "!==", "$", "ids", ")", "{", "return", "$", "this", "->", "getNodesByIds", "(", "$", "request", ",", "$", "ids", ")", ";", "}", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "webspace", "=", "$", "this", "->", "getWebspace", "(", "$", "request", ")", ";", "$", "excludeGhosts", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'exclude-ghosts'", ",", "false", ",", "false", ")", ";", "$", "parentUuid", "=", "$", "request", "->", "get", "(", "'parentId'", ")", ";", "$", "depth", "=", "$", "request", "->", "get", "(", "'depth'", ",", "1", ")", ";", "$", "depth", "=", "intval", "(", "$", "depth", ")", ";", "$", "flat", "=", "$", "request", "->", "get", "(", "'flat'", ",", "'true'", ")", ";", "$", "flat", "=", "(", "'true'", "===", "$", "flat", ")", ";", "// TODO pagination", "$", "result", "=", "$", "this", "->", "getRepository", "(", ")", "->", "getNodes", "(", "$", "parentUuid", ",", "$", "webspace", ",", "$", "language", ",", "$", "depth", ",", "$", "flat", ",", "false", ",", "$", "excludeGhosts", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "result", ")", ")", ";", "}" ]
Returns complete nodes. @param Request $request @return Response @throws MissingParameterException @throws ParameterDataTypeException @deprecated this will be removed when the content-repository is able to solve all requirements
[ "Returns", "complete", "nodes", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L410-L443
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.putAction
public function putAction(Request $request, $id) { $language = $this->getLanguage($request); $action = $request->get('action'); $this->checkActionParameterSecurity($action, $language, $id); $document = $this->getDocumentManager()->find( $id, $language, [ 'load_ghost_content' => false, 'load_shadow_content' => false, ] ); $formType = $this->getMetadataFactory()->getMetadataForClass(get_class($document))->getFormType(); $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid()); $this->persistDocument($request, $formType, $document, $language); $this->handleActionParameter($action, $document, $language); $this->getDocumentManager()->flush(); $context = new Context(); $context->setGroups(['defaultPage']); return $this->handleView($this->view($document)->setContext($context)); }
php
public function putAction(Request $request, $id) { $language = $this->getLanguage($request); $action = $request->get('action'); $this->checkActionParameterSecurity($action, $language, $id); $document = $this->getDocumentManager()->find( $id, $language, [ 'load_ghost_content' => false, 'load_shadow_content' => false, ] ); $formType = $this->getMetadataFactory()->getMetadataForClass(get_class($document))->getFormType(); $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid()); $this->persistDocument($request, $formType, $document, $language); $this->handleActionParameter($action, $document, $language); $this->getDocumentManager()->flush(); $context = new Context(); $context->setGroups(['defaultPage']); return $this->handleView($this->view($document)->setContext($context)); }
[ "public", "function", "putAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "action", "=", "$", "request", "->", "get", "(", "'action'", ")", ";", "$", "this", "->", "checkActionParameterSecurity", "(", "$", "action", ",", "$", "language", ",", "$", "id", ")", ";", "$", "document", "=", "$", "this", "->", "getDocumentManager", "(", ")", "->", "find", "(", "$", "id", ",", "$", "language", ",", "[", "'load_ghost_content'", "=>", "false", ",", "'load_shadow_content'", "=>", "false", ",", "]", ")", ";", "$", "formType", "=", "$", "this", "->", "getMetadataFactory", "(", ")", "->", "getMetadataForClass", "(", "get_class", "(", "$", "document", ")", ")", "->", "getFormType", "(", ")", ";", "$", "this", "->", "get", "(", "'sulu_hash.request_hash_checker'", ")", "->", "checkHash", "(", "$", "request", ",", "$", "document", ",", "$", "document", "->", "getUuid", "(", ")", ")", ";", "$", "this", "->", "persistDocument", "(", "$", "request", ",", "$", "formType", ",", "$", "document", ",", "$", "language", ")", ";", "$", "this", "->", "handleActionParameter", "(", "$", "action", ",", "$", "document", ",", "$", "language", ")", ";", "$", "this", "->", "getDocumentManager", "(", ")", "->", "flush", "(", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "[", "'defaultPage'", "]", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "document", ")", "->", "setContext", "(", "$", "context", ")", ")", ";", "}" ]
saves node with given id and data. @param Request $request @param string $id @return Response @throws InvalidFormException @throws InvalidHashException @throws MissingParameterException
[ "saves", "node", "with", "given", "id", "and", "data", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L537-L565
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.postAction
public function postAction(Request $request) { $type = 'page'; $language = $this->getLanguage($request); $action = $request->get('action'); $this->checkActionParameterSecurity($action, $language); $document = $this->getDocumentManager()->create($type); $formType = $this->getMetadataFactory()->getMetadataForAlias($type)->getFormType(); $this->persistDocument($request, $formType, $document, $language); $this->handleActionParameter($action, $document, $language); $this->getDocumentManager()->flush(); $context = new Context(); $context->setGroups(['defaultPage']); return $this->handleView($this->view($document)->setContext($context)); }
php
public function postAction(Request $request) { $type = 'page'; $language = $this->getLanguage($request); $action = $request->get('action'); $this->checkActionParameterSecurity($action, $language); $document = $this->getDocumentManager()->create($type); $formType = $this->getMetadataFactory()->getMetadataForAlias($type)->getFormType(); $this->persistDocument($request, $formType, $document, $language); $this->handleActionParameter($action, $document, $language); $this->getDocumentManager()->flush(); $context = new Context(); $context->setGroups(['defaultPage']); return $this->handleView($this->view($document)->setContext($context)); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ")", "{", "$", "type", "=", "'page'", ";", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "action", "=", "$", "request", "->", "get", "(", "'action'", ")", ";", "$", "this", "->", "checkActionParameterSecurity", "(", "$", "action", ",", "$", "language", ")", ";", "$", "document", "=", "$", "this", "->", "getDocumentManager", "(", ")", "->", "create", "(", "$", "type", ")", ";", "$", "formType", "=", "$", "this", "->", "getMetadataFactory", "(", ")", "->", "getMetadataForAlias", "(", "$", "type", ")", "->", "getFormType", "(", ")", ";", "$", "this", "->", "persistDocument", "(", "$", "request", ",", "$", "formType", ",", "$", "document", ",", "$", "language", ")", ";", "$", "this", "->", "handleActionParameter", "(", "$", "action", ",", "$", "document", ",", "$", "language", ")", ";", "$", "this", "->", "getDocumentManager", "(", ")", "->", "flush", "(", ")", ";", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "context", "->", "setGroups", "(", "[", "'defaultPage'", "]", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "document", ")", "->", "setContext", "(", "$", "context", ")", ")", ";", "}" ]
Updates a content item and returns result as JSON String. @param Request $request @return Response @throws InvalidFormException @throws MissingParameterException
[ "Updates", "a", "content", "item", "and", "returns", "result", "as", "JSON", "String", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L577-L596
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.deleteAction
public function deleteAction(Request $request, $id) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request); $force = $this->getBooleanRequestParameter($request, 'force', false, false); if (!$force) { $references = array_filter( $this->getRepository()->getReferences($id), function(PropertyInterface $reference) { return $reference->getParent()->isNodeType('sulu:page'); } ); if (count($references) > 0) { $data = [ 'structures' => [], 'other' => [], ]; foreach ($references as $reference) { $content = $this->get('sulu.content.mapper')->load( $reference->getParent()->getIdentifier(), $webspace, $language, true ); $data['structures'][] = $content->toArray(); } return $this->handleView($this->view($data, 409)); } } $view = $this->responseDelete( $id, function($id) use ($webspace) { try { $this->getRepository()->deleteNode($id, $webspace); } catch (DocumentNotFoundException $ex) { throw new EntityNotFoundException('Content', $id); } } ); return $this->handleView($view); }
php
public function deleteAction(Request $request, $id) { $language = $this->getLanguage($request); $webspace = $this->getWebspace($request); $force = $this->getBooleanRequestParameter($request, 'force', false, false); if (!$force) { $references = array_filter( $this->getRepository()->getReferences($id), function(PropertyInterface $reference) { return $reference->getParent()->isNodeType('sulu:page'); } ); if (count($references) > 0) { $data = [ 'structures' => [], 'other' => [], ]; foreach ($references as $reference) { $content = $this->get('sulu.content.mapper')->load( $reference->getParent()->getIdentifier(), $webspace, $language, true ); $data['structures'][] = $content->toArray(); } return $this->handleView($this->view($data, 409)); } } $view = $this->responseDelete( $id, function($id) use ($webspace) { try { $this->getRepository()->deleteNode($id, $webspace); } catch (DocumentNotFoundException $ex) { throw new EntityNotFoundException('Content', $id); } } ); return $this->handleView($view); }
[ "public", "function", "deleteAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "language", "=", "$", "this", "->", "getLanguage", "(", "$", "request", ")", ";", "$", "webspace", "=", "$", "this", "->", "getWebspace", "(", "$", "request", ")", ";", "$", "force", "=", "$", "this", "->", "getBooleanRequestParameter", "(", "$", "request", ",", "'force'", ",", "false", ",", "false", ")", ";", "if", "(", "!", "$", "force", ")", "{", "$", "references", "=", "array_filter", "(", "$", "this", "->", "getRepository", "(", ")", "->", "getReferences", "(", "$", "id", ")", ",", "function", "(", "PropertyInterface", "$", "reference", ")", "{", "return", "$", "reference", "->", "getParent", "(", ")", "->", "isNodeType", "(", "'sulu:page'", ")", ";", "}", ")", ";", "if", "(", "count", "(", "$", "references", ")", ">", "0", ")", "{", "$", "data", "=", "[", "'structures'", "=>", "[", "]", ",", "'other'", "=>", "[", "]", ",", "]", ";", "foreach", "(", "$", "references", "as", "$", "reference", ")", "{", "$", "content", "=", "$", "this", "->", "get", "(", "'sulu.content.mapper'", ")", "->", "load", "(", "$", "reference", "->", "getParent", "(", ")", "->", "getIdentifier", "(", ")", ",", "$", "webspace", ",", "$", "language", ",", "true", ")", ";", "$", "data", "[", "'structures'", "]", "[", "]", "=", "$", "content", "->", "toArray", "(", ")", ";", "}", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "data", ",", "409", ")", ")", ";", "}", "}", "$", "view", "=", "$", "this", "->", "responseDelete", "(", "$", "id", ",", "function", "(", "$", "id", ")", "use", "(", "$", "webspace", ")", "{", "try", "{", "$", "this", "->", "getRepository", "(", ")", "->", "deleteNode", "(", "$", "id", ",", "$", "webspace", ")", ";", "}", "catch", "(", "DocumentNotFoundException", "$", "ex", ")", "{", "throw", "new", "EntityNotFoundException", "(", "'Content'", ",", "$", "id", ")", ";", "}", "}", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "view", ")", ";", "}" ]
deletes node with given id. @param Request $request @param string $id @return \Symfony\Component\HttpFoundation\Response
[ "deletes", "node", "with", "given", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L606-L652
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.checkActionParameterSecurity
private function checkActionParameterSecurity($actionParameter, $locale, $id = null) { $permission = null; switch ($actionParameter) { case 'publish': $permission = 'live'; break; } if (!$permission) { return; } $this->get('sulu_security.security_checker')->checkPermission( new SecurityCondition( $this->getSecurityContext(), $locale, $this->getSecuredClass(), $id ), $permission ); }
php
private function checkActionParameterSecurity($actionParameter, $locale, $id = null) { $permission = null; switch ($actionParameter) { case 'publish': $permission = 'live'; break; } if (!$permission) { return; } $this->get('sulu_security.security_checker')->checkPermission( new SecurityCondition( $this->getSecurityContext(), $locale, $this->getSecuredClass(), $id ), $permission ); }
[ "private", "function", "checkActionParameterSecurity", "(", "$", "actionParameter", ",", "$", "locale", ",", "$", "id", "=", "null", ")", "{", "$", "permission", "=", "null", ";", "switch", "(", "$", "actionParameter", ")", "{", "case", "'publish'", ":", "$", "permission", "=", "'live'", ";", "break", ";", "}", "if", "(", "!", "$", "permission", ")", "{", "return", ";", "}", "$", "this", "->", "get", "(", "'sulu_security.security_checker'", ")", "->", "checkPermission", "(", "new", "SecurityCondition", "(", "$", "this", "->", "getSecurityContext", "(", ")", ",", "$", "locale", ",", "$", "this", "->", "getSecuredClass", "(", ")", ",", "$", "id", ")", ",", "$", "permission", ")", ";", "}" ]
Checks if the user has the required permissions for the given action with the given locale. The additional id parameter will also include checks for the document identified by it. @param string $actionParameter @param string $locale @param string $id
[ "Checks", "if", "the", "user", "has", "the", "required", "permissions", "for", "the", "given", "action", "with", "the", "given", "locale", ".", "The", "additional", "id", "parameter", "will", "also", "include", "checks", "for", "the", "document", "identified", "by", "it", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L976-L998
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Controller/NodeController.php
NodeController.handleActionParameter
private function handleActionParameter($actionParameter, $document, $locale) { switch ($actionParameter) { case 'publish': $this->getDocumentManager()->publish($document, $locale); break; } }
php
private function handleActionParameter($actionParameter, $document, $locale) { switch ($actionParameter) { case 'publish': $this->getDocumentManager()->publish($document, $locale); break; } }
[ "private", "function", "handleActionParameter", "(", "$", "actionParameter", ",", "$", "document", ",", "$", "locale", ")", "{", "switch", "(", "$", "actionParameter", ")", "{", "case", "'publish'", ":", "$", "this", "->", "getDocumentManager", "(", ")", "->", "publish", "(", "$", "document", ",", "$", "locale", ")", ";", "break", ";", "}", "}" ]
Delegates actions by given actionParameter, which can be retrieved from the request. @param string $actionParameter @param object $document @param string $locale
[ "Delegates", "actions", "by", "given", "actionParameter", "which", "can", "be", "retrieved", "from", "the", "request", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Controller/NodeController.php#L1007-L1014
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Entity/ConditionGroup.php
ConditionGroup.addCondition
public function addCondition(\Sulu\Bundle\ResourceBundle\Entity\Condition $conditions) { $this->conditions[] = $conditions; return $this; }
php
public function addCondition(\Sulu\Bundle\ResourceBundle\Entity\Condition $conditions) { $this->conditions[] = $conditions; return $this; }
[ "public", "function", "addCondition", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ResourceBundle", "\\", "Entity", "\\", "Condition", "$", "conditions", ")", "{", "$", "this", "->", "conditions", "[", "]", "=", "$", "conditions", ";", "return", "$", "this", ";", "}" ]
Add conditions. @param \Sulu\Bundle\ResourceBundle\Entity\Condition $conditions @return ConditionGroup
[ "Add", "conditions", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Entity/ConditionGroup.php#L59-L64
train
sulu/sulu
src/Sulu/Bundle/ResourceBundle/Entity/ConditionGroup.php
ConditionGroup.removeCondition
public function removeCondition(\Sulu\Bundle\ResourceBundle\Entity\Condition $conditions) { $this->conditions->removeElement($conditions); }
php
public function removeCondition(\Sulu\Bundle\ResourceBundle\Entity\Condition $conditions) { $this->conditions->removeElement($conditions); }
[ "public", "function", "removeCondition", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ResourceBundle", "\\", "Entity", "\\", "Condition", "$", "conditions", ")", "{", "$", "this", "->", "conditions", "->", "removeElement", "(", "$", "conditions", ")", ";", "}" ]
Remove conditions. @param \Sulu\Bundle\ResourceBundle\Entity\Condition $conditions
[ "Remove", "conditions", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Entity/ConditionGroup.php#L71-L74
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php
ListRestHelper.getIds
public function getIds() { $idsString = $this->getRequest()->get('ids'); return (null !== $idsString) ? array_filter(explode(',', $idsString)) : null; }
php
public function getIds() { $idsString = $this->getRequest()->get('ids'); return (null !== $idsString) ? array_filter(explode(',', $idsString)) : null; }
[ "public", "function", "getIds", "(", ")", "{", "$", "idsString", "=", "$", "this", "->", "getRequest", "(", ")", "->", "get", "(", "'ids'", ")", ";", "return", "(", "null", "!==", "$", "idsString", ")", "?", "array_filter", "(", "explode", "(", "','", ",", "$", "idsString", ")", ")", ":", "null", ";", "}" ]
Returns an array of ids to which the response should be restricted. If null is returned, entities in the response should not be restricted by their id. @return array
[ "Returns", "an", "array", "of", "ids", "to", "which", "the", "response", "should", "be", "restricted", ".", "If", "null", "is", "returned", "entities", "in", "the", "response", "should", "not", "be", "restricted", "by", "their", "id", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php#L59-L64
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php
ListRestHelper.getExcludedIds
public function getExcludedIds() { $excludedIdsString = $this->getRequest()->get('excludedIds'); return (null !== $excludedIdsString) ? array_filter(explode(',', $excludedIdsString)) : []; }
php
public function getExcludedIds() { $excludedIdsString = $this->getRequest()->get('excludedIds'); return (null !== $excludedIdsString) ? array_filter(explode(',', $excludedIdsString)) : []; }
[ "public", "function", "getExcludedIds", "(", ")", "{", "$", "excludedIdsString", "=", "$", "this", "->", "getRequest", "(", ")", "->", "get", "(", "'excludedIds'", ")", ";", "return", "(", "null", "!==", "$", "excludedIdsString", ")", "?", "array_filter", "(", "explode", "(", "','", ",", "$", "excludedIdsString", ")", ")", ":", "[", "]", ";", "}" ]
Returns an array of ids which should be excluded from the response. @return array
[ "Returns", "an", "array", "of", "ids", "which", "should", "be", "excluded", "from", "the", "response", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php#L71-L76
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php
ListRestHelper.getLimit
public function getLimit() { $default = 10; if ('csv' === $this->getRequest()->getRequestFormat()) { $default = null; } // set default limit to count of ids if result is restricted to specific ids $ids = $this->getIds(); if (null != $ids) { $default = count($ids); } return $this->getRequest()->get('limit', $default); }
php
public function getLimit() { $default = 10; if ('csv' === $this->getRequest()->getRequestFormat()) { $default = null; } // set default limit to count of ids if result is restricted to specific ids $ids = $this->getIds(); if (null != $ids) { $default = count($ids); } return $this->getRequest()->get('limit', $default); }
[ "public", "function", "getLimit", "(", ")", "{", "$", "default", "=", "10", ";", "if", "(", "'csv'", "===", "$", "this", "->", "getRequest", "(", ")", "->", "getRequestFormat", "(", ")", ")", "{", "$", "default", "=", "null", ";", "}", "// set default limit to count of ids if result is restricted to specific ids", "$", "ids", "=", "$", "this", "->", "getIds", "(", ")", ";", "if", "(", "null", "!=", "$", "ids", ")", "{", "$", "default", "=", "count", "(", "$", "ids", ")", ";", "}", "return", "$", "this", "->", "getRequest", "(", ")", "->", "get", "(", "'limit'", ",", "$", "default", ")", ";", "}" ]
Returns the maximum number of elements in a single response. @return int
[ "Returns", "the", "maximum", "number", "of", "elements", "in", "a", "single", "response", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php#L103-L117
train
sulu/sulu
src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php
ListRestHelper.getFields
public function getFields() { $fields = $this->getRequest()->get('fields'); return (null != $fields) ? explode(',', $fields) : null; }
php
public function getFields() { $fields = $this->getRequest()->get('fields'); return (null != $fields) ? explode(',', $fields) : null; }
[ "public", "function", "getFields", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "getRequest", "(", ")", "->", "get", "(", "'fields'", ")", ";", "return", "(", "null", "!=", "$", "fields", ")", "?", "explode", "(", "','", ",", "$", "fields", ")", ":", "null", ";", "}" ]
Returns an array with all the fields, which should be contained in the response. If null is returned every field should be contained. @return array|null
[ "Returns", "an", "array", "with", "all", "the", "fields", "which", "should", "be", "contained", "in", "the", "response", ".", "If", "null", "is", "returned", "every", "field", "should", "be", "contained", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/ListBuilder/ListRestHelper.php#L149-L154
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Markup/Link/PageLinkProvider.php
PageLinkProvider.getLinkItem
protected function getLinkItem(Content $content, $locale, $scheme) { $published = !empty($content->getPropertyWithDefault('published')); $url = $this->webspaceManager->findUrlByResourceLocator( $content->getUrl(), $this->environment, $locale, $content->getWebspaceKey(), null, $scheme ); return new LinkItem($content->getId(), $content->getPropertyWithDefault('title'), $url, $published); }
php
protected function getLinkItem(Content $content, $locale, $scheme) { $published = !empty($content->getPropertyWithDefault('published')); $url = $this->webspaceManager->findUrlByResourceLocator( $content->getUrl(), $this->environment, $locale, $content->getWebspaceKey(), null, $scheme ); return new LinkItem($content->getId(), $content->getPropertyWithDefault('title'), $url, $published); }
[ "protected", "function", "getLinkItem", "(", "Content", "$", "content", ",", "$", "locale", ",", "$", "scheme", ")", "{", "$", "published", "=", "!", "empty", "(", "$", "content", "->", "getPropertyWithDefault", "(", "'published'", ")", ")", ";", "$", "url", "=", "$", "this", "->", "webspaceManager", "->", "findUrlByResourceLocator", "(", "$", "content", "->", "getUrl", "(", ")", ",", "$", "this", "->", "environment", ",", "$", "locale", ",", "$", "content", "->", "getWebspaceKey", "(", ")", ",", "null", ",", "$", "scheme", ")", ";", "return", "new", "LinkItem", "(", "$", "content", "->", "getId", "(", ")", ",", "$", "content", "->", "getPropertyWithDefault", "(", "'title'", ")", ",", "$", "url", ",", "$", "published", ")", ";", "}" ]
Returns new link item. @param Content $content @param string $locale @param string $scheme @return LinkItem
[ "Returns", "new", "link", "item", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Markup/Link/PageLinkProvider.php#L120-L133
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Entity/File.php
File.getFileVersion
public function getFileVersion($version) { /** @var FileVersion $fileVersion */ foreach ($this->fileVersions as $fileVersion) { if ($fileVersion->getVersion() === $version) { return $fileVersion; } } return null; }
php
public function getFileVersion($version) { /** @var FileVersion $fileVersion */ foreach ($this->fileVersions as $fileVersion) { if ($fileVersion->getVersion() === $version) { return $fileVersion; } } return null; }
[ "public", "function", "getFileVersion", "(", "$", "version", ")", "{", "/** @var FileVersion $fileVersion */", "foreach", "(", "$", "this", "->", "fileVersions", "as", "$", "fileVersion", ")", "{", "if", "(", "$", "fileVersion", "->", "getVersion", "(", ")", "===", "$", "version", ")", "{", "return", "$", "fileVersion", ";", "}", "}", "return", "null", ";", "}" ]
Get file version. @param int $version @return FileVersion|null
[ "Get", "file", "version", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Entity/File.php#L129-L139
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.setVersionMixin
public function setVersionMixin(AbstractMappingEvent $event) { if (!$this->support($event->getDocument())) { return; } $event->getNode()->addMixin('mix:versionable'); }
php
public function setVersionMixin(AbstractMappingEvent $event) { if (!$this->support($event->getDocument())) { return; } $event->getNode()->addMixin('mix:versionable'); }
[ "public", "function", "setVersionMixin", "(", "AbstractMappingEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "support", "(", "$", "event", "->", "getDocument", "(", ")", ")", ")", "{", "return", ";", "}", "$", "event", "->", "getNode", "(", ")", "->", "addMixin", "(", "'mix:versionable'", ")", ";", "}" ]
Sets the versionable mixin on the node if it is a versionable document. @param AbstractMappingEvent $event
[ "Sets", "the", "versionable", "mixin", "on", "the", "node", "if", "it", "is", "a", "versionable", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L95-L102
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.setVersionsOnDocument
public function setVersionsOnDocument(HydrateEvent $event) { $document = $event->getDocument(); if (!$this->support($document)) { return; } $node = $event->getNode(); $versions = []; $versionProperty = $node->getPropertyValueWithDefault(static::VERSION_PROPERTY, []); foreach ($versionProperty as $version) { $versionInformation = json_decode($version); $versions[] = new Version( $versionInformation->version, $versionInformation->locale, $versionInformation->author, new \DateTime($versionInformation->authored) ); } $document->setVersions($versions); }
php
public function setVersionsOnDocument(HydrateEvent $event) { $document = $event->getDocument(); if (!$this->support($document)) { return; } $node = $event->getNode(); $versions = []; $versionProperty = $node->getPropertyValueWithDefault(static::VERSION_PROPERTY, []); foreach ($versionProperty as $version) { $versionInformation = json_decode($version); $versions[] = new Version( $versionInformation->version, $versionInformation->locale, $versionInformation->author, new \DateTime($versionInformation->authored) ); } $document->setVersions($versions); }
[ "public", "function", "setVersionsOnDocument", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "support", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "versions", "=", "[", "]", ";", "$", "versionProperty", "=", "$", "node", "->", "getPropertyValueWithDefault", "(", "static", "::", "VERSION_PROPERTY", ",", "[", "]", ")", ";", "foreach", "(", "$", "versionProperty", "as", "$", "version", ")", "{", "$", "versionInformation", "=", "json_decode", "(", "$", "version", ")", ";", "$", "versions", "[", "]", "=", "new", "Version", "(", "$", "versionInformation", "->", "version", ",", "$", "versionInformation", "->", "locale", ",", "$", "versionInformation", "->", "author", ",", "new", "\\", "DateTime", "(", "$", "versionInformation", "->", "authored", ")", ")", ";", "}", "$", "document", "->", "setVersions", "(", "$", "versions", ")", ";", "}" ]
Sets the version information set on the node to the document. @param HydrateEvent $event
[ "Sets", "the", "version", "information", "set", "on", "the", "node", "to", "the", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L109-L132
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.rememberCheckoutUuids
public function rememberCheckoutUuids(PersistEvent $event) { if (!$this->support($event->getDocument())) { return; } $this->checkoutUuids[] = $event->getNode()->getIdentifier(); }
php
public function rememberCheckoutUuids(PersistEvent $event) { if (!$this->support($event->getDocument())) { return; } $this->checkoutUuids[] = $event->getNode()->getIdentifier(); }
[ "public", "function", "rememberCheckoutUuids", "(", "PersistEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "support", "(", "$", "event", "->", "getDocument", "(", ")", ")", ")", "{", "return", ";", "}", "$", "this", "->", "checkoutUuids", "[", "]", "=", "$", "event", "->", "getNode", "(", ")", "->", "getIdentifier", "(", ")", ";", "}" ]
Remember which uuids need to be checked out after everything has been saved. @param PersistEvent $event
[ "Remember", "which", "uuids", "need", "to", "be", "checked", "out", "after", "everything", "has", "been", "saved", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L139-L146
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.rememberCreateVersion
public function rememberCreateVersion(PublishEvent $event) { $document = $event->getDocument(); if (!$this->support($document)) { return; } $this->checkpointUuids[] = [ 'uuid' => $event->getNode()->getIdentifier(), 'locale' => $document->getLocale(), 'author' => $event->getOption('user'), ]; }
php
public function rememberCreateVersion(PublishEvent $event) { $document = $event->getDocument(); if (!$this->support($document)) { return; } $this->checkpointUuids[] = [ 'uuid' => $event->getNode()->getIdentifier(), 'locale' => $document->getLocale(), 'author' => $event->getOption('user'), ]; }
[ "public", "function", "rememberCreateVersion", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "support", "(", "$", "document", ")", ")", "{", "return", ";", "}", "$", "this", "->", "checkpointUuids", "[", "]", "=", "[", "'uuid'", "=>", "$", "event", "->", "getNode", "(", ")", "->", "getIdentifier", "(", ")", ",", "'locale'", "=>", "$", "document", "->", "getLocale", "(", ")", ",", "'author'", "=>", "$", "event", "->", "getOption", "(", "'user'", ")", ",", "]", ";", "}" ]
Remember for which uuids a new version has to be created. @param PublishEvent $event
[ "Remember", "for", "which", "uuids", "a", "new", "version", "has", "to", "be", "created", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L153-L165
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.applyVersionOperations
public function applyVersionOperations() { foreach ($this->checkoutUuids as $uuid) { $node = $this->defaultSession->getNodeByIdentifier($uuid); $path = $node->getPath(); if (!$this->versionManager->isCheckedOut($path)) { $this->versionManager->checkout($path); } } $this->checkoutUuids = []; /** @var NodeInterface[] $nodes */ $nodes = []; $nodeVersions = []; foreach ($this->checkpointUuids as $versionInformation) { $node = $this->defaultSession->getNodeByIdentifier($versionInformation['uuid']); $path = $node->getPath(); $version = $this->versionManager->checkpoint($path); if (!array_key_exists($path, $nodes)) { $nodes[$path] = $this->defaultSession->getNode($path); } $versions = $nodes[$path]->getPropertyValueWithDefault(static::VERSION_PROPERTY, []); if (!array_key_exists($path, $nodeVersions)) { $nodeVersions[$path] = $versions; } $nodeVersions[$path][] = json_encode( [ 'locale' => $versionInformation['locale'], 'version' => $version->getName(), 'author' => $versionInformation['author'], 'authored' => date('c'), ] ); } foreach ($nodes as $uuid => $node) { $node->setProperty(static::VERSION_PROPERTY, $nodeVersions[$uuid]); } $this->defaultSession->save(); $this->checkpointUuids = []; }
php
public function applyVersionOperations() { foreach ($this->checkoutUuids as $uuid) { $node = $this->defaultSession->getNodeByIdentifier($uuid); $path = $node->getPath(); if (!$this->versionManager->isCheckedOut($path)) { $this->versionManager->checkout($path); } } $this->checkoutUuids = []; /** @var NodeInterface[] $nodes */ $nodes = []; $nodeVersions = []; foreach ($this->checkpointUuids as $versionInformation) { $node = $this->defaultSession->getNodeByIdentifier($versionInformation['uuid']); $path = $node->getPath(); $version = $this->versionManager->checkpoint($path); if (!array_key_exists($path, $nodes)) { $nodes[$path] = $this->defaultSession->getNode($path); } $versions = $nodes[$path]->getPropertyValueWithDefault(static::VERSION_PROPERTY, []); if (!array_key_exists($path, $nodeVersions)) { $nodeVersions[$path] = $versions; } $nodeVersions[$path][] = json_encode( [ 'locale' => $versionInformation['locale'], 'version' => $version->getName(), 'author' => $versionInformation['author'], 'authored' => date('c'), ] ); } foreach ($nodes as $uuid => $node) { $node->setProperty(static::VERSION_PROPERTY, $nodeVersions[$uuid]); } $this->defaultSession->save(); $this->checkpointUuids = []; }
[ "public", "function", "applyVersionOperations", "(", ")", "{", "foreach", "(", "$", "this", "->", "checkoutUuids", "as", "$", "uuid", ")", "{", "$", "node", "=", "$", "this", "->", "defaultSession", "->", "getNodeByIdentifier", "(", "$", "uuid", ")", ";", "$", "path", "=", "$", "node", "->", "getPath", "(", ")", ";", "if", "(", "!", "$", "this", "->", "versionManager", "->", "isCheckedOut", "(", "$", "path", ")", ")", "{", "$", "this", "->", "versionManager", "->", "checkout", "(", "$", "path", ")", ";", "}", "}", "$", "this", "->", "checkoutUuids", "=", "[", "]", ";", "/** @var NodeInterface[] $nodes */", "$", "nodes", "=", "[", "]", ";", "$", "nodeVersions", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "checkpointUuids", "as", "$", "versionInformation", ")", "{", "$", "node", "=", "$", "this", "->", "defaultSession", "->", "getNodeByIdentifier", "(", "$", "versionInformation", "[", "'uuid'", "]", ")", ";", "$", "path", "=", "$", "node", "->", "getPath", "(", ")", ";", "$", "version", "=", "$", "this", "->", "versionManager", "->", "checkpoint", "(", "$", "path", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "path", ",", "$", "nodes", ")", ")", "{", "$", "nodes", "[", "$", "path", "]", "=", "$", "this", "->", "defaultSession", "->", "getNode", "(", "$", "path", ")", ";", "}", "$", "versions", "=", "$", "nodes", "[", "$", "path", "]", "->", "getPropertyValueWithDefault", "(", "static", "::", "VERSION_PROPERTY", ",", "[", "]", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "path", ",", "$", "nodeVersions", ")", ")", "{", "$", "nodeVersions", "[", "$", "path", "]", "=", "$", "versions", ";", "}", "$", "nodeVersions", "[", "$", "path", "]", "[", "]", "=", "json_encode", "(", "[", "'locale'", "=>", "$", "versionInformation", "[", "'locale'", "]", ",", "'version'", "=>", "$", "version", "->", "getName", "(", ")", ",", "'author'", "=>", "$", "versionInformation", "[", "'author'", "]", ",", "'authored'", "=>", "date", "(", "'c'", ")", ",", "]", ")", ";", "}", "foreach", "(", "$", "nodes", "as", "$", "uuid", "=>", "$", "node", ")", "{", "$", "node", "->", "setProperty", "(", "static", "::", "VERSION_PROPERTY", ",", "$", "nodeVersions", "[", "$", "uuid", "]", ")", ";", "}", "$", "this", "->", "defaultSession", "->", "save", "(", ")", ";", "$", "this", "->", "checkpointUuids", "=", "[", "]", ";", "}" ]
Apply all the operations which have been remembered after the flush.
[ "Apply", "all", "the", "operations", "which", "have", "been", "remembered", "after", "the", "flush", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L170-L216
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.restoreProperties
public function restoreProperties(RestoreEvent $event) { if (!$this->support($event->getDocument())) { $event->stopPropagation(); return; } $contentPropertyPrefix = $this->propertyEncoder->localizedContentName('', $event->getLocale()); $systemPropertyPrefix = $this->propertyEncoder->localizedSystemName('', $event->getLocale()); $node = $event->getNode(); try { $version = $this->versionManager->getVersionHistory($node->getPath())->getVersion($event->getVersion()); $frozenNode = $version->getFrozenNode(); $this->restoreNode($node, $frozenNode, $contentPropertyPrefix, $systemPropertyPrefix); } catch (VersionException $exception) { throw new VersionNotFoundException($event->getDocument(), $event->getVersion()); } }
php
public function restoreProperties(RestoreEvent $event) { if (!$this->support($event->getDocument())) { $event->stopPropagation(); return; } $contentPropertyPrefix = $this->propertyEncoder->localizedContentName('', $event->getLocale()); $systemPropertyPrefix = $this->propertyEncoder->localizedSystemName('', $event->getLocale()); $node = $event->getNode(); try { $version = $this->versionManager->getVersionHistory($node->getPath())->getVersion($event->getVersion()); $frozenNode = $version->getFrozenNode(); $this->restoreNode($node, $frozenNode, $contentPropertyPrefix, $systemPropertyPrefix); } catch (VersionException $exception) { throw new VersionNotFoundException($event->getDocument(), $event->getVersion()); } }
[ "public", "function", "restoreProperties", "(", "RestoreEvent", "$", "event", ")", "{", "if", "(", "!", "$", "this", "->", "support", "(", "$", "event", "->", "getDocument", "(", ")", ")", ")", "{", "$", "event", "->", "stopPropagation", "(", ")", ";", "return", ";", "}", "$", "contentPropertyPrefix", "=", "$", "this", "->", "propertyEncoder", "->", "localizedContentName", "(", "''", ",", "$", "event", "->", "getLocale", "(", ")", ")", ";", "$", "systemPropertyPrefix", "=", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "''", ",", "$", "event", "->", "getLocale", "(", ")", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "try", "{", "$", "version", "=", "$", "this", "->", "versionManager", "->", "getVersionHistory", "(", "$", "node", "->", "getPath", "(", ")", ")", "->", "getVersion", "(", "$", "event", "->", "getVersion", "(", ")", ")", ";", "$", "frozenNode", "=", "$", "version", "->", "getFrozenNode", "(", ")", ";", "$", "this", "->", "restoreNode", "(", "$", "node", ",", "$", "frozenNode", ",", "$", "contentPropertyPrefix", ",", "$", "systemPropertyPrefix", ")", ";", "}", "catch", "(", "VersionException", "$", "exception", ")", "{", "throw", "new", "VersionNotFoundException", "(", "$", "event", "->", "getDocument", "(", ")", ",", "$", "event", "->", "getVersion", "(", ")", ")", ";", "}", "}" ]
Restore the properties of the old version. @param RestoreEvent $event @throws VersionNotFoundException
[ "Restore", "the", "properties", "of", "the", "old", "version", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L225-L247
train
sulu/sulu
src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php
VersionSubscriber.restoreNode
private function restoreNode( NodeInterface $node, NodeInterface $frozenNode, $contentPropertyPrefix, $systemPropertyPrefix ) { // remove the properties for the given language, so that values being added since the last version are removed foreach ($node->getProperties() as $property) { if ($this->isRestoreProperty($property->getName(), $contentPropertyPrefix, $systemPropertyPrefix)) { $property->remove(); } } // set all the properties from the saved version to the node foreach ($frozenNode->getPropertiesValues() as $name => $value) { if ($this->isRestoreProperty($name, $contentPropertyPrefix, $systemPropertyPrefix)) { $node->setProperty($name, $value); } } /** @var NodeInterface $childNode */ foreach ($frozenNode->getNodes() as $childNode) { // create new node if it not exists if (!$node->hasNode($childNode->getName())) { $newNode = $node->addNode($childNode->getName()); $newNode->setMixins($childNode->getPropertyValueWithDefault('jcr:frozenMixinTypes', [])); } $this->restoreNode( $node->getNode($childNode->getName()), $childNode, $contentPropertyPrefix, $systemPropertyPrefix ); } // remove child-nodes which do not exists in frozen-node foreach ($node->getNodes() as $childNode) { if (OnParentVersionAction::COPY !== $childNode->getDefinition()->getOnParentVersion() || $frozenNode->hasNode($childNode->getName()) ) { continue; } $childNode->remove(); } }
php
private function restoreNode( NodeInterface $node, NodeInterface $frozenNode, $contentPropertyPrefix, $systemPropertyPrefix ) { // remove the properties for the given language, so that values being added since the last version are removed foreach ($node->getProperties() as $property) { if ($this->isRestoreProperty($property->getName(), $contentPropertyPrefix, $systemPropertyPrefix)) { $property->remove(); } } // set all the properties from the saved version to the node foreach ($frozenNode->getPropertiesValues() as $name => $value) { if ($this->isRestoreProperty($name, $contentPropertyPrefix, $systemPropertyPrefix)) { $node->setProperty($name, $value); } } /** @var NodeInterface $childNode */ foreach ($frozenNode->getNodes() as $childNode) { // create new node if it not exists if (!$node->hasNode($childNode->getName())) { $newNode = $node->addNode($childNode->getName()); $newNode->setMixins($childNode->getPropertyValueWithDefault('jcr:frozenMixinTypes', [])); } $this->restoreNode( $node->getNode($childNode->getName()), $childNode, $contentPropertyPrefix, $systemPropertyPrefix ); } // remove child-nodes which do not exists in frozen-node foreach ($node->getNodes() as $childNode) { if (OnParentVersionAction::COPY !== $childNode->getDefinition()->getOnParentVersion() || $frozenNode->hasNode($childNode->getName()) ) { continue; } $childNode->remove(); } }
[ "private", "function", "restoreNode", "(", "NodeInterface", "$", "node", ",", "NodeInterface", "$", "frozenNode", ",", "$", "contentPropertyPrefix", ",", "$", "systemPropertyPrefix", ")", "{", "// remove the properties for the given language, so that values being added since the last version are removed", "foreach", "(", "$", "node", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "if", "(", "$", "this", "->", "isRestoreProperty", "(", "$", "property", "->", "getName", "(", ")", ",", "$", "contentPropertyPrefix", ",", "$", "systemPropertyPrefix", ")", ")", "{", "$", "property", "->", "remove", "(", ")", ";", "}", "}", "// set all the properties from the saved version to the node", "foreach", "(", "$", "frozenNode", "->", "getPropertiesValues", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isRestoreProperty", "(", "$", "name", ",", "$", "contentPropertyPrefix", ",", "$", "systemPropertyPrefix", ")", ")", "{", "$", "node", "->", "setProperty", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}", "/** @var NodeInterface $childNode */", "foreach", "(", "$", "frozenNode", "->", "getNodes", "(", ")", "as", "$", "childNode", ")", "{", "// create new node if it not exists", "if", "(", "!", "$", "node", "->", "hasNode", "(", "$", "childNode", "->", "getName", "(", ")", ")", ")", "{", "$", "newNode", "=", "$", "node", "->", "addNode", "(", "$", "childNode", "->", "getName", "(", ")", ")", ";", "$", "newNode", "->", "setMixins", "(", "$", "childNode", "->", "getPropertyValueWithDefault", "(", "'jcr:frozenMixinTypes'", ",", "[", "]", ")", ")", ";", "}", "$", "this", "->", "restoreNode", "(", "$", "node", "->", "getNode", "(", "$", "childNode", "->", "getName", "(", ")", ")", ",", "$", "childNode", ",", "$", "contentPropertyPrefix", ",", "$", "systemPropertyPrefix", ")", ";", "}", "// remove child-nodes which do not exists in frozen-node", "foreach", "(", "$", "node", "->", "getNodes", "(", ")", "as", "$", "childNode", ")", "{", "if", "(", "OnParentVersionAction", "::", "COPY", "!==", "$", "childNode", "->", "getDefinition", "(", ")", "->", "getOnParentVersion", "(", ")", "||", "$", "frozenNode", "->", "hasNode", "(", "$", "childNode", "->", "getName", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "childNode", "->", "remove", "(", ")", ";", "}", "}" ]
Restore given node with properties given from frozen-node. Will be called recursive. @param NodeInterface $node @param NodeInterface $frozenNode @param string $contentPropertyPrefix @param string $systemPropertyPrefix
[ "Restore", "given", "node", "with", "properties", "given", "from", "frozen", "-", "node", ".", "Will", "be", "called", "recursive", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Behavior/VersionSubscriber.php#L258-L304
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Entity/Role.php
Role.addSetting
public function addSetting(RoleSettingInterface $setting) { $this->settings->set($setting->getKey(), $setting); return $this; }
php
public function addSetting(RoleSettingInterface $setting) { $this->settings->set($setting->getKey(), $setting); return $this; }
[ "public", "function", "addSetting", "(", "RoleSettingInterface", "$", "setting", ")", "{", "$", "this", "->", "settings", "->", "set", "(", "$", "setting", "->", "getKey", "(", ")", ",", "$", "setting", ")", ";", "return", "$", "this", ";", "}" ]
Add setting. @param RoleSettingInterface $setting @return Role
[ "Add", "setting", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Entity/Role.php#L173-L178
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php
NodeRepository.createWebspaceNode
private function createWebspaceNode( $webspaceKey, $languageCode, $depth = 1, $excludeGhosts = false ) { $webspace = $this->webspaceManager->getWebspaceCollection()->getWebspace($webspaceKey); if ($depth > 0) { $nodes = $this->getMapper()->loadByParent( null, $webspaceKey, $languageCode, $depth, false, false, $excludeGhosts ); $embedded = $this->prepareNodesTree($nodes, $webspaceKey, $languageCode, true, $excludeGhosts, $depth); } else { $embedded = []; } return [ 'id' => $this->sessionManager->getContentNode($webspace->getKey())->getIdentifier(), 'path' => '/', 'title' => $webspace->getName(), 'hasSub' => true, 'publishedState' => true, '_embedded' => $embedded, '_links' => [ 'children' => [ 'href' => $this->apiBasePath . '?depth=' . $depth . '&webspace=' . $webspaceKey . '&language=' . $languageCode . (true === $excludeGhosts ? '&exclude-ghosts=true' : ''), ], ], ]; }
php
private function createWebspaceNode( $webspaceKey, $languageCode, $depth = 1, $excludeGhosts = false ) { $webspace = $this->webspaceManager->getWebspaceCollection()->getWebspace($webspaceKey); if ($depth > 0) { $nodes = $this->getMapper()->loadByParent( null, $webspaceKey, $languageCode, $depth, false, false, $excludeGhosts ); $embedded = $this->prepareNodesTree($nodes, $webspaceKey, $languageCode, true, $excludeGhosts, $depth); } else { $embedded = []; } return [ 'id' => $this->sessionManager->getContentNode($webspace->getKey())->getIdentifier(), 'path' => '/', 'title' => $webspace->getName(), 'hasSub' => true, 'publishedState' => true, '_embedded' => $embedded, '_links' => [ 'children' => [ 'href' => $this->apiBasePath . '?depth=' . $depth . '&webspace=' . $webspaceKey . '&language=' . $languageCode . (true === $excludeGhosts ? '&exclude-ghosts=true' : ''), ], ], ]; }
[ "private", "function", "createWebspaceNode", "(", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "depth", "=", "1", ",", "$", "excludeGhosts", "=", "false", ")", "{", "$", "webspace", "=", "$", "this", "->", "webspaceManager", "->", "getWebspaceCollection", "(", ")", "->", "getWebspace", "(", "$", "webspaceKey", ")", ";", "if", "(", "$", "depth", ">", "0", ")", "{", "$", "nodes", "=", "$", "this", "->", "getMapper", "(", ")", "->", "loadByParent", "(", "null", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "$", "depth", ",", "false", ",", "false", ",", "$", "excludeGhosts", ")", ";", "$", "embedded", "=", "$", "this", "->", "prepareNodesTree", "(", "$", "nodes", ",", "$", "webspaceKey", ",", "$", "languageCode", ",", "true", ",", "$", "excludeGhosts", ",", "$", "depth", ")", ";", "}", "else", "{", "$", "embedded", "=", "[", "]", ";", "}", "return", "[", "'id'", "=>", "$", "this", "->", "sessionManager", "->", "getContentNode", "(", "$", "webspace", "->", "getKey", "(", ")", ")", "->", "getIdentifier", "(", ")", ",", "'path'", "=>", "'/'", ",", "'title'", "=>", "$", "webspace", "->", "getName", "(", ")", ",", "'hasSub'", "=>", "true", ",", "'publishedState'", "=>", "true", ",", "'_embedded'", "=>", "$", "embedded", ",", "'_links'", "=>", "[", "'children'", "=>", "[", "'href'", "=>", "$", "this", "->", "apiBasePath", ".", "'?depth='", ".", "$", "depth", ".", "'&webspace='", ".", "$", "webspaceKey", ".", "'&language='", ".", "$", "languageCode", ".", "(", "true", "===", "$", "excludeGhosts", "?", "'&exclude-ghosts=true'", ":", "''", ")", ",", "]", ",", "]", ",", "]", ";", "}" ]
Creates a webspace node.
[ "Creates", "a", "webspace", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php#L376-L413
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php
NodeRepository.getParentNode
private function getParentNode($parent, $webspaceKey, $languageCode) { if (null != $parent) { return $this->getMapper()->load($parent, $webspaceKey, $languageCode); } else { return $this->getMapper()->loadStartPage($webspaceKey, $languageCode); } }
php
private function getParentNode($parent, $webspaceKey, $languageCode) { if (null != $parent) { return $this->getMapper()->load($parent, $webspaceKey, $languageCode); } else { return $this->getMapper()->loadStartPage($webspaceKey, $languageCode); } }
[ "private", "function", "getParentNode", "(", "$", "parent", ",", "$", "webspaceKey", ",", "$", "languageCode", ")", "{", "if", "(", "null", "!=", "$", "parent", ")", "{", "return", "$", "this", "->", "getMapper", "(", ")", "->", "load", "(", "$", "parent", ",", "$", "webspaceKey", ",", "$", "languageCode", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getMapper", "(", ")", "->", "loadStartPage", "(", "$", "webspaceKey", ",", "$", "languageCode", ")", ";", "}", "}" ]
if parent is null return home page else the page with given uuid. @param string|null $parent uuid of parent node @param string $webspaceKey @param string $languageCode @return StructureInterface
[ "if", "parent", "is", "null", "return", "home", "page", "else", "the", "page", "with", "given", "uuid", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php#L474-L481
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php
NodeRepository.loadNodeAndAncestors
private function loadNodeAndAncestors($uuid, $webspaceKey, $locale, $excludeGhosts, $excludeShadows, $complete) { $descendants = $this->getMapper()->loadNodeAndAncestors( $uuid, $locale, $webspaceKey, $excludeGhosts, $excludeShadows ); $descendants = array_reverse($descendants); $childTiers = []; foreach ($descendants as $descendant) { foreach ($descendant->getChildren() as $child) { $type = $child->getType(); if ($excludeShadows && null !== $type && 'shadow' === $type->getName()) { continue; } if ($excludeGhosts && null !== $type && 'ghost' === $type->getName()) { continue; } if (!isset($childTiers[$descendant->getUuid()])) { $childTiers[$descendant->getUuid()] = []; } $childTiers[$descendant->getUuid()][] = $this->prepareNode( $child, $webspaceKey, $locale, 1, $complete, $excludeGhosts ); } } $result = array_shift($childTiers); $this->iterateTiers($childTiers, $result); return $result; }
php
private function loadNodeAndAncestors($uuid, $webspaceKey, $locale, $excludeGhosts, $excludeShadows, $complete) { $descendants = $this->getMapper()->loadNodeAndAncestors( $uuid, $locale, $webspaceKey, $excludeGhosts, $excludeShadows ); $descendants = array_reverse($descendants); $childTiers = []; foreach ($descendants as $descendant) { foreach ($descendant->getChildren() as $child) { $type = $child->getType(); if ($excludeShadows && null !== $type && 'shadow' === $type->getName()) { continue; } if ($excludeGhosts && null !== $type && 'ghost' === $type->getName()) { continue; } if (!isset($childTiers[$descendant->getUuid()])) { $childTiers[$descendant->getUuid()] = []; } $childTiers[$descendant->getUuid()][] = $this->prepareNode( $child, $webspaceKey, $locale, 1, $complete, $excludeGhosts ); } } $result = array_shift($childTiers); $this->iterateTiers($childTiers, $result); return $result; }
[ "private", "function", "loadNodeAndAncestors", "(", "$", "uuid", ",", "$", "webspaceKey", ",", "$", "locale", ",", "$", "excludeGhosts", ",", "$", "excludeShadows", ",", "$", "complete", ")", "{", "$", "descendants", "=", "$", "this", "->", "getMapper", "(", ")", "->", "loadNodeAndAncestors", "(", "$", "uuid", ",", "$", "locale", ",", "$", "webspaceKey", ",", "$", "excludeGhosts", ",", "$", "excludeShadows", ")", ";", "$", "descendants", "=", "array_reverse", "(", "$", "descendants", ")", ";", "$", "childTiers", "=", "[", "]", ";", "foreach", "(", "$", "descendants", "as", "$", "descendant", ")", "{", "foreach", "(", "$", "descendant", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "type", "=", "$", "child", "->", "getType", "(", ")", ";", "if", "(", "$", "excludeShadows", "&&", "null", "!==", "$", "type", "&&", "'shadow'", "===", "$", "type", "->", "getName", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "excludeGhosts", "&&", "null", "!==", "$", "type", "&&", "'ghost'", "===", "$", "type", "->", "getName", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "childTiers", "[", "$", "descendant", "->", "getUuid", "(", ")", "]", ")", ")", "{", "$", "childTiers", "[", "$", "descendant", "->", "getUuid", "(", ")", "]", "=", "[", "]", ";", "}", "$", "childTiers", "[", "$", "descendant", "->", "getUuid", "(", ")", "]", "[", "]", "=", "$", "this", "->", "prepareNode", "(", "$", "child", ",", "$", "webspaceKey", ",", "$", "locale", ",", "1", ",", "$", "complete", ",", "$", "excludeGhosts", ")", ";", "}", "}", "$", "result", "=", "array_shift", "(", "$", "childTiers", ")", ";", "$", "this", "->", "iterateTiers", "(", "$", "childTiers", ",", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Load the node and its ancestors and convert them into a HATEOAS representation. @param string $uuid @param string $webspaceKey @param string $locale @param bool $excludeGhosts @param bool $excludeShadows @param bool $complete @return array
[ "Load", "the", "node", "and", "its", "ancestors", "and", "convert", "them", "into", "a", "HATEOAS", "representation", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php#L577-L619
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php
NodeRepository.iterateTiers
private function iterateTiers($tiers, &$result) { reset($tiers); $uuid = key($tiers); $tier = array_shift($tiers); $found = false; if (is_array($result)) { foreach ($result as &$node) { if ($node['id'] === $uuid) { $node['_embedded']['nodes'] = $tier; $found = true; break; } } } if (!$tiers) { return; } if (!$found) { throw new \RuntimeException( sprintf( 'Could not find target node in with UUID "%s" in tier. This should not happen.', $uuid ) ); } $this->iterateTiers($tiers, $node['_embedded']['nodes']); }
php
private function iterateTiers($tiers, &$result) { reset($tiers); $uuid = key($tiers); $tier = array_shift($tiers); $found = false; if (is_array($result)) { foreach ($result as &$node) { if ($node['id'] === $uuid) { $node['_embedded']['nodes'] = $tier; $found = true; break; } } } if (!$tiers) { return; } if (!$found) { throw new \RuntimeException( sprintf( 'Could not find target node in with UUID "%s" in tier. This should not happen.', $uuid ) ); } $this->iterateTiers($tiers, $node['_embedded']['nodes']); }
[ "private", "function", "iterateTiers", "(", "$", "tiers", ",", "&", "$", "result", ")", "{", "reset", "(", "$", "tiers", ")", ";", "$", "uuid", "=", "key", "(", "$", "tiers", ")", ";", "$", "tier", "=", "array_shift", "(", "$", "tiers", ")", ";", "$", "found", "=", "false", ";", "if", "(", "is_array", "(", "$", "result", ")", ")", "{", "foreach", "(", "$", "result", "as", "&", "$", "node", ")", "{", "if", "(", "$", "node", "[", "'id'", "]", "===", "$", "uuid", ")", "{", "$", "node", "[", "'_embedded'", "]", "[", "'nodes'", "]", "=", "$", "tier", ";", "$", "found", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "!", "$", "tiers", ")", "{", "return", ";", "}", "if", "(", "!", "$", "found", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Could not find target node in with UUID \"%s\" in tier. This should not happen.'", ",", "$", "uuid", ")", ")", ";", "}", "$", "this", "->", "iterateTiers", "(", "$", "tiers", ",", "$", "node", "[", "'_embedded'", "]", "[", "'nodes'", "]", ")", ";", "}" ]
Iterate over the ancestor tiers and build up the result. @param array $tiers @param array $result (by rereference)
[ "Iterate", "over", "the", "ancestor", "tiers", "and", "build", "up", "the", "result", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Repository/NodeRepository.php#L627-L658
train
sulu/sulu
src/Sulu/Component/DocumentManager/DocumentHelper.php
DocumentHelper.getDebugTitle
public static function getDebugTitle($document) { $title = spl_object_hash($document); if ($document instanceof PathBehavior && $document->getPath()) { $title .= ' (' . $document->getPath() . ')'; } elseif ($document instanceof TitleBehavior && $document->getTitle()) { $title .= ' (' . $document->getTitle() . ')'; } return $title; }
php
public static function getDebugTitle($document) { $title = spl_object_hash($document); if ($document instanceof PathBehavior && $document->getPath()) { $title .= ' (' . $document->getPath() . ')'; } elseif ($document instanceof TitleBehavior && $document->getTitle()) { $title .= ' (' . $document->getTitle() . ')'; } return $title; }
[ "public", "static", "function", "getDebugTitle", "(", "$", "document", ")", "{", "$", "title", "=", "spl_object_hash", "(", "$", "document", ")", ";", "if", "(", "$", "document", "instanceof", "PathBehavior", "&&", "$", "document", "->", "getPath", "(", ")", ")", "{", "$", "title", ".=", "' ('", ".", "$", "document", "->", "getPath", "(", ")", ".", "')'", ";", "}", "elseif", "(", "$", "document", "instanceof", "TitleBehavior", "&&", "$", "document", "->", "getTitle", "(", ")", ")", "{", "$", "title", ".=", "' ('", ".", "$", "document", "->", "getTitle", "(", ")", ".", "')'", ";", "}", "return", "$", "title", ";", "}" ]
Return a debug title for the document for use in exception messages. @param $document @return string
[ "Return", "a", "debug", "title", "for", "the", "document", "for", "use", "in", "exception", "messages", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/DocumentHelper.php#L26-L37
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Security/AuthenticationHandler.php
AuthenticationHandler.onAuthenticationSuccess
public function onAuthenticationSuccess(Request $request, TokenInterface $token) { // get url to redirect (or return in the JSON-response) if ($this->session->get('_security.admin.target_path') && false !== strpos($this->session->get('_security.admin.target_path'), '#') ) { $url = $this->session->get('_security.admin.target_path'); } else { $url = $this->router->generate('sulu_admin'); } if ($request->isXmlHttpRequest()) { // if AJAX login $array = ['url' => $url]; $response = new JsonResponse($array, 200); } else { // if form login $response = new RedirectResponse($url); } return $response; }
php
public function onAuthenticationSuccess(Request $request, TokenInterface $token) { // get url to redirect (or return in the JSON-response) if ($this->session->get('_security.admin.target_path') && false !== strpos($this->session->get('_security.admin.target_path'), '#') ) { $url = $this->session->get('_security.admin.target_path'); } else { $url = $this->router->generate('sulu_admin'); } if ($request->isXmlHttpRequest()) { // if AJAX login $array = ['url' => $url]; $response = new JsonResponse($array, 200); } else { // if form login $response = new RedirectResponse($url); } return $response; }
[ "public", "function", "onAuthenticationSuccess", "(", "Request", "$", "request", ",", "TokenInterface", "$", "token", ")", "{", "// get url to redirect (or return in the JSON-response)", "if", "(", "$", "this", "->", "session", "->", "get", "(", "'_security.admin.target_path'", ")", "&&", "false", "!==", "strpos", "(", "$", "this", "->", "session", "->", "get", "(", "'_security.admin.target_path'", ")", ",", "'#'", ")", ")", "{", "$", "url", "=", "$", "this", "->", "session", "->", "get", "(", "'_security.admin.target_path'", ")", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "router", "->", "generate", "(", "'sulu_admin'", ")", ";", "}", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "// if AJAX login", "$", "array", "=", "[", "'url'", "=>", "$", "url", "]", ";", "$", "response", "=", "new", "JsonResponse", "(", "$", "array", ",", "200", ")", ";", "}", "else", "{", "// if form login", "$", "response", "=", "new", "RedirectResponse", "(", "$", "url", ")", ";", "}", "return", "$", "response", ";", "}" ]
Handler for AuthenticationSuccess. Returns a JsonResponse if request is an AJAX-request. Returns a RedirectResponse otherwise. @param Request $request @param TokenInterface $token @return Response
[ "Handler", "for", "AuthenticationSuccess", ".", "Returns", "a", "JsonResponse", "if", "request", "is", "an", "AJAX", "-", "request", ".", "Returns", "a", "RedirectResponse", "otherwise", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Security/AuthenticationHandler.php#L57-L78
train
sulu/sulu
src/Sulu/Bundle/SecurityBundle/Security/AuthenticationHandler.php
AuthenticationHandler.onAuthenticationFailure
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { if ($request->isXmlHttpRequest()) { // if AJAX login $array = ['message' => $exception->getMessage()]; $response = new JsonResponse($array, 401); } else { // if form login // set authentication exception to session $this->session->set(Security::AUTHENTICATION_ERROR, $exception); $response = new RedirectResponse($this->router->generate('sulu_admin.login')); } return $response; }
php
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) { if ($request->isXmlHttpRequest()) { // if AJAX login $array = ['message' => $exception->getMessage()]; $response = new JsonResponse($array, 401); } else { // if form login // set authentication exception to session $this->session->set(Security::AUTHENTICATION_ERROR, $exception); $response = new RedirectResponse($this->router->generate('sulu_admin.login')); } return $response; }
[ "public", "function", "onAuthenticationFailure", "(", "Request", "$", "request", ",", "AuthenticationException", "$", "exception", ")", "{", "if", "(", "$", "request", "->", "isXmlHttpRequest", "(", ")", ")", "{", "// if AJAX login", "$", "array", "=", "[", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", "]", ";", "$", "response", "=", "new", "JsonResponse", "(", "$", "array", ",", "401", ")", ";", "}", "else", "{", "// if form login", "// set authentication exception to session", "$", "this", "->", "session", "->", "set", "(", "Security", "::", "AUTHENTICATION_ERROR", ",", "$", "exception", ")", ";", "$", "response", "=", "new", "RedirectResponse", "(", "$", "this", "->", "router", "->", "generate", "(", "'sulu_admin.login'", ")", ")", ";", "}", "return", "$", "response", ";", "}" ]
Handler for AuthenticationFailure. Returns a JsonResponse if request is an AJAX-request. Returns a Redirect-response otherwise. @param Request $request @param AuthenticationException $exception @return Response
[ "Handler", "for", "AuthenticationFailure", ".", "Returns", "a", "JsonResponse", "if", "request", "is", "an", "AJAX", "-", "request", ".", "Returns", "a", "Redirect", "-", "response", "otherwise", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SecurityBundle/Security/AuthenticationHandler.php#L89-L103
train
sulu/sulu
src/Sulu/Component/Content/Document/Structure/ManagedStructure.php
ManagedStructure.toArray
public function toArray() { $this->init(); $values = []; foreach (array_keys($this->structureMetadata->getProperties()) as $childName) { $values[$childName] = $this->normalize($this->getProperty($childName)->getValue()); } return $values; }
php
public function toArray() { $this->init(); $values = []; foreach (array_keys($this->structureMetadata->getProperties()) as $childName) { $values[$childName] = $this->normalize($this->getProperty($childName)->getValue()); } return $values; }
[ "public", "function", "toArray", "(", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "values", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "structureMetadata", "->", "getProperties", "(", ")", ")", "as", "$", "childName", ")", "{", "$", "values", "[", "$", "childName", "]", "=", "$", "this", "->", "normalize", "(", "$", "this", "->", "getProperty", "(", "$", "childName", ")", "->", "getValue", "(", ")", ")", ";", "}", "return", "$", "values", ";", "}" ]
Return an array copy of the property data. @return array
[ "Return", "an", "array", "copy", "of", "the", "property", "data", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Structure/ManagedStructure.php#L178-L187
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php
WorkflowStageSubscriber.setWorkflowStageOnDocument
public function setWorkflowStageOnDocument(HydrateEvent $event) { $document = $event->getDocument(); if (!$this->supports($event)) { return; } $node = $event->getNode(); $locale = $event->getLocale(); $document->setWorkflowStage( $node->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, $locale), WorkflowStage::TEST ) ); $event->getAccessor()->set( self::PUBLISHED_FIELD, $node->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::PUBLISHED_FIELD, $locale), null ) ); }
php
public function setWorkflowStageOnDocument(HydrateEvent $event) { $document = $event->getDocument(); if (!$this->supports($event)) { return; } $node = $event->getNode(); $locale = $event->getLocale(); $document->setWorkflowStage( $node->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, $locale), WorkflowStage::TEST ) ); $event->getAccessor()->set( self::PUBLISHED_FIELD, $node->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::PUBLISHED_FIELD, $locale), null ) ); }
[ "public", "function", "setWorkflowStageOnDocument", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "event", ")", ")", "{", "return", ";", "}", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "locale", "=", "$", "event", "->", "getLocale", "(", ")", ";", "$", "document", "->", "setWorkflowStage", "(", "$", "node", "->", "getPropertyValueWithDefault", "(", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "self", "::", "WORKFLOW_STAGE_FIELD", ",", "$", "locale", ")", ",", "WorkflowStage", "::", "TEST", ")", ")", ";", "$", "event", "->", "getAccessor", "(", ")", "->", "set", "(", "self", "::", "PUBLISHED_FIELD", ",", "$", "node", "->", "getPropertyValueWithDefault", "(", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "self", "::", "PUBLISHED_FIELD", ",", "$", "locale", ")", ",", "null", ")", ")", ";", "}" ]
Sets the workflow properties from the node on the document. @param HydrateEvent $event @throws \Sulu\Component\DocumentManager\Exception\DocumentManagerException
[ "Sets", "the", "workflow", "properties", "from", "the", "node", "on", "the", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php#L88-L113
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php
WorkflowStageSubscriber.setWorkflowStageToPublished
public function setWorkflowStageToPublished(PublishEvent $event) { $document = $event->getDocument(); if (!$this->supports($event)) { return; } $this->setWorkflowStage($document, $event->getAccessor(), WorkflowStage::PUBLISHED, $event->getLocale(), true); }
php
public function setWorkflowStageToPublished(PublishEvent $event) { $document = $event->getDocument(); if (!$this->supports($event)) { return; } $this->setWorkflowStage($document, $event->getAccessor(), WorkflowStage::PUBLISHED, $event->getLocale(), true); }
[ "public", "function", "setWorkflowStageToPublished", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "event", ")", ")", "{", "return", ";", "}", "$", "this", "->", "setWorkflowStage", "(", "$", "document", ",", "$", "event", "->", "getAccessor", "(", ")", ",", "WorkflowStage", "::", "PUBLISHED", ",", "$", "event", "->", "getLocale", "(", ")", ",", "true", ")", ";", "}" ]
Sets the workflow stage for the passed document to published. @param PublishEvent $event
[ "Sets", "the", "workflow", "stage", "for", "the", "passed", "document", "to", "published", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php#L136-L145
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php
WorkflowStageSubscriber.setWorkflowStage
private function setWorkflowStage( WorkflowStageBehavior $document, DocumentAccessor $accessor, $workflowStage, $locale, $live ) { $path = $this->documentInspector->getPath($document); $document->setWorkflowStage($workflowStage); $publishDate = $document->getPublished(); if (!$publishDate && WorkflowStage::PUBLISHED === $workflowStage) { $publishDate = new \DateTime(); $accessor->set(self::PUBLISHED_FIELD, $publishDate); } $defaultNode = $this->defaultSession->getNode($path); $this->setWorkflowStageOnNode($defaultNode, $locale, $workflowStage, $publishDate); if ($live) { $liveNode = $this->liveSession->getNode($path); $this->setWorkflowStageOnNode($liveNode, $locale, $workflowStage, $publishDate); } }
php
private function setWorkflowStage( WorkflowStageBehavior $document, DocumentAccessor $accessor, $workflowStage, $locale, $live ) { $path = $this->documentInspector->getPath($document); $document->setWorkflowStage($workflowStage); $publishDate = $document->getPublished(); if (!$publishDate && WorkflowStage::PUBLISHED === $workflowStage) { $publishDate = new \DateTime(); $accessor->set(self::PUBLISHED_FIELD, $publishDate); } $defaultNode = $this->defaultSession->getNode($path); $this->setWorkflowStageOnNode($defaultNode, $locale, $workflowStage, $publishDate); if ($live) { $liveNode = $this->liveSession->getNode($path); $this->setWorkflowStageOnNode($liveNode, $locale, $workflowStage, $publishDate); } }
[ "private", "function", "setWorkflowStage", "(", "WorkflowStageBehavior", "$", "document", ",", "DocumentAccessor", "$", "accessor", ",", "$", "workflowStage", ",", "$", "locale", ",", "$", "live", ")", "{", "$", "path", "=", "$", "this", "->", "documentInspector", "->", "getPath", "(", "$", "document", ")", ";", "$", "document", "->", "setWorkflowStage", "(", "$", "workflowStage", ")", ";", "$", "publishDate", "=", "$", "document", "->", "getPublished", "(", ")", ";", "if", "(", "!", "$", "publishDate", "&&", "WorkflowStage", "::", "PUBLISHED", "===", "$", "workflowStage", ")", "{", "$", "publishDate", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "accessor", "->", "set", "(", "self", "::", "PUBLISHED_FIELD", ",", "$", "publishDate", ")", ";", "}", "$", "defaultNode", "=", "$", "this", "->", "defaultSession", "->", "getNode", "(", "$", "path", ")", ";", "$", "this", "->", "setWorkflowStageOnNode", "(", "$", "defaultNode", ",", "$", "locale", ",", "$", "workflowStage", ",", "$", "publishDate", ")", ";", "if", "(", "$", "live", ")", "{", "$", "liveNode", "=", "$", "this", "->", "liveSession", "->", "getNode", "(", "$", "path", ")", ";", "$", "this", "->", "setWorkflowStageOnNode", "(", "$", "liveNode", ",", "$", "locale", ",", "$", "workflowStage", ",", "$", "publishDate", ")", ";", "}", "}" ]
Sets the workflow properties on the given document. @param WorkflowStageBehavior $document @param DocumentAccessor $accessor @param string $workflowStage @param string $locale @param string $live @throws \Sulu\Component\DocumentManager\Exception\DocumentManagerException
[ "Sets", "the", "workflow", "properties", "on", "the", "given", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php#L245-L269
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php
WorkflowStageSubscriber.setWorkflowStageOnNode
private function setWorkflowStageOnNode(NodeInterface $node, $locale, $workflowStage, \DateTime $publishDate = null) { $node->setProperty( $this->propertyEncoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, $locale), $workflowStage ); if ($publishDate) { $node->setProperty( $this->propertyEncoder->localizedSystemName(self::PUBLISHED_FIELD, $locale), $publishDate ); } }
php
private function setWorkflowStageOnNode(NodeInterface $node, $locale, $workflowStage, \DateTime $publishDate = null) { $node->setProperty( $this->propertyEncoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, $locale), $workflowStage ); if ($publishDate) { $node->setProperty( $this->propertyEncoder->localizedSystemName(self::PUBLISHED_FIELD, $locale), $publishDate ); } }
[ "private", "function", "setWorkflowStageOnNode", "(", "NodeInterface", "$", "node", ",", "$", "locale", ",", "$", "workflowStage", ",", "\\", "DateTime", "$", "publishDate", "=", "null", ")", "{", "$", "node", "->", "setProperty", "(", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "self", "::", "WORKFLOW_STAGE_FIELD", ",", "$", "locale", ")", ",", "$", "workflowStage", ")", ";", "if", "(", "$", "publishDate", ")", "{", "$", "node", "->", "setProperty", "(", "$", "this", "->", "propertyEncoder", "->", "localizedSystemName", "(", "self", "::", "PUBLISHED_FIELD", ",", "$", "locale", ")", ",", "$", "publishDate", ")", ";", "}", "}" ]
Sets the workflow stage properties on the given node. @param NodeInterface $node @param string $locale @param int $workflowStage @param \DateTime $publishDate
[ "Sets", "the", "workflow", "stage", "properties", "on", "the", "given", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php#L279-L292
train
sulu/sulu
src/Sulu/Bundle/PageBundle/Command/CleanupHistoryCommand.php
CleanupHistoryCommand.cleanup
private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun) { foreach ($node->getNodes() as $childNode) { $this->cleanup($output, $childNode, $rootPath, $dryRun); } $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/'); if (!$node->getPropertyValueWithDefault('sulu:history', false)) { $output->writeln( '<info>Processing aborted: </info>/' . $path . ' <comment>(no history url)</comment>' ); return; } if (false === $dryRun) { $node->remove(); } $output->writeln('<info>Processing: </info>/' . $path); }
php
private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun) { foreach ($node->getNodes() as $childNode) { $this->cleanup($output, $childNode, $rootPath, $dryRun); } $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/'); if (!$node->getPropertyValueWithDefault('sulu:history', false)) { $output->writeln( '<info>Processing aborted: </info>/' . $path . ' <comment>(no history url)</comment>' ); return; } if (false === $dryRun) { $node->remove(); } $output->writeln('<info>Processing: </info>/' . $path); }
[ "private", "function", "cleanup", "(", "OutputInterface", "$", "output", ",", "NodeInterface", "$", "node", ",", "$", "rootPath", ",", "$", "dryRun", ")", "{", "foreach", "(", "$", "node", "->", "getNodes", "(", ")", "as", "$", "childNode", ")", "{", "$", "this", "->", "cleanup", "(", "$", "output", ",", "$", "childNode", ",", "$", "rootPath", ",", "$", "dryRun", ")", ";", "}", "$", "path", "=", "ltrim", "(", "str_replace", "(", "$", "rootPath", ",", "''", ",", "$", "node", "->", "getPath", "(", ")", ")", ",", "'/'", ")", ";", "if", "(", "!", "$", "node", "->", "getPropertyValueWithDefault", "(", "'sulu:history'", ",", "false", ")", ")", "{", "$", "output", "->", "writeln", "(", "'<info>Processing aborted: </info>/'", ".", "$", "path", ".", "' <comment>(no history url)</comment>'", ")", ";", "return", ";", "}", "if", "(", "false", "===", "$", "dryRun", ")", "{", "$", "node", "->", "remove", "(", ")", ";", "}", "$", "output", "->", "writeln", "(", "'<info>Processing: </info>/'", ".", "$", "path", ")", ";", "}" ]
Cleanup specific node and his children. @param NodeInterface $node @param string $rootPath @param bool $dryRun
[ "Cleanup", "specific", "node", "and", "his", "children", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Command/CleanupHistoryCommand.php#L136-L157
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.getUserObjectPermission
private function getUserObjectPermission(SecurityCondition $securityCondition, UserInterface $user) { $permissions = $this->getPermissions($securityCondition->getObjectType(), $securityCondition->getObjectId()); return $this->getUserObjectPermissionByArray($permissions, $user); }
php
private function getUserObjectPermission(SecurityCondition $securityCondition, UserInterface $user) { $permissions = $this->getPermissions($securityCondition->getObjectType(), $securityCondition->getObjectId()); return $this->getUserObjectPermissionByArray($permissions, $user); }
[ "private", "function", "getUserObjectPermission", "(", "SecurityCondition", "$", "securityCondition", ",", "UserInterface", "$", "user", ")", "{", "$", "permissions", "=", "$", "this", "->", "getPermissions", "(", "$", "securityCondition", "->", "getObjectType", "(", ")", ",", "$", "securityCondition", "->", "getObjectId", "(", ")", ")", ";", "return", "$", "this", "->", "getUserObjectPermissionByArray", "(", "$", "permissions", ",", "$", "user", ")", ";", "}" ]
Returns the permissions for the given object for the given user. @param SecurityCondition $securityCondition The condition to check @param UserInterface $user The user for the check @return array
[ "Returns", "the", "permissions", "for", "the", "given", "object", "for", "the", "given", "user", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L148-L153
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.getUserObjectPermissionByArray
private function getUserObjectPermissionByArray($permissions, UserInterface $user) { if (empty($permissions)) { return []; } $userPermission = []; $roles = $user->getRoleObjects(); foreach ($roles as $role) { $roleId = $role->getId(); if (!isset($permissions[$roleId])) { continue; } $userPermission = $this->cumulatePermissions($userPermission, $permissions[$roleId]); } return $userPermission; }
php
private function getUserObjectPermissionByArray($permissions, UserInterface $user) { if (empty($permissions)) { return []; } $userPermission = []; $roles = $user->getRoleObjects(); foreach ($roles as $role) { $roleId = $role->getId(); if (!isset($permissions[$roleId])) { continue; } $userPermission = $this->cumulatePermissions($userPermission, $permissions[$roleId]); } return $userPermission; }
[ "private", "function", "getUserObjectPermissionByArray", "(", "$", "permissions", ",", "UserInterface", "$", "user", ")", "{", "if", "(", "empty", "(", "$", "permissions", ")", ")", "{", "return", "[", "]", ";", "}", "$", "userPermission", "=", "[", "]", ";", "$", "roles", "=", "$", "user", "->", "getRoleObjects", "(", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "$", "roleId", "=", "$", "role", "->", "getId", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "permissions", "[", "$", "roleId", "]", ")", ")", "{", "continue", ";", "}", "$", "userPermission", "=", "$", "this", "->", "cumulatePermissions", "(", "$", "userPermission", ",", "$", "permissions", "[", "$", "roleId", "]", ")", ";", "}", "return", "$", "userPermission", ";", "}" ]
Returns the permissions for the given permission array and the given user. @param array $permissions Object permissions @param UserInterface $user The user for the check @return array
[ "Returns", "the", "permissions", "for", "the", "given", "permission", "array", "and", "the", "given", "user", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L163-L181
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.getUserSecurityContextPermissions
private function getUserSecurityContextPermissions( $locale, $securityContext, UserInterface $user, $checkPermissionType ) { $userPermissions = []; foreach ($user->getUserRoles() as $userRole) { $userPermissions = $this->cumulatePermissions( $userPermissions, $this->getUserRoleSecurityContextPermission( $locale, $securityContext, $userRole, $checkPermissionType ) ); } return $userPermissions; }
php
private function getUserSecurityContextPermissions( $locale, $securityContext, UserInterface $user, $checkPermissionType ) { $userPermissions = []; foreach ($user->getUserRoles() as $userRole) { $userPermissions = $this->cumulatePermissions( $userPermissions, $this->getUserRoleSecurityContextPermission( $locale, $securityContext, $userRole, $checkPermissionType ) ); } return $userPermissions; }
[ "private", "function", "getUserSecurityContextPermissions", "(", "$", "locale", ",", "$", "securityContext", ",", "UserInterface", "$", "user", ",", "$", "checkPermissionType", ")", "{", "$", "userPermissions", "=", "[", "]", ";", "foreach", "(", "$", "user", "->", "getUserRoles", "(", ")", "as", "$", "userRole", ")", "{", "$", "userPermissions", "=", "$", "this", "->", "cumulatePermissions", "(", "$", "userPermissions", ",", "$", "this", "->", "getUserRoleSecurityContextPermission", "(", "$", "locale", ",", "$", "securityContext", ",", "$", "userRole", ",", "$", "checkPermissionType", ")", ")", ";", "}", "return", "$", "userPermissions", ";", "}" ]
Returns the permissions for the given security context for the given user. @param string $locale @param string $securityContext @param UserInterface $user The user for which the security is checked @param bool $checkPermissionType Flag to show if the permission type should also be checked. If set to false it will only check if the user has access to the context in the given locale @return array
[ "Returns", "the", "permissions", "for", "the", "given", "security", "context", "for", "the", "given", "user", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L194-L215
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.getUserRoleSecurityContextPermission
private function getUserRoleSecurityContextPermission( $locale, $securityContext, UserRole $userRole, $checkPermissionType ) { $userPermission = $this->maskConverter->convertPermissionsToArray(0); foreach ($userRole->getRole()->getPermissions() as $permission) { $hasContext = $permission->getContext() == $securityContext; if (!$hasContext) { continue; } $hasLocale = null == $locale || in_array($locale, $userRole->getLocales()); if (!$hasLocale) { continue; } if ($checkPermissionType) { $userPermission = $this->maskConverter->convertPermissionsToArray($permission->getPermissions()); } else { array_walk($userPermission, function(&$permission) { $permission = true; }); } } return $userPermission; }
php
private function getUserRoleSecurityContextPermission( $locale, $securityContext, UserRole $userRole, $checkPermissionType ) { $userPermission = $this->maskConverter->convertPermissionsToArray(0); foreach ($userRole->getRole()->getPermissions() as $permission) { $hasContext = $permission->getContext() == $securityContext; if (!$hasContext) { continue; } $hasLocale = null == $locale || in_array($locale, $userRole->getLocales()); if (!$hasLocale) { continue; } if ($checkPermissionType) { $userPermission = $this->maskConverter->convertPermissionsToArray($permission->getPermissions()); } else { array_walk($userPermission, function(&$permission) { $permission = true; }); } } return $userPermission; }
[ "private", "function", "getUserRoleSecurityContextPermission", "(", "$", "locale", ",", "$", "securityContext", ",", "UserRole", "$", "userRole", ",", "$", "checkPermissionType", ")", "{", "$", "userPermission", "=", "$", "this", "->", "maskConverter", "->", "convertPermissionsToArray", "(", "0", ")", ";", "foreach", "(", "$", "userRole", "->", "getRole", "(", ")", "->", "getPermissions", "(", ")", "as", "$", "permission", ")", "{", "$", "hasContext", "=", "$", "permission", "->", "getContext", "(", ")", "==", "$", "securityContext", ";", "if", "(", "!", "$", "hasContext", ")", "{", "continue", ";", "}", "$", "hasLocale", "=", "null", "==", "$", "locale", "||", "in_array", "(", "$", "locale", ",", "$", "userRole", "->", "getLocales", "(", ")", ")", ";", "if", "(", "!", "$", "hasLocale", ")", "{", "continue", ";", "}", "if", "(", "$", "checkPermissionType", ")", "{", "$", "userPermission", "=", "$", "this", "->", "maskConverter", "->", "convertPermissionsToArray", "(", "$", "permission", "->", "getPermissions", "(", ")", ")", ";", "}", "else", "{", "array_walk", "(", "$", "userPermission", ",", "function", "(", "&", "$", "permission", ")", "{", "$", "permission", "=", "true", ";", "}", ")", ";", "}", "}", "return", "$", "userPermission", ";", "}" ]
Returns the permissions for the given security context for the given user role. @param string $locale @param string $securityContext @param UserRole $userRole The user role for which the security is checked @param bool $checkPermissionType Flag to show if the permission type should also be checked @return array
[ "Returns", "the", "permissions", "for", "the", "given", "security", "context", "for", "the", "given", "user", "role", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L227-L258
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.cumulatePermissions
private function cumulatePermissions(array $userPermission, array $permissions) { return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) { return $permission1 || $permission2; }); }
php
private function cumulatePermissions(array $userPermission, array $permissions) { return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) { return $permission1 || $permission2; }); }
[ "private", "function", "cumulatePermissions", "(", "array", "$", "userPermission", ",", "array", "$", "permissions", ")", "{", "return", "$", "this", "->", "mapPermissions", "(", "$", "userPermission", ",", "$", "permissions", ",", "function", "(", "$", "permission1", ",", "$", "permission2", ")", "{", "return", "$", "permission1", "||", "$", "permission2", ";", "}", ")", ";", "}" ]
Merges all the true values for the given permission arrays. @param array $permissions The array of the additional permissions @param array $userPermission The array of the currently changing permissions @return mixed
[ "Merges", "all", "the", "true", "values", "for", "the", "given", "permission", "arrays", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L287-L292
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.restrictPermissions
private function restrictPermissions(array $userPermission, array $permissions) { return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) { return $permission1 && $permission2; }); }
php
private function restrictPermissions(array $userPermission, array $permissions) { return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) { return $permission1 && $permission2; }); }
[ "private", "function", "restrictPermissions", "(", "array", "$", "userPermission", ",", "array", "$", "permissions", ")", "{", "return", "$", "this", "->", "mapPermissions", "(", "$", "userPermission", ",", "$", "permissions", ",", "function", "(", "$", "permission1", ",", "$", "permission2", ")", "{", "return", "$", "permission1", "&&", "$", "permission2", ";", "}", ")", ";", "}" ]
Merges all the values for the given permission arrays. Only returns true if all values are true. @param array $permissions The array of the additional permissions @param array $userPermission The array of the currently changing permissions @return mixed
[ "Merges", "all", "the", "values", "for", "the", "given", "permission", "arrays", ".", "Only", "returns", "true", "if", "all", "values", "are", "true", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L302-L307
train
sulu/sulu
src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php
AccessControlManager.getAccessControlProvider
private function getAccessControlProvider($type) { foreach ($this->accessControlProviders as $accessControlProvider) { if ($accessControlProvider->supports($type)) { return $accessControlProvider; } } }
php
private function getAccessControlProvider($type) { foreach ($this->accessControlProviders as $accessControlProvider) { if ($accessControlProvider->supports($type)) { return $accessControlProvider; } } }
[ "private", "function", "getAccessControlProvider", "(", "$", "type", ")", "{", "foreach", "(", "$", "this", "->", "accessControlProviders", "as", "$", "accessControlProvider", ")", "{", "if", "(", "$", "accessControlProvider", "->", "supports", "(", "$", "type", ")", ")", "{", "return", "$", "accessControlProvider", ";", "}", "}", "}" ]
Returns the AccessControlProvider, which supports the given type. @param string $type The type the AccessControlProvider should support @return AccessControlProviderInterface
[ "Returns", "the", "AccessControlProvider", "which", "supports", "the", "given", "type", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Security/Authorization/AccessControl/AccessControlManager.php#L316-L323
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Contact/CustomerManager.php
CustomerManager.findAccountsByIds
private function findAccountsByIds($ids) { if (0 === count($ids)) { return []; } $queryBuilder = $this->entityManager->createQueryBuilder() ->select('CONCAT(\'a\', a.id) AS id, a.name AS name') ->from($this->accountEntityClass, 'a') ->where('a.id IN (:ids)'); $query = $queryBuilder->getQuery(); $query->setParameter('ids', $ids); return $query->getArrayResult(); }
php
private function findAccountsByIds($ids) { if (0 === count($ids)) { return []; } $queryBuilder = $this->entityManager->createQueryBuilder() ->select('CONCAT(\'a\', a.id) AS id, a.name AS name') ->from($this->accountEntityClass, 'a') ->where('a.id IN (:ids)'); $query = $queryBuilder->getQuery(); $query->setParameter('ids', $ids); return $query->getArrayResult(); }
[ "private", "function", "findAccountsByIds", "(", "$", "ids", ")", "{", "if", "(", "0", "===", "count", "(", "$", "ids", ")", ")", "{", "return", "[", "]", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'CONCAT(\\'a\\', a.id) AS id, a.name AS name'", ")", "->", "from", "(", "$", "this", "->", "accountEntityClass", ",", "'a'", ")", "->", "where", "(", "'a.id IN (:ids)'", ")", ";", "$", "query", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'ids'", ",", "$", "ids", ")", ";", "return", "$", "query", "->", "getArrayResult", "(", ")", ";", "}" ]
Returns array of accounts by ids. @param array $ids @return array
[ "Returns", "array", "of", "accounts", "by", "ids", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Contact/CustomerManager.php#L95-L110
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Contact/CustomerManager.php
CustomerManager.findContactsByIds
private function findContactsByIds($ids) { if (0 === count($ids)) { return []; } $queryBuilder = $this->entityManager->createQueryBuilder() ->select('CONCAT(\'c\', c.id) AS id, CONCAT(CONCAT(c.firstName, \' \'), c.lastName) AS name') ->from($this->contactEntityClass, 'c') ->where('c.id IN (:ids)'); $query = $queryBuilder->getQuery(); $query->setParameter('ids', $ids); return $query->getArrayResult(); }
php
private function findContactsByIds($ids) { if (0 === count($ids)) { return []; } $queryBuilder = $this->entityManager->createQueryBuilder() ->select('CONCAT(\'c\', c.id) AS id, CONCAT(CONCAT(c.firstName, \' \'), c.lastName) AS name') ->from($this->contactEntityClass, 'c') ->where('c.id IN (:ids)'); $query = $queryBuilder->getQuery(); $query->setParameter('ids', $ids); return $query->getArrayResult(); }
[ "private", "function", "findContactsByIds", "(", "$", "ids", ")", "{", "if", "(", "0", "===", "count", "(", "$", "ids", ")", ")", "{", "return", "[", "]", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "entityManager", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'CONCAT(\\'c\\', c.id) AS id, CONCAT(CONCAT(c.firstName, \\' \\'), c.lastName) AS name'", ")", "->", "from", "(", "$", "this", "->", "contactEntityClass", ",", "'c'", ")", "->", "where", "(", "'c.id IN (:ids)'", ")", ";", "$", "query", "=", "$", "queryBuilder", "->", "getQuery", "(", ")", ";", "$", "query", "->", "setParameter", "(", "'ids'", ",", "$", "ids", ")", ";", "return", "$", "query", "->", "getArrayResult", "(", ")", ";", "}" ]
Returns array of contacts by ids. @param array $ids @return array
[ "Returns", "array", "of", "contacts", "by", "ids", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Contact/CustomerManager.php#L119-L134
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Controller/MediaFormatController.php
MediaFormatController.cgetAction
public function cgetAction($id, Request $request) { $formatOptions = $this->getFormatOptionsManager()->getAll($id); return $this->handleView($this->view(count($formatOptions) > 0 ? $formatOptions : new \stdClass())); }
php
public function cgetAction($id, Request $request) { $formatOptions = $this->getFormatOptionsManager()->getAll($id); return $this->handleView($this->view(count($formatOptions) > 0 ? $formatOptions : new \stdClass())); }
[ "public", "function", "cgetAction", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "formatOptions", "=", "$", "this", "->", "getFormatOptionsManager", "(", ")", "->", "getAll", "(", "$", "id", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "count", "(", "$", "formatOptions", ")", ">", "0", "?", "$", "formatOptions", ":", "new", "\\", "stdClass", "(", ")", ")", ")", ";", "}" ]
Returns all format resources. @param $id @param Request $request @return Response
[ "Returns", "all", "format", "resources", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Controller/MediaFormatController.php#L38-L43
train
sulu/sulu
src/Sulu/Bundle/MediaBundle/Controller/MediaFormatController.php
MediaFormatController.putAction
public function putAction($id, $key, Request $request) { $options = $request->request->all(); if (empty($options)) { $this->getFormatOptionsManager()->delete($id, $key); } else { $this->getFormatOptionsManager()->save($id, $key, $options); } $this->get('doctrine.orm.entity_manager')->flush(); $formatOptions = $this->getFormatOptionsManager()->get($id, $key); return $this->handleView($this->view($formatOptions)); }
php
public function putAction($id, $key, Request $request) { $options = $request->request->all(); if (empty($options)) { $this->getFormatOptionsManager()->delete($id, $key); } else { $this->getFormatOptionsManager()->save($id, $key, $options); } $this->get('doctrine.orm.entity_manager')->flush(); $formatOptions = $this->getFormatOptionsManager()->get($id, $key); return $this->handleView($this->view($formatOptions)); }
[ "public", "function", "putAction", "(", "$", "id", ",", "$", "key", ",", "Request", "$", "request", ")", "{", "$", "options", "=", "$", "request", "->", "request", "->", "all", "(", ")", ";", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "$", "this", "->", "getFormatOptionsManager", "(", ")", "->", "delete", "(", "$", "id", ",", "$", "key", ")", ";", "}", "else", "{", "$", "this", "->", "getFormatOptionsManager", "(", ")", "->", "save", "(", "$", "id", ",", "$", "key", ",", "$", "options", ")", ";", "}", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", "->", "flush", "(", ")", ";", "$", "formatOptions", "=", "$", "this", "->", "getFormatOptionsManager", "(", ")", "->", "get", "(", "$", "id", ",", "$", "key", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "$", "formatOptions", ")", ")", ";", "}" ]
Edits a format resource. @param int $id @param string $key @param Request $request @return Response
[ "Edits", "a", "format", "resource", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Controller/MediaFormatController.php#L54-L68
train
sulu/sulu
src/Sulu/Bundle/WebsiteBundle/Sitemap/XmlSitemapDumper.php
XmlSitemapDumper.dumpProviderSitemap
private function dumpProviderSitemap($alias, PortalInformation $portalInformation, $scheme) { $maxPage = $this->sitemapProviderPool->getProvider($alias)->getMaxPage(); for ($page = 1; $page <= $maxPage; ++$page) { $sitemap = $this->sitemapRenderer->renderSitemap( $alias, $page, $portalInformation->getLocale(), $portalInformation->getPortal(), $portalInformation->getHost(), $scheme ); $this->dumpFile( $this->getDumpPath( $scheme, $portalInformation->getWebspaceKey(), $portalInformation->getLocale(), $portalInformation->getHost(), $alias, $page ), $sitemap ); } }
php
private function dumpProviderSitemap($alias, PortalInformation $portalInformation, $scheme) { $maxPage = $this->sitemapProviderPool->getProvider($alias)->getMaxPage(); for ($page = 1; $page <= $maxPage; ++$page) { $sitemap = $this->sitemapRenderer->renderSitemap( $alias, $page, $portalInformation->getLocale(), $portalInformation->getPortal(), $portalInformation->getHost(), $scheme ); $this->dumpFile( $this->getDumpPath( $scheme, $portalInformation->getWebspaceKey(), $portalInformation->getLocale(), $portalInformation->getHost(), $alias, $page ), $sitemap ); } }
[ "private", "function", "dumpProviderSitemap", "(", "$", "alias", ",", "PortalInformation", "$", "portalInformation", ",", "$", "scheme", ")", "{", "$", "maxPage", "=", "$", "this", "->", "sitemapProviderPool", "->", "getProvider", "(", "$", "alias", ")", "->", "getMaxPage", "(", ")", ";", "for", "(", "$", "page", "=", "1", ";", "$", "page", "<=", "$", "maxPage", ";", "++", "$", "page", ")", "{", "$", "sitemap", "=", "$", "this", "->", "sitemapRenderer", "->", "renderSitemap", "(", "$", "alias", ",", "$", "page", ",", "$", "portalInformation", "->", "getLocale", "(", ")", ",", "$", "portalInformation", "->", "getPortal", "(", ")", ",", "$", "portalInformation", "->", "getHost", "(", ")", ",", "$", "scheme", ")", ";", "$", "this", "->", "dumpFile", "(", "$", "this", "->", "getDumpPath", "(", "$", "scheme", ",", "$", "portalInformation", "->", "getWebspaceKey", "(", ")", ",", "$", "portalInformation", "->", "getLocale", "(", ")", ",", "$", "portalInformation", "->", "getHost", "(", ")", ",", "$", "alias", ",", "$", "page", ")", ",", "$", "sitemap", ")", ";", "}", "}" ]
Render sitemap for provider. @param string $alias @param PortalInformation $portalInformation @param string $scheme
[ "Render", "sitemap", "for", "provider", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Sitemap/XmlSitemapDumper.php#L151-L176
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/StructureRemoveSubscriber.php
StructureRemoveSubscriber.removeRoute
private function removeRoute(StructureBehavior $document) { foreach ($this->documentInspector->getReferrers($document) as $referrer) { if ($referrer instanceof RouteBehavior) { $this->documentManager->remove($referrer); } } }
php
private function removeRoute(StructureBehavior $document) { foreach ($this->documentInspector->getReferrers($document) as $referrer) { if ($referrer instanceof RouteBehavior) { $this->documentManager->remove($referrer); } } }
[ "private", "function", "removeRoute", "(", "StructureBehavior", "$", "document", ")", "{", "foreach", "(", "$", "this", "->", "documentInspector", "->", "getReferrers", "(", "$", "document", ")", "as", "$", "referrer", ")", "{", "if", "(", "$", "referrer", "instanceof", "RouteBehavior", ")", "{", "$", "this", "->", "documentManager", "->", "remove", "(", "$", "referrer", ")", ";", "}", "}", "}" ]
Removes related route of given document. @param StructureBehavior $document
[ "Removes", "related", "route", "of", "given", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/StructureRemoveSubscriber.php#L104-L111
train
sulu/sulu
src/Sulu/Component/Content/Repository/Content.php
Content.getPropertyWithDefault
public function getPropertyWithDefault($name, $default = null) { if (!array_key_exists($name, $this->data)) { return $default; } return $this->data[$name]; }
php
public function getPropertyWithDefault($name, $default = null) { if (!array_key_exists($name, $this->data)) { return $default; } return $this->data[$name]; }
[ "public", "function", "getPropertyWithDefault", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "data", ")", ")", "{", "return", "$", "default", ";", "}", "return", "$", "this", "->", "data", "[", "$", "name", "]", ";", "}" ]
Returns value for given property or given default. @param string $name @param mixed $default @return mixed
[ "Returns", "value", "for", "given", "property", "or", "given", "default", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Repository/Content.php#L196-L203
train
sulu/sulu
src/Sulu/Component/Persistence/RelationTrait.php
RelationTrait.compareEntitiesWithData
public function compareEntitiesWithData( $entities, array $requestEntities, callable $compare, callable $add = null, callable $update = null, callable $delete = null ) { // define a matching function $matchFunction = function($entity, $requestEntities, &$matchedEntry, &$matchedKey) use ($compare) { $this->findMatchByCallback($entity, $requestEntities, $compare, $matchedEntry, $matchedKey); }; return $this->compareData($entities, $requestEntities, $matchFunction, $add, $update, $delete); }
php
public function compareEntitiesWithData( $entities, array $requestEntities, callable $compare, callable $add = null, callable $update = null, callable $delete = null ) { // define a matching function $matchFunction = function($entity, $requestEntities, &$matchedEntry, &$matchedKey) use ($compare) { $this->findMatchByCallback($entity, $requestEntities, $compare, $matchedEntry, $matchedKey); }; return $this->compareData($entities, $requestEntities, $matchFunction, $add, $update, $delete); }
[ "public", "function", "compareEntitiesWithData", "(", "$", "entities", ",", "array", "$", "requestEntities", ",", "callable", "$", "compare", ",", "callable", "$", "add", "=", "null", ",", "callable", "$", "update", "=", "null", ",", "callable", "$", "delete", "=", "null", ")", "{", "// define a matching function", "$", "matchFunction", "=", "function", "(", "$", "entity", ",", "$", "requestEntities", ",", "&", "$", "matchedEntry", ",", "&", "$", "matchedKey", ")", "use", "(", "$", "compare", ")", "{", "$", "this", "->", "findMatchByCallback", "(", "$", "entity", ",", "$", "requestEntities", ",", "$", "compare", ",", "$", "matchedEntry", ",", "$", "matchedKey", ")", ";", "}", ";", "return", "$", "this", "->", "compareData", "(", "$", "entities", ",", "$", "requestEntities", ",", "$", "matchFunction", ",", "$", "add", ",", "$", "update", ",", "$", "delete", ")", ";", "}" ]
Compares entities with data array and calls the given callbacks. @param Traversable $entities The list of entities to work on @param array $requestEntities The entities as retrieved from the request @param callable $compare return true if data matches entity @param callable $add @param callable $update @param callable $delete @return bool
[ "Compares", "entities", "with", "data", "array", "and", "calls", "the", "given", "callbacks", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Persistence/RelationTrait.php#L66-L80
train
sulu/sulu
src/Sulu/Component/Persistence/RelationTrait.php
RelationTrait.compareData
public function compareData( $entities, array $requestEntities, callable $compare = null, callable $add = null, callable $update = null, callable $delete = null ) { $success = true; if (!empty($entities)) { foreach ($entities as $entity) { $matchedEntry = null; $matchedKey = null; // find match callback $compare($entity, $requestEntities, $matchedEntry, $matchedKey); if (null == $matchedEntry && null != $delete) { // delete entity if it is not listed anymore $delete($entity); } elseif (null != $update) { // update entity if it is matched $success = $update($entity, $matchedEntry); if (!$success) { break; } } // Remove done element from array if (null !== $matchedKey) { unset($requestEntities[$matchedKey]); } } } // The entity which have not been delete or updated have to be added if (!empty($requestEntities) && null != $add) { foreach ($requestEntities as $entity) { if (!$success) { break; } $success = $add($entity); } } return $success; }
php
public function compareData( $entities, array $requestEntities, callable $compare = null, callable $add = null, callable $update = null, callable $delete = null ) { $success = true; if (!empty($entities)) { foreach ($entities as $entity) { $matchedEntry = null; $matchedKey = null; // find match callback $compare($entity, $requestEntities, $matchedEntry, $matchedKey); if (null == $matchedEntry && null != $delete) { // delete entity if it is not listed anymore $delete($entity); } elseif (null != $update) { // update entity if it is matched $success = $update($entity, $matchedEntry); if (!$success) { break; } } // Remove done element from array if (null !== $matchedKey) { unset($requestEntities[$matchedKey]); } } } // The entity which have not been delete or updated have to be added if (!empty($requestEntities) && null != $add) { foreach ($requestEntities as $entity) { if (!$success) { break; } $success = $add($entity); } } return $success; }
[ "public", "function", "compareData", "(", "$", "entities", ",", "array", "$", "requestEntities", ",", "callable", "$", "compare", "=", "null", ",", "callable", "$", "add", "=", "null", ",", "callable", "$", "update", "=", "null", ",", "callable", "$", "delete", "=", "null", ")", "{", "$", "success", "=", "true", ";", "if", "(", "!", "empty", "(", "$", "entities", ")", ")", "{", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "matchedEntry", "=", "null", ";", "$", "matchedKey", "=", "null", ";", "// find match callback", "$", "compare", "(", "$", "entity", ",", "$", "requestEntities", ",", "$", "matchedEntry", ",", "$", "matchedKey", ")", ";", "if", "(", "null", "==", "$", "matchedEntry", "&&", "null", "!=", "$", "delete", ")", "{", "// delete entity if it is not listed anymore", "$", "delete", "(", "$", "entity", ")", ";", "}", "elseif", "(", "null", "!=", "$", "update", ")", "{", "// update entity if it is matched", "$", "success", "=", "$", "update", "(", "$", "entity", ",", "$", "matchedEntry", ")", ";", "if", "(", "!", "$", "success", ")", "{", "break", ";", "}", "}", "// Remove done element from array", "if", "(", "null", "!==", "$", "matchedKey", ")", "{", "unset", "(", "$", "requestEntities", "[", "$", "matchedKey", "]", ")", ";", "}", "}", "}", "// The entity which have not been delete or updated have to be added", "if", "(", "!", "empty", "(", "$", "requestEntities", ")", "&&", "null", "!=", "$", "add", ")", "{", "foreach", "(", "$", "requestEntities", "as", "$", "entity", ")", "{", "if", "(", "!", "$", "success", ")", "{", "break", ";", "}", "$", "success", "=", "$", "add", "(", "$", "entity", ")", ";", "}", "}", "return", "$", "success", ";", "}" ]
function compares entities with data of array and makes callback. @param $entities @param array $requestEntities @param callable $compare @param callable $add @param callable $update @param callable $delete @return bool
[ "function", "compares", "entities", "with", "data", "of", "array", "and", "makes", "callback", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Persistence/RelationTrait.php#L119-L166
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/FaxType.php
FaxType.removeFaxe
public function removeFaxe(\Sulu\Bundle\ContactBundle\Entity\Fax $faxes) { $this->faxes->removeElement($faxes); }
php
public function removeFaxe(\Sulu\Bundle\ContactBundle\Entity\Fax $faxes) { $this->faxes->removeElement($faxes); }
[ "public", "function", "removeFaxe", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ContactBundle", "\\", "Entity", "\\", "Fax", "$", "faxes", ")", "{", "$", "this", "->", "faxes", "->", "removeElement", "(", "$", "faxes", ")", ";", "}" ]
Remove faxes. @param \Sulu\Bundle\ContactBundle\Entity\Fax $faxes
[ "Remove", "faxes", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/FaxType.php#L111-L114
train
sulu/sulu
src/Sulu/Bundle/ContactBundle/Entity/AddressType.php
AddressType.removeAddresse
public function removeAddresse(\Sulu\Bundle\ContactBundle\Entity\Address $addresses) { $this->addresses->removeElement($addresses); }
php
public function removeAddresse(\Sulu\Bundle\ContactBundle\Entity\Address $addresses) { $this->addresses->removeElement($addresses); }
[ "public", "function", "removeAddresse", "(", "\\", "Sulu", "\\", "Bundle", "\\", "ContactBundle", "\\", "Entity", "\\", "Address", "$", "addresses", ")", "{", "$", "this", "->", "addresses", "->", "removeElement", "(", "$", "addresses", ")", ";", "}" ]
Remove addresses. @param \Sulu\Bundle\ContactBundle\Entity\Address $addresses
[ "Remove", "addresses", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/AddressType.php#L111-L114
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/TitleSubscriber.php
TitleSubscriber.setTitleOnDocument
public function setTitleOnDocument(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } if ($document instanceof LocalizedTitleBehavior) { if (!$event->getLocale()) { return; } $document->setTitle( $event->getNode()->getPropertyValueWithDefault( $this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()), '' ) ); } else { $document->setTitle( $event->getNode()->getPropertyValueWithDefault( $this->propertyEncoder->contentName(static::PROPERTY_NAME), '' ) ); } }
php
public function setTitleOnDocument(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } if ($document instanceof LocalizedTitleBehavior) { if (!$event->getLocale()) { return; } $document->setTitle( $event->getNode()->getPropertyValueWithDefault( $this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()), '' ) ); } else { $document->setTitle( $event->getNode()->getPropertyValueWithDefault( $this->propertyEncoder->contentName(static::PROPERTY_NAME), '' ) ); } }
[ "public", "function", "setTitleOnDocument", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "if", "(", "$", "document", "instanceof", "LocalizedTitleBehavior", ")", "{", "if", "(", "!", "$", "event", "->", "getLocale", "(", ")", ")", "{", "return", ";", "}", "$", "document", "->", "setTitle", "(", "$", "event", "->", "getNode", "(", ")", "->", "getPropertyValueWithDefault", "(", "$", "this", "->", "propertyEncoder", "->", "localizedContentName", "(", "static", "::", "PROPERTY_NAME", ",", "$", "event", "->", "getLocale", "(", ")", ")", ",", "''", ")", ")", ";", "}", "else", "{", "$", "document", "->", "setTitle", "(", "$", "event", "->", "getNode", "(", ")", "->", "getPropertyValueWithDefault", "(", "$", "this", "->", "propertyEncoder", "->", "contentName", "(", "static", "::", "PROPERTY_NAME", ")", ",", "''", ")", ")", ";", "}", "}" ]
Sets the title on the document from the node. @param AbstractMappingEvent $event
[ "Sets", "the", "title", "on", "the", "document", "from", "the", "node", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/TitleSubscriber.php#L54-L81
train
sulu/sulu
src/Sulu/Component/Content/Document/Subscriber/TitleSubscriber.php
TitleSubscriber.setTitleOnNode
public function setTitleOnNode(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } if ($document instanceof LocalizedTitleBehavior) { if (!$event->getLocale()) { return; } $event->getNode()->setProperty( $this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()), $document->getTitle() ); } else { $event->getNode()->setProperty( $this->propertyEncoder->contentName(static::PROPERTY_NAME), $document->getTitle() ); } }
php
public function setTitleOnNode(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$this->supports($document)) { return; } if ($document instanceof LocalizedTitleBehavior) { if (!$event->getLocale()) { return; } $event->getNode()->setProperty( $this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()), $document->getTitle() ); } else { $event->getNode()->setProperty( $this->propertyEncoder->contentName(static::PROPERTY_NAME), $document->getTitle() ); } }
[ "public", "function", "setTitleOnNode", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "this", "->", "supports", "(", "$", "document", ")", ")", "{", "return", ";", "}", "if", "(", "$", "document", "instanceof", "LocalizedTitleBehavior", ")", "{", "if", "(", "!", "$", "event", "->", "getLocale", "(", ")", ")", "{", "return", ";", "}", "$", "event", "->", "getNode", "(", ")", "->", "setProperty", "(", "$", "this", "->", "propertyEncoder", "->", "localizedContentName", "(", "static", "::", "PROPERTY_NAME", ",", "$", "event", "->", "getLocale", "(", ")", ")", ",", "$", "document", "->", "getTitle", "(", ")", ")", ";", "}", "else", "{", "$", "event", "->", "getNode", "(", ")", "->", "setProperty", "(", "$", "this", "->", "propertyEncoder", "->", "contentName", "(", "static", "::", "PROPERTY_NAME", ")", ",", "$", "document", "->", "getTitle", "(", ")", ")", ";", "}", "}" ]
Sets the title on the node from the value in the document. @param PersistEvent $event
[ "Sets", "the", "title", "on", "the", "node", "from", "the", "value", "in", "the", "document", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/TitleSubscriber.php#L88-L111
train
sulu/sulu
src/Sulu/Component/Rest/Listing/ListRestHelper.php
ListRestHelper.getRepository
public function getRepository($entityName) { return new ListRepository($this->em, $this->em->getClassMetadata($entityName), $this); }
php
public function getRepository($entityName) { return new ListRepository($this->em, $this->em->getClassMetadata($entityName), $this); }
[ "public", "function", "getRepository", "(", "$", "entityName", ")", "{", "return", "new", "ListRepository", "(", "$", "this", "->", "em", ",", "$", "this", "->", "em", "->", "getClassMetadata", "(", "$", "entityName", ")", ",", "$", "this", ")", ";", "}" ]
Create a ListRepository for given EntityName. @param string $entityName @return ListRepository
[ "Create", "a", "ListRepository", "for", "given", "EntityName", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/Listing/ListRestHelper.php#L68-L71
train
sulu/sulu
src/Sulu/Component/Rest/Listing/ListRestHelper.php
ListRestHelper.find
public function find($entityName, $where = [], $joinConditions = []) { return $this->getRepository($entityName)->find($where, 'u', false, $joinConditions); }
php
public function find($entityName, $where = [], $joinConditions = []) { return $this->getRepository($entityName)->find($where, 'u', false, $joinConditions); }
[ "public", "function", "find", "(", "$", "entityName", ",", "$", "where", "=", "[", "]", ",", "$", "joinConditions", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getRepository", "(", "$", "entityName", ")", "->", "find", "(", "$", "where", ",", "'u'", ",", "false", ",", "$", "joinConditions", ")", ";", "}" ]
Create a ListRepository for given EntityName and find Entities for list. @param string $entityName @param array $where @param array $joinConditions @return array
[ "Create", "a", "ListRepository", "for", "given", "EntityName", "and", "find", "Entities", "for", "list", "." ]
6766a36cc2f0c807c59202bf7540a08c4ef31192
https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Rest/Listing/ListRestHelper.php#L82-L85
train