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
silverstripe/vendor-plugin
src/Library.php
Library.getName
public function getName() { if ($this->name) { return $this->name; } // Get from composer $json = $this->getJson(); if (isset($json['name'])) { $this->name = $json['name']; } return $this->name; }
php
public function getName() { if ($this->name) { return $this->name; } // Get from composer $json = $this->getJson(); if (isset($json['name'])) { $this->name = $json['name']; } return $this->name; }
[ "public", "function", "getName", "(", ")", "{", "if", "(", "$", "this", "->", "name", ")", "{", "return", "$", "this", "->", "name", ";", "}", "// Get from composer", "$", "json", "=", "$", "this", "->", "getJson", "(", ")", ";", "if", "(", "isset"...
Get module name @return string
[ "Get", "module", "name" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Library.php#L66-L77
train
silverstripe/vendor-plugin
src/Library.php
Library.getBasePublicPath
public function getBasePublicPath() { $projectPath = $this->getBasePath(); $publicPath = $this->publicPathExists() ? Util::joinPaths($projectPath, self::PUBLIC_PATH, self::RESOURCES_PATH) : Util::joinPaths($projectPath, self::RESOURCES_PATH); return $publicPath; }
php
public function getBasePublicPath() { $projectPath = $this->getBasePath(); $publicPath = $this->publicPathExists() ? Util::joinPaths($projectPath, self::PUBLIC_PATH, self::RESOURCES_PATH) : Util::joinPaths($projectPath, self::RESOURCES_PATH); return $publicPath; }
[ "public", "function", "getBasePublicPath", "(", ")", "{", "$", "projectPath", "=", "$", "this", "->", "getBasePath", "(", ")", ";", "$", "publicPath", "=", "$", "this", "->", "publicPathExists", "(", ")", "?", "Util", "::", "joinPaths", "(", "$", "projec...
Get base path to expose all libraries to @return string Path with no trailing slash E.g. /var/www/public/resources
[ "Get", "base", "path", "to", "expose", "all", "libraries", "to" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Library.php#L109-L116
train
silverstripe/vendor-plugin
src/Library.php
Library.getPublicPath
public function getPublicPath() { $relativePath = $this->getRelativePath(); // 4.0 compatibility: If there is no public folder, and this is a vendor path, // remove the leading `vendor` from the destination if (!$this->publicPathExists() && $this->installedIntoVendor()) { $relativePath = substr($relativePath, strlen('vendor/')); } return Util::joinPaths($this->getBasePublicPath(), $relativePath); }
php
public function getPublicPath() { $relativePath = $this->getRelativePath(); // 4.0 compatibility: If there is no public folder, and this is a vendor path, // remove the leading `vendor` from the destination if (!$this->publicPathExists() && $this->installedIntoVendor()) { $relativePath = substr($relativePath, strlen('vendor/')); } return Util::joinPaths($this->getBasePublicPath(), $relativePath); }
[ "public", "function", "getPublicPath", "(", ")", "{", "$", "relativePath", "=", "$", "this", "->", "getRelativePath", "(", ")", ";", "// 4.0 compatibility: If there is no public folder, and this is a vendor path,", "// remove the leading `vendor` from the destination", "if", "(...
Get base path to map resources for this module @return string Path with trimmed slashes. E.g. /var/www/public/resources/vendor/silverstripe/module
[ "Get", "base", "path", "to", "map", "resources", "for", "this", "module" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Library.php#L145-L156
train
silverstripe/vendor-plugin
src/Library.php
Library.getJson
protected function getJson() { if ($this->json) { return $this->json; } $composer = Util::joinPaths($this->getPath(), 'composer.json'); $file = new JsonFile($composer); $this->json = $file->read(); return $this->json; }
php
protected function getJson() { if ($this->json) { return $this->json; } $composer = Util::joinPaths($this->getPath(), 'composer.json'); $file = new JsonFile($composer); $this->json = $file->read(); return $this->json; }
[ "protected", "function", "getJson", "(", ")", "{", "if", "(", "$", "this", "->", "json", ")", "{", "return", "$", "this", "->", "json", ";", "}", "$", "composer", "=", "Util", "::", "joinPaths", "(", "$", "this", "->", "getPath", "(", ")", ",", "...
Get json content for this module from composer.json @return array
[ "Get", "json", "content", "for", "this", "module", "from", "composer", ".", "json" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Library.php#L170-L179
train
silverstripe/vendor-plugin
src/Library.php
Library.exposePaths
public function exposePaths(ExposeMethod $method) { // No-op if exposure not necessary for this configuration if (!$this->requiresExpose()) { return; } $folders = $this->getExposedFolders(); $sourcePath = $this->getPath(); $targetPath = $this->getPublicPath(); foreach ($folders as $folder) { // Get paths for this folder and delegate to expose method $folderSourcePath = Util::joinPaths($sourcePath, $folder); $folderTargetPath = Util::joinPaths($targetPath, $folder); $method->exposeDirectory($folderSourcePath, $folderTargetPath); } }
php
public function exposePaths(ExposeMethod $method) { // No-op if exposure not necessary for this configuration if (!$this->requiresExpose()) { return; } $folders = $this->getExposedFolders(); $sourcePath = $this->getPath(); $targetPath = $this->getPublicPath(); foreach ($folders as $folder) { // Get paths for this folder and delegate to expose method $folderSourcePath = Util::joinPaths($sourcePath, $folder); $folderTargetPath = Util::joinPaths($targetPath, $folder); $method->exposeDirectory($folderSourcePath, $folderTargetPath); } }
[ "public", "function", "exposePaths", "(", "ExposeMethod", "$", "method", ")", "{", "// No-op if exposure not necessary for this configuration", "if", "(", "!", "$", "this", "->", "requiresExpose", "(", ")", ")", "{", "return", ";", "}", "$", "folders", "=", "$",...
Expose all web accessible paths for this module @param ExposeMethod $method
[ "Expose", "all", "web", "accessible", "paths", "for", "this", "module" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Library.php#L203-L218
train
silverstripe/vendor-plugin
src/Library.php
Library.validateFolder
protected function validateFolder($exposeFolder) { if (strstr($exposeFolder, '.')) { return false; } if (strpos($exposeFolder, '/') === 0) { return false; } if (strpos($exposeFolder, '\\') === 0) { return false; } return true; }
php
protected function validateFolder($exposeFolder) { if (strstr($exposeFolder, '.')) { return false; } if (strpos($exposeFolder, '/') === 0) { return false; } if (strpos($exposeFolder, '\\') === 0) { return false; } return true; }
[ "protected", "function", "validateFolder", "(", "$", "exposeFolder", ")", "{", "if", "(", "strstr", "(", "$", "exposeFolder", ",", "'.'", ")", ")", "{", "return", "false", ";", "}", "if", "(", "strpos", "(", "$", "exposeFolder", ",", "'/'", ")", "===",...
Validate the given folder is allowed @param string $exposeFolder Relative folder name to check @return bool
[ "Validate", "the", "given", "folder", "is", "allowed" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Library.php#L250-L262
train
silverstripe/vendor-plugin
src/Console/VendorExposeCommand.php
VendorExposeCommand.getAllLibraries
protected function getAllLibraries() { $modules = []; $basePath = $this->getProjectPath(); // Get all modules foreach ($this->getModulePaths() as $modulePath) { // Filter by non-composer folders $composerPath = Util::joinPaths($modulePath, 'composer.json'); if (!file_exists($composerPath)) { continue; } // Ensure this library should be exposed, and has at least one folder $module = new Library($basePath, $modulePath); if (!$module->requiresExpose() || !$module->getExposedFolders()) { continue; } // Save this module $modules[] = $module; } return $modules; }
php
protected function getAllLibraries() { $modules = []; $basePath = $this->getProjectPath(); // Get all modules foreach ($this->getModulePaths() as $modulePath) { // Filter by non-composer folders $composerPath = Util::joinPaths($modulePath, 'composer.json'); if (!file_exists($composerPath)) { continue; } // Ensure this library should be exposed, and has at least one folder $module = new Library($basePath, $modulePath); if (!$module->requiresExpose() || !$module->getExposedFolders()) { continue; } // Save this module $modules[] = $module; } return $modules; }
[ "protected", "function", "getAllLibraries", "(", ")", "{", "$", "modules", "=", "[", "]", ";", "$", "basePath", "=", "$", "this", "->", "getProjectPath", "(", ")", ";", "// Get all modules", "foreach", "(", "$", "this", "->", "getModulePaths", "(", ")", ...
Get all libraries @return Library[]
[ "Get", "all", "libraries" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Console/VendorExposeCommand.php#L63-L86
train
silverstripe/vendor-plugin
src/Console/VendorExposeCommand.php
VendorExposeCommand.isPathModule
protected function isPathModule($path) { return file_exists(Util::joinPaths($path, '_config')) || file_exists(Util::joinPaths($path, '_config.php')); }
php
protected function isPathModule($path) { return file_exists(Util::joinPaths($path, '_config')) || file_exists(Util::joinPaths($path, '_config.php')); }
[ "protected", "function", "isPathModule", "(", "$", "path", ")", "{", "return", "file_exists", "(", "Util", "::", "joinPaths", "(", "$", "path", ",", "'_config'", ")", ")", "||", "file_exists", "(", "Util", "::", "joinPaths", "(", "$", "path", ",", "'_con...
Check if the given path is a silverstripe module @param string $path @return bool
[ "Check", "if", "the", "given", "path", "is", "a", "silverstripe", "module" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Console/VendorExposeCommand.php#L145-L149
train
silverstripe/vendor-plugin
src/VendorExposeTask.php
VendorExposeTask.process
public function process(IOInterface $io, array $libraries, $methodKey = null) { // No-op if (empty($libraries)) { return; } // Setup root folder $this->setupResources($io); // Get or choose method if (!$methodKey) { $methodKey = $this->getMethodKey(); } $method = $this->getMethod($methodKey); // Update all modules foreach ($libraries as $module) { // Skip this module if no exposure required if (!$module->requiresExpose()) { continue; } $name = $module->getName(); $type = $module->getType(); $io->write( "Exposing web directories for {$type} <info>{$name}</info> with method <info>{$methodKey}</info>:" ); foreach ($module->getExposedFolders() as $folder) { $io->write(" - <info>$folder</info>"); } // Expose web dirs with given method $module->exposePaths($method); } // On success, write `.method` token to persist for subsequent updates $this->saveMethodKey($methodKey); }
php
public function process(IOInterface $io, array $libraries, $methodKey = null) { // No-op if (empty($libraries)) { return; } // Setup root folder $this->setupResources($io); // Get or choose method if (!$methodKey) { $methodKey = $this->getMethodKey(); } $method = $this->getMethod($methodKey); // Update all modules foreach ($libraries as $module) { // Skip this module if no exposure required if (!$module->requiresExpose()) { continue; } $name = $module->getName(); $type = $module->getType(); $io->write( "Exposing web directories for {$type} <info>{$name}</info> with method <info>{$methodKey}</info>:" ); foreach ($module->getExposedFolders() as $folder) { $io->write(" - <info>$folder</info>"); } // Expose web dirs with given method $module->exposePaths($method); } // On success, write `.method` token to persist for subsequent updates $this->saveMethodKey($methodKey); }
[ "public", "function", "process", "(", "IOInterface", "$", "io", ",", "array", "$", "libraries", ",", "$", "methodKey", "=", "null", ")", "{", "// No-op", "if", "(", "empty", "(", "$", "libraries", ")", ")", "{", "return", ";", "}", "// Setup root folder"...
Expose all modules with the given method @param IOInterface $io @param Library[] $libraries @param string $methodKey Method key, or null to auto-detect from environment
[ "Expose", "all", "modules", "with", "the", "given", "method" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorExposeTask.php#L62-L99
train
silverstripe/vendor-plugin
src/VendorExposeTask.php
VendorExposeTask.setupResources
protected function setupResources(IOInterface $io) { // Setup root dir $resourcesPath = $this->getResourcesPath(); $this->filesystem->ensureDirectoryExists($resourcesPath); // Copy missing resources $files = new DirectoryIterator(__DIR__.'/../resources'); foreach ($files as $file) { $targetPath = $resourcesPath . DIRECTORY_SEPARATOR . $file->getFilename(); if ($file->isFile() && !file_exists($targetPath)) { $name = $file->getFilename(); $io->write("Writing <info>{$name}</info> to resources folder"); copy($file->getPathname(), $targetPath); } } }
php
protected function setupResources(IOInterface $io) { // Setup root dir $resourcesPath = $this->getResourcesPath(); $this->filesystem->ensureDirectoryExists($resourcesPath); // Copy missing resources $files = new DirectoryIterator(__DIR__.'/../resources'); foreach ($files as $file) { $targetPath = $resourcesPath . DIRECTORY_SEPARATOR . $file->getFilename(); if ($file->isFile() && !file_exists($targetPath)) { $name = $file->getFilename(); $io->write("Writing <info>{$name}</info> to resources folder"); copy($file->getPathname(), $targetPath); } } }
[ "protected", "function", "setupResources", "(", "IOInterface", "$", "io", ")", "{", "// Setup root dir", "$", "resourcesPath", "=", "$", "this", "->", "getResourcesPath", "(", ")", ";", "$", "this", "->", "filesystem", "->", "ensureDirectoryExists", "(", "$", ...
Ensure the resources folder is safely created and protected from index.php in root @param IOInterface $io
[ "Ensure", "the", "resources", "folder", "is", "safely", "created", "and", "protected", "from", "index", ".", "php", "in", "root" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorExposeTask.php#L107-L123
train
silverstripe/vendor-plugin
src/VendorExposeTask.php
VendorExposeTask.getMethod
protected function getMethod($key) { switch ($key) { case CopyMethod::NAME: return new CopyMethod(); case SymlinkMethod::NAME: return new SymlinkMethod(); case JunctionMethod::NAME: return new JunctionMethod(); case VendorPlugin::METHOD_NONE: // 'none' is forced to an empty chain return new ChainedMethod([]); case VendorPlugin::METHOD_AUTO: // Default to safe-failover method if (Platform::isWindows()) { // Use junctions on windows environment return new ChainedMethod(new JunctionMethod(), new CopyMethod()); } else { // Use symlink on non-windows environments return new ChainedMethod(new SymlinkMethod(), new CopyMethod()); } default: throw new InvalidArgumentException("Invalid method: {$key}"); } }
php
protected function getMethod($key) { switch ($key) { case CopyMethod::NAME: return new CopyMethod(); case SymlinkMethod::NAME: return new SymlinkMethod(); case JunctionMethod::NAME: return new JunctionMethod(); case VendorPlugin::METHOD_NONE: // 'none' is forced to an empty chain return new ChainedMethod([]); case VendorPlugin::METHOD_AUTO: // Default to safe-failover method if (Platform::isWindows()) { // Use junctions on windows environment return new ChainedMethod(new JunctionMethod(), new CopyMethod()); } else { // Use symlink on non-windows environments return new ChainedMethod(new SymlinkMethod(), new CopyMethod()); } default: throw new InvalidArgumentException("Invalid method: {$key}"); } }
[ "protected", "function", "getMethod", "(", "$", "key", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "CopyMethod", "::", "NAME", ":", "return", "new", "CopyMethod", "(", ")", ";", "case", "SymlinkMethod", "::", "NAME", ":", "return", "new", "S...
Get named method instance @param string $key Key of method to use @return ExposeMethod
[ "Get", "named", "method", "instance" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorExposeTask.php#L131-L155
train
silverstripe/vendor-plugin
src/VendorExposeTask.php
VendorExposeTask.getMethodKey
protected function getMethodKey() { // Switch if `resources/.method` contains a file $methodFilePath = $this->getMethodFilePath(); if (file_exists($methodFilePath) && is_readable($methodFilePath)) { return trim(file_get_contents($methodFilePath)); } // Switch based on SS_VENDOR_METHOD arg $method = getenv(VendorPlugin::METHOD_ENV); if ($method) { return $method; } // Default method return VendorPlugin::METHOD_DEFAULT; }
php
protected function getMethodKey() { // Switch if `resources/.method` contains a file $methodFilePath = $this->getMethodFilePath(); if (file_exists($methodFilePath) && is_readable($methodFilePath)) { return trim(file_get_contents($methodFilePath)); } // Switch based on SS_VENDOR_METHOD arg $method = getenv(VendorPlugin::METHOD_ENV); if ($method) { return $method; } // Default method return VendorPlugin::METHOD_DEFAULT; }
[ "protected", "function", "getMethodKey", "(", ")", "{", "// Switch if `resources/.method` contains a file", "$", "methodFilePath", "=", "$", "this", "->", "getMethodFilePath", "(", ")", ";", "if", "(", "file_exists", "(", "$", "methodFilePath", ")", "&&", "is_readab...
Get 'key' of method to use @return string
[ "Get", "key", "of", "method", "to", "use" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/VendorExposeTask.php#L162-L178
train
silverstripe/vendor-plugin
src/Methods/ChainedMethod.php
ChainedMethod.exposeDirectory
public function exposeDirectory($source, $target) { $lastException = null; foreach ($this->failovers as $failover) { try { $failover->exposeDirectory($source, $target); return; // Return on first success } catch (RuntimeException $lastException) { } } if ($lastException) { throw $lastException; } }
php
public function exposeDirectory($source, $target) { $lastException = null; foreach ($this->failovers as $failover) { try { $failover->exposeDirectory($source, $target); return; // Return on first success } catch (RuntimeException $lastException) { } } if ($lastException) { throw $lastException; } }
[ "public", "function", "exposeDirectory", "(", "$", "source", ",", "$", "target", ")", "{", "$", "lastException", "=", "null", ";", "foreach", "(", "$", "this", "->", "failovers", "as", "$", "failover", ")", "{", "try", "{", "$", "failover", "->", "expo...
Exposes the directory with the given paths @param string $source Full filesystem path to file source @param string $target Full filesystem path to the target directory @throws RuntimeException If could not be exposed
[ "Exposes", "the", "directory", "with", "the", "given", "paths" ]
87769ad5770921428e74cc7de6ba4f217399b005
https://github.com/silverstripe/vendor-plugin/blob/87769ad5770921428e74cc7de6ba4f217399b005/src/Methods/ChainedMethod.php#L33-L46
train
php-http/mock-client
src/Client.php
Client.on
public function on(RequestMatcher $requestMatcher, $result) { $callable = null; switch (true) { case is_callable($result): $callable = $result; break; case $result instanceof ResponseInterface: $callable = function () use ($result) { return $result; }; break; case $result instanceof \Exception: $callable = function () use ($result) { throw $result; }; break; default: throw new \InvalidArgumentException('Result must be either a response, an exception, or a callable'); } $this->conditionalResults[] = [ 'matcher' => $requestMatcher, 'callable' => $callable, ]; }
php
public function on(RequestMatcher $requestMatcher, $result) { $callable = null; switch (true) { case is_callable($result): $callable = $result; break; case $result instanceof ResponseInterface: $callable = function () use ($result) { return $result; }; break; case $result instanceof \Exception: $callable = function () use ($result) { throw $result; }; break; default: throw new \InvalidArgumentException('Result must be either a response, an exception, or a callable'); } $this->conditionalResults[] = [ 'matcher' => $requestMatcher, 'callable' => $callable, ]; }
[ "public", "function", "on", "(", "RequestMatcher", "$", "requestMatcher", ",", "$", "result", ")", "{", "$", "callable", "=", "null", ";", "switch", "(", "true", ")", "{", "case", "is_callable", "(", "$", "result", ")", ":", "$", "callable", "=", "$", ...
Adds an exception to be thrown or response to be returned if the request matcher matches. For more complex logic, pass a callable as $result. The method is given the request and MUST either return a ResponseInterface or throw an exception that implements the PSR-18 / HTTPlug exception interface. @param ResponseInterface|Exception|ClientExceptionInterface|callable $result
[ "Adds", "an", "exception", "to", "be", "thrown", "or", "response", "to", "be", "returned", "if", "the", "request", "matcher", "matches", "." ]
d364c4a2847229dd37237d0083887889d3bd8564
https://github.com/php-http/mock-client/blob/d364c4a2847229dd37237d0083887889d3bd8564/src/Client.php#L123-L151
train
php-http/mock-client
src/Client.php
Client.addException
public function addException(\Exception $exception) { if (!$exception instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($exception).' will not be possible anymore in the future', E_USER_DEPRECATED); } $this->exceptions[] = $exception; }
php
public function addException(\Exception $exception) { if (!$exception instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($exception).' will not be possible anymore in the future', E_USER_DEPRECATED); } $this->exceptions[] = $exception; }
[ "public", "function", "addException", "(", "\\", "Exception", "$", "exception", ")", "{", "if", "(", "!", "$", "exception", "instanceof", "Exception", ")", "{", "@", "trigger_error", "(", "'Clients may only throw exceptions of type '", ".", "Exception", "::", "cla...
Adds an exception that will be thrown.
[ "Adds", "an", "exception", "that", "will", "be", "thrown", "." ]
d364c4a2847229dd37237d0083887889d3bd8564
https://github.com/php-http/mock-client/blob/d364c4a2847229dd37237d0083887889d3bd8564/src/Client.php#L156-L162
train
php-http/mock-client
src/Client.php
Client.setDefaultException
public function setDefaultException(\Exception $defaultException = null) { if (!$defaultException instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED); } $this->defaultException = $defaultException; }
php
public function setDefaultException(\Exception $defaultException = null) { if (!$defaultException instanceof Exception) { @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED); } $this->defaultException = $defaultException; }
[ "public", "function", "setDefaultException", "(", "\\", "Exception", "$", "defaultException", "=", "null", ")", "{", "if", "(", "!", "$", "defaultException", "instanceof", "Exception", ")", "{", "@", "trigger_error", "(", "'Clients may only throw exceptions of type '"...
Sets the default exception to throw when the list of added exceptions and responses is exhausted. If both a default exception and a default response are set, the exception will be thrown.
[ "Sets", "the", "default", "exception", "to", "throw", "when", "the", "list", "of", "added", "exceptions", "and", "responses", "is", "exhausted", "." ]
d364c4a2847229dd37237d0083887889d3bd8564
https://github.com/php-http/mock-client/blob/d364c4a2847229dd37237d0083887889d3bd8564/src/Client.php#L169-L175
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getConfigurationBuilder
protected function getConfigurationBuilder() { return Builder::create() ->enableTags() ->enableCategories() ->enableLimit() ->enablePagination() ->enablePresentAs() ->setDeepLink('articles/{locale}/edit:{id}/details') ->enableSorting( [ ['column' => 'published', 'title' => 'sulu_article.smart-content.published'], ['column' => 'authored', 'title' => 'sulu_article.smart-content.authored'], ['column' => 'created', 'title' => 'sulu_article.smart-content.created'], ['column' => 'title', 'title' => 'sulu_article.smart-content.title'], ['column' => 'author_full_name', 'title' => 'sulu_article.smart-content.author-full-name'], ] ); }
php
protected function getConfigurationBuilder() { return Builder::create() ->enableTags() ->enableCategories() ->enableLimit() ->enablePagination() ->enablePresentAs() ->setDeepLink('articles/{locale}/edit:{id}/details') ->enableSorting( [ ['column' => 'published', 'title' => 'sulu_article.smart-content.published'], ['column' => 'authored', 'title' => 'sulu_article.smart-content.authored'], ['column' => 'created', 'title' => 'sulu_article.smart-content.created'], ['column' => 'title', 'title' => 'sulu_article.smart-content.title'], ['column' => 'author_full_name', 'title' => 'sulu_article.smart-content.author-full-name'], ] ); }
[ "protected", "function", "getConfigurationBuilder", "(", ")", "{", "return", "Builder", "::", "create", "(", ")", "->", "enableTags", "(", ")", "->", "enableCategories", "(", ")", "->", "enableLimit", "(", ")", "->", "enablePagination", "(", ")", "->", "enab...
Create new configuration-builder. @return BuilderInterface
[ "Create", "new", "configuration", "-", "builder", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L113-L131
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getSearchResult
private function getSearchResult(array $filters, $limit, $page, $pageSize, $locale, $webspaceKey) { $repository = $this->searchManager->getRepository($this->articleDocumentClass); $search = $this->createSearch($repository->createSearch(), $filters, $locale); if (!$search) { return new \ArrayIterator([]); } $this->addPagination($search, $pageSize, $page, $limit); if (array_key_exists('sortBy', $filters) && is_array($filters['sortBy'])) { $sortMethod = array_key_exists('sortMethod', $filters) ? $filters['sortMethod'] : 'asc'; $this->appendSortBy($filters['sortBy'], $sortMethod, $search); } if ($webspaceKey) { $webspaceQuery = new BoolQuery(); // check for mainWebspace $webspaceQuery->add(new TermQuery('main_webspace', $webspaceKey), BoolQuery::SHOULD); // check for additionalWebspaces $webspaceQuery->add(new TermQuery('additional_webspaces', $webspaceKey), BoolQuery::SHOULD); $search->addQuery($webspaceQuery); } return $repository->findDocuments($search); }
php
private function getSearchResult(array $filters, $limit, $page, $pageSize, $locale, $webspaceKey) { $repository = $this->searchManager->getRepository($this->articleDocumentClass); $search = $this->createSearch($repository->createSearch(), $filters, $locale); if (!$search) { return new \ArrayIterator([]); } $this->addPagination($search, $pageSize, $page, $limit); if (array_key_exists('sortBy', $filters) && is_array($filters['sortBy'])) { $sortMethod = array_key_exists('sortMethod', $filters) ? $filters['sortMethod'] : 'asc'; $this->appendSortBy($filters['sortBy'], $sortMethod, $search); } if ($webspaceKey) { $webspaceQuery = new BoolQuery(); // check for mainWebspace $webspaceQuery->add(new TermQuery('main_webspace', $webspaceKey), BoolQuery::SHOULD); // check for additionalWebspaces $webspaceQuery->add(new TermQuery('additional_webspaces', $webspaceKey), BoolQuery::SHOULD); $search->addQuery($webspaceQuery); } return $repository->findDocuments($search); }
[ "private", "function", "getSearchResult", "(", "array", "$", "filters", ",", "$", "limit", ",", "$", "page", ",", "$", "pageSize", ",", "$", "locale", ",", "$", "webspaceKey", ")", "{", "$", "repository", "=", "$", "this", "->", "searchManager", "->", ...
Creates search for filters and returns search-result. @param array $filters @param int $limit @param int $page @param int $pageSize @param string $locale @param null|string $webspaceKey @return \Countable
[ "Creates", "search", "for", "filters", "and", "returns", "search", "-", "result", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L265-L293
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.createSearch
protected function createSearch(Search $search, array $filters, $locale) { if (0 < count($filters['excluded'])) { foreach ($filters['excluded'] as $uuid) { $search->addQuery(new TermQuery('uuid', $uuid), BoolQuery::MUST_NOT); } } $query = new BoolQuery(); $queriesCount = 0; $operator = $this->getFilter($filters, 'tagOperator', 'or'); $this->addBoolQuery('tags', $filters, 'excerpt.tags.id', $operator, $query, $queriesCount); $operator = $this->getFilter($filters, 'websiteTagsOperator', 'or'); $this->addBoolQuery('websiteTags', $filters, 'excerpt.tags.id', $operator, $query, $queriesCount); $operator = $this->getFilter($filters, 'categoryOperator', 'or'); $this->addBoolQuery('categories', $filters, 'excerpt.categories.id', $operator, $query, $queriesCount); $operator = $this->getFilter($filters, 'websiteCategoriesOperator', 'or'); $this->addBoolQuery('websiteCategories', $filters, 'excerpt.categories.id', $operator, $query, $queriesCount); if (null !== $locale) { $search->addQuery(new TermQuery('locale', $locale)); } if (array_key_exists('types', $filters) && $filters['types']) { $typesQuery = new BoolQuery(); foreach ($filters['types'] as $typeFilter) { $typesQuery->add(new TermQuery('type', $typeFilter), BoolQuery::SHOULD); } $search->addQuery($typesQuery); } if (array_key_exists('structureTypes', $filters) && $filters['structureTypes']) { $strTypesQuery = new BoolQuery(); foreach ($filters['structureTypes'] as $filter) { $strTypesQuery->add(new TermQuery('structure_type', $filter), BoolQuery::SHOULD); } $search->addQuery($strTypesQuery); } if (0 === $queriesCount) { $search->addQuery(new MatchAllQuery(), BoolQuery::MUST); } else { $search->addQuery($query, BoolQuery::MUST); } return $search; }
php
protected function createSearch(Search $search, array $filters, $locale) { if (0 < count($filters['excluded'])) { foreach ($filters['excluded'] as $uuid) { $search->addQuery(new TermQuery('uuid', $uuid), BoolQuery::MUST_NOT); } } $query = new BoolQuery(); $queriesCount = 0; $operator = $this->getFilter($filters, 'tagOperator', 'or'); $this->addBoolQuery('tags', $filters, 'excerpt.tags.id', $operator, $query, $queriesCount); $operator = $this->getFilter($filters, 'websiteTagsOperator', 'or'); $this->addBoolQuery('websiteTags', $filters, 'excerpt.tags.id', $operator, $query, $queriesCount); $operator = $this->getFilter($filters, 'categoryOperator', 'or'); $this->addBoolQuery('categories', $filters, 'excerpt.categories.id', $operator, $query, $queriesCount); $operator = $this->getFilter($filters, 'websiteCategoriesOperator', 'or'); $this->addBoolQuery('websiteCategories', $filters, 'excerpt.categories.id', $operator, $query, $queriesCount); if (null !== $locale) { $search->addQuery(new TermQuery('locale', $locale)); } if (array_key_exists('types', $filters) && $filters['types']) { $typesQuery = new BoolQuery(); foreach ($filters['types'] as $typeFilter) { $typesQuery->add(new TermQuery('type', $typeFilter), BoolQuery::SHOULD); } $search->addQuery($typesQuery); } if (array_key_exists('structureTypes', $filters) && $filters['structureTypes']) { $strTypesQuery = new BoolQuery(); foreach ($filters['structureTypes'] as $filter) { $strTypesQuery->add(new TermQuery('structure_type', $filter), BoolQuery::SHOULD); } $search->addQuery($strTypesQuery); } if (0 === $queriesCount) { $search->addQuery(new MatchAllQuery(), BoolQuery::MUST); } else { $search->addQuery($query, BoolQuery::MUST); } return $search; }
[ "protected", "function", "createSearch", "(", "Search", "$", "search", ",", "array", "$", "filters", ",", "$", "locale", ")", "{", "if", "(", "0", "<", "count", "(", "$", "filters", "[", "'excluded'", "]", ")", ")", "{", "foreach", "(", "$", "filters...
Initialize search with neccesary queries. @param Search $search @param array $filters @param string $locale @return Search
[ "Initialize", "search", "with", "neccesary", "queries", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L304-L352
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getTypesProperty
private function getTypesProperty($propertyParameter) { $filterTypes = []; if (array_key_exists('types', $propertyParameter) && null !== ($types = explode(',', $propertyParameter['types']->getValue())) ) { foreach ($types as $type) { $filterTypes[] = $type; } } return $filterTypes; }
php
private function getTypesProperty($propertyParameter) { $filterTypes = []; if (array_key_exists('types', $propertyParameter) && null !== ($types = explode(',', $propertyParameter['types']->getValue())) ) { foreach ($types as $type) { $filterTypes[] = $type; } } return $filterTypes; }
[ "private", "function", "getTypesProperty", "(", "$", "propertyParameter", ")", "{", "$", "filterTypes", "=", "[", "]", ";", "if", "(", "array_key_exists", "(", "'types'", ",", "$", "propertyParameter", ")", "&&", "null", "!==", "(", "$", "types", "=", "exp...
Returns array with all types defined in property parameter. @param array $propertyParameter @return array
[ "Returns", "array", "with", "all", "types", "defined", "in", "property", "parameter", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L361-L374
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getExcludedFilter
private function getExcludedFilter(array $filters, array $propertyParameter) { $excluded = array_key_exists('excluded', $filters) ? $filters['excluded'] : []; if (array_key_exists('exclude_duplicates', $propertyParameter) && $propertyParameter['exclude_duplicates']->getValue() ) { $excluded = array_merge($excluded, $this->referenceStore->getAll()); } return $excluded; }
php
private function getExcludedFilter(array $filters, array $propertyParameter) { $excluded = array_key_exists('excluded', $filters) ? $filters['excluded'] : []; if (array_key_exists('exclude_duplicates', $propertyParameter) && $propertyParameter['exclude_duplicates']->getValue() ) { $excluded = array_merge($excluded, $this->referenceStore->getAll()); } return $excluded; }
[ "private", "function", "getExcludedFilter", "(", "array", "$", "filters", ",", "array", "$", "propertyParameter", ")", "{", "$", "excluded", "=", "array_key_exists", "(", "'excluded'", ",", "$", "filters", ")", "?", "$", "filters", "[", "'excluded'", "]", ":...
Returns excluded articles. @param array $filters @param PropertyParameter[] $propertyParameter @return array
[ "Returns", "excluded", "articles", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L406-L416
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.addPagination
private function addPagination(Search $search, $pageSize, $page, $limit) { $offset = 0; if ($pageSize) { $pageSize = intval($pageSize); $offset = ($page - 1) * $pageSize; } if (null === $limit) { $limit = $this->defaultLimit; } if (null === $pageSize || $offset + $pageSize > $limit) { $pageSize = $limit - $offset; if ($pageSize < 0) { $pageSize = 0; } } $search->setFrom($offset); $search->setSize($pageSize); }
php
private function addPagination(Search $search, $pageSize, $page, $limit) { $offset = 0; if ($pageSize) { $pageSize = intval($pageSize); $offset = ($page - 1) * $pageSize; } if (null === $limit) { $limit = $this->defaultLimit; } if (null === $pageSize || $offset + $pageSize > $limit) { $pageSize = $limit - $offset; if ($pageSize < 0) { $pageSize = 0; } } $search->setFrom($offset); $search->setSize($pageSize); }
[ "private", "function", "addPagination", "(", "Search", "$", "search", ",", "$", "pageSize", ",", "$", "page", ",", "$", "limit", ")", "{", "$", "offset", "=", "0", ";", "if", "(", "$", "pageSize", ")", "{", "$", "pageSize", "=", "intval", "(", "$",...
Add the pagination to given query. @param Search $search @param int $pageSize @param int $page @param int $limit
[ "Add", "the", "pagination", "to", "given", "query", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L442-L464
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.addBoolQuery
private function addBoolQuery($filterName, array $filters, $field, $operator, BoolQuery $query, &$queriesCount) { if (0 !== count($tags = $this->getFilter($filters, $filterName, []))) { ++$queriesCount; $query->add($this->getBoolQuery($field, $tags, $operator)); } }
php
private function addBoolQuery($filterName, array $filters, $field, $operator, BoolQuery $query, &$queriesCount) { if (0 !== count($tags = $this->getFilter($filters, $filterName, []))) { ++$queriesCount; $query->add($this->getBoolQuery($field, $tags, $operator)); } }
[ "private", "function", "addBoolQuery", "(", "$", "filterName", ",", "array", "$", "filters", ",", "$", "field", ",", "$", "operator", ",", "BoolQuery", "$", "query", ",", "&", "$", "queriesCount", ")", "{", "if", "(", "0", "!==", "count", "(", "$", "...
Add a boolean-query if filter exists. @param string $filterName @param array $filters @param string $field @param string $operator @param BoolQuery $query @param int $queriesCount
[ "Add", "a", "boolean", "-", "query", "if", "filter", "exists", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L476-L482
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getBoolQuery
private function getBoolQuery($field, array $values, $operator) { $type = ('or' === strtolower($operator) ? BoolQuery::SHOULD : BoolQuery::MUST); $query = new BoolQuery(); foreach ($values as $value) { $query->add(new TermQuery($field, $value), $type); } return $query; }
php
private function getBoolQuery($field, array $values, $operator) { $type = ('or' === strtolower($operator) ? BoolQuery::SHOULD : BoolQuery::MUST); $query = new BoolQuery(); foreach ($values as $value) { $query->add(new TermQuery($field, $value), $type); } return $query; }
[ "private", "function", "getBoolQuery", "(", "$", "field", ",", "array", "$", "values", ",", "$", "operator", ")", "{", "$", "type", "=", "(", "'or'", "===", "strtolower", "(", "$", "operator", ")", "?", "BoolQuery", "::", "SHOULD", ":", "BoolQuery", ":...
Returns boolean query for given fields and values. @param string $field @param array $values @param string $operator @return BoolQuery
[ "Returns", "boolean", "query", "for", "given", "fields", "and", "values", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L493-L503
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getFilter
private function getFilter(array $filters, $name, $default = null) { if ($this->hasFilter($filters, $name)) { return $filters[$name]; } return $default; }
php
private function getFilter(array $filters, $name, $default = null) { if ($this->hasFilter($filters, $name)) { return $filters[$name]; } return $default; }
[ "private", "function", "getFilter", "(", "array", "$", "filters", ",", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasFilter", "(", "$", "filters", ",", "$", "name", ")", ")", "{", "return", "$", "filters...
Returns filter value. @param array $filters @param string $name @param mixed $default @return mixed
[ "Returns", "filter", "value", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L514-L521
train
sulu/SuluArticleBundle
Content/ArticleDataProvider.php
ArticleDataProvider.getResource
private function getResource($uuid, $locale) { return $this->proxyFactory->createProxy( ArticleDocument::class, function ( &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer ) use ($uuid, $locale) { $initializer = null; $wrappedObject = $this->documentManager->find($uuid, $locale); return true; } ); }
php
private function getResource($uuid, $locale) { return $this->proxyFactory->createProxy( ArticleDocument::class, function ( &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer ) use ($uuid, $locale) { $initializer = null; $wrappedObject = $this->documentManager->find($uuid, $locale); return true; } ); }
[ "private", "function", "getResource", "(", "$", "uuid", ",", "$", "locale", ")", "{", "return", "$", "this", "->", "proxyFactory", "->", "createProxy", "(", "ArticleDocument", "::", "class", ",", "function", "(", "&", "$", "wrappedObject", ",", "LazyLoadingI...
Returns Proxy document for uuid. @param string $uuid @param string $locale @return object
[ "Returns", "Proxy", "document", "for", "uuid", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleDataProvider.php#L544-L561
train
sulu/SuluArticleBundle
Content/ArticleResourceItemFactory.php
ArticleResourceItemFactory.createResourceItem
public function createResourceItem(ArticleViewDocumentInterface $articleViewDocument) { return new ArticleResourceItem( $articleViewDocument, $this->getResource($articleViewDocument->getUuid(), $articleViewDocument->getLocale()) ); }
php
public function createResourceItem(ArticleViewDocumentInterface $articleViewDocument) { return new ArticleResourceItem( $articleViewDocument, $this->getResource($articleViewDocument->getUuid(), $articleViewDocument->getLocale()) ); }
[ "public", "function", "createResourceItem", "(", "ArticleViewDocumentInterface", "$", "articleViewDocument", ")", "{", "return", "new", "ArticleResourceItem", "(", "$", "articleViewDocument", ",", "$", "this", "->", "getResource", "(", "$", "articleViewDocument", "->", ...
Creates and returns article source item with proxy document. @param ArticleViewDocumentInterface $articleViewDocument @return ArticleResourceItem
[ "Creates", "and", "returns", "article", "source", "item", "with", "proxy", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/ArticleResourceItemFactory.php#L54-L60
train
sulu/SuluArticleBundle
Document/Repository/ArticleViewDocumentRepository.php
ArticleViewDocumentRepository.findRecent
public function findRecent( $excludeUuid = null, $limit = self::DEFAULT_LIMIT, array $types = null, $locale = null, $webspaceKey = null ) { $search = $this->createSearch($limit, $types, $locale, $webspaceKey); if ($excludeUuid) { $search->addQuery(new TermQuery('uuid', $excludeUuid), BoolQuery::MUST_NOT); } $search->addSort(new FieldSort('authored', FieldSort::DESC)); return $this->repository->findDocuments($search); }
php
public function findRecent( $excludeUuid = null, $limit = self::DEFAULT_LIMIT, array $types = null, $locale = null, $webspaceKey = null ) { $search = $this->createSearch($limit, $types, $locale, $webspaceKey); if ($excludeUuid) { $search->addQuery(new TermQuery('uuid', $excludeUuid), BoolQuery::MUST_NOT); } $search->addSort(new FieldSort('authored', FieldSort::DESC)); return $this->repository->findDocuments($search); }
[ "public", "function", "findRecent", "(", "$", "excludeUuid", "=", "null", ",", "$", "limit", "=", "self", "::", "DEFAULT_LIMIT", ",", "array", "$", "types", "=", "null", ",", "$", "locale", "=", "null", ",", "$", "webspaceKey", "=", "null", ")", "{", ...
Finds recent articles for given parameters sorted by field `authored`. @param null|string $excludeUuid @param int $limit @param null|array $types @param null|string $locale @param null|string $webspaceKey @return DocumentIterator
[ "Finds", "recent", "articles", "for", "given", "parameters", "sorted", "by", "field", "authored", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Repository/ArticleViewDocumentRepository.php#L86-L102
train
sulu/SuluArticleBundle
Document/Repository/ArticleViewDocumentRepository.php
ArticleViewDocumentRepository.findSimilar
public function findSimilar( $uuid, $limit = self::DEFAULT_LIMIT, array $types = null, $locale = null, $webspaceKey = null ) { $search = $this->createSearch($limit, $types, $locale, $webspaceKey); $search->addQuery( new MoreLikeThisQuery( null, [ 'fields' => $this->searchFields, 'min_term_freq' => 1, 'min_doc_freq' => 2, 'like' => [ [ '_id' => $this->getViewDocumentId($uuid, $locale), ], ], ] ) ); return $this->repository->findDocuments($search); }
php
public function findSimilar( $uuid, $limit = self::DEFAULT_LIMIT, array $types = null, $locale = null, $webspaceKey = null ) { $search = $this->createSearch($limit, $types, $locale, $webspaceKey); $search->addQuery( new MoreLikeThisQuery( null, [ 'fields' => $this->searchFields, 'min_term_freq' => 1, 'min_doc_freq' => 2, 'like' => [ [ '_id' => $this->getViewDocumentId($uuid, $locale), ], ], ] ) ); return $this->repository->findDocuments($search); }
[ "public", "function", "findSimilar", "(", "$", "uuid", ",", "$", "limit", "=", "self", "::", "DEFAULT_LIMIT", ",", "array", "$", "types", "=", "null", ",", "$", "locale", "=", "null", ",", "$", "webspaceKey", "=", "null", ")", "{", "$", "search", "="...
Finds similar articles for given `uuid` with given parameters. @param string $uuid @param int $limit @param null|array $types @param null|string $locale @param null|string $webspaceKey @return DocumentIterator
[ "Finds", "similar", "articles", "for", "given", "uuid", "with", "given", "parameters", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Repository/ArticleViewDocumentRepository.php#L115-L141
train
sulu/SuluArticleBundle
DependencyInjection/SuluArticleExtension.php
SuluArticleExtension.appendDefaultAuthor
private function appendDefaultAuthor(array $config, ContainerBuilder $container) { $mapping = $container->getParameter('sulu_document_manager.mapping'); foreach ($mapping as $key => $item) { if ('article' === $item['alias']) { $mapping[$key]['set_default_author'] = $config['default_author']; } } $container->setParameter('sulu_document_manager.mapping', $mapping); $container->setParameter('sulu_article.default_author', $config['default_author']); }
php
private function appendDefaultAuthor(array $config, ContainerBuilder $container) { $mapping = $container->getParameter('sulu_document_manager.mapping'); foreach ($mapping as $key => $item) { if ('article' === $item['alias']) { $mapping[$key]['set_default_author'] = $config['default_author']; } } $container->setParameter('sulu_document_manager.mapping', $mapping); $container->setParameter('sulu_article.default_author', $config['default_author']); }
[ "private", "function", "appendDefaultAuthor", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "mapping", "=", "$", "container", "->", "getParameter", "(", "'sulu_document_manager.mapping'", ")", ";", "foreach", "(", "$", "m...
Append configuration for article "set_default_author". @param array $config @param ContainerBuilder $container
[ "Append", "configuration", "for", "article", "set_default_author", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/DependencyInjection/SuluArticleExtension.php#L222-L233
train
sulu/SuluArticleBundle
DependencyInjection/SuluArticleExtension.php
SuluArticleExtension.cloneArticleConfig
private function cloneArticleConfig(array $config, $type) { $result = []; foreach ($config as $item) { $result[] = ['path' => $item['path'], 'type' => $type]; } return $result; }
php
private function cloneArticleConfig(array $config, $type) { $result = []; foreach ($config as $item) { $result[] = ['path' => $item['path'], 'type' => $type]; } return $result; }
[ "private", "function", "cloneArticleConfig", "(", "array", "$", "config", ",", "$", "type", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "item", ")", "{", "$", "result", "[", "]", "=", "[", "'path'", "=>", ...
Clone given path configuration and use given type. @param array $config @param string $type @return array
[ "Clone", "given", "path", "configuration", "and", "use", "given", "type", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/DependencyInjection/SuluArticleExtension.php#L259-L267
train
sulu/SuluArticleBundle
Document/Serializer/ArticleSubscriber.php
ArticleSubscriber.addTypeOnPostSerialize
public function addTypeOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!($article instanceof ArticleDocument)) { return; } $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $visitor->addData('articleType', $context->accept($this->getType($structure->getStructure()))); }
php
public function addTypeOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!($article instanceof ArticleDocument)) { return; } $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $visitor->addData('articleType', $context->accept($this->getType($structure->getStructure()))); }
[ "public", "function", "addTypeOnPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "article", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "context", "=", ...
Append type to result. @param ObjectEvent $event
[ "Append", "type", "to", "result", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleSubscriber.php#L87-L99
train
sulu/SuluArticleBundle
Document/Serializer/ArticleSubscriber.php
ArticleSubscriber.addBrokenIndicatorOnPostSerialize
public function addBrokenIndicatorOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); if (!($article instanceof ArticleViewDocumentInterface)) { return; } $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $visitor->addData('broken', !$structure || $structure->getKey() !== $article->getStructureType()); $visitor->addData('originalStructureType', $article->getStructureType()); }
php
public function addBrokenIndicatorOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); if (!($article instanceof ArticleViewDocumentInterface)) { return; } $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $visitor->addData('broken', !$structure || $structure->getKey() !== $article->getStructureType()); $visitor->addData('originalStructureType', $article->getStructureType()); }
[ "public", "function", "addBrokenIndicatorOnPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "article", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "if", "(", "...
Append broken-indicator to result. @param ObjectEvent $event
[ "Append", "broken", "-", "indicator", "to", "result", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleSubscriber.php#L106-L118
train
sulu/SuluArticleBundle
Document/Serializer/ArticleSubscriber.php
ArticleSubscriber.addPageTitlePropertyNameOnPostSerialize
public function addPageTitlePropertyNameOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!$article instanceof ArticleInterface) { return; } $property = $this->getPageTitleProperty($article); if ($property) { $visitor->addData('_pageTitlePropertyName', $context->accept($property->getName())); } }
php
public function addPageTitlePropertyNameOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!$article instanceof ArticleInterface) { return; } $property = $this->getPageTitleProperty($article); if ($property) { $visitor->addData('_pageTitlePropertyName', $context->accept($property->getName())); } }
[ "public", "function", "addPageTitlePropertyNameOnPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "article", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "co...
Append page-title-property to result. @param ObjectEvent $event
[ "Append", "page", "-", "title", "-", "property", "to", "result", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleSubscriber.php#L125-L139
train
sulu/SuluArticleBundle
Document/Serializer/ArticleSubscriber.php
ArticleSubscriber.getPageTitleProperty
private function getPageTitleProperty(ArticleInterface $document) { $metadata = $this->structureMetadataFactory->getStructureMetadata( 'article', $document->getStructureType() ); if ($metadata->hasPropertyWithTagName(self::PAGE_TITLE_TAG_NAME)) { return $metadata->getPropertyByTagName(self::PAGE_TITLE_TAG_NAME); } if ($metadata->hasProperty(self::PAGE_TITLE_PROPERTY_NAME)) { return $metadata->getProperty(self::PAGE_TITLE_PROPERTY_NAME); } return null; }
php
private function getPageTitleProperty(ArticleInterface $document) { $metadata = $this->structureMetadataFactory->getStructureMetadata( 'article', $document->getStructureType() ); if ($metadata->hasPropertyWithTagName(self::PAGE_TITLE_TAG_NAME)) { return $metadata->getPropertyByTagName(self::PAGE_TITLE_TAG_NAME); } if ($metadata->hasProperty(self::PAGE_TITLE_PROPERTY_NAME)) { return $metadata->getProperty(self::PAGE_TITLE_PROPERTY_NAME); } return null; }
[ "private", "function", "getPageTitleProperty", "(", "ArticleInterface", "$", "document", ")", "{", "$", "metadata", "=", "$", "this", "->", "structureMetadataFactory", "->", "getStructureMetadata", "(", "'article'", ",", "$", "document", "->", "getStructureType", "(...
Find page-title property. @param ArticleInterface $document @return PropertyMetadata
[ "Find", "page", "-", "title", "property", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleSubscriber.php#L148-L164
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.handleHydrate
public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutablePageBehavior) { return; } $locale = $document->getLocale(); if (LocalizationState::SHADOW === $this->documentInspector->getLocalizationState($document)) { $locale = $document->getOriginalLocale(); } $propertyName = $this->getRoutePathPropertyName($document->getStructureType(), $locale); $routePath = $event->getNode()->getPropertyValueWithDefault($propertyName, null); $document->setRoutePath($routePath); $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale); if ($route) { $document->setRoute($route); } }
php
public function handleHydrate(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutablePageBehavior) { return; } $locale = $document->getLocale(); if (LocalizationState::SHADOW === $this->documentInspector->getLocalizationState($document)) { $locale = $document->getOriginalLocale(); } $propertyName = $this->getRoutePathPropertyName($document->getStructureType(), $locale); $routePath = $event->getNode()->getPropertyValueWithDefault($propertyName, null); $document->setRoutePath($routePath); $route = $this->routeRepository->findByEntity($document->getClass(), $document->getUuid(), $locale); if ($route) { $document->setRoute($route); } }
[ "public", "function", "handleHydrate", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "RoutablePageBehavior", ")", "{", "return", ";"...
Load route. @param AbstractMappingEvent $event
[ "Load", "route", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L156-L176
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.handlePersist
public function handlePersist(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutablePageBehavior) { return; } $document->setUuid($event->getNode()->getIdentifier()); $propertyName = $this->getRoutePathPropertyName($document->getStructureType(), $event->getLocale()); $routePath = $event->getNode()->getPropertyValueWithDefault($propertyName, null); $route = $this->conflictResolver->resolve($this->chainRouteGenerator->generate($document, $routePath)); $document->setRoutePath($route->getPath()); $event->getNode()->setProperty($propertyName, $route->getPath()); if (!$document instanceof ChildrenBehavior) { return; } foreach ($document->getChildren() as $child) { if (!$child instanceof RoutablePageBehavior) { continue; } $route = $this->chainRouteGenerator->generate($child); $child->setRoutePath($route->getPath()); $node = $this->documentInspector->getNode($child); $node->setProperty($propertyName, $route->getPath()); } }
php
public function handlePersist(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutablePageBehavior) { return; } $document->setUuid($event->getNode()->getIdentifier()); $propertyName = $this->getRoutePathPropertyName($document->getStructureType(), $event->getLocale()); $routePath = $event->getNode()->getPropertyValueWithDefault($propertyName, null); $route = $this->conflictResolver->resolve($this->chainRouteGenerator->generate($document, $routePath)); $document->setRoutePath($route->getPath()); $event->getNode()->setProperty($propertyName, $route->getPath()); if (!$document instanceof ChildrenBehavior) { return; } foreach ($document->getChildren() as $child) { if (!$child instanceof RoutablePageBehavior) { continue; } $route = $this->chainRouteGenerator->generate($child); $child->setRoutePath($route->getPath()); $node = $this->documentInspector->getNode($child); $node->setProperty($propertyName, $route->getPath()); } }
[ "public", "function", "handlePersist", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "RoutablePageBehavior", ")", "{", "return", ";"...
Generate route and save route-path. @param AbstractMappingEvent $event
[ "Generate", "route", "and", "save", "route", "-", "path", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L183-L215
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.handleReorder
public function handleReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutablePageBehavior || !$document instanceof ParentBehavior) { return; } $parentDocument = $document->getParent(); if (!$parentDocument instanceof ChildrenBehavior) { return; } $locale = $this->documentInspector->getLocale($parentDocument); $propertyName = $this->getRoutePathPropertyName($parentDocument->getStructureType(), $locale); foreach ($parentDocument->getChildren() as $childDocument) { $node = $this->documentInspector->getNode($childDocument); $route = $this->chainRouteGenerator->generate($childDocument); $childDocument->setRoutePath($route->getPath()); $node->setProperty($propertyName, $route->getPath()); } }
php
public function handleReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutablePageBehavior || !$document instanceof ParentBehavior) { return; } $parentDocument = $document->getParent(); if (!$parentDocument instanceof ChildrenBehavior) { return; } $locale = $this->documentInspector->getLocale($parentDocument); $propertyName = $this->getRoutePathPropertyName($parentDocument->getStructureType(), $locale); foreach ($parentDocument->getChildren() as $childDocument) { $node = $this->documentInspector->getNode($childDocument); $route = $this->chainRouteGenerator->generate($childDocument); $childDocument->setRoutePath($route->getPath()); $node->setProperty($propertyName, $route->getPath()); } }
[ "public", "function", "handleReorder", "(", "ReorderEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "RoutablePageBehavior", "||", "!", "$", "document", "...
Regenerate routes for siblings on reorder. @param ReorderEvent $event
[ "Regenerate", "routes", "for", "siblings", "on", "reorder", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L222-L244
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.handlePublish
public function handlePublish(PublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutableBehavior) { return; } $node = $this->documentInspector->getNode($document); try { $route = $this->createOrUpdateRoute($document, $event->getLocale()); } catch (RouteIsNotUniqueException $exception) { throw new ResourceLocatorAlreadyExistsException($exception->getRoute()->getPath(), $document->getPath()); } $document->setRoutePath($route->getPath()); $this->entityManager->persist($route); $node->setProperty( $this->getRoutePathPropertyName($document->getStructureType(), $event->getLocale()), $route->getPath() ); $propertyName = $this->getPropertyName($event->getLocale(), self::ROUTES_PROPERTY); // check if nodes previous generated routes exists and remove them if not $oldRoutes = $event->getNode()->getPropertyValueWithDefault($propertyName, []); $this->removeOldChildRoutes($event->getNode()->getSession(), $oldRoutes, $event->getLocale()); $routes = []; if ($document instanceof ChildrenBehavior) { // generate new routes of children $routes = $this->generateChildRoutes($document, $event->getLocale()); } // save the newly generated routes of children $event->getNode()->setProperty($propertyName, $routes); $this->entityManager->flush(); }
php
public function handlePublish(PublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutableBehavior) { return; } $node = $this->documentInspector->getNode($document); try { $route = $this->createOrUpdateRoute($document, $event->getLocale()); } catch (RouteIsNotUniqueException $exception) { throw new ResourceLocatorAlreadyExistsException($exception->getRoute()->getPath(), $document->getPath()); } $document->setRoutePath($route->getPath()); $this->entityManager->persist($route); $node->setProperty( $this->getRoutePathPropertyName($document->getStructureType(), $event->getLocale()), $route->getPath() ); $propertyName = $this->getPropertyName($event->getLocale(), self::ROUTES_PROPERTY); // check if nodes previous generated routes exists and remove them if not $oldRoutes = $event->getNode()->getPropertyValueWithDefault($propertyName, []); $this->removeOldChildRoutes($event->getNode()->getSession(), $oldRoutes, $event->getLocale()); $routes = []; if ($document instanceof ChildrenBehavior) { // generate new routes of children $routes = $this->generateChildRoutes($document, $event->getLocale()); } // save the newly generated routes of children $event->getNode()->setProperty($propertyName, $routes); $this->entityManager->flush(); }
[ "public", "function", "handlePublish", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "RoutableBehavior", ")", "{", "return", ";", "}", "...
Handle publish event and generate route and the child-routes. @param PublishEvent $event @throws ResourceLocatorAlreadyExistsException
[ "Handle", "publish", "event", "and", "generate", "route", "and", "the", "child", "-", "routes", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L253-L291
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.reallocateExistingRoute
private function reallocateExistingRoute(RoutablePageBehavior $document, $locale) { $newRoute = $this->routeRepository->findByPath($document->getRoutePath(), $locale); if (!$newRoute) { return; } $oldRoute = $this->routeRepository->findByEntity(get_class($document), $document->getUuid(), $locale); $history = $this->routeRepository->findHistoryByEntity(get_class($document), $document->getUuid(), $locale); /** @var RouteInterface $historyRoute */ foreach (array_filter(array_merge($history, [$oldRoute])) as $historyRoute) { if ($historyRoute->getId() === $newRoute->getId() || $document->getId() !== $historyRoute->getEntityId()) { // Mismatch of entity-id's happens because doctrine don't check entities which has been changed in the // current session. If the old-route was already reused by a page before it will be returned in the // query of line 329. continue; } $historyRoute->setTarget($newRoute); $historyRoute->setHistory(true); $newRoute->addHistory($historyRoute); } $newRoute->setEntityClass(get_class($document)); $newRoute->setEntityId($document->getId()); $newRoute->setTarget(null); $newRoute->setHistory(false); return $newRoute; }
php
private function reallocateExistingRoute(RoutablePageBehavior $document, $locale) { $newRoute = $this->routeRepository->findByPath($document->getRoutePath(), $locale); if (!$newRoute) { return; } $oldRoute = $this->routeRepository->findByEntity(get_class($document), $document->getUuid(), $locale); $history = $this->routeRepository->findHistoryByEntity(get_class($document), $document->getUuid(), $locale); /** @var RouteInterface $historyRoute */ foreach (array_filter(array_merge($history, [$oldRoute])) as $historyRoute) { if ($historyRoute->getId() === $newRoute->getId() || $document->getId() !== $historyRoute->getEntityId()) { // Mismatch of entity-id's happens because doctrine don't check entities which has been changed in the // current session. If the old-route was already reused by a page before it will be returned in the // query of line 329. continue; } $historyRoute->setTarget($newRoute); $historyRoute->setHistory(true); $newRoute->addHistory($historyRoute); } $newRoute->setEntityClass(get_class($document)); $newRoute->setEntityId($document->getId()); $newRoute->setTarget(null); $newRoute->setHistory(false); return $newRoute; }
[ "private", "function", "reallocateExistingRoute", "(", "RoutablePageBehavior", "$", "document", ",", "$", "locale", ")", "{", "$", "newRoute", "=", "$", "this", "->", "routeRepository", "->", "findByPath", "(", "$", "document", "->", "getRoutePath", "(", ")", ...
Reallocates existing route to given document. @param RoutablePageBehavior $document @param string $locale @return RouteInterface
[ "Reallocates", "existing", "route", "to", "given", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L338-L369
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.removeOldChildRoutes
private function removeOldChildRoutes(SessionInterface $session, array $oldRoutes, $locale) { foreach ($oldRoutes as $oldRoute) { $oldRouteEntity = $this->routeRepository->findByPath($oldRoute, $locale); if ($oldRouteEntity && !$this->nodeExists($session, $oldRouteEntity->getEntityId())) { $this->entityManager->remove($oldRouteEntity); } } $this->entityManager->flush(); }
php
private function removeOldChildRoutes(SessionInterface $session, array $oldRoutes, $locale) { foreach ($oldRoutes as $oldRoute) { $oldRouteEntity = $this->routeRepository->findByPath($oldRoute, $locale); if ($oldRouteEntity && !$this->nodeExists($session, $oldRouteEntity->getEntityId())) { $this->entityManager->remove($oldRouteEntity); } } $this->entityManager->flush(); }
[ "private", "function", "removeOldChildRoutes", "(", "SessionInterface", "$", "session", ",", "array", "$", "oldRoutes", ",", "$", "locale", ")", "{", "foreach", "(", "$", "oldRoutes", "as", "$", "oldRoute", ")", "{", "$", "oldRouteEntity", "=", "$", "this", ...
Removes old-routes where the node does not exists anymore. @param SessionInterface $session @param array $oldRoutes @param string $locale
[ "Removes", "old", "-", "routes", "where", "the", "node", "does", "not", "exists", "anymore", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L403-L413
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.generateChildRoutes
private function generateChildRoutes(ChildrenBehavior $document, $locale) { $routes = []; foreach ($document->getChildren() as $child) { if (!$child instanceof RoutablePageBehavior) { continue; } $childRoute = $this->createOrUpdatePageRoute($child, $locale); $this->entityManager->persist($childRoute); $child->setRoutePath($childRoute->getPath()); $childNode = $this->documentInspector->getNode($child); $propertyName = $this->getRoutePathPropertyName($child->getStructureType(), $locale); $childNode->setProperty($propertyName, $childRoute->getPath()); $routes[] = $childRoute->getPath(); } return $routes; }
php
private function generateChildRoutes(ChildrenBehavior $document, $locale) { $routes = []; foreach ($document->getChildren() as $child) { if (!$child instanceof RoutablePageBehavior) { continue; } $childRoute = $this->createOrUpdatePageRoute($child, $locale); $this->entityManager->persist($childRoute); $child->setRoutePath($childRoute->getPath()); $childNode = $this->documentInspector->getNode($child); $propertyName = $this->getRoutePathPropertyName($child->getStructureType(), $locale); $childNode->setProperty($propertyName, $childRoute->getPath()); $routes[] = $childRoute->getPath(); } return $routes; }
[ "private", "function", "generateChildRoutes", "(", "ChildrenBehavior", "$", "document", ",", "$", "locale", ")", "{", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "document", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "if", ...
Generates child routes. @param ChildrenBehavior $document @param string $locale @return string[]
[ "Generates", "child", "routes", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L423-L444
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.handleRemove
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutableBehavior) { return; } $locales = $this->documentInspector->getLocales($document); foreach ($locales as $locale) { $localizedDocument = $this->documentManager->find($document->getUuid(), $locale); $route = $this->routeRepository->findByEntity( $localizedDocument->getClass(), $localizedDocument->getUuid(), $locale ); if (!$route) { continue; } $this->entityManager->remove($route); if ($document instanceof ChildrenBehavior) { $this->removeChildRoutes($document, $locale); } } $this->entityManager->flush(); }
php
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutableBehavior) { return; } $locales = $this->documentInspector->getLocales($document); foreach ($locales as $locale) { $localizedDocument = $this->documentManager->find($document->getUuid(), $locale); $route = $this->routeRepository->findByEntity( $localizedDocument->getClass(), $localizedDocument->getUuid(), $locale ); if (!$route) { continue; } $this->entityManager->remove($route); if ($document instanceof ChildrenBehavior) { $this->removeChildRoutes($document, $locale); } } $this->entityManager->flush(); }
[ "public", "function", "handleRemove", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "RoutableBehavior", ")", "{", "return", ";", "}", "$"...
Removes route. @param RemoveEvent $event
[ "Removes", "route", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L451-L479
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.handleCopy
public function handleCopy(CopyEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutableBehavior) { return; } $locales = $this->documentInspector->getLocales($document); foreach ($locales as $locale) { $localizedDocument = $this->documentManager->find($event->getCopiedPath(), $locale); $route = $this->conflictResolver->resolve($this->chainRouteGenerator->generate($localizedDocument)); $localizedDocument->setRoutePath($route->getPath()); $node = $this->documentInspector->getNode($localizedDocument); $node->setProperty( $this->getRoutePathPropertyName($localizedDocument->getStructureType(), $locale), $route->getPath() ); $propertyName = $this->getRoutePathPropertyName($localizedDocument->getStructureType(), $locale); $node = $this->documentInspector->getNode($localizedDocument); $node->setProperty($propertyName, $route->getPath()); if ($localizedDocument instanceof ChildrenBehavior) { $this->generateChildRoutes($localizedDocument, $locale); } } }
php
public function handleCopy(CopyEvent $event) { $document = $event->getDocument(); if (!$document instanceof RoutableBehavior) { return; } $locales = $this->documentInspector->getLocales($document); foreach ($locales as $locale) { $localizedDocument = $this->documentManager->find($event->getCopiedPath(), $locale); $route = $this->conflictResolver->resolve($this->chainRouteGenerator->generate($localizedDocument)); $localizedDocument->setRoutePath($route->getPath()); $node = $this->documentInspector->getNode($localizedDocument); $node->setProperty( $this->getRoutePathPropertyName($localizedDocument->getStructureType(), $locale), $route->getPath() ); $propertyName = $this->getRoutePathPropertyName($localizedDocument->getStructureType(), $locale); $node = $this->documentInspector->getNode($localizedDocument); $node->setProperty($propertyName, $route->getPath()); if ($localizedDocument instanceof ChildrenBehavior) { $this->generateChildRoutes($localizedDocument, $locale); } } }
[ "public", "function", "handleCopy", "(", "CopyEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "RoutableBehavior", ")", "{", "return", ";", "}", "$", ...
Update routes for copied article. @param CopyEvent $event
[ "Update", "routes", "for", "copied", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L486-L514
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.removeChildRoutes
private function removeChildRoutes(ChildrenBehavior $document, $locale) { foreach ($document->getChildren() as $child) { if ($child instanceof RoutablePageBehavior) { $this->removeChildRoute($child, $locale); } if ($child instanceof ChildrenBehavior) { $this->removeChildRoutes($child, $locale); } } }
php
private function removeChildRoutes(ChildrenBehavior $document, $locale) { foreach ($document->getChildren() as $child) { if ($child instanceof RoutablePageBehavior) { $this->removeChildRoute($child, $locale); } if ($child instanceof ChildrenBehavior) { $this->removeChildRoutes($child, $locale); } } }
[ "private", "function", "removeChildRoutes", "(", "ChildrenBehavior", "$", "document", ",", "$", "locale", ")", "{", "foreach", "(", "$", "document", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "if", "(", "$", "child", "instanceof", "Routab...
Iterate over children and remove routes. @param ChildrenBehavior $document @param string $locale
[ "Iterate", "over", "children", "and", "remove", "routes", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L522-L533
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.removeChildRoute
private function removeChildRoute(RoutablePageBehavior $document, $locale) { $route = $this->routeRepository->findByPath($document->getRoutePath(), $locale); if ($route) { $this->entityManager->remove($route); } }
php
private function removeChildRoute(RoutablePageBehavior $document, $locale) { $route = $this->routeRepository->findByPath($document->getRoutePath(), $locale); if ($route) { $this->entityManager->remove($route); } }
[ "private", "function", "removeChildRoute", "(", "RoutablePageBehavior", "$", "document", ",", "$", "locale", ")", "{", "$", "route", "=", "$", "this", "->", "routeRepository", "->", "findByPath", "(", "$", "document", "->", "getRoutePath", "(", ")", ",", "$"...
Removes route if exists. @param RoutablePageBehavior $document @param string $locale
[ "Removes", "route", "if", "exists", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L541-L547
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.getRoutePathPropertyName
private function getRoutePathPropertyName($structureType, $locale) { $metadata = $this->metadataFactory->getStructureMetadata('article', $structureType); if ($metadata->hasTag(self::TAG_NAME)) { return $this->getPropertyName($locale, $metadata->getPropertyByTagName(self::TAG_NAME)->getName()); } return $this->getPropertyName($locale, self::ROUTE_FIELD); }
php
private function getRoutePathPropertyName($structureType, $locale) { $metadata = $this->metadataFactory->getStructureMetadata('article', $structureType); if ($metadata->hasTag(self::TAG_NAME)) { return $this->getPropertyName($locale, $metadata->getPropertyByTagName(self::TAG_NAME)->getName()); } return $this->getPropertyName($locale, self::ROUTE_FIELD); }
[ "private", "function", "getRoutePathPropertyName", "(", "$", "structureType", ",", "$", "locale", ")", "{", "$", "metadata", "=", "$", "this", "->", "metadataFactory", "->", "getStructureMetadata", "(", "'article'", ",", "$", "structureType", ")", ";", "if", "...
Returns encoded "routePath" property-name. @param string $structureType @param string $locale @return string
[ "Returns", "encoded", "routePath", "property", "-", "name", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L557-L566
train
sulu/SuluArticleBundle
Document/Subscriber/RoutableSubscriber.php
RoutableSubscriber.nodeExists
private function nodeExists(SessionInterface $session, $uuid) { try { $session->getNodeByIdentifier($uuid); return true; } catch (ItemNotFoundException $exception) { return false; } }
php
private function nodeExists(SessionInterface $session, $uuid) { try { $session->getNodeByIdentifier($uuid); return true; } catch (ItemNotFoundException $exception) { return false; } }
[ "private", "function", "nodeExists", "(", "SessionInterface", "$", "session", ",", "$", "uuid", ")", "{", "try", "{", "$", "session", "->", "getNodeByIdentifier", "(", "$", "uuid", ")", ";", "return", "true", ";", "}", "catch", "(", "ItemNotFoundException", ...
Returns true if given uuid exists. @param SessionInterface $session @param string $uuid @return bool
[ "Returns", "true", "if", "given", "uuid", "exists", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/RoutableSubscriber.php#L589-L598
train
sulu/SuluArticleBundle
Document/MediaViewObject.php
MediaViewObject.setFormats
public function setFormats($formats) { if (is_array($formats)) { $formats = json_encode($formats); } $this->formats = $formats; return $this; }
php
public function setFormats($formats) { if (is_array($formats)) { $formats = json_encode($formats); } $this->formats = $formats; return $this; }
[ "public", "function", "setFormats", "(", "$", "formats", ")", "{", "if", "(", "is_array", "(", "$", "formats", ")", ")", "{", "$", "formats", "=", "json_encode", "(", "$", "formats", ")", ";", "}", "$", "this", "->", "formats", "=", "$", "formats", ...
Set formats. @param string[] $formats @return $this
[ "Set", "formats", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/MediaViewObject.php#L95-L104
train
sulu/SuluArticleBundle
Document/Serializer/WebsiteArticleUrlsSubscriber.php
WebsiteArticleUrlsSubscriber.addUrlsOnPostSerialize
public function addUrlsOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); $request = $this->requestStack->getCurrentRequest(); if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website') || !$request) { return; } /** @var RequestAttributes $attributes */ $attributes = $request->get('_sulu'); if (!$attributes) { return; } /** @var Webspace $webspace */ $webspace = $attributes->getAttribute('webspace'); if (!$webspace) { return; } $urls = []; foreach ($webspace->getAllLocalizations() as $localization) { $locale = $localization->getLocale(); $route = $this->routeRepository->findByEntity(get_class($article), $article->getUuid(), $locale); $urls[$locale] = '/'; if ($route) { $urls[$locale] = $route->getPath(); } } $visitor->addData('urls', $context->accept($urls)); }
php
public function addUrlsOnPostSerialize(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); $request = $this->requestStack->getCurrentRequest(); if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website') || !$request) { return; } /** @var RequestAttributes $attributes */ $attributes = $request->get('_sulu'); if (!$attributes) { return; } /** @var Webspace $webspace */ $webspace = $attributes->getAttribute('webspace'); if (!$webspace) { return; } $urls = []; foreach ($webspace->getAllLocalizations() as $localization) { $locale = $localization->getLocale(); $route = $this->routeRepository->findByEntity(get_class($article), $article->getUuid(), $locale); $urls[$locale] = '/'; if ($route) { $urls[$locale] = $route->getPath(); } } $visitor->addData('urls', $context->accept($urls)); }
[ "public", "function", "addUrlsOnPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "article", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "context", "=", ...
Loops thru current webspace locales and generates routes for them. @param ObjectEvent $event
[ "Loops", "thru", "current", "webspace", "locales", "and", "generates", "routes", "for", "them", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/WebsiteArticleUrlsSubscriber.php#L67-L102
train
sulu/SuluArticleBundle
Metadata/StructureTagTrait.php
StructureTagTrait.getTagAttribute
private function getTagAttribute(StructureMetadata $metadata, $tag, $attribute, $default) { if (!$metadata->hasTag($tag)) { return $default; } $tag = $metadata->getTag($tag); if (!array_key_exists($attribute, $tag['attributes'])) { return $default; } return $tag['attributes'][$attribute]; }
php
private function getTagAttribute(StructureMetadata $metadata, $tag, $attribute, $default) { if (!$metadata->hasTag($tag)) { return $default; } $tag = $metadata->getTag($tag); if (!array_key_exists($attribute, $tag['attributes'])) { return $default; } return $tag['attributes'][$attribute]; }
[ "private", "function", "getTagAttribute", "(", "StructureMetadata", "$", "metadata", ",", "$", "tag", ",", "$", "attribute", ",", "$", "default", ")", "{", "if", "(", "!", "$", "metadata", "->", "hasTag", "(", "$", "tag", ")", ")", "{", "return", "$", ...
Returns attribute for given tag in metadata. @param StructureMetadata $metadata @param string $tag @param string $attribute @param mixed $default @return mixed
[ "Returns", "attribute", "for", "given", "tag", "in", "metadata", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Metadata/StructureTagTrait.php#L56-L68
train
sulu/SuluArticleBundle
Document/Index/Factory/ExcerptFactory.php
ExcerptFactory.create
public function create($data, $locale) { $excerpt = new ExcerptViewObject(); if (empty($data)) { return $excerpt; } $excerpt->title = $data['title']; $excerpt->more = $data['more']; $excerpt->description = $data['description']; $excerpt->tags = $this->tagCollectionFactory->create($data['tags']); $excerpt->categories = $this->categoryCollectionFactory->create($data['categories'], $locale); $excerpt->icon = $this->mediaCollectionFactory->create($data['icon'], $locale); $excerpt->images = $this->mediaCollectionFactory->create($data['images'], $locale); return $excerpt; }
php
public function create($data, $locale) { $excerpt = new ExcerptViewObject(); if (empty($data)) { return $excerpt; } $excerpt->title = $data['title']; $excerpt->more = $data['more']; $excerpt->description = $data['description']; $excerpt->tags = $this->tagCollectionFactory->create($data['tags']); $excerpt->categories = $this->categoryCollectionFactory->create($data['categories'], $locale); $excerpt->icon = $this->mediaCollectionFactory->create($data['icon'], $locale); $excerpt->images = $this->mediaCollectionFactory->create($data['images'], $locale); return $excerpt; }
[ "public", "function", "create", "(", "$", "data", ",", "$", "locale", ")", "{", "$", "excerpt", "=", "new", "ExcerptViewObject", "(", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "excerpt", ";", "}", "$", "excerpt",...
Create a excerpt object by given data. @param array $data @param string $locale @return ExcerptViewObject
[ "Create", "a", "excerpt", "object", "by", "given", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/Factory/ExcerptFactory.php#L61-L78
train
sulu/SuluArticleBundle
Document/Subscriber/DateShardingSubscriber.php
DateShardingSubscriber.handleSetParentNode
public function handleSetParentNode(PersistEvent $event) { if (!$event->getDocument() instanceof DateShardingBehavior || $event->hasParentNode()) { return; } $date = $event->getDocument()->getCreated(); if (null === $date) { $date = new \DateTime(); } $path = $this->pathBuilder->build(['%base%', '%articles%', $date->format('Y'), $date->format('m')]); $event->setParentNode($this->nodeManager->createPath($path)); }
php
public function handleSetParentNode(PersistEvent $event) { if (!$event->getDocument() instanceof DateShardingBehavior || $event->hasParentNode()) { return; } $date = $event->getDocument()->getCreated(); if (null === $date) { $date = new \DateTime(); } $path = $this->pathBuilder->build(['%base%', '%articles%', $date->format('Y'), $date->format('m')]); $event->setParentNode($this->nodeManager->createPath($path)); }
[ "public", "function", "handleSetParentNode", "(", "PersistEvent", "$", "event", ")", "{", "if", "(", "!", "$", "event", "->", "getDocument", "(", ")", "instanceof", "DateShardingBehavior", "||", "$", "event", "->", "hasParentNode", "(", ")", ")", "{", "retur...
Set parent-node if no parent exists. The format of parent node is: /%base%/%articles%/ @param PersistEvent $event
[ "Set", "parent", "-", "node", "if", "no", "parent", "exists", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/DateShardingSubscriber.php#L65-L79
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleScheduleIndex
public function handleScheduleIndex(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); } $this->documents[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
php
public function handleScheduleIndex(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); } $this->documents[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
[ "public", "function", "handleScheduleIndex", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "if", "(", ...
Schedule article document for index. @param AbstractMappingEvent $event
[ "Schedule", "article", "document", "for", "index", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L147-L162
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleScheduleIndexLive
public function handleScheduleIndexLive(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); } $this->liveDocuments[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
php
public function handleScheduleIndexLive(AbstractMappingEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); } $this->liveDocuments[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
[ "public", "function", "handleScheduleIndexLive", "(", "AbstractMappingEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "if", "(...
Schedule article document for live index. @param AbstractMappingEvent $event
[ "Schedule", "article", "document", "for", "live", "index", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L169-L184
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.synchronizeChildren
public function synchronizeChildren(PublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $liveNode = $event->getNode(); $draftNode = $this->documentInspector->getNode($document); $liveChildren = $this->getChildren($liveNode); $draftChildren = $this->getChildren($draftNode); $removedChildrenIds = array_diff(array_keys($liveChildren), array_keys($draftChildren)); foreach ($removedChildrenIds as $removedChildrenId) { $liveChildren[$removedChildrenId]->remove(); } }
php
public function synchronizeChildren(PublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $liveNode = $event->getNode(); $draftNode = $this->documentInspector->getNode($document); $liveChildren = $this->getChildren($liveNode); $draftChildren = $this->getChildren($draftNode); $removedChildrenIds = array_diff(array_keys($liveChildren), array_keys($draftChildren)); foreach ($removedChildrenIds as $removedChildrenId) { $liveChildren[$removedChildrenId]->remove(); } }
[ "public", "function", "synchronizeChildren", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "}"...
Syncs children between live and draft. @param PublishEvent $event
[ "Syncs", "children", "between", "live", "and", "draft", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L191-L208
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.getChildren
private function getChildren(NodeInterface $node) { $result = []; foreach ($node->getNodes() as $child) { $result[$child->getIdentifier()] = $child; } return $result; }
php
private function getChildren(NodeInterface $node) { $result = []; foreach ($node->getNodes() as $child) { $result[$child->getIdentifier()] = $child; } return $result; }
[ "private", "function", "getChildren", "(", "NodeInterface", "$", "node", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "node", "->", "getNodes", "(", ")", "as", "$", "child", ")", "{", "$", "result", "[", "$", "child", "->", "ge...
Returns children of given node. @param NodeInterface $node @return NodeInterface[]
[ "Returns", "children", "of", "given", "node", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L217-L225
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.publishChildren
public function publishChildren(PublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $children = iterator_to_array($document->getChildren()); foreach ($children as $child) { if (LocalizationState::GHOST !== $this->documentInspector->getLocalizationState($child)) { $this->documentManager->publish($child, $event->getLocale()); } } }
php
public function publishChildren(PublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $children = iterator_to_array($document->getChildren()); foreach ($children as $child) { if (LocalizationState::GHOST !== $this->documentInspector->getLocalizationState($child)) { $this->documentManager->publish($child, $event->getLocale()); } } }
[ "public", "function", "publishChildren", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "}", ...
Publish pages when article will be published. @param PublishEvent $event
[ "Publish", "pages", "when", "article", "will", "be", "published", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L232-L245
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.persistPageDataOnReorder
public function persistPageDataOnReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); $node = $this->documentInspector->getNode($document); $this->setPageData($document, $node, $document->getLocale()); $document->setWorkflowStage(WorkflowStage::TEST); $this->documentManager->persist($document, $this->documentInspector->getLocale($document)); $this->documents[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
php
public function persistPageDataOnReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); $node = $this->documentInspector->getNode($document); $this->setPageData($document, $node, $document->getLocale()); $document->setWorkflowStage(WorkflowStage::TEST); $this->documentManager->persist($document, $this->documentInspector->getLocale($document)); $this->documents[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
[ "public", "function", "persistPageDataOnReorder", "(", "ReorderEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", ")", "{", "return", "...
Persist page-data for reordering children. @param ReorderEvent $event
[ "Persist", "page", "-", "data", "for", "reordering", "children", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L252-L271
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.persistPageData
public function persistPageData($event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $this->setPageData($document, $event->getNode(), $event->getLocale()); }
php
public function persistPageData($event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $this->setPageData($document, $event->getNode(), $event->getLocale()); }
[ "public", "function", "persistPageData", "(", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "}", "$", "this", "...
Persist page-data. @param PersistEvent|PublishEvent $event
[ "Persist", "page", "-", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L278-L286
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.setPageData
private function setPageData(ArticleDocument $document, NodeInterface $node, $locale) { $pages = [ [ 'uuid' => $document->getUuid(), 'title' => $document->getPageTitle() ?: $document->getTitle(), 'routePath' => $document->getRoutePath(), 'pageNumber' => $document->getPageNumber(), ], ]; foreach ($document->getChildren() as $child) { if ($child instanceof ArticlePageDocument && LocalizationState::GHOST !== $this->documentInspector->getLocalizationState($child) ) { $pages[] = [ 'uuid' => $child->getUuid(), 'title' => $child->getPageTitle(), 'routePath' => $child->getRoutePath(), 'pageNumber' => $child->getPageNumber(), ]; } } $pages = SortUtils::multisort($pages, '[pageNumber]'); $document->setPages($pages); $node->setProperty( $this->propertyEncoder->localizedSystemName(self::PAGES_PROPERTY, $locale), json_encode($pages) ); }
php
private function setPageData(ArticleDocument $document, NodeInterface $node, $locale) { $pages = [ [ 'uuid' => $document->getUuid(), 'title' => $document->getPageTitle() ?: $document->getTitle(), 'routePath' => $document->getRoutePath(), 'pageNumber' => $document->getPageNumber(), ], ]; foreach ($document->getChildren() as $child) { if ($child instanceof ArticlePageDocument && LocalizationState::GHOST !== $this->documentInspector->getLocalizationState($child) ) { $pages[] = [ 'uuid' => $child->getUuid(), 'title' => $child->getPageTitle(), 'routePath' => $child->getRoutePath(), 'pageNumber' => $child->getPageNumber(), ]; } } $pages = SortUtils::multisort($pages, '[pageNumber]'); $document->setPages($pages); $node->setProperty( $this->propertyEncoder->localizedSystemName(self::PAGES_PROPERTY, $locale), json_encode($pages) ); }
[ "private", "function", "setPageData", "(", "ArticleDocument", "$", "document", ",", "NodeInterface", "$", "node", ",", "$", "locale", ")", "{", "$", "pages", "=", "[", "[", "'uuid'", "=>", "$", "document", "->", "getUuid", "(", ")", ",", "'title'", "=>",...
Set page-data for given document on given node. @param ArticleDocument $document @param NodeInterface $node @param string $locale
[ "Set", "page", "-", "data", "for", "given", "document", "on", "given", "node", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L295-L326
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.hydratePageData
public function hydratePageData(HydrateEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $pages = $event->getNode()->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::PAGES_PROPERTY, $document->getOriginalLocale()), json_encode([]) ); $pages = json_decode($pages, true); if (LocalizationState::SHADOW === $this->documentInspector->getLocalizationState($document)) { $pages = $this->loadPageDataForShadow($event->getNode(), $document, $pages); } $document->setPages($pages); }
php
public function hydratePageData(HydrateEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $pages = $event->getNode()->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::PAGES_PROPERTY, $document->getOriginalLocale()), json_encode([]) ); $pages = json_decode($pages, true); if (LocalizationState::SHADOW === $this->documentInspector->getLocalizationState($document)) { $pages = $this->loadPageDataForShadow($event->getNode(), $document, $pages); } $document->setPages($pages); }
[ "public", "function", "hydratePageData", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "}", ...
Hydrate page-data. @param HydrateEvent $event
[ "Hydrate", "page", "-", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L333-L351
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.loadPageDataForShadow
private function loadPageDataForShadow(NodeInterface $node, ArticleDocument $document, array $originalPages) { $pages = $node->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::PAGES_PROPERTY, $document->getLocale()), json_encode([]) ); $pages = json_decode($pages, true); for ($i = 0; $i < count($originalPages); ++$i) { $pages[$i]['routePath'] = $originalPages[$i]['routePath']; } return $pages; }
php
private function loadPageDataForShadow(NodeInterface $node, ArticleDocument $document, array $originalPages) { $pages = $node->getPropertyValueWithDefault( $this->propertyEncoder->localizedSystemName(self::PAGES_PROPERTY, $document->getLocale()), json_encode([]) ); $pages = json_decode($pages, true); for ($i = 0; $i < count($originalPages); ++$i) { $pages[$i]['routePath'] = $originalPages[$i]['routePath']; } return $pages; }
[ "private", "function", "loadPageDataForShadow", "(", "NodeInterface", "$", "node", ",", "ArticleDocument", "$", "document", ",", "array", "$", "originalPages", ")", "{", "$", "pages", "=", "$", "node", "->", "getPropertyValueWithDefault", "(", "$", "this", "->",...
Load `routePath` from current locale into `pageData`. @param NodeInterface $node @param ArticleDocument $document @param array $originalPages @return array
[ "Load", "routePath", "from", "current", "locale", "into", "pageData", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L362-L375
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.removeDraftChildren
public function removeDraftChildren(RemoveDraftEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } foreach ($document->getChildren() as $child) { if (LocalizationState::GHOST === $this->documentInspector->getLocalizationState($child)) { continue; } try { $this->documentManager->removeDraft($child, $event->getLocale()); } catch (PathNotFoundException $exception) { // child is not available in live workspace $node = $this->documentInspector->getNode($child); $node->remove(); } } }
php
public function removeDraftChildren(RemoveDraftEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } foreach ($document->getChildren() as $child) { if (LocalizationState::GHOST === $this->documentInspector->getLocalizationState($child)) { continue; } try { $this->documentManager->removeDraft($child, $event->getLocale()); } catch (PathNotFoundException $exception) { // child is not available in live workspace $node = $this->documentInspector->getNode($child); $node->remove(); } } }
[ "public", "function", "removeDraftChildren", "(", "RemoveDraftEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", ...
Remove draft from children. @param RemoveDraftEvent $event
[ "Remove", "draft", "from", "children", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L382-L402
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleFlush
public function handleFlush(FlushEvent $event) { if (count($this->documents) < 1) { return; } foreach ($this->documents as $documentData) { $document = $this->documentManager->find($documentData['uuid'], $documentData['locale']); $this->documentManager->refresh($document); $this->indexer->index($document); } $this->indexer->flush(); $this->documents = []; }
php
public function handleFlush(FlushEvent $event) { if (count($this->documents) < 1) { return; } foreach ($this->documents as $documentData) { $document = $this->documentManager->find($documentData['uuid'], $documentData['locale']); $this->documentManager->refresh($document); $this->indexer->index($document); } $this->indexer->flush(); $this->documents = []; }
[ "public", "function", "handleFlush", "(", "FlushEvent", "$", "event", ")", "{", "if", "(", "count", "(", "$", "this", "->", "documents", ")", "<", "1", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "documents", "as", "$", "document...
Index all scheduled article documents with default indexer. @param FlushEvent $event
[ "Index", "all", "scheduled", "article", "documents", "with", "default", "indexer", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L409-L423
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleFlushLive
public function handleFlushLive(FlushEvent $event) { if (count($this->liveDocuments) < 1) { return; } foreach ($this->liveDocuments as $documentData) { $document = $this->documentManager->find($documentData['uuid'], $documentData['locale']); $this->documentManager->refresh($document); $this->liveIndexer->index($document); } $this->liveIndexer->flush(); $this->liveDocuments = []; }
php
public function handleFlushLive(FlushEvent $event) { if (count($this->liveDocuments) < 1) { return; } foreach ($this->liveDocuments as $documentData) { $document = $this->documentManager->find($documentData['uuid'], $documentData['locale']); $this->documentManager->refresh($document); $this->liveIndexer->index($document); } $this->liveIndexer->flush(); $this->liveDocuments = []; }
[ "public", "function", "handleFlushLive", "(", "FlushEvent", "$", "event", ")", "{", "if", "(", "count", "(", "$", "this", "->", "liveDocuments", ")", "<", "1", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "liveDocuments", "as", "$",...
Index all scheduled article documents with live indexer. @param FlushEvent $event
[ "Index", "all", "scheduled", "article", "documents", "with", "live", "indexer", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L430-L444
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleUnpublish
public function handleUnpublish(UnpublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $this->liveIndexer->remove($document); $this->liveIndexer->flush(); $this->indexer->setUnpublished($document->getUuid(), $event->getLocale()); $this->indexer->flush(); }
php
public function handleUnpublish(UnpublishEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $this->liveIndexer->remove($document); $this->liveIndexer->flush(); $this->indexer->setUnpublished($document->getUuid(), $event->getLocale()); $this->indexer->flush(); }
[ "public", "function", "handleUnpublish", "(", "UnpublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "}", ...
Removes document from live index and unpublish document in default index. @param UnpublishEvent $event
[ "Removes", "document", "from", "live", "index", "and", "unpublish", "document", "in", "default", "index", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L451-L463
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleRemovePage
public function handleRemovePage(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); $this->documents[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
php
public function handleRemovePage(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $document = $document->getParent(); $this->documents[$document->getUuid()] = [ 'uuid' => $document->getUuid(), 'locale' => $document->getLocale(), ]; }
[ "public", "function", "handleRemovePage", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", ")", "{", "return", ";", "}"...
Reindex article if a page was removed. @param RemoveEvent $event
[ "Reindex", "article", "if", "a", "page", "was", "removed", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L470-L482
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleCopy
public function handleCopy(CopyEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $uuid = $event->getCopiedNode()->getIdentifier(); $this->documents[$uuid] = [ 'uuid' => $uuid, 'locale' => $document->getLocale(), ]; }
php
public function handleCopy(CopyEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } $uuid = $event->getCopiedNode()->getIdentifier(); $this->documents[$uuid] = [ 'uuid' => $uuid, 'locale' => $document->getLocale(), ]; }
[ "public", "function", "handleCopy", "(", "CopyEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "}", "$", "...
Schedule document to index. @param CopyEvent $event
[ "Schedule", "document", "to", "index", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L521-L533
train
sulu/SuluArticleBundle
Document/Subscriber/ArticleSubscriber.php
ArticleSubscriber.handleChildrenPersist
public function handleChildrenPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } foreach ($document->getChildren() as $childDocument) { if (!$childDocument instanceof ArticlePageDocument) { continue; } $localizationState = $this->documentInspector->getLocalizationState($childDocument); if (LocalizationState::GHOST === $localizationState) { continue; } $changed = false; if ($document->getStructureType() !== $childDocument->getStructureType()) { $childDocument->setStructureType($document->getStructureType()); $changed = true; } if ($document->getShadowLocale() !== $childDocument->getShadowLocale()) { $childDocument->setShadowLocale($document->getShadowLocale()); $changed = true; } if ($document->isShadowLocaleEnabled() !== $childDocument->isShadowLocaleEnabled()) { $childDocument->setShadowLocaleEnabled($document->isShadowLocaleEnabled()); $changed = true; } if ($changed) { $this->documentManager->persist( $childDocument, $childDocument->getLocale(), [ 'clear_missing_content' => false, 'auto_name' => false, 'auto_rename' => false, ] ); } } }
php
public function handleChildrenPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleDocument) { return; } foreach ($document->getChildren() as $childDocument) { if (!$childDocument instanceof ArticlePageDocument) { continue; } $localizationState = $this->documentInspector->getLocalizationState($childDocument); if (LocalizationState::GHOST === $localizationState) { continue; } $changed = false; if ($document->getStructureType() !== $childDocument->getStructureType()) { $childDocument->setStructureType($document->getStructureType()); $changed = true; } if ($document->getShadowLocale() !== $childDocument->getShadowLocale()) { $childDocument->setShadowLocale($document->getShadowLocale()); $changed = true; } if ($document->isShadowLocaleEnabled() !== $childDocument->isShadowLocaleEnabled()) { $childDocument->setShadowLocaleEnabled($document->isShadowLocaleEnabled()); $changed = true; } if ($changed) { $this->documentManager->persist( $childDocument, $childDocument->getLocale(), [ 'clear_missing_content' => false, 'auto_name' => false, 'auto_rename' => false, ] ); } } }
[ "public", "function", "handleChildrenPersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleDocument", ")", "{", "return", ";", "...
Schedule all children. @param PersistEvent $event
[ "Schedule", "all", "children", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticleSubscriber.php#L540-L587
train
sulu/SuluArticleBundle
Document/Index/Factory/SeoFactory.php
SeoFactory.create
public function create($data) { $seo = new SeoViewObject(); if (empty($data)) { return $seo; } $seo->title = $data['title']; $seo->description = $data['description']; $seo->keywords = $data['keywords']; $seo->canonicalUrl = $data['canonicalUrl']; $seo->noIndex = $data['noIndex']; $seo->noFollow = $data['noFollow']; $seo->hideInSitemap = $data['hideInSitemap']; return $seo; }
php
public function create($data) { $seo = new SeoViewObject(); if (empty($data)) { return $seo; } $seo->title = $data['title']; $seo->description = $data['description']; $seo->keywords = $data['keywords']; $seo->canonicalUrl = $data['canonicalUrl']; $seo->noIndex = $data['noIndex']; $seo->noFollow = $data['noFollow']; $seo->hideInSitemap = $data['hideInSitemap']; return $seo; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "seo", "=", "new", "SeoViewObject", "(", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "seo", ";", "}", "$", "seo", "->", "title", "=", "$", "data"...
Create a seo view object by given data. @param array $data @return SeoViewObject
[ "Create", "a", "seo", "view", "object", "by", "given", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/Factory/SeoFactory.php#L28-L45
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.setParentOnHydrate
public function setParentOnHydrate(HydrateEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || $document->getParent()) { return; } $parent = $this->documentManager->find( $event->getNode()->getParent()->getIdentifier(), $document->getOriginalLocale(), $event->getOptions() ); $document->setParent($parent); }
php
public function setParentOnHydrate(HydrateEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || $document->getParent()) { return; } $parent = $this->documentManager->find( $event->getNode()->getParent()->getIdentifier(), $document->getOriginalLocale(), $event->getOptions() ); $document->setParent($parent); }
[ "public", "function", "setParentOnHydrate", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", "||", "$", "document", "->"...
Hydrate parent to avoid proxiing it. @param HydrateEvent $event
[ "Hydrate", "parent", "to", "avoid", "proxiing", "it", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L113-L126
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.checkOptions
public function checkOptions(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $autoRename = $event->getOption('auto_rename'); if (false !== $autoRename) { throw new \InvalidArgumentException('Persist "ArticlePageDocument" only with option "auto_rename" set to "false" allowed'); } }
php
public function checkOptions(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $autoRename = $event->getOption('auto_rename'); if (false !== $autoRename) { throw new \InvalidArgumentException('Persist "ArticlePageDocument" only with option "auto_rename" set to "false" allowed'); } }
[ "public", "function", "checkOptions", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", ")", "{", "return", ";", "}", ...
Check for missing persist options. @param PersistEvent $event
[ "Check", "for", "missing", "persist", "options", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L133-L145
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.setTitleOnPersist
public function setTitleOnPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $document->setTitle($document->getParent()->getTitle()); }
php
public function setTitleOnPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument) { return; } $document->setTitle($document->getParent()->getTitle()); }
[ "public", "function", "setTitleOnPersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", ")", "{", "return", ";", "...
Set page-title from structure to document. @param PersistEvent $event
[ "Set", "page", "-", "title", "from", "structure", "to", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L152-L160
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.setWorkflowStageOnArticle
public function setWorkflowStageOnArticle($event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || LocalizationState::GHOST === $this->documentInspector->getLocalizationState($document->getParent()) ) { return; } $document->getParent()->setWorkflowStage(WorkflowStage::TEST); $this->documentManager->persist( $document->getParent(), $this->documentInspector->getLocale($document), $event instanceof PersistEvent ? $event->getOptions() : [] ); }
php
public function setWorkflowStageOnArticle($event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || LocalizationState::GHOST === $this->documentInspector->getLocalizationState($document->getParent()) ) { return; } $document->getParent()->setWorkflowStage(WorkflowStage::TEST); $this->documentManager->persist( $document->getParent(), $this->documentInspector->getLocale($document), $event instanceof PersistEvent ? $event->getOptions() : [] ); }
[ "public", "function", "setWorkflowStageOnArticle", "(", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", "||", "LocalizationState", "::", "GHOS...
Set workflow-stage to test for article. @param PersistEvent|RemoveEvent $event
[ "Set", "workflow", "-", "stage", "to", "test", "for", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L167-L182
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.setNodeOnPersist
public function setNodeOnPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || $event->hasNode()) { return; } $pageTitle = $this->getPageTitle($document); // if no page-title exists use a unique-id $nodeName = $this->slugifier->slugify($pageTitle ?: uniqid('page-', true)); $nodeName = $this->resolver->resolveName($event->getParentNode(), $nodeName); $node = $event->getParentNode()->addNode($nodeName); $event->setNode($node); }
php
public function setNodeOnPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || $event->hasNode()) { return; } $pageTitle = $this->getPageTitle($document); // if no page-title exists use a unique-id $nodeName = $this->slugifier->slugify($pageTitle ?: uniqid('page-', true)); $nodeName = $this->resolver->resolveName($event->getParentNode(), $nodeName); $node = $event->getParentNode()->addNode($nodeName); $event->setNode($node); }
[ "public", "function", "setNodeOnPersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", "||", "$", "event", "->", "...
Set node to event on persist. @param PersistEvent $event
[ "Set", "node", "to", "event", "on", "persist", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L189-L204
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.setPageTitleOnPersist
public function setPageTitleOnPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleInterface) { return; } $document->setPageTitle($this->getPageTitle($document)); }
php
public function setPageTitleOnPersist(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticleInterface) { return; } $document->setPageTitle($this->getPageTitle($document)); }
[ "public", "function", "setPageTitleOnPersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticleInterface", ")", "{", "return", ";", ...
Set page-title on persist event. @param PersistEvent $event
[ "Set", "page", "-", "title", "on", "persist", "event", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L211-L219
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.getPageTitle
private function getPageTitle(ArticleInterface $document) { $pageTitleProperty = $this->getPageTitleProperty($document); if (!$pageTitleProperty) { return; } $stagedData = $document->getStructure()->getStagedData(); if (array_key_exists($pageTitleProperty->getName(), $stagedData)) { return $stagedData[$pageTitleProperty->getName()]; } if (!$document->getStructure()->hasProperty($pageTitleProperty->getName())) { return; } return $document->getStructure()->getProperty($pageTitleProperty->getName())->getValue(); }
php
private function getPageTitle(ArticleInterface $document) { $pageTitleProperty = $this->getPageTitleProperty($document); if (!$pageTitleProperty) { return; } $stagedData = $document->getStructure()->getStagedData(); if (array_key_exists($pageTitleProperty->getName(), $stagedData)) { return $stagedData[$pageTitleProperty->getName()]; } if (!$document->getStructure()->hasProperty($pageTitleProperty->getName())) { return; } return $document->getStructure()->getProperty($pageTitleProperty->getName())->getValue(); }
[ "private", "function", "getPageTitle", "(", "ArticleInterface", "$", "document", ")", "{", "$", "pageTitleProperty", "=", "$", "this", "->", "getPageTitleProperty", "(", "$", "document", ")", ";", "if", "(", "!", "$", "pageTitleProperty", ")", "{", "return", ...
Returns page-title for node. @param ArticleInterface $document @return string
[ "Returns", "page", "-", "title", "for", "node", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L228-L245
train
sulu/SuluArticleBundle
Document/Subscriber/ArticlePageSubscriber.php
ArticlePageSubscriber.setStructureTypeToParent
public function setStructureTypeToParent(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || LocalizationState::GHOST === $this->documentInspector->getLocalizationState($document->getParent()) || $document->getStructureType() === $document->getParent()->getStructureType() ) { return; } $document->getParent()->setStructureType($document->getStructureType()); $this->documentManager->persist($document->getParent(), $event->getLocale()); }
php
public function setStructureTypeToParent(PersistEvent $event) { $document = $event->getDocument(); if (!$document instanceof ArticlePageDocument || LocalizationState::GHOST === $this->documentInspector->getLocalizationState($document->getParent()) || $document->getStructureType() === $document->getParent()->getStructureType() ) { return; } $document->getParent()->setStructureType($document->getStructureType()); $this->documentManager->persist($document->getParent(), $event->getLocale()); }
[ "public", "function", "setStructureTypeToParent", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ArticlePageDocument", "||", "LocalizationState"...
Set structure-type to parent document. @param PersistEvent $event
[ "Set", "structure", "-", "type", "to", "parent", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/ArticlePageSubscriber.php#L277-L289
train
sulu/SuluArticleBundle
EventListener/ContentProxyListener.php
ContentProxyListener.getProxies
private function getProxies($contentData, StructureInterface $structure) { $contentData = $contentData ?: '{}'; $data = json_decode($contentData, true); $content = $this->contentProxyFactory->createContentProxy($structure, $data); $view = $this->contentProxyFactory->createViewProxy($structure, $data); return [$content, $view]; }
php
private function getProxies($contentData, StructureInterface $structure) { $contentData = $contentData ?: '{}'; $data = json_decode($contentData, true); $content = $this->contentProxyFactory->createContentProxy($structure, $data); $view = $this->contentProxyFactory->createViewProxy($structure, $data); return [$content, $view]; }
[ "private", "function", "getProxies", "(", "$", "contentData", ",", "StructureInterface", "$", "structure", ")", "{", "$", "contentData", "=", "$", "contentData", "?", ":", "'{}'", ";", "$", "data", "=", "json_decode", "(", "$", "contentData", ",", "true", ...
Create content and view proxy for given content-data. @param string $contentData @param StructureInterface $structure @return array
[ "Create", "content", "and", "view", "proxy", "for", "given", "content", "-", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/EventListener/ContentProxyListener.php#L76-L85
train
sulu/SuluArticleBundle
Document/Index/ArticleIndexer.php
ArticleIndexer.getTypeTranslation
private function getTypeTranslation($type) { if (!array_key_exists($type, $this->typeConfiguration)) { return ucfirst($type); } $typeTranslationKey = $this->typeConfiguration[$type]['translation_key']; return $this->translator->trans($typeTranslationKey, [], 'backend'); }
php
private function getTypeTranslation($type) { if (!array_key_exists($type, $this->typeConfiguration)) { return ucfirst($type); } $typeTranslationKey = $this->typeConfiguration[$type]['translation_key']; return $this->translator->trans($typeTranslationKey, [], 'backend'); }
[ "private", "function", "getTypeTranslation", "(", "$", "type", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "typeConfiguration", ")", ")", "{", "return", "ucfirst", "(", "$", "type", ")", ";", "}", "$", "typeT...
Returns translation for given article type. @param string $type @return string
[ "Returns", "translation", "for", "given", "article", "type", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/ArticleIndexer.php#L176-L185
train
sulu/SuluArticleBundle
Document/Index/ArticleIndexer.php
ArticleIndexer.findOrCreateViewDocument
protected function findOrCreateViewDocument(ArticleDocument $document, $locale, $localizationState) { $articleId = $this->getViewDocumentId($document->getUuid(), $locale); /** @var ArticleViewDocumentInterface $article */ $article = $this->manager->find($this->documentFactory->getClass('article'), $articleId); if ($article) { // Only index ghosts when the article isn't a ghost himself. if (LocalizationState::GHOST === $localizationState && LocalizationState::GHOST !== $article->getLocalizationState()->state ) { return null; } return $article; } $article = $this->documentFactory->create('article'); $article->setId($articleId); $article->setUuid($document->getUuid()); $article->setLocale($locale); return $article; }
php
protected function findOrCreateViewDocument(ArticleDocument $document, $locale, $localizationState) { $articleId = $this->getViewDocumentId($document->getUuid(), $locale); /** @var ArticleViewDocumentInterface $article */ $article = $this->manager->find($this->documentFactory->getClass('article'), $articleId); if ($article) { // Only index ghosts when the article isn't a ghost himself. if (LocalizationState::GHOST === $localizationState && LocalizationState::GHOST !== $article->getLocalizationState()->state ) { return null; } return $article; } $article = $this->documentFactory->create('article'); $article->setId($articleId); $article->setUuid($document->getUuid()); $article->setLocale($locale); return $article; }
[ "protected", "function", "findOrCreateViewDocument", "(", "ArticleDocument", "$", "document", ",", "$", "locale", ",", "$", "localizationState", ")", "{", "$", "articleId", "=", "$", "this", "->", "getViewDocumentId", "(", "$", "document", "->", "getUuid", "(", ...
Returns view-document from index or create a new one. @param ArticleDocument $document @param string $locale @param string $localizationState @return ArticleViewDocumentInterface
[ "Returns", "view", "-", "document", "from", "index", "or", "create", "a", "new", "one", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/ArticleIndexer.php#L288-L311
train
sulu/SuluArticleBundle
Document/Index/ArticleIndexer.php
ArticleIndexer.mapPages
private function mapPages(ArticleDocument $document, ArticleViewDocumentInterface $article) { $pages = []; /** @var ArticlePageDocument $child */ foreach ($document->getChildren() as $child) { if (!$child instanceof ArticlePageDocument) { continue; } /** @var ArticlePageViewObject $page */ $pages[] = $page = $this->documentFactory->create('article_page'); $page->uuid = $child->getUuid(); $page->pageNumber = $child->getPageNumber(); $page->title = $child->getPageTitle(); $page->routePath = $child->getRoutePath(); $page->contentData = json_encode($child->getStructure()->toArray()); } $article->setPages(new Collection($pages)); }
php
private function mapPages(ArticleDocument $document, ArticleViewDocumentInterface $article) { $pages = []; /** @var ArticlePageDocument $child */ foreach ($document->getChildren() as $child) { if (!$child instanceof ArticlePageDocument) { continue; } /** @var ArticlePageViewObject $page */ $pages[] = $page = $this->documentFactory->create('article_page'); $page->uuid = $child->getUuid(); $page->pageNumber = $child->getPageNumber(); $page->title = $child->getPageTitle(); $page->routePath = $child->getRoutePath(); $page->contentData = json_encode($child->getStructure()->toArray()); } $article->setPages(new Collection($pages)); }
[ "private", "function", "mapPages", "(", "ArticleDocument", "$", "document", ",", "ArticleViewDocumentInterface", "$", "article", ")", "{", "$", "pages", "=", "[", "]", ";", "/** @var ArticlePageDocument $child */", "foreach", "(", "$", "document", "->", "getChildren...
Maps pages from document to view-document. @param ArticleDocument $document @param ArticleViewDocumentInterface $article
[ "Maps", "pages", "from", "document", "to", "view", "-", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/ArticleIndexer.php#L319-L338
train
sulu/SuluArticleBundle
Document/Index/ArticleIndexer.php
ArticleIndexer.setParentPageUuid
private function setParentPageUuid( ArticleDocument $document, ArticleViewDocumentInterface $article ) { $parentPageUuid = $this->getParentPageUuidFromPageTree($document); if (!$parentPageUuid) { return; } $article->setParentPageUuid($parentPageUuid); }
php
private function setParentPageUuid( ArticleDocument $document, ArticleViewDocumentInterface $article ) { $parentPageUuid = $this->getParentPageUuidFromPageTree($document); if (!$parentPageUuid) { return; } $article->setParentPageUuid($parentPageUuid); }
[ "private", "function", "setParentPageUuid", "(", "ArticleDocument", "$", "document", ",", "ArticleViewDocumentInterface", "$", "article", ")", "{", "$", "parentPageUuid", "=", "$", "this", "->", "getParentPageUuidFromPageTree", "(", "$", "document", ")", ";", "if", ...
Set parent-page-uuid to view-document. @param ArticleDocument $document @param ArticleViewDocumentInterface $article
[ "Set", "parent", "-", "page", "-", "uuid", "to", "view", "-", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/ArticleIndexer.php#L346-L357
train
sulu/SuluArticleBundle
Document/Index/Factory/MediaCollectionFactory.php
MediaCollectionFactory.create
public function create($data, $locale) { $mediaCollection = new Collection(); if (empty($data)) { return $mediaCollection; } if (array_key_exists('ids', $data)) { $medias = $this->mediaManager->getByIds($data['ids'], $locale); foreach ($medias as $media) { $mediaViewObject = new MediaViewObject(); $mediaViewObject->setData($media); $mediaCollection[] = $mediaViewObject; } } return $mediaCollection; }
php
public function create($data, $locale) { $mediaCollection = new Collection(); if (empty($data)) { return $mediaCollection; } if (array_key_exists('ids', $data)) { $medias = $this->mediaManager->getByIds($data['ids'], $locale); foreach ($medias as $media) { $mediaViewObject = new MediaViewObject(); $mediaViewObject->setData($media); $mediaCollection[] = $mediaViewObject; } } return $mediaCollection; }
[ "public", "function", "create", "(", "$", "data", ",", "$", "locale", ")", "{", "$", "mediaCollection", "=", "new", "Collection", "(", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "mediaCollection", ";", "}", "if", ...
Create media collection object. @param array $data @param $locale @return MediaViewObject[]|Collection
[ "Create", "media", "collection", "object", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/Factory/MediaCollectionFactory.php#L46-L66
train
sulu/SuluArticleBundle
Sitemap/ArticleSitemapProvider.php
ArticleSitemapProvider.setAlternatives
private function setAlternatives(array $sitemapUrlList, SitemapUrl $sitemapUrl) { foreach ($sitemapUrlList as $sitemapUrlFromList) { // Add current as alternative to exist. $sitemapUrlFromList->addAlternateLink( new SitemapAlternateLink($sitemapUrl->getLoc(), $sitemapUrl->getLocale()) ); // Add others as alternative to current. $sitemapUrl->addAlternateLink( new SitemapAlternateLink($sitemapUrlFromList->getLoc(), $sitemapUrlFromList->getLocale()) ); } $sitemapUrlList[] = $sitemapUrl; return $sitemapUrlList; }
php
private function setAlternatives(array $sitemapUrlList, SitemapUrl $sitemapUrl) { foreach ($sitemapUrlList as $sitemapUrlFromList) { // Add current as alternative to exist. $sitemapUrlFromList->addAlternateLink( new SitemapAlternateLink($sitemapUrl->getLoc(), $sitemapUrl->getLocale()) ); // Add others as alternative to current. $sitemapUrl->addAlternateLink( new SitemapAlternateLink($sitemapUrlFromList->getLoc(), $sitemapUrlFromList->getLocale()) ); } $sitemapUrlList[] = $sitemapUrl; return $sitemapUrlList; }
[ "private", "function", "setAlternatives", "(", "array", "$", "sitemapUrlList", ",", "SitemapUrl", "$", "sitemapUrl", ")", "{", "foreach", "(", "$", "sitemapUrlList", "as", "$", "sitemapUrlFromList", ")", "{", "// Add current as alternative to exist.", "$", "sitemapUrl...
Set alternatives to sitemap url. @param SitemapUrl[] $sitemapUrlList @param SitemapUrl $sitemapUrl @return SitemapUrl[]
[ "Set", "alternatives", "to", "sitemap", "url", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Sitemap/ArticleSitemapProvider.php#L113-L130
train
sulu/SuluArticleBundle
Controller/ArticlePageController.php
ArticlePageController.deleteAction
public function deleteAction($articleUuid, $uuid, Request $request) { $locale = $this->getRequestParameter($request, 'locale', true); $documentManager = $this->getDocumentManager(); $document = $documentManager->find($uuid, $locale); $documentManager->remove($document); $documentManager->flush(); return $this->handleView($this->view(null)); }
php
public function deleteAction($articleUuid, $uuid, Request $request) { $locale = $this->getRequestParameter($request, 'locale', true); $documentManager = $this->getDocumentManager(); $document = $documentManager->find($uuid, $locale); $documentManager->remove($document); $documentManager->flush(); return $this->handleView($this->view(null)); }
[ "public", "function", "deleteAction", "(", "$", "articleUuid", ",", "$", "uuid", ",", "Request", "$", "request", ")", "{", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "true", ")", ";", "$", "...
Delete article-page. @param string $articleUuid @param string $uuid @param Request $request @return Response
[ "Delete", "article", "-", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticlePageController.php#L155-L165
train
sulu/SuluArticleBundle
Twig/ArticleViewDocumentTwigExtension.php
ArticleViewDocumentTwigExtension.loadRecent
public function loadRecent( $limit = ArticleViewDocumentRepository::DEFAULT_LIMIT, array $types = null, $locale = null, $ignoreWebspaces = false ) { $excludeUuid = null; /** @var Request $request */ $request = $this->requestStack->getCurrentRequest(); $articleDocument = $request->get('object'); if ($articleDocument instanceof ArticleDocument) { $excludeUuid = $articleDocument->getUuid(); if (!$types) { $types = [$this->getArticleType($articleDocument)]; } } if (!$locale) { $locale = $request->getLocale(); } $webspaceKey = $this->getWebspaceKey($request, $ignoreWebspaces); $articleViewDocuments = $this->articleViewDocumentRepository->findRecent( $excludeUuid, $limit, $types, $locale, $webspaceKey ); return $this->getResourceItems($articleViewDocuments); }
php
public function loadRecent( $limit = ArticleViewDocumentRepository::DEFAULT_LIMIT, array $types = null, $locale = null, $ignoreWebspaces = false ) { $excludeUuid = null; /** @var Request $request */ $request = $this->requestStack->getCurrentRequest(); $articleDocument = $request->get('object'); if ($articleDocument instanceof ArticleDocument) { $excludeUuid = $articleDocument->getUuid(); if (!$types) { $types = [$this->getArticleType($articleDocument)]; } } if (!$locale) { $locale = $request->getLocale(); } $webspaceKey = $this->getWebspaceKey($request, $ignoreWebspaces); $articleViewDocuments = $this->articleViewDocumentRepository->findRecent( $excludeUuid, $limit, $types, $locale, $webspaceKey ); return $this->getResourceItems($articleViewDocuments); }
[ "public", "function", "loadRecent", "(", "$", "limit", "=", "ArticleViewDocumentRepository", "::", "DEFAULT_LIMIT", ",", "array", "$", "types", "=", "null", ",", "$", "locale", "=", "null", ",", "$", "ignoreWebspaces", "=", "false", ")", "{", "$", "excludeUu...
Loads recent articles with given parameters. @param int $limit @param null|array $types @param null|string $locale @param bool $ignoreWebspaces @return ArticleResourceItem[]
[ "Loads", "recent", "articles", "with", "given", "parameters", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Twig/ArticleViewDocumentTwigExtension.php#L104-L139
train
sulu/SuluArticleBundle
Twig/ArticleViewDocumentTwigExtension.php
ArticleViewDocumentTwigExtension.loadSimilar
public function loadSimilar( $limit = ArticleViewDocumentRepository::DEFAULT_LIMIT, array $types = null, $locale = null, $ignoreWebspaces = false ) { $uuid = null; $request = $this->requestStack->getCurrentRequest(); $articleDocument = $request->get('object'); if ($articleDocument instanceof ArticleDocument) { $uuid = $articleDocument->getUuid(); if (!$types) { $types = [$this->getArticleType($articleDocument)]; } } if (!$uuid) { throw new ArticleInRequestNotFoundException(); } if (!$locale) { $locale = $request->getLocale(); } $webspaceKey = $this->getWebspaceKey($request, $ignoreWebspaces); $articleViewDocuments = $this->articleViewDocumentRepository->findSimilar( $uuid, $limit, $types, $locale, $webspaceKey ); return $this->getResourceItems($articleViewDocuments); }
php
public function loadSimilar( $limit = ArticleViewDocumentRepository::DEFAULT_LIMIT, array $types = null, $locale = null, $ignoreWebspaces = false ) { $uuid = null; $request = $this->requestStack->getCurrentRequest(); $articleDocument = $request->get('object'); if ($articleDocument instanceof ArticleDocument) { $uuid = $articleDocument->getUuid(); if (!$types) { $types = [$this->getArticleType($articleDocument)]; } } if (!$uuid) { throw new ArticleInRequestNotFoundException(); } if (!$locale) { $locale = $request->getLocale(); } $webspaceKey = $this->getWebspaceKey($request, $ignoreWebspaces); $articleViewDocuments = $this->articleViewDocumentRepository->findSimilar( $uuid, $limit, $types, $locale, $webspaceKey ); return $this->getResourceItems($articleViewDocuments); }
[ "public", "function", "loadSimilar", "(", "$", "limit", "=", "ArticleViewDocumentRepository", "::", "DEFAULT_LIMIT", ",", "array", "$", "types", "=", "null", ",", "$", "locale", "=", "null", ",", "$", "ignoreWebspaces", "=", "false", ")", "{", "$", "uuid", ...
Loads similar articles with given parameters. @param int $limit @param array|null $types @param null $locale @param bool $ignoreWebspaces @throws ArticleInRequestNotFoundException @return ArticleResourceItem[]
[ "Loads", "similar", "articles", "with", "given", "parameters", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Twig/ArticleViewDocumentTwigExtension.php#L153-L191
train
sulu/SuluArticleBundle
Routing/ArticleRouteEnhancer.php
ArticleRouteEnhancer.shouldAddCanonicalTag
private function shouldAddCanonicalTag(array $defaults, Request $request) { if (!array_key_exists('object', $defaults)) { return false; } $article = $defaults['object']; if (!$article instanceof ArticleInterface || !$article instanceof WebspaceBehavior) { return false; } $sulu = $request->get('_sulu'); if (!$sulu) { return false; } /** @var Webspace $webspace */ $webspace = $sulu->getAttribute('webspace'); if (!$webspace) { return false; } $additionalWebspaces = $this->webspaceResolver->resolveAdditionalWebspaces($article); if (!$additionalWebspaces || !in_array($webspace->getKey(), $additionalWebspaces)) { return false; } return true; }
php
private function shouldAddCanonicalTag(array $defaults, Request $request) { if (!array_key_exists('object', $defaults)) { return false; } $article = $defaults['object']; if (!$article instanceof ArticleInterface || !$article instanceof WebspaceBehavior) { return false; } $sulu = $request->get('_sulu'); if (!$sulu) { return false; } /** @var Webspace $webspace */ $webspace = $sulu->getAttribute('webspace'); if (!$webspace) { return false; } $additionalWebspaces = $this->webspaceResolver->resolveAdditionalWebspaces($article); if (!$additionalWebspaces || !in_array($webspace->getKey(), $additionalWebspaces)) { return false; } return true; }
[ "private", "function", "shouldAddCanonicalTag", "(", "array", "$", "defaults", ",", "Request", "$", "request", ")", "{", "if", "(", "!", "array_key_exists", "(", "'object'", ",", "$", "defaults", ")", ")", "{", "return", "false", ";", "}", "$", "article", ...
Checks if the enhancer should add an canonical tag to the route attributes. @param array $defaults @param Request $request @return bool
[ "Checks", "if", "the", "enhancer", "should", "add", "an", "canonical", "tag", "to", "the", "route", "attributes", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Routing/ArticleRouteEnhancer.php#L85-L113
train
sulu/SuluArticleBundle
PageTree/PageTreeRepository.php
PageTreeRepository.findLinkedArticles
private function findLinkedArticles($field, $value, $locale) { $where = []; foreach ($this->metadataFactory->getStructures('article') as $metadata) { $property = $this->getRoutePathPropertyName($metadata); if (null === $property || PageTreeRouteContentType::NAME !== $property->getType()) { continue; } $where[] = sprintf( '([%s] = "%s" AND [%s-%s] = "%s")', $this->propertyEncoder->localizedSystemName('template', $locale), $metadata->getName(), $this->propertyEncoder->localizedContentName($property->getName(), $locale), $field, $value ); } if (0 === count($where)) { return []; } $query = $this->documentManager->createQuery( sprintf( 'SELECT * FROM [nt:unstructured] WHERE [jcr:mixinTypes] = "sulu:article" AND (%s)', implode(' OR ', $where) ), $locale ); return $query->execute(); }
php
private function findLinkedArticles($field, $value, $locale) { $where = []; foreach ($this->metadataFactory->getStructures('article') as $metadata) { $property = $this->getRoutePathPropertyName($metadata); if (null === $property || PageTreeRouteContentType::NAME !== $property->getType()) { continue; } $where[] = sprintf( '([%s] = "%s" AND [%s-%s] = "%s")', $this->propertyEncoder->localizedSystemName('template', $locale), $metadata->getName(), $this->propertyEncoder->localizedContentName($property->getName(), $locale), $field, $value ); } if (0 === count($where)) { return []; } $query = $this->documentManager->createQuery( sprintf( 'SELECT * FROM [nt:unstructured] WHERE [jcr:mixinTypes] = "sulu:article" AND (%s)', implode(' OR ', $where) ), $locale ); return $query->execute(); }
[ "private", "function", "findLinkedArticles", "(", "$", "field", ",", "$", "value", ",", "$", "locale", ")", "{", "$", "where", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "metadataFactory", "->", "getStructures", "(", "'article'", ")", "as", ...
Find articles linked to the given page. @param string $field @param string $value @param string $locale @return ArticleInterface[]
[ "Find", "articles", "linked", "to", "the", "given", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/PageTree/PageTreeRepository.php#L104-L136
train
sulu/SuluArticleBundle
PageTree/PageTreeRepository.php
PageTreeRepository.updateArticle
private function updateArticle(ArticleDocument $article, BasePageDocument $document) { $locale = $document->getLocale(); $resourceSegment = $document->getResourceSegment(); $property = $this->getRoutePathPropertyNameByStructureType($article->getStructureType()); $propertyName = $this->propertyEncoder->localizedContentName($property->getName(), $locale); $node = $this->documentInspector->getNode($article); $node->setProperty($propertyName . '-page', $document->getUuid()); $node->setProperty($propertyName . '-page-path', $resourceSegment); $suffix = $node->getPropertyValueWithDefault($propertyName . '-suffix', null); if ($suffix) { $path = rtrim($resourceSegment, '/') . '/' . $suffix; $node->setProperty($propertyName, $path); $article->setRoutePath($path); } $workflowStage = $article->getWorkflowStage(); $this->documentManager->persist($article, $locale); if (WorkflowStage::PUBLISHED === $workflowStage) { $this->documentManager->publish($article, $locale); } }
php
private function updateArticle(ArticleDocument $article, BasePageDocument $document) { $locale = $document->getLocale(); $resourceSegment = $document->getResourceSegment(); $property = $this->getRoutePathPropertyNameByStructureType($article->getStructureType()); $propertyName = $this->propertyEncoder->localizedContentName($property->getName(), $locale); $node = $this->documentInspector->getNode($article); $node->setProperty($propertyName . '-page', $document->getUuid()); $node->setProperty($propertyName . '-page-path', $resourceSegment); $suffix = $node->getPropertyValueWithDefault($propertyName . '-suffix', null); if ($suffix) { $path = rtrim($resourceSegment, '/') . '/' . $suffix; $node->setProperty($propertyName, $path); $article->setRoutePath($path); } $workflowStage = $article->getWorkflowStage(); $this->documentManager->persist($article, $locale); if (WorkflowStage::PUBLISHED === $workflowStage) { $this->documentManager->publish($article, $locale); } }
[ "private", "function", "updateArticle", "(", "ArticleDocument", "$", "article", ",", "BasePageDocument", "$", "document", ")", "{", "$", "locale", "=", "$", "document", "->", "getLocale", "(", ")", ";", "$", "resourceSegment", "=", "$", "document", "->", "ge...
Update route of given article. @param ArticleDocument $article @param BasePageDocument $document
[ "Update", "route", "of", "given", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/PageTree/PageTreeRepository.php#L144-L169
train
sulu/SuluArticleBundle
Document/Subscriber/PageTreeRouteSubscriber.php
PageTreeRouteSubscriber.hasChangedResourceSegment
private function hasChangedResourceSegment(PageDocument $document) { $metadata = $this->metadataFactory->getStructureMetadata('page', $document->getStructureType()); $urlProperty = $metadata->getPropertyByTagName('sulu.rlp'); $urlPropertyName = $this->propertyEncoder->localizedContentName( $urlProperty->getName(), $document->getLocale() ); $liveNode = $this->getLiveNode($document); $url = $liveNode->getPropertyValueWithDefault($urlPropertyName, null); return $url && $url !== $document->getResourceSegment(); }
php
private function hasChangedResourceSegment(PageDocument $document) { $metadata = $this->metadataFactory->getStructureMetadata('page', $document->getStructureType()); $urlProperty = $metadata->getPropertyByTagName('sulu.rlp'); $urlPropertyName = $this->propertyEncoder->localizedContentName( $urlProperty->getName(), $document->getLocale() ); $liveNode = $this->getLiveNode($document); $url = $liveNode->getPropertyValueWithDefault($urlPropertyName, null); return $url && $url !== $document->getResourceSegment(); }
[ "private", "function", "hasChangedResourceSegment", "(", "PageDocument", "$", "document", ")", "{", "$", "metadata", "=", "$", "this", "->", "metadataFactory", "->", "getStructureMetadata", "(", "'page'", ",", "$", "document", "->", "getStructureType", "(", ")", ...
Returns true if the resource-segment was changed in the draft page. @param PageDocument $document @return bool
[ "Returns", "true", "if", "the", "resource", "-", "segment", "was", "changed", "in", "the", "draft", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageTreeRouteSubscriber.php#L143-L157
train
sulu/SuluArticleBundle
Document/Structure/ContentProxyFactory.php
ContentProxyFactory.createContentProxy
public function createContentProxy(StructureInterface $structure, array $data) { return $this->proxyFactory->createProxy( \ArrayObject::class, function ( &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer ) use ($structure, $data) { $initializer = null; $wrappedObject = new \ArrayObject($this->resolveContent($structure, $data)); return true; } ); }
php
public function createContentProxy(StructureInterface $structure, array $data) { return $this->proxyFactory->createProxy( \ArrayObject::class, function ( &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer ) use ($structure, $data) { $initializer = null; $wrappedObject = new \ArrayObject($this->resolveContent($structure, $data)); return true; } ); }
[ "public", "function", "createContentProxy", "(", "StructureInterface", "$", "structure", ",", "array", "$", "data", ")", "{", "return", "$", "this", "->", "proxyFactory", "->", "createProxy", "(", "\\", "ArrayObject", "::", "class", ",", "function", "(", "&", ...
Create content-proxy for given structure. @param StructureInterface $structure @param array $data @return array
[ "Create", "content", "-", "proxy", "for", "given", "structure", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Structure/ContentProxyFactory.php#L59-L76
train
sulu/SuluArticleBundle
Document/Structure/ContentProxyFactory.php
ContentProxyFactory.resolveContent
private function resolveContent(StructureInterface $structure, array $data) { $structure->setWebspaceKey($this->getWebspaceKey()); $content = []; foreach ($structure->getProperties(true) as $child) { if (array_key_exists($child->getName(), $data)) { $child->setValue($data[$child->getName()]); } $contentType = $this->contentTypeManager->get($child->getContentTypeName()); $content[$child->getName()] = $contentType->getContentData($child); } return $content; }
php
private function resolveContent(StructureInterface $structure, array $data) { $structure->setWebspaceKey($this->getWebspaceKey()); $content = []; foreach ($structure->getProperties(true) as $child) { if (array_key_exists($child->getName(), $data)) { $child->setValue($data[$child->getName()]); } $contentType = $this->contentTypeManager->get($child->getContentTypeName()); $content[$child->getName()] = $contentType->getContentData($child); } return $content; }
[ "private", "function", "resolveContent", "(", "StructureInterface", "$", "structure", ",", "array", "$", "data", ")", "{", "$", "structure", "->", "setWebspaceKey", "(", "$", "this", "->", "getWebspaceKey", "(", ")", ")", ";", "$", "content", "=", "[", "]"...
Resolve content from given data with the structure. @param StructureInterface $structure @param array $data @return array
[ "Resolve", "content", "from", "given", "data", "with", "the", "structure", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Structure/ContentProxyFactory.php#L86-L101
train
sulu/SuluArticleBundle
Document/Structure/ContentProxyFactory.php
ContentProxyFactory.createViewProxy
public function createViewProxy(StructureInterface $structure, array $data) { return $this->proxyFactory->createProxy( \ArrayObject::class, function ( &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer ) use ($structure, $data) { $initializer = null; $wrappedObject = new \ArrayObject($this->resolveView($structure, $data)); return true; } ); }
php
public function createViewProxy(StructureInterface $structure, array $data) { return $this->proxyFactory->createProxy( \ArrayObject::class, function ( &$wrappedObject, LazyLoadingInterface $proxy, $method, array $parameters, &$initializer ) use ($structure, $data) { $initializer = null; $wrappedObject = new \ArrayObject($this->resolveView($structure, $data)); return true; } ); }
[ "public", "function", "createViewProxy", "(", "StructureInterface", "$", "structure", ",", "array", "$", "data", ")", "{", "return", "$", "this", "->", "proxyFactory", "->", "createProxy", "(", "\\", "ArrayObject", "::", "class", ",", "function", "(", "&", "...
Create view-proxy for given structure. @param StructureInterface $structure @param array $data @return array
[ "Create", "view", "-", "proxy", "for", "given", "structure", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Structure/ContentProxyFactory.php#L111-L128
train
sulu/SuluArticleBundle
Document/Structure/ContentProxyFactory.php
ContentProxyFactory.resolveView
private function resolveView(StructureInterface $structure, array $data) { $structure->setWebspaceKey($this->getWebspaceKey()); $view = []; foreach ($structure->getProperties(true) as $child) { if (array_key_exists($child->getName(), $data)) { $child->setValue($data[$child->getName()]); } $contentType = $this->contentTypeManager->get($child->getContentTypeName()); $view[$child->getName()] = $contentType->getViewData($child); } return $view; }
php
private function resolveView(StructureInterface $structure, array $data) { $structure->setWebspaceKey($this->getWebspaceKey()); $view = []; foreach ($structure->getProperties(true) as $child) { if (array_key_exists($child->getName(), $data)) { $child->setValue($data[$child->getName()]); } $contentType = $this->contentTypeManager->get($child->getContentTypeName()); $view[$child->getName()] = $contentType->getViewData($child); } return $view; }
[ "private", "function", "resolveView", "(", "StructureInterface", "$", "structure", ",", "array", "$", "data", ")", "{", "$", "structure", "->", "setWebspaceKey", "(", "$", "this", "->", "getWebspaceKey", "(", ")", ")", ";", "$", "view", "=", "[", "]", ";...
Resolve view from given data with the structure. @param StructureInterface $structure @param array $data @return array
[ "Resolve", "view", "from", "given", "data", "with", "the", "structure", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Structure/ContentProxyFactory.php#L138-L153
train
sulu/SuluArticleBundle
Builder/ArticleIndexBuilder.php
ArticleIndexBuilder.buildForManager
private function buildForManager(Manager $manager, $destroy) { $name = $manager->getName(); if (!$manager->indexExists()) { $this->output->writeln(sprintf('Create index for "<comment>%s</comment>" manager.', $name)); $manager->createIndex(); return; } if (!$destroy) { return; } $this->output->writeln(sprintf('Drop and create index for "<comment>%s</comment>" manager.', $name)); $manager->dropAndCreateIndex(); }
php
private function buildForManager(Manager $manager, $destroy) { $name = $manager->getName(); if (!$manager->indexExists()) { $this->output->writeln(sprintf('Create index for "<comment>%s</comment>" manager.', $name)); $manager->createIndex(); return; } if (!$destroy) { return; } $this->output->writeln(sprintf('Drop and create index for "<comment>%s</comment>" manager.', $name)); $manager->dropAndCreateIndex(); }
[ "private", "function", "buildForManager", "(", "Manager", "$", "manager", ",", "$", "destroy", ")", "{", "$", "name", "=", "$", "manager", "->", "getName", "(", ")", ";", "if", "(", "!", "$", "manager", "->", "indexExists", "(", ")", ")", "{", "$", ...
Build index for given manager. If index not exists - it will be created. If index exists and destroy flag is true - drop and create index. Else do nothing. @param Manager $manager @param bool $destroy
[ "Build", "index", "for", "given", "manager", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Builder/ArticleIndexBuilder.php#L57-L73
train
sulu/SuluArticleBundle
Metadata/PageTreeTrait.php
PageTreeTrait.getRoutePathProperty
private function getRoutePathProperty(StructureMetadata $metadata) { if ($metadata->hasTag(RoutableSubscriber::TAG_NAME)) { return $metadata->getPropertyByTagName(RoutableSubscriber::TAG_NAME); } if (!$metadata->hasProperty(RoutableSubscriber::ROUTE_FIELD)) { return null; } return $metadata->getProperty(RoutableSubscriber::ROUTE_FIELD); }
php
private function getRoutePathProperty(StructureMetadata $metadata) { if ($metadata->hasTag(RoutableSubscriber::TAG_NAME)) { return $metadata->getPropertyByTagName(RoutableSubscriber::TAG_NAME); } if (!$metadata->hasProperty(RoutableSubscriber::ROUTE_FIELD)) { return null; } return $metadata->getProperty(RoutableSubscriber::ROUTE_FIELD); }
[ "private", "function", "getRoutePathProperty", "(", "StructureMetadata", "$", "metadata", ")", "{", "if", "(", "$", "metadata", "->", "hasTag", "(", "RoutableSubscriber", "::", "TAG_NAME", ")", ")", "{", "return", "$", "metadata", "->", "getPropertyByTagName", "...
Returns property-metadata for route-path property. @param StructureMetadata $metadata @return null|PropertyMetadata
[ "Returns", "property", "-", "metadata", "for", "route", "-", "path", "property", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Metadata/PageTreeTrait.php#L68-L79
train
sulu/SuluArticleBundle
Document/Index/Factory/CategoryCollectionFactory.php
CategoryCollectionFactory.create
public function create($categoryIds, $locale) { if (empty($categoryIds)) { return new Collection(); } // Load category with keywords $queryBuilder = $this->categoryRepository->createQueryBuilder('category') ->select(['category.id', 'category.key', 'translate.translation as name', 'keyword.keyword']) ->leftJoin('category.translations', 'translate', Join::WITH, 'translate.locale = :locale') ->setParameter('locale', $locale) ->leftJoin('translate.keywords', 'keyword'); $queryBuilder->where($queryBuilder->expr()->in('category.id', $categoryIds)); $categories = []; foreach ($queryBuilder->getQuery()->getResult() as $categoryData) { $id = (int) $categoryData['id']; if (!isset($categories[$id])) { $categories[$id] = new CategoryViewObject(); $categories[$id]->id = $id; $categories[$id]->key = $categoryData['key']; $categories[$id]->name = $categoryData['name']; } $categories[$id]->keywords[] = $categoryData['keyword']; } return new Collection(array_values($categories)); }
php
public function create($categoryIds, $locale) { if (empty($categoryIds)) { return new Collection(); } // Load category with keywords $queryBuilder = $this->categoryRepository->createQueryBuilder('category') ->select(['category.id', 'category.key', 'translate.translation as name', 'keyword.keyword']) ->leftJoin('category.translations', 'translate', Join::WITH, 'translate.locale = :locale') ->setParameter('locale', $locale) ->leftJoin('translate.keywords', 'keyword'); $queryBuilder->where($queryBuilder->expr()->in('category.id', $categoryIds)); $categories = []; foreach ($queryBuilder->getQuery()->getResult() as $categoryData) { $id = (int) $categoryData['id']; if (!isset($categories[$id])) { $categories[$id] = new CategoryViewObject(); $categories[$id]->id = $id; $categories[$id]->key = $categoryData['key']; $categories[$id]->name = $categoryData['name']; } $categories[$id]->keywords[] = $categoryData['keyword']; } return new Collection(array_values($categories)); }
[ "public", "function", "create", "(", "$", "categoryIds", ",", "$", "locale", ")", "{", "if", "(", "empty", "(", "$", "categoryIds", ")", ")", "{", "return", "new", "Collection", "(", ")", ";", "}", "// Load category with keywords", "$", "queryBuilder", "="...
Create category collection. @param int[] $categoryIds @param string $locale @return Collection
[ "Create", "category", "collection", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/Factory/CategoryCollectionFactory.php#L47-L78
train