repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getNodeTranslationByNodeIdQueryBuilder
public function getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang) { $qb = $this->createQueryBuilder('nt') ->select('nt') ->innerJoin('nt.node', 'n', 'WITH', 'nt.node = n.id') ->where('n.deleted != 1') ->andWhere('nt.online = 1') ->andWhere('nt.lang = :lang') ->setParameter('lang', $lang) ->andWhere('n.id = :node_id') ->setParameter('node_id', $nodeId) ->setFirstResult(0) ->setMaxResults(1); return $qb->getQuery()->getOneOrNullResult(); }
php
public function getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang) { $qb = $this->createQueryBuilder('nt') ->select('nt') ->innerJoin('nt.node', 'n', 'WITH', 'nt.node = n.id') ->where('n.deleted != 1') ->andWhere('nt.online = 1') ->andWhere('nt.lang = :lang') ->setParameter('lang', $lang) ->andWhere('n.id = :node_id') ->setParameter('node_id', $nodeId) ->setFirstResult(0) ->setMaxResults(1); return $qb->getQuery()->getOneOrNullResult(); }
[ "public", "function", "getNodeTranslationByNodeIdQueryBuilder", "(", "$", "nodeId", ",", "$", "lang", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'nt'", ")", "->", "select", "(", "'nt'", ")", "->", "innerJoin", "(", "'nt.node'", ...
Get the QueryBuilder based on node id and language. @param int $nodeId @param string $lang @return array_shift($result)
[ "Get", "the", "QueryBuilder", "based", "on", "node", "id", "and", "language", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L28-L43
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getMaxChildrenWeight
public function getMaxChildrenWeight(Node $parentNode = null, $lang = null) { $maxWeight = $this->getNodeTranslationsQueryBuilder($lang) ->select('max(nt.weight)') ->andWhere('n.parent = :parentNode') ->setParameter('parentNode', $parentNode) ->getQuery() ->getSingleScalarResult(); return (int) $maxWeight; }
php
public function getMaxChildrenWeight(Node $parentNode = null, $lang = null) { $maxWeight = $this->getNodeTranslationsQueryBuilder($lang) ->select('max(nt.weight)') ->andWhere('n.parent = :parentNode') ->setParameter('parentNode', $parentNode) ->getQuery() ->getSingleScalarResult(); return (int) $maxWeight; }
[ "public", "function", "getMaxChildrenWeight", "(", "Node", "$", "parentNode", "=", "null", ",", "$", "lang", "=", "null", ")", "{", "$", "maxWeight", "=", "$", "this", "->", "getNodeTranslationsQueryBuilder", "(", "$", "lang", ")", "->", "select", "(", "'m...
Get max children weight @param Node $parentNode @param string $lang (optional) Only return max weight for the given language @return int
[ "Get", "max", "children", "weight" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L54-L64
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getNodeTranslationFor
public function getNodeTranslationFor(HasNodeInterface $hasNode) { /* @var NodeVersion $nodeVersion */ $nodeVersion = $this->getEntityManager() ->getRepository('KunstmaanNodeBundle:NodeVersion') ->getNodeVersionFor($hasNode); if (!is_null($nodeVersion)) { return $nodeVersion->getNodeTranslation(); } return null; }
php
public function getNodeTranslationFor(HasNodeInterface $hasNode) { /* @var NodeVersion $nodeVersion */ $nodeVersion = $this->getEntityManager() ->getRepository('KunstmaanNodeBundle:NodeVersion') ->getNodeVersionFor($hasNode); if (!is_null($nodeVersion)) { return $nodeVersion->getNodeTranslation(); } return null; }
[ "public", "function", "getNodeTranslationFor", "(", "HasNodeInterface", "$", "hasNode", ")", "{", "/* @var NodeVersion $nodeVersion */", "$", "nodeVersion", "=", "$", "this", "->", "getEntityManager", "(", ")", "->", "getRepository", "(", "'KunstmaanNodeBundle:NodeVersion...
Get the node translation for a node @param HasNodeInterface $hasNode @return NodeTranslation
[ "Get", "the", "node", "translation", "for", "a", "node" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L182-L194
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getNodeTranslationForSlug
public function getNodeTranslationForSlug( $slug, NodeTranslation $parentNode = null ) { if (empty($slug)) { return $this->getNodeTranslationForSlugPart(null, $slug); } $slugParts = explode('/', $slug); $result = $parentNode; foreach ($slugParts as $slugPart) { $result = $this->getNodeTranslationForSlugPart($result, $slugPart); } return $result; }
php
public function getNodeTranslationForSlug( $slug, NodeTranslation $parentNode = null ) { if (empty($slug)) { return $this->getNodeTranslationForSlugPart(null, $slug); } $slugParts = explode('/', $slug); $result = $parentNode; foreach ($slugParts as $slugPart) { $result = $this->getNodeTranslationForSlugPart($result, $slugPart); } return $result; }
[ "public", "function", "getNodeTranslationForSlug", "(", "$", "slug", ",", "NodeTranslation", "$", "parentNode", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "slug", ")", ")", "{", "return", "$", "this", "->", "getNodeTranslationForSlugPart", "(", "nu...
Get the node translation for a given slug string @param string $slug The slug @param NodeTranslation|null $parentNode The parentnode @return NodeTranslation|null
[ "Get", "the", "node", "translation", "for", "a", "given", "slug", "string" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L204-L219
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getNodeTranslationForSlugPart
private function getNodeTranslationForSlugPart( NodeTranslation $parentNode = null, $slugPart = '' ) { $qb = $this->createQueryBuilder('t') ->select('t', 'v', 'n') ->innerJoin('t.node', 'n', 'WITH', 't.node = n.id') ->leftJoin( 't.publicNodeVersion', 'v', 'WITH', 't.publicNodeVersion = v.id' ) ->where('n.deleted != 1') ->setFirstResult(0) ->setMaxResults(1); if ($parentNode !== null) { $qb->andWhere('t.slug = :slug') ->andWhere('n.parent = :parent') ->setParameter('slug', $slugPart) ->setParameter('parent', $parentNode->getNode()->getId()); } else { /* if parent is null we should look for slugs that have no parent */ $qb->andWhere('n.parent IS NULL'); if (empty($slugPart)) { $qb->andWhere('t.slug is NULL'); } else { $qb->andWhere('t.slug = :slug'); $qb->setParameter('slug', $slugPart); } } return $qb->getQuery()->getOneOrNullResult(); }
php
private function getNodeTranslationForSlugPart( NodeTranslation $parentNode = null, $slugPart = '' ) { $qb = $this->createQueryBuilder('t') ->select('t', 'v', 'n') ->innerJoin('t.node', 'n', 'WITH', 't.node = n.id') ->leftJoin( 't.publicNodeVersion', 'v', 'WITH', 't.publicNodeVersion = v.id' ) ->where('n.deleted != 1') ->setFirstResult(0) ->setMaxResults(1); if ($parentNode !== null) { $qb->andWhere('t.slug = :slug') ->andWhere('n.parent = :parent') ->setParameter('slug', $slugPart) ->setParameter('parent', $parentNode->getNode()->getId()); } else { /* if parent is null we should look for slugs that have no parent */ $qb->andWhere('n.parent IS NULL'); if (empty($slugPart)) { $qb->andWhere('t.slug is NULL'); } else { $qb->andWhere('t.slug = :slug'); $qb->setParameter('slug', $slugPart); } } return $qb->getQuery()->getOneOrNullResult(); }
[ "private", "function", "getNodeTranslationForSlugPart", "(", "NodeTranslation", "$", "parentNode", "=", "null", ",", "$", "slugPart", "=", "''", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'t'", ")", "->", "select", "(", "'t'", ...
Returns the node translation for a given slug @param NodeTranslation|null $parentNode The parentNode @param string $slugPart The slug part @return NodeTranslation|null
[ "Returns", "the", "node", "translation", "for", "a", "given", "slug" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L229-L263
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getTopNodeTranslations
public function getTopNodeTranslations() { $qb = $this->createQueryBuilder('b') ->select('b', 'v') ->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id') ->leftJoin( 'b.publicNodeVersion', 'v', 'WITH', 'b.publicNodeVersion = v.id' ) ->where('n.parent IS NULL') ->andWhere('n.deleted != 1'); return $qb->getQuery()->getResult(); }
php
public function getTopNodeTranslations() { $qb = $this->createQueryBuilder('b') ->select('b', 'v') ->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id') ->leftJoin( 'b.publicNodeVersion', 'v', 'WITH', 'b.publicNodeVersion = v.id' ) ->where('n.parent IS NULL') ->andWhere('n.deleted != 1'); return $qb->getQuery()->getResult(); }
[ "public", "function", "getTopNodeTranslations", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'b'", ")", "->", "select", "(", "'b'", ",", "'v'", ")", "->", "innerJoin", "(", "'b.node'", ",", "'n'", ",", "'WITH'", ",", "'...
Get all top node translations @return NodeTranslation[]
[ "Get", "all", "top", "node", "translations" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L363-L378
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.createNodeTranslationFor
public function createNodeTranslationFor( HasNodeInterface $hasNode, $lang, Node $node, BaseUser $owner ) { $em = $this->getEntityManager(); $className = ClassLookup::getClass($hasNode); if (!$hasNode->getId() > 0) { throw new \InvalidArgumentException( 'The entity of class ' . $className . ' has no id, maybe you forgot to flush first' ); } $nodeTranslation = new NodeTranslation(); $nodeTranslation ->setNode($node) ->setLang($lang) ->setTitle($hasNode->getTitle()) ->setOnline(false) ->setWeight(0); $em->persist($nodeTranslation); $nodeVersion = $em->getRepository('KunstmaanNodeBundle:NodeVersion') ->createNodeVersionFor( $hasNode, $nodeTranslation, $owner, null ); $nodeTranslation->setPublicNodeVersion($nodeVersion); $em->persist($nodeTranslation); $em->flush(); $em->refresh($nodeTranslation); $em->refresh($node); return $nodeTranslation; }
php
public function createNodeTranslationFor( HasNodeInterface $hasNode, $lang, Node $node, BaseUser $owner ) { $em = $this->getEntityManager(); $className = ClassLookup::getClass($hasNode); if (!$hasNode->getId() > 0) { throw new \InvalidArgumentException( 'The entity of class ' . $className . ' has no id, maybe you forgot to flush first' ); } $nodeTranslation = new NodeTranslation(); $nodeTranslation ->setNode($node) ->setLang($lang) ->setTitle($hasNode->getTitle()) ->setOnline(false) ->setWeight(0); $em->persist($nodeTranslation); $nodeVersion = $em->getRepository('KunstmaanNodeBundle:NodeVersion') ->createNodeVersionFor( $hasNode, $nodeTranslation, $owner, null ); $nodeTranslation->setPublicNodeVersion($nodeVersion); $em->persist($nodeTranslation); $em->flush(); $em->refresh($nodeTranslation); $em->refresh($node); return $nodeTranslation; }
[ "public", "function", "createNodeTranslationFor", "(", "HasNodeInterface", "$", "hasNode", ",", "$", "lang", ",", "Node", "$", "node", ",", "BaseUser", "$", "owner", ")", "{", "$", "em", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "cl...
Create a node translation for a given node @param HasNodeInterface $hasNode The hasNode @param string $lang The locale @param Node $node The node @param BaseUser $owner The user @throws \InvalidArgumentException @return NodeTranslation
[ "Create", "a", "node", "translation", "for", "a", "given", "node" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L392-L432
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.addDraftNodeVersionFor
public function addDraftNodeVersionFor( HasNodeInterface $hasNode, $lang, Node $node, BaseUser $owner ) { $em = $this->getEntityManager(); $className = ClassLookup::getClass($hasNode); if (!$hasNode->getId() > 0) { throw new \InvalidArgumentException( 'The entity of class ' . $className . ' has no id, maybe you forgot to flush first' ); } $nodeTranslation = $em->getRepository('KunstmaanNodeBundle:NodeTranslation')->findOneBy(['lang' => $lang, 'node' => $node]); $em->getRepository('KunstmaanNodeBundle:NodeVersion') ->createNodeVersionFor( $hasNode, $nodeTranslation, $owner, null, NodeVersion::DRAFT_VERSION ); $em->refresh($nodeTranslation); $em->refresh($node); return $nodeTranslation; }
php
public function addDraftNodeVersionFor( HasNodeInterface $hasNode, $lang, Node $node, BaseUser $owner ) { $em = $this->getEntityManager(); $className = ClassLookup::getClass($hasNode); if (!$hasNode->getId() > 0) { throw new \InvalidArgumentException( 'The entity of class ' . $className . ' has no id, maybe you forgot to flush first' ); } $nodeTranslation = $em->getRepository('KunstmaanNodeBundle:NodeTranslation')->findOneBy(['lang' => $lang, 'node' => $node]); $em->getRepository('KunstmaanNodeBundle:NodeVersion') ->createNodeVersionFor( $hasNode, $nodeTranslation, $owner, null, NodeVersion::DRAFT_VERSION ); $em->refresh($nodeTranslation); $em->refresh($node); return $nodeTranslation; }
[ "public", "function", "addDraftNodeVersionFor", "(", "HasNodeInterface", "$", "hasNode", ",", "$", "lang", ",", "Node", "$", "node", ",", "BaseUser", "$", "owner", ")", "{", "$", "em", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "clas...
Add a draft node version for a given node @param HasNodeInterface $hasNode The hasNode @param string $lang The locale @param Node $node The node @param BaseUser $owner The user @throws \InvalidArgumentException @return NodeTranslation
[ "Add", "a", "draft", "node", "version", "for", "a", "given", "node" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L446-L476
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.getBestMatchForUrl
public function getBestMatchForUrl($urlSlug, $locale) { $em = $this->getEntityManager(); $rsm = new ResultSetMappingBuilder($em); $rsm->addRootEntityFromClassMetadata( 'Kunstmaan\NodeBundle\Entity\NodeTranslation', 'nt' ); $query = $em ->createNativeQuery( 'select nt.* from kuma_node_translations nt join kuma_nodes n on n.id = nt.node_id where n.deleted = 0 and nt.lang = :lang and locate(nt.url, :url) = 1 order by length(nt.url) desc limit 1', $rsm ); $query->setParameter('lang', $locale); $query->setParameter('url', $urlSlug); $translation = $query->getOneOrNullResult(); return $translation; }
php
public function getBestMatchForUrl($urlSlug, $locale) { $em = $this->getEntityManager(); $rsm = new ResultSetMappingBuilder($em); $rsm->addRootEntityFromClassMetadata( 'Kunstmaan\NodeBundle\Entity\NodeTranslation', 'nt' ); $query = $em ->createNativeQuery( 'select nt.* from kuma_node_translations nt join kuma_nodes n on n.id = nt.node_id where n.deleted = 0 and nt.lang = :lang and locate(nt.url, :url) = 1 order by length(nt.url) desc limit 1', $rsm ); $query->setParameter('lang', $locale); $query->setParameter('url', $urlSlug); $translation = $query->getOneOrNullResult(); return $translation; }
[ "public", "function", "getBestMatchForUrl", "(", "$", "urlSlug", ",", "$", "locale", ")", "{", "$", "em", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "rsm", "=", "new", "ResultSetMappingBuilder", "(", "$", "em", ")", ";", "$", "rsm"...
Find best match for given URL and locale @param string $urlSlug The slug @param string $locale The locale @return NodeTranslation
[ "Find", "best", "match", "for", "given", "URL", "and", "locale" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L486-L510
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php
NodeTranslationRepository.hasParentNodeTranslationsForLanguage
public function hasParentNodeTranslationsForLanguage( NodeTranslation $nodeTranslation, $language ) { $parentNode = $nodeTranslation->getNode()->getParent(); if ($parentNode !== null) { $parentNodeTranslation = $parentNode->getNodeTranslation( $language, true ); if ($parentNodeTranslation !== null) { return $this->hasParentNodeTranslationsForLanguage( $parentNodeTranslation, $language ); } else { return false; } } return true; }
php
public function hasParentNodeTranslationsForLanguage( NodeTranslation $nodeTranslation, $language ) { $parentNode = $nodeTranslation->getNode()->getParent(); if ($parentNode !== null) { $parentNodeTranslation = $parentNode->getNodeTranslation( $language, true ); if ($parentNodeTranslation !== null) { return $this->hasParentNodeTranslationsForLanguage( $parentNodeTranslation, $language ); } else { return false; } } return true; }
[ "public", "function", "hasParentNodeTranslationsForLanguage", "(", "NodeTranslation", "$", "nodeTranslation", ",", "$", "language", ")", "{", "$", "parentNode", "=", "$", "nodeTranslation", "->", "getNode", "(", ")", "->", "getParent", "(", ")", ";", "if", "(", ...
Test if all parents of the specified NodeTranslation have a node translation for the specified language @param NodeTranslation $nodeTranslation The node translation @param string $language The locale @return bool
[ "Test", "if", "all", "parents", "of", "the", "specified", "NodeTranslation", "have", "a", "node", "translation", "for", "the", "specified", "language" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeTranslationRepository.php#L521-L542
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/AbstractAnalyticsCommandHelper.php
AbstractAnalyticsCommandHelper.getExtra
protected function getExtra(AnalyticsOverview $overview) { $extra = array(); // add segment if ($overview->getSegment()) { $extra['segment'] = $overview->getSegment()->getQuery(); } return $extra; }
php
protected function getExtra(AnalyticsOverview $overview) { $extra = array(); // add segment if ($overview->getSegment()) { $extra['segment'] = $overview->getSegment()->getQuery(); } return $extra; }
[ "protected", "function", "getExtra", "(", "AnalyticsOverview", "$", "overview", ")", "{", "$", "extra", "=", "array", "(", ")", ";", "// add segment", "if", "(", "$", "overview", "->", "getSegment", "(", ")", ")", "{", "$", "extra", "[", "'segment'", "]"...
get the extra data for an overview, can be overridden @return array
[ "get", "the", "extra", "data", "for", "an", "overview", "can", "be", "overridden" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/AbstractAnalyticsCommandHelper.php#L68-L78
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/AbstractAnalyticsCommandHelper.php
AbstractAnalyticsCommandHelper.executeQuery
protected function executeQuery(AnalyticsOverview $overview, $metrics) { $timestamps = $this->getTimestamps($overview); $extra = $this->getExtra($overview); // execute query $results = $this->query->getResultsByDate( $timestamps['begin'], $timestamps['end'], $metrics, $extra ); return $results->getRows(); }
php
protected function executeQuery(AnalyticsOverview $overview, $metrics) { $timestamps = $this->getTimestamps($overview); $extra = $this->getExtra($overview); // execute query $results = $this->query->getResultsByDate( $timestamps['begin'], $timestamps['end'], $metrics, $extra ); return $results->getRows(); }
[ "protected", "function", "executeQuery", "(", "AnalyticsOverview", "$", "overview", ",", "$", "metrics", ")", "{", "$", "timestamps", "=", "$", "this", "->", "getTimestamps", "(", "$", "overview", ")", ";", "$", "extra", "=", "$", "this", "->", "getExtra",...
Executes the query @return array the resultset
[ "Executes", "the", "query" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/AbstractAnalyticsCommandHelper.php#L85-L99
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/ArticleBundle/AdminList/AbstractArticleCategoryAdminListConfigurator.php
AbstractArticleCategoryAdminListConfigurator.getQuery
public function getQuery() { $query = parent::getQuery(); if (!is_null($query)) { $query->setHint( \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker' ); $query->useQueryCache(false); } return $query; }
php
public function getQuery() { $query = parent::getQuery(); if (!is_null($query)) { $query->setHint( \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker' ); $query->useQueryCache(false); } return $query; }
[ "public", "function", "getQuery", "(", ")", "{", "$", "query", "=", "parent", "::", "getQuery", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "query", ")", ")", "{", "$", "query", "->", "setHint", "(", "\\", "Doctrine", "\\", "ORM", "\\", "...
Overwrite the parent function. By adding the TranslationWalker, we can order by the translated fields. @return \Doctrine\ORM\Query|null
[ "Overwrite", "the", "parent", "function", ".", "By", "adding", "the", "TranslationWalker", "we", "can", "order", "by", "the", "translated", "fields", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/ArticleBundle/AdminList/AbstractArticleCategoryAdminListConfigurator.php#L74-L87
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MediaBundle/AdminList/MediaAdminListConfigurator.php
MediaAdminListConfigurator.buildItemActions
public function buildItemActions() { if ($this->request->get('_route') == 'KunstmaanMediaBundle_chooser_show_folder') { $this->addItemAction(new MediaSelectItemAction()); } else { $this->addItemAction(new MediaEditItemAction()); $this->addItemAction(new MediaDeleteItemAction($this->request->getRequestUri())); } }
php
public function buildItemActions() { if ($this->request->get('_route') == 'KunstmaanMediaBundle_chooser_show_folder') { $this->addItemAction(new MediaSelectItemAction()); } else { $this->addItemAction(new MediaEditItemAction()); $this->addItemAction(new MediaDeleteItemAction($this->request->getRequestUri())); } }
[ "public", "function", "buildItemActions", "(", ")", "{", "if", "(", "$", "this", "->", "request", "->", "get", "(", "'_route'", ")", "==", "'KunstmaanMediaBundle_chooser_show_folder'", ")", "{", "$", "this", "->", "addItemAction", "(", "new", "MediaSelectItemAct...
Add item actions buttons
[ "Add", "item", "actions", "buttons" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/AdminList/MediaAdminListConfigurator.php#L119-L127
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeAdminPublisher.php
NodeAdminPublisher.publish
public function publish(NodeTranslation $nodeTranslation, $user = null) { if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_PUBLISH, $nodeTranslation->getNode())) { throw new AccessDeniedException(); } if (is_null($user)) { $user = $this->tokenStorage->getToken()->getUser(); } $node = $nodeTranslation->getNode(); $nodeVersion = $nodeTranslation->getNodeVersion('draft'); if (!is_null($nodeVersion)) { $page = $nodeVersion->getRef($this->em); /** @var $nodeVersion NodeVersion */ $nodeVersion = $this->createPublicVersion($page, $nodeTranslation, $nodeVersion, $user); $nodeTranslation = $nodeVersion->getNodeTranslation(); } else { $nodeVersion = $nodeTranslation->getPublicNodeVersion(); } $page = $nodeVersion->getRef($this->em); $this->eventDispatcher->dispatch( Events::PRE_PUBLISH, new NodeEvent($node, $nodeTranslation, $nodeVersion, $page) ); $nodeTranslation ->setOnline(true) ->setPublicNodeVersion($nodeVersion) ->setUpdated(new \DateTime()); $this->em->persist($nodeTranslation); $this->em->flush(); // Remove scheduled task $this->unSchedulePublish($nodeTranslation); $this->eventDispatcher->dispatch( Events::POST_PUBLISH, new NodeEvent($node, $nodeTranslation, $nodeVersion, $page) ); }
php
public function publish(NodeTranslation $nodeTranslation, $user = null) { if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_PUBLISH, $nodeTranslation->getNode())) { throw new AccessDeniedException(); } if (is_null($user)) { $user = $this->tokenStorage->getToken()->getUser(); } $node = $nodeTranslation->getNode(); $nodeVersion = $nodeTranslation->getNodeVersion('draft'); if (!is_null($nodeVersion)) { $page = $nodeVersion->getRef($this->em); /** @var $nodeVersion NodeVersion */ $nodeVersion = $this->createPublicVersion($page, $nodeTranslation, $nodeVersion, $user); $nodeTranslation = $nodeVersion->getNodeTranslation(); } else { $nodeVersion = $nodeTranslation->getPublicNodeVersion(); } $page = $nodeVersion->getRef($this->em); $this->eventDispatcher->dispatch( Events::PRE_PUBLISH, new NodeEvent($node, $nodeTranslation, $nodeVersion, $page) ); $nodeTranslation ->setOnline(true) ->setPublicNodeVersion($nodeVersion) ->setUpdated(new \DateTime()); $this->em->persist($nodeTranslation); $this->em->flush(); // Remove scheduled task $this->unSchedulePublish($nodeTranslation); $this->eventDispatcher->dispatch( Events::POST_PUBLISH, new NodeEvent($node, $nodeTranslation, $nodeVersion, $page) ); }
[ "public", "function", "publish", "(", "NodeTranslation", "$", "nodeTranslation", ",", "$", "user", "=", "null", ")", "{", "if", "(", "false", "===", "$", "this", "->", "authorizationChecker", "->", "isGranted", "(", "PermissionMap", "::", "PERMISSION_PUBLISH", ...
If there is a draft version it'll try to publish the draft first. Makse snese because if you want to publish the public version you don't publish but you save. @param NodeTranslation $nodeTranslation @param null|BaseUser $user @throws AccessDeniedException
[ "If", "there", "is", "a", "draft", "version", "it", "ll", "try", "to", "publish", "the", "draft", "first", ".", "Makse", "snese", "because", "if", "you", "want", "to", "publish", "the", "public", "version", "you", "don", "t", "publish", "but", "you", "...
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeAdminPublisher.php#L81-L123
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeAdminPublisher.php
NodeAdminPublisher.createPublicVersion
public function createPublicVersion( HasNodeInterface $page, NodeTranslation $nodeTranslation, NodeVersion $nodeVersion, BaseUser $user ) { $newPublicPage = $this->cloneHelper->deepCloneAndSave($page); $newNodeVersion = $this->em->getRepository('KunstmaanNodeBundle:NodeVersion')->createNodeVersionFor( $newPublicPage, $nodeTranslation, $user, $nodeVersion ); $newNodeVersion ->setOwner($nodeVersion->getOwner()) ->setUpdated($nodeVersion->getUpdated()) ->setCreated($nodeVersion->getCreated()); $nodeVersion ->setOwner($user) ->setCreated(new \DateTime()) ->setOrigin($newNodeVersion); $this->em->persist($newNodeVersion); $this->em->persist($nodeVersion); $this->em->persist($nodeTranslation); $this->em->flush(); $this->eventDispatcher->dispatch( Events::CREATE_PUBLIC_VERSION, new NodeEvent($nodeTranslation->getNode(), $nodeTranslation, $nodeVersion, $newPublicPage) ); return $newNodeVersion; }
php
public function createPublicVersion( HasNodeInterface $page, NodeTranslation $nodeTranslation, NodeVersion $nodeVersion, BaseUser $user ) { $newPublicPage = $this->cloneHelper->deepCloneAndSave($page); $newNodeVersion = $this->em->getRepository('KunstmaanNodeBundle:NodeVersion')->createNodeVersionFor( $newPublicPage, $nodeTranslation, $user, $nodeVersion ); $newNodeVersion ->setOwner($nodeVersion->getOwner()) ->setUpdated($nodeVersion->getUpdated()) ->setCreated($nodeVersion->getCreated()); $nodeVersion ->setOwner($user) ->setCreated(new \DateTime()) ->setOrigin($newNodeVersion); $this->em->persist($newNodeVersion); $this->em->persist($nodeVersion); $this->em->persist($nodeTranslation); $this->em->flush(); $this->eventDispatcher->dispatch( Events::CREATE_PUBLIC_VERSION, new NodeEvent($nodeTranslation->getNode(), $nodeTranslation, $nodeVersion, $newPublicPage) ); return $newNodeVersion; }
[ "public", "function", "createPublicVersion", "(", "HasNodeInterface", "$", "page", ",", "NodeTranslation", "$", "nodeTranslation", ",", "NodeVersion", "$", "nodeVersion", ",", "BaseUser", "$", "user", ")", "{", "$", "newPublicPage", "=", "$", "this", "->", "clon...
This shouldn't be here either but it's an improvement. @param HasNodeInterface $page The page @param NodeTranslation $nodeTranslation The node translation @param NodeVersion $nodeVersion The node version @param BaseUser $user The user @return mixed
[ "This", "shouldn", "t", "be", "here", "either", "but", "it", "s", "an", "improvement", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeAdmin/NodeAdminPublisher.php#L235-L269
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/EventListener/LoginListener.php
LoginListener.onSecurityInteractiveLogin
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) { /* @var BaseUser $user */ $user = $event->getAuthenticationToken()->getUser(); if ($user instanceof UserInterface) { $this->logger->info($user . ' successfully logged in to the cms'); $this->versionChecker->periodicallyCheck(); } }
php
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event) { /* @var BaseUser $user */ $user = $event->getAuthenticationToken()->getUser(); if ($user instanceof UserInterface) { $this->logger->info($user . ' successfully logged in to the cms'); $this->versionChecker->periodicallyCheck(); } }
[ "public", "function", "onSecurityInteractiveLogin", "(", "InteractiveLoginEvent", "$", "event", ")", "{", "/* @var BaseUser $user */", "$", "user", "=", "$", "event", "->", "getAuthenticationToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "user...
Handle login event. @param InteractiveLoginEvent $event
[ "Handle", "login", "event", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/EventListener/LoginListener.php#L43-L52
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SearchBundle/Configuration/SearchConfigurationChain.php
SearchConfigurationChain.getConfiguration
public function getConfiguration($alias) { if (array_key_exists($alias, $this->searchConfigurations)) { return $this->searchConfigurations[$alias]; } return null; }
php
public function getConfiguration($alias) { if (array_key_exists($alias, $this->searchConfigurations)) { return $this->searchConfigurations[$alias]; } return null; }
[ "public", "function", "getConfiguration", "(", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "searchConfigurations", ")", ")", "{", "return", "$", "this", "->", "searchConfigurations", "[", "$", "alias", ...
Get an index configuration based on its alias @param string $alias @return SearchConfigurationInterface|null
[ "Get", "an", "index", "configuration", "based", "on", "its", "alias" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SearchBundle/Configuration/SearchConfigurationChain.php#L38-L45
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MenuBundle/Service/MenuService.php
MenuService.makeSureMenusExist
public function makeSureMenusExist() { $locales = array_unique($this->getLocales()); $required = array(); foreach ($this->menuNames as $name) { $required[$name] = $locales; } $menuObjects = $this->em->getRepository($this->menuEntityClass)->findAll(); foreach ($menuObjects as $menu) { if (array_key_exists($menu->getName(), $required)) { $index = array_search($menu->getLocale(), $required[$menu->getName()]); if ($index !== false) { unset($required[$menu->getName()][$index]); } } } foreach ($required as $name => $locales) { foreach ($locales as $locale) { $className = $this->menuEntityClass; $menu = new $className(); $menu->setName($name); $menu->setLocale($locale); $this->em->persist($menu); } } $this->em->flush(); }
php
public function makeSureMenusExist() { $locales = array_unique($this->getLocales()); $required = array(); foreach ($this->menuNames as $name) { $required[$name] = $locales; } $menuObjects = $this->em->getRepository($this->menuEntityClass)->findAll(); foreach ($menuObjects as $menu) { if (array_key_exists($menu->getName(), $required)) { $index = array_search($menu->getLocale(), $required[$menu->getName()]); if ($index !== false) { unset($required[$menu->getName()][$index]); } } } foreach ($required as $name => $locales) { foreach ($locales as $locale) { $className = $this->menuEntityClass; $menu = new $className(); $menu->setName($name); $menu->setLocale($locale); $this->em->persist($menu); } } $this->em->flush(); }
[ "public", "function", "makeSureMenusExist", "(", ")", "{", "$", "locales", "=", "array_unique", "(", "$", "this", "->", "getLocales", "(", ")", ")", ";", "$", "required", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "menuNames", "as"...
Make sure the menu objects exist in the database for each locale.
[ "Make", "sure", "the", "menu", "objects", "exist", "in", "the", "database", "for", "each", "locale", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MenuBundle/Service/MenuService.php#L47-L78
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/LayoutGenerator.php
LayoutGenerator.generate
public function generate(BundleInterface $bundle, $rootDir, $demosite, $browserSyncUrl) { $this->bundle = $bundle; $this->rootDir = $rootDir; $this->demosite = $demosite; $this->browserSyncUrl = $browserSyncUrl; $this->shortBundleName = '@'.str_replace('Bundle', '', $bundle->getName()); $this->generateGroundcontrolFiles(); $this->generateAssets(); $this->generateTemplate(); }
php
public function generate(BundleInterface $bundle, $rootDir, $demosite, $browserSyncUrl) { $this->bundle = $bundle; $this->rootDir = $rootDir; $this->demosite = $demosite; $this->browserSyncUrl = $browserSyncUrl; $this->shortBundleName = '@'.str_replace('Bundle', '', $bundle->getName()); $this->generateGroundcontrolFiles(); $this->generateAssets(); $this->generateTemplate(); }
[ "public", "function", "generate", "(", "BundleInterface", "$", "bundle", ",", "$", "rootDir", ",", "$", "demosite", ",", "$", "browserSyncUrl", ")", "{", "$", "this", "->", "bundle", "=", "$", "bundle", ";", "$", "this", "->", "rootDir", "=", "$", "roo...
Generate the basic layout. @param BundleInterface $bundle The bundle @param string $rootDir The root directory of the application
[ "Generate", "the", "basic", "layout", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/LayoutGenerator.php#L43-L55
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/LayoutGenerator.php
LayoutGenerator.generateTemplate
private function generateTemplate() { $relPath = '/Resources/views/'; $this->renderFiles( $this->skeletonDir . $relPath, $this->getTemplateDir($this->bundle), array('bundle' => $this->bundle, 'demosite' => $this->demosite, 'shortBundleName' => $this->shortBundleName, 'isV4' => $this->isSymfony4()), true ); if (!$this->demosite) { // Layout $this->removeFile($this->getTemplateDir($this->bundle) . '/Layout/_mobile-nav.html.twig'); $this->removeFile($this->getTemplateDir($this->bundle) . '/Layout/_demositemessage.html.twig'); } $this->assistant->writeLine('Generating template files : <info>OK</info>'); }
php
private function generateTemplate() { $relPath = '/Resources/views/'; $this->renderFiles( $this->skeletonDir . $relPath, $this->getTemplateDir($this->bundle), array('bundle' => $this->bundle, 'demosite' => $this->demosite, 'shortBundleName' => $this->shortBundleName, 'isV4' => $this->isSymfony4()), true ); if (!$this->demosite) { // Layout $this->removeFile($this->getTemplateDir($this->bundle) . '/Layout/_mobile-nav.html.twig'); $this->removeFile($this->getTemplateDir($this->bundle) . '/Layout/_demositemessage.html.twig'); } $this->assistant->writeLine('Generating template files : <info>OK</info>'); }
[ "private", "function", "generateTemplate", "(", ")", "{", "$", "relPath", "=", "'/Resources/views/'", ";", "$", "this", "->", "renderFiles", "(", "$", "this", "->", "skeletonDir", ".", "$", "relPath", ",", "$", "this", "->", "getTemplateDir", "(", "$", "th...
Generate the twig template files.
[ "Generate", "the", "twig", "template", "files", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/LayoutGenerator.php#L216-L233
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Repository/AclChangesetRepository.php
AclChangesetRepository.findRunningChangeset
public function findRunningChangeset() { $qb = $this->createQueryBuilder('ac') ->select('ac') ->where('ac.status = :status') ->addOrderBy('ac.id', 'ASC') ->setMaxResults(1) ->setParameter('status', AclChangeset::STATUS_RUNNING); return $qb->getQuery()->getOneOrNullResult(); }
php
public function findRunningChangeset() { $qb = $this->createQueryBuilder('ac') ->select('ac') ->where('ac.status = :status') ->addOrderBy('ac.id', 'ASC') ->setMaxResults(1) ->setParameter('status', AclChangeset::STATUS_RUNNING); return $qb->getQuery()->getOneOrNullResult(); }
[ "public", "function", "findRunningChangeset", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'ac'", ")", "->", "select", "(", "'ac'", ")", "->", "where", "(", "'ac.status = :status'", ")", "->", "addOrderBy", "(", "'ac.id'", ...
Find a changeset with status RUNNING @return null|AclChangeset
[ "Find", "a", "changeset", "with", "status", "RUNNING" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Repository/AclChangesetRepository.php#L18-L28
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Repository/AclChangesetRepository.php
AclChangesetRepository.findNewChangeset
public function findNewChangeset() { $qb = $this->createQueryBuilder('ac') ->select('ac') ->where('ac.status = :status') ->addOrderBy('ac.id', 'ASC') ->setMaxResults(1) ->setParameter('status', AclChangeset::STATUS_NEW); return $qb->getQuery()->getOneOrNullResult(); }
php
public function findNewChangeset() { $qb = $this->createQueryBuilder('ac') ->select('ac') ->where('ac.status = :status') ->addOrderBy('ac.id', 'ASC') ->setMaxResults(1) ->setParameter('status', AclChangeset::STATUS_NEW); return $qb->getQuery()->getOneOrNullResult(); }
[ "public", "function", "findNewChangeset", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'ac'", ")", "->", "select", "(", "'ac'", ")", "->", "where", "(", "'ac.status = :status'", ")", "->", "addOrderBy", "(", "'ac.id'", ",",...
Fetch the oldest acl changeset for state NEW @return null|AclChangeset
[ "Fetch", "the", "oldest", "acl", "changeset", "for", "state", "NEW" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Repository/AclChangesetRepository.php#L35-L45
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Repository/AclChangesetRepository.php
AclChangesetRepository.hasPendingChangesets
public function hasPendingChangesets() { $qb = $this->createQueryBuilder('ac') ->select('count(ac)') ->where('ac.status = :status') ->setParameter('status', AclChangeset::STATUS_NEW); return $qb->getQuery()->getSingleScalarResult() != 0; }
php
public function hasPendingChangesets() { $qb = $this->createQueryBuilder('ac') ->select('count(ac)') ->where('ac.status = :status') ->setParameter('status', AclChangeset::STATUS_NEW); return $qb->getQuery()->getSingleScalarResult() != 0; }
[ "public", "function", "hasPendingChangesets", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'ac'", ")", "->", "select", "(", "'count(ac)'", ")", "->", "where", "(", "'ac.status = :status'", ")", "->", "setParameter", "(", "'st...
Check if there are pending changesets @return bool
[ "Check", "if", "there", "are", "pending", "changesets" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Repository/AclChangesetRepository.php#L52-L60
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsGenerateCommand.php
GoogleAnalyticsOverviewsGenerateCommand.generateOverviewsOfSegment
private function generateOverviewsOfSegment($segmentId) { /** @var AnalyticsSegmentRepository $segmentRepository */ $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); $segment = $segmentRepository->find($segmentId); if (!$segment) { throw new \InvalidArgumentException('Unknown segment ID'); } // init the segment $segmentRepository->initSegment($segment); }
php
private function generateOverviewsOfSegment($segmentId) { /** @var AnalyticsSegmentRepository $segmentRepository */ $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); $segment = $segmentRepository->find($segmentId); if (!$segment) { throw new \InvalidArgumentException('Unknown segment ID'); } // init the segment $segmentRepository->initSegment($segment); }
[ "private", "function", "generateOverviewsOfSegment", "(", "$", "segmentId", ")", "{", "/** @var AnalyticsSegmentRepository $segmentRepository */", "$", "segmentRepository", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsSegment'", ...
Get all overviews of a segment @param int $segmentId @return array @throws \InvalidArgumentException
[ "Get", "all", "overviews", "of", "a", "segment" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsGenerateCommand.php#L108-L120
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsGenerateCommand.php
GoogleAnalyticsOverviewsGenerateCommand.generateAllOverviews
private function generateAllOverviews() { $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview'); $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); $configs = $configRepository->findAll(); foreach ($configs as $config) { // add overviews if none exist yet if (!count($configRepository->findDefaultOverviews($config))) { $overviewRepository->addOverviews($config); } // init all the segments for this config $segments = $config->getSegments(); foreach ($segments as $segment) { $segmentRepository->initSegment($segment); } } }
php
private function generateAllOverviews() { $configRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); $overviewRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsOverview'); $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); $configs = $configRepository->findAll(); foreach ($configs as $config) { // add overviews if none exist yet if (!count($configRepository->findDefaultOverviews($config))) { $overviewRepository->addOverviews($config); } // init all the segments for this config $segments = $config->getSegments(); foreach ($segments as $segment) { $segmentRepository->initSegment($segment); } } }
[ "private", "function", "generateAllOverviews", "(", ")", "{", "$", "configRepository", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsConfig'", ")", ";", "$", "overviewRepository", "=", "$", "this", "->", "em", "->", ...
get all overviews @return array
[ "get", "all", "overviews" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsGenerateCommand.php#L160-L179
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FixturesBundle/Populator/Methods/ArrayAdd.php
ArrayAdd.findAdderMethod
private function findAdderMethod($object, $property) { if (is_callable([$object, $method = 'add' . $property])) { return $method; } if (class_exists('Symfony\Component\PropertyAccess\StringUtil') && method_exists('Symfony\Component\PropertyAccess\StringUtil', 'singularify')) { foreach ((array) Inflector::singularize($property) as $singularForm) { if (is_callable([$object, $method = 'add' . $singularForm])) { return $method; } } } if (is_callable([$object, $method = 'add' . rtrim($property, 's')])) { return $method; } if (substr($property, -3) === 'ies' && is_callable([$object, $method = 'add' . substr($property, 0, -3) . 'y'])) { return $method; } return null; }
php
private function findAdderMethod($object, $property) { if (is_callable([$object, $method = 'add' . $property])) { return $method; } if (class_exists('Symfony\Component\PropertyAccess\StringUtil') && method_exists('Symfony\Component\PropertyAccess\StringUtil', 'singularify')) { foreach ((array) Inflector::singularize($property) as $singularForm) { if (is_callable([$object, $method = 'add' . $singularForm])) { return $method; } } } if (is_callable([$object, $method = 'add' . rtrim($property, 's')])) { return $method; } if (substr($property, -3) === 'ies' && is_callable([$object, $method = 'add' . substr($property, 0, -3) . 'y'])) { return $method; } return null; }
[ "private", "function", "findAdderMethod", "(", "$", "object", ",", "$", "property", ")", "{", "if", "(", "is_callable", "(", "[", "$", "object", ",", "$", "method", "=", "'add'", ".", "$", "property", "]", ")", ")", "{", "return", "$", "method", ";",...
finds the method used to append values to the named property @param mixed $object @param string $property @return string|null
[ "finds", "the", "method", "used", "to", "append", "values", "to", "the", "named", "property" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FixturesBundle/Populator/Methods/ArrayAdd.php#L36-L56
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/AdminList/FormSubmissionAdminListConfigurator.php
FormSubmissionAdminListConfigurator.buildFilters
public function buildFilters() { $builder = $this->getFilterBuilder(); $builder->add('created', new DateFilterType('created'), 'Date') ->add('lang', new StringFilterType('lang'), 'Language') ->add('ipAddress', new StringFilterType('ipAddress'), 'IP Address'); }
php
public function buildFilters() { $builder = $this->getFilterBuilder(); $builder->add('created', new DateFilterType('created'), 'Date') ->add('lang', new StringFilterType('lang'), 'Language') ->add('ipAddress', new StringFilterType('ipAddress'), 'IP Address'); }
[ "public", "function", "buildFilters", "(", ")", "{", "$", "builder", "=", "$", "this", "->", "getFilterBuilder", "(", ")", ";", "$", "builder", "->", "add", "(", "'created'", ",", "new", "DateFilterType", "(", "'created'", ")", ",", "'Date'", ")", "->", ...
Configure the fields you can filter on
[ "Configure", "the", "fields", "you", "can", "filter", "on" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/AdminList/FormSubmissionAdminListConfigurator.php#L43-L49
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/AdminList/FormSubmissionAdminListConfigurator.php
FormSubmissionAdminListConfigurator.adaptQueryBuilder
public function adaptQueryBuilder(QueryBuilder $queryBuilder, array $params = array()) { parent::adaptQueryBuilder($queryBuilder); $queryBuilder ->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id') ->andWhere('n.id = :node') ->andWhere('b.lang = :lang') ->setParameter('node', $this->nodeTranslation->getNode()->getId()) ->setParameter('lang', $this->nodeTranslation->getLang()) ->addOrderBy('b.created', 'DESC'); }
php
public function adaptQueryBuilder(QueryBuilder $queryBuilder, array $params = array()) { parent::adaptQueryBuilder($queryBuilder); $queryBuilder ->innerJoin('b.node', 'n', 'WITH', 'b.node = n.id') ->andWhere('n.id = :node') ->andWhere('b.lang = :lang') ->setParameter('node', $this->nodeTranslation->getNode()->getId()) ->setParameter('lang', $this->nodeTranslation->getLang()) ->addOrderBy('b.created', 'DESC'); }
[ "public", "function", "adaptQueryBuilder", "(", "QueryBuilder", "$", "queryBuilder", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "parent", "::", "adaptQueryBuilder", "(", "$", "queryBuilder", ")", ";", "$", "queryBuilder", "->", "innerJoin",...
Make some modifications to the default created query builder @param QueryBuilder $queryBuilder The query builder @param array $params The parameters
[ "Make", "some", "modifications", "to", "the", "default", "created", "query", "builder" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/AdminList/FormSubmissionAdminListConfigurator.php#L204-L214
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php
AclHelper.cloneQuery
protected function cloneQuery(Query $query) { $aclAppliedQuery = clone $query; $params = $query->getParameters(); /* @var $param Parameter */ foreach ($params as $param) { $aclAppliedQuery->setParameter($param->getName(), $param->getValue(), $param->getType()); } return $aclAppliedQuery; }
php
protected function cloneQuery(Query $query) { $aclAppliedQuery = clone $query; $params = $query->getParameters(); /* @var $param Parameter */ foreach ($params as $param) { $aclAppliedQuery->setParameter($param->getName(), $param->getValue(), $param->getType()); } return $aclAppliedQuery; }
[ "protected", "function", "cloneQuery", "(", "Query", "$", "query", ")", "{", "$", "aclAppliedQuery", "=", "clone", "$", "query", ";", "$", "params", "=", "$", "query", "->", "getParameters", "(", ")", ";", "/* @var $param Parameter */", "foreach", "(", "$", ...
Clone specified query with parameters. @param Query $query @return Query
[ "Clone", "specified", "query", "with", "parameters", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php#L68-L78
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php
AclHelper.getAllowedEntityIds
public function getAllowedEntityIds(PermissionDefinition $permissionDef) { $rootEntity = $permissionDef->getEntity(); if (empty($rootEntity)) { throw new InvalidArgumentException('You have to provide an entity class name!'); } $builder = new MaskBuilder(); foreach ($permissionDef->getPermissions() as $permission) { $mask = constant(get_class($builder) . '::MASK_' . strtoupper($permission)); $builder->add($mask); } $query = new Query($this->em); $query->setHint('acl.mask', $builder->get()); $query->setHint('acl.root.entity', $rootEntity); $sql = $this->getPermittedAclIdsSQLForUser($query); $rsm = new ResultSetMapping(); $rsm->addScalarResult('id', 'id'); $nativeQuery = $this->em->createNativeQuery($sql, $rsm); $transform = function ($item) { return $item['id']; }; $result = array_map($transform, $nativeQuery->getScalarResult()); return $result; }
php
public function getAllowedEntityIds(PermissionDefinition $permissionDef) { $rootEntity = $permissionDef->getEntity(); if (empty($rootEntity)) { throw new InvalidArgumentException('You have to provide an entity class name!'); } $builder = new MaskBuilder(); foreach ($permissionDef->getPermissions() as $permission) { $mask = constant(get_class($builder) . '::MASK_' . strtoupper($permission)); $builder->add($mask); } $query = new Query($this->em); $query->setHint('acl.mask', $builder->get()); $query->setHint('acl.root.entity', $rootEntity); $sql = $this->getPermittedAclIdsSQLForUser($query); $rsm = new ResultSetMapping(); $rsm->addScalarResult('id', 'id'); $nativeQuery = $this->em->createNativeQuery($sql, $rsm); $transform = function ($item) { return $item['id']; }; $result = array_map($transform, $nativeQuery->getScalarResult()); return $result; }
[ "public", "function", "getAllowedEntityIds", "(", "PermissionDefinition", "$", "permissionDef", ")", "{", "$", "rootEntity", "=", "$", "permissionDef", "->", "getEntity", "(", ")", ";", "if", "(", "empty", "(", "$", "rootEntity", ")", ")", "{", "throw", "new...
Returns valid IDs for a specific entity with ACL restrictions for current user applied @param PermissionDefinition $permissionDef @throws InvalidArgumentException @return array
[ "Returns", "valid", "IDs", "for", "a", "specific", "entity", "with", "ACL", "restrictions", "for", "current", "user", "applied" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/AclHelper.php#L202-L229
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php
Translator.addResourcesFromCacher
public function addResourcesFromCacher() { $resources = $this->resourceCacher->getCachedResources(false); if ($resources !== false) { $this->addResources($resources); return true; } return false; }
php
public function addResourcesFromCacher() { $resources = $this->resourceCacher->getCachedResources(false); if ($resources !== false) { $this->addResources($resources); return true; } return false; }
[ "public", "function", "addResourcesFromCacher", "(", ")", "{", "$", "resources", "=", "$", "this", "->", "resourceCacher", "->", "getCachedResources", "(", "false", ")", ";", "if", "(", "$", "resources", "!==", "false", ")", "{", "$", "this", "->", "addRes...
Add resources to the Translator from the cache
[ "Add", "resources", "to", "the", "Translator", "from", "the", "cache" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php#L64-L75
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php
Translator.addResourcesFromDatabaseAndCacheThem
public function addResourcesFromDatabaseAndCacheThem($cacheResources = true) { try { $resources = $this->translationRepository->getAllDomainsByLocale(); $this->addResources($resources); if ($cacheResources === true) { $this->resourceCacher->cacheResources($resources); } } catch (\Exception $ex) { // don't load if the database doesn't work } }
php
public function addResourcesFromDatabaseAndCacheThem($cacheResources = true) { try { $resources = $this->translationRepository->getAllDomainsByLocale(); $this->addResources($resources); if ($cacheResources === true) { $this->resourceCacher->cacheResources($resources); } } catch (\Exception $ex) { // don't load if the database doesn't work } }
[ "public", "function", "addResourcesFromDatabaseAndCacheThem", "(", "$", "cacheResources", "=", "true", ")", "{", "try", "{", "$", "resources", "=", "$", "this", "->", "translationRepository", "->", "getAllDomainsByLocale", "(", ")", ";", "$", "this", "->", "addR...
Add resources from the stash and cache them @param bool $cacheResources cache resources after retrieving them from the stasher
[ "Add", "resources", "from", "the", "stash", "and", "cache", "them" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Translator/Translator.php#L82-L94
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/Services/ACLPermissionCreatorService.php
ACLPermissionCreatorService.setContainer
public function setContainer(ContainerInterface $container = null) { $this->setAclProvider($container->get('security.acl.provider')); $this->setObjectIdentityRetrievalStrategy($container->get('security.acl.object_identity_retrieval_strategy')); }
php
public function setContainer(ContainerInterface $container = null) { $this->setAclProvider($container->get('security.acl.provider')); $this->setObjectIdentityRetrievalStrategy($container->get('security.acl.object_identity_retrieval_strategy')); }
[ "public", "function", "setContainer", "(", "ContainerInterface", "$", "container", "=", "null", ")", "{", "$", "this", "->", "setAclProvider", "(", "$", "container", "->", "get", "(", "'security.acl.provider'", ")", ")", ";", "$", "this", "->", "setObjectIdent...
Sets the Container. This is still here for backwards compatibility. The ContainerAwareInterface has been removed so the container won't be injected automatically. This function is just there for code that calls it manually. @param ContainerInterface $container a ContainerInterface instance @api
[ "Sets", "the", "Container", ".", "This", "is", "still", "here", "for", "backwards", "compatibility", ".", "The", "ContainerAwareInterface", "has", "been", "removed", "so", "the", "container", "won", "t", "be", "injected", "automatically", ".", "This", "function"...
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/Services/ACLPermissionCreatorService.php#L42-L46
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultPagePartGenerator.php
DefaultPagePartGenerator.generate
public function generate(BundleInterface $bundle, $entity, $prefix, array $sections, $behatTest) { $this->bundle = $bundle; $this->entity = $entity; $this->prefix = $prefix; $this->sections = $sections; $this->generatePagePartEntity(); if ($entity != 'AbstractPagePart') { $this->generateFormType(); $this->generateResourceTemplate(); $this->generateSectionConfig(); if ($behatTest) { $this->generateBehatTest(); } } }
php
public function generate(BundleInterface $bundle, $entity, $prefix, array $sections, $behatTest) { $this->bundle = $bundle; $this->entity = $entity; $this->prefix = $prefix; $this->sections = $sections; $this->generatePagePartEntity(); if ($entity != 'AbstractPagePart') { $this->generateFormType(); $this->generateResourceTemplate(); $this->generateSectionConfig(); if ($behatTest) { $this->generateBehatTest(); } } }
[ "public", "function", "generate", "(", "BundleInterface", "$", "bundle", ",", "$", "entity", ",", "$", "prefix", ",", "array", "$", "sections", ",", "$", "behatTest", ")", "{", "$", "this", "->", "bundle", "=", "$", "bundle", ";", "$", "this", "->", ...
Generate the pagepart. @param BundleInterface $bundle The bundle @param string $entity The entity name @param string $prefix The database prefix @param array $sections The page sections @param bool $behatTest If we need to generate a behat test for this pagepart @throws \RuntimeException
[ "Generate", "the", "pagepart", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultPagePartGenerator.php#L44-L60
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/EventListener/FixDateListener.php
FixDateListener.onKernelResponse
public function onKernelResponse(FilterResponseEvent $event) { $response = $event->getResponse(); if ($response) { $date = $response->getDate(); if (empty($date)) { $response->setDate(new \DateTime()); } } }
php
public function onKernelResponse(FilterResponseEvent $event) { $response = $event->getResponse(); if ($response) { $date = $response->getDate(); if (empty($date)) { $response->setDate(new \DateTime()); } } }
[ "public", "function", "onKernelResponse", "(", "FilterResponseEvent", "$", "event", ")", "{", "$", "response", "=", "$", "event", "->", "getResponse", "(", ")", ";", "if", "(", "$", "response", ")", "{", "$", "date", "=", "$", "response", "->", "getDate"...
Make sure response has a timestamp @param FilterResponseEvent|GetResponseEvent $event
[ "Make", "sure", "response", "has", "a", "timestamp" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/EventListener/FixDateListener.php#L18-L27
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Repository/SeoRepository.php
SeoRepository.findFor
public function findFor(AbstractEntity $entity) { return $this->findOneBy(array('refId' => $entity->getId(), 'refEntityName' => ClassLookup::getClass($entity))); }
php
public function findFor(AbstractEntity $entity) { return $this->findOneBy(array('refId' => $entity->getId(), 'refEntityName' => ClassLookup::getClass($entity))); }
[ "public", "function", "findFor", "(", "AbstractEntity", "$", "entity", ")", "{", "return", "$", "this", "->", "findOneBy", "(", "array", "(", "'refId'", "=>", "$", "entity", "->", "getId", "(", ")", ",", "'refEntityName'", "=>", "ClassLookup", "::", "getCl...
Find the seo information for the given entity @param AbstractEntity $entity @return Seo
[ "Find", "the", "seo", "information", "for", "the", "given", "entity" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Repository/SeoRepository.php#L22-L25
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FixturesBundle/Parser/Property/Method.php
Method.canParse
public function canParse($value) { if (is_string($value) && preg_match(self::REGEX, $value)) { return true; } return false; }
php
public function canParse($value) { if (is_string($value) && preg_match(self::REGEX, $value)) { return true; } return false; }
[ "public", "function", "canParse", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", "&&", "preg_match", "(", "self", "::", "REGEX", ",", "$", "value", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}"...
Check if this parser is applicable @return bool
[ "Check", "if", "this", "parser", "is", "applicable" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FixturesBundle/Parser/Property/Method.php#L14-L21
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/OAuth/OAuthUserCreator.php
OAuthUserCreator.getAccessLevels
private function getAccessLevels($email) { foreach ($this->hostedDomains as $hostedDomain) { if (preg_match('/'.$hostedDomain['domain_name'].'$/', $email)) { return $hostedDomain['access_levels']; } } return null; }
php
private function getAccessLevels($email) { foreach ($this->hostedDomains as $hostedDomain) { if (preg_match('/'.$hostedDomain['domain_name'].'$/', $email)) { return $hostedDomain['access_levels']; } } return null; }
[ "private", "function", "getAccessLevels", "(", "$", "email", ")", "{", "foreach", "(", "$", "this", "->", "hostedDomains", "as", "$", "hostedDomain", ")", "{", "if", "(", "preg_match", "(", "'/'", ".", "$", "hostedDomain", "[", "'domain_name'", "]", ".", ...
This method returns the access level coupled with the domain of the given email If the given domain name has not been configured this function will return null @param string $email @return string[]|null
[ "This", "method", "returns", "the", "access", "level", "coupled", "with", "the", "domain", "of", "the", "given", "email", "If", "the", "given", "domain", "name", "has", "not", "been", "configured", "this", "function", "will", "return", "null" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/OAuth/OAuthUserCreator.php#L84-L93
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/OAuth/OAuthUserCreator.php
OAuthUserCreator.isConfiguredDomain
private function isConfiguredDomain($email) { foreach ($this->hostedDomains as $hostedDomain) { if (preg_match('/'.$hostedDomain['domain_name'].'$/', $email)) { return true; } } return false; }
php
private function isConfiguredDomain($email) { foreach ($this->hostedDomains as $hostedDomain) { if (preg_match('/'.$hostedDomain['domain_name'].'$/', $email)) { return true; } } return false; }
[ "private", "function", "isConfiguredDomain", "(", "$", "email", ")", "{", "foreach", "(", "$", "this", "->", "hostedDomains", "as", "$", "hostedDomain", ")", "{", "if", "(", "preg_match", "(", "'/'", ".", "$", "hostedDomain", "[", "'domain_name'", "]", "."...
This method returns wether a domain for the given email has been configured @param string $email @return bool
[ "This", "method", "returns", "wether", "a", "domain", "for", "the", "given", "email", "has", "been", "configured" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/OAuth/OAuthUserCreator.php#L102-L111
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php
MaskBuilder.getPattern
public function getPattern() { $pattern = self::ALL_OFF; $length = strlen($pattern); $bitmask = str_pad(decbin($this->mask), $length, '0', STR_PAD_LEFT); for ($i = $length - 1; $i >= 0; --$i) { if ('1' === $bitmask[$i]) { try { $pattern[$i] = self::getCode(1 << ($length - $i - 1)); } catch (\Exception $notPredefined) { $pattern[$i] = self::ON; } } } return $pattern; }
php
public function getPattern() { $pattern = self::ALL_OFF; $length = strlen($pattern); $bitmask = str_pad(decbin($this->mask), $length, '0', STR_PAD_LEFT); for ($i = $length - 1; $i >= 0; --$i) { if ('1' === $bitmask[$i]) { try { $pattern[$i] = self::getCode(1 << ($length - $i - 1)); } catch (\Exception $notPredefined) { $pattern[$i] = self::ON; } } } return $pattern; }
[ "public", "function", "getPattern", "(", ")", "{", "$", "pattern", "=", "self", "::", "ALL_OFF", ";", "$", "length", "=", "strlen", "(", "$", "pattern", ")", ";", "$", "bitmask", "=", "str_pad", "(", "decbin", "(", "$", "this", "->", "mask", ")", "...
Returns a human-readable representation of the permission @return string
[ "Returns", "a", "human", "-", "readable", "representation", "of", "the", "permission" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php#L38-L55
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php
MaskBuilder.getCode
public static function getCode($mask) { if (!is_int($mask)) { throw new InvalidArgumentException('$mask must be an integer.'); } $reflection = new \ReflectionClass(get_called_class()); foreach ($reflection->getConstants() as $name => $cMask) { if (0 !== strpos($name, 'MASK_')) { continue; } if ($mask === $cMask) { if (!defined($cName = 'static::CODE_'.substr($name, 5))) { throw new \RuntimeException('There was no code defined for this mask.'); } return constant($cName); } } throw new InvalidArgumentException(sprintf('The mask "%d" is not supported.', $mask)); }
php
public static function getCode($mask) { if (!is_int($mask)) { throw new InvalidArgumentException('$mask must be an integer.'); } $reflection = new \ReflectionClass(get_called_class()); foreach ($reflection->getConstants() as $name => $cMask) { if (0 !== strpos($name, 'MASK_')) { continue; } if ($mask === $cMask) { if (!defined($cName = 'static::CODE_'.substr($name, 5))) { throw new \RuntimeException('There was no code defined for this mask.'); } return constant($cName); } } throw new InvalidArgumentException(sprintf('The mask "%d" is not supported.', $mask)); }
[ "public", "static", "function", "getCode", "(", "$", "mask", ")", "{", "if", "(", "!", "is_int", "(", "$", "mask", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'$mask must be an integer.'", ")", ";", "}", "$", "reflection", "=", "new", ...
Returns the code for the passed mask @param null|int $mask @throws InvalidArgumentException @throws \RuntimeException @return string
[ "Returns", "the", "code", "for", "the", "passed", "mask" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php#L67-L89
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php
MaskBuilder.has
public function has($mask) { if (is_string($mask) && defined($name = 'static::MASK_'.strtoupper($mask))) { $mask = constant($name); } elseif (!is_int($mask)) { throw new InvalidArgumentException('$mask must be an integer.'); } return ($this->mask & $mask) != 0; }
php
public function has($mask) { if (is_string($mask) && defined($name = 'static::MASK_'.strtoupper($mask))) { $mask = constant($name); } elseif (!is_int($mask)) { throw new InvalidArgumentException('$mask must be an integer.'); } return ($this->mask & $mask) != 0; }
[ "public", "function", "has", "(", "$", "mask", ")", "{", "if", "(", "is_string", "(", "$", "mask", ")", "&&", "defined", "(", "$", "name", "=", "'static::MASK_'", ".", "strtoupper", "(", "$", "mask", ")", ")", ")", "{", "$", "mask", "=", "constant"...
Checks if a specific permission or mask value is set in the current mask @param string|int $mask @throws InvalidArgumentException @return bool
[ "Checks", "if", "a", "specific", "permission", "or", "mask", "value", "is", "set", "in", "the", "current", "mask" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php#L100-L109
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php
MaskBuilder.resolveMask
public function resolveMask($code) { if (is_string($code)) { if (!defined($name = sprintf('static::MASK_%s', strtoupper($code)))) { throw new \InvalidArgumentException(sprintf('The code "%s" is not supported', $code)); } return constant($name); } if (!is_int($code)) { throw new \InvalidArgumentException('$code must be an integer.'); } return $code; }
php
public function resolveMask($code) { if (is_string($code)) { if (!defined($name = sprintf('static::MASK_%s', strtoupper($code)))) { throw new \InvalidArgumentException(sprintf('The code "%s" is not supported', $code)); } return constant($name); } if (!is_int($code)) { throw new \InvalidArgumentException('$code must be an integer.'); } return $code; }
[ "public", "function", "resolveMask", "(", "$", "code", ")", "{", "if", "(", "is_string", "(", "$", "code", ")", ")", "{", "if", "(", "!", "defined", "(", "$", "name", "=", "sprintf", "(", "'static::MASK_%s'", ",", "strtoupper", "(", "$", "code", ")",...
Returns the mask for the passed code. @param mixed $code @return int @throws \InvalidArgumentException
[ "Returns", "the", "mask", "for", "the", "passed", "code", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php#L120-L135
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generate
public function generate(BundleInterface $bundle, $prefix, $rootDir, $demosite = false) { $this->bundle = $bundle; $this->prefix = GeneratorUtils::cleanPrefix($prefix); $this->rootDir = $rootDir; $this->demosite = $demosite; $parameters = array( 'namespace' => $this->bundle->getNamespace(), 'bundle' => $this->bundle, 'bundle_name' => $this->bundle->getName(), 'prefix' => $this->prefix, 'demosite' => $this->demosite, 'multilanguage' => $this->isMultiLangEnvironment(), 'isV4' => $this->isSymfony4(), ); $this->generateControllers($parameters); $this->generateAdminLists($parameters); $this->generateEntities($parameters); $this->generateFormTypes($parameters); $this->generateTwigExtensions($parameters); $this->generateMenuAdaptors($parameters); $this->generateFixtures($parameters); $this->generatePagepartConfigs($parameters); $this->generatePagetemplateConfigs($parameters); $this->generateConfig(); $this->generateRouting($parameters); $this->generateTemplates($parameters); }
php
public function generate(BundleInterface $bundle, $prefix, $rootDir, $demosite = false) { $this->bundle = $bundle; $this->prefix = GeneratorUtils::cleanPrefix($prefix); $this->rootDir = $rootDir; $this->demosite = $demosite; $parameters = array( 'namespace' => $this->bundle->getNamespace(), 'bundle' => $this->bundle, 'bundle_name' => $this->bundle->getName(), 'prefix' => $this->prefix, 'demosite' => $this->demosite, 'multilanguage' => $this->isMultiLangEnvironment(), 'isV4' => $this->isSymfony4(), ); $this->generateControllers($parameters); $this->generateAdminLists($parameters); $this->generateEntities($parameters); $this->generateFormTypes($parameters); $this->generateTwigExtensions($parameters); $this->generateMenuAdaptors($parameters); $this->generateFixtures($parameters); $this->generatePagepartConfigs($parameters); $this->generatePagetemplateConfigs($parameters); $this->generateConfig(); $this->generateRouting($parameters); $this->generateTemplates($parameters); }
[ "public", "function", "generate", "(", "BundleInterface", "$", "bundle", ",", "$", "prefix", ",", "$", "rootDir", ",", "$", "demosite", "=", "false", ")", "{", "$", "this", "->", "bundle", "=", "$", "bundle", ";", "$", "this", "->", "prefix", "=", "G...
Generate the website. @param BundleInterface $bundle @param string $prefix @param string $rootDir @param bool $demosite
[ "Generate", "the", "website", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L42-L71
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateControllers
private function generateControllers(array $parameters) { $relPath = '/Controller/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'DefaultController.php', $parameters, true); if ($this->demosite) { $this->renderSingleFile($sourceDir, $targetDir, 'BikeAdminListController.php', $parameters, true); } $this->assistant->writeLine('Generating controllers : <info>OK</info>'); }
php
private function generateControllers(array $parameters) { $relPath = '/Controller/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'DefaultController.php', $parameters, true); if ($this->demosite) { $this->renderSingleFile($sourceDir, $targetDir, 'BikeAdminListController.php', $parameters, true); } $this->assistant->writeLine('Generating controllers : <info>OK</info>'); }
[ "private", "function", "generateControllers", "(", "array", "$", "parameters", ")", "{", "$", "relPath", "=", "'/Controller/'", ";", "$", "sourceDir", "=", "$", "this", "->", "skeletonDir", ".", "$", "relPath", ";", "$", "targetDir", "=", "$", "this", "->"...
Generate controller classes. @param array $parameters
[ "Generate", "controller", "classes", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L78-L91
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateAdminLists
private function generateAdminLists(array $parameters) { if ($this->demosite) { $relPath = '/AdminList/'; $this->renderFiles($this->skeletonDir.$relPath, $this->bundle->getPath().$relPath, $parameters, true); $this->assistant->writeLine('Generating admin lists : <info>OK</info>'); } }
php
private function generateAdminLists(array $parameters) { if ($this->demosite) { $relPath = '/AdminList/'; $this->renderFiles($this->skeletonDir.$relPath, $this->bundle->getPath().$relPath, $parameters, true); $this->assistant->writeLine('Generating admin lists : <info>OK</info>'); } }
[ "private", "function", "generateAdminLists", "(", "array", "$", "parameters", ")", "{", "if", "(", "$", "this", "->", "demosite", ")", "{", "$", "relPath", "=", "'/AdminList/'", ";", "$", "this", "->", "renderFiles", "(", "$", "this", "->", "skeletonDir", ...
Generate admin list classes. @param array $parameters
[ "Generate", "admin", "list", "classes", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L98-L106
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateEntities
public function generateEntities(array $parameters) { $relPath = '/Entity/Pages/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'HomePage.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'ContentPage.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'BehatTestPage.php', $parameters); if ($this->demosite) { $this->renderSingleFile($sourceDir, $targetDir, 'FormPage.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'SearchPage.php', $parameters); } if ($this->demosite) { $relPath = '/Entity/PageParts/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'PageBannerPagePart.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'ServicePagePart.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'UspPagePart.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'BikesListPagePart.php', $parameters); } if ($this->demosite) { $relPath = '/Entity/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'Bike.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'UspItem.php', $parameters); } $this->assistant->writeLine('Generating entities : <info>OK</info>'); }
php
public function generateEntities(array $parameters) { $relPath = '/Entity/Pages/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'HomePage.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'ContentPage.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'BehatTestPage.php', $parameters); if ($this->demosite) { $this->renderSingleFile($sourceDir, $targetDir, 'FormPage.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'SearchPage.php', $parameters); } if ($this->demosite) { $relPath = '/Entity/PageParts/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'PageBannerPagePart.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'ServicePagePart.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'UspPagePart.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'BikesListPagePart.php', $parameters); } if ($this->demosite) { $relPath = '/Entity/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'Bike.php', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'UspItem.php', $parameters); } $this->assistant->writeLine('Generating entities : <info>OK</info>'); }
[ "public", "function", "generateEntities", "(", "array", "$", "parameters", ")", "{", "$", "relPath", "=", "'/Entity/Pages/'", ";", "$", "sourceDir", "=", "$", "this", "->", "skeletonDir", ".", "$", "relPath", ";", "$", "targetDir", "=", "$", "this", "->", ...
Generate the entity classes. @param array $parameters The template parameters
[ "Generate", "the", "entity", "classes", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L113-L149
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateMenuAdaptors
public function generateMenuAdaptors(array $parameters) { if ($this->demosite) { $relPath = '/Helper/Menu/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'AdminMenuAdaptor.php', $parameters); if ($this->isSymfony4()) { return; } $file = $this->bundle->getPath().'/Resources/config/services.yml'; if (!is_file($file)) { $ymlData = 'services:'; } else { $ymlData = ''; } $ymlData .= "\n\n ".strtolower($this->bundle->getName()).'.admin_menu_adaptor:'; $ymlData .= "\n class: ".$this->bundle->getNamespace()."\Helper\Menu\AdminMenuAdaptor"; $ymlData .= "\n tags:"; $ymlData .= "\n - { name: 'kunstmaan_admin.menu.adaptor' }\n"; file_put_contents($file, $ymlData, FILE_APPEND); $this->assistant->writeLine('Generating menu adaptors : <info>OK</info>'); } }
php
public function generateMenuAdaptors(array $parameters) { if ($this->demosite) { $relPath = '/Helper/Menu/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'AdminMenuAdaptor.php', $parameters); if ($this->isSymfony4()) { return; } $file = $this->bundle->getPath().'/Resources/config/services.yml'; if (!is_file($file)) { $ymlData = 'services:'; } else { $ymlData = ''; } $ymlData .= "\n\n ".strtolower($this->bundle->getName()).'.admin_menu_adaptor:'; $ymlData .= "\n class: ".$this->bundle->getNamespace()."\Helper\Menu\AdminMenuAdaptor"; $ymlData .= "\n tags:"; $ymlData .= "\n - { name: 'kunstmaan_admin.menu.adaptor' }\n"; file_put_contents($file, $ymlData, FILE_APPEND); $this->assistant->writeLine('Generating menu adaptors : <info>OK</info>'); } }
[ "public", "function", "generateMenuAdaptors", "(", "array", "$", "parameters", ")", "{", "if", "(", "$", "this", "->", "demosite", ")", "{", "$", "relPath", "=", "'/Helper/Menu/'", ";", "$", "sourceDir", "=", "$", "this", "->", "skeletonDir", ".", "$", "...
Generate the menu adaptors classes. @param array $parameters The template parameters
[ "Generate", "the", "menu", "adaptors", "classes", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L198-L225
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generatePagepartConfigs
public function generatePagepartConfigs(array $parameters) { $basePath = $this->isSymfony4() ? $this->container->getParameter('kernel.project_dir') : $this->bundle->getPath(); $relPath = $this->isSymfony4() ? '/config/kunstmaancms/pageparts' : '/Resources/config/pageparts/'; $sourceDir = $this->skeletonDir.'/Resources/config/pageparts/'; $targetDir = $basePath.$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'main.yml', $parameters); if ($this->demosite) { $this->renderSingleFile($sourceDir, $targetDir, 'header.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section1.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section2.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section3.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section4.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section5.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'form.yml', $parameters); } $this->assistant->writeLine('Generating pagepart configuration : <info>OK</info>'); }
php
public function generatePagepartConfigs(array $parameters) { $basePath = $this->isSymfony4() ? $this->container->getParameter('kernel.project_dir') : $this->bundle->getPath(); $relPath = $this->isSymfony4() ? '/config/kunstmaancms/pageparts' : '/Resources/config/pageparts/'; $sourceDir = $this->skeletonDir.'/Resources/config/pageparts/'; $targetDir = $basePath.$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'main.yml', $parameters); if ($this->demosite) { $this->renderSingleFile($sourceDir, $targetDir, 'header.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section1.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section2.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section3.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section4.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'section5.yml', $parameters); $this->renderSingleFile($sourceDir, $targetDir, 'form.yml', $parameters); } $this->assistant->writeLine('Generating pagepart configuration : <info>OK</info>'); }
[ "public", "function", "generatePagepartConfigs", "(", "array", "$", "parameters", ")", "{", "$", "basePath", "=", "$", "this", "->", "isSymfony4", "(", ")", "?", "$", "this", "->", "container", "->", "getParameter", "(", "'kernel.project_dir'", ")", ":", "$"...
Generate the pagepart section configuration. @param array $parameters The template parameters
[ "Generate", "the", "pagepart", "section", "configuration", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L253-L273
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateConfig
public function generateConfig() { if ($this->isSymfony4()) { return; } $configFile = $this->rootDir.'/app/config/config.yml'; $config = file_get_contents($configFile); $data = Yaml::parse($config); if (!array_key_exists('white_october_pagerfanta', $data)) { $ymlData = "\n\nwhite_october_pagerfanta:"; $ymlData .= "\n default_view: twitter_bootstrap\n"; file_put_contents($configFile, $ymlData, FILE_APPEND); } }
php
public function generateConfig() { if ($this->isSymfony4()) { return; } $configFile = $this->rootDir.'/app/config/config.yml'; $config = file_get_contents($configFile); $data = Yaml::parse($config); if (!array_key_exists('white_october_pagerfanta', $data)) { $ymlData = "\n\nwhite_october_pagerfanta:"; $ymlData .= "\n default_view: twitter_bootstrap\n"; file_put_contents($configFile, $ymlData, FILE_APPEND); } }
[ "public", "function", "generateConfig", "(", ")", "{", "if", "(", "$", "this", "->", "isSymfony4", "(", ")", ")", "{", "return", ";", "}", "$", "configFile", "=", "$", "this", "->", "rootDir", ".", "'/app/config/config.yml'", ";", "$", "config", "=", "...
Append to the application config file.
[ "Append", "to", "the", "application", "config", "file", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L303-L318
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateRouting
public function generateRouting(array $parameters) { if ($this->isSymfony4()) { return; } $relPath = '/Resources/config/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'routing.yml', $parameters, true); $this->assistant->writeLine('Generating routing : <info>OK</info>'); }
php
public function generateRouting(array $parameters) { if ($this->isSymfony4()) { return; } $relPath = '/Resources/config/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'routing.yml', $parameters, true); $this->assistant->writeLine('Generating routing : <info>OK</info>'); }
[ "public", "function", "generateRouting", "(", "array", "$", "parameters", ")", "{", "if", "(", "$", "this", "->", "isSymfony4", "(", ")", ")", "{", "return", ";", "}", "$", "relPath", "=", "'/Resources/config/'", ";", "$", "sourceDir", "=", "$", "this", ...
Generate bundle routing configuration. @param array $parameters The template parameters
[ "Generate", "bundle", "routing", "configuration", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L325-L338
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.generateTwigExtensions
public function generateTwigExtensions($parameters) { $relPath = '/Twig/'; if ($this->demosite) { $this->renderSingleFile($this->skeletonDir.$relPath, $this->bundle->getPath().$relPath, 'BikesTwigExtension.php', $parameters, true); } if ($this->isSymfony4()) { return; } $relPath = '/Resources/config/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'services.yml', $parameters, true); }
php
public function generateTwigExtensions($parameters) { $relPath = '/Twig/'; if ($this->demosite) { $this->renderSingleFile($this->skeletonDir.$relPath, $this->bundle->getPath().$relPath, 'BikesTwigExtension.php', $parameters, true); } if ($this->isSymfony4()) { return; } $relPath = '/Resources/config/'; $sourceDir = $this->skeletonDir.$relPath; $targetDir = $this->bundle->getPath().$relPath; $this->renderSingleFile($sourceDir, $targetDir, 'services.yml', $parameters, true); }
[ "public", "function", "generateTwigExtensions", "(", "$", "parameters", ")", "{", "$", "relPath", "=", "'/Twig/'", ";", "if", "(", "$", "this", "->", "demosite", ")", "{", "$", "this", "->", "renderSingleFile", "(", "$", "this", "->", "skeletonDir", ".", ...
Generate the twig extensions. @param array $parameters The template parameters
[ "Generate", "the", "twig", "extensions", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L420-L435
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php
DefaultSiteGenerator.isMultiLangEnvironment
private function isMultiLangEnvironment() { // use the multilanguage parameter, if it exists if ($this->container->hasParameter('kunstmaan_admin.multi_language')) { return $this->container->getParameter('kunstmaan_admin.multi_language'); } // This is a pretty silly implementation. // It just checks if it can find _locale in the routing.yml $routingFile = file_get_contents($this->rootDir.'/app/config/routing.yml'); return preg_match('/_locale:/i', $routingFile); }
php
private function isMultiLangEnvironment() { // use the multilanguage parameter, if it exists if ($this->container->hasParameter('kunstmaan_admin.multi_language')) { return $this->container->getParameter('kunstmaan_admin.multi_language'); } // This is a pretty silly implementation. // It just checks if it can find _locale in the routing.yml $routingFile = file_get_contents($this->rootDir.'/app/config/routing.yml'); return preg_match('/_locale:/i', $routingFile); }
[ "private", "function", "isMultiLangEnvironment", "(", ")", "{", "// use the multilanguage parameter, if it exists", "if", "(", "$", "this", "->", "container", "->", "hasParameter", "(", "'kunstmaan_admin.multi_language'", ")", ")", "{", "return", "$", "this", "->", "c...
Returns true if we detect the site uses the locale. @return bool
[ "Returns", "true", "if", "we", "detect", "the", "site", "uses", "the", "locale", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/DefaultSiteGenerator.php#L442-L454
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsListCommand.php
GoogleAnalyticsOverviewsListCommand.getOverviewsOfSegment
private function getOverviewsOfSegment($segmentId) { // get specified segment $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); $segment = $segmentRepository->find($segmentId); if (!$segment) { throw new \Exception('Unkown segment ID'); } // get the overviews return $segment->getOverviews(); }
php
private function getOverviewsOfSegment($segmentId) { // get specified segment $segmentRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsSegment'); $segment = $segmentRepository->find($segmentId); if (!$segment) { throw new \Exception('Unkown segment ID'); } // get the overviews return $segment->getOverviews(); }
[ "private", "function", "getOverviewsOfSegment", "(", "$", "segmentId", ")", "{", "// get specified segment", "$", "segmentRepository", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsSegment'", ")", ";", "$", "segment", "=...
get all overviews of a segment @param int $segmentId @return array
[ "get", "all", "overviews", "of", "a", "segment" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/GoogleAnalyticsOverviewsListCommand.php#L116-L128
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Controller/RobotsController.php
RobotsController.indexAction
public function indexAction(Request $request) { $entity = $this->getDoctrine()->getRepository('KunstmaanSeoBundle:Robots')->findOneBy(array()); $robots = $this->getParameter('robots_default'); if ($entity && $entity->getRobotsTxt()) { $robots = $entity->getRobotsTxt(); } else { $file = $request->getBasePath() . 'robots.txt'; if (file_exists($file)) { $robots = file_get_contents($file); } } return array('robots' => $robots); }
php
public function indexAction(Request $request) { $entity = $this->getDoctrine()->getRepository('KunstmaanSeoBundle:Robots')->findOneBy(array()); $robots = $this->getParameter('robots_default'); if ($entity && $entity->getRobotsTxt()) { $robots = $entity->getRobotsTxt(); } else { $file = $request->getBasePath() . 'robots.txt'; if (file_exists($file)) { $robots = file_get_contents($file); } } return array('robots' => $robots); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "entity", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'KunstmaanSeoBundle:Robots'", ")", "->", "findOneBy", "(", "array", "(", ")", ")", "...
Generates the robots.txt content when available in the database and falls back to normal robots.txt if exists @Route(path="/robots.txt", name="KunstmaanSeoBundle_robots", defaults={"_format": "txt"}) @Template(template="@KunstmaanSeo/Admin/Robots/index.html.twig") @param Request $request @return array
[ "Generates", "the", "robots", ".", "txt", "content", "when", "available", "in", "the", "database", "and", "falls", "back", "to", "normal", "robots", ".", "txt", "if", "exists" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Controller/RobotsController.php#L22-L37
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/ArticleBundle/AdminList/AbstractArticlePageAdminListConfigurator.php
AbstractArticlePageAdminListConfigurator.getOverviewPage
public function getOverviewPage() { $repository = $this->getOverviewPageRepository(); $pages = $repository->findActiveOverviewPages(); if (isset($pages) && count($pages) > 0) { return $pages[0]; } return null; }
php
public function getOverviewPage() { $repository = $this->getOverviewPageRepository(); $pages = $repository->findActiveOverviewPages(); if (isset($pages) && count($pages) > 0) { return $pages[0]; } return null; }
[ "public", "function", "getOverviewPage", "(", ")", "{", "$", "repository", "=", "$", "this", "->", "getOverviewPageRepository", "(", ")", ";", "$", "pages", "=", "$", "repository", "->", "findActiveOverviewPages", "(", ")", ";", "if", "(", "isset", "(", "$...
Returns the OverviewPage of these articles @return AbstractArticleOverviewPage
[ "Returns", "the", "OverviewPage", "of", "these", "articles" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/ArticleBundle/AdminList/AbstractArticlePageAdminListConfigurator.php#L155-L165
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Translator/ResourceCacher.php
ResourceCacher.cacheResources
public function cacheResources(array $resources) { $cache = new ConfigCache($this->getCacheFileLocation(), $this->debug); $content = sprintf('<?php return %s;', var_export($resources, true)); $cache->write($content); $this->logger->debug('Writing translation resources to cache file.'); }
php
public function cacheResources(array $resources) { $cache = new ConfigCache($this->getCacheFileLocation(), $this->debug); $content = sprintf('<?php return %s;', var_export($resources, true)); $cache->write($content); $this->logger->debug('Writing translation resources to cache file.'); }
[ "public", "function", "cacheResources", "(", "array", "$", "resources", ")", "{", "$", "cache", "=", "new", "ConfigCache", "(", "$", "this", "->", "getCacheFileLocation", "(", ")", ",", "$", "this", "->", "debug", ")", ";", "$", "content", "=", "sprintf"...
Cache an array of resources into the given cache @param array $resources
[ "Cache", "an", "array", "of", "resources", "into", "the", "given", "cache" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Translator/ResourceCacher.php#L57-L63
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.generateEntity
protected function generateEntity( BundleInterface $bundle, $name, $fields, $namePrefix, $dbPrefix, $extendClass = null, $withRepository = false ) { // configure the bundle (needed if the bundle does not contain any Entities yet) $config = $this->registry->getManager(null)->getConfiguration(); $config->setEntityNamespaces( array_merge( array($bundle->getName() => $bundle->getNamespace() . '\\Entity' . ($namePrefix ? '\\' . $namePrefix : '')), $config->getEntityNamespaces() ) ); $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . ($namePrefix ? '\\' . $namePrefix : '') . '\\' . $name; $entityPath = $bundle->getPath() . '/Entity/' . ($namePrefix ? $namePrefix . '/' : '') . str_replace('\\', '/', $name) . '.php'; if (file_exists($entityPath)) { throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass)); } $class = new ClassMetadataInfo($entityClass, new UnderscoreNamingStrategy()); if ($withRepository) { if ($this->isSymfony4()) { $repositoryClass = preg_replace('/\\\\Entity\\\\/', '\\Repository\\', $entityClass, 1) . 'Repository'; $class->customRepositoryClassName = $repositoryClass; $this->getSymfony4RepositoryGenerator()->writeEntityRepositoryClass($entityClass, $repositoryClass, $bundle->getPath()); } else { $entityClass = preg_replace('/\\\\Entity\\\\/', '\\Repository\\', $entityClass, 1); $class->customRepositoryClassName = $entityClass.'Repository'; $path = $bundle->getPath().str_repeat('/..', substr_count(get_class($bundle), '\\')); $this->getRepositoryGenerator()->writeEntityRepositoryClass($class->customRepositoryClassName, $path); } } foreach ($fields as $fieldSet) { foreach ($fieldSet as $fieldArray) { foreach ($fieldArray as $field) { if (array_key_exists('joinColumn', $field)) { $class->mapManyToOne($field); } elseif (array_key_exists('joinTable', $field)) { $class->mapManyToMany($field); } else { $class->mapField($field); } } } } $class->setPrimaryTable( array( 'name' => strtolower($dbPrefix) . Inflector::tableize(Inflector::pluralize($name)), ) ); $entityCode = $this->getEntityGenerator($extendClass)->generateEntityClass($class); return array($entityCode, $entityPath); }
php
protected function generateEntity( BundleInterface $bundle, $name, $fields, $namePrefix, $dbPrefix, $extendClass = null, $withRepository = false ) { // configure the bundle (needed if the bundle does not contain any Entities yet) $config = $this->registry->getManager(null)->getConfiguration(); $config->setEntityNamespaces( array_merge( array($bundle->getName() => $bundle->getNamespace() . '\\Entity' . ($namePrefix ? '\\' . $namePrefix : '')), $config->getEntityNamespaces() ) ); $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . ($namePrefix ? '\\' . $namePrefix : '') . '\\' . $name; $entityPath = $bundle->getPath() . '/Entity/' . ($namePrefix ? $namePrefix . '/' : '') . str_replace('\\', '/', $name) . '.php'; if (file_exists($entityPath)) { throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass)); } $class = new ClassMetadataInfo($entityClass, new UnderscoreNamingStrategy()); if ($withRepository) { if ($this->isSymfony4()) { $repositoryClass = preg_replace('/\\\\Entity\\\\/', '\\Repository\\', $entityClass, 1) . 'Repository'; $class->customRepositoryClassName = $repositoryClass; $this->getSymfony4RepositoryGenerator()->writeEntityRepositoryClass($entityClass, $repositoryClass, $bundle->getPath()); } else { $entityClass = preg_replace('/\\\\Entity\\\\/', '\\Repository\\', $entityClass, 1); $class->customRepositoryClassName = $entityClass.'Repository'; $path = $bundle->getPath().str_repeat('/..', substr_count(get_class($bundle), '\\')); $this->getRepositoryGenerator()->writeEntityRepositoryClass($class->customRepositoryClassName, $path); } } foreach ($fields as $fieldSet) { foreach ($fieldSet as $fieldArray) { foreach ($fieldArray as $field) { if (array_key_exists('joinColumn', $field)) { $class->mapManyToOne($field); } elseif (array_key_exists('joinTable', $field)) { $class->mapManyToMany($field); } else { $class->mapField($field); } } } } $class->setPrimaryTable( array( 'name' => strtolower($dbPrefix) . Inflector::tableize(Inflector::pluralize($name)), ) ); $entityCode = $this->getEntityGenerator($extendClass)->generateEntityClass($class); return array($entityCode, $entityPath); }
[ "protected", "function", "generateEntity", "(", "BundleInterface", "$", "bundle", ",", "$", "name", ",", "$", "fields", ",", "$", "namePrefix", ",", "$", "dbPrefix", ",", "$", "extendClass", "=", "null", ",", "$", "withRepository", "=", "false", ")", "{", ...
Generate the entity PHP code. @param BundleInterface $bundle @param string $name @param array $fields @param string $namePrefix @param string $dbPrefix @param string|null $extendClass @param bool $withRepository @return array @throws \RuntimeException
[ "Generate", "the", "entity", "PHP", "code", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L100-L159
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.getEntityGenerator
protected function getEntityGenerator($classToExtend = null) { $entityGenerator = new EntityGenerator(); if (!is_null($classToExtend)) { $entityGenerator->setClassToExtend($classToExtend); } $entityGenerator->setGenerateAnnotations(true); $entityGenerator->setGenerateStubMethods(true); $entityGenerator->setRegenerateEntityIfExists(false); $entityGenerator->setUpdateEntityIfExists(true); $entityGenerator->setNumSpaces(4); $entityGenerator->setAnnotationPrefix('ORM\\'); return $entityGenerator; }
php
protected function getEntityGenerator($classToExtend = null) { $entityGenerator = new EntityGenerator(); if (!is_null($classToExtend)) { $entityGenerator->setClassToExtend($classToExtend); } $entityGenerator->setGenerateAnnotations(true); $entityGenerator->setGenerateStubMethods(true); $entityGenerator->setRegenerateEntityIfExists(false); $entityGenerator->setUpdateEntityIfExists(true); $entityGenerator->setNumSpaces(4); $entityGenerator->setAnnotationPrefix('ORM\\'); return $entityGenerator; }
[ "protected", "function", "getEntityGenerator", "(", "$", "classToExtend", "=", "null", ")", "{", "$", "entityGenerator", "=", "new", "EntityGenerator", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "classToExtend", ")", ")", "{", "$", "entityGenerator"...
Get a Doctrine EntityGenerator instance. @param string|null $classToExtend @return EntityGenerator
[ "Get", "a", "Doctrine", "EntityGenerator", "instance", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L168-L182
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.generateEntityAdminType
protected function generateEntityAdminType( $bundle, $entityName, $entityPrefix, array $fields, $extendClass = '\Symfony\Component\Form\AbstractType' ) { $className = $entityName . 'AdminType'; $savePath = $bundle->getPath() . '/Form/' . $entityPrefix . '/' . $className . '.php'; $name = str_replace( '\\', '_', strtolower($bundle->getNamespace()) ) . '_' . strtolower($entityName) . 'type'; $params = array( 'className' => $className, 'name' => $name, 'namespace' => $bundle->getNamespace(), 'entity' => '\\' . $bundle->getNamespace() . '\Entity\\' . $entityPrefix . '\\' . $entityName, 'fields' => $fields, 'entity_prefix' => $entityPrefix, 'extend_class' => $extendClass, ); $this->renderFile('/Form/EntityAdminType.php', $savePath, $params); }
php
protected function generateEntityAdminType( $bundle, $entityName, $entityPrefix, array $fields, $extendClass = '\Symfony\Component\Form\AbstractType' ) { $className = $entityName . 'AdminType'; $savePath = $bundle->getPath() . '/Form/' . $entityPrefix . '/' . $className . '.php'; $name = str_replace( '\\', '_', strtolower($bundle->getNamespace()) ) . '_' . strtolower($entityName) . 'type'; $params = array( 'className' => $className, 'name' => $name, 'namespace' => $bundle->getNamespace(), 'entity' => '\\' . $bundle->getNamespace() . '\Entity\\' . $entityPrefix . '\\' . $entityName, 'fields' => $fields, 'entity_prefix' => $entityPrefix, 'extend_class' => $extendClass, ); $this->renderFile('/Form/EntityAdminType.php', $savePath, $params); }
[ "protected", "function", "generateEntityAdminType", "(", "$", "bundle", ",", "$", "entityName", ",", "$", "entityPrefix", ",", "array", "$", "fields", ",", "$", "extendClass", "=", "'\\Symfony\\Component\\Form\\AbstractType'", ")", "{", "$", "className", "=", "$",...
Generate the entity admin type. @param $bundle @param $entityName @param $entityPrefix @param array $fields @param string $extendClass
[ "Generate", "the", "entity", "admin", "type", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L193-L218
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.installDefaultPageTemplates
protected function installDefaultPageTemplates($bundle) { // Configuration templates if ($this->isSymfony4()) { $dirPath = $this->container->getParameter('kernel.project_dir') . '/config/kunstmaancms/pagetemplates/'; } else { $dirPath = sprintf('%s/Resources/config/pagetemplates/', $bundle->getPath()); } $skeletonDir = sprintf('%s/Resources/config/pagetemplates/', GeneratorUtils::getFullSkeletonPath('/common')); // Only copy templates over when the folder does not exist yet... if (!$this->filesystem->exists($dirPath)) { $files = array( 'default-one-column.yml', 'default-two-column-left.yml', 'default-two-column-right.yml', 'default-three-column.yml', ); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); GeneratorUtils::replace('~~~BUNDLE~~~', $bundle->getName(), $dirPath . $file); } } // Twig templates $dirPath = $this->getTemplateDir($bundle) . '/Pages/Common/'; $skeletonDir = sprintf('%s/Resources/views/Pages/Common/', GeneratorUtils::getFullSkeletonPath('/common')); if (!$this->filesystem->exists($dirPath)) { $files = array( 'one-column-pagetemplate.html.twig', 'two-column-left-pagetemplate.html.twig', 'two-column-right-pagetemplate.html.twig', 'three-column-pagetemplate.html.twig', ); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); } $this->filesystem->copy($skeletonDir . 'view.html.twig', $dirPath . 'view.html.twig', false); } $contents = file_get_contents($dirPath . 'view.html.twig'); $twigFile = $this->isSymfony4() ? $twigFile = "{% extends 'Layout/layout.html.twig' %}\n" : $twigFile = "{% extends '".$bundle->getName().":Layout:layout.html.twig' %}\n" ; if (strpos($contents, '{% extends ') === false) { GeneratorUtils::prepend( $twigFile, $dirPath . 'view.html.twig' ); } }
php
protected function installDefaultPageTemplates($bundle) { // Configuration templates if ($this->isSymfony4()) { $dirPath = $this->container->getParameter('kernel.project_dir') . '/config/kunstmaancms/pagetemplates/'; } else { $dirPath = sprintf('%s/Resources/config/pagetemplates/', $bundle->getPath()); } $skeletonDir = sprintf('%s/Resources/config/pagetemplates/', GeneratorUtils::getFullSkeletonPath('/common')); // Only copy templates over when the folder does not exist yet... if (!$this->filesystem->exists($dirPath)) { $files = array( 'default-one-column.yml', 'default-two-column-left.yml', 'default-two-column-right.yml', 'default-three-column.yml', ); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); GeneratorUtils::replace('~~~BUNDLE~~~', $bundle->getName(), $dirPath . $file); } } // Twig templates $dirPath = $this->getTemplateDir($bundle) . '/Pages/Common/'; $skeletonDir = sprintf('%s/Resources/views/Pages/Common/', GeneratorUtils::getFullSkeletonPath('/common')); if (!$this->filesystem->exists($dirPath)) { $files = array( 'one-column-pagetemplate.html.twig', 'two-column-left-pagetemplate.html.twig', 'two-column-right-pagetemplate.html.twig', 'three-column-pagetemplate.html.twig', ); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); } $this->filesystem->copy($skeletonDir . 'view.html.twig', $dirPath . 'view.html.twig', false); } $contents = file_get_contents($dirPath . 'view.html.twig'); $twigFile = $this->isSymfony4() ? $twigFile = "{% extends 'Layout/layout.html.twig' %}\n" : $twigFile = "{% extends '".$bundle->getName().":Layout:layout.html.twig' %}\n" ; if (strpos($contents, '{% extends ') === false) { GeneratorUtils::prepend( $twigFile, $dirPath . 'view.html.twig' ); } }
[ "protected", "function", "installDefaultPageTemplates", "(", "$", "bundle", ")", "{", "// Configuration templates", "if", "(", "$", "this", "->", "isSymfony4", "(", ")", ")", "{", "$", "dirPath", "=", "$", "this", "->", "container", "->", "getParameter", "(", ...
Install the default page templates. @param BundleInterface $bundle
[ "Install", "the", "default", "page", "templates", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L225-L281
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.installDefaultPagePartConfiguration
protected function installDefaultPagePartConfiguration($bundle) { // Pagepart configuration if ($this->isSymfony4()) { $dirPath = $this->container->getParameter('kernel.project_dir') . '/config/kunstmaancms/pageparts/'; } else { $dirPath = sprintf('%s/Resources/config/pageparts/', $bundle->getPath()); } $skeletonDir = sprintf('%s/Resources/config/pageparts/', GeneratorUtils::getFullSkeletonPath('/common')); // Only copy when folder does not exist yet if (!$this->filesystem->exists($dirPath)) { $files = array('footer.yml', 'main.yml', 'left-sidebar.yml', 'right-sidebar.yml'); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); } } }
php
protected function installDefaultPagePartConfiguration($bundle) { // Pagepart configuration if ($this->isSymfony4()) { $dirPath = $this->container->getParameter('kernel.project_dir') . '/config/kunstmaancms/pageparts/'; } else { $dirPath = sprintf('%s/Resources/config/pageparts/', $bundle->getPath()); } $skeletonDir = sprintf('%s/Resources/config/pageparts/', GeneratorUtils::getFullSkeletonPath('/common')); // Only copy when folder does not exist yet if (!$this->filesystem->exists($dirPath)) { $files = array('footer.yml', 'main.yml', 'left-sidebar.yml', 'right-sidebar.yml'); foreach ($files as $file) { $this->filesystem->copy($skeletonDir . $file, $dirPath . $file, false); } } }
[ "protected", "function", "installDefaultPagePartConfiguration", "(", "$", "bundle", ")", "{", "// Pagepart configuration", "if", "(", "$", "this", "->", "isSymfony4", "(", ")", ")", "{", "$", "dirPath", "=", "$", "this", "->", "container", "->", "getParameter", ...
Install the default pagepart configuration. @param BundleInterface $bundle
[ "Install", "the", "default", "pagepart", "configuration", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L288-L306
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.renderExecutableFile
public function renderExecutableFile($sourceDir, $targetDir, $filename, array $parameters, $override = false, $mode = 0774) { $this->renderSingleFile($sourceDir, $targetDir, $filename, $parameters, $override); $targetDir = rtrim($targetDir, '/') . '/'; $targetFile = $targetDir . $filename; $this->filesystem->chmod($targetFile, $mode); }
php
public function renderExecutableFile($sourceDir, $targetDir, $filename, array $parameters, $override = false, $mode = 0774) { $this->renderSingleFile($sourceDir, $targetDir, $filename, $parameters, $override); $targetDir = rtrim($targetDir, '/') . '/'; $targetFile = $targetDir . $filename; $this->filesystem->chmod($targetFile, $mode); }
[ "public", "function", "renderExecutableFile", "(", "$", "sourceDir", ",", "$", "targetDir", ",", "$", "filename", ",", "array", "$", "parameters", ",", "$", "override", "=", "false", ",", "$", "mode", "=", "0774", ")", "{", "$", "this", "->", "renderSing...
Render a file and make it executable. @param string $sourceDir The source directory where we need to look in @param string $targetDir The target directory where we need to copy the files too @param string $filename The name of the file that needs to be rendered @param array $parameters The parameters that will be passed to the templates @param bool $override Whether to override an existing file or not @param int $mode The mode
[ "Render", "a", "file", "and", "make", "it", "executable", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L391-L398
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.copyFiles
public function copyFiles($sourceDir, $targetDir, $override = false) { // Make sure the source -and target dir contain a trailing slash $sourceDir = rtrim($sourceDir, '/') . '/'; $targetDir = rtrim($targetDir, '/') . '/'; $this->filesystem->mirror($sourceDir, $targetDir, null, array('override' => $override)); }
php
public function copyFiles($sourceDir, $targetDir, $override = false) { // Make sure the source -and target dir contain a trailing slash $sourceDir = rtrim($sourceDir, '/') . '/'; $targetDir = rtrim($targetDir, '/') . '/'; $this->filesystem->mirror($sourceDir, $targetDir, null, array('override' => $override)); }
[ "public", "function", "copyFiles", "(", "$", "sourceDir", ",", "$", "targetDir", ",", "$", "override", "=", "false", ")", "{", "// Make sure the source -and target dir contain a trailing slash", "$", "sourceDir", "=", "rtrim", "(", "$", "sourceDir", ",", "'/'", ")...
Copy all files in the source directory to the target directory. @param string $sourceDir The source directory where we need to look in @param string $targetDir The target directory where we need to copy the files too @param bool $override Whether to override an existing file or not
[ "Copy", "all", "files", "in", "the", "source", "directory", "to", "the", "target", "directory", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L407-L414
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.renderTwig
public function renderTwig($template, array $parameters, $sourceDir) { $twig = new \Twig_Environment( new \Twig_Loader_Filesystem(array($sourceDir)), array( 'debug' => true, 'cache' => false, 'strict_variables' => true, 'autoescape' => false, ) ); // Ruby erb template syntax $lexer = new \Twig_Lexer( $twig, array( 'tag_comment' => array('<%#', '%>'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<%=', '%>'), ) ); $twig->setLexer($lexer); return $twig->render($template, $parameters); }
php
public function renderTwig($template, array $parameters, $sourceDir) { $twig = new \Twig_Environment( new \Twig_Loader_Filesystem(array($sourceDir)), array( 'debug' => true, 'cache' => false, 'strict_variables' => true, 'autoescape' => false, ) ); // Ruby erb template syntax $lexer = new \Twig_Lexer( $twig, array( 'tag_comment' => array('<%#', '%>'), 'tag_block' => array('<%', '%>'), 'tag_variable' => array('<%=', '%>'), ) ); $twig->setLexer($lexer); return $twig->render($template, $parameters); }
[ "public", "function", "renderTwig", "(", "$", "template", ",", "array", "$", "parameters", ",", "$", "sourceDir", ")", "{", "$", "twig", "=", "new", "\\", "Twig_Environment", "(", "new", "\\", "Twig_Loader_Filesystem", "(", "array", "(", "$", "sourceDir", ...
Render a twig file with custom twig tags. @param string $template @param array $parameters @param string $sourceDir @return string
[ "Render", "a", "twig", "file", "with", "custom", "twig", "tags", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L448-L471
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php
KunstmaanGenerator.renderTwigFile
public function renderTwigFile($template, $target, array $parameters, $sourceDir) { if (!is_dir(dirname($target))) { mkdir(dirname($target), 0777, true); } return file_put_contents($target, $this->renderTwig($template, $parameters, $sourceDir)); }
php
public function renderTwigFile($template, $target, array $parameters, $sourceDir) { if (!is_dir(dirname($target))) { mkdir(dirname($target), 0777, true); } return file_put_contents($target, $this->renderTwig($template, $parameters, $sourceDir)); }
[ "public", "function", "renderTwigFile", "(", "$", "template", ",", "$", "target", ",", "array", "$", "parameters", ",", "$", "sourceDir", ")", "{", "if", "(", "!", "is_dir", "(", "dirname", "(", "$", "target", ")", ")", ")", "{", "mkdir", "(", "dirna...
Render a twig file, and save it to disk. @param string $template @param string $target @param array $parameters @param string $sourceDir @return int
[ "Render", "a", "twig", "file", "and", "save", "it", "to", "disk", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/KunstmaanGenerator.php#L483-L490
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/ChartDataCommandHelper.php
ChartDataCommandHelper.getExtra
protected function getExtra(AnalyticsOverview $overview) { $timespan = $overview->getTimespan() - $overview->getStartOffset(); $extra = parent::getExtra($overview); if ($timespan <= 1) { $extra['dimensions'] = 'ga:date,ga:hour'; } elseif ($timespan <= 7) { $extra['dimensions'] = 'ga:date,ga:hour'; } elseif ($timespan <= 31) { $extra['dimensions'] = 'ga:week,ga:day,ga:date'; } else { $extra['dimensions'] = 'ga:isoYearIsoWeek'; } return $extra; }
php
protected function getExtra(AnalyticsOverview $overview) { $timespan = $overview->getTimespan() - $overview->getStartOffset(); $extra = parent::getExtra($overview); if ($timespan <= 1) { $extra['dimensions'] = 'ga:date,ga:hour'; } elseif ($timespan <= 7) { $extra['dimensions'] = 'ga:date,ga:hour'; } elseif ($timespan <= 31) { $extra['dimensions'] = 'ga:week,ga:day,ga:date'; } else { $extra['dimensions'] = 'ga:isoYearIsoWeek'; } return $extra; }
[ "protected", "function", "getExtra", "(", "AnalyticsOverview", "$", "overview", ")", "{", "$", "timespan", "=", "$", "overview", "->", "getTimespan", "(", ")", "-", "$", "overview", "->", "getStartOffset", "(", ")", ";", "$", "extra", "=", "parent", "::", ...
get extra data @return array
[ "get", "extra", "data" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Command/Helper/Analytics/ChartDataCommandHelper.php#L14-L30
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/PagePartBundle/Twig/Extension/PagePartAdminTwigExtension.php
PagePartAdminTwigExtension.renderWidget
public function renderWidget(\Twig_Environment $env, PagePartAdmin $ppAdmin, $form = null, array $parameters = [], $templateName = null) { if ($templateName === null) { $templateName = 'KunstmaanPagePartBundle:PagePartAdminTwigExtension:widget.html.twig'; } $template = $env->loadTemplate($templateName); return $template->render(array_merge($parameters, [ 'pagepartadmin' => $ppAdmin, 'page' => $ppAdmin->getPage(), 'form' => $form, 'extended' => $this->usesExtendedPagePartChooser, ])); }
php
public function renderWidget(\Twig_Environment $env, PagePartAdmin $ppAdmin, $form = null, array $parameters = [], $templateName = null) { if ($templateName === null) { $templateName = 'KunstmaanPagePartBundle:PagePartAdminTwigExtension:widget.html.twig'; } $template = $env->loadTemplate($templateName); return $template->render(array_merge($parameters, [ 'pagepartadmin' => $ppAdmin, 'page' => $ppAdmin->getPage(), 'form' => $form, 'extended' => $this->usesExtendedPagePartChooser, ])); }
[ "public", "function", "renderWidget", "(", "\\", "Twig_Environment", "$", "env", ",", "PagePartAdmin", "$", "ppAdmin", ",", "$", "form", "=", "null", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "templateName", "=", "null", ")", "{", "if", ...
Renders the HTML for a given pagepart Example usage in Twig: {{ pagepartadmin_widget(ppAdmin) }} You can pass options during the call: {{ pagepartadmin_widget(ppAdmin, {'attr': {'class': 'foo'}}) }} {{ pagepartadmin_widget(ppAdmin, {'separator': '+++++'}) }} @param \Twig_Environment $env @param PagePartAdmin $ppAdmin The pagepart admin to render @param Form $form The form @param array $parameters Additional variables passed to the template @param string $templateName @return string The html markup
[ "Renders", "the", "HTML", "for", "a", "given", "pagepart" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/Twig/Extension/PagePartAdminTwigExtension.php#L45-L59
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MediaBundle/Helper/File/PdfHandler.php
PdfHandler.setMediaPath
public function setMediaPath($kernelRootDir) { parent::setMediaPath($kernelRootDir); $this->setWebPath(realpath(str_replace('/', DIRECTORY_SEPARATOR, $kernelRootDir . '/../web/')) . DIRECTORY_SEPARATOR); }
php
public function setMediaPath($kernelRootDir) { parent::setMediaPath($kernelRootDir); $this->setWebPath(realpath(str_replace('/', DIRECTORY_SEPARATOR, $kernelRootDir . '/../web/')) . DIRECTORY_SEPARATOR); }
[ "public", "function", "setMediaPath", "(", "$", "kernelRootDir", ")", "{", "parent", "::", "setMediaPath", "(", "$", "kernelRootDir", ")", ";", "$", "this", "->", "setWebPath", "(", "realpath", "(", "str_replace", "(", "'/'", ",", "DIRECTORY_SEPARATOR", ",", ...
Inject the root dir so we know the full path where we need to store the file. @param string $kernelRootDir
[ "Inject", "the", "root", "dir", "so", "we", "know", "the", "full", "path", "where", "we", "need", "to", "store", "the", "file", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Helper/File/PdfHandler.php#L26-L31
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/AdminPanel/AdminPanel.php
AdminPanel.addAdminPanelAdaptor
public function addAdminPanelAdaptor(AdminPanelAdaptorInterface $adaptor, $priority = 0) { $this->adaptors[$priority][] = $adaptor; unset($this->sorted); }
php
public function addAdminPanelAdaptor(AdminPanelAdaptorInterface $adaptor, $priority = 0) { $this->adaptors[$priority][] = $adaptor; unset($this->sorted); }
[ "public", "function", "addAdminPanelAdaptor", "(", "AdminPanelAdaptorInterface", "$", "adaptor", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "adaptors", "[", "$", "priority", "]", "[", "]", "=", "$", "adaptor", ";", "unset", "(", "$", "t...
Add admin panel adaptor @param AdminPanelAdaptorInterface $adaptor
[ "Add", "admin", "panel", "adaptor" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/AdminPanel/AdminPanel.php#L27-L31
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/AdminPanel/AdminPanel.php
AdminPanel.getAdminPanelActions
public function getAdminPanelActions() { if (!$this->actions) { $this->actions = array(); $adaptors = $this->getAdaptors(); foreach ($adaptors as $adaptor) { $this->actions = array_merge($this->actions, $adaptor->getAdminPanelActions()); } } return $this->actions; }
php
public function getAdminPanelActions() { if (!$this->actions) { $this->actions = array(); $adaptors = $this->getAdaptors(); foreach ($adaptors as $adaptor) { $this->actions = array_merge($this->actions, $adaptor->getAdminPanelActions()); } } return $this->actions; }
[ "public", "function", "getAdminPanelActions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "actions", ")", "{", "$", "this", "->", "actions", "=", "array", "(", ")", ";", "$", "adaptors", "=", "$", "this", "->", "getAdaptors", "(", ")", ";", "...
Return current admin panel actions
[ "Return", "current", "admin", "panel", "actions" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/AdminPanel/AdminPanel.php#L36-L47
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/UtilitiesBundle/Helper/Cipher/UrlSafeCipher.php
UrlSafeCipher.hex2bin
public function hex2bin($hexString) { $pos = 0; $result = ''; while ($pos < strlen($hexString)) { if (strpos(" \t\n\r", $hexString[$pos]) !== false) { ++$pos; } else { $code = hexdec(substr($hexString, $pos, 2)); $pos += 2; $result .= chr($code); } } return $result; }
php
public function hex2bin($hexString) { $pos = 0; $result = ''; while ($pos < strlen($hexString)) { if (strpos(" \t\n\r", $hexString[$pos]) !== false) { ++$pos; } else { $code = hexdec(substr($hexString, $pos, 2)); $pos += 2; $result .= chr($code); } } return $result; }
[ "public", "function", "hex2bin", "(", "$", "hexString", ")", "{", "$", "pos", "=", "0", ";", "$", "result", "=", "''", ";", "while", "(", "$", "pos", "<", "strlen", "(", "$", "hexString", ")", ")", "{", "if", "(", "strpos", "(", "\" \\t\\n\\r\"", ...
Decodes a hexadecimal encoded binary string. PHP version >= 5.4 has a function for this by default. @param string $hexString @return string
[ "Decodes", "a", "hexadecimal", "encoded", "binary", "string", ".", "PHP", "version", ">", "=", "5", ".", "4", "has", "a", "function", "for", "this", "by", "default", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/UtilitiesBundle/Helper/Cipher/UrlSafeCipher.php#L49-L64
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/ConfigBundle/Controller/ConfigController.php
ConfigController.indexAction
public function indexAction(Request $request, $internalName) { /** * @var AbstractConfig */ $entity = $this->getConfigEntityByInternalName($internalName); $entityClass = get_class($entity); // Check if current user has permission for the site config. foreach ($entity->getRoles() as $role) { $this->checkPermission($role); } $repo = $this->em->getRepository($entityClass); $config = $repo->findOneBy(array()); if (!$config) { $config = new $entityClass(); } $form = $this->formFactory->create( $entity->getDefaultAdminType(), $config ); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->em->persist($config); $this->em->flush(); return new RedirectResponse($this->router->generate('kunstmaanconfigbundle_default', array('internalName' => $internalName))); } } return $this->templating->renderResponse( '@KunstmaanConfig/Settings/configSettings.html.twig', array( 'form' => $form->createView(), ) ); }
php
public function indexAction(Request $request, $internalName) { /** * @var AbstractConfig */ $entity = $this->getConfigEntityByInternalName($internalName); $entityClass = get_class($entity); // Check if current user has permission for the site config. foreach ($entity->getRoles() as $role) { $this->checkPermission($role); } $repo = $this->em->getRepository($entityClass); $config = $repo->findOneBy(array()); if (!$config) { $config = new $entityClass(); } $form = $this->formFactory->create( $entity->getDefaultAdminType(), $config ); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->em->persist($config); $this->em->flush(); return new RedirectResponse($this->router->generate('kunstmaanconfigbundle_default', array('internalName' => $internalName))); } } return $this->templating->renderResponse( '@KunstmaanConfig/Settings/configSettings.html.twig', array( 'form' => $form->createView(), ) ); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ",", "$", "internalName", ")", "{", "/**\n * @var AbstractConfig\n */", "$", "entity", "=", "$", "this", "->", "getConfigEntityByInternalName", "(", "$", "internalName", ")", ";", "...
Generates the site config administration form and fills it with a default value if needed. @param Request $request @param string $internalName @return array|RedirectResponse
[ "Generates", "the", "site", "config", "administration", "form", "and", "fills", "it", "with", "a", "default", "value", "if", "needed", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/ConfigBundle/Controller/ConfigController.php#L95-L137
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/AdminRouteHelper.php
AdminRouteHelper.isAdminRoute
public function isAdminRoute($url) { if ($this->matchesPreviewRoute($url)) { return false; } preg_match(sprintf(self::$ADMIN_MATCH_REGEX, $this->adminKey), $url, $matches); // Check if path is part of admin area if (count($matches) === 0) { return false; } return true; }
php
public function isAdminRoute($url) { if ($this->matchesPreviewRoute($url)) { return false; } preg_match(sprintf(self::$ADMIN_MATCH_REGEX, $this->adminKey), $url, $matches); // Check if path is part of admin area if (count($matches) === 0) { return false; } return true; }
[ "public", "function", "isAdminRoute", "(", "$", "url", ")", "{", "if", "(", "$", "this", "->", "matchesPreviewRoute", "(", "$", "url", ")", ")", "{", "return", "false", ";", "}", "preg_match", "(", "sprintf", "(", "self", "::", "$", "ADMIN_MATCH_REGEX", ...
Checks wether the given url points to an admin route @param string $url @return bool
[ "Checks", "wether", "the", "given", "url", "points", "to", "an", "admin", "route" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/AdminRouteHelper.php#L43-L57
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Helper/Order.php
Order.accumulatePropertyOnOrderItems
private function accumulatePropertyOnOrderItems($property) { if (count($this->orderItems) == 0) { return ''; } $total = 0; foreach ($this->orderItems as $orderItem) { $total += $orderItem->$property(); } return $total; }
php
private function accumulatePropertyOnOrderItems($property) { if (count($this->orderItems) == 0) { return ''; } $total = 0; foreach ($this->orderItems as $orderItem) { $total += $orderItem->$property(); } return $total; }
[ "private", "function", "accumulatePropertyOnOrderItems", "(", "$", "property", ")", "{", "if", "(", "count", "(", "$", "this", "->", "orderItems", ")", "==", "0", ")", "{", "return", "''", ";", "}", "$", "total", "=", "0", ";", "foreach", "(", "$", "...
Loops over the OrderItems and accumulates the value of the given property. Can also be a getter. @param $property @return int|string
[ "Loops", "over", "the", "OrderItems", "and", "accumulates", "the", "value", "of", "the", "given", "property", ".", "Can", "also", "be", "a", "getter", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Helper/Order.php#L193-L205
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FixturesBundle/Loader/FixtureLoader.php
FixtureLoader.initFixtures
private function initFixtures($data) { $fixtures = []; $parser = $this->container->get('kunstmaan_fixtures.parser.parser'); foreach ($data as $file) { foreach ($file as $class => $specs) { foreach ($specs as $name => $options) { $fixture = new Fixture($name, $class, $options); $fixtures = $parser->parseSpec($name, $fixture, $fixtures); } } } return $fixtures; }
php
private function initFixtures($data) { $fixtures = []; $parser = $this->container->get('kunstmaan_fixtures.parser.parser'); foreach ($data as $file) { foreach ($file as $class => $specs) { foreach ($specs as $name => $options) { $fixture = new Fixture($name, $class, $options); $fixtures = $parser->parseSpec($name, $fixture, $fixtures); } } } return $fixtures; }
[ "private", "function", "initFixtures", "(", "$", "data", ")", "{", "$", "fixtures", "=", "[", "]", ";", "$", "parser", "=", "$", "this", "->", "container", "->", "get", "(", "'kunstmaan_fixtures.parser.parser'", ")", ";", "foreach", "(", "$", "data", "as...
Parse specs and initiate fixtures @param $data @return array|mixed
[ "Parse", "specs", "and", "initiate", "fixtures" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FixturesBundle/Loader/FixtureLoader.php#L64-L79
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php
DomainBasedLocaleRouter.generate
public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { if ('_slug' === $name) { if ($this->isMultiLanguage() && $this->isMultiDomainHost()) { $locale = isset($parameters['_locale']) ? $parameters['_locale'] : $this->getRequestLocale(); $reverseLocaleMap = $this->getReverseLocaleMap(); if (isset($reverseLocaleMap[$locale])) { $parameters['_locale'] = $reverseLocaleMap[$locale]; } } } if (isset($parameters['otherSite'])) { $this->otherSite = $this->domainConfiguration->getFullHostById($parameters['otherSite']); } else { $this->otherSite = null; } $this->urlGenerator = new UrlGenerator( $this->getRouteCollection(), $this->getContext() ); if (isset($parameters['otherSite'])) { unset($parameters['otherSite']); } return $this->urlGenerator->generate($name, $parameters, $referenceType); }
php
public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { if ('_slug' === $name) { if ($this->isMultiLanguage() && $this->isMultiDomainHost()) { $locale = isset($parameters['_locale']) ? $parameters['_locale'] : $this->getRequestLocale(); $reverseLocaleMap = $this->getReverseLocaleMap(); if (isset($reverseLocaleMap[$locale])) { $parameters['_locale'] = $reverseLocaleMap[$locale]; } } } if (isset($parameters['otherSite'])) { $this->otherSite = $this->domainConfiguration->getFullHostById($parameters['otherSite']); } else { $this->otherSite = null; } $this->urlGenerator = new UrlGenerator( $this->getRouteCollection(), $this->getContext() ); if (isset($parameters['otherSite'])) { unset($parameters['otherSite']); } return $this->urlGenerator->generate($name, $parameters, $referenceType); }
[ "public", "function", "generate", "(", "$", "name", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "referenceType", "=", "UrlGeneratorInterface", "::", "ABSOLUTE_PATH", ")", "{", "if", "(", "'_slug'", "===", "$", "name", ")", "{", "if", "(", ...
Generate an url for a supplied route @param string $name The path @param array $parameters The route parameters @param int|bool $referenceType The type of reference to be generated (one of the UrlGeneratorInterface constants) @return null|string
[ "Generate", "an", "url", "for", "a", "supplied", "route" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MultiDomainBundle/Router/DomainBasedLocaleRouter.php#L41-L70
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Form/EventListener/URLChooserLinkTypeSubscriber.php
URLChooserLinkTypeSubscriber.postSubmit
public function postSubmit(FormEvent $event) { // Suppress validation $event->stopPropagation(); $constraints = []; $attributes['class'] = 'js-change-urlchooser'; $form = $event->getForm()->getParent(); $linkType = $event->getData(); if ($linkType) { $form->remove('link_url'); switch ($linkType) { case URLChooserType::INTERNAL: $attributes['choose_url'] = true; break; case URLChooserType::EXTERNAL: $attributes['placeholder'] = 'https://'; $constraints[] = new Url(); break; case URLChooserType::EMAIL: $constraints[] = new Email(); break; } $form->add('link_url', TextType::class, array( 'label' => 'URL', 'required' => true, 'attr' => $attributes, 'constraints' => $constraints, 'error_bubbling' => true, )); } }
php
public function postSubmit(FormEvent $event) { // Suppress validation $event->stopPropagation(); $constraints = []; $attributes['class'] = 'js-change-urlchooser'; $form = $event->getForm()->getParent(); $linkType = $event->getData(); if ($linkType) { $form->remove('link_url'); switch ($linkType) { case URLChooserType::INTERNAL: $attributes['choose_url'] = true; break; case URLChooserType::EXTERNAL: $attributes['placeholder'] = 'https://'; $constraints[] = new Url(); break; case URLChooserType::EMAIL: $constraints[] = new Email(); break; } $form->add('link_url', TextType::class, array( 'label' => 'URL', 'required' => true, 'attr' => $attributes, 'constraints' => $constraints, 'error_bubbling' => true, )); } }
[ "public", "function", "postSubmit", "(", "FormEvent", "$", "event", ")", "{", "// Suppress validation", "$", "event", "->", "stopPropagation", "(", ")", ";", "$", "constraints", "=", "[", "]", ";", "$", "attributes", "[", "'class'", "]", "=", "'js-change-url...
When changing the link type, the form get's submitted with an ajax callback in the url_chooser.js; We add the URL field only as an URL Chooser if it's an external link. @param FormEvent $event
[ "When", "changing", "the", "link", "type", "the", "form", "get", "s", "submitted", "with", "an", "ajax", "callback", "in", "the", "url_chooser", ".", "js", ";", "We", "add", "the", "URL", "field", "only", "as", "an", "URL", "Chooser", "if", "it", "s", ...
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Form/EventListener/URLChooserLinkTypeSubscriber.php#L34-L72
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/Repository/EntityVersionLockRepository.php
EntityVersionLockRepository.getLocksForLockableEntity
public function getLocksForLockableEntity(LockableEntity $entity, $threshold, User $userToExclude = null) { $qb = $this->createQueryBuilder('evl') ->select('evl') ->join('evl.lockableEntity', 'le') ->where('le.id = :e') ->andWhere('evl.createdAt > :date') ->setParameter('e', $entity->getId()) ->setParameter('date', new \DateTime(sprintf('-%s seconds', $threshold))) ; if (!is_null($userToExclude)) { $qb->andWhere('evl.owner <> :owner') ->setParameter('owner', $userToExclude->getUsername()) ; } return $qb->getQuery()->getResult(); }
php
public function getLocksForLockableEntity(LockableEntity $entity, $threshold, User $userToExclude = null) { $qb = $this->createQueryBuilder('evl') ->select('evl') ->join('evl.lockableEntity', 'le') ->where('le.id = :e') ->andWhere('evl.createdAt > :date') ->setParameter('e', $entity->getId()) ->setParameter('date', new \DateTime(sprintf('-%s seconds', $threshold))) ; if (!is_null($userToExclude)) { $qb->andWhere('evl.owner <> :owner') ->setParameter('owner', $userToExclude->getUsername()) ; } return $qb->getQuery()->getResult(); }
[ "public", "function", "getLocksForLockableEntity", "(", "LockableEntity", "$", "entity", ",", "$", "threshold", ",", "User", "$", "userToExclude", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'evl'", ")", "->", "selec...
Check if there is a entity lock that's not passed the threshold. @param LockableEntity $entity @param int $threshold @param User $userToExclude @return EntityVersionLock[]
[ "Check", "if", "there", "is", "a", "entity", "lock", "that", "s", "not", "passed", "the", "threshold", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Repository/EntityVersionLockRepository.php#L23-L41
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Security/OAuthAuthenticator.php
OAuthAuthenticator.getUser
public function getUser($credentials, UserProviderInterface $userProvider) { $idToken = $credentials['token']; $gc = new \Google_Client(); $gc->setClientId($this->clientId); $gc->setClientSecret($this->clientSecret); $ticket = $gc->verifyIdToken($idToken); if (!$ticket instanceof \Google_LoginTicket) { return null; } $data = $ticket->getAttributes()['payload']; $email = $data['email']; $googleId = $data['sub']; return $this->oAuthUserCreator->getOrCreateUser($email, $googleId); }
php
public function getUser($credentials, UserProviderInterface $userProvider) { $idToken = $credentials['token']; $gc = new \Google_Client(); $gc->setClientId($this->clientId); $gc->setClientSecret($this->clientSecret); $ticket = $gc->verifyIdToken($idToken); if (!$ticket instanceof \Google_LoginTicket) { return null; } $data = $ticket->getAttributes()['payload']; $email = $data['email']; $googleId = $data['sub']; return $this->oAuthUserCreator->getOrCreateUser($email, $googleId); }
[ "public", "function", "getUser", "(", "$", "credentials", ",", "UserProviderInterface", "$", "userProvider", ")", "{", "$", "idToken", "=", "$", "credentials", "[", "'token'", "]", ";", "$", "gc", "=", "new", "\\", "Google_Client", "(", ")", ";", "$", "g...
Return a UserInterface object based on the credentials. The *credentials* are the return value from getCredentials() You may throw an AuthenticationException if you wish. If you return null, then a UsernameNotFoundException is thrown for you. @param mixed $credentials @param UserProviderInterface $userProvider @throws AuthenticationException @return UserInterface|null
[ "Return", "a", "UserInterface", "object", "based", "on", "the", "credentials", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Security/OAuthAuthenticator.php#L138-L155
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php
NodeTranslationListener.onFlush
public function onFlush(OnFlushEventArgs $args) { try { $em = $args->getEntityManager(); $class = $em->getClassMetadata(NodeTranslation::class); // Collect all nodetranslations that are updated foreach ($em->getUnitOfWork()->getScheduledEntityUpdates() as $entity) { if ($entity instanceof NodeTranslation) { /** @var Node $publicNode */ $publicNode = $entity->getPublicNodeVersion()->getRef($em); // Do nothing for StructureNode objects, skip. if ($publicNode instanceof HasNodeInterface && $publicNode->isStructureNode()) { continue; } $entity = $this->updateUrl($entity, $em); if ($entity !== false) { $em->persist($entity); $em->getUnitOfWork()->recomputeSingleEntityChangeSet($class, $entity); $this->updateNodeChildren($entity, $em, $class); } } } } catch (MappingException $e) { // Different entity manager without this entity configured in namespace chain. Ignore } }
php
public function onFlush(OnFlushEventArgs $args) { try { $em = $args->getEntityManager(); $class = $em->getClassMetadata(NodeTranslation::class); // Collect all nodetranslations that are updated foreach ($em->getUnitOfWork()->getScheduledEntityUpdates() as $entity) { if ($entity instanceof NodeTranslation) { /** @var Node $publicNode */ $publicNode = $entity->getPublicNodeVersion()->getRef($em); // Do nothing for StructureNode objects, skip. if ($publicNode instanceof HasNodeInterface && $publicNode->isStructureNode()) { continue; } $entity = $this->updateUrl($entity, $em); if ($entity !== false) { $em->persist($entity); $em->getUnitOfWork()->recomputeSingleEntityChangeSet($class, $entity); $this->updateNodeChildren($entity, $em, $class); } } } } catch (MappingException $e) { // Different entity manager without this entity configured in namespace chain. Ignore } }
[ "public", "function", "onFlush", "(", "OnFlushEventArgs", "$", "args", ")", "{", "try", "{", "$", "em", "=", "$", "args", "->", "getEntityManager", "(", ")", ";", "$", "class", "=", "$", "em", "->", "getClassMetadata", "(", "NodeTranslation", "::", "clas...
OnFlush doctrine event - updates the nodetranslation urls if needed @param OnFlushEventArgs $args
[ "OnFlush", "doctrine", "event", "-", "updates", "the", "nodetranslation", "urls", "if", "needed" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php#L136-L167
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php
NodeTranslationListener.updateNodeChildren
private function updateNodeChildren(NodeTranslation $node, EntityManagerInterface $em, ClassMetadata $class) { $children = $node->getNode()->getChildren(); if (\count($children) > 0) { /* @var Node $child */ foreach ($children as $child) { $translation = $child->getNodeTranslation($node->getLang(), true); if ($translation) { $translation = $this->updateUrl($translation, $em); if ($translation !== false) { $em->persist($translation); $em->getUnitOfWork()->recomputeSingleEntityChangeSet($class, $translation); $this->updateNodeChildren($translation, $em, $class); } } } } }
php
private function updateNodeChildren(NodeTranslation $node, EntityManagerInterface $em, ClassMetadata $class) { $children = $node->getNode()->getChildren(); if (\count($children) > 0) { /* @var Node $child */ foreach ($children as $child) { $translation = $child->getNodeTranslation($node->getLang(), true); if ($translation) { $translation = $this->updateUrl($translation, $em); if ($translation !== false) { $em->persist($translation); $em->getUnitOfWork()->recomputeSingleEntityChangeSet($class, $translation); $this->updateNodeChildren($translation, $em, $class); } } } } }
[ "private", "function", "updateNodeChildren", "(", "NodeTranslation", "$", "node", ",", "EntityManagerInterface", "$", "em", ",", "ClassMetadata", "$", "class", ")", "{", "$", "children", "=", "$", "node", "->", "getNode", "(", ")", "->", "getChildren", "(", ...
Checks if a nodetranslation has children and update their url @param NodeTranslation $node The node @param EntityManagerInterface $em The entity manager @param ClassMetadata $class The class meta daat
[ "Checks", "if", "a", "nodetranslation", "has", "children", "and", "update", "their", "url" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php#L176-L195
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php
NodeTranslationListener.updateUrl
private function updateUrl(NodeTranslation $nodeTranslation, EntityManagerInterface $em) { $result = $this->ensureUniqueUrl($nodeTranslation, $em); if ($result) { return $nodeTranslation; } $this->logger->info( sprintf('Found NT %s needed NO change', $nodeTranslation->getId()) ); return false; }
php
private function updateUrl(NodeTranslation $nodeTranslation, EntityManagerInterface $em) { $result = $this->ensureUniqueUrl($nodeTranslation, $em); if ($result) { return $nodeTranslation; } $this->logger->info( sprintf('Found NT %s needed NO change', $nodeTranslation->getId()) ); return false; }
[ "private", "function", "updateUrl", "(", "NodeTranslation", "$", "nodeTranslation", ",", "EntityManagerInterface", "$", "em", ")", "{", "$", "result", "=", "$", "this", "->", "ensureUniqueUrl", "(", "$", "nodeTranslation", ",", "$", "em", ")", ";", "if", "("...
Update the url for a nodetranslation @param NodeTranslation $nodeTranslation The node translation @param EntityManagerInterface $em The entity manager @return NodeTranslation|bool returns the node when all is well because it has to be saved
[ "Update", "the", "url", "for", "a", "nodetranslation" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php#L205-L218
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php
NodeTranslationListener.ensureUniqueUrl
private function ensureUniqueUrl(NodeTranslation $translation, EntityManagerInterface $em, array $flashes = []) { // Can't use GetRef here yet since the NodeVersions aren't loaded yet for some reason. $nodeVersion = $translation->getPublicNodeVersion(); $page = $em->getRepository($nodeVersion->getRefEntityName()) ->find($nodeVersion->getRefId()); if (null === $page) { return false; } $isStructureNode = $page->isStructureNode(); // If it's a StructureNode the slug and url should be empty. if ($isStructureNode) { $translation->setSlug(''); $translation->setUrl($translation->getFullSlug()); return true; } /* @var NodeTranslationRepository $nodeTranslationRepository */ $nodeTranslationRepository = $em->getRepository(NodeTranslation::class); if ($translation->getUrl() === $translation->getFullSlug()) { $this->logger->debug( sprintf( 'Evaluating URL for NT %s getUrl: "%s" getFullSlug: "%s"', $translation->getId(), $translation->getUrl(), $translation->getFullSlug() ) ); return false; } // Adjust the URL. $translation->setUrl($translation->getFullSlug()); // Find all translations with this new URL, whose nodes are not deleted. $translations = $nodeTranslationRepository->getAllNodeTranslationsForUrl( $translation->getUrl(), $translation->getLang(), false, $translation, $this->domainConfiguration->getRootNode() ); $this->logger->debug( sprintf( 'Found %s node(s) that math url "%s"', \count($translations), $translation->getUrl() ) ); $translationsWithSameUrl = []; /** @var NodeTranslation $trans */ foreach ($translations as $trans) { if (!$this->pagesConfiguration->isStructureNode($trans->getPublicNodeVersion()->getRefEntityName())) { $translationsWithSameUrl[] = $trans; } } if (\count($translationsWithSameUrl) > 0) { $oldUrl = $translation->getFullSlug(); $translation->setSlug( $this->slugifier->slugify( $this->incrementString($translation->getSlug()) ) ); $newUrl = $translation->getFullSlug(); $message = sprintf( 'The URL of the page has been changed from %s to %s since another page already uses this URL', $oldUrl, $newUrl ); $this->logger->info($message); $flashes[] = $message; $this->ensureUniqueUrl($translation, $em, $flashes); } elseif (\count($flashes) > 0 && $this->isInRequestScope()) { // No translations found so we're certain we can show this message. $flash = current(\array_slice($flashes, -1)); $this->flashBag->add(FlashTypes::WARNING, $flash); } return true; }
php
private function ensureUniqueUrl(NodeTranslation $translation, EntityManagerInterface $em, array $flashes = []) { // Can't use GetRef here yet since the NodeVersions aren't loaded yet for some reason. $nodeVersion = $translation->getPublicNodeVersion(); $page = $em->getRepository($nodeVersion->getRefEntityName()) ->find($nodeVersion->getRefId()); if (null === $page) { return false; } $isStructureNode = $page->isStructureNode(); // If it's a StructureNode the slug and url should be empty. if ($isStructureNode) { $translation->setSlug(''); $translation->setUrl($translation->getFullSlug()); return true; } /* @var NodeTranslationRepository $nodeTranslationRepository */ $nodeTranslationRepository = $em->getRepository(NodeTranslation::class); if ($translation->getUrl() === $translation->getFullSlug()) { $this->logger->debug( sprintf( 'Evaluating URL for NT %s getUrl: "%s" getFullSlug: "%s"', $translation->getId(), $translation->getUrl(), $translation->getFullSlug() ) ); return false; } // Adjust the URL. $translation->setUrl($translation->getFullSlug()); // Find all translations with this new URL, whose nodes are not deleted. $translations = $nodeTranslationRepository->getAllNodeTranslationsForUrl( $translation->getUrl(), $translation->getLang(), false, $translation, $this->domainConfiguration->getRootNode() ); $this->logger->debug( sprintf( 'Found %s node(s) that math url "%s"', \count($translations), $translation->getUrl() ) ); $translationsWithSameUrl = []; /** @var NodeTranslation $trans */ foreach ($translations as $trans) { if (!$this->pagesConfiguration->isStructureNode($trans->getPublicNodeVersion()->getRefEntityName())) { $translationsWithSameUrl[] = $trans; } } if (\count($translationsWithSameUrl) > 0) { $oldUrl = $translation->getFullSlug(); $translation->setSlug( $this->slugifier->slugify( $this->incrementString($translation->getSlug()) ) ); $newUrl = $translation->getFullSlug(); $message = sprintf( 'The URL of the page has been changed from %s to %s since another page already uses this URL', $oldUrl, $newUrl ); $this->logger->info($message); $flashes[] = $message; $this->ensureUniqueUrl($translation, $em, $flashes); } elseif (\count($flashes) > 0 && $this->isInRequestScope()) { // No translations found so we're certain we can show this message. $flash = current(\array_slice($flashes, -1)); $this->flashBag->add(FlashTypes::WARNING, $flash); } return true; }
[ "private", "function", "ensureUniqueUrl", "(", "NodeTranslation", "$", "translation", ",", "EntityManagerInterface", "$", "em", ",", "array", "$", "flashes", "=", "[", "]", ")", "{", "// Can't use GetRef here yet since the NodeVersions aren't loaded yet for some reason.", "...
A function that checks the URL and sees if it's unique. It's allowed to be the same when the node is a StructureNode. When a node is deleted it needs to be ignored in the check. Offline nodes need to be included as well. It sluggifies the slug, updates the URL and checks all existing NodeTranslations ([1]), excluding itself. If a URL existsthat has the same url. If an existing one is found the slug is modified, the URL is updated and the check is repeated until no prior urls exist. NOTE: We need a way to tell if the slug has been modified or not. NOTE: Would be cool if we could increment a number after the slug. Like check if it matches -v# and increment the number. [1] For all languages for now. The issue is that we need a way to know if a node's URL is prepended with the language or not. For now both scenarios are possible so we check for all languages. @param NodeTranslation $translation Reference to the NodeTranslation. This is modified in place. @param EntityManagerInterface $em The entity manager @param array $flashes The flash messages array @return bool
[ "A", "function", "that", "checks", "the", "URL", "and", "sees", "if", "it", "s", "unique", ".", "It", "s", "allowed", "to", "be", "the", "same", "when", "the", "node", "is", "a", "StructureNode", ".", "When", "a", "node", "is", "deleted", "it", "need...
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/EventListener/NodeTranslationListener.php#L247-L338
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SearchBundle/Provider/SearchProviderChain.php
SearchProviderChain.getProvider
public function getProvider($alias) { if (array_key_exists($alias, $this->providers)) { return $this->providers[$alias]; } return null; }
php
public function getProvider($alias) { if (array_key_exists($alias, $this->providers)) { return $this->providers[$alias]; } return null; }
[ "public", "function", "getProvider", "(", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "providers", ")", ")", "{", "return", "$", "this", "->", "providers", "[", "$", "alias", "]", ";", "}", "retur...
Get a SearchProvider based on its alias @param string $alias @return SearchProviderInterface|null
[ "Get", "a", "SearchProvider", "based", "on", "its", "alias" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SearchBundle/Provider/SearchProviderChain.php#L36-L43
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Translator/CacheValidator.php
CacheValidator.isCacheFresh
public function isCacheFresh() { $fileDate = $this->getOldestCachefileDate(); $stashDate = $this->getLastTranslationChangeDate(); if ($fileDate === null) { return true; } return $fileDate >= $stashDate; }
php
public function isCacheFresh() { $fileDate = $this->getOldestCachefileDate(); $stashDate = $this->getLastTranslationChangeDate(); if ($fileDate === null) { return true; } return $fileDate >= $stashDate; }
[ "public", "function", "isCacheFresh", "(", ")", "{", "$", "fileDate", "=", "$", "this", "->", "getOldestCachefileDate", "(", ")", ";", "$", "stashDate", "=", "$", "this", "->", "getLastTranslationChangeDate", "(", ")", ";", "if", "(", "$", "fileDate", "===...
Checks the caching files of they are even with the stasher content @return bool
[ "Checks", "the", "caching", "files", "of", "they", "are", "even", "with", "the", "stasher", "content" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Translator/CacheValidator.php#L26-L36
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Translator/CacheValidator.php
CacheValidator.getOldestCachefileDate
public function getOldestCachefileDate() { if (!is_dir($this->cacheDir)) { return null; } $finder = new Finder(); $finder->files() ->name('catalogue*.php') ->sortByModifiedTime() ->in($this->cacheDir); foreach ($finder as $file) { $date = new \DateTime(); $date->setTimestamp($file->getMTime()); return $date; } return null; }
php
public function getOldestCachefileDate() { if (!is_dir($this->cacheDir)) { return null; } $finder = new Finder(); $finder->files() ->name('catalogue*.php') ->sortByModifiedTime() ->in($this->cacheDir); foreach ($finder as $file) { $date = new \DateTime(); $date->setTimestamp($file->getMTime()); return $date; } return null; }
[ "public", "function", "getOldestCachefileDate", "(", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "cacheDir", ")", ")", "{", "return", "null", ";", "}", "$", "finder", "=", "new", "Finder", "(", ")", ";", "$", "finder", "->", "files", ...
Retrieve a Datetime of the oldest cache file made @return DateTime mtime of oldest cache file
[ "Retrieve", "a", "Datetime", "of", "the", "oldest", "cache", "file", "made" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Translator/CacheValidator.php#L53-L73
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.createIndex
public function createIndex() { //create analysis $analysis = $this->container->get( 'kunstmaan_search.search.factory.analysis' ); foreach ($this->locales as $locale) { // Multilanguage check if (preg_match('/[a-z]{2}_?+[a-zA-Z]{2}/', $locale)) { $locale = strtolower($locale); } // Build new index $index = $this->searchProvider->createIndex($this->indexName . '_' . $locale); if (array_key_exists($locale, $this->analyzerLanguages)) { $localeAnalysis = clone $analysis; $language = $this->analyzerLanguages[$locale]['analyzer']; // Create index with analysis $this->setAnalysis($index, $localeAnalysis->setupLanguage($language)); } else { $index->create(); } $this->setMapping($index, $locale); } }
php
public function createIndex() { //create analysis $analysis = $this->container->get( 'kunstmaan_search.search.factory.analysis' ); foreach ($this->locales as $locale) { // Multilanguage check if (preg_match('/[a-z]{2}_?+[a-zA-Z]{2}/', $locale)) { $locale = strtolower($locale); } // Build new index $index = $this->searchProvider->createIndex($this->indexName . '_' . $locale); if (array_key_exists($locale, $this->analyzerLanguages)) { $localeAnalysis = clone $analysis; $language = $this->analyzerLanguages[$locale]['analyzer']; // Create index with analysis $this->setAnalysis($index, $localeAnalysis->setupLanguage($language)); } else { $index->create(); } $this->setMapping($index, $locale); } }
[ "public", "function", "createIndex", "(", ")", "{", "//create analysis", "$", "analysis", "=", "$", "this", "->", "container", "->", "get", "(", "'kunstmaan_search.search.factory.analysis'", ")", ";", "foreach", "(", "$", "this", "->", "locales", "as", "$", "l...
Create node index
[ "Create", "node", "index" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L163-L191
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.populateIndex
public function populateIndex() { $nodeRepository = $this->em->getRepository('KunstmaanNodeBundle:Node'); $nodes = $nodeRepository->getAllTopNodes(); foreach ($nodes as $node) { $this->currentTopNode = $node; foreach ($this->locales as $lang) { $this->createNodeDocuments($node, $lang); } } if (!empty($this->documents)) { $this->searchProvider->addDocuments($this->documents); $this->documents = []; } }
php
public function populateIndex() { $nodeRepository = $this->em->getRepository('KunstmaanNodeBundle:Node'); $nodes = $nodeRepository->getAllTopNodes(); foreach ($nodes as $node) { $this->currentTopNode = $node; foreach ($this->locales as $lang) { $this->createNodeDocuments($node, $lang); } } if (!empty($this->documents)) { $this->searchProvider->addDocuments($this->documents); $this->documents = []; } }
[ "public", "function", "populateIndex", "(", ")", "{", "$", "nodeRepository", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanNodeBundle:Node'", ")", ";", "$", "nodes", "=", "$", "nodeRepository", "->", "getAllTopNodes", "(", ")", ";", "f...
Populate node index
[ "Populate", "node", "index" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L196-L212
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.indexNodeTranslation
public function indexNodeTranslation(NodeTranslation $nodeTranslation, $add = false) { // Retrieve the public NodeVersion $publicNodeVersion = $nodeTranslation->getPublicNodeVersion(); if (is_null($publicNodeVersion)) { return false; } $refPage = $this->getNodeRefPage($publicNodeVersion); if ($refPage->isStructureNode()) { return true; } // Only index online NodeTranslations if (!$nodeTranslation->isOnline()) { return false; } $node = $nodeTranslation->getNode(); if ($this->isIndexable($refPage)) { // Retrieve the referenced entity from the public NodeVersion $page = $publicNodeVersion->getRef($this->em); $this->addPageToIndex($nodeTranslation, $node, $publicNodeVersion, $page); if ($add) { $this->searchProvider->addDocuments($this->documents); $this->documents = []; } } return true; // return true even if the page itself should not be indexed. This makes sure its children are being processed (i.e. structured nodes) }
php
public function indexNodeTranslation(NodeTranslation $nodeTranslation, $add = false) { // Retrieve the public NodeVersion $publicNodeVersion = $nodeTranslation->getPublicNodeVersion(); if (is_null($publicNodeVersion)) { return false; } $refPage = $this->getNodeRefPage($publicNodeVersion); if ($refPage->isStructureNode()) { return true; } // Only index online NodeTranslations if (!$nodeTranslation->isOnline()) { return false; } $node = $nodeTranslation->getNode(); if ($this->isIndexable($refPage)) { // Retrieve the referenced entity from the public NodeVersion $page = $publicNodeVersion->getRef($this->em); $this->addPageToIndex($nodeTranslation, $node, $publicNodeVersion, $page); if ($add) { $this->searchProvider->addDocuments($this->documents); $this->documents = []; } } return true; // return true even if the page itself should not be indexed. This makes sure its children are being processed (i.e. structured nodes) }
[ "public", "function", "indexNodeTranslation", "(", "NodeTranslation", "$", "nodeTranslation", ",", "$", "add", "=", "false", ")", "{", "// Retrieve the public NodeVersion", "$", "publicNodeVersion", "=", "$", "nodeTranslation", "->", "getPublicNodeVersion", "(", ")", ...
Index a node translation @param NodeTranslation $nodeTranslation @param bool $add Add node immediately to index? @return bool Return true if the document has been indexed
[ "Index", "a", "node", "translation" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L268-L299
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.deleteNodeTranslation
public function deleteNodeTranslation(NodeTranslation $nodeTranslation) { $uid = 'nodetranslation_' . $nodeTranslation->getId(); $indexName = $this->indexName . '_' . $nodeTranslation->getLang(); $this->searchProvider->deleteDocument($indexName, $this->indexType, $uid); }
php
public function deleteNodeTranslation(NodeTranslation $nodeTranslation) { $uid = 'nodetranslation_' . $nodeTranslation->getId(); $indexName = $this->indexName . '_' . $nodeTranslation->getLang(); $this->searchProvider->deleteDocument($indexName, $this->indexType, $uid); }
[ "public", "function", "deleteNodeTranslation", "(", "NodeTranslation", "$", "nodeTranslation", ")", "{", "$", "uid", "=", "'nodetranslation_'", ".", "$", "nodeTranslation", "->", "getId", "(", ")", ";", "$", "indexName", "=", "$", "this", "->", "indexName", "....
Remove the specified node translation from the index @param NodeTranslation $nodeTranslation
[ "Remove", "the", "specified", "node", "translation", "from", "the", "index" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L320-L325
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.deleteIndex
public function deleteIndex() { foreach ($this->locales as $locale) { $this->searchProvider->deleteIndex($this->indexName . '_' . $locale); } }
php
public function deleteIndex() { foreach ($this->locales as $locale) { $this->searchProvider->deleteIndex($this->indexName . '_' . $locale); } }
[ "public", "function", "deleteIndex", "(", ")", "{", "foreach", "(", "$", "this", "->", "locales", "as", "$", "locale", ")", "{", "$", "this", "->", "searchProvider", "->", "deleteIndex", "(", "$", "this", "->", "indexName", ".", "'_'", ".", "$", "local...
Delete the specified index
[ "Delete", "the", "specified", "index" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L330-L335
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.setAnalysis
public function setAnalysis(Index $index, AnalysisFactoryInterface $analysis) { $index->create( array( 'number_of_shards' => $this->numberOfShards, 'number_of_replicas' => $this->numberOfReplicas, 'analysis' => $analysis->build(), ) ); }
php
public function setAnalysis(Index $index, AnalysisFactoryInterface $analysis) { $index->create( array( 'number_of_shards' => $this->numberOfShards, 'number_of_replicas' => $this->numberOfReplicas, 'analysis' => $analysis->build(), ) ); }
[ "public", "function", "setAnalysis", "(", "Index", "$", "index", ",", "AnalysisFactoryInterface", "$", "analysis", ")", "{", "$", "index", "->", "create", "(", "array", "(", "'number_of_shards'", "=>", "$", "this", "->", "numberOfShards", ",", "'number_of_replic...
Apply the analysis factory to the index @param Index $index @param AnalysisFactoryInterface $analysis
[ "Apply", "the", "analysis", "factory", "to", "the", "index" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L343-L352
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.createDefaultSearchFieldsMapping
protected function createDefaultSearchFieldsMapping(Index $index, $lang = 'en') { $mapping = new Mapping(); $mapping->setType($index->getType($this->indexType)); $mapping->setProperties($this->properties); return $mapping; }
php
protected function createDefaultSearchFieldsMapping(Index $index, $lang = 'en') { $mapping = new Mapping(); $mapping->setType($index->getType($this->indexType)); $mapping->setProperties($this->properties); return $mapping; }
[ "protected", "function", "createDefaultSearchFieldsMapping", "(", "Index", "$", "index", ",", "$", "lang", "=", "'en'", ")", "{", "$", "mapping", "=", "new", "Mapping", "(", ")", ";", "$", "mapping", "->", "setType", "(", "$", "index", "->", "getType", "...
Return default search fields mapping for node translations @param Index $index @param string $lang @return Mapping
[ "Return", "default", "search", "fields", "mapping", "for", "node", "translations" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L362-L370
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.setMapping
protected function setMapping(Index $index, $lang = 'en') { $mapping = $this->createDefaultSearchFieldsMapping($index, $lang); $mapping->send(); $index->refresh(); }
php
protected function setMapping(Index $index, $lang = 'en') { $mapping = $this->createDefaultSearchFieldsMapping($index, $lang); $mapping->send(); $index->refresh(); }
[ "protected", "function", "setMapping", "(", "Index", "$", "index", ",", "$", "lang", "=", "'en'", ")", "{", "$", "mapping", "=", "$", "this", "->", "createDefaultSearchFieldsMapping", "(", "$", "index", ",", "$", "lang", ")", ";", "$", "mapping", "->", ...
Initialize the index with the default search fields mapping @param Index $index @param string $lang
[ "Initialize", "the", "index", "with", "the", "default", "search", "fields", "mapping" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L378-L383
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.addPageToIndex
protected function addPageToIndex( NodeTranslation $nodeTranslation, Node $node, NodeVersion $publicNodeVersion, HasNodeInterface $page ) { $rootNode = $this->currentTopNode; if (!$rootNode) { // Fetch main parent of current node... $rootNode = $this->em->getRepository('KunstmaanNodeBundle:Node')->getRootNodeFor( $node, $nodeTranslation->getLang() ); } $doc = array( 'root_id' => $rootNode->getId(), 'node_id' => $node->getId(), 'node_translation_id' => $nodeTranslation->getId(), 'node_version_id' => $publicNodeVersion->getId(), 'title' => $nodeTranslation->getTitle(), 'slug' => $nodeTranslation->getFullSlug(), 'page_class' => ClassLookup::getClass($page), 'created' => $this->getUTCDateTime( $nodeTranslation->getCreated() )->format(\DateTime::ISO8601), 'updated' => $this->getUTCDateTime( $nodeTranslation->getUpdated() )->format(\DateTime::ISO8601), ); if ($this->logger) { $this->logger->info('Indexing document : ' . implode(', ', $doc)); } // Permissions $this->addPermissions($node, $doc); // Search type $this->addSearchType($page, $doc); // Parent and Ancestors $this->addParentAndAncestors($node, $doc); // Content $this->addPageContent($nodeTranslation, $page, $doc); // Add document to index $uid = 'nodetranslation_' . $nodeTranslation->getId(); $this->addCustomData($page, $doc); $this->documents[] = $this->searchProvider->createDocument( $uid, $doc, $this->indexName . '_' . $nodeTranslation->getLang(), $this->indexType ); }
php
protected function addPageToIndex( NodeTranslation $nodeTranslation, Node $node, NodeVersion $publicNodeVersion, HasNodeInterface $page ) { $rootNode = $this->currentTopNode; if (!$rootNode) { // Fetch main parent of current node... $rootNode = $this->em->getRepository('KunstmaanNodeBundle:Node')->getRootNodeFor( $node, $nodeTranslation->getLang() ); } $doc = array( 'root_id' => $rootNode->getId(), 'node_id' => $node->getId(), 'node_translation_id' => $nodeTranslation->getId(), 'node_version_id' => $publicNodeVersion->getId(), 'title' => $nodeTranslation->getTitle(), 'slug' => $nodeTranslation->getFullSlug(), 'page_class' => ClassLookup::getClass($page), 'created' => $this->getUTCDateTime( $nodeTranslation->getCreated() )->format(\DateTime::ISO8601), 'updated' => $this->getUTCDateTime( $nodeTranslation->getUpdated() )->format(\DateTime::ISO8601), ); if ($this->logger) { $this->logger->info('Indexing document : ' . implode(', ', $doc)); } // Permissions $this->addPermissions($node, $doc); // Search type $this->addSearchType($page, $doc); // Parent and Ancestors $this->addParentAndAncestors($node, $doc); // Content $this->addPageContent($nodeTranslation, $page, $doc); // Add document to index $uid = 'nodetranslation_' . $nodeTranslation->getId(); $this->addCustomData($page, $doc); $this->documents[] = $this->searchProvider->createDocument( $uid, $doc, $this->indexName . '_' . $nodeTranslation->getLang(), $this->indexType ); }
[ "protected", "function", "addPageToIndex", "(", "NodeTranslation", "$", "nodeTranslation", ",", "Node", "$", "node", ",", "NodeVersion", "$", "publicNodeVersion", ",", "HasNodeInterface", "$", "page", ")", "{", "$", "rootNode", "=", "$", "this", "->", "currentTo...
Create a search document for a page @param NodeTranslation $nodeTranslation @param Node $node @param NodeVersion $publicNodeVersion @param HasNodeInterface $page
[ "Create", "a", "search", "document", "for", "a", "page" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L393-L450
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.addPermissions
protected function addPermissions(Node $node, &$doc) { if (!is_null($this->aclProvider)) { $roles = $this->getAclPermissions($node); } else { // Fallback when no ACL available / assume everything is accessible... $roles = array('IS_AUTHENTICATED_ANONYMOUSLY'); } $doc['view_roles'] = $roles; }
php
protected function addPermissions(Node $node, &$doc) { if (!is_null($this->aclProvider)) { $roles = $this->getAclPermissions($node); } else { // Fallback when no ACL available / assume everything is accessible... $roles = array('IS_AUTHENTICATED_ANONYMOUSLY'); } $doc['view_roles'] = $roles; }
[ "protected", "function", "addPermissions", "(", "Node", "$", "node", ",", "&", "$", "doc", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "aclProvider", ")", ")", "{", "$", "roles", "=", "$", "this", "->", "getAclPermissions", "(", "$",...
Add view permissions to the index document @param Node $node @param array $doc @return array
[ "Add", "view", "permissions", "to", "the", "index", "document" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L460-L469
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.addParentAndAncestors
protected function addParentAndAncestors($node, &$doc) { $parent = $node->getParent(); if ($parent) { $doc['parent'] = $parent->getId(); $ancestors = []; do { $ancestors[] = $parent->getId(); $parent = $parent->getParent(); } while ($parent); $doc['ancestors'] = $ancestors; } }
php
protected function addParentAndAncestors($node, &$doc) { $parent = $node->getParent(); if ($parent) { $doc['parent'] = $parent->getId(); $ancestors = []; do { $ancestors[] = $parent->getId(); $parent = $parent->getParent(); } while ($parent); $doc['ancestors'] = $ancestors; } }
[ "protected", "function", "addParentAndAncestors", "(", "$", "node", ",", "&", "$", "doc", ")", "{", "$", "parent", "=", "$", "node", "->", "getParent", "(", ")", ";", "if", "(", "$", "parent", ")", "{", "$", "doc", "[", "'parent'", "]", "=", "$", ...
Add parent nodes to the index document @param Node $node @param array $doc @return array
[ "Add", "parent", "nodes", "to", "the", "index", "document" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L492-L505
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.addPageContent
protected function addPageContent(NodeTranslation $nodeTranslation, $page, &$doc) { $this->enterRequestScope($nodeTranslation->getLang()); if ($this->logger) { $this->logger->debug( sprintf( 'Indexing page "%s" / lang : %s / type : %s / id : %d / node id : %d', $page->getTitle(), $nodeTranslation->getLang(), get_class($page), $page->getId(), $nodeTranslation->getNode()->getId() ) ); } $renderer = $this->container->get('templating'); $doc['content'] = ''; if ($page instanceof SearchViewTemplateInterface) { $doc['content'] = $this->renderCustomSearchView($nodeTranslation, $page, $renderer); return null; } if ($page instanceof HasPagePartsInterface) { $doc['content'] = $this->renderDefaultSearchView($nodeTranslation, $page, $renderer); return null; } }
php
protected function addPageContent(NodeTranslation $nodeTranslation, $page, &$doc) { $this->enterRequestScope($nodeTranslation->getLang()); if ($this->logger) { $this->logger->debug( sprintf( 'Indexing page "%s" / lang : %s / type : %s / id : %d / node id : %d', $page->getTitle(), $nodeTranslation->getLang(), get_class($page), $page->getId(), $nodeTranslation->getNode()->getId() ) ); } $renderer = $this->container->get('templating'); $doc['content'] = ''; if ($page instanceof SearchViewTemplateInterface) { $doc['content'] = $this->renderCustomSearchView($nodeTranslation, $page, $renderer); return null; } if ($page instanceof HasPagePartsInterface) { $doc['content'] = $this->renderDefaultSearchView($nodeTranslation, $page, $renderer); return null; } }
[ "protected", "function", "addPageContent", "(", "NodeTranslation", "$", "nodeTranslation", ",", "$", "page", ",", "&", "$", "doc", ")", "{", "$", "this", "->", "enterRequestScope", "(", "$", "nodeTranslation", "->", "getLang", "(", ")", ")", ";", "if", "("...
Add page content to the index document @param NodeTranslation $nodeTranslation @param HasNodeInterface $page @param array $doc
[ "Add", "page", "content", "to", "the", "index", "document" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L514-L544
train