id
int32
0
241k
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
43,400
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
43,401
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
43,402
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
43,403
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
43,404
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
43,405
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
43,406
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
43,407
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
43,408
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
43,409
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
43,410
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
43,411
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
43,412
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
43,413
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
43,414
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
43,415
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
43,416
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
43,417
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
43,418
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
43,419
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
43,420
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
43,421
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
43,422
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
43,423
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
43,424
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
43,425
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
43,426
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
43,427
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
43,428
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
43,429
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
43,430
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
43,431
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
43,432
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
43,433
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
43,434
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
43,435
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
43,436
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
43,437
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
43,438
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
43,439
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
43,440
sulu/SuluArticleBundle
Controller/TemplateController.php
TemplateController.getAction
public function getAction(Request $request) { $structureProvider = $this->get('sulu.content.structure_manager'); $type = $request->get('type', 'default'); $templates = []; foreach ($structureProvider->getStructures('article') as $structure) { if ($this->getType($structure->getStructure()) !== $type) { continue; } $templates[] = [ 'internal' => $structure->getInternal(), 'template' => $structure->getKey(), 'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()), ]; } return new JsonResponse( [ '_embedded' => $templates, 'total' => count($templates), ] ); }
php
public function getAction(Request $request) { $structureProvider = $this->get('sulu.content.structure_manager'); $type = $request->get('type', 'default'); $templates = []; foreach ($structureProvider->getStructures('article') as $structure) { if ($this->getType($structure->getStructure()) !== $type) { continue; } $templates[] = [ 'internal' => $structure->getInternal(), 'template' => $structure->getKey(), 'title' => $structure->getLocalizedTitle($this->getUser()->getLocale()), ]; } return new JsonResponse( [ '_embedded' => $templates, 'total' => count($templates), ] ); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ")", "{", "$", "structureProvider", "=", "$", "this", "->", "get", "(", "'sulu.content.structure_manager'", ")", ";", "$", "type", "=", "$", "request", "->", "get", "(", "'type'", ",", "'de...
Returns template for given article type. @param Request $request @return JsonResponse
[ "Returns", "template", "for", "given", "article", "type", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/TemplateController.php#L34-L58
43,441
sulu/SuluArticleBundle
Document/Serializer/ArticleWebsiteSubscriber.php
ArticleWebsiteSubscriber.appendPageData
public function appendPageData(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if ($article instanceof ArticlePageDocument) { $article = $article->getParent(); } if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website')) { return; } $pageNumber = 1; if ($context->attributes->containsKey('pageNumber')) { $pageNumber = $context->attributes->get('pageNumber')->get(); } $visitor->addData('page', $pageNumber); $visitor->addData('pages', $context->accept($article->getPages())); }
php
public function appendPageData(ObjectEvent $event) { $article = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if ($article instanceof ArticlePageDocument) { $article = $article->getParent(); } if (!$article instanceof ArticleDocument || !$context->attributes->containsKey('website')) { return; } $pageNumber = 1; if ($context->attributes->containsKey('pageNumber')) { $pageNumber = $context->attributes->get('pageNumber')->get(); } $visitor->addData('page', $pageNumber); $visitor->addData('pages', $context->accept($article->getPages())); }
[ "public", "function", "appendPageData", "(", "ObjectEvent", "$", "event", ")", "{", "$", "article", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "context", "=", "$", "...
Append page data. @param ObjectEvent $event
[ "Append", "page", "data", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleWebsiteSubscriber.php#L115-L136
43,442
sulu/SuluArticleBundle
Document/Serializer/ArticleWebsiteSubscriber.php
ArticleWebsiteSubscriber.getArticleForPage
private function getArticleForPage(ArticleDocument $article, $pageNumber) { $children = $article->getChildren(); if (null === $children || 1 === $pageNumber) { return $article; } foreach ($children as $child) { if ($child instanceof ArticlePageDocument && $child->getPageNumber() === $pageNumber) { return $child; } } return $article; }
php
private function getArticleForPage(ArticleDocument $article, $pageNumber) { $children = $article->getChildren(); if (null === $children || 1 === $pageNumber) { return $article; } foreach ($children as $child) { if ($child instanceof ArticlePageDocument && $child->getPageNumber() === $pageNumber) { return $child; } } return $article; }
[ "private", "function", "getArticleForPage", "(", "ArticleDocument", "$", "article", ",", "$", "pageNumber", ")", "{", "$", "children", "=", "$", "article", "->", "getChildren", "(", ")", ";", "if", "(", "null", "===", "$", "children", "||", "1", "===", "...
Returns article page by page-number. @param ArticleDocument $article @param int $pageNumber @return ArticleDocument
[ "Returns", "article", "page", "by", "page", "-", "number", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleWebsiteSubscriber.php#L171-L185
43,443
sulu/SuluArticleBundle
Document/Serializer/ArticleWebsiteSubscriber.php
ArticleWebsiteSubscriber.resolve
private function resolve(ArticleInterface $article) { $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $structure->setDocument($article); $data = $article->getStructure()->toArray(); return [ 'content' => $this->contentProxyFactory->createContentProxy($structure, $data), 'view' => $this->contentProxyFactory->createViewProxy($structure, $data), ]; }
php
private function resolve(ArticleInterface $article) { $structure = $this->structureManager->getStructure($article->getStructureType(), 'article'); $structure->setDocument($article); $data = $article->getStructure()->toArray(); return [ 'content' => $this->contentProxyFactory->createContentProxy($structure, $data), 'view' => $this->contentProxyFactory->createViewProxy($structure, $data), ]; }
[ "private", "function", "resolve", "(", "ArticleInterface", "$", "article", ")", "{", "$", "structure", "=", "$", "this", "->", "structureManager", "->", "getStructure", "(", "$", "article", "->", "getStructureType", "(", ")", ",", "'article'", ")", ";", "$",...
Returns content and view of article. @param ArticleInterface $article @return array
[ "Returns", "content", "and", "view", "of", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticleWebsiteSubscriber.php#L215-L226
43,444
sulu/SuluArticleBundle
Document/Index/Factory/TagCollectionFactory.php
TagCollectionFactory.create
public function create($tagNames) { $collection = new Collection(); foreach ($tagNames as $tagName) { $tagEntity = $this->tagManager->findByName($tagName); if (!$tagEntity) { return; } $tag = new TagViewObject(); $tag->name = $tagName; $tag->id = $tagEntity->getId(); $collection[] = $tag; } return $collection; }
php
public function create($tagNames) { $collection = new Collection(); foreach ($tagNames as $tagName) { $tagEntity = $this->tagManager->findByName($tagName); if (!$tagEntity) { return; } $tag = new TagViewObject(); $tag->name = $tagName; $tag->id = $tagEntity->getId(); $collection[] = $tag; } return $collection; }
[ "public", "function", "create", "(", "$", "tagNames", ")", "{", "$", "collection", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "tagNames", "as", "$", "tagName", ")", "{", "$", "tagEntity", "=", "$", "this", "->", "tagManager", "->", ...
Create tag collection. @param string[] $tagNames @return Collection
[ "Create", "tag", "collection", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Index/Factory/TagCollectionFactory.php#L45-L64
43,445
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.dropIndex
protected function dropIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('drop')) { return true; } if (!$input->getOption('no-interaction')) { $output->writeln( '<comment>ATTENTION</comment>: This operation drops and recreates the whole index and deletes the complete data.' ); $output->writeln(''); $question = new ConfirmationQuestion('Are you sure you want to drop the index? [Y/n] '); /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); if (!$questionHelper->ask($input, $output, $question)) { return false; } $output->writeln(''); } $indexer->dropIndex(); $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln( sprintf('Dropped and recreated index for the <comment>`%s`</comment> context' . PHP_EOL, $context) ); return true; }
php
protected function dropIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('drop')) { return true; } if (!$input->getOption('no-interaction')) { $output->writeln( '<comment>ATTENTION</comment>: This operation drops and recreates the whole index and deletes the complete data.' ); $output->writeln(''); $question = new ConfirmationQuestion('Are you sure you want to drop the index? [Y/n] '); /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); if (!$questionHelper->ask($input, $output, $question)) { return false; } $output->writeln(''); } $indexer->dropIndex(); $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln( sprintf('Dropped and recreated index for the <comment>`%s`</comment> context' . PHP_EOL, $context) ); return true; }
[ "protected", "function", "dropIndex", "(", "IndexerInterface", "$", "indexer", ",", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "!", "$", "input", "->", "getOption", "(", "'drop'", ")", ")", "{", "return", "t...
Drop index if requested. @param IndexerInterface $indexer @param InputInterface $input @param OutputInterface $output @return bool
[ "Drop", "index", "if", "requested", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L98-L129
43,446
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.clearIndex
protected function clearIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('clear')) { return; } $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln(sprintf('Cleared index for the <comment>`%s`</comment> context', $context)); $indexer->clear(); }
php
protected function clearIndex(IndexerInterface $indexer, InputInterface $input, OutputInterface $output) { if (!$input->getOption('clear')) { return; } $context = $this->getContainer()->getParameter('sulu.context'); $output->writeln(sprintf('Cleared index for the <comment>`%s`</comment> context', $context)); $indexer->clear(); }
[ "protected", "function", "clearIndex", "(", "IndexerInterface", "$", "indexer", ",", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "!", "$", "input", "->", "getOption", "(", "'clear'", ")", ")", "{", "return", ...
Clear article-content of index. @param IndexerInterface $indexer @param InputInterface $input @param OutputInterface $output
[ "Clear", "article", "-", "content", "of", "index", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L138-L147
43,447
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.indexDocuments
protected function indexDocuments($locale, IndexerInterface $indexer, OutputInterface $output) { $documents = $this->getDocuments($locale); $count = count($documents); if (0 === $count) { $output->writeln(' No documents found'); return; } $progessBar = new ProgressBar($output, $count); $progessBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'); $progessBar->start(); foreach ($documents as $document) { $indexer->index($document); $progessBar->advance(); } $indexer->flush(); $progessBar->finish(); }
php
protected function indexDocuments($locale, IndexerInterface $indexer, OutputInterface $output) { $documents = $this->getDocuments($locale); $count = count($documents); if (0 === $count) { $output->writeln(' No documents found'); return; } $progessBar = new ProgressBar($output, $count); $progessBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%'); $progessBar->start(); foreach ($documents as $document) { $indexer->index($document); $progessBar->advance(); } $indexer->flush(); $progessBar->finish(); }
[ "protected", "function", "indexDocuments", "(", "$", "locale", ",", "IndexerInterface", "$", "indexer", ",", "OutputInterface", "$", "output", ")", "{", "$", "documents", "=", "$", "this", "->", "getDocuments", "(", "$", "locale", ")", ";", "$", "count", "...
Index documents for given locale. @param string $locale @param IndexerInterface $indexer @param OutputInterface $output
[ "Index", "documents", "for", "given", "locale", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L156-L177
43,448
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.getDocuments
protected function getDocuments($locale) { $propertyEncoder = $this->getContainer()->get('sulu_document_manager.property_encoder'); $documentManager = $this->getContainer()->get('sulu_document_manager.document_manager'); $sql2 = sprintf( 'SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "sulu:article" AND [%s] IS NOT NULL', $propertyEncoder->localizedSystemName('template', $locale) ); return $documentManager->createQuery($sql2, $locale, ['load_ghost_content' => false])->execute(); }
php
protected function getDocuments($locale) { $propertyEncoder = $this->getContainer()->get('sulu_document_manager.property_encoder'); $documentManager = $this->getContainer()->get('sulu_document_manager.document_manager'); $sql2 = sprintf( 'SELECT * FROM [nt:unstructured] AS a WHERE [jcr:mixinTypes] = "sulu:article" AND [%s] IS NOT NULL', $propertyEncoder->localizedSystemName('template', $locale) ); return $documentManager->createQuery($sql2, $locale, ['load_ghost_content' => false])->execute(); }
[ "protected", "function", "getDocuments", "(", "$", "locale", ")", "{", "$", "propertyEncoder", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'sulu_document_manager.property_encoder'", ")", ";", "$", "documentManager", "=", "$", "this", "...
Query for documents with given locale. @param string $locale @return QueryResultInterface
[ "Query", "for", "documents", "with", "given", "locale", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L186-L197
43,449
sulu/SuluArticleBundle
Command/ReindexCommand.php
ReindexCommand.humanBytes
protected function humanBytes($bytes, $dec = 2) { $size = ['b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = (int) floor((strlen($bytes) - 1) / 3); return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . $size[$factor]; }
php
protected function humanBytes($bytes, $dec = 2) { $size = ['b', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = (int) floor((strlen($bytes) - 1) / 3); return sprintf("%.{$dec}f", $bytes / pow(1024, $factor)) . $size[$factor]; }
[ "protected", "function", "humanBytes", "(", "$", "bytes", ",", "$", "dec", "=", "2", ")", "{", "$", "size", "=", "[", "'b'", ",", "'kB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", ",", "'PB'", ",", "'EB'", ",", "'ZB'", ",", "'YB'", "]", ";", "$", ...
Converts bytes into human readable. Inspired by http://jeffreysambells.com/2012/10/25/human-readable-filesize-php @param int $bytes @param int $dec @return string
[ "Converts", "bytes", "into", "human", "readable", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Command/ReindexCommand.php#L209-L215
43,450
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.getFieldDescriptors
protected function getFieldDescriptors() { return [ 'uuid' => ElasticSearchFieldDescriptor::create('id', 'public.id') ->setDisabled(true) ->build(), 'typeTranslation' => ElasticSearchFieldDescriptor::create('typeTranslation', 'sulu_article.list.type') ->setSortField('typeTranslation.raw') ->setDisabled(!$this->getParameter('sulu_article.display_tab_all')) ->build(), 'title' => ElasticSearchFieldDescriptor::create('title', 'public.title') ->setSortField('title.raw') ->build(), 'creatorFullName' => ElasticSearchFieldDescriptor::create('creatorFullName', 'sulu_article.list.creator') ->setSortField('creatorFullName.raw') ->build(), 'changerFullName' => ElasticSearchFieldDescriptor::create('changerFullName', 'sulu_article.list.changer') ->setSortField('changerFullName.raw') ->build(), 'authorFullName' => ElasticSearchFieldDescriptor::create('authorFullName', 'sulu_article.author') ->setSortField('authorFullName.raw') ->build(), 'created' => ElasticSearchFieldDescriptor::create('created', 'public.created') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'changed' => ElasticSearchFieldDescriptor::create('changed', 'public.changed') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'authored' => ElasticSearchFieldDescriptor::create('authored', 'sulu_article.authored') ->setSortField('authored') ->setType('datetime') ->build(), 'localizationState' => ElasticSearchFieldDescriptor::create('localizationState') ->setDisabled(true) ->build(), 'published' => ElasticSearchFieldDescriptor::create('published') ->setDisabled(true) ->build(), 'publishedState' => ElasticSearchFieldDescriptor::create('publishedState') ->setDisabled(true) ->build(), 'routePath' => ElasticSearchFieldDescriptor::create('routePath') ->setDisabled(true) ->build(), ]; }
php
protected function getFieldDescriptors() { return [ 'uuid' => ElasticSearchFieldDescriptor::create('id', 'public.id') ->setDisabled(true) ->build(), 'typeTranslation' => ElasticSearchFieldDescriptor::create('typeTranslation', 'sulu_article.list.type') ->setSortField('typeTranslation.raw') ->setDisabled(!$this->getParameter('sulu_article.display_tab_all')) ->build(), 'title' => ElasticSearchFieldDescriptor::create('title', 'public.title') ->setSortField('title.raw') ->build(), 'creatorFullName' => ElasticSearchFieldDescriptor::create('creatorFullName', 'sulu_article.list.creator') ->setSortField('creatorFullName.raw') ->build(), 'changerFullName' => ElasticSearchFieldDescriptor::create('changerFullName', 'sulu_article.list.changer') ->setSortField('changerFullName.raw') ->build(), 'authorFullName' => ElasticSearchFieldDescriptor::create('authorFullName', 'sulu_article.author') ->setSortField('authorFullName.raw') ->build(), 'created' => ElasticSearchFieldDescriptor::create('created', 'public.created') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'changed' => ElasticSearchFieldDescriptor::create('changed', 'public.changed') ->setSortField('authored') ->setType('datetime') ->setDisabled(true) ->build(), 'authored' => ElasticSearchFieldDescriptor::create('authored', 'sulu_article.authored') ->setSortField('authored') ->setType('datetime') ->build(), 'localizationState' => ElasticSearchFieldDescriptor::create('localizationState') ->setDisabled(true) ->build(), 'published' => ElasticSearchFieldDescriptor::create('published') ->setDisabled(true) ->build(), 'publishedState' => ElasticSearchFieldDescriptor::create('publishedState') ->setDisabled(true) ->build(), 'routePath' => ElasticSearchFieldDescriptor::create('routePath') ->setDisabled(true) ->build(), ]; }
[ "protected", "function", "getFieldDescriptors", "(", ")", "{", "return", "[", "'uuid'", "=>", "ElasticSearchFieldDescriptor", "::", "create", "(", "'id'", ",", "'public.id'", ")", "->", "setDisabled", "(", "true", ")", "->", "build", "(", ")", ",", "'typeTrans...
Create field-descriptor array. @return ElasticSearchFieldDescriptor[]
[ "Create", "field", "-", "descriptor", "array", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L62-L111
43,451
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.cgetFieldsAction
public function cgetFieldsAction() { $fieldDescriptors = $this->getFieldDescriptors(); return $this->handleView($this->view(array_values($fieldDescriptors))); }
php
public function cgetFieldsAction() { $fieldDescriptors = $this->getFieldDescriptors(); return $this->handleView($this->view(array_values($fieldDescriptors))); }
[ "public", "function", "cgetFieldsAction", "(", ")", "{", "$", "fieldDescriptors", "=", "$", "this", "->", "getFieldDescriptors", "(", ")", ";", "return", "$", "this", "->", "handleView", "(", "$", "this", "->", "view", "(", "array_values", "(", "$", "field...
Returns fields. @return Response
[ "Returns", "fields", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L118-L123
43,452
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.getAction
public function getAction($uuid, Request $request) { $locale = $this->getRequestParameter($request, 'locale', true); $document = $this->getDocumentManager()->find( $uuid, $locale ); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
php
public function getAction($uuid, Request $request) { $locale = $this->getRequestParameter($request, 'locale', true); $document = $this->getDocumentManager()->find( $uuid, $locale ); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
[ "public", "function", "getAction", "(", "$", "uuid", ",", "Request", "$", "request", ")", "{", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "true", ")", ";", "$", "document", "=", "$", "this",...
Returns single article. @param string $uuid @param Request $request @return Response
[ "Returns", "single", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L313-L328
43,453
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.postAction
public function postAction(Request $request) { $action = $request->get('action'); $document = $this->getDocumentManager()->create(self::DOCUMENT_TYPE); $locale = $this->getRequestParameter($request, 'locale', true); $data = $request->request->all(); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
php
public function postAction(Request $request) { $action = $request->get('action'); $document = $this->getDocumentManager()->create(self::DOCUMENT_TYPE); $locale = $this->getRequestParameter($request, 'locale', true); $data = $request->request->all(); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
[ "public", "function", "postAction", "(", "Request", "$", "request", ")", "{", "$", "action", "=", "$", "request", "->", "get", "(", "'action'", ")", ";", "$", "document", "=", "$", "this", "->", "getDocumentManager", "(", ")", "->", "create", "(", "sel...
Create article. @param Request $request @return Response
[ "Create", "article", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L337-L355
43,454
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.putAction
public function putAction(Request $request, $uuid) { $locale = $this->getRequestParameter($request, 'locale', true); $action = $request->get('action'); $data = $request->request->all(); $document = $this->getDocumentManager()->find( $uuid, $locale, [ 'load_ghost_content' => false, 'load_shadow_content' => false, ] ); $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid()); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
php
public function putAction(Request $request, $uuid) { $locale = $this->getRequestParameter($request, 'locale', true); $action = $request->get('action'); $data = $request->request->all(); $document = $this->getDocumentManager()->find( $uuid, $locale, [ 'load_ghost_content' => false, 'load_shadow_content' => false, ] ); $this->get('sulu_hash.request_hash_checker')->checkHash($request, $document, $document->getUuid()); $this->persistDocument($data, $document, $locale); $this->handleActionParameter($action, $document, $locale); $this->getDocumentManager()->flush(); return $this->handleView( $this->view($document)->setSerializationContext( SerializationContext::create() ->setSerializeNull(true) ->setGroups(['defaultPage', 'defaultArticle', 'smallArticlePage']) ) ); }
[ "public", "function", "putAction", "(", "Request", "$", "request", ",", "$", "uuid", ")", "{", "$", "locale", "=", "$", "this", "->", "getRequestParameter", "(", "$", "request", ",", "'locale'", ",", "true", ")", ";", "$", "action", "=", "$", "request"...
Update articles. @param Request $request @param string $uuid @return Response
[ "Update", "articles", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L365-L393
43,455
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.orderPages
private function orderPages(array $pages, $locale) { $documentManager = $this->getDocumentManager(); for ($i = 0; $i < count($pages); ++$i) { $document = $documentManager->find($pages[$i], $locale); $documentManager->reorder($document, null); } }
php
private function orderPages(array $pages, $locale) { $documentManager = $this->getDocumentManager(); for ($i = 0; $i < count($pages); ++$i) { $document = $documentManager->find($pages[$i], $locale); $documentManager->reorder($document, null); } }
[ "private", "function", "orderPages", "(", "array", "$", "pages", ",", "$", "locale", ")", "{", "$", "documentManager", "=", "$", "this", "->", "getDocumentManager", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$...
Ordering given pages. @param array $pages @param string $locale
[ "Ordering", "given", "pages", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L528-L536
43,456
sulu/SuluArticleBundle
Controller/ArticleController.php
ArticleController.persistDocument
private function persistDocument($data, $document, $locale) { $formType = $this->getMetadataFactory()->getMetadataForAlias('article')->getFormType(); $form = $this->createForm( $formType, $document, [ // disable csrf protection, since we can't produce a token, because the form is cached on the client 'csrf_protection' => false, ] ); $form->submit($data, false); if (!$form->isValid()) { throw new InvalidFormException($form); } if (array_key_exists('author', $data) && null === $data['author']) { $document->setAuthor(null); } if (array_key_exists('additionalWebspaces', $data) && null === $data['additionalWebspaces']) { $document->setAdditionalWebspaces(null); } $this->getDocumentManager()->persist( $document, $locale, [ 'user' => $this->getUser()->getId(), 'clear_missing_content' => false, ] ); }
php
private function persistDocument($data, $document, $locale) { $formType = $this->getMetadataFactory()->getMetadataForAlias('article')->getFormType(); $form = $this->createForm( $formType, $document, [ // disable csrf protection, since we can't produce a token, because the form is cached on the client 'csrf_protection' => false, ] ); $form->submit($data, false); if (!$form->isValid()) { throw new InvalidFormException($form); } if (array_key_exists('author', $data) && null === $data['author']) { $document->setAuthor(null); } if (array_key_exists('additionalWebspaces', $data) && null === $data['additionalWebspaces']) { $document->setAdditionalWebspaces(null); } $this->getDocumentManager()->persist( $document, $locale, [ 'user' => $this->getUser()->getId(), 'clear_missing_content' => false, ] ); }
[ "private", "function", "persistDocument", "(", "$", "data", ",", "$", "document", ",", "$", "locale", ")", "{", "$", "formType", "=", "$", "this", "->", "getMetadataFactory", "(", ")", "->", "getMetadataForAlias", "(", "'article'", ")", "->", "getFormType", ...
Persists the document using the given Formation. @param array $data @param object $document @param string $locale @throws InvalidFormException @throws MissingParameterException
[ "Persists", "the", "document", "using", "the", "given", "Formation", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/ArticleController.php#L556-L589
43,457
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleHydrate
public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior || !$node->hasProperty($propertyName)) { return; } $node = $event->getNode(); $document->setPageNumber($node->getPropertyValue($this->propertyEncoder->systemName(static::FIELD))); }
php
public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior || !$node->hasProperty($propertyName)) { return; } $node = $event->getNode(); $document->setPageNumber($node->getPropertyValue($this->propertyEncoder->systemName(static::FIELD))); }
[ "public", "function", "handleHydrate", "(", "HydrateEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "propertyName", "=", "$", ...
Set the page-number to existing pages. @param HydrateEvent $event
[ "Set", "the", "page", "-", "number", "to", "existing", "pages", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L85-L96
43,458
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handlePersist
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $parentDocument = $document->getParent(); $page = 1; foreach ($parentDocument->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } ++$page; if ($child === $document) { break; } } $node->setProperty($propertyName, $page); $document->setPageNumber($page); }
php
public function handlePersist(PersistEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $parentDocument = $document->getParent(); $page = 1; foreach ($parentDocument->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } ++$page; if ($child === $document) { break; } } $node->setProperty($propertyName, $page); $document->setPageNumber($page); }
[ "public", "function", "handlePersist", "(", "PersistEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "propertyName", "=", "$", ...
Set the page-number to new pages. @param PersistEvent $event
[ "Set", "the", "page", "-", "number", "to", "new", "pages", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L103-L129
43,459
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleReorder
public function handleReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $propertyName = $this->propertyEncoder->systemName(static::FIELD); $parentNode = $this->documentInspector->getNode($document->getParent()); $page = 1; foreach ($parentNode->getNodes() as $childNode) { $child = $this->documentManager->find($childNode->getIdentifier(), $event->getLocale()); if (!$child instanceof PageBehavior) { continue; } $childNode->setProperty($propertyName, ++$page); $child->setPageNumber($page); } }
php
public function handleReorder(ReorderEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $propertyName = $this->propertyEncoder->systemName(static::FIELD); $parentNode = $this->documentInspector->getNode($document->getParent()); $page = 1; foreach ($parentNode->getNodes() as $childNode) { $child = $this->documentManager->find($childNode->getIdentifier(), $event->getLocale()); if (!$child instanceof PageBehavior) { continue; } $childNode->setProperty($propertyName, ++$page); $child->setPageNumber($page); } }
[ "public", "function", "handleReorder", "(", "ReorderEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "PageBehavior", ")", "{", "return", ";", "}", "$", ...
Adjust the page-numbers of siblings when reordering a page. @param ReorderEvent $event
[ "Adjust", "the", "page", "-", "numbers", "of", "siblings", "when", "reordering", "a", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L136-L156
43,460
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handlePublishPageNumber
public function handlePublishPageNumber(PublishEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $node->setProperty($propertyName, $document->getPageNumber()); }
php
public function handlePublishPageNumber(PublishEvent $event) { $document = $event->getDocument(); $node = $event->getNode(); $propertyName = $this->propertyEncoder->systemName(static::FIELD); if (!$document instanceof PageBehavior) { return; } $node->setProperty($propertyName, $document->getPageNumber()); }
[ "public", "function", "handlePublishPageNumber", "(", "PublishEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "propertyName", "="...
Copy page-number to live workspace. @param PublishEvent $event
[ "Copy", "page", "-", "number", "to", "live", "workspace", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L163-L173
43,461
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleRemove
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $page = 1; foreach ($document->getParent()->getChildren() as $child) { if (!$child instanceof PageBehavior || $child->getUuid() === $document->getUuid()) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
php
public function handleRemove(RemoveEvent $event) { $document = $event->getDocument(); if (!$document instanceof PageBehavior) { return; } $page = 1; foreach ($document->getParent()->getChildren() as $child) { if (!$child instanceof PageBehavior || $child->getUuid() === $document->getUuid()) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
[ "public", "function", "handleRemove", "(", "RemoveEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "PageBehavior", ")", "{", "return", ";", "}", "$", ...
Adjust the page-numbers of siblings when removing a page. @param RemoveEvent $event
[ "Adjust", "the", "page", "-", "numbers", "of", "siblings", "when", "removing", "a", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L180-L196
43,462
sulu/SuluArticleBundle
Document/Subscriber/PageSubscriber.php
PageSubscriber.handleRestore
public function handleRestore(RestoreEvent $event) { $document = $event->getDocument(); if (!$document instanceof ChildrenBehavior) { return; } $page = 1; foreach ($document->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
php
public function handleRestore(RestoreEvent $event) { $document = $event->getDocument(); if (!$document instanceof ChildrenBehavior) { return; } $page = 1; foreach ($document->getChildren() as $child) { if (!$child instanceof PageBehavior) { continue; } $childNode = $this->documentInspector->getNode($child); $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), ++$page); } }
[ "public", "function", "handleRestore", "(", "RestoreEvent", "$", "event", ")", "{", "$", "document", "=", "$", "event", "->", "getDocument", "(", ")", ";", "if", "(", "!", "$", "document", "instanceof", "ChildrenBehavior", ")", "{", "return", ";", "}", "...
Adjust the page-numbers of siblings when restoring a page. @param RestoreEvent $event
[ "Adjust", "the", "page", "-", "numbers", "of", "siblings", "when", "restoring", "a", "page", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Subscriber/PageSubscriber.php#L203-L219
43,463
sulu/SuluArticleBundle
Admin/ArticleJsConfig.php
ArticleJsConfig.getTitle
private function getTitle($type) { if (!array_key_exists($type, $this->typeConfiguration)) { return ucfirst($type); } return $this->typeConfiguration[$type]['translation_key']; }
php
private function getTitle($type) { if (!array_key_exists($type, $this->typeConfiguration)) { return ucfirst($type); } return $this->typeConfiguration[$type]['translation_key']; }
[ "private", "function", "getTitle", "(", "$", "type", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "typeConfiguration", ")", ")", "{", "return", "ucfirst", "(", "$", "type", ")", ";", "}", "return", "$", "thi...
Returns title for given type. @param string $type @return string
[ "Returns", "title", "for", "given", "type", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Admin/ArticleJsConfig.php#L121-L128
43,464
sulu/SuluArticleBundle
Document/Serializer/ArticlePageSubscriber.php
ArticlePageSubscriber.addTitleOnPostSerialize
public function addTitleOnPostSerialize(ObjectEvent $event) { $articlePage = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!$articlePage instanceof ArticlePageDocument) { return; } $visitor->addData('title', $context->accept($articlePage->getParent()->getTitle())); }
php
public function addTitleOnPostSerialize(ObjectEvent $event) { $articlePage = $event->getObject(); $visitor = $event->getVisitor(); $context = $event->getContext(); if (!$articlePage instanceof ArticlePageDocument) { return; } $visitor->addData('title', $context->accept($articlePage->getParent()->getTitle())); }
[ "public", "function", "addTitleOnPostSerialize", "(", "ObjectEvent", "$", "event", ")", "{", "$", "articlePage", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "visitor", "=", "$", "event", "->", "getVisitor", "(", ")", ";", "$", "context", "=...
Append title to result. @param ObjectEvent $event
[ "Append", "title", "to", "result", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Document/Serializer/ArticlePageSubscriber.php#L43-L54
43,465
sulu/SuluArticleBundle
Routing/ArticleRouteDefaultProvider.php
ArticleRouteDefaultProvider.isPublished
public function isPublished($entityClass, $id, $locale) { $object = $this->documentManager->find($id, $locale); if (!$object instanceof ArticleInterface || WorkflowStage::PUBLISHED !== $object->getWorkflowStage()) { return false; } if (!$object instanceof WebspaceBehavior) { return true; } $webspace = $this->requestAnalyzer->getWebspace(); if (!$webspace || ( $this->webspaceResolver->resolveMainWebspace($object) !== $webspace->getKey() && !in_array($webspace->getKey(), $this->webspaceResolver->resolveAdditionalWebspaces($object)) ) ) { return false; } return true; }
php
public function isPublished($entityClass, $id, $locale) { $object = $this->documentManager->find($id, $locale); if (!$object instanceof ArticleInterface || WorkflowStage::PUBLISHED !== $object->getWorkflowStage()) { return false; } if (!$object instanceof WebspaceBehavior) { return true; } $webspace = $this->requestAnalyzer->getWebspace(); if (!$webspace || ( $this->webspaceResolver->resolveMainWebspace($object) !== $webspace->getKey() && !in_array($webspace->getKey(), $this->webspaceResolver->resolveAdditionalWebspaces($object)) ) ) { return false; } return true; }
[ "public", "function", "isPublished", "(", "$", "entityClass", ",", "$", "id", ",", "$", "locale", ")", "{", "$", "object", "=", "$", "this", "->", "documentManager", "->", "find", "(", "$", "id", ",", "$", "locale", ")", ";", "if", "(", "!", "$", ...
If article is not published the document will be of typ unknown-document. Also check the workflow stage if it`s a ArticleDocument. {@inheritdoc}
[ "If", "article", "is", "not", "published", "the", "document", "will", "be", "of", "typ", "unknown", "-", "document", ".", "Also", "check", "the", "workflow", "stage", "if", "it", "s", "a", "ArticleDocument", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Routing/ArticleRouteDefaultProvider.php#L127-L150
43,466
sulu/SuluArticleBundle
Routing/ArticleRouteDefaultProvider.php
ArticleRouteDefaultProvider.getCacheLifetime
private function getCacheLifetime($metadata) { $cacheLifetime = $metadata->cacheLifetime; if (!$cacheLifetime) { return null; } if (!is_array($cacheLifetime) || !isset($cacheLifetime['type']) || !isset($cacheLifetime['value']) || !$this->cacheLifetimeResolver->supports($cacheLifetime['type'], $cacheLifetime['value']) ) { throw new \InvalidArgumentException( sprintf('Invalid cachelifetime in article route default provider: %s', var_export($cacheLifetime, true)) ); } return $this->cacheLifetimeResolver->resolve($cacheLifetime['type'], $cacheLifetime['value']); }
php
private function getCacheLifetime($metadata) { $cacheLifetime = $metadata->cacheLifetime; if (!$cacheLifetime) { return null; } if (!is_array($cacheLifetime) || !isset($cacheLifetime['type']) || !isset($cacheLifetime['value']) || !$this->cacheLifetimeResolver->supports($cacheLifetime['type'], $cacheLifetime['value']) ) { throw new \InvalidArgumentException( sprintf('Invalid cachelifetime in article route default provider: %s', var_export($cacheLifetime, true)) ); } return $this->cacheLifetimeResolver->resolve($cacheLifetime['type'], $cacheLifetime['value']); }
[ "private", "function", "getCacheLifetime", "(", "$", "metadata", ")", "{", "$", "cacheLifetime", "=", "$", "metadata", "->", "cacheLifetime", ";", "if", "(", "!", "$", "cacheLifetime", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_array", "("...
Get cache life time. @param StructureMetadata $metadata @return int|null
[ "Get", "cache", "life", "time", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Routing/ArticleRouteDefaultProvider.php#L170-L189
43,467
sulu/SuluArticleBundle
Controller/WebsiteArticleController.php
WebsiteArticleController.indexAction
public function indexAction(Request $request, ArticleInterface $object, $view, $pageNumber = 1) { return $this->renderArticle($request, $object, $view, $pageNumber); }
php
public function indexAction(Request $request, ArticleInterface $object, $view, $pageNumber = 1) { return $this->renderArticle($request, $object, $view, $pageNumber); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ",", "ArticleInterface", "$", "object", ",", "$", "view", ",", "$", "pageNumber", "=", "1", ")", "{", "return", "$", "this", "->", "renderArticle", "(", "$", "request", ",", "$", "objec...
Article index action. @param Request $request @param ArticleInterface $object @param string $view @param int $pageNumber @return Response
[ "Article", "index", "action", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/WebsiteArticleController.php#L39-L42
43,468
sulu/SuluArticleBundle
Controller/WebsiteArticleController.php
WebsiteArticleController.renderArticle
protected function renderArticle(Request $request, ArticleInterface $object, $view, $pageNumber, $attributes = []) { $object = $this->normalizeArticle($object); $requestFormat = $request->getRequestFormat(); $viewTemplate = $view . '.' . $requestFormat . '.twig'; $content = $this->serializeArticle($object, $pageNumber); try { return $this->render( $viewTemplate, $this->get('sulu_website.resolver.template_attribute')->resolve(array_merge($content, $attributes)), $this->createResponse($request) ); } catch (\InvalidArgumentException $exception) { // template not found throw new HttpException(406, 'Error encountered when rendering content', $exception); } }
php
protected function renderArticle(Request $request, ArticleInterface $object, $view, $pageNumber, $attributes = []) { $object = $this->normalizeArticle($object); $requestFormat = $request->getRequestFormat(); $viewTemplate = $view . '.' . $requestFormat . '.twig'; $content = $this->serializeArticle($object, $pageNumber); try { return $this->render( $viewTemplate, $this->get('sulu_website.resolver.template_attribute')->resolve(array_merge($content, $attributes)), $this->createResponse($request) ); } catch (\InvalidArgumentException $exception) { // template not found throw new HttpException(406, 'Error encountered when rendering content', $exception); } }
[ "protected", "function", "renderArticle", "(", "Request", "$", "request", ",", "ArticleInterface", "$", "object", ",", "$", "view", ",", "$", "pageNumber", ",", "$", "attributes", "=", "[", "]", ")", "{", "$", "object", "=", "$", "this", "->", "normalize...
Render article with given view. @param Request $request @param ArticleInterface $object @param string $view @param int $pageNumber @param array $attributes @return Response
[ "Render", "article", "with", "given", "view", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/WebsiteArticleController.php#L55-L74
43,469
sulu/SuluArticleBundle
Controller/WebsiteArticleController.php
WebsiteArticleController.serializeArticle
protected function serializeArticle(ArticleInterface $object, $pageNumber) { return $this->get('jms_serializer')->serialize( $object, 'array', SerializationContext::create() ->setSerializeNull(true) ->setGroups(['website', 'content']) ->setAttribute('website', true) ->setAttribute('pageNumber', $pageNumber) ); }
php
protected function serializeArticle(ArticleInterface $object, $pageNumber) { return $this->get('jms_serializer')->serialize( $object, 'array', SerializationContext::create() ->setSerializeNull(true) ->setGroups(['website', 'content']) ->setAttribute('website', true) ->setAttribute('pageNumber', $pageNumber) ); }
[ "protected", "function", "serializeArticle", "(", "ArticleInterface", "$", "object", ",", "$", "pageNumber", ")", "{", "return", "$", "this", "->", "get", "(", "'jms_serializer'", ")", "->", "serialize", "(", "$", "object", ",", "'array'", ",", "SerializationC...
Serialize given article with page-number. @param ArticleInterface $object @param int $pageNumber @return array
[ "Serialize", "given", "article", "with", "page", "-", "number", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Controller/WebsiteArticleController.php#L101-L112
43,470
sulu/SuluArticleBundle
Content/PageTreeRouteContentType.php
PageTreeRouteContentType.readPage
private function readPage($propertyName, NodeInterface $node) { $pagePropertyName = $propertyName . '-page'; if (!$node->hasProperty($pagePropertyName)) { return; } try { $pageUuid = $node->getPropertyValue($pagePropertyName, PropertyType::STRING); } catch (ItemNotFoundException $exception) { return; } return [ 'uuid' => $pageUuid, 'path' => $node->getPropertyValueWithDefault($pagePropertyName . '-path', ''), 'webspace' => $node->getPropertyValueWithDefault($pagePropertyName . '-webspace', null), ]; }
php
private function readPage($propertyName, NodeInterface $node) { $pagePropertyName = $propertyName . '-page'; if (!$node->hasProperty($pagePropertyName)) { return; } try { $pageUuid = $node->getPropertyValue($pagePropertyName, PropertyType::STRING); } catch (ItemNotFoundException $exception) { return; } return [ 'uuid' => $pageUuid, 'path' => $node->getPropertyValueWithDefault($pagePropertyName . '-path', ''), 'webspace' => $node->getPropertyValueWithDefault($pagePropertyName . '-webspace', null), ]; }
[ "private", "function", "readPage", "(", "$", "propertyName", ",", "NodeInterface", "$", "node", ")", "{", "$", "pagePropertyName", "=", "$", "propertyName", ".", "'-page'", ";", "if", "(", "!", "$", "node", "->", "hasProperty", "(", "$", "pagePropertyName", ...
Read page-information from given node. @param string $propertyName @param NodeInterface $node @return array
[ "Read", "page", "-", "information", "from", "given", "node", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/PageTreeRouteContentType.php#L194-L212
43,471
sulu/SuluArticleBundle
Content/PageTreeRouteContentType.php
PageTreeRouteContentType.generateSuffix
private function generateSuffix(NodeInterface $node, $locale, $pagePath) { $document = $this->documentRegistry->getDocumentForNode($node, $locale); $route = $this->chainRouteGenerator->generate($document); $route->setPath(rtrim($pagePath, '/') . '/' . ltrim($route->getPath(), '/')); $route = $this->conflictResolver->resolve($route); return substr($route->getPath(), strlen(rtrim($pagePath, '/')) + 1); }
php
private function generateSuffix(NodeInterface $node, $locale, $pagePath) { $document = $this->documentRegistry->getDocumentForNode($node, $locale); $route = $this->chainRouteGenerator->generate($document); $route->setPath(rtrim($pagePath, '/') . '/' . ltrim($route->getPath(), '/')); $route = $this->conflictResolver->resolve($route); return substr($route->getPath(), strlen(rtrim($pagePath, '/')) + 1); }
[ "private", "function", "generateSuffix", "(", "NodeInterface", "$", "node", ",", "$", "locale", ",", "$", "pagePath", ")", "{", "$", "document", "=", "$", "this", "->", "documentRegistry", "->", "getDocumentForNode", "(", "$", "node", ",", "$", "locale", "...
Generate a new suffix for document. @param NodeInterface $node @param string $locale @param string $pagePath @return string
[ "Generate", "a", "new", "suffix", "for", "document", "." ]
6d877ca6f28ffc67b70f60c84f56170541a58cf5
https://github.com/sulu/SuluArticleBundle/blob/6d877ca6f28ffc67b70f60c84f56170541a58cf5/Content/PageTreeRouteContentType.php#L241-L250
43,472
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.startGroup
public function startGroup($options = []) { $options += [ 'id' => 'panelGroup-'.(++$this->_groupCount), 'collapsible' => true, 'open' => 0, 'templateVars' => [] ]; $this->_states->push('group', [ 'groupPanelOpen' => $options['open'], 'groupPanelCount' => -1, 'groupId' => $options['id'], 'groupCollapsible' => $options['collapsible'] ]); return $this->formatTemplate('panelGroupStart', [ 'attrs' => $this->templater()->formatAttributes($options, ['open', 'collapsible']), 'templateVars' => $options['templateVars'] ]); }
php
public function startGroup($options = []) { $options += [ 'id' => 'panelGroup-'.(++$this->_groupCount), 'collapsible' => true, 'open' => 0, 'templateVars' => [] ]; $this->_states->push('group', [ 'groupPanelOpen' => $options['open'], 'groupPanelCount' => -1, 'groupId' => $options['id'], 'groupCollapsible' => $options['collapsible'] ]); return $this->formatTemplate('panelGroupStart', [ 'attrs' => $this->templater()->formatAttributes($options, ['open', 'collapsible']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "startGroup", "(", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'id'", "=>", "'panelGroup-'", ".", "(", "++", "$", "this", "->", "_groupCount", ")", ",", "'collapsible'", "=>", "true", ",", "'open'", "=>", ...
Open a panel group. ### Options - `collapsible` Set to `false` if panels should not be collapsible. Default is `true`. - `id` Identifier for the group. Default is automatically generated. - `open` If `collapsible` is `true`, indicate the panel that should be open by default. Set to `false` to have no panels open. You can also indicate if a panel should be open in the `create()` method. Default is `0`. - Other attributes will be passed to the `Html::div()` method. @param array $options Array of options. See above. @return string A formated opening HTML tag for panel groups. @link http://getbootstrap.com/javascript/#collapse-example-accordion
[ "Open", "a", "panel", "group", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L134-L151
43,473
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.endGroup
public function endGroup() { $out = ''; while ($this->_states->is('panel')) { // panels were not closed $out .= $this->end(); } $out .= $this->formatTemplate('panelGroupEnd', []); $this->_states->pop(); return $out; }
php
public function endGroup() { $out = ''; while ($this->_states->is('panel')) { // panels were not closed $out .= $this->end(); } $out .= $this->formatTemplate('panelGroupEnd', []); $this->_states->pop(); return $out; }
[ "public", "function", "endGroup", "(", ")", "{", "$", "out", "=", "''", ";", "while", "(", "$", "this", "->", "_states", "->", "is", "(", "'panel'", ")", ")", "{", "// panels were not closed", "$", "out", ".=", "$", "this", "->", "end", "(", ")", "...
Closes a panel group, closes the last panel if it has not already been closed. @return string An HTML string containing closing tags.
[ "Closes", "a", "panel", "group", "closes", "the", "last", "panel", "if", "it", "has", "not", "already", "been", "closed", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L158-L166
43,474
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.create
public function create($title = null, $options = []) { if (is_array($title)) { $options = $title; $title = null; } $out = ''; // close previous panel if in group if ($this->_states->is('panel') && $this->_states->getValue('inGroup')) { $out .= $this->end(); } $options += [ 'body' => true, 'type' => 'default', 'collapsible' => $this->_states->is('group') ? $this->_states->getValue('groupCollapsible') : $this->getConfig('collapsible'), 'open' => !$this->_states->is('group'), 'panel-count' => $this->_panelCount, 'title' => [], 'templateVars' => [] ]; $this->_panelCount = intval($options['panel-count']) + 1; // check open $open = $options['open']; if ($this->_states->is('group')) { // increment count inside $this->_states->setValue('groupPanelCount', $this->_states->getValue('groupPanelCount') + 1); $open = $open || $this->_states->getValue('groupPanelOpen') == $this->_states->getValue('groupPanelCount'); } $out .= $this->formatTemplate('panelStart', [ 'type' => $options['type'], 'attrs' => $this->templater()->formatAttributes( $options, ['body', 'type', 'collapsible', 'open', 'panel-count', 'title']), 'templateVars' => $options['templateVars'] ]); $this->_states->push('panel', [ 'part' => null, 'bodyId' => 'collapse-'.$options['panel-count'], 'headId' => 'heading-'.$options['panel-count'], 'collapsible' => $options['collapsible'], 'open' => $open, 'inGroup' => $this->_states->is('group'), 'groupId' => $this->_states->is('group') ? $this->_states->getValue('groupId') : 0 ]); if (is_string($title) && $title) { $out .= $this->_createHeader($title, [ 'title' => $options['title'] ]); if ($options['body']) { $out .= $this->_createBody(); } } return $out; }
php
public function create($title = null, $options = []) { if (is_array($title)) { $options = $title; $title = null; } $out = ''; // close previous panel if in group if ($this->_states->is('panel') && $this->_states->getValue('inGroup')) { $out .= $this->end(); } $options += [ 'body' => true, 'type' => 'default', 'collapsible' => $this->_states->is('group') ? $this->_states->getValue('groupCollapsible') : $this->getConfig('collapsible'), 'open' => !$this->_states->is('group'), 'panel-count' => $this->_panelCount, 'title' => [], 'templateVars' => [] ]; $this->_panelCount = intval($options['panel-count']) + 1; // check open $open = $options['open']; if ($this->_states->is('group')) { // increment count inside $this->_states->setValue('groupPanelCount', $this->_states->getValue('groupPanelCount') + 1); $open = $open || $this->_states->getValue('groupPanelOpen') == $this->_states->getValue('groupPanelCount'); } $out .= $this->formatTemplate('panelStart', [ 'type' => $options['type'], 'attrs' => $this->templater()->formatAttributes( $options, ['body', 'type', 'collapsible', 'open', 'panel-count', 'title']), 'templateVars' => $options['templateVars'] ]); $this->_states->push('panel', [ 'part' => null, 'bodyId' => 'collapse-'.$options['panel-count'], 'headId' => 'heading-'.$options['panel-count'], 'collapsible' => $options['collapsible'], 'open' => $open, 'inGroup' => $this->_states->is('group'), 'groupId' => $this->_states->is('group') ? $this->_states->getValue('groupId') : 0 ]); if (is_string($title) && $title) { $out .= $this->_createHeader($title, [ 'title' => $options['title'] ]); if ($options['body']) { $out .= $this->_createBody(); } } return $out; }
[ "public", "function", "create", "(", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "$", "options", "=", "$", "title", ";", "$", "title", "=", "null", ";", "}", ...
Open a panel. If `$title` is a string, the panel header is created using `$title` as its content and default options (except for the `title` options that can be specified inside `$options`). ```php echo $this->Panel->create('My Panel Title', ['title' => ['tag' => 'h2']]); ``` If the panel header is created, the panel body is automatically opened after it, except if the `no-body` options is specified (see below). If `$title` is an array, it is used as `$options`. ```php echo $this->Panel->create(['class' => 'my-panel-class']); ``` If the `create()` method is used inside a panel group, the previous panel is automatically closed. ### Options - `collapsible` Set to `true` if the panel should be collapsible. Default is fetch from configuration/ - `body` If `$title` is a string, set to `false` to not open the body after the panel header. Default is `true`. - `open` Indicate if the panel should be open. If the panel is not inside a group, the default is `true`, otherwize the default is `false` and the panel is open if its count matches the specified value in `startGroup()` (set to `true` inside a group to force the panel to be open). - `panel-count` Panel counter, can be used to override the default counter when inside a group. This value is used to generate the panel, header and body ID attribute. - `title` Array of options for the title. Default is []. - `type` Type of the panel (`'default'`, `'primary'`, ...). Default is `'default'`. - Other options will be passed to the `Html::div` method for creating the panel `<div>`. @param array|string $title The panel title or an array of options. @param array $options Array of options. See above. @return string An HTML string containing opening elements for a panel.
[ "Open", "a", "panel", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L213-L279
43,475
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper.end
public function end($content = null, $options = []) { $this->_lastPanelClosed = true; $res = ''; $res .= $this->_cleanCurrent(); if ($content !== null) { $res .= $this->footer($content, $options); } $res .= $this->formatTemplate('panelEnd', []); $this->_states->pop(); return $res; }
php
public function end($content = null, $options = []) { $this->_lastPanelClosed = true; $res = ''; $res .= $this->_cleanCurrent(); if ($content !== null) { $res .= $this->footer($content, $options); } $res .= $this->formatTemplate('panelEnd', []); $this->_states->pop(); return $res; }
[ "public", "function", "end", "(", "$", "content", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "_lastPanelClosed", "=", "true", ";", "$", "res", "=", "''", ";", "$", "res", ".=", "$", "this", "->", "_cleanCurrent", ...
Closes a panel, cleans part that have not been closed correctly and optionaly adds a footer to the panel. If `$content` is not null, the `footer()` methods will be used to create the panel footer using `$content` and `$options`. ```php echo $this->Panel->end('Footer Content', ['my-class' => 'my-footer-class']); ``` @param string|null $content Footer content, or `null`. @param array $options Array of options for the footer. @return string An HTML string containing closing tags.
[ "Closes", "a", "panel", "cleans", "part", "that", "have", "not", "been", "closed", "correctly", "and", "optionaly", "adds", "a", "footer", "to", "the", "panel", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L297-L307
43,476
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PanelHelper.php
PanelHelper._cleanCurrent
protected function _cleanCurrent() { if (!$this->_states->is('panel')) { return ''; } $current = $this->_states->getValue('part'); if ($current === null) { return ''; } $out = $this->formatTemplate($current.'End', []); if ($this->_states->getValue('collapsible')) { $ctplt = $current.'CollapsibleEnd'; if ($this->getTemplates($ctplt)) { $out = $this->formatTemplate($ctplt, [ $current.'End' => $out ]); } } $this->_states->setValue('part', null); return $out; }
php
protected function _cleanCurrent() { if (!$this->_states->is('panel')) { return ''; } $current = $this->_states->getValue('part'); if ($current === null) { return ''; } $out = $this->formatTemplate($current.'End', []); if ($this->_states->getValue('collapsible')) { $ctplt = $current.'CollapsibleEnd'; if ($this->getTemplates($ctplt)) { $out = $this->formatTemplate($ctplt, [ $current.'End' => $out ]); } } $this->_states->setValue('part', null); return $out; }
[ "protected", "function", "_cleanCurrent", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_states", "->", "is", "(", "'panel'", ")", ")", "{", "return", "''", ";", "}", "$", "current", "=", "$", "this", "->", "_states", "->", "getValue", "(", "'...
Cleans the current panel part and return necessary HTML closing elements. @return string An HTML string containing closing elements.
[ "Cleans", "the", "current", "panel", "part", "and", "return", "necessary", "HTML", "closing", "elements", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PanelHelper.php#L314-L333
43,477
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ClassTrait.php
ClassTrait.addClass
public function addClass(array $options = [], $class = null, $key = 'class') { if (!is_array($class)) { $class = explode(' ', trim($class)); } $optClass = []; if (isset($options[$key])) { $optClass = $options[$key]; if (!is_array($optClass)) { $optClass = explode(' ', trim($optClass)); } } $class = array_merge($optClass, $class); $class = array_map('trim', $class); $class = array_unique($class); $class = array_filter($class); $options[$key] = implode(' ', $class); return $options; }
php
public function addClass(array $options = [], $class = null, $key = 'class') { if (!is_array($class)) { $class = explode(' ', trim($class)); } $optClass = []; if (isset($options[$key])) { $optClass = $options[$key]; if (!is_array($optClass)) { $optClass = explode(' ', trim($optClass)); } } $class = array_merge($optClass, $class); $class = array_map('trim', $class); $class = array_unique($class); $class = array_filter($class); $options[$key] = implode(' ', $class); return $options; }
[ "public", "function", "addClass", "(", "array", "$", "options", "=", "[", "]", ",", "$", "class", "=", "null", ",", "$", "key", "=", "'class'", ")", "{", "if", "(", "!", "is_array", "(", "$", "class", ")", ")", "{", "$", "class", "=", "explode", ...
Adds the given class to the element options. @param array $options Array of options/attributes to add a class to. @param string|array $class The class names to be added. @param string $key The key to use for class (default to `'class'`). @return array Array of options with `$key` set or updated.
[ "Adds", "the", "given", "class", "to", "the", "element", "options", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ClassTrait.php#L33-L50
43,478
Holt59/cakephp3-bootstrap-helpers
src/Utility/StackedStates.php
StackedStates.push
public function push($type, $state = []) { if (isset($this->_defaults[$type])) { $state = array_merge($this->_defaults[$type], $state); } array_push($this->_states, [$type, $state]); }
php
public function push($type, $state = []) { if (isset($this->_defaults[$type])) { $state = array_merge($this->_defaults[$type], $state); } array_push($this->_states, [$type, $state]); }
[ "public", "function", "push", "(", "$", "type", ",", "$", "state", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_defaults", "[", "$", "type", "]", ")", ")", "{", "$", "state", "=", "array_merge", "(", "$", "this", "->",...
Push a new state, merging given values with the default ones. @param string $type Type of the new state. @param mixed $sate New state.
[ "Push", "a", "new", "state", "merging", "given", "values", "with", "the", "default", "ones", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/StackedStates.php#L73-L78
43,479
Holt59/cakephp3-bootstrap-helpers
src/Utility/StackedStates.php
StackedStates.setValue
public function setValue($name, $value) { $this->_states[count($this->_states) - 1][1][$name] = $value; }
php
public function setValue($name, $value) { $this->_states[count($this->_states) - 1][1][$name] = $value; }
[ "public", "function", "setValue", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "_states", "[", "count", "(", "$", "this", "->", "_states", ")", "-", "1", "]", "[", "1", "]", "[", "$", "name", "]", "=", "$", "value", ";", ...
Set a value of the current state. @param mixed $name Name of the attribute to set. @param mixed $value New value for the attribute.
[ "Set", "a", "value", "of", "the", "current", "state", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/StackedStates.php#L105-L107
43,480
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait._matchHost
protected function _matchHost($url) { $components = parse_url($url); return !(isset($components['host']) && $components['host'] != $this->_hostname()); }
php
protected function _matchHost($url) { $components = parse_url($url); return !(isset($components['host']) && $components['host'] != $this->_hostname()); }
[ "protected", "function", "_matchHost", "(", "$", "url", ")", "{", "$", "components", "=", "parse_url", "(", "$", "url", ")", ";", "return", "!", "(", "isset", "(", "$", "components", "[", "'host'", "]", ")", "&&", "$", "components", "[", "'host'", "]...
Checks if the given URL components match the current host. @param string $url URL to check. @return bool `true` if the URL matches, `false` otherwise.
[ "Checks", "if", "the", "given", "URL", "components", "match", "the", "current", "host", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L62-L65
43,481
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait._matchRelative
protected function _matchRelative($url) { $relative = $this->_relative(); if (!$relative) { return true; } $components = parse_url($url); if (!isset($components['host'])) { return true; } $path = trim($components['path'], '/'); return strpos($path, $relative) === 0; }
php
protected function _matchRelative($url) { $relative = $this->_relative(); if (!$relative) { return true; } $components = parse_url($url); if (!isset($components['host'])) { return true; } $path = trim($components['path'], '/'); return strpos($path, $relative) === 0; }
[ "protected", "function", "_matchRelative", "(", "$", "url", ")", "{", "$", "relative", "=", "$", "this", "->", "_relative", "(", ")", ";", "if", "(", "!", "$", "relative", ")", "{", "return", "true", ";", "}", "$", "components", "=", "parse_url", "("...
Checks if the given URL components match the current relative URL. This methods only works with full URL, and do not check the host. @param string $url URL to check. @return bool `true` if the URL matches, `false` otherwise.
[ "Checks", "if", "the", "given", "URL", "components", "match", "the", "current", "relative", "URL", ".", "This", "methods", "only", "works", "with", "full", "URL", "and", "do", "not", "check", "the", "host", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L75-L86
43,482
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait._normalize
protected function _normalize($url, array $parts = []) { if (!is_string($url)) { $url = Router::url($url); } if (!$this->_matchHost($url)) { return null; } if (!$this->_matchRelative($url)) { return null; } $url = Router::parseRequest(new ServerRequest($this->_removeRelative($url))); $arr = []; foreach ($this->_parts as $part) { if (!isset($url[$part]) || (isset($parts[$part]) && !$parts[$part])) { continue; } if (is_array($url[$part])) { $url[$part] = implode('/', $url[$part]); } if ($part != 'pass') { $url[$part] = strtolower($url[$part]); } $arr[] = $url[$part]; } return $this->_removeRelative(Router::normalize('/'.implode('/', $arr))); }
php
protected function _normalize($url, array $parts = []) { if (!is_string($url)) { $url = Router::url($url); } if (!$this->_matchHost($url)) { return null; } if (!$this->_matchRelative($url)) { return null; } $url = Router::parseRequest(new ServerRequest($this->_removeRelative($url))); $arr = []; foreach ($this->_parts as $part) { if (!isset($url[$part]) || (isset($parts[$part]) && !$parts[$part])) { continue; } if (is_array($url[$part])) { $url[$part] = implode('/', $url[$part]); } if ($part != 'pass') { $url[$part] = strtolower($url[$part]); } $arr[] = $url[$part]; } return $this->_removeRelative(Router::normalize('/'.implode('/', $arr))); }
[ "protected", "function", "_normalize", "(", "$", "url", ",", "array", "$", "parts", "=", "[", "]", ")", "{", "if", "(", "!", "is_string", "(", "$", "url", ")", ")", "{", "$", "url", "=", "Router", "::", "url", "(", "$", "url", ")", ";", "}", ...
Normalize an URL. @param string $url URL to normalize. @param array $pass Include pass parameters. @return string Normalized URL.
[ "Normalize", "an", "URL", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L113-L138
43,483
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/UrlComparerTrait.php
UrlComparerTrait.compareUrls
public function compareUrls($lhs, $rhs = null, $parts = []) { if ($rhs == null) { $rhs = Router::url(); } $lhs = $this->_normalize($lhs, $parts); $rhs = $this->_normalize($rhs); return $lhs !== null && $rhs !== null && strpos($rhs, $lhs) === 0; }
php
public function compareUrls($lhs, $rhs = null, $parts = []) { if ($rhs == null) { $rhs = Router::url(); } $lhs = $this->_normalize($lhs, $parts); $rhs = $this->_normalize($rhs); return $lhs !== null && $rhs !== null && strpos($rhs, $lhs) === 0; }
[ "public", "function", "compareUrls", "(", "$", "lhs", ",", "$", "rhs", "=", "null", ",", "$", "parts", "=", "[", "]", ")", "{", "if", "(", "$", "rhs", "==", "null", ")", "{", "$", "rhs", "=", "Router", "::", "url", "(", ")", ";", "}", "$", ...
Check if first URL is a parent of the right URL, without regards to query parameters or hash. @param string|array $lhs First URL to compare. @param string|array $rhs Second URL to compare. Default is current URL (`Router::url()`). @return bool `true` if both URL match, `false` otherwise.
[ "Check", "if", "first", "URL", "is", "a", "parent", "of", "the", "right", "URL", "without", "regards", "to", "query", "parameters", "or", "hash", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/UrlComparerTrait.php#L149-L156
43,484
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/PaginatorHelper.php
PaginatorHelper.prev
public function prev($title = '<< Previous', array $options = []) { list($options, $easyIcon) = $this->_easyIconOption($options); return $this->_injectIcon(parent::prev($title, $options), $easyIcon); }
php
public function prev($title = '<< Previous', array $options = []) { list($options, $easyIcon) = $this->_easyIconOption($options); return $this->_injectIcon(parent::prev($title, $options), $easyIcon); }
[ "public", "function", "prev", "(", "$", "title", "=", "'<< Previous'", ",", "array", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "options", ",", "$", "easyIcon", ")", "=", "$", "this", "->", "_easyIconOption", "(", "$", "options", ")",...
Generates a "previous" link for a set of paged records. ### Options: - `disabledTitle` The text to used when the link is disabled. This defaults to the same text at the active link. Setting to false will cause this method to return ''. - `escape` Whether you want the contents html entity encoded, defaults to true. - `model` The model to use, defaults to `PaginatorHelper::defaultModel()`. - `url` An array of additional URL options to use for link generation. - `templates` An array of templates, or template file name containing the templates you'd like to use when generating the link for previous page. The helper's original templates will be restored once prev() is done. @param string $title Title for the link. Defaults to '<< Previous'. @param array $options Options for pagination link. See above for list of keys. @return string A "previous" link or a disabled link. @link http://book.cakephp.org/3.0/en/views/helpers/paginator.html#creating-jump-links
[ "Generates", "a", "previous", "link", "for", "a", "set", "of", "paged", "records", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/PaginatorHelper.php#L277-L280
43,485
Holt59/cakephp3-bootstrap-helpers
src/View/Widget/FancyFileWidget.php
FancyFileWidget.render
public function render(array $data, \Cake\View\Form\ContextInterface $context) { $data += [ '_input' => [], '_button' => [], 'id' => $data['name'], 'count-label' => __('files selected'), 'button-label' => (isset($data['multiple']) && $data['multiple']) ? __('Choose Files') : __('Choose File'), 'templateVars' => [] ]; $fakeInputCustomOptions = $data['_input']; $fakeButtonCustomOptions = $data['_button']; $countLabel = $data['count-label']; $buttonLabel = $data['button-label']; unset($data['_input'], $data['_button'], $data['type'], $data['count-label'], $data['button-label']); // avoid javascript errors due to invisible control unset($data['required']); $fileInput = $this->_file->render($data + [ 'style' => 'display: none;', 'onchange' => "document.getElementById('".$data['id']."-input').value = " . "(this.files.length <= 1) ? " . "(this.files.length ? this.files[0].name : '') " . ": this.files.length + ' ' + '" . $countLabel . "';", 'escape' => false ], $context); if (!empty($data['val']) && is_array($data['val'])) { if (isset($data['val']['name']) || count($data['val']) == 1) { $fakeInputCustomOptions += [ 'value' => (isset($data['val']['name'])) ? $data['val']['name'] : $data['val'][0]['name'] ]; } else { $fakeInputCustomOptions += [ 'value' => count($data['val']) . ' ' . $countLabel ]; } } $fakeInput = $this->_input->render($fakeInputCustomOptions + [ 'name' => $this->_fakeFieldName($data['name']), 'readonly' => 'readonly', 'id' => $data['id'].'-input', 'onclick' => "document.getElementById('".$data['id']."').click();", 'escape' => false ], $context); $fakeButton = $this->_button->render($fakeButtonCustomOptions + [ 'type' => 'button', 'text' => $buttonLabel, 'onclick' => "document.getElementById('".$data['id']."').click();" ], $context); return $this->_templates->format('fancyFileInput', [ 'fileInput' => $fileInput, 'button' => $fakeButton, 'input' => $fakeInput, 'attrs' => $this->_templates->formatAttributes($data), 'templateVars' => $data['templateVars'] ]); }
php
public function render(array $data, \Cake\View\Form\ContextInterface $context) { $data += [ '_input' => [], '_button' => [], 'id' => $data['name'], 'count-label' => __('files selected'), 'button-label' => (isset($data['multiple']) && $data['multiple']) ? __('Choose Files') : __('Choose File'), 'templateVars' => [] ]; $fakeInputCustomOptions = $data['_input']; $fakeButtonCustomOptions = $data['_button']; $countLabel = $data['count-label']; $buttonLabel = $data['button-label']; unset($data['_input'], $data['_button'], $data['type'], $data['count-label'], $data['button-label']); // avoid javascript errors due to invisible control unset($data['required']); $fileInput = $this->_file->render($data + [ 'style' => 'display: none;', 'onchange' => "document.getElementById('".$data['id']."-input').value = " . "(this.files.length <= 1) ? " . "(this.files.length ? this.files[0].name : '') " . ": this.files.length + ' ' + '" . $countLabel . "';", 'escape' => false ], $context); if (!empty($data['val']) && is_array($data['val'])) { if (isset($data['val']['name']) || count($data['val']) == 1) { $fakeInputCustomOptions += [ 'value' => (isset($data['val']['name'])) ? $data['val']['name'] : $data['val'][0]['name'] ]; } else { $fakeInputCustomOptions += [ 'value' => count($data['val']) . ' ' . $countLabel ]; } } $fakeInput = $this->_input->render($fakeInputCustomOptions + [ 'name' => $this->_fakeFieldName($data['name']), 'readonly' => 'readonly', 'id' => $data['id'].'-input', 'onclick' => "document.getElementById('".$data['id']."').click();", 'escape' => false ], $context); $fakeButton = $this->_button->render($fakeButtonCustomOptions + [ 'type' => 'button', 'text' => $buttonLabel, 'onclick' => "document.getElementById('".$data['id']."').click();" ], $context); return $this->_templates->format('fancyFileInput', [ 'fileInput' => $fileInput, 'button' => $fakeButton, 'input' => $fakeInput, 'attrs' => $this->_templates->formatAttributes($data), 'templateVars' => $data['templateVars'] ]); }
[ "public", "function", "render", "(", "array", "$", "data", ",", "\\", "Cake", "\\", "View", "\\", "Form", "\\", "ContextInterface", "$", "context", ")", "{", "$", "data", "+=", "[", "'_input'", "=>", "[", "]", ",", "'_button'", "=>", "[", "]", ",", ...
Render a custom file upload form widget. Data supports the following keys: - `_input` - Options for the input element. - `_button` - Options for the button element. - `name` - Set the input name. - `count-label` - Label for multiple files. Default is `__('files selected')`. - `button-label` - Button text. Default is `__('Choose File')`. - `escape` - Set to false to disable HTML escaping. All other keys will be converted into HTML attributes. Unlike other input objects the `val` property will be specifically ignored. @param array $data The data to build a file input with. @param \Cake\View\Form\ContextInterface $context The current form context. @return string HTML elements.
[ "Render", "a", "custom", "file", "upload", "form", "widget", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Widget/FancyFileWidget.php#L93-L157
43,486
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/EasyIconTrait.php
EasyIconTrait._easyIconOption
protected function _easyIconOption(array $options) { $options += [ 'easyIcon' => $this->easyIcon ]; $easyIcon = $options['easyIcon']; unset($options['easyIcon']); return [$options, $easyIcon]; }
php
protected function _easyIconOption(array $options) { $options += [ 'easyIcon' => $this->easyIcon ]; $easyIcon = $options['easyIcon']; unset($options['easyIcon']); return [$options, $easyIcon]; }
[ "protected", "function", "_easyIconOption", "(", "array", "$", "options", ")", "{", "$", "options", "+=", "[", "'easyIcon'", "=>", "$", "this", "->", "easyIcon", "]", ";", "$", "easyIcon", "=", "$", "options", "[", "'easyIcon'", "]", ";", "unset", "(", ...
Remove the `easyIcon` option from the given array and return it together with the array. @param array $options Array of options from which the easy-icon option should be extracted. @return array An array containing the options and the easy-icon option.
[ "Remove", "the", "easyIcon", "option", "from", "the", "given", "array", "and", "return", "it", "together", "with", "the", "array", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/EasyIconTrait.php#L39-L46
43,487
Holt59/cakephp3-bootstrap-helpers
src/View/FlexibleStringTemplate.php
FlexibleStringTemplate._getTemplateName
protected function _getTemplateName($name, array &$data = []) { if (isset($this->_callbacks[$name])) { $data = call_user_func($this->_callbacks[$name], $data); } if ($this->_callback) { $data = call_user_func($this->_callback, $name, $data); } if (isset($data['templateName'])) { $name = $data['templateName']; unset($data['templateName']); } return $name; }
php
protected function _getTemplateName($name, array &$data = []) { if (isset($this->_callbacks[$name])) { $data = call_user_func($this->_callbacks[$name], $data); } if ($this->_callback) { $data = call_user_func($this->_callback, $name, $data); } if (isset($data['templateName'])) { $name = $data['templateName']; unset($data['templateName']); } return $name; }
[ "protected", "function", "_getTemplateName", "(", "$", "name", ",", "array", "&", "$", "data", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_callbacks", "[", "$", "name", "]", ")", ")", "{", "$", "data", "=", "call_user_fun...
Retrieve a template name after checking the various callbacks. @param string $name The original name of the template. @param array $data The data to update. @return string The new name of the template.
[ "Retrieve", "a", "template", "name", "after", "checking", "the", "various", "callbacks", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/FlexibleStringTemplate.php#L70-L82
43,488
Holt59/cakephp3-bootstrap-helpers
src/Utility/Matching.php
Matching.matchTag
public static function matchTag($tag, $subject, &$content = null, &$attrs = null) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } // wrong tag => false if ($xml->name !== $tag) { return false; } $attrs = []; while ($xml->moveToNextAttribute()) { $attrs[$xml->name] = $xml->value; } $content = $xml->readInnerXML(); return true; }
php
public static function matchTag($tag, $subject, &$content = null, &$attrs = null) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } // wrong tag => false if ($xml->name !== $tag) { return false; } $attrs = []; while ($xml->moveToNextAttribute()) { $attrs[$xml->name] = $xml->value; } $content = $xml->readInnerXML(); return true; }
[ "public", "static", "function", "matchTag", "(", "$", "tag", ",", "$", "subject", ",", "&", "$", "content", "=", "null", ",", "&", "$", "attrs", "=", "null", ")", "{", "$", "xml", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "xml", "->", ...
Check if the given input string match the given tag, and returns an array of attributes if attrs is not null. This function does not work for "singleton" tags. @param string $tag Tag to match (e.g. 'a', 'div', 'span'). @param string $subject String within which to match the tag. @param string $content Content within the tag, if one was found. @param array $attrs Attributes of the tag, if one was found. @return bool True if the given tag was found, false otherwize.
[ "Check", "if", "the", "given", "input", "string", "match", "the", "given", "tag", "and", "returns", "an", "array", "of", "attributes", "if", "attrs", "is", "not", "null", ".", "This", "function", "does", "not", "work", "for", "singleton", "tags", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/Matching.php#L35-L57
43,489
Holt59/cakephp3-bootstrap-helpers
src/Utility/Matching.php
Matching.matchAttribute
public static function matchAttribute($attr, $value, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } return $xml->getAttribute($attr) === $value; }
php
public static function matchAttribute($attr, $value, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } return $xml->getAttribute($attr) === $value; }
[ "public", "static", "function", "matchAttribute", "(", "$", "attr", ",", "$", "value", ",", "$", "subject", ")", "{", "$", "xml", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "xml", "->", "xml", "(", "$", "subject", ",", "'UTF-8'", ",", "LIBX...
Check if the first tag found in the given input string contains an attribute with the given name and value. @param string $attr Name of the attribute. @param string $value Value of the attribute. @param string $subject String to search. @return bool True if an attribute with the given name/value was found, false otherwize.
[ "Check", "if", "the", "first", "tag", "found", "in", "the", "given", "input", "string", "contains", "an", "attribute", "with", "the", "given", "name", "and", "value", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/Matching.php#L70-L80
43,490
Holt59/cakephp3-bootstrap-helpers
src/Utility/Matching.php
Matching.findTagOrAttribute
public static function findTagOrAttribute($tag, $attrs, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } if (!is_null($attrs) && !is_array($attrs)) { $attrs = [$attrs => null]; } while ($xml->read()) { if (!is_null($tag) && $xml->name == $tag) { return true; // tag found } if (!is_null($attrs)) { foreach ($attrs as $attr => $attrValue) { $value = $xml->getAttribute($attr); if (!is_null($value) && (is_null($attrValue) || $value == $attrValue)) { return true; } } } } return false; }
php
public static function findTagOrAttribute($tag, $attrs, $subject) { $xml = new \XMLReader(); $xml->xml($subject, 'UTF-8', LIBXML_NOERROR | LIBXML_ERR_NONE); // failed to parse => false if ($xml->read() === false) { return false; } if (!is_null($attrs) && !is_array($attrs)) { $attrs = [$attrs => null]; } while ($xml->read()) { if (!is_null($tag) && $xml->name == $tag) { return true; // tag found } if (!is_null($attrs)) { foreach ($attrs as $attr => $attrValue) { $value = $xml->getAttribute($attr); if (!is_null($value) && (is_null($attrValue) || $value == $attrValue)) { return true; } } } } return false; }
[ "public", "static", "function", "findTagOrAttribute", "(", "$", "tag", ",", "$", "attrs", ",", "$", "subject", ")", "{", "$", "xml", "=", "new", "\\", "XMLReader", "(", ")", ";", "$", "xml", "->", "xml", "(", "$", "subject", ",", "'UTF-8'", ",", "L...
Check if the given input string contains an element with the given type name or attribute. @param string $tag Tag name to search for, or null if not relevant. @param string $attrs Array [name => value] for the attributes to search for, or null if not relevant. `value` can be null if only the name should be looked. @param string $subject String to search. @return bool True if the given tag or given attribute is found.
[ "Check", "if", "the", "given", "input", "string", "contains", "an", "element", "with", "the", "given", "type", "name", "or", "attribute", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/Utility/Matching.php#L93-L121
43,491
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper.create
public function create($title = null, $options = []) { if(is_array($title)) { $options = $title; } $this->_currentId = null; $this->_current = null; $options += [ 'id' => null, 'close' => true, 'body' => true, 'size' => false, 'templateVars' => [] ]; $dialogOptions = []; if($options['id']) { $this->_currentId = $options['id']; $options['aria-labelledby'] = $this->_currentId.'Label'; } switch($options['size']) { case 'lg': case 'large': case 'modal-lg': $size = ' modal-lg'; break; case 'sm': case 'small': case 'modal-sm': $size = ' modal-sm'; break; case false: $size = ''; break; default: $size = ' '.$options['size']; break; } $dialogOptions = $this->addClass($dialogOptions, $size); $dialogStart = $this->formatTemplate('modalDialogStart', [ 'attrs' => $this->templater()->formatAttributes($dialogOptions) ]); $contentStart = $this->formatTemplate('modalContentStart', []); $res = $this->formatTemplate('modalStart', [ 'dialogStart' => $dialogStart, 'contentStart' => $contentStart, 'attrs' => $this->templater()->formatAttributes($options, ['body', 'close', 'size']), 'templateVars' => $options['templateVars'] ]); if(is_string($title) && $title) { $res .= $this->_createHeader($title, ['close' => $options['close']]); if($options['body']) { $res .= $this->_createBody(); } } return $res; }
php
public function create($title = null, $options = []) { if(is_array($title)) { $options = $title; } $this->_currentId = null; $this->_current = null; $options += [ 'id' => null, 'close' => true, 'body' => true, 'size' => false, 'templateVars' => [] ]; $dialogOptions = []; if($options['id']) { $this->_currentId = $options['id']; $options['aria-labelledby'] = $this->_currentId.'Label'; } switch($options['size']) { case 'lg': case 'large': case 'modal-lg': $size = ' modal-lg'; break; case 'sm': case 'small': case 'modal-sm': $size = ' modal-sm'; break; case false: $size = ''; break; default: $size = ' '.$options['size']; break; } $dialogOptions = $this->addClass($dialogOptions, $size); $dialogStart = $this->formatTemplate('modalDialogStart', [ 'attrs' => $this->templater()->formatAttributes($dialogOptions) ]); $contentStart = $this->formatTemplate('modalContentStart', []); $res = $this->formatTemplate('modalStart', [ 'dialogStart' => $dialogStart, 'contentStart' => $contentStart, 'attrs' => $this->templater()->formatAttributes($options, ['body', 'close', 'size']), 'templateVars' => $options['templateVars'] ]); if(is_string($title) && $title) { $res .= $this->_createHeader($title, ['close' => $options['close']]); if($options['body']) { $res .= $this->_createBody(); } } return $res; }
[ "public", "function", "create", "(", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "$", "options", "=", "$", "title", ";", "}", "$", "this", "->", "_currentId", ...
Open a modal If `$title` is a string, the modal header is created using `$title` as its content and default options. ```php echo $this->Modal->create('My Modal Title'); ``` If the modal header is created, the modal body is automatically opened after it, except if the `body` options is specified(see below). If `$title` is an array, it is used as `$options`. ```php echo $this->Modal->create(['class' => 'my-modal-class']); ``` ### Options - `body` If `$title` is a string, set to `false` to not open the body after the panel header. Default is `true`. - `close` Set to `false` to not add a close button to the modal. Default is `true`. - `id` Identifier of the modal. If specified, a `aria-labelledby` HTML attribute will be added to the modal and the header will be set accordingly. - `size` Size of the modal. Either a shortcut(`'lg'`/`'large'`/`'modal-lg'` or (`'sm'`/`'small'`/`'modal-sm'`) or `false`(no size specified) or a custom class. Other options will be passed to the `Html::div` method for creating the outer modal `<div>`. @param array|string $title The modal title or an array of options. @param array $options Array of options. See above. @return string An HTML string containing opening elements for a modal.
[ "Open", "a", "modal" ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L120-L181
43,492
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper.end
public function end($buttons = NULL, $options = []) { $res = $this->_cleanCurrent(); if($buttons !== null) { $res .= $this->footer($buttons, $options); } $res .= $this->formatTemplate('modalEnd', [ 'contentEnd' => $this->formatTemplate('modalContentEnd', []), 'dialogEnd' => $this->formatTemplate('modalDialogEnd', []) ]); return $res; }
php
public function end($buttons = NULL, $options = []) { $res = $this->_cleanCurrent(); if($buttons !== null) { $res .= $this->footer($buttons, $options); } $res .= $this->formatTemplate('modalEnd', [ 'contentEnd' => $this->formatTemplate('modalContentEnd', []), 'dialogEnd' => $this->formatTemplate('modalDialogEnd', []) ]); return $res; }
[ "public", "function", "end", "(", "$", "buttons", "=", "NULL", ",", "$", "options", "=", "[", "]", ")", "{", "$", "res", "=", "$", "this", "->", "_cleanCurrent", "(", ")", ";", "if", "(", "$", "buttons", "!==", "null", ")", "{", "$", "res", ".=...
Closes a modal, cleans part that have not been closed correctly and optionaly adds a footer with buttons to the modal. If `$buttons` is not null, the `footer()` method will be used to create the modal footer using `$buttons` and `$options`: ```php echo $this->Modal->end([$this->Form->button('Save'), $this->Form->button('Close')]); ``` @param array $buttons Array of buttons for the `footer()` method or `null`. @param array $options Array of options for the `footer()` method. @return string An HTML string containing closing tags for the modal.
[ "Closes", "a", "modal", "cleans", "part", "that", "have", "not", "been", "closed", "correctly", "and", "optionaly", "adds", "a", "footer", "with", "buttons", "to", "the", "modal", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L199-L209
43,493
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper._cleanCurrent
protected function _cleanCurrent() { if($this->_current) { $current = $this->_current; $this->_current = null; return $this->formatTemplate($current.'End', []); } return ''; }
php
protected function _cleanCurrent() { if($this->_current) { $current = $this->_current; $this->_current = null; return $this->formatTemplate($current.'End', []); } return ''; }
[ "protected", "function", "_cleanCurrent", "(", ")", "{", "if", "(", "$", "this", "->", "_current", ")", "{", "$", "current", "=", "$", "this", "->", "_current", ";", "$", "this", "->", "_current", "=", "null", ";", "return", "$", "this", "->", "forma...
Cleans the current modal part and return necessary HTML closing elements. @return string An HTML string containing closing elements.
[ "Cleans", "the", "current", "modal", "part", "and", "return", "necessary", "HTML", "closing", "elements", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L216-L223
43,494
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper._part
protected function _part($part, $content = null, $options = []) { $options += [ 'templateVars' => [] ]; $out = $this->_cleanCurrent(); $out .= $this->formatTemplate($part.'Start', [ 'attrs' => $this->templater()->formatAttributes($options, ['close']), 'templateVars' => $options ]); $this->_current = $part; if ($content) { $out .= $content; $out .= $this->_cleanCurrent(); } return $out; }
php
protected function _part($part, $content = null, $options = []) { $options += [ 'templateVars' => [] ]; $out = $this->_cleanCurrent(); $out .= $this->formatTemplate($part.'Start', [ 'attrs' => $this->templater()->formatAttributes($options, ['close']), 'templateVars' => $options ]); $this->_current = $part; if ($content) { $out .= $content; $out .= $this->_cleanCurrent(); } return $out; }
[ "protected", "function", "_part", "(", "$", "part", ",", "$", "content", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "$", "out", "=", "$", "this", "->", "_clean...
Cleans the current modal part, create a new ones with the given content, and update the internal `_current` variable if necessary. @param string $part The name of the part(`'header'`, `'body'`, `'footer'`). @param string $content The content of the part or `null`. @param array $options Array of options for the `Html::tag` method. @return string
[ "Cleans", "the", "current", "modal", "part", "create", "a", "new", "ones", "with", "the", "given", "content", "and", "update", "the", "internal", "_current", "variable", "if", "necessary", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L235-L250
43,495
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper._createHeader
protected function _createHeader($title = null, $options = []) { $options += [ 'close' => true ]; $out = null; if($title) { $out = ''; if($options['close']) { $out .= $this->formatTemplate('modalHeaderCloseButton', [ 'content' => $this->formatTemplate('modalHeaderCloseContent', []), 'label' => __('Close') ]); } $out .= $this->formatTemplate('modalTitle', [ 'content' => $title, 'attrs' => $this->templater()->formatAttributes([ 'id' => $this->_currentId ? $this->_currentId.'Label' : false ]) ]); } return $this->_part('header', $out, $options); }
php
protected function _createHeader($title = null, $options = []) { $options += [ 'close' => true ]; $out = null; if($title) { $out = ''; if($options['close']) { $out .= $this->formatTemplate('modalHeaderCloseButton', [ 'content' => $this->formatTemplate('modalHeaderCloseContent', []), 'label' => __('Close') ]); } $out .= $this->formatTemplate('modalTitle', [ 'content' => $title, 'attrs' => $this->templater()->formatAttributes([ 'id' => $this->_currentId ? $this->_currentId.'Label' : false ]) ]); } return $this->_part('header', $out, $options); }
[ "protected", "function", "_createHeader", "(", "$", "title", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'close'", "=>", "true", "]", ";", "$", "out", "=", "null", ";", "if", "(", "$", "title", ")", "{",...
Create or open a modal header. ### Options - `close` Set to `false` to not add a close button to the modal. Default is `true`. - `templateVars` Provide template variables for the `headerStart` template. - Other attributes will be assigned to the modal header element. @param string $text The modal header content, or null to only open the header. @param array $options Array of options. See above. @return string A formated opening tag for the modal header or the complete modal header. @see `BootstrapModalHelper::header`
[ "Create", "or", "open", "a", "modal", "header", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L269-L290
43,496
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/ModalHelper.php
ModalHelper.body
public function body($info = null, $options = []) { if(is_array($info)) { $options = $info; $info = null; } return $this->_createBody($info, $options); }
php
public function body($info = null, $options = []) { if(is_array($info)) { $options = $info; $info = null; } return $this->_createBody($info, $options); }
[ "public", "function", "body", "(", "$", "info", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "is_array", "(", "$", "info", ")", ")", "{", "$", "options", "=", "$", "info", ";", "$", "info", "=", "null", ";", "}", "ret...
Create or open a modal body. If `$content` is a string, create a modal body using the specified content and `$options`. ```php echo $this->Modal->body('Modal Content', ['class' => 'my-class']); ``` If `$content` is `null`, create a formated opening tag for a modal body using the specified `$options`. ```php echo $this->Modal->body(null, ['class' => 'my-class']); ``` If `$content` is an array, used it as `$options` and create a formated opening tag for a modal body. ```php echo $this->Modal->body(['class' => 'my-class']); ``` ### Options - `templateVars` Provide template variables for the `bodyStart` template. - Other attributes will be assigned to the modal body element. @param array|string $info The body content, or `null`, or an array of options. `$options`. @param array $options Array of options. See above. @return string A formated opening tag for the modal body or the complete modal body.
[ "Create", "or", "open", "a", "modal", "body", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/ModalHelper.php#L421-L427
43,497
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.link
public function link($name, $url = '', array $options = [], array $linkOptions = []) { $url = $this->Url->build($url); $options += [ 'active' => [], 'templateVars' => [] ]; $linkOptions += [ 'templateVars' => [] ]; if (is_string($options['active'])) { $options['active'] = []; } if ($this->getConfig('autoActiveLink') && is_array($options['active'])) { $options['active'] = $this->compareUrls($url, null, $options['active']); } $active = $options['active'] ? 'Active' : ''; $level = $this->_level > 1 ? 'inner' : 'outer'; $template = $level.'MenuItem'.$active; $linkTemplate = $level.'MenuItemLink'.$active; $link = $this->formatTemplate($linkTemplate, [ 'content' => $name, 'url' => $url, 'attrs' => $this->templater()->formatAttributes($linkOptions), 'templateVars' => $linkOptions['templateVars'] ]); return $this->formatTemplate($template, [ 'link' => $link, 'attrs' => $this->templater()->formatAttributes($options, ['active']), 'templateVars' => $options['templateVars'] ]); }
php
public function link($name, $url = '', array $options = [], array $linkOptions = []) { $url = $this->Url->build($url); $options += [ 'active' => [], 'templateVars' => [] ]; $linkOptions += [ 'templateVars' => [] ]; if (is_string($options['active'])) { $options['active'] = []; } if ($this->getConfig('autoActiveLink') && is_array($options['active'])) { $options['active'] = $this->compareUrls($url, null, $options['active']); } $active = $options['active'] ? 'Active' : ''; $level = $this->_level > 1 ? 'inner' : 'outer'; $template = $level.'MenuItem'.$active; $linkTemplate = $level.'MenuItemLink'.$active; $link = $this->formatTemplate($linkTemplate, [ 'content' => $name, 'url' => $url, 'attrs' => $this->templater()->formatAttributes($linkOptions), 'templateVars' => $linkOptions['templateVars'] ]); return $this->formatTemplate($template, [ 'link' => $link, 'attrs' => $this->templater()->formatAttributes($options, ['active']), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "link", "(", "$", "name", ",", "$", "url", "=", "''", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "linkOptions", "=", "[", "]", ")", "{", "$", "url", "=", "$", "this", "->", "Url", "->", "build", "(", ...
Add a link to the navbar or to a menu. Encapsulate links with `beginMenu()`, `endMenu()` to create a horizontal hover menu in the navbar or a dropdown menu. ### Options - `active` Indicates if the link is the current one. Default is automatically deduced if `autoActiveLink` is on, otherwize default is `false`. - `templateVars` Provide template variables for the templates. - Other attributes will be assigned to the navbar link element. @param string $name The link text. @param string|array $url The link URL (CakePHP way). @param array $options Array of attributes for the wrapper tag. @param array $linkOptions Array of attributes for the link. @return string A HTML tag wrapping the link.
[ "Add", "a", "link", "to", "the", "navbar", "or", "to", "a", "menu", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L233-L263
43,498
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.divider
public function divider(array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemDivider', [ 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function divider(array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemDivider', [ 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "divider", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate", "(", "'innerMenuItemDivider'", ",", "[", "'attrs...
Add a divider to an inner menu of the navbar. ### Options - `templateVars` Provide template variables for the divider template. - Other attributes will be assigned to the divider element. @param array $options Array of options. See above. @return A HTML dropdown divider tag.
[ "Add", "a", "divider", "to", "an", "inner", "menu", "of", "the", "navbar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L293-L299
43,499
Holt59/cakephp3-bootstrap-helpers
src/View/Helper/NavbarHelper.php
NavbarHelper.header
public function header($name, array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemHeader', [ 'content' => $name, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
php
public function header($name, array $options = []) { $options += ['templateVars' => []]; return $this->formatTemplate('innerMenuItemHeader', [ 'content' => $name, 'attrs' => $this->templater()->formatAttributes($options), 'templateVars' => $options['templateVars'] ]); }
[ "public", "function", "header", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'templateVars'", "=>", "[", "]", "]", ";", "return", "$", "this", "->", "formatTemplate", "(", "'innerMenuItemHeader'", ...
Add a header to an inner menu of the navbar. ### Options - `templateVars` Provide template variables for the header template. - Other attributes will be assigned to the header element. * @param string $name Title of the header. @param array $options Array of options for the wrapper tag. @return A HTML header tag.
[ "Add", "a", "header", "to", "an", "inner", "menu", "of", "the", "navbar", "." ]
30dda77c540a8da7d336a1201acb86bced220cb8
https://github.com/Holt59/cakephp3-bootstrap-helpers/blob/30dda77c540a8da7d336a1201acb86bced220cb8/src/View/Helper/NavbarHelper.php#L314-L321