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/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.enterRequestScope
protected function enterRequestScope($lang) { $requestStack = $this->container->get('request_stack'); // If there already is a request, get the locale from it. if ($requestStack->getCurrentRequest()) { $locale = $requestStack->getCurrentRequest()->getLocale(); } // If we don't have a request or the current request locale is different from the node langauge if (!$requestStack->getCurrentRequest() || ($locale && $locale !== $lang)) { $request = new Request(); $request->setLocale($lang); $context = $this->container->get('router')->getContext(); $context->setParameter('_locale', $lang); $requestStack->push($request); } }
php
protected function enterRequestScope($lang) { $requestStack = $this->container->get('request_stack'); // If there already is a request, get the locale from it. if ($requestStack->getCurrentRequest()) { $locale = $requestStack->getCurrentRequest()->getLocale(); } // If we don't have a request or the current request locale is different from the node langauge if (!$requestStack->getCurrentRequest() || ($locale && $locale !== $lang)) { $request = new Request(); $request->setLocale($lang); $context = $this->container->get('router')->getContext(); $context->setParameter('_locale', $lang); $requestStack->push($request); } }
[ "protected", "function", "enterRequestScope", "(", "$", "lang", ")", "{", "$", "requestStack", "=", "$", "this", "->", "container", "->", "get", "(", "'request_stack'", ")", ";", "// If there already is a request, get the locale from it.", "if", "(", "$", "requestSt...
Enter request scope if it is not active yet... @param string $lang
[ "Enter", "request", "scope", "if", "it", "is", "not", "active", "yet", "..." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L551-L568
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.renderCustomSearchView
protected function renderCustomSearchView( NodeTranslation $nodeTranslation, SearchViewTemplateInterface $page, EngineInterface $renderer ) { $view = $page->getSearchView(); $renderContext = new RenderContext([ 'locale' => $nodeTranslation->getLang(), 'page' => $page, 'indexMode' => true, 'nodetranslation' => $nodeTranslation, ]); if ($page instanceof PageInterface) { $request = $this->container->get('request_stack')->getCurrentRequest(); $page->service($this->container, $request, $renderContext); } $content = $this->removeHtml( $renderer->render( $view, $renderContext->getArrayCopy() ) ); return $content; }
php
protected function renderCustomSearchView( NodeTranslation $nodeTranslation, SearchViewTemplateInterface $page, EngineInterface $renderer ) { $view = $page->getSearchView(); $renderContext = new RenderContext([ 'locale' => $nodeTranslation->getLang(), 'page' => $page, 'indexMode' => true, 'nodetranslation' => $nodeTranslation, ]); if ($page instanceof PageInterface) { $request = $this->container->get('request_stack')->getCurrentRequest(); $page->service($this->container, $request, $renderContext); } $content = $this->removeHtml( $renderer->render( $view, $renderContext->getArrayCopy() ) ); return $content; }
[ "protected", "function", "renderCustomSearchView", "(", "NodeTranslation", "$", "nodeTranslation", ",", "SearchViewTemplateInterface", "$", "page", ",", "EngineInterface", "$", "renderer", ")", "{", "$", "view", "=", "$", "page", "->", "getSearchView", "(", ")", "...
Render a custom search view @param NodeTranslation $nodeTranslation @param SearchViewTemplateInterface $page @param EngineInterface $renderer @return string
[ "Render", "a", "custom", "search", "view" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L579-L605
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php
NodePagesConfiguration.getAclPermissions
protected function getAclPermissions($object) { $roles = []; try { $objectIdentity = ObjectIdentity::fromDomainObject($object); /* @var AclInterface $acl */ $acl = $this->aclProvider->findAcl($objectIdentity); $objectAces = $acl->getObjectAces(); /* @var AuditableEntryInterface $ace */ foreach ($objectAces as $ace) { $securityIdentity = $ace->getSecurityIdentity(); if ( $securityIdentity instanceof RoleSecurityIdentity && ($ace->getMask() & MaskBuilder::MASK_VIEW != 0) ) { $roles[] = $securityIdentity->getRole(); } } } catch (AclNotFoundException $e) { // No ACL found... assume default $roles = array('IS_AUTHENTICATED_ANONYMOUSLY'); } return $roles; }
php
protected function getAclPermissions($object) { $roles = []; try { $objectIdentity = ObjectIdentity::fromDomainObject($object); /* @var AclInterface $acl */ $acl = $this->aclProvider->findAcl($objectIdentity); $objectAces = $acl->getObjectAces(); /* @var AuditableEntryInterface $ace */ foreach ($objectAces as $ace) { $securityIdentity = $ace->getSecurityIdentity(); if ( $securityIdentity instanceof RoleSecurityIdentity && ($ace->getMask() & MaskBuilder::MASK_VIEW != 0) ) { $roles[] = $securityIdentity->getRole(); } } } catch (AclNotFoundException $e) { // No ACL found... assume default $roles = array('IS_AUTHENTICATED_ANONYMOUSLY'); } return $roles; }
[ "protected", "function", "getAclPermissions", "(", "$", "object", ")", "{", "$", "roles", "=", "[", "]", ";", "try", "{", "$", "objectIdentity", "=", "ObjectIdentity", "::", "fromDomainObject", "(", "$", "object", ")", ";", "/* @var AclInterface $acl */", "$",...
Fetch ACL permissions for the specified entity @param object $object @return array
[ "Fetch", "ACL", "permissions", "for", "the", "specified", "entity" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Configuration/NodePagesConfiguration.php#L711-L738
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/defaultsite/Controller/BikeAdminListController.php
BikeAdminListController.moveUpAction
public function moveUpAction(Request $request, $id) { return parent::doMoveUpAction($this->getAdminListConfigurator(), $id, $request); }
php
public function moveUpAction(Request $request, $id) { return parent::doMoveUpAction($this->getAdminListConfigurator(), $id, $request); }
[ "public", "function", "moveUpAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "return", "parent", "::", "doMoveUpAction", "(", "$", "this", "->", "getAdminListConfigurator", "(", ")", ",", "$", "id", ",", "$", "request", ")", ";", "}" ]
The move up action @param int $id @Route("/{id}/move-up", requirements={"id" = "\d+"}, name="{{ bundle_name|lower }}_admin_bike_move_up", methods={"GET"}) @return array
[ "The", "move", "up", "action" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/defaultsite/Controller/BikeAdminListController.php#L105-L108
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/defaultsite/Controller/BikeAdminListController.php
BikeAdminListController.moveDownAction
public function moveDownAction(Request $request, $id) { return parent::doMoveDownAction($this->getAdminListConfigurator(), $id, $request); }
php
public function moveDownAction(Request $request, $id) { return parent::doMoveDownAction($this->getAdminListConfigurator(), $id, $request); }
[ "public", "function", "moveDownAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "return", "parent", "::", "doMoveDownAction", "(", "$", "this", "->", "getAdminListConfigurator", "(", ")", ",", "$", "id", ",", "$", "request", ")", ";", "...
The move down action @param int $id @Route("/{id}/move-down", requirements={"id" = "\d+"}, name="{{ bundle_name|lower }}_admin_bike_move_down", methods={"GET"}) @return array
[ "The", "move", "down", "action" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/defaultsite/Controller/BikeAdminListController.php#L119-L122
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Twig/NodeTwigExtension.php
NodeTwigExtension.getNodeTranslationByNodeId
public function getNodeTranslationByNodeId($nodeId, $lang) { $repo = $this->em->getRepository('KunstmaanNodeBundle:NodeTranslation'); return $repo->getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang); }
php
public function getNodeTranslationByNodeId($nodeId, $lang) { $repo = $this->em->getRepository('KunstmaanNodeBundle:NodeTranslation'); return $repo->getNodeTranslationByNodeIdQueryBuilder($nodeId, $lang); }
[ "public", "function", "getNodeTranslationByNodeId", "(", "$", "nodeId", ",", "$", "lang", ")", "{", "$", "repo", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanNodeBundle:NodeTranslation'", ")", ";", "return", "$", "repo", "->", "getNodeT...
Get the node translation object based on node id and language. @param int $nodeId @param string $lang @return NodeTranslation
[ "Get", "the", "node", "translation", "object", "based", "on", "node", "id", "and", "language", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Twig/NodeTwigExtension.php#L121-L126
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php
VersionChecker.periodicallyCheck
public function periodicallyCheck() { if (!$this->isEnabled()) { return; } $data = $this->cache->fetch('version_check'); if (!is_array($data)) { $this->check(); } }
php
public function periodicallyCheck() { if (!$this->isEnabled()) { return; } $data = $this->cache->fetch('version_check'); if (!is_array($data)) { $this->check(); } }
[ "public", "function", "periodicallyCheck", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "data", "=", "$", "this", "->", "cache", "->", "fetch", "(", "'version_check'", ")", ";", "if", "...
Check if we recently did a version check, if not do one now. @throws ParseException
[ "Check", "if", "we", "recently", "did", "a", "version", "check", "if", "not", "do", "one", "now", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php#L77-L87
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php
VersionChecker.check
public function check() { if (!$this->isEnabled()) { return; } $host = $this->container->get('request_stack')->getCurrentRequest()->getHttpHost(); $console = realpath($this->container->get('kernel')->getProjectDir().'/bin/console'); $installed = filectime($console); $bundles = $this->parseComposer(); $title = $this->container->getParameter('kunstmaan_admin.website_title'); $jsonData = json_encode(array( 'host' => $host, 'installed' => $installed, 'bundles' => $bundles, 'project' => $title, )); try { $client = $this->getClient(); $response = $client->post($this->webserviceUrl, ['body' => $jsonData]); $contents = $response->getBody()->getContents(); $data = json_decode($contents); if (null === $data) { return false; } // Save the result in the cache to make sure we don't do the check too often $this->cache->save('version_check', $data, $this->cacheTimeframe); return $data; } catch (Exception $e) { // We did not receive valid json return false; } }
php
public function check() { if (!$this->isEnabled()) { return; } $host = $this->container->get('request_stack')->getCurrentRequest()->getHttpHost(); $console = realpath($this->container->get('kernel')->getProjectDir().'/bin/console'); $installed = filectime($console); $bundles = $this->parseComposer(); $title = $this->container->getParameter('kunstmaan_admin.website_title'); $jsonData = json_encode(array( 'host' => $host, 'installed' => $installed, 'bundles' => $bundles, 'project' => $title, )); try { $client = $this->getClient(); $response = $client->post($this->webserviceUrl, ['body' => $jsonData]); $contents = $response->getBody()->getContents(); $data = json_decode($contents); if (null === $data) { return false; } // Save the result in the cache to make sure we don't do the check too often $this->cache->save('version_check', $data, $this->cacheTimeframe); return $data; } catch (Exception $e) { // We did not receive valid json return false; } }
[ "public", "function", "check", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "host", "=", "$", "this", "->", "container", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest...
Get the version details via webservice. @return mixed a list of bundles if available @throws ParseException
[ "Get", "the", "version", "details", "via", "webservice", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php#L96-L133
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php
VersionChecker.getPackages
protected function getPackages() { $translator = $this->container->get('translator'); $errorMessage = $translator->trans('settings.version.error_parsing_composer'); $composerPath = $this->getLockPath(); if (!file_exists($composerPath)) { throw new ParseException( $translator->trans('settings.version.composer_lock_not_found') ); } $json = file_get_contents($composerPath); $result = json_decode($json, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new ParseException($errorMessage.' (#'.json_last_error().')'); } if (array_key_exists('packages', $result) && is_array($result['packages'])) { return $result['packages']; } // No package list in JSON structure throw new ParseException($errorMessage); }
php
protected function getPackages() { $translator = $this->container->get('translator'); $errorMessage = $translator->trans('settings.version.error_parsing_composer'); $composerPath = $this->getLockPath(); if (!file_exists($composerPath)) { throw new ParseException( $translator->trans('settings.version.composer_lock_not_found') ); } $json = file_get_contents($composerPath); $result = json_decode($json, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new ParseException($errorMessage.' (#'.json_last_error().')'); } if (array_key_exists('packages', $result) && is_array($result['packages'])) { return $result['packages']; } // No package list in JSON structure throw new ParseException($errorMessage); }
[ "protected", "function", "getPackages", "(", ")", "{", "$", "translator", "=", "$", "this", "->", "container", "->", "get", "(", "'translator'", ")", ";", "$", "errorMessage", "=", "$", "translator", "->", "trans", "(", "'settings.version.error_parsing_composer'...
Returns a list of composer packages. @return array @throws ParseException
[ "Returns", "a", "list", "of", "composer", "packages", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php#L175-L200
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php
VersionChecker.parseComposer
protected function parseComposer() { $bundles = array(); foreach ($this->getPackages() as $package) { if (!strncmp($package['name'], 'kunstmaan/', strlen('kunstmaan/'))) { $bundles[] = array( 'name' => $package['name'], 'version' => $package['version'], 'reference' => $package['source']['reference'], ); } } return $bundles; }
php
protected function parseComposer() { $bundles = array(); foreach ($this->getPackages() as $package) { if (!strncmp($package['name'], 'kunstmaan/', strlen('kunstmaan/'))) { $bundles[] = array( 'name' => $package['name'], 'version' => $package['version'], 'reference' => $package['source']['reference'], ); } } return $bundles; }
[ "protected", "function", "parseComposer", "(", ")", "{", "$", "bundles", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getPackages", "(", ")", "as", "$", "package", ")", "{", "if", "(", "!", "strncmp", "(", "$", "package", "[", "...
Parse the composer.lock file to get the currently used versions of the kunstmaan bundles. @return array @throws ParseException
[ "Parse", "the", "composer", ".", "lock", "file", "to", "get", "the", "currently", "used", "versions", "of", "the", "kunstmaan", "bundles", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/VersionCheck/VersionChecker.php#L209-L223
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Helper/OrderPreparer.php
OrderPreparer.prepare
public function prepare(Order $order) { /** @var $orderItems OrderItem[] */ $orderItems = $order->orderItems; /** @var $newOrderItems OrderItem[] */ $newOrderItems = array(); foreach ($orderItems as $item) { if (!isset($newOrderItems[$item->getSKU()])) { $newOrderItems[$item->getSKU()] = $item; } else { $newOrderItems[$item->getSKU()]->setQuantity($newOrderItems[$item->getSKU()]->getQuantity() + $item->getQuantity()); $newOrderItems[$item->getSKU()]->setTaxes($newOrderItems[$item->getSKU()]->getTaxes() + $item->getTaxes()); } } $order->orderItems = $newOrderItems; return $order; }
php
public function prepare(Order $order) { /** @var $orderItems OrderItem[] */ $orderItems = $order->orderItems; /** @var $newOrderItems OrderItem[] */ $newOrderItems = array(); foreach ($orderItems as $item) { if (!isset($newOrderItems[$item->getSKU()])) { $newOrderItems[$item->getSKU()] = $item; } else { $newOrderItems[$item->getSKU()]->setQuantity($newOrderItems[$item->getSKU()]->getQuantity() + $item->getQuantity()); $newOrderItems[$item->getSKU()]->setTaxes($newOrderItems[$item->getSKU()]->getTaxes() + $item->getTaxes()); } } $order->orderItems = $newOrderItems; return $order; }
[ "public", "function", "prepare", "(", "Order", "$", "order", ")", "{", "/** @var $orderItems OrderItem[] */", "$", "orderItems", "=", "$", "order", "->", "orderItems", ";", "/** @var $newOrderItems OrderItem[] */", "$", "newOrderItems", "=", "array", "(", ")", ";", ...
Fully prepares an order for conversion. What it does for now is deduplicate the OrderItems. Ensure every orderItem has a unique SKU. Only one request is made per order/SKU. So the same SKUs on multiple lines need to be grouped. @param Order $order @return Order
[ "Fully", "prepares", "an", "order", "for", "conversion", ".", "What", "it", "does", "for", "now", "is", "deduplicate", "the", "OrderItems", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Helper/OrderPreparer.php#L24-L44
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Entity/BaseUser.php
BaseUser.getGroupIds
public function getGroupIds() { $groups = $this->groups; $groupIds = array(); if (count($groups) > 0) { /* @var $group GroupInterface */ foreach ($groups as $group) { $groupIds[] = $group->getId(); } } return $groupIds; }
php
public function getGroupIds() { $groups = $this->groups; $groupIds = array(); if (count($groups) > 0) { /* @var $group GroupInterface */ foreach ($groups as $group) { $groupIds[] = $group->getId(); } } return $groupIds; }
[ "public", "function", "getGroupIds", "(", ")", "{", "$", "groups", "=", "$", "this", "->", "groups", ";", "$", "groupIds", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "groups", ")", ">", "0", ")", "{", "/* @var $group GroupInterface */",...
Gets the groupIds for the user. @return array
[ "Gets", "the", "groupIds", "for", "the", "user", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Entity/BaseUser.php#L82-L95
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/ConfigGenerator.php
ConfigGenerator.generate
public function generate(string $projectDir, bool $overwriteSecurity, bool $overwriteLiipImagine, bool $overwriteFosHttpCache, bool $overwriteFosUser) { $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/', 'security.yaml', [], true, $overwriteSecurity ? 'security.yaml' : 'security.yaml.example' ); $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/', 'liip_imagine.yaml', [], true, $overwriteLiipImagine ? 'liip_imagine.yaml' : 'liip_imagine.yaml.example' ); $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/prod/', 'fos_http_cache.yaml', [], true, $overwriteFosHttpCache ? 'fos_http_cache.yaml' : 'fos_http_cache.yaml.example' ); $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/', 'fos_user.yaml', [], true, $overwriteFosUser ? 'fos_user.yaml' : 'fos_user.yaml.example' ); }
php
public function generate(string $projectDir, bool $overwriteSecurity, bool $overwriteLiipImagine, bool $overwriteFosHttpCache, bool $overwriteFosUser) { $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/', 'security.yaml', [], true, $overwriteSecurity ? 'security.yaml' : 'security.yaml.example' ); $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/', 'liip_imagine.yaml', [], true, $overwriteLiipImagine ? 'liip_imagine.yaml' : 'liip_imagine.yaml.example' ); $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/prod/', 'fos_http_cache.yaml', [], true, $overwriteFosHttpCache ? 'fos_http_cache.yaml' : 'fos_http_cache.yaml.example' ); $this->renderSingleFile( $this->skeletonDir, $projectDir . '/config/packages/', 'fos_user.yaml', [], true, $overwriteFosUser ? 'fos_user.yaml' : 'fos_user.yaml.example' ); }
[ "public", "function", "generate", "(", "string", "$", "projectDir", ",", "bool", "$", "overwriteSecurity", ",", "bool", "$", "overwriteLiipImagine", ",", "bool", "$", "overwriteFosHttpCache", ",", "bool", "$", "overwriteFosUser", ")", "{", "$", "this", "->", "...
Generate all config files. @param string $projectDir @param bool $overwriteSecurity @param bool $overwriteLiipImagine @param bool $overwriteFosHttpCache @param bool $overwriteFosUser
[ "Generate", "all", "config", "files", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/ConfigGenerator.php#L19-L53
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/Service/EntityVersionLockService.php
EntityVersionLockService.createEntityVersionLock
protected function createEntityVersionLock(User $user, LockableEntity $entity) { /** @var EntityVersionLock $lock */ $lock = $this->objectManager->getRepository('KunstmaanAdminListBundle:EntityVersionLock')->findOneBy([ 'owner' => $user->getUsername(), 'lockableEntity' => $entity, ]); if (!$lock) { $lock = new EntityVersionLock(); } $lock->setOwner($user->getUsername()); $lock->setLockableEntity($entity); $lock->setCreatedAt(new \DateTime()); $this->objectManager->persist($lock); $this->objectManager->flush(); }
php
protected function createEntityVersionLock(User $user, LockableEntity $entity) { /** @var EntityVersionLock $lock */ $lock = $this->objectManager->getRepository('KunstmaanAdminListBundle:EntityVersionLock')->findOneBy([ 'owner' => $user->getUsername(), 'lockableEntity' => $entity, ]); if (!$lock) { $lock = new EntityVersionLock(); } $lock->setOwner($user->getUsername()); $lock->setLockableEntity($entity); $lock->setCreatedAt(new \DateTime()); $this->objectManager->persist($lock); $this->objectManager->flush(); }
[ "protected", "function", "createEntityVersionLock", "(", "User", "$", "user", ",", "LockableEntity", "$", "entity", ")", "{", "/** @var EntityVersionLock $lock */", "$", "lock", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'KunstmaanAdminListB...
When editing the entity, create a new entity translation lock. @param User $user @param LockableEntity $entity
[ "When", "editing", "the", "entity", "create", "a", "new", "entity", "translation", "lock", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Service/EntityVersionLockService.php#L93-L108
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/Service/EntityVersionLockService.php
EntityVersionLockService.getEntityVersionLocksByLockableEntity
protected function getEntityVersionLocksByLockableEntity(LockableEntity $entity, User $userToExclude = null) { /** @var EntityVersionLockRepository $objectRepository */ $objectRepository = $this->objectManager->getRepository('KunstmaanAdminListBundle:EntityVersionLock'); return $objectRepository->getLocksForLockableEntity($entity, $this->threshold, $userToExclude); }
php
protected function getEntityVersionLocksByLockableEntity(LockableEntity $entity, User $userToExclude = null) { /** @var EntityVersionLockRepository $objectRepository */ $objectRepository = $this->objectManager->getRepository('KunstmaanAdminListBundle:EntityVersionLock'); return $objectRepository->getLocksForLockableEntity($entity, $this->threshold, $userToExclude); }
[ "protected", "function", "getEntityVersionLocksByLockableEntity", "(", "LockableEntity", "$", "entity", ",", "User", "$", "userToExclude", "=", "null", ")", "{", "/** @var EntityVersionLockRepository $objectRepository */", "$", "objectRepository", "=", "$", "this", "->", ...
When editing an entity, check if there is a lock for this entity. @param LockableEntity $entity @param User $userToExclude @return EntityVersionLock[]
[ "When", "editing", "an", "entity", "check", "if", "there", "is", "a", "lock", "for", "this", "entity", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Service/EntityVersionLockService.php#L151-L157
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/Service/EntityVersionLockService.php
EntityVersionLockService.getLockableEntity
protected function getLockableEntity(LockableEntityInterface $entity, $create = true) { /** @var LockableEntity $lockable */ $lockable = $this->objectManager->getRepository('KunstmaanAdminListBundle:LockableEntity')->getOrCreate($entity->getId(), get_class($entity)); if ($create === true && $lockable->getId() === null) { $this->objectManager->persist($lockable); $this->objectManager->flush(); } return $lockable; }
php
protected function getLockableEntity(LockableEntityInterface $entity, $create = true) { /** @var LockableEntity $lockable */ $lockable = $this->objectManager->getRepository('KunstmaanAdminListBundle:LockableEntity')->getOrCreate($entity->getId(), get_class($entity)); if ($create === true && $lockable->getId() === null) { $this->objectManager->persist($lockable); $this->objectManager->flush(); } return $lockable; }
[ "protected", "function", "getLockableEntity", "(", "LockableEntityInterface", "$", "entity", ",", "$", "create", "=", "true", ")", "{", "/** @var LockableEntity $lockable */", "$", "lockable", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'Ku...
Get or create a LockableEntity for an entity with LockableEntityInterface @param LockableEntityInterface $entity @return LockableEntity
[ "Get", "or", "create", "a", "LockableEntity", "for", "an", "entity", "with", "LockableEntityInterface" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/Service/EntityVersionLockService.php#L166-L177
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/CacheBundle/Controller/VarnishController.php
VarnishController.indexAction
public function indexAction(Request $request) { $this->checkPermission(); $form = $this->createForm(BanType::class); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isValid()) { $path = $form['path']->getData(); $this->get('kunstmaan_cache.helper.varnish')->banPath($path, $form['allDomains']->getData()); $this->addFlash('success', 'kunstmaan_cache.varnish.ban.success'); } } return [ 'form' => $form->createView(), ]; }
php
public function indexAction(Request $request) { $this->checkPermission(); $form = $this->createForm(BanType::class); if ($request->isMethod('POST')) { $form->handleRequest($request); if ($form->isValid()) { $path = $form['path']->getData(); $this->get('kunstmaan_cache.helper.varnish')->banPath($path, $form['allDomains']->getData()); $this->addFlash('success', 'kunstmaan_cache.varnish.ban.success'); } } return [ 'form' => $form->createView(), ]; }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "checkPermission", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "BanType", "::", "class", ")", ";", "if", "(", "$", "request", ...
Generates the varnish ban form. @Route("/settings/varnish", name="kunstmaancachebundle_varnish_settings_ban") @Template("KunstmaanCacheBundle:Varnish:ban.html.twig") @param Request $request @return array
[ "Generates", "the", "varnish", "ban", "form", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/CacheBundle/Controller/VarnishController.php#L30-L51
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/CacheBundle/Controller/VarnishController.php
VarnishController.banAction
public function banAction(Node $node) { $this->checkPermission(); /** @var NodeTranslation $nodeTranslation */ foreach ($node->getNodeTranslations() as $nodeTranslation) { $route = $this->generateUrl('_slug', ['url' => $nodeTranslation->getUrl(), '_locale' => $nodeTranslation->getLang()]); $this->get('kunstmaan_cache.helper.varnish')->banPath($route); } $this->addFlash('success', 'kunstmaan_cache.varnish.ban.success'); return $this->redirect($this->generateUrl('KunstmaanNodeBundle_nodes_edit', ['id' => $node->getId()])); }
php
public function banAction(Node $node) { $this->checkPermission(); /** @var NodeTranslation $nodeTranslation */ foreach ($node->getNodeTranslations() as $nodeTranslation) { $route = $this->generateUrl('_slug', ['url' => $nodeTranslation->getUrl(), '_locale' => $nodeTranslation->getLang()]); $this->get('kunstmaan_cache.helper.varnish')->banPath($route); } $this->addFlash('success', 'kunstmaan_cache.varnish.ban.success'); return $this->redirect($this->generateUrl('KunstmaanNodeBundle_nodes_edit', ['id' => $node->getId()])); }
[ "public", "function", "banAction", "(", "Node", "$", "node", ")", "{", "$", "this", "->", "checkPermission", "(", ")", ";", "/** @var NodeTranslation $nodeTranslation */", "foreach", "(", "$", "node", "->", "getNodeTranslations", "(", ")", "as", "$", "nodeTransl...
Ban route from varnish @Route("/varnish/ban/{node}", name="kunstmaancachebundle_varnish_ban") @param Node $node @return RedirectResponse
[ "Ban", "route", "from", "varnish" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/CacheBundle/Controller/VarnishController.php#L62-L74
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeSearchBundle/Helper/IndexablePagePartsService.php
IndexablePagePartsService.getIndexablePageParts
public function getIndexablePageParts(HasPagePartsInterface $page, $context = 'main') { $contexts = array_unique(array_merge($this->contexts, [$context])); $indexablePageParts = []; foreach ($contexts as $context) { $pageParts = $this->em ->getRepository('KunstmaanPagePartBundle:PagePartRef') ->getPageParts($page, $context); foreach ($pageParts as $pagePart) { if ($pagePart instanceof IndexableInterface && !$pagePart->isIndexable()) { continue; } $indexablePageParts[] = $pagePart; } } return $indexablePageParts; }
php
public function getIndexablePageParts(HasPagePartsInterface $page, $context = 'main') { $contexts = array_unique(array_merge($this->contexts, [$context])); $indexablePageParts = []; foreach ($contexts as $context) { $pageParts = $this->em ->getRepository('KunstmaanPagePartBundle:PagePartRef') ->getPageParts($page, $context); foreach ($pageParts as $pagePart) { if ($pagePart instanceof IndexableInterface && !$pagePart->isIndexable()) { continue; } $indexablePageParts[] = $pagePart; } } return $indexablePageParts; }
[ "public", "function", "getIndexablePageParts", "(", "HasPagePartsInterface", "$", "page", ",", "$", "context", "=", "'main'", ")", "{", "$", "contexts", "=", "array_unique", "(", "array_merge", "(", "$", "this", "->", "contexts", ",", "[", "$", "context", "]...
Returns all indexable pageparts for the specified page and context @param HasPagePartsInterface $page @param string $context @return array
[ "Returns", "all", "indexable", "pageparts", "for", "the", "specified", "page", "and", "context" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeSearchBundle/Helper/IndexablePagePartsService.php#L43-L62
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Controller/SettingsController.php
SettingsController.bundleVersionAction
public function bundleVersionAction() { $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN'); $versionChecker = $this->container->get('kunstmaan_admin.versionchecker'); if (!$versionChecker->isEnabled()) { return array('data' => null); } $data = null; try { $data = $versionChecker->check(); } catch (\Exception $e) { $this->container->get('logger')->error( $e->getMessage(), array('exception' => $e) ); } return array( 'data' => $data, ); }
php
public function bundleVersionAction() { $this->denyAccessUnlessGranted('ROLE_SUPER_ADMIN'); $versionChecker = $this->container->get('kunstmaan_admin.versionchecker'); if (!$versionChecker->isEnabled()) { return array('data' => null); } $data = null; try { $data = $versionChecker->check(); } catch (\Exception $e) { $this->container->get('logger')->error( $e->getMessage(), array('exception' => $e) ); } return array( 'data' => $data, ); }
[ "public", "function", "bundleVersionAction", "(", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ROLE_SUPER_ADMIN'", ")", ";", "$", "versionChecker", "=", "$", "this", "->", "container", "->", "get", "(", "'kunstmaan_admin.versionchecker'", ")", ";...
Show bundles version update information @Route("/bundle-version", name="KunstmaanAdminBundle_settings_bundle_version") @Template("KunstmaanAdminBundle:Settings:bundleVersion.html.twig") @throws AccessDeniedException @return array
[ "Show", "bundles", "version", "update", "information" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Controller/SettingsController.php#L41-L64
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Helper/InputAssistant.php
InputAssistant.askForNamespace
public function askForNamespace(array $text = null) { $namespace = $this->input->hasOption('namespace') ? $this->input->getOption('namespace') : null; // When the Namespace is filled in return it immediately if valid. try { if (!is_null($namespace) && !empty($namespace)) { Validators::validateBundleNamespace($namespace); return $namespace; } } catch (\Exception $error) { $this->writeError(array("Namespace '$namespace' is incorrect. Please provide a correct value.", $error->getMessage())); exit; } $ownBundles = $this->getOwnBundles(); if (count($ownBundles) <= 0) { $this->writeError("Looks like you don't have created a bundle for your project, create one first.", true); } $namespace = ''; // If we only have 1 or more bundles, we can prefill it. if (count($ownBundles) > 0) { $namespace = $ownBundles[1]['namespace'] . '/' . $ownBundles[1]['name']; } $namespaces = $this->getNamespaceAutoComplete($this->kernel); if (!is_null($text) && (count($text) > 0)) { $this->output->writeln($text); } $question = new Question($this->questionHelper->getQuestion('Bundle Namespace', $namespace), $namespace); $question->setValidator(array('Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateBundleNamespace')); $question->setAutocompleterValues($namespaces); $namespace = $this->questionHelper->ask($this->input, $this->output, $question); if ($this->input->hasOption('namespace')) { $this->input->setOption('namespace', $namespace); } return $namespace; }
php
public function askForNamespace(array $text = null) { $namespace = $this->input->hasOption('namespace') ? $this->input->getOption('namespace') : null; // When the Namespace is filled in return it immediately if valid. try { if (!is_null($namespace) && !empty($namespace)) { Validators::validateBundleNamespace($namespace); return $namespace; } } catch (\Exception $error) { $this->writeError(array("Namespace '$namespace' is incorrect. Please provide a correct value.", $error->getMessage())); exit; } $ownBundles = $this->getOwnBundles(); if (count($ownBundles) <= 0) { $this->writeError("Looks like you don't have created a bundle for your project, create one first.", true); } $namespace = ''; // If we only have 1 or more bundles, we can prefill it. if (count($ownBundles) > 0) { $namespace = $ownBundles[1]['namespace'] . '/' . $ownBundles[1]['name']; } $namespaces = $this->getNamespaceAutoComplete($this->kernel); if (!is_null($text) && (count($text) > 0)) { $this->output->writeln($text); } $question = new Question($this->questionHelper->getQuestion('Bundle Namespace', $namespace), $namespace); $question->setValidator(array('Sensio\Bundle\GeneratorBundle\Command\Validators', 'validateBundleNamespace')); $question->setAutocompleterValues($namespaces); $namespace = $this->questionHelper->ask($this->input, $this->output, $question); if ($this->input->hasOption('namespace')) { $this->input->setOption('namespace', $namespace); } return $namespace; }
[ "public", "function", "askForNamespace", "(", "array", "$", "text", "=", "null", ")", "{", "$", "namespace", "=", "$", "this", "->", "input", "->", "hasOption", "(", "'namespace'", ")", "?", "$", "this", "->", "input", "->", "getOption", "(", "'namespace...
Asks for the namespace and sets it on the InputInterface as the 'namespace' option, if this option is not set yet. @param array $text what you want printed before the namespace is asked @return string The namespace. But it's also been set on the InputInterface.
[ "Asks", "for", "the", "namespace", "and", "sets", "it", "on", "the", "InputInterface", "as", "the", "namespace", "option", "if", "this", "option", "is", "not", "set", "yet", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/InputAssistant.php#L56-L100
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Helper/InputAssistant.php
InputAssistant.getNamespaceAutoComplete
private function getNamespaceAutoComplete(Kernel $kernel) { $ret = array(); foreach ($kernel->getBundles() as $k => $v) { $ret[] = $this->fixNamespace($v->getNamespace()); } return $ret; }
php
private function getNamespaceAutoComplete(Kernel $kernel) { $ret = array(); foreach ($kernel->getBundles() as $k => $v) { $ret[] = $this->fixNamespace($v->getNamespace()); } return $ret; }
[ "private", "function", "getNamespaceAutoComplete", "(", "Kernel", "$", "kernel", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "kernel", "->", "getBundles", "(", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "ret", "...
Returns a list of namespaces as array with a forward slash to split the namespace & bundle. @param Kernel $kernel @return array
[ "Returns", "a", "list", "of", "namespaces", "as", "array", "with", "a", "forward", "slash", "to", "split", "the", "namespace", "&", "bundle", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Helper/InputAssistant.php#L153-L161
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.init
public function init($configId = false) { // if token is already saved in the database if ($this->getToken($configId) && '' !== $this->getToken($configId)) { $this ->serviceHelper ->getClientHelper() ->getClient() ->setAccessToken($this->getToken($configId)); } if ($configId) { $this->getAccountId($configId); $this->getPropertyId($configId); $this->getProfileId($configId); } }
php
public function init($configId = false) { // if token is already saved in the database if ($this->getToken($configId) && '' !== $this->getToken($configId)) { $this ->serviceHelper ->getClientHelper() ->getClient() ->setAccessToken($this->getToken($configId)); } if ($configId) { $this->getAccountId($configId); $this->getPropertyId($configId); $this->getProfileId($configId); } }
[ "public", "function", "init", "(", "$", "configId", "=", "false", ")", "{", "// if token is already saved in the database", "if", "(", "$", "this", "->", "getToken", "(", "$", "configId", ")", "&&", "''", "!==", "$", "this", "->", "getToken", "(", "$", "co...
Tries to initialise the Client object @param int $configId
[ "Tries", "to", "initialise", "the", "Client", "object" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L45-L61
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getToken
private function getToken($configId = false) { if (!$this->token || $configId) { /** @var AnalyticsConfigRepository $analyticsConfigRepository */ $analyticsConfigRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); if ($configId) { $this->token = $analyticsConfigRepository->find($configId)->getToken(); } else { $this->token = $analyticsConfigRepository->findFirst()->getToken(); } } return $this->token; }
php
private function getToken($configId = false) { if (!$this->token || $configId) { /** @var AnalyticsConfigRepository $analyticsConfigRepository */ $analyticsConfigRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); if ($configId) { $this->token = $analyticsConfigRepository->find($configId)->getToken(); } else { $this->token = $analyticsConfigRepository->findFirst()->getToken(); } } return $this->token; }
[ "private", "function", "getToken", "(", "$", "configId", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "token", "||", "$", "configId", ")", "{", "/** @var AnalyticsConfigRepository $analyticsConfigRepository */", "$", "analyticsConfigRepository", "=", ...
Get the token from the database @return string $token
[ "Get", "the", "token", "from", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L70-L83
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.saveToken
public function saveToken($token, $configId = false) { $this->token = $token; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveToken($token, $configId); }
php
public function saveToken($token, $configId = false) { $this->token = $token; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveToken($token, $configId); }
[ "public", "function", "saveToken", "(", "$", "token", ",", "$", "configId", "=", "false", ")", "{", "$", "this", "->", "token", "=", "$", "token", ";", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsConfig'", ")", ...
Save the token to the database
[ "Save", "the", "token", "to", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L88-L92
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getAccounts
public function getAccounts() { $accounts = $this->serviceHelper->getService()->management_accounts->listManagementAccounts()->getItems(); $data = array(); foreach ($accounts as $account) { $data[$account->getName()] = array( 'accountId' => $account->getId(), 'accountName' => $account->getName(), ); } ksort($data); return $data; }
php
public function getAccounts() { $accounts = $this->serviceHelper->getService()->management_accounts->listManagementAccounts()->getItems(); $data = array(); foreach ($accounts as $account) { $data[$account->getName()] = array( 'accountId' => $account->getId(), 'accountName' => $account->getName(), ); } ksort($data); return $data; }
[ "public", "function", "getAccounts", "(", ")", "{", "$", "accounts", "=", "$", "this", "->", "serviceHelper", "->", "getService", "(", ")", "->", "management_accounts", "->", "listManagementAccounts", "(", ")", "->", "getItems", "(", ")", ";", "$", "data", ...
Get a list of all available accounts @return array $data A list of all properties
[ "Get", "a", "list", "of", "all", "available", "accounts" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L111-L125
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getAccountId
public function getAccountId($configId = false) { if (!$this->accountId || $configId) { /** @var AnalyticsConfigRepository $analyticsConfigRepository */ $analyticsConfigRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); if ($configId) { $this->accountId = $analyticsConfigRepository->find($configId)->getAccountId(); } else { $this->accountId = $analyticsConfigRepository->findFirst()->getAccountId(); } } return $this->accountId; }
php
public function getAccountId($configId = false) { if (!$this->accountId || $configId) { /** @var AnalyticsConfigRepository $analyticsConfigRepository */ $analyticsConfigRepository = $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig'); if ($configId) { $this->accountId = $analyticsConfigRepository->find($configId)->getAccountId(); } else { $this->accountId = $analyticsConfigRepository->findFirst()->getAccountId(); } } return $this->accountId; }
[ "public", "function", "getAccountId", "(", "$", "configId", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "accountId", "||", "$", "configId", ")", "{", "/** @var AnalyticsConfigRepository $analyticsConfigRepository */", "$", "analyticsConfigRepository", ...
Get the accountId from the database @return string $accountId
[ "Get", "the", "accountId", "from", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L132-L145
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.saveAccountId
public function saveAccountId($accountId, $configId = false) { $this->accountId = $accountId; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveAccountId($accountId, $configId); }
php
public function saveAccountId($accountId, $configId = false) { $this->accountId = $accountId; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveAccountId($accountId, $configId); }
[ "public", "function", "saveAccountId", "(", "$", "accountId", ",", "$", "configId", "=", "false", ")", "{", "$", "this", "->", "accountId", "=", "$", "accountId", ";", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsCon...
Save the accountId to the database
[ "Save", "the", "accountId", "to", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L150-L154
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getProperties
public function getProperties($accountId = false) { if (!$this->getAccountId() && !$accountId) { return false; } if ($accountId) { $webproperties = $this->serviceHelper->getService()->management_webproperties->listManagementWebproperties($accountId); } else { $webproperties = $this->serviceHelper->getService()->management_webproperties->listManagementWebproperties($this->getAccountId()); } $data = array(); foreach ($webproperties->getItems() as $property) { $profiles = $this->getProfiles($accountId, $property->getId()); if (count($profiles) > 0) { $data[$property->getName()] = array( 'propertyId' => $property->getId(), 'propertyName' => $property->getName() . ' (' . $property->getWebsiteUrl() . ')', ); } } ksort($data); return $data; }
php
public function getProperties($accountId = false) { if (!$this->getAccountId() && !$accountId) { return false; } if ($accountId) { $webproperties = $this->serviceHelper->getService()->management_webproperties->listManagementWebproperties($accountId); } else { $webproperties = $this->serviceHelper->getService()->management_webproperties->listManagementWebproperties($this->getAccountId()); } $data = array(); foreach ($webproperties->getItems() as $property) { $profiles = $this->getProfiles($accountId, $property->getId()); if (count($profiles) > 0) { $data[$property->getName()] = array( 'propertyId' => $property->getId(), 'propertyName' => $property->getName() . ' (' . $property->getWebsiteUrl() . ')', ); } } ksort($data); return $data; }
[ "public", "function", "getProperties", "(", "$", "accountId", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "getAccountId", "(", ")", "&&", "!", "$", "accountId", ")", "{", "return", "false", ";", "}", "if", "(", "$", "accountId", ")", ...
Get a list of all available properties @return array $data A list of all properties
[ "Get", "a", "list", "of", "all", "available", "properties" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L173-L198
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.savePropertyId
public function savePropertyId($propertyId, $configId = false) { $this->propertyId = $propertyId; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->savePropertyId($propertyId, $configId); }
php
public function savePropertyId($propertyId, $configId = false) { $this->propertyId = $propertyId; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->savePropertyId($propertyId, $configId); }
[ "public", "function", "savePropertyId", "(", "$", "propertyId", ",", "$", "configId", "=", "false", ")", "{", "$", "this", "->", "propertyId", "=", "$", "propertyId", ";", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:Analytic...
Save the propertyId to the database
[ "Save", "the", "propertyId", "to", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L223-L227
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getProfiles
public function getProfiles($accountId = false, $propertyId = false) { if (!$this->getAccountId() && !$accountId || !$this->getPropertyId() && !$propertyId) { return false; } // get views if ($accountId && $propertyId) { $profiles = $this->serviceHelper->getService()->management_profiles->listManagementProfiles( $accountId, $propertyId ); } else { $profiles = $this->serviceHelper->getService()->management_profiles->listManagementProfiles( $this->getAccountId(), $this->getPropertyId() ); } $data = array(); if (is_array($profiles->getItems())) { foreach ($profiles->getItems() as $profile) { $data[$profile->name] = array( 'profileId' => $profile->id, 'profileName' => $profile->name, 'created' => $profile->created, ); } } ksort($data); return $data; }
php
public function getProfiles($accountId = false, $propertyId = false) { if (!$this->getAccountId() && !$accountId || !$this->getPropertyId() && !$propertyId) { return false; } // get views if ($accountId && $propertyId) { $profiles = $this->serviceHelper->getService()->management_profiles->listManagementProfiles( $accountId, $propertyId ); } else { $profiles = $this->serviceHelper->getService()->management_profiles->listManagementProfiles( $this->getAccountId(), $this->getPropertyId() ); } $data = array(); if (is_array($profiles->getItems())) { foreach ($profiles->getItems() as $profile) { $data[$profile->name] = array( 'profileId' => $profile->id, 'profileName' => $profile->name, 'created' => $profile->created, ); } } ksort($data); return $data; }
[ "public", "function", "getProfiles", "(", "$", "accountId", "=", "false", ",", "$", "propertyId", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "getAccountId", "(", ")", "&&", "!", "$", "accountId", "||", "!", "$", "this", "->", "getProp...
Get a list of all available profiles @return array $data A list of all properties
[ "Get", "a", "list", "of", "all", "available", "profiles" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L246-L278
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.saveProfileId
public function saveProfileId($profileId, $configId = false) { $this->profileId = $profileId; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveProfileId($profileId, $configId); }
php
public function saveProfileId($profileId, $configId = false) { $this->profileId = $profileId; $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveProfileId($profileId, $configId); }
[ "public", "function", "saveProfileId", "(", "$", "profileId", ",", "$", "configId", "=", "false", ")", "{", "$", "this", "->", "profileId", "=", "$", "profileId", ";", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsCon...
Save the profileId to the database
[ "Save", "the", "profileId", "to", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L303-L307
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getActiveProfile
public function getActiveProfile() { $profiles = $this->getProfiles(); $profileId = $this->getProfileId(); if (!is_array($profiles)) { throw new \Exception('<fg=red>The config is invalid</fg=red>'); } foreach ($profiles as $profile) { if ($profile['profileId'] == $profileId) { return $profile; } } }
php
public function getActiveProfile() { $profiles = $this->getProfiles(); $profileId = $this->getProfileId(); if (!is_array($profiles)) { throw new \Exception('<fg=red>The config is invalid</fg=red>'); } foreach ($profiles as $profile) { if ($profile['profileId'] == $profileId) { return $profile; } } }
[ "public", "function", "getActiveProfile", "(", ")", "{", "$", "profiles", "=", "$", "this", "->", "getProfiles", "(", ")", ";", "$", "profileId", "=", "$", "this", "->", "getProfileId", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "profiles", ...
Get the active profile @return the profile
[ "Get", "the", "active", "profile" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L324-L338
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.getProfileSegments
public function getProfileSegments() { $profileSegments = $this ->serviceHelper ->getService() ->management_segments ->listManagementSegments() ->items; $builtin = array(); $own = array(); foreach ($profileSegments as $segment) { if ($segment->type == 'BUILT_IN') { $builtin[] = array( 'name' => $segment->name, 'query' => $segment->segmentId, ); } else { $own[] = array( 'name' => $segment->name, 'query' => $segment->segmentId, ); } } return array('builtin' => $builtin, 'own' => $own); }
php
public function getProfileSegments() { $profileSegments = $this ->serviceHelper ->getService() ->management_segments ->listManagementSegments() ->items; $builtin = array(); $own = array(); foreach ($profileSegments as $segment) { if ($segment->type == 'BUILT_IN') { $builtin[] = array( 'name' => $segment->name, 'query' => $segment->segmentId, ); } else { $own[] = array( 'name' => $segment->name, 'query' => $segment->segmentId, ); } } return array('builtin' => $builtin, 'own' => $own); }
[ "public", "function", "getProfileSegments", "(", ")", "{", "$", "profileSegments", "=", "$", "this", "->", "serviceHelper", "->", "getService", "(", ")", "->", "management_segments", "->", "listManagementSegments", "(", ")", "->", "items", ";", "$", "builtin", ...
get all segments for the saved profile @return array
[ "get", "all", "segments", "for", "the", "saved", "profile" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L347-L373
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php
ConfigHelper.saveConfigName
public function saveConfigName($configName, $configId = false) { $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveConfigName($configName, $configId); }
php
public function saveConfigName($configName, $configId = false) { $this->em->getRepository('KunstmaanDashboardBundle:AnalyticsConfig')->saveConfigName($configName, $configId); }
[ "public", "function", "saveConfigName", "(", "$", "configName", ",", "$", "configId", "=", "false", ")", "{", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanDashboardBundle:AnalyticsConfig'", ")", "->", "saveConfigName", "(", "$", "configName", ...
Save the config to the database
[ "Save", "the", "config", "to", "the", "database" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Helper/Google/Analytics/ConfigHelper.php#L380-L383
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MultiDomainBundle/DependencyInjection/KunstmaanMultiDomainExtension.php
KunstmaanMultiDomainExtension.getHostConfigurations
private function getHostConfigurations($hosts) { $hostConfigurations = array(); foreach ($hosts as $name => $settings) { $host = $settings['host']; // Set the key of the host as id. $hostConfigurations[$host]['id'] = $name; foreach ($settings as $setting => $data) { if ($setting === 'locales') { $hostConfigurations[$host]['locales_extra'] = $this->getLocalesExtra($data); $data = $this->getHostLocales($data); $hostConfigurations[$host]['reverse_locales'] = array_flip($data); } $hostConfigurations[$host][$setting] = $data; } } return $hostConfigurations; }
php
private function getHostConfigurations($hosts) { $hostConfigurations = array(); foreach ($hosts as $name => $settings) { $host = $settings['host']; // Set the key of the host as id. $hostConfigurations[$host]['id'] = $name; foreach ($settings as $setting => $data) { if ($setting === 'locales') { $hostConfigurations[$host]['locales_extra'] = $this->getLocalesExtra($data); $data = $this->getHostLocales($data); $hostConfigurations[$host]['reverse_locales'] = array_flip($data); } $hostConfigurations[$host][$setting] = $data; } } return $hostConfigurations; }
[ "private", "function", "getHostConfigurations", "(", "$", "hosts", ")", "{", "$", "hostConfigurations", "=", "array", "(", ")", ";", "foreach", "(", "$", "hosts", "as", "$", "name", "=>", "$", "settings", ")", "{", "$", "host", "=", "$", "settings", "[...
Convert config hosts array to a usable format @param $hosts @return array
[ "Convert", "config", "hosts", "array", "to", "a", "usable", "format" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MultiDomainBundle/DependencyInjection/KunstmaanMultiDomainExtension.php#L61-L80
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MultiDomainBundle/DependencyInjection/KunstmaanMultiDomainExtension.php
KunstmaanMultiDomainExtension.getHostLocales
private function getHostLocales($localeSettings) { $hostLocales = array(); foreach ($localeSettings as $key => $localeMapping) { $hostLocales[$localeMapping['uri_locale']] = $localeMapping['locale']; } return $hostLocales; }
php
private function getHostLocales($localeSettings) { $hostLocales = array(); foreach ($localeSettings as $key => $localeMapping) { $hostLocales[$localeMapping['uri_locale']] = $localeMapping['locale']; } return $hostLocales; }
[ "private", "function", "getHostLocales", "(", "$", "localeSettings", ")", "{", "$", "hostLocales", "=", "array", "(", ")", ";", "foreach", "(", "$", "localeSettings", "as", "$", "key", "=>", "$", "localeMapping", ")", "{", "$", "hostLocales", "[", "$", "...
Return uri to actual locale mappings @param $localeSettings @return array
[ "Return", "uri", "to", "actual", "locale", "mappings" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MultiDomainBundle/DependencyInjection/KunstmaanMultiDomainExtension.php#L89-L97
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MultiDomainBundle/DependencyInjection/KunstmaanMultiDomainExtension.php
KunstmaanMultiDomainExtension.getLocalesExtra
private function getLocalesExtra($localeSettings) { $localesExtra = array(); foreach ($localeSettings as $key => $localeMapping) { $localesExtra[$localeMapping['uri_locale']] = array_key_exists('extra', $localeMapping) ? $localeMapping['extra'] : array(); } return $localesExtra; }
php
private function getLocalesExtra($localeSettings) { $localesExtra = array(); foreach ($localeSettings as $key => $localeMapping) { $localesExtra[$localeMapping['uri_locale']] = array_key_exists('extra', $localeMapping) ? $localeMapping['extra'] : array(); } return $localesExtra; }
[ "private", "function", "getLocalesExtra", "(", "$", "localeSettings", ")", "{", "$", "localesExtra", "=", "array", "(", ")", ";", "foreach", "(", "$", "localeSettings", "as", "$", "key", "=>", "$", "localeMapping", ")", "{", "$", "localesExtra", "[", "$", ...
Return the extra data configured for each locale @param $localeSettings @return array
[ "Return", "the", "extra", "data", "configured", "for", "each", "locale" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MultiDomainBundle/DependencyInjection/KunstmaanMultiDomainExtension.php#L106-L114
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/Controller/FormSubmissionsController.php
FormSubmissionsController.indexAction
public function indexAction(Request $request) { /* @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); $aclHelper = $this->container->get('kunstmaan_admin.acl.helper'); /* @var AdminList $adminList */ $adminList = $this->get('kunstmaan_adminlist.factory')->createList( new FormPageAdminListConfigurator($em, $aclHelper, PermissionMap::PERMISSION_VIEW), $em ); $adminList->bindRequest($request); return array('adminlist' => $adminList); }
php
public function indexAction(Request $request) { /* @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); $aclHelper = $this->container->get('kunstmaan_admin.acl.helper'); /* @var AdminList $adminList */ $adminList = $this->get('kunstmaan_adminlist.factory')->createList( new FormPageAdminListConfigurator($em, $aclHelper, PermissionMap::PERMISSION_VIEW), $em ); $adminList->bindRequest($request); return array('adminlist' => $adminList); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ")", "{", "/* @var EntityManager $em */", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "aclHelper", "=", "$", "this", "->", "contain...
The index action will use an admin list to list all the form pages @Route("/", name="KunstmaanFormBundle_formsubmissions") @Template("KunstmaanAdminListBundle:Default:list.html.twig") @return array
[ "The", "index", "action", "will", "use", "an", "admin", "list", "to", "list", "all", "the", "form", "pages" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Controller/FormSubmissionsController.php#L34-L48
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/Controller/FormSubmissionsController.php
FormSubmissionsController.editAction
public function editAction($nodeTranslationId, $submissionId) { $em = $this->getDoctrine()->getManager(); $nodeTranslation = $em->getRepository('KunstmaanNodeBundle:NodeTranslation')->find($nodeTranslationId); $formSubmission = $em->getRepository('KunstmaanFormBundle:FormSubmission')->find($submissionId); $request = $this->container->get('request_stack')->getCurrentRequest(); $deletableFormsubmission = $this->getParameter('kunstmaan_form.deletable_formsubmissions'); /** @var AdminList $adminList */ $adminList = $this->get('kunstmaan_adminlist.factory')->createList( new FormSubmissionAdminListConfigurator($em, $nodeTranslation, $deletableFormsubmission), $em ); $adminList->bindRequest($request); return [ 'nodetranslation' => $nodeTranslation, 'formsubmission' => $formSubmission, 'adminlist' => $adminList, ]; }
php
public function editAction($nodeTranslationId, $submissionId) { $em = $this->getDoctrine()->getManager(); $nodeTranslation = $em->getRepository('KunstmaanNodeBundle:NodeTranslation')->find($nodeTranslationId); $formSubmission = $em->getRepository('KunstmaanFormBundle:FormSubmission')->find($submissionId); $request = $this->container->get('request_stack')->getCurrentRequest(); $deletableFormsubmission = $this->getParameter('kunstmaan_form.deletable_formsubmissions'); /** @var AdminList $adminList */ $adminList = $this->get('kunstmaan_adminlist.factory')->createList( new FormSubmissionAdminListConfigurator($em, $nodeTranslation, $deletableFormsubmission), $em ); $adminList->bindRequest($request); return [ 'nodetranslation' => $nodeTranslation, 'formsubmission' => $formSubmission, 'adminlist' => $adminList, ]; }
[ "public", "function", "editAction", "(", "$", "nodeTranslationId", ",", "$", "submissionId", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "nodeTranslation", "=", "$", "em", "->", "getReposi...
The edit action will be used to edit a given submission. @param int $nodeTranslationId The node translation id @param int $submissionId The submission id @Route("/list/{nodeTranslationId}/{submissionId}", requirements={"nodeTranslationId" = "\d+", "submissionId" = "\d+"}, name="KunstmaanFormBundle_formsubmissions_list_edit", methods={"GET", "POST"}) @Template("@KunstmaanForm/FormSubmissions/edit.html.twig") @return array
[ "The", "edit", "action", "will", "be", "used", "to", "edit", "a", "given", "submission", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Controller/FormSubmissionsController.php#L88-L108
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Migrations/MigrationsService.php
MigrationsService.buildInsertSql
public function buildInsertSql($entities, $entityClassName, $ignoreFields = array()) { if (count($entities) <= 0) { return null; } $fieldNames = $this->entityManager->getClassMetadata($entityClassName)->getFieldNames(); $tableName = $this->entityManager->getClassMetadata($entityClassName)->getTableName(); $tableName = $this->entityManager->getConnection()->quoteIdentifier($tableName); $fieldNames = array_diff($fieldNames, $ignoreFields); $values = array(); foreach ($entities as $entity) { $insertValues = array(); foreach ($fieldNames as $fieldName) { $value = $entity->{'get'.$fieldName}(); if ($value instanceof \DateTime) { $value = $value->format('Y-m-d H:i:s'); } $insertValues[] = $this->entityManager->getConnection()->quote($value); } $values[] = '(' . implode(',', $insertValues) . ')'; } foreach ($fieldNames as $key => $fieldName) { $columnName = $this->entityManager->getClassMetadata($entityClassName)->getColumnName($fieldName); $fieldNames[$key] = $this->entityManager->getConnection()->quoteIdentifier($columnName); } $sql = sprintf('INSERT INTO %s (%s) VALUES %s', $tableName, implode(',', $fieldNames), implode(', ', $values)); return $sql; }
php
public function buildInsertSql($entities, $entityClassName, $ignoreFields = array()) { if (count($entities) <= 0) { return null; } $fieldNames = $this->entityManager->getClassMetadata($entityClassName)->getFieldNames(); $tableName = $this->entityManager->getClassMetadata($entityClassName)->getTableName(); $tableName = $this->entityManager->getConnection()->quoteIdentifier($tableName); $fieldNames = array_diff($fieldNames, $ignoreFields); $values = array(); foreach ($entities as $entity) { $insertValues = array(); foreach ($fieldNames as $fieldName) { $value = $entity->{'get'.$fieldName}(); if ($value instanceof \DateTime) { $value = $value->format('Y-m-d H:i:s'); } $insertValues[] = $this->entityManager->getConnection()->quote($value); } $values[] = '(' . implode(',', $insertValues) . ')'; } foreach ($fieldNames as $key => $fieldName) { $columnName = $this->entityManager->getClassMetadata($entityClassName)->getColumnName($fieldName); $fieldNames[$key] = $this->entityManager->getConnection()->quoteIdentifier($columnName); } $sql = sprintf('INSERT INTO %s (%s) VALUES %s', $tableName, implode(',', $fieldNames), implode(', ', $values)); return $sql; }
[ "public", "function", "buildInsertSql", "(", "$", "entities", ",", "$", "entityClassName", ",", "$", "ignoreFields", "=", "array", "(", ")", ")", "{", "if", "(", "count", "(", "$", "entities", ")", "<=", "0", ")", "{", "return", "null", ";", "}", "$"...
Build an sql insert into query by the paramters provided @param ORM\Entity $entities Result array with all entities to create an insert for @param string $entityClassName Class of the specified entity (same as entities) @param array $ignoreFields fields not to use in the insert query @return string an insert sql query, of no result nul
[ "Build", "an", "sql", "insert", "into", "query", "by", "the", "paramters", "provided" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Migrations/MigrationsService.php#L96-L134
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/Service/Migrations/MigrationsService.php
MigrationsService.getNewTranslationSql
public function getNewTranslationSql() { $translations = $this->translationRepository->findBy(array('flag' => \Kunstmaan\TranslatorBundle\Entity\Translation::FLAG_NEW)); return $this->buildInsertSql($translations, '\Kunstmaan\TranslatorBundle\Entity\Translation', array('flag', 'id')); }
php
public function getNewTranslationSql() { $translations = $this->translationRepository->findBy(array('flag' => \Kunstmaan\TranslatorBundle\Entity\Translation::FLAG_NEW)); return $this->buildInsertSql($translations, '\Kunstmaan\TranslatorBundle\Entity\Translation', array('flag', 'id')); }
[ "public", "function", "getNewTranslationSql", "(", ")", "{", "$", "translations", "=", "$", "this", "->", "translationRepository", "->", "findBy", "(", "array", "(", "'flag'", "=>", "\\", "Kunstmaan", "\\", "TranslatorBundle", "\\", "Entity", "\\", "Translation"...
Get the sql query for all new translations added @return string sql query
[ "Get", "the", "sql", "query", "for", "all", "new", "translations", "added" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/Service/Migrations/MigrationsService.php#L141-L146
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Controller/WidgetsController.php
WidgetsController.getTemplateParameters
private function getTemplateParameters(Request $request) { // When the media bundle is available, we show a link in the header to the media chooser $allBundles = $this->getParameter('kernel.bundles'); $mediaChooserLink = null; if (array_key_exists('KunstmaanMediaBundle', $allBundles)) { $params = ['linkChooser' => 1]; $cKEditorFuncNum = $request->get('CKEditorFuncNum'); if (!empty($cKEditorFuncNum)) { $params['CKEditorFuncNum'] = $cKEditorFuncNum; } $mediaChooserLink = $this->generateUrl( 'KunstmaanMediaBundle_chooser', $params ); } return [ 'mediaChooserLink' => $mediaChooserLink, ]; }
php
private function getTemplateParameters(Request $request) { // When the media bundle is available, we show a link in the header to the media chooser $allBundles = $this->getParameter('kernel.bundles'); $mediaChooserLink = null; if (array_key_exists('KunstmaanMediaBundle', $allBundles)) { $params = ['linkChooser' => 1]; $cKEditorFuncNum = $request->get('CKEditorFuncNum'); if (!empty($cKEditorFuncNum)) { $params['CKEditorFuncNum'] = $cKEditorFuncNum; } $mediaChooserLink = $this->generateUrl( 'KunstmaanMediaBundle_chooser', $params ); } return [ 'mediaChooserLink' => $mediaChooserLink, ]; }
[ "private", "function", "getTemplateParameters", "(", "Request", "$", "request", ")", "{", "// When the media bundle is available, we show a link in the header to the media chooser", "$", "allBundles", "=", "$", "this", "->", "getParameter", "(", "'kernel.bundles'", ")", ";", ...
Get the parameters needed in the template. This is common for the default link chooser and the cke link chooser. @param \Symfony\Component\HttpFoundation\Request $request @return array
[ "Get", "the", "parameters", "needed", "in", "the", "template", ".", "This", "is", "common", "for", "the", "default", "link", "chooser", "and", "the", "cke", "link", "chooser", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Controller/WidgetsController.php#L138-L159
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/PagePartBundle/PagePartAdmin/PagePartAdmin.php
PagePartAdmin.initializePageParts
private function initializePageParts() { // Get all the pagepartrefs /** @var PagePartRefRepository $ppRefRepo */ $ppRefRepo = $this->em->getRepository('KunstmaanPagePartBundle:PagePartRef'); $ppRefs = $ppRefRepo->getPagePartRefs($this->page, $this->context); // Group pagepartrefs per type $types = array(); foreach ($ppRefs as $pagePartRef) { $types[$pagePartRef->getPagePartEntityname()][] = $pagePartRef->getPagePartId(); $this->pagePartRefs[$pagePartRef->getId()] = $pagePartRef; } // Fetch all the pageparts (only one query per pagepart type) /** @var EntityInterface[] $pageParts */ $pageParts = array(); foreach ($types as $classname => $ids) { $result = $this->em->getRepository($classname)->findBy(array('id' => $ids)); $pageParts = array_merge($pageParts, $result); } // Link the pagepartref to the pagepart foreach ($this->pagePartRefs as $pagePartRef) { foreach ($pageParts as $key => $pagePart) { if (ClassLookup::getClass($pagePart) == $pagePartRef->getPagePartEntityname() && $pagePart->getId() == $pagePartRef->getPagePartId() ) { $this->pageParts[$pagePartRef->getId()] = $pagePart; unset($pageParts[$key]); break; } } } }
php
private function initializePageParts() { // Get all the pagepartrefs /** @var PagePartRefRepository $ppRefRepo */ $ppRefRepo = $this->em->getRepository('KunstmaanPagePartBundle:PagePartRef'); $ppRefs = $ppRefRepo->getPagePartRefs($this->page, $this->context); // Group pagepartrefs per type $types = array(); foreach ($ppRefs as $pagePartRef) { $types[$pagePartRef->getPagePartEntityname()][] = $pagePartRef->getPagePartId(); $this->pagePartRefs[$pagePartRef->getId()] = $pagePartRef; } // Fetch all the pageparts (only one query per pagepart type) /** @var EntityInterface[] $pageParts */ $pageParts = array(); foreach ($types as $classname => $ids) { $result = $this->em->getRepository($classname)->findBy(array('id' => $ids)); $pageParts = array_merge($pageParts, $result); } // Link the pagepartref to the pagepart foreach ($this->pagePartRefs as $pagePartRef) { foreach ($pageParts as $key => $pagePart) { if (ClassLookup::getClass($pagePart) == $pagePartRef->getPagePartEntityname() && $pagePart->getId() == $pagePartRef->getPagePartId() ) { $this->pageParts[$pagePartRef->getId()] = $pagePart; unset($pageParts[$key]); break; } } } }
[ "private", "function", "initializePageParts", "(", ")", "{", "// Get all the pagepartrefs", "/** @var PagePartRefRepository $ppRefRepo */", "$", "ppRefRepo", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanPagePartBundle:PagePartRef'", ")", ";", "$", ...
Get all pageparts from the database, and store them.
[ "Get", "all", "pageparts", "from", "the", "database", "and", "store", "them", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/PagePartAdmin/PagePartAdmin.php#L100-L135
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/PagePartBundle/PagePartAdmin/PagePartAdmin.php
PagePartAdmin.getPossiblePagePartTypes
public function getPossiblePagePartTypes() { $possiblePPTypes = $this->configurator->getPossiblePagePartTypes(); $result = array(); // filter page part types that can only be added x times to the page context. // to achieve this, provide a 'pagelimit' parameter when adding the pp type in your PagePartAdminConfiguration if (!empty($possiblePPTypes)) { foreach ($possiblePPTypes as $possibleTypeData) { if (array_key_exists('pagelimit', $possibleTypeData)) { $pageLimit = $possibleTypeData['pagelimit']; /** @var PagePartRefRepository $entityRepository */ $entityRepository = $this->em->getRepository('KunstmaanPagePartBundle:PagePartRef'); $formPPCount = $entityRepository->countPagePartsOfType( $this->page, $possibleTypeData['class'], $this->configurator->getContext() ); if ($formPPCount < $pageLimit) { $result[] = $possibleTypeData; } } else { $result[] = $possibleTypeData; } } } return $result; }
php
public function getPossiblePagePartTypes() { $possiblePPTypes = $this->configurator->getPossiblePagePartTypes(); $result = array(); // filter page part types that can only be added x times to the page context. // to achieve this, provide a 'pagelimit' parameter when adding the pp type in your PagePartAdminConfiguration if (!empty($possiblePPTypes)) { foreach ($possiblePPTypes as $possibleTypeData) { if (array_key_exists('pagelimit', $possibleTypeData)) { $pageLimit = $possibleTypeData['pagelimit']; /** @var PagePartRefRepository $entityRepository */ $entityRepository = $this->em->getRepository('KunstmaanPagePartBundle:PagePartRef'); $formPPCount = $entityRepository->countPagePartsOfType( $this->page, $possibleTypeData['class'], $this->configurator->getContext() ); if ($formPPCount < $pageLimit) { $result[] = $possibleTypeData; } } else { $result[] = $possibleTypeData; } } } return $result; }
[ "public", "function", "getPossiblePagePartTypes", "(", ")", "{", "$", "possiblePPTypes", "=", "$", "this", "->", "configurator", "->", "getPossiblePagePartTypes", "(", ")", ";", "$", "result", "=", "array", "(", ")", ";", "// filter page part types that can only be ...
This getter returns an array holding info on page part types that can be added to the page. The types are filtererd here, based on the amount of page parts of a certain type that can be added to the page. @return array
[ "This", "getter", "returns", "an", "array", "holding", "info", "on", "page", "part", "types", "that", "can", "be", "added", "to", "the", "page", ".", "The", "types", "are", "filtererd", "here", "based", "on", "the", "amount", "of", "page", "parts", "of",...
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/PagePartBundle/PagePartAdmin/PagePartAdmin.php#L303-L331
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Helper/FormHelper.php
FormHelper.hasRecursiveErrorMessages
public function hasRecursiveErrorMessages(FormView $formView) { $errors = $formView->vars['errors']; if (is_object($errors) && $errors instanceof \Traversable) { $errors = iterator_to_array($errors); } if (!empty($errors)) { return true; } if ($formView->count()) { foreach ($formView->children as $child) { if ($this->hasRecursiveErrorMessages($child)) { return true; } } } return false; }
php
public function hasRecursiveErrorMessages(FormView $formView) { $errors = $formView->vars['errors']; if (is_object($errors) && $errors instanceof \Traversable) { $errors = iterator_to_array($errors); } if (!empty($errors)) { return true; } if ($formView->count()) { foreach ($formView->children as $child) { if ($this->hasRecursiveErrorMessages($child)) { return true; } } } return false; }
[ "public", "function", "hasRecursiveErrorMessages", "(", "FormView", "$", "formView", ")", "{", "$", "errors", "=", "$", "formView", "->", "vars", "[", "'errors'", "]", ";", "if", "(", "is_object", "(", "$", "errors", ")", "&&", "$", "errors", "instanceof",...
Return if there are error messages. @param FormView $formView @return bool
[ "Return", "if", "there", "are", "error", "messages", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Helper/FormHelper.php#L20-L41
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/NodeMenuItem.php
NodeMenuItem.getChildOfClass
public function getChildOfClass($class) { // Check for namespace alias if (strpos($class, ':') !== false) { list($namespaceAlias, $simpleClassName) = explode(':', $class); $class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; } foreach ($this->getChildren() as $child) { if ($child->getPage() instanceof $class) { return $child; } } return null; }
php
public function getChildOfClass($class) { // Check for namespace alias if (strpos($class, ':') !== false) { list($namespaceAlias, $simpleClassName) = explode(':', $class); $class = $this->em->getConfiguration()->getEntityNamespace($namespaceAlias) . '\\' . $simpleClassName; } foreach ($this->getChildren() as $child) { if ($child->getPage() instanceof $class) { return $child; } } return null; }
[ "public", "function", "getChildOfClass", "(", "$", "class", ")", "{", "// Check for namespace alias", "if", "(", "strpos", "(", "$", "class", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "namespaceAlias", ",", "$", "simpleClassName", ")", "...
Get the first child of class, this is not using the getChildrenOfClass method for performance reasons @param string $class @return NodeMenuItem
[ "Get", "the", "first", "child", "of", "class", "this", "is", "not", "using", "the", "getChildrenOfClass", "method", "for", "performance", "reasons" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/NodeMenuItem.php#L260-L274
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/EventListener/SlugSecurityListener.php
SlugSecurityListener.onSlugSecurityEvent
public function onSlugSecurityEvent(SlugSecurityEvent $event) { $node = $event->getNode(); $nodeTranslation = $event->getNodeTranslation(); $request = $event->getRequest(); if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_VIEW, $node)) { throw new AccessDeniedException( 'You do not have sufficient rights to access this page.' ); } $isPreview = $request->attributes->get('preview'); if (!$isPreview && !$nodeTranslation->isOnline()) { throw new NotFoundHttpException('The requested page is not online'); } $nodeMenu = $this->nodeMenu; $nodeMenu->setLocale($nodeTranslation->getLang()); $nodeMenu->setCurrentNode($node); $nodeMenu->setIncludeOffline($isPreview); $request->attributes->set('_nodeMenu', $nodeMenu); }
php
public function onSlugSecurityEvent(SlugSecurityEvent $event) { $node = $event->getNode(); $nodeTranslation = $event->getNodeTranslation(); $request = $event->getRequest(); if (false === $this->authorizationChecker->isGranted(PermissionMap::PERMISSION_VIEW, $node)) { throw new AccessDeniedException( 'You do not have sufficient rights to access this page.' ); } $isPreview = $request->attributes->get('preview'); if (!$isPreview && !$nodeTranslation->isOnline()) { throw new NotFoundHttpException('The requested page is not online'); } $nodeMenu = $this->nodeMenu; $nodeMenu->setLocale($nodeTranslation->getLang()); $nodeMenu->setCurrentNode($node); $nodeMenu->setIncludeOffline($isPreview); $request->attributes->set('_nodeMenu', $nodeMenu); }
[ "public", "function", "onSlugSecurityEvent", "(", "SlugSecurityEvent", "$", "event", ")", "{", "$", "node", "=", "$", "event", "->", "getNode", "(", ")", ";", "$", "nodeTranslation", "=", "$", "event", "->", "getNodeTranslation", "(", ")", ";", "$", "reque...
Perform basic security checks @param SlugSecurityEvent $event @throws AccessDeniedException @throws NotFoundHttpException
[ "Perform", "basic", "security", "checks" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/EventListener/SlugSecurityListener.php#L53-L77
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Command/CreateGroupCommand.php
CreateGroupCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { if (null === $this->em) { $this->em = $this->getContainer()->get('doctrine.orm.entity_manager'); } $groupName = $input->getArgument('group'); $roleNames = $input->getOption('role'); $group = new Group($groupName); if (!empty($roleNames)) { // Roles were provided, so attach them to the group $roleNames = explode(',', strtoupper($roleNames)); foreach ($roleNames as $roleName) { if ('ROLE_' != substr($roleName, 0, 5)) { $roleName = 'ROLE_' . $roleName; } /* @var Role $role */ $role = $this->em->getRepository('KunstmaanAdminBundle:Role')->findOneBy(array('role' => $roleName)); $group->addRole($role); } } $this->em->persist($group); $this->em->flush(); $output->writeln(sprintf('Created group <comment>%s</comment>', $groupName)); }
php
protected function execute(InputInterface $input, OutputInterface $output) { if (null === $this->em) { $this->em = $this->getContainer()->get('doctrine.orm.entity_manager'); } $groupName = $input->getArgument('group'); $roleNames = $input->getOption('role'); $group = new Group($groupName); if (!empty($roleNames)) { // Roles were provided, so attach them to the group $roleNames = explode(',', strtoupper($roleNames)); foreach ($roleNames as $roleName) { if ('ROLE_' != substr($roleName, 0, 5)) { $roleName = 'ROLE_' . $roleName; } /* @var Role $role */ $role = $this->em->getRepository('KunstmaanAdminBundle:Role')->findOneBy(array('role' => $roleName)); $group->addRole($role); } } $this->em->persist($group); $this->em->flush(); $output->writeln(sprintf('Created group <comment>%s</comment>', $groupName)); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "if", "(", "null", "===", "$", "this", "->", "em", ")", "{", "$", "this", "->", "em", "=", "$", "this", "->", "getContainer", "(",...
Executes the current command @param InputInterface $input The input @param OutputInterface $output The output @return int
[ "Executes", "the", "current", "command" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Command/CreateGroupCommand.php#L83-L109
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/DataFixtures/ORM/RoleFixtures.php
RoleFixtures.createRole
private function createRole(ObjectManager $manager, $name) { $role = new Role($name); $manager->persist($role); return $role; }
php
private function createRole(ObjectManager $manager, $name) { $role = new Role($name); $manager->persist($role); return $role; }
[ "private", "function", "createRole", "(", "ObjectManager", "$", "manager", ",", "$", "name", ")", "{", "$", "role", "=", "new", "Role", "(", "$", "name", ")", ";", "$", "manager", "->", "persist", "(", "$", "role", ")", ";", "return", "$", "role", ...
Create a role @param ObjectManager $manager The object manager @param string $name The name of the role @return Role
[ "Create", "a", "role" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/DataFixtures/ORM/RoleFixtures.php#L48-L54
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/UtilitiesBundle/Helper/Cipher/Cipher.php
Cipher.encrypt
public function encrypt($value, $raw_binary = false) { return Crypto::encryptWithPassword($value, $this->secret, $raw_binary); }
php
public function encrypt($value, $raw_binary = false) { return Crypto::encryptWithPassword($value, $this->secret, $raw_binary); }
[ "public", "function", "encrypt", "(", "$", "value", ",", "$", "raw_binary", "=", "false", ")", "{", "return", "Crypto", "::", "encryptWithPassword", "(", "$", "value", ",", "$", "this", "->", "secret", ",", "$", "raw_binary", ")", ";", "}" ]
Encrypt the given value to an unreadable string. @param string $value @param bool $raw_binary @return string @throws \Defuse\Crypto\Exception\EnvironmentIsBrokenException
[ "Encrypt", "the", "given", "value", "to", "an", "unreadable", "string", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/UtilitiesBundle/Helper/Cipher/Cipher.php#L43-L46
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/TranslatorBundle/DataFixtures/ORM/TranslationFixtures.php
TranslationFixtures.hasFixtureInstalled
public function hasFixtureInstalled($domain, $keyword, $locale) { $criteria = array('domain' => $domain, 'keyword' => $keyword, 'locale' => $locale); return $this->repo->findOneBy($criteria) instanceof Entity; }
php
public function hasFixtureInstalled($domain, $keyword, $locale) { $criteria = array('domain' => $domain, 'keyword' => $keyword, 'locale' => $locale); return $this->repo->findOneBy($criteria) instanceof Entity; }
[ "public", "function", "hasFixtureInstalled", "(", "$", "domain", ",", "$", "keyword", ",", "$", "locale", ")", "{", "$", "criteria", "=", "array", "(", "'domain'", "=>", "$", "domain", ",", "'keyword'", "=>", "$", "keyword", ",", "'locale'", "=>", "$", ...
Checks if the specified translation is installed. @param string $domain @param string $keyword @param string $locale @return bool
[ "Checks", "if", "the", "specified", "translation", "is", "installed", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/TranslatorBundle/DataFixtures/ORM/TranslationFixtures.php#L66-L71
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/defaultsite/Entity/PageParts/UspPagePart.php
UspPagePart.deepClone
public function deepClone() { $items = $this->getItems(); $this->items = new ArrayCollection(); foreach ($items as $item) { $cloneItem = clone $item; $this->addItem($cloneItem); } }
php
public function deepClone() { $items = $this->getItems(); $this->items = new ArrayCollection(); foreach ($items as $item) { $cloneItem = clone $item; $this->addItem($cloneItem); } }
[ "public", "function", "deepClone", "(", ")", "{", "$", "items", "=", "$", "this", "->", "getItems", "(", ")", ";", "$", "this", "->", "items", "=", "new", "ArrayCollection", "(", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", ...
When cloning this entity, we must also clone all entities in the ArrayCollection
[ "When", "cloning", "this", "entity", "we", "must", "also", "clone", "all", "entities", "in", "the", "ArrayCollection" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Resources/SensioGeneratorBundle/skeleton/defaultsite/Entity/PageParts/UspPagePart.php#L93-L101
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/PageGenerator.php
PageGenerator.generate
public function generate( BundleInterface $bundle, $entity, $prefix, array $fields, $template, array $sections, array $parentPages ) { $this->bundle = $bundle; $this->entity = $entity; $this->prefix = $prefix; $this->fields = $fields; $this->template = $template; $this->sections = $sections; $this->parentPages = $parentPages; $this->generatePageEntity(); $this->generatePageFormType(); $this->generatePageTemplateConfiguration(); $this->updateParentPages(); }
php
public function generate( BundleInterface $bundle, $entity, $prefix, array $fields, $template, array $sections, array $parentPages ) { $this->bundle = $bundle; $this->entity = $entity; $this->prefix = $prefix; $this->fields = $fields; $this->template = $template; $this->sections = $sections; $this->parentPages = $parentPages; $this->generatePageEntity(); $this->generatePageFormType(); $this->generatePageTemplateConfiguration(); $this->updateParentPages(); }
[ "public", "function", "generate", "(", "BundleInterface", "$", "bundle", ",", "$", "entity", ",", "$", "prefix", ",", "array", "$", "fields", ",", "$", "template", ",", "array", "$", "sections", ",", "array", "$", "parentPages", ")", "{", "$", "this", ...
Generate the page. @param BundleInterface $bundle The bundle @param string $entity The entity name @param string $prefix The database prefix @param array $fields The fields @param string $template The page template @param array $sections The page sections @param array $parentPages The parent pages @throws \RuntimeException
[ "Generate", "the", "page", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/PageGenerator.php#L60-L81
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/PageGenerator.php
PageGenerator.generatePageEntity
private function generatePageEntity() { list($entityCode, $entityPath) = $this->generateEntity( $this->bundle, $this->entity, $this->fields, 'Pages', $this->prefix, 'Kunstmaan\NodeBundle\Entity\AbstractPage' ); // Add implements HasPageTemplateInterface $search = 'extends \Kunstmaan\NodeBundle\Entity\AbstractPage'; $entityCode = str_replace( $search, $search . ' implements \Kunstmaan\PagePartBundle\Helper\HasPageTemplateInterface', $entityCode ); // Add some extra functions in the generated entity :s $params = array( 'bundle' => $this->bundle->getName(), 'page' => $this->entity, 'template' => substr($this->template, 0, strpos($this->template, '.')), 'sections' => array_map( function ($val) { return substr($val, 0, strpos($val, '.')); }, $this->sections ), 'adminType' => '\\' . $this->bundle->getNamespace() . '\\Form\\Pages\\' . $this->entity . 'AdminType', 'namespace' => $this->registry->getAliasNamespace($this->bundle->getName()) . '\\Pages\\' . $this->entity, 'isV4' => $this->isSymfony4(), ); $extraCode = $this->render('/Entity/Pages/ExtraFunctions.php', $params); $pos = strrpos($entityCode, "\n}"); $trimmed = substr($entityCode, 0, $pos); $entityCode = $trimmed."\n\n".$extraCode."\n}\n"; // Write class to filesystem $this->filesystem->mkdir(dirname($entityPath)); file_put_contents($entityPath, $entityCode); $this->assistant->writeLine('Generating entity : <info>OK</info>'); }
php
private function generatePageEntity() { list($entityCode, $entityPath) = $this->generateEntity( $this->bundle, $this->entity, $this->fields, 'Pages', $this->prefix, 'Kunstmaan\NodeBundle\Entity\AbstractPage' ); // Add implements HasPageTemplateInterface $search = 'extends \Kunstmaan\NodeBundle\Entity\AbstractPage'; $entityCode = str_replace( $search, $search . ' implements \Kunstmaan\PagePartBundle\Helper\HasPageTemplateInterface', $entityCode ); // Add some extra functions in the generated entity :s $params = array( 'bundle' => $this->bundle->getName(), 'page' => $this->entity, 'template' => substr($this->template, 0, strpos($this->template, '.')), 'sections' => array_map( function ($val) { return substr($val, 0, strpos($val, '.')); }, $this->sections ), 'adminType' => '\\' . $this->bundle->getNamespace() . '\\Form\\Pages\\' . $this->entity . 'AdminType', 'namespace' => $this->registry->getAliasNamespace($this->bundle->getName()) . '\\Pages\\' . $this->entity, 'isV4' => $this->isSymfony4(), ); $extraCode = $this->render('/Entity/Pages/ExtraFunctions.php', $params); $pos = strrpos($entityCode, "\n}"); $trimmed = substr($entityCode, 0, $pos); $entityCode = $trimmed."\n\n".$extraCode."\n}\n"; // Write class to filesystem $this->filesystem->mkdir(dirname($entityPath)); file_put_contents($entityPath, $entityCode); $this->assistant->writeLine('Generating entity : <info>OK</info>'); }
[ "private", "function", "generatePageEntity", "(", ")", "{", "list", "(", "$", "entityCode", ",", "$", "entityPath", ")", "=", "$", "this", "->", "generateEntity", "(", "$", "this", "->", "bundle", ",", "$", "this", "->", "entity", ",", "$", "this", "->...
Generate the page entity. @throws \RuntimeException
[ "Generate", "the", "page", "entity", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/PageGenerator.php#L88-L133
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Generator/PageGenerator.php
PageGenerator.generatePageTemplateConfiguration
private function generatePageTemplateConfiguration() { $this->installDefaultPageTemplates($this->bundle); $this->installDefaultPagePartConfiguration($this->bundle); $this->assistant->writeLine('Generating template configuration : <info>OK</info>'); }
php
private function generatePageTemplateConfiguration() { $this->installDefaultPageTemplates($this->bundle); $this->installDefaultPagePartConfiguration($this->bundle); $this->assistant->writeLine('Generating template configuration : <info>OK</info>'); }
[ "private", "function", "generatePageTemplateConfiguration", "(", ")", "{", "$", "this", "->", "installDefaultPageTemplates", "(", "$", "this", "->", "bundle", ")", ";", "$", "this", "->", "installDefaultPagePartConfiguration", "(", "$", "this", "->", "bundle", ")"...
Generate the page template -and pagepart configuration.
[ "Generate", "the", "page", "template", "-", "and", "pagepart", "configuration", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Generator/PageGenerator.php#L154-L160
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Twig/GoogleAnalyticsTwigExtension.php
GoogleAnalyticsTwigExtension.renderInitialize
public function renderInitialize(\Twig_Environment $environment, $options = null) { if (is_null($options)) { $options = array(); } $defaults = array(); $this->setOptionIfNotSet($defaults, $this->accountVarName, $this->accountId); // Things set in $options will override things set in $defaults. $options = array_merge($defaults, $options); if (!$this->isOptionSet($options, $this->accountVarName)) { throw new \Twig_Error_Runtime( "The google_analytics_initialize function depends on a Google Analytics account ID. You can either pass this along in the initialize_google_analytics function ($this->accountVarName), provide a variable under 'parameters.google.analytics.account_id'." ); } $template = $environment->loadTemplate('KunstmaanSeoBundle:GoogleAnalyticsTwigExtension:init.html.twig'); return $template->render($options); }
php
public function renderInitialize(\Twig_Environment $environment, $options = null) { if (is_null($options)) { $options = array(); } $defaults = array(); $this->setOptionIfNotSet($defaults, $this->accountVarName, $this->accountId); // Things set in $options will override things set in $defaults. $options = array_merge($defaults, $options); if (!$this->isOptionSet($options, $this->accountVarName)) { throw new \Twig_Error_Runtime( "The google_analytics_initialize function depends on a Google Analytics account ID. You can either pass this along in the initialize_google_analytics function ($this->accountVarName), provide a variable under 'parameters.google.analytics.account_id'." ); } $template = $environment->loadTemplate('KunstmaanSeoBundle:GoogleAnalyticsTwigExtension:init.html.twig'); return $template->render($options); }
[ "public", "function", "renderInitialize", "(", "\\", "Twig_Environment", "$", "environment", ",", "$", "options", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "options", ")", ")", "{", "$", "options", "=", "array", "(", ")", ";", "}", "$", ...
Renders the default Google Analytics JavaScript. If the options are not set it'll try and load the account ID from your parameters (google.analytics.account_id) @param $environment \Twig_Environment @param $options array|null Example: {account_id: 'UA-XXXXX-Y'} @return string the HTML rendered @throws \Twig_Error_Runtime when the Google Analytics ID is nowhere to be found
[ "Renders", "the", "default", "Google", "Analytics", "JavaScript", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Twig/GoogleAnalyticsTwigExtension.php#L83-L105
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Twig/GoogleAnalyticsTwigExtension.php
GoogleAnalyticsTwigExtension.setOptionIfNotSet
private function setOptionIfNotSet(&$arr, $option, $value) { if ($this->isOptionSet($arr, $option)) { $arr[$option] = $value; } }
php
private function setOptionIfNotSet(&$arr, $option, $value) { if ($this->isOptionSet($arr, $option)) { $arr[$option] = $value; } }
[ "private", "function", "setOptionIfNotSet", "(", "&", "$", "arr", ",", "$", "option", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isOptionSet", "(", "$", "arr", ",", "$", "option", ")", ")", "{", "$", "arr", "[", "$", "option", "]...
Prefer the given option if already set. Otherwise set the value given. @param array &$arr This is modified in place @param string $option the key in the $arr array @param mixed $value the new value if the option wasn't set already
[ "Prefer", "the", "given", "option", "if", "already", "set", ".", "Otherwise", "set", "the", "value", "given", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Twig/GoogleAnalyticsTwigExtension.php#L131-L136
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractAdminListConfigurator.php
AbstractAdminListConfigurator.resetBuilds
public function resetBuilds() { $this->fields = array(); $this->exportFields = array(); $this->filterBuilder = null; $this->itemActions = array(); $this->listActions = array(); }
php
public function resetBuilds() { $this->fields = array(); $this->exportFields = array(); $this->filterBuilder = null; $this->itemActions = array(); $this->listActions = array(); }
[ "public", "function", "resetBuilds", "(", ")", "{", "$", "this", "->", "fields", "=", "array", "(", ")", ";", "$", "this", "->", "exportFields", "=", "array", "(", ")", ";", "$", "this", "->", "filterBuilder", "=", "null", ";", "$", "this", "->", "...
Reset all built members
[ "Reset", "all", "built", "members" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractAdminListConfigurator.php#L181-L188
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractAdminListConfigurator.php
AbstractAdminListConfigurator.getAddUrlFor
public function getAddUrlFor(array $params = array()) { $params = array_merge($params, $this->getExtraParameters()); $friendlyName = explode('\\', $this->getEntityName()); $friendlyName = array_pop($friendlyName); $re = '/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/'; $a = preg_split($re, $friendlyName); $superFriendlyName = implode(' ', $a); return array( $superFriendlyName => array( 'path' => $this->getPathByConvention($this::SUFFIX_ADD), 'params' => $params, ), ); }
php
public function getAddUrlFor(array $params = array()) { $params = array_merge($params, $this->getExtraParameters()); $friendlyName = explode('\\', $this->getEntityName()); $friendlyName = array_pop($friendlyName); $re = '/(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/'; $a = preg_split($re, $friendlyName); $superFriendlyName = implode(' ', $a); return array( $superFriendlyName => array( 'path' => $this->getPathByConvention($this::SUFFIX_ADD), 'params' => $params, ), ); }
[ "public", "function", "getAddUrlFor", "(", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "this", "->", "getExtraParameters", "(", ")", ")", ";", "$", "friendlyName", "=", "exp...
Configure the types of items you can add @param array $params @return array
[ "Configure", "the", "types", "of", "items", "you", "can", "add" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractAdminListConfigurator.php#L197-L213
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractAdminListConfigurator.php
AbstractAdminListConfigurator.getExportUrl
public function getExportUrl() { $params = $this->getExtraParameters(); return array( 'path' => $this->getPathByConvention($this::SUFFIX_EXPORT), 'params' => array_merge(array('_format' => 'csv'), $params), ); }
php
public function getExportUrl() { $params = $this->getExtraParameters(); return array( 'path' => $this->getPathByConvention($this::SUFFIX_EXPORT), 'params' => array_merge(array('_format' => 'csv'), $params), ); }
[ "public", "function", "getExportUrl", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getExtraParameters", "(", ")", ";", "return", "array", "(", "'path'", "=>", "$", "this", "->", "getPathByConvention", "(", "$", "this", "::", "SUFFIX_EXPORT", ")",...
Get the url to export the listed items @return array
[ "Get", "the", "url", "to", "export", "the", "listed", "items" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminListBundle/AdminList/Configurator/AbstractAdminListConfigurator.php#L220-L228
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/URLHelper.php
URLHelper.replaceUrl
public function replaceUrl($text) { if ($this->isEmailAddress($text)) { $text = sprintf('%s:%s', 'mailto', $text); } if ($this->isInternalLink($text)) { preg_match_all("/\[(([a-z_A-Z\.]+):)?NT([0-9]+)\]/", $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { $map = $this->getNodeTranslationMap(); foreach ($matches as $match) { $nodeTranslationFound = false; $fullTag = $match[0]; $hostId = $match[2]; $hostConfig = $this->domainConfiguration->getFullHostById($hostId); $hostBaseUrl = $this->domainConfiguration->getHostBaseUrl($hostConfig['host']); $nodeTranslationId = $match[3]; foreach ($map as $nodeTranslation) { if ($nodeTranslation['id'] == $nodeTranslationId) { $urlParams = ['url' => $nodeTranslation['url']]; $nodeTranslationFound = true; // Only add locale if multilingual site if ($this->domainConfiguration->isMultiLanguage($hostConfig['host'])) { $urlParams['_locale'] = $nodeTranslation['lang']; } // Only add other site, when having this. if ($hostId) { $urlParams['otherSite'] = $hostId; } $url = $this->router->generate('_slug', $urlParams); $text = str_replace($fullTag, $hostId ? $hostBaseUrl . $url : $url, $text); } } if (!$nodeTranslationFound) { $this->logger->error('No NodeTranslation found in the database when replacing url tag ' . $fullTag); } } } } if ($this->isInternalMediaLink($text)) { preg_match_all("/\[(([a-z_A-Z]+):)?M([0-9]+)\]/", $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { $map = $this->getMediaMap(); foreach ($matches as $match) { $mediaFound = false; $fullTag = $match[0]; $mediaId = $match[3]; foreach ($map as $mediaItem) { if ($mediaItem['id'] == $mediaId) { $mediaFound = true; $text = str_replace($fullTag, $mediaItem['url'], $text); } } if (!$mediaFound) { $this->logger->error('No Media found in the database when replacing url tag ' . $fullTag); } } } } return $text; }
php
public function replaceUrl($text) { if ($this->isEmailAddress($text)) { $text = sprintf('%s:%s', 'mailto', $text); } if ($this->isInternalLink($text)) { preg_match_all("/\[(([a-z_A-Z\.]+):)?NT([0-9]+)\]/", $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { $map = $this->getNodeTranslationMap(); foreach ($matches as $match) { $nodeTranslationFound = false; $fullTag = $match[0]; $hostId = $match[2]; $hostConfig = $this->domainConfiguration->getFullHostById($hostId); $hostBaseUrl = $this->domainConfiguration->getHostBaseUrl($hostConfig['host']); $nodeTranslationId = $match[3]; foreach ($map as $nodeTranslation) { if ($nodeTranslation['id'] == $nodeTranslationId) { $urlParams = ['url' => $nodeTranslation['url']]; $nodeTranslationFound = true; // Only add locale if multilingual site if ($this->domainConfiguration->isMultiLanguage($hostConfig['host'])) { $urlParams['_locale'] = $nodeTranslation['lang']; } // Only add other site, when having this. if ($hostId) { $urlParams['otherSite'] = $hostId; } $url = $this->router->generate('_slug', $urlParams); $text = str_replace($fullTag, $hostId ? $hostBaseUrl . $url : $url, $text); } } if (!$nodeTranslationFound) { $this->logger->error('No NodeTranslation found in the database when replacing url tag ' . $fullTag); } } } } if ($this->isInternalMediaLink($text)) { preg_match_all("/\[(([a-z_A-Z]+):)?M([0-9]+)\]/", $text, $matches, PREG_SET_ORDER); if (count($matches) > 0) { $map = $this->getMediaMap(); foreach ($matches as $match) { $mediaFound = false; $fullTag = $match[0]; $mediaId = $match[3]; foreach ($map as $mediaItem) { if ($mediaItem['id'] == $mediaId) { $mediaFound = true; $text = str_replace($fullTag, $mediaItem['url'], $text); } } if (!$mediaFound) { $this->logger->error('No Media found in the database when replacing url tag ' . $fullTag); } } } } return $text; }
[ "public", "function", "replaceUrl", "(", "$", "text", ")", "{", "if", "(", "$", "this", "->", "isEmailAddress", "(", "$", "text", ")", ")", "{", "$", "text", "=", "sprintf", "(", "'%s:%s'", ",", "'mailto'", ",", "$", "text", ")", ";", "}", "if", ...
Replace a given text, according to the node translation id and the multidomain site id. @param $text @return mixed
[ "Replace", "a", "given", "text", "according", "to", "the", "node", "translation", "id", "and", "the", "multidomain", "site", "id", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/URLHelper.php#L69-L141
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/URLHelper.php
URLHelper.getNodeTranslationMap
private function getNodeTranslationMap() { if (is_null($this->nodeTranslationMap)) { $sql = 'SELECT id, url, lang FROM kuma_node_translations'; $stmt = $this->em->getConnection()->prepare($sql); $stmt->execute(); $this->nodeTranslationMap = $stmt->fetchAll(); } return $this->nodeTranslationMap; }
php
private function getNodeTranslationMap() { if (is_null($this->nodeTranslationMap)) { $sql = 'SELECT id, url, lang FROM kuma_node_translations'; $stmt = $this->em->getConnection()->prepare($sql); $stmt->execute(); $this->nodeTranslationMap = $stmt->fetchAll(); } return $this->nodeTranslationMap; }
[ "private", "function", "getNodeTranslationMap", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "nodeTranslationMap", ")", ")", "{", "$", "sql", "=", "'SELECT id, url, lang FROM kuma_node_translations'", ";", "$", "stmt", "=", "$", "this", "->", "...
Get a map of all node translations. Only called once for caching. @return array|null @throws \Doctrine\DBAL\DBALException
[ "Get", "a", "map", "of", "all", "node", "translations", ".", "Only", "called", "once", "for", "caching", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/URLHelper.php#L150-L160
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Helper/URLHelper.php
URLHelper.getMediaMap
private function getMediaMap() { if (is_null($this->mediaMap)) { $sql = 'SELECT id, url FROM kuma_media'; $stmt = $this->em->getConnection()->prepare($sql); $stmt->execute(); $this->mediaMap = $stmt->fetchAll(); } return $this->mediaMap; }
php
private function getMediaMap() { if (is_null($this->mediaMap)) { $sql = 'SELECT id, url FROM kuma_media'; $stmt = $this->em->getConnection()->prepare($sql); $stmt->execute(); $this->mediaMap = $stmt->fetchAll(); } return $this->mediaMap; }
[ "private", "function", "getMediaMap", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "mediaMap", ")", ")", "{", "$", "sql", "=", "'SELECT id, url FROM kuma_media'", ";", "$", "stmt", "=", "$", "this", "->", "em", "->", "getConnection", "(",...
Get a map of all media items. Only called once for caching. @return array|null @throws \Doctrine\DBAL\DBALException
[ "Get", "a", "map", "of", "all", "media", "items", ".", "Only", "called", "once", "for", "caching", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Helper/URLHelper.php#L169-L179
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/DashboardBundle/Repository/AnalyticsOverviewRepository.php
AnalyticsOverviewRepository.addOverviews
public function addOverviews(&$config, &$segment = null) { $em = $this->getEntityManager(); $today = new AnalyticsOverview(); $today->setTitle('dashboard.ga.tab.today'); $today->setTimespan(0); $today->setStartOffset(0); $today->setConfig($config); $today->setSegment($segment); $em->persist($today); $yesterday = new AnalyticsOverview(); $yesterday->setTitle('dashboard.ga.tab.yesterday'); $yesterday->setTimespan(1); $yesterday->setStartOffset(1); $yesterday->setConfig($config); $yesterday->setSegment($segment); $em->persist($yesterday); $week = new AnalyticsOverview(); $week->setTitle('dashboard.ga.tab.last_7_days'); $week->setTimespan(7); $week->setStartOffset(1); $week->setConfig($config); $week->setSegment($segment); $em->persist($week); $month = new AnalyticsOverview(); $month->setTitle('dashboard.ga.tab.last_30_days'); $month->setTimespan(30); $month->setStartOffset(1); $month->setConfig($config); $month->setSegment($segment); $em->persist($month); $year = new AnalyticsOverview(); $year->setTitle('dashboard.ga.tab.last_12_months'); $year->setTimespan(365); $year->setStartOffset(1); $year->setConfig($config); $year->setSegment($segment); $em->persist($year); $yearToDate = new AnalyticsOverview(); $yearToDate->setTitle('dashboard.ga.tab.year_to_date'); $yearToDate->setTimespan(365); $yearToDate->setStartOffset(1); $yearToDate->setConfig($config); $yearToDate->setSegment($segment); $yearToDate->setUseYear(true); $em->persist($yearToDate); $em->flush(); }
php
public function addOverviews(&$config, &$segment = null) { $em = $this->getEntityManager(); $today = new AnalyticsOverview(); $today->setTitle('dashboard.ga.tab.today'); $today->setTimespan(0); $today->setStartOffset(0); $today->setConfig($config); $today->setSegment($segment); $em->persist($today); $yesterday = new AnalyticsOverview(); $yesterday->setTitle('dashboard.ga.tab.yesterday'); $yesterday->setTimespan(1); $yesterday->setStartOffset(1); $yesterday->setConfig($config); $yesterday->setSegment($segment); $em->persist($yesterday); $week = new AnalyticsOverview(); $week->setTitle('dashboard.ga.tab.last_7_days'); $week->setTimespan(7); $week->setStartOffset(1); $week->setConfig($config); $week->setSegment($segment); $em->persist($week); $month = new AnalyticsOverview(); $month->setTitle('dashboard.ga.tab.last_30_days'); $month->setTimespan(30); $month->setStartOffset(1); $month->setConfig($config); $month->setSegment($segment); $em->persist($month); $year = new AnalyticsOverview(); $year->setTitle('dashboard.ga.tab.last_12_months'); $year->setTimespan(365); $year->setStartOffset(1); $year->setConfig($config); $year->setSegment($segment); $em->persist($year); $yearToDate = new AnalyticsOverview(); $yearToDate->setTitle('dashboard.ga.tab.year_to_date'); $yearToDate->setTimespan(365); $yearToDate->setStartOffset(1); $yearToDate->setConfig($config); $yearToDate->setSegment($segment); $yearToDate->setUseYear(true); $em->persist($yearToDate); $em->flush(); }
[ "public", "function", "addOverviews", "(", "&", "$", "config", ",", "&", "$", "segment", "=", "null", ")", "{", "$", "em", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "today", "=", "new", "AnalyticsOverview", "(", ")", ";", "$", ...
Add overviews for a config and optionally a segment @param AnalyticsConfig $config @param AnalyticsSegment $segment
[ "Add", "overviews", "for", "a", "config", "and", "optionally", "a", "segment" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/DashboardBundle/Repository/AnalyticsOverviewRepository.php#L36-L90
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MediaBundle/Entity/Folder.php
Folder.addChild
public function addChild(Folder $child) { $this->children[] = $child; $child->setParent($this); return $this; }
php
public function addChild(Folder $child) { $this->children[] = $child; $child->setParent($this); return $this; }
[ "public", "function", "addChild", "(", "Folder", "$", "child", ")", "{", "$", "this", "->", "children", "[", "]", "=", "$", "child", ";", "$", "child", "->", "setParent", "(", "$", "this", ")", ";", "return", "$", "this", ";", "}" ]
Add a child @param Folder $child @return Folder
[ "Add", "a", "child" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Entity/Folder.php#L294-L300
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/Entity/AbstractFormPage.php
AbstractFormPage.generateThankYouUrl
public function generateThankYouUrl(RouterInterface $router, RenderContext $context) { /* @var $nodeTranslation NodeTranslation */ $nodeTranslation = $context['nodetranslation']; return $router->generate('_slug', array( 'url' => $context['slug'], '_locale' => $nodeTranslation->getLang(), 'thanks' => true, )); }
php
public function generateThankYouUrl(RouterInterface $router, RenderContext $context) { /* @var $nodeTranslation NodeTranslation */ $nodeTranslation = $context['nodetranslation']; return $router->generate('_slug', array( 'url' => $context['slug'], '_locale' => $nodeTranslation->getLang(), 'thanks' => true, )); }
[ "public", "function", "generateThankYouUrl", "(", "RouterInterface", "$", "router", ",", "RenderContext", "$", "context", ")", "{", "/* @var $nodeTranslation NodeTranslation */", "$", "nodeTranslation", "=", "$", "context", "[", "'nodetranslation'", "]", ";", "return", ...
Generate the url of the thank you page @param RouterInterface $router The router @param RenderContext $context The render context @return string
[ "Generate", "the", "url", "of", "the", "thank", "you", "page" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Entity/AbstractFormPage.php#L158-L168
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Repository/NodeVersionLockRepository.php
NodeVersionLockRepository.getLocksForNodeTranslation
public function getLocksForNodeTranslation(NodeTranslation $nodeTranslation, $isPublicVersion, $threshold, BaseUser $userToExclude = null) { $qb = $this->createQueryBuilder('nvl') ->select('nvl') ->where('nvl.nodeTranslation = :nt') ->andWhere('nvl.publicVersion = :pub') ->andWhere('nvl.createdAt > :date') ->setParameter('nt', $nodeTranslation) ->setParameter('pub', $isPublicVersion) ->setParameter('date', new \DateTime(sprintf('-%s seconds', $threshold))) ; if (!is_null($userToExclude)) { $qb->andWhere('nvl.owner <> :owner') ->setParameter('owner', $userToExclude->getUsername()) ; } return $qb->getQuery()->getResult(); }
php
public function getLocksForNodeTranslation(NodeTranslation $nodeTranslation, $isPublicVersion, $threshold, BaseUser $userToExclude = null) { $qb = $this->createQueryBuilder('nvl') ->select('nvl') ->where('nvl.nodeTranslation = :nt') ->andWhere('nvl.publicVersion = :pub') ->andWhere('nvl.createdAt > :date') ->setParameter('nt', $nodeTranslation) ->setParameter('pub', $isPublicVersion) ->setParameter('date', new \DateTime(sprintf('-%s seconds', $threshold))) ; if (!is_null($userToExclude)) { $qb->andWhere('nvl.owner <> :owner') ->setParameter('owner', $userToExclude->getUsername()) ; } return $qb->getQuery()->getResult(); }
[ "public", "function", "getLocksForNodeTranslation", "(", "NodeTranslation", "$", "nodeTranslation", ",", "$", "isPublicVersion", ",", "$", "threshold", ",", "BaseUser", "$", "userToExclude", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryB...
Check if there is a nodetranslation lock that's not passed the 30 minute threshold. @param NodeTranslation $nodeTranslation @param bool $isPublicVersion @param int $threshold @param BaseUser $userToExclude @return NodeVersionLock[]
[ "Check", "if", "there", "is", "a", "nodetranslation", "lock", "that", "s", "not", "passed", "the", "30", "minute", "threshold", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Repository/NodeVersionLockRepository.php#L27-L46
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/LeadGenerationBundle/Service/PopupManager.php
PopupManager.getPopups
public function getPopups() { if (is_null($this->popups)) { $this->popups = $this->em->getRepository('KunstmaanLeadGenerationBundle:Popup\AbstractPopup')->findAll(); } return $this->popups; }
php
public function getPopups() { if (is_null($this->popups)) { $this->popups = $this->em->getRepository('KunstmaanLeadGenerationBundle:Popup\AbstractPopup')->findAll(); } return $this->popups; }
[ "public", "function", "getPopups", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "popups", ")", ")", "{", "$", "this", "->", "popups", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'KunstmaanLeadGenerationBundle:Popup\\AbstractPop...
Get a list of popup definitions. @return array
[ "Get", "a", "list", "of", "popup", "definitions", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/LeadGenerationBundle/Service/PopupManager.php#L33-L40
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/LeadGenerationBundle/Service/PopupManager.php
PopupManager.getUniqueJsIncludes
public function getUniqueJsIncludes() { $includes = array(); foreach ($this->getPopups() as $popup) { foreach ($popup->getRules() as $rule) { $includes[] = $rule->getJsFilePath(); } } return array_unique($includes); }
php
public function getUniqueJsIncludes() { $includes = array(); foreach ($this->getPopups() as $popup) { foreach ($popup->getRules() as $rule) { $includes[] = $rule->getJsFilePath(); } } return array_unique($includes); }
[ "public", "function", "getUniqueJsIncludes", "(", ")", "{", "$", "includes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getPopups", "(", ")", "as", "$", "popup", ")", "{", "foreach", "(", "$", "popup", "->", "getRules", "(", ")"...
Get a list of unique javascript files that should be included in the html. @return array
[ "Get", "a", "list", "of", "unique", "javascript", "files", "that", "should", "be", "included", "in", "the", "html", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/LeadGenerationBundle/Service/PopupManager.php#L47-L57
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MenuBundle/Twig/MenuTwigExtension.php
MenuTwigExtension.getMenu
public function getMenu(\Twig_Environment $environment, $name, $lang, $options = array()) { $options = array_merge($this->getDefaultOptions(), $options); $renderService = $this->renderService; $options['nodeDecorator'] = function ($node) use ($environment, $renderService, $options) { return $renderService->renderMenuItemTemplate($environment, $node, $options); }; $arrayResult = $this->getMenuItems($name, $lang); $html = $this->repository->buildTree($arrayResult, $options); return $html; }
php
public function getMenu(\Twig_Environment $environment, $name, $lang, $options = array()) { $options = array_merge($this->getDefaultOptions(), $options); $renderService = $this->renderService; $options['nodeDecorator'] = function ($node) use ($environment, $renderService, $options) { return $renderService->renderMenuItemTemplate($environment, $node, $options); }; $arrayResult = $this->getMenuItems($name, $lang); $html = $this->repository->buildTree($arrayResult, $options); return $html; }
[ "public", "function", "getMenu", "(", "\\", "Twig_Environment", "$", "environment", ",", "$", "name", ",", "$", "lang", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "$", "this", "->", "getDefaultOptions"...
Get a html representation of a menu. @param string $name @param string $lang @param array $options @return string
[ "Get", "a", "html", "representation", "of", "a", "menu", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MenuBundle/Twig/MenuTwigExtension.php#L60-L73
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MenuBundle/Twig/MenuTwigExtension.php
MenuTwigExtension.getMenuItems
public function getMenuItems($name, $lang) { /** @var MenuItem $menuRepo */ $arrayResult = $this->repository->getMenuItemsForLanguage($name, $lang); // Make sure the parent item is not offline $foundIds = array(); foreach ($arrayResult as $array) { $foundIds[] = $array['id']; } foreach ($arrayResult as $key => $array) { if (!is_null($array['parent']) && !in_array($array['parent']['id'], $foundIds)) { unset($arrayResult[$key]); } } return $arrayResult; }
php
public function getMenuItems($name, $lang) { /** @var MenuItem $menuRepo */ $arrayResult = $this->repository->getMenuItemsForLanguage($name, $lang); // Make sure the parent item is not offline $foundIds = array(); foreach ($arrayResult as $array) { $foundIds[] = $array['id']; } foreach ($arrayResult as $key => $array) { if (!is_null($array['parent']) && !in_array($array['parent']['id'], $foundIds)) { unset($arrayResult[$key]); } } return $arrayResult; }
[ "public", "function", "getMenuItems", "(", "$", "name", ",", "$", "lang", ")", "{", "/** @var MenuItem $menuRepo */", "$", "arrayResult", "=", "$", "this", "->", "repository", "->", "getMenuItemsForLanguage", "(", "$", "name", ",", "$", "lang", ")", ";", "//...
Get an array with menu items of a menu. @param string $name @param string $lang @return array
[ "Get", "an", "array", "with", "menu", "items", "of", "a", "menu", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MenuBundle/Twig/MenuTwigExtension.php#L83-L100
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Twig/LocaleSwitcherTwigExtension.php
LocaleSwitcherTwigExtension.renderWidget
public function renderWidget(\Twig_Environment $env, $locales, $route, array $parameters = array()) { $template = $env->loadTemplate( 'KunstmaanAdminBundle:LocaleSwitcherTwigExtension:widget.html.twig' ); return $template->render( array_merge( $parameters, array( 'locales' => $locales, 'route' => $route, ) ) ); }
php
public function renderWidget(\Twig_Environment $env, $locales, $route, array $parameters = array()) { $template = $env->loadTemplate( 'KunstmaanAdminBundle:LocaleSwitcherTwigExtension:widget.html.twig' ); return $template->render( array_merge( $parameters, array( 'locales' => $locales, 'route' => $route, ) ) ); }
[ "public", "function", "renderWidget", "(", "\\", "Twig_Environment", "$", "env", ",", "$", "locales", ",", "$", "route", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "template", "=", "$", "env", "->", "loadTemplate", "(", "'K...
Render locale switcher widget. @param \Twig_Environment $env @param array $locales The locales @param string $route The route @param array $parameters The route parameters @return string
[ "Render", "locale", "switcher", "widget", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Twig/LocaleSwitcherTwigExtension.php#L49-L64
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/BehatBundle/Features/Context/FeatureContext.php
FeatureContext.hiddenFieldValueEquals
public function hiddenFieldValueEquals($field, $value) { $node = $this->findHiddenField($field); $actual = $node->getValue(); $regex = '/^' . preg_quote($value, '/') . '/ui'; if (!preg_match($regex, $actual)) { $message = sprintf('The hidden field "%s" value is "%s", but "%s" expected.', $field, $actual, $value); throw new ExpectationException($message, $this->getSession()); } }
php
public function hiddenFieldValueEquals($field, $value) { $node = $this->findHiddenField($field); $actual = $node->getValue(); $regex = '/^' . preg_quote($value, '/') . '/ui'; if (!preg_match($regex, $actual)) { $message = sprintf('The hidden field "%s" value is "%s", but "%s" expected.', $field, $actual, $value); throw new ExpectationException($message, $this->getSession()); } }
[ "public", "function", "hiddenFieldValueEquals", "(", "$", "field", ",", "$", "value", ")", "{", "$", "node", "=", "$", "this", "->", "findHiddenField", "(", "$", "field", ")", ";", "$", "actual", "=", "$", "node", "->", "getValue", "(", ")", ";", "$"...
Checks that form hidden field with specified id|name has specified value. @Then /^the "(?P<field>(?:[^"]|\\")*)" hidden field should contain "(?P<value>(?:[^"]|\\")*)"$/
[ "Checks", "that", "form", "hidden", "field", "with", "specified", "id|name", "has", "specified", "value", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/BehatBundle/Features/Context/FeatureContext.php#L38-L49
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/NodeBundle/Controller/UrlReplaceController.php
UrlReplaceController.replaceURLAction
public function replaceURLAction(Request $request) { $response = new JsonResponse(); $response->setData(['text' => $this->urlHelper->replaceUrl($request->get('text'))]); return $response; }
php
public function replaceURLAction(Request $request) { $response = new JsonResponse(); $response->setData(['text' => $this->urlHelper->replaceUrl($request->get('text'))]); return $response; }
[ "public", "function", "replaceURLAction", "(", "Request", "$", "request", ")", "{", "$", "response", "=", "new", "JsonResponse", "(", ")", ";", "$", "response", "->", "setData", "(", "[", "'text'", "=>", "$", "this", "->", "urlHelper", "->", "replaceUrl", ...
Render a url with the twig url replace filter @Route("/replace", name="KunstmaanNodeBundle_urlchooser_replace", condition="request.isXmlHttpRequest()")
[ "Render", "a", "url", "with", "the", "twig", "url", "replace", "filter" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/NodeBundle/Controller/UrlReplaceController.php#L33-L40
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SeoBundle/Twig/SeoTwigExtension.php
SeoTwigExtension.getTitleFor
public function getTitleFor(AbstractPage $entity) { $arr = array(); $arr[] = $this->getSeoTitle($entity); $arr[] = $entity->getTitle(); return $this->getPreferredValue($arr); }
php
public function getTitleFor(AbstractPage $entity) { $arr = array(); $arr[] = $this->getSeoTitle($entity); $arr[] = $entity->getTitle(); return $this->getPreferredValue($arr); }
[ "public", "function", "getTitleFor", "(", "AbstractPage", "$", "entity", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "$", "arr", "[", "]", "=", "$", "this", "->", "getSeoTitle", "(", "$", "entity", ")", ";", "$", "arr", "[", "]", "=", "$",...
The first value that is not null or empty will be returned. @param AbstractPage $entity the entity for which you want the page title @return string The page title. Will look in the SEO meta first, then the NodeTranslation, then the page.
[ "The", "first", "value", "that", "is", "not", "null", "or", "empty", "will", "be", "returned", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SeoBundle/Twig/SeoTwigExtension.php#L118-L127
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/AdminBundle/Twig/DateByLocaleExtension.php
DateByLocaleExtension.localeDateFilter
public static function localeDateFilter($date, $locale = 'nl', $dateType = 'medium', $timeType = 'none', $pattern = null) { $values = array( 'none' => DateFormatter::NONE, 'short' => DateFormatter::SHORT, 'medium' => DateFormatter::MEDIUM, 'long' => DateFormatter::LONG, 'full' => DateFormatter::FULL, ); if (is_null($pattern)) { $dateFormatter = DateFormatter::create( $locale, $values[$dateType], $values[$timeType], 'Europe/Brussels' ); } else { $dateFormatter = DateFormatter::create( $locale, $values[$dateType], $values[$timeType], 'Europe/Brussels', DateFormatter::GREGORIAN, $pattern ); } return $dateFormatter->format($date); }
php
public static function localeDateFilter($date, $locale = 'nl', $dateType = 'medium', $timeType = 'none', $pattern = null) { $values = array( 'none' => DateFormatter::NONE, 'short' => DateFormatter::SHORT, 'medium' => DateFormatter::MEDIUM, 'long' => DateFormatter::LONG, 'full' => DateFormatter::FULL, ); if (is_null($pattern)) { $dateFormatter = DateFormatter::create( $locale, $values[$dateType], $values[$timeType], 'Europe/Brussels' ); } else { $dateFormatter = DateFormatter::create( $locale, $values[$dateType], $values[$timeType], 'Europe/Brussels', DateFormatter::GREGORIAN, $pattern ); } return $dateFormatter->format($date); }
[ "public", "static", "function", "localeDateFilter", "(", "$", "date", ",", "$", "locale", "=", "'nl'", ",", "$", "dateType", "=", "'medium'", ",", "$", "timeType", "=", "'none'", ",", "$", "pattern", "=", "null", ")", "{", "$", "values", "=", "array", ...
A date formatting filter for Twig, renders the date using the specified parameters. @param mixed $date Unix timestamp to format @param string $locale The locale @param string $dateType The date type @param string $timeType The time type @param string $pattern The pattern to use @return string
[ "A", "date", "formatting", "filter", "for", "Twig", "renders", "the", "date", "using", "the", "specified", "parameters", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/AdminBundle/Twig/DateByLocaleExtension.php#L35-L62
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SitemapBundle/Twig/SitemapTwigExtension.php
SitemapTwigExtension.isHiddenFromSitemap
public function isHiddenFromSitemap(NodeMenuItem $item) { if (is_subclass_of($item->getNode()->getRefEntityName(), 'Kunstmaan\\SitemapBundle\\Helper\\HiddenFromSitemapInterface')) { $page = $item->getPage(); return $page->isHiddenFromSitemap(); } return false; }
php
public function isHiddenFromSitemap(NodeMenuItem $item) { if (is_subclass_of($item->getNode()->getRefEntityName(), 'Kunstmaan\\SitemapBundle\\Helper\\HiddenFromSitemapInterface')) { $page = $item->getPage(); return $page->isHiddenFromSitemap(); } return false; }
[ "public", "function", "isHiddenFromSitemap", "(", "NodeMenuItem", "$", "item", ")", "{", "if", "(", "is_subclass_of", "(", "$", "item", "->", "getNode", "(", ")", "->", "getRefEntityName", "(", ")", ",", "'Kunstmaan\\\\SitemapBundle\\\\Helper\\\\HiddenFromSitemapInter...
Returns true when the item should be hidden from the sitemap @param NodeMenuItem $item @return \Kunstmaan\NodeBundle\Helper\NodeMenuItem
[ "Returns", "true", "when", "the", "item", "should", "be", "hidden", "from", "the", "sitemap" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SitemapBundle/Twig/SitemapTwigExtension.php#L29-L38
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/SitemapBundle/Twig/SitemapTwigExtension.php
SitemapTwigExtension.isHiddenChildrenFromSitemap
public function isHiddenChildrenFromSitemap(NodeMenuItem $item) { if (is_subclass_of($item->getNode()->getRefEntityName(), 'Kunstmaan\\SitemapBundle\\Helper\\HiddenFromSitemapInterface')) { $page = $item->getPage(); return $page->isChildrenHiddenFromSitemap(); } return false; }
php
public function isHiddenChildrenFromSitemap(NodeMenuItem $item) { if (is_subclass_of($item->getNode()->getRefEntityName(), 'Kunstmaan\\SitemapBundle\\Helper\\HiddenFromSitemapInterface')) { $page = $item->getPage(); return $page->isChildrenHiddenFromSitemap(); } return false; }
[ "public", "function", "isHiddenChildrenFromSitemap", "(", "NodeMenuItem", "$", "item", ")", "{", "if", "(", "is_subclass_of", "(", "$", "item", "->", "getNode", "(", ")", "->", "getRefEntityName", "(", ")", ",", "'Kunstmaan\\\\SitemapBundle\\\\Helper\\\\HiddenFromSite...
Returns true when the children of the item should be hidden from the sitemap @param NodeMenuItem $item @return bool
[ "Returns", "true", "when", "the", "children", "of", "the", "item", "should", "be", "hidden", "from", "the", "sitemap" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/SitemapBundle/Twig/SitemapTwigExtension.php#L47-L56
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/GeneratorBundle/Command/GenerateArticleCommand.php
GenerateArticleCommand.doExecute
protected function doExecute() { $this->assistant->writeSection('Article classes generation'); $this->createGenerator()->generate($this->bundle, $this->entity, $this->prefix, $this->getContainer()->getParameter('kunstmaan_admin.multi_language'), $this->usesAuthor, $this->usesCategories, $this->usesTags, $this->bundleWithHomePage, $this->dummydata); $this->assistant->writeSection('Article classes successfully created', 'bg=green;fg=black'); $this->assistant->writeLine(array( 'Make sure you update your database first before you test the pagepart:', ' Directly update your database: <comment>bin/console doctrine:schema:update --force</comment>', ' Create a Doctrine migration and run it: <comment>bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate</comment>', )); }
php
protected function doExecute() { $this->assistant->writeSection('Article classes generation'); $this->createGenerator()->generate($this->bundle, $this->entity, $this->prefix, $this->getContainer()->getParameter('kunstmaan_admin.multi_language'), $this->usesAuthor, $this->usesCategories, $this->usesTags, $this->bundleWithHomePage, $this->dummydata); $this->assistant->writeSection('Article classes successfully created', 'bg=green;fg=black'); $this->assistant->writeLine(array( 'Make sure you update your database first before you test the pagepart:', ' Directly update your database: <comment>bin/console doctrine:schema:update --force</comment>', ' Create a Doctrine migration and run it: <comment>bin/console doctrine:migrations:diff && bin/console doctrine:migrations:migrate</comment>', )); }
[ "protected", "function", "doExecute", "(", ")", "{", "$", "this", "->", "assistant", "->", "writeSection", "(", "'Article classes generation'", ")", ";", "$", "this", "->", "createGenerator", "(", ")", "->", "generate", "(", "$", "this", "->", "bundle", ",",...
This function implements the final execution of the Generator. It calls the execute function with the correct parameters.
[ "This", "function", "implements", "the", "final", "execution", "of", "the", "Generator", ".", "It", "calls", "the", "execute", "function", "with", "the", "correct", "parameters", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/GeneratorBundle/Command/GenerateArticleCommand.php#L211-L223
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MediaBundle/Helper/MediaManager.php
MediaManager.getHandler
public function getHandler($media) { $bestHandler = $this->defaultHandler; foreach ($this->handlers as $handler) { if ($handler->canHandle($media) && $handler->getPriority() > $bestHandler->getPriority()) { $bestHandler = $handler; } } return $bestHandler; }
php
public function getHandler($media) { $bestHandler = $this->defaultHandler; foreach ($this->handlers as $handler) { if ($handler->canHandle($media) && $handler->getPriority() > $bestHandler->getPriority()) { $bestHandler = $handler; } } return $bestHandler; }
[ "public", "function", "getHandler", "(", "$", "media", ")", "{", "$", "bestHandler", "=", "$", "this", "->", "defaultHandler", ";", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "handler", ")", "{", "if", "(", "$", "handler", "->", "canHand...
Returns handler with the highest priority to handle the Media item which can handle the item. If no handler is found, it returns FileHandler @param Media|File $media @return AbstractMediaHandler
[ "Returns", "handler", "with", "the", "highest", "priority", "to", "handle", "the", "Media", "item", "which", "can", "handle", "the", "item", ".", "If", "no", "handler", "is", "found", "it", "returns", "FileHandler" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Helper/MediaManager.php#L55-L65
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MediaBundle/Helper/MediaManager.php
MediaManager.getHandlerForType
public function getHandlerForType($type) { $bestHandler = $this->defaultHandler; foreach ($this->handlers as $handler) { if ($handler->getType() == $type && $handler->getPriority() > $bestHandler->getPriority()) { $bestHandler = $handler; } } return $bestHandler; }
php
public function getHandlerForType($type) { $bestHandler = $this->defaultHandler; foreach ($this->handlers as $handler) { if ($handler->getType() == $type && $handler->getPriority() > $bestHandler->getPriority()) { $bestHandler = $handler; } } return $bestHandler; }
[ "public", "function", "getHandlerForType", "(", "$", "type", ")", "{", "$", "bestHandler", "=", "$", "this", "->", "defaultHandler", ";", "foreach", "(", "$", "this", "->", "handlers", "as", "$", "handler", ")", "{", "if", "(", "$", "handler", "->", "g...
Returns handler with the highest priority to handle the Media item based on the Type. If no handler is found, it returns FileHandler @param string $type @return AbstractMediaHandler
[ "Returns", "handler", "with", "the", "highest", "priority", "to", "handle", "the", "Media", "item", "based", "on", "the", "Type", ".", "If", "no", "handler", "is", "found", "it", "returns", "FileHandler" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Helper/MediaManager.php#L74-L84
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php
FileFormSubmissionField.upload
public function upload($uploadDir, $webDir) { // the file property can be empty if the field is not required if (null === $this->file) { return; } // sanitize filename for security $safeFileName = $this->getSafeFileName($this->file); $uuid = uniqid(); $this->setUuid($uuid); // move takes the target directory and then the target filename to move to $this->file->move(sprintf('%s/%s', $uploadDir, $uuid), $safeFileName); // set the path property to the filename where you'ved saved the file $this->fileName = $safeFileName; // set the url to the uuid directory inside the web dir $this->setUrl(sprintf('%s%s/', $webDir, $uuid) . $safeFileName); // clean up the file property as you won't need it anymore $this->file = null; }
php
public function upload($uploadDir, $webDir) { // the file property can be empty if the field is not required if (null === $this->file) { return; } // sanitize filename for security $safeFileName = $this->getSafeFileName($this->file); $uuid = uniqid(); $this->setUuid($uuid); // move takes the target directory and then the target filename to move to $this->file->move(sprintf('%s/%s', $uploadDir, $uuid), $safeFileName); // set the path property to the filename where you'ved saved the file $this->fileName = $safeFileName; // set the url to the uuid directory inside the web dir $this->setUrl(sprintf('%s%s/', $webDir, $uuid) . $safeFileName); // clean up the file property as you won't need it anymore $this->file = null; }
[ "public", "function", "upload", "(", "$", "uploadDir", ",", "$", "webDir", ")", "{", "// the file property can be empty if the field is not required", "if", "(", "null", "===", "$", "this", "->", "file", ")", "{", "return", ";", "}", "// sanitize filename for securi...
Move the file to the given uploadDir and save the filename @param string $uploadDir
[ "Move", "the", "file", "to", "the", "given", "uploadDir", "and", "save", "the", "filename" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php#L85-L109
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php
FileFormSubmissionField.onValidPost
public function onValidPost(Form $form, FormBuilderInterface $formBuilder, Request $request, ContainerInterface $container) { $uploadDir = $container->getParameter('form_submission_rootdir'); $webDir = $container->getParameter('form_submission_webdir'); $this->upload($uploadDir, $webDir); }
php
public function onValidPost(Form $form, FormBuilderInterface $formBuilder, Request $request, ContainerInterface $container) { $uploadDir = $container->getParameter('form_submission_rootdir'); $webDir = $container->getParameter('form_submission_webdir'); $this->upload($uploadDir, $webDir); }
[ "public", "function", "onValidPost", "(", "Form", "$", "form", ",", "FormBuilderInterface", "$", "formBuilder", ",", "Request", "$", "request", ",", "ContainerInterface", "$", "container", ")", "{", "$", "uploadDir", "=", "$", "container", "->", "getParameter", ...
This function will be triggered if the form was successfully posted. @param Form $form the Form @param FormBuilderInterface $formBuilder the FormBuilder @param Request $request the Request @param ContainerInterface $container the Container
[ "This", "function", "will", "be", "triggered", "if", "the", "form", "was", "successfully", "posted", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php#L119-L124
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php
FileFormSubmissionField.getSafeFileName
public function getSafeFileName() { $fileExtension = pathinfo($this->file->getClientOriginalName(), PATHINFO_EXTENSION); $mimeTypeExtension = $this->file->guessExtension(); $newExtension = !empty($mimeTypeExtension) ? $mimeTypeExtension : $fileExtension; $baseName = !empty($fileExtension) ? basename($this->file->getClientOriginalName(), $fileExtension) : $this->file->getClientOriginalName(); $safeBaseName = Transliterator::urlize($baseName); return $safeBaseName . (!empty($newExtension) ? '.' . $newExtension : ''); }
php
public function getSafeFileName() { $fileExtension = pathinfo($this->file->getClientOriginalName(), PATHINFO_EXTENSION); $mimeTypeExtension = $this->file->guessExtension(); $newExtension = !empty($mimeTypeExtension) ? $mimeTypeExtension : $fileExtension; $baseName = !empty($fileExtension) ? basename($this->file->getClientOriginalName(), $fileExtension) : $this->file->getClientOriginalName(); $safeBaseName = Transliterator::urlize($baseName); return $safeBaseName . (!empty($newExtension) ? '.' . $newExtension : ''); }
[ "public", "function", "getSafeFileName", "(", ")", "{", "$", "fileExtension", "=", "pathinfo", "(", "$", "this", "->", "file", "->", "getClientOriginalName", "(", ")", ",", "PATHINFO_EXTENSION", ")", ";", "$", "mimeTypeExtension", "=", "$", "this", "->", "fi...
Create a safe file name for the uploaded file, so that it can be saved safely on the disk. @return string
[ "Create", "a", "safe", "file", "name", "for", "the", "uploaded", "file", "so", "that", "it", "can", "be", "saved", "safely", "on", "the", "disk", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php#L131-L141
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MultiDomainBundle/Helper/DomainConfiguration.php
DomainConfiguration.getRootNode
public function getRootNode($host = null) { if (!$this->isMultiDomainHost()) { return parent::getRootNode(); } if (is_null($this->rootNode)) { $host = $this->getRealHost($host); $internalName = $this->hosts[$host]['root']; $nodeRepo = $this->em->getRepository('KunstmaanNodeBundle:Node'); $this->rootNode = $nodeRepo->getNodeByInternalName($internalName); } return $this->rootNode; }
php
public function getRootNode($host = null) { if (!$this->isMultiDomainHost()) { return parent::getRootNode(); } if (is_null($this->rootNode)) { $host = $this->getRealHost($host); $internalName = $this->hosts[$host]['root']; $nodeRepo = $this->em->getRepository('KunstmaanNodeBundle:Node'); $this->rootNode = $nodeRepo->getNodeByInternalName($internalName); } return $this->rootNode; }
[ "public", "function", "getRootNode", "(", "$", "host", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isMultiDomainHost", "(", ")", ")", "{", "return", "parent", "::", "getRootNode", "(", ")", ";", "}", "if", "(", "is_null", "(", "$", "...
Fetch the root node for the current host @param string|null $host @return Node|null
[ "Fetch", "the", "root", "node", "for", "the", "current", "host" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MultiDomainBundle/Helper/DomainConfiguration.php#L170-L185
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/MediaBundle/Helper/Transformer/PdfTransformer.php
PdfTransformer.apply
public function apply($absolutePath) { $info = pathinfo($absolutePath); if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf') && file_exists($absolutePath)) { // If it doesn't exist yet, extract the first page of the PDF $previewFilename = $this->getPreviewFilename($absolutePath); if (!file_exists($previewFilename)) { $this->imagick->readImage($absolutePath . '[0]'); $this->imagick->setImageFormat('jpg'); $this->imagick->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); $this->imagick->writeImage($previewFilename); $this->imagick->clear(); } $absolutePath = $previewFilename; } return $absolutePath; }
php
public function apply($absolutePath) { $info = pathinfo($absolutePath); if (isset($info['extension']) && false !== strpos(strtolower($info['extension']), 'pdf') && file_exists($absolutePath)) { // If it doesn't exist yet, extract the first page of the PDF $previewFilename = $this->getPreviewFilename($absolutePath); if (!file_exists($previewFilename)) { $this->imagick->readImage($absolutePath . '[0]'); $this->imagick->setImageFormat('jpg'); $this->imagick->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); $this->imagick->writeImage($previewFilename); $this->imagick->clear(); } $absolutePath = $previewFilename; } return $absolutePath; }
[ "public", "function", "apply", "(", "$", "absolutePath", ")", "{", "$", "info", "=", "pathinfo", "(", "$", "absolutePath", ")", ";", "if", "(", "isset", "(", "$", "info", "[", "'extension'", "]", ")", "&&", "false", "!==", "strpos", "(", "strtolower", ...
Apply the transformer on the absolute path and return an altered version of it. @param string $absolutePath @return string|false
[ "Apply", "the", "transformer", "on", "the", "absolute", "path", "and", "return", "an", "altered", "version", "of", "it", "." ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/MediaBundle/Helper/Transformer/PdfTransformer.php#L22-L41
train
Kunstmaan/KunstmaanBundlesCMS
src/Kunstmaan/LeadGenerationBundle/Controller/RulesAdminListController.php
RulesAdminListController.detailAction
public function detailAction(Request $request, $popup) { return parent::doIndexAction($this->getAdminListConfigurator($popup), $request); }
php
public function detailAction(Request $request, $popup) { return parent::doIndexAction($this->getAdminListConfigurator($popup), $request); }
[ "public", "function", "detailAction", "(", "Request", "$", "request", ",", "$", "popup", ")", "{", "return", "parent", "::", "doIndexAction", "(", "$", "this", "->", "getAdminListConfigurator", "(", "$", "popup", ")", ",", "$", "request", ")", ";", "}" ]
The detail action @Route("/{popup}/rules", requirements={"popup" = "\d+"}, name="kunstmaanleadgenerationbundle_admin_rule_abstractrule_detail")
[ "The", "detail", "action" ]
d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1
https://github.com/Kunstmaan/KunstmaanBundlesCMS/blob/d841f8eb7dbb16318f8312d1f9701cefeb7aa6d1/src/Kunstmaan/LeadGenerationBundle/Controller/RulesAdminListController.php#L35-L38
train
Gregwar/Image
Adapter/Common.php
Common.forceResize
public function forceResize($width = null, $height = null, $background = 'transparent') { return $this->resize($width, $height, $background, true); }
php
public function forceResize($width = null, $height = null, $background = 'transparent') { return $this->resize($width, $height, $background, true); }
[ "public", "function", "forceResize", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "'transparent'", ")", "{", "return", "$", "this", "->", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "bac...
Resizes the image forcing the destination to have exactly the given width and the height. @param int $w the width @param int $h the height @param int $bg the background
[ "Resizes", "the", "image", "forcing", "the", "destination", "to", "have", "exactly", "the", "given", "width", "and", "the", "height", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Adapter/Common.php#L72-L75
train
Gregwar/Image
Adapter/Common.php
Common.fixOrientation
public function fixOrientation() { if (!in_array(exif_imagetype($this->source->getInfos()), array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) { return $this; } if (!extension_loaded('exif')) { throw new \RuntimeException('You need to EXIF PHP Extension to use this function'); } $exif = @exif_read_data($this->source->getInfos()); if ($exif === false || !array_key_exists('Orientation', $exif)) { return $this; } switch ($exif['Orientation']) { case 1: break; case 2: $this->flip(false, true); break; case 3: // 180 rotate left $this->rotate(180); break; case 4: // vertical flip $this->flip(true, false); break; case 5: // vertical flip + 90 rotate right $this->flip(true, false); $this->rotate(-90); break; case 6: // 90 rotate right $this->rotate(-90); break; case 7: // horizontal flip + 90 rotate right $this->flip(false, true); $this->rotate(-90); break; case 8: // 90 rotate left $this->rotate(90); break; } return $this; }
php
public function fixOrientation() { if (!in_array(exif_imagetype($this->source->getInfos()), array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM))) { return $this; } if (!extension_loaded('exif')) { throw new \RuntimeException('You need to EXIF PHP Extension to use this function'); } $exif = @exif_read_data($this->source->getInfos()); if ($exif === false || !array_key_exists('Orientation', $exif)) { return $this; } switch ($exif['Orientation']) { case 1: break; case 2: $this->flip(false, true); break; case 3: // 180 rotate left $this->rotate(180); break; case 4: // vertical flip $this->flip(true, false); break; case 5: // vertical flip + 90 rotate right $this->flip(true, false); $this->rotate(-90); break; case 6: // 90 rotate right $this->rotate(-90); break; case 7: // horizontal flip + 90 rotate right $this->flip(false, true); $this->rotate(-90); break; case 8: // 90 rotate left $this->rotate(90); break; } return $this; }
[ "public", "function", "fixOrientation", "(", ")", "{", "if", "(", "!", "in_array", "(", "exif_imagetype", "(", "$", "this", "->", "source", "->", "getInfos", "(", ")", ")", ",", "array", "(", "IMAGETYPE_JPEG", ",", "IMAGETYPE_TIFF_II", ",", "IMAGETYPE_TIFF_M...
Fix orientation using Exif informations.
[ "Fix", "orientation", "using", "Exif", "informations", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Adapter/Common.php#L96-L148
train
Gregwar/Image
Adapter/Common.php
Common._trimColor
protected function _trimColor($background = 'transparent') { $width = $this->width(); $height = $this->height(); $b_top = 0; $b_lft = 0; $b_btm = $height - 1; $b_rt = $width - 1; //top for (; $b_top < $height; ++$b_top) { for ($x = 0; $x < $width; ++$x) { if ($this->getColor($x, $b_top) != $background) { break 2; } } } // bottom for (; $b_btm >= 0; --$b_btm) { for ($x = 0; $x < $width; ++$x) { if ($this->getColor($x, $b_btm) != $background) { break 2; } } } // left for (; $b_lft < $width; ++$b_lft) { for ($y = $b_top; $y <= $b_btm; ++$y) { if ($this->getColor($b_lft, $y) != $background) { break 2; } } } // right for (; $b_rt >= 0; --$b_rt) { for ($y = $b_top; $y <= $b_btm; ++$y) { if ($this->getColor($b_rt, $y) != $background) { break 2; } } } ++$b_btm; ++$b_rt; $this->crop($b_lft, $b_top, $b_rt - $b_lft, $b_btm - $b_top); }
php
protected function _trimColor($background = 'transparent') { $width = $this->width(); $height = $this->height(); $b_top = 0; $b_lft = 0; $b_btm = $height - 1; $b_rt = $width - 1; //top for (; $b_top < $height; ++$b_top) { for ($x = 0; $x < $width; ++$x) { if ($this->getColor($x, $b_top) != $background) { break 2; } } } // bottom for (; $b_btm >= 0; --$b_btm) { for ($x = 0; $x < $width; ++$x) { if ($this->getColor($x, $b_btm) != $background) { break 2; } } } // left for (; $b_lft < $width; ++$b_lft) { for ($y = $b_top; $y <= $b_btm; ++$y) { if ($this->getColor($b_lft, $y) != $background) { break 2; } } } // right for (; $b_rt >= 0; --$b_rt) { for ($y = $b_top; $y <= $b_btm; ++$y) { if ($this->getColor($b_rt, $y) != $background) { break 2; } } } ++$b_btm; ++$b_rt; $this->crop($b_lft, $b_top, $b_rt - $b_lft, $b_btm - $b_top); }
[ "protected", "function", "_trimColor", "(", "$", "background", "=", "'transparent'", ")", "{", "$", "width", "=", "$", "this", "->", "width", "(", ")", ";", "$", "height", "=", "$", "this", "->", "height", "(", ")", ";", "$", "b_top", "=", "0", ";"...
Trim background color arround the image. @param int $bg the background
[ "Trim", "background", "color", "arround", "the", "image", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Adapter/Common.php#L298-L348
train
Gregwar/Image
GarbageCollect.php
GarbageCollect.dropOldFiles
public static function dropOldFiles($directory, $days = 30, $verbose = false) { $allDropped = true; $now = time(); $dir = opendir($directory); if (!$dir) { if ($verbose) { echo "! Unable to open $directory\n"; } return false; } while ($file = readdir($dir)) { if ($file == '.' || $file == '..') { continue; } $fullName = $directory.'/'.$file; $old = $now - filemtime($fullName); if (is_dir($fullName)) { // Directories are recursively crawled if (static::dropOldFiles($fullName, $days, $verbose)) { self::drop($fullName, $verbose); } else { $allDropped = false; } } else { if ($old > (24 * 60 * 60 * $days)) { self::drop($fullName, $verbose); } else { $allDropped = false; } } } closedir($dir); return $allDropped; }
php
public static function dropOldFiles($directory, $days = 30, $verbose = false) { $allDropped = true; $now = time(); $dir = opendir($directory); if (!$dir) { if ($verbose) { echo "! Unable to open $directory\n"; } return false; } while ($file = readdir($dir)) { if ($file == '.' || $file == '..') { continue; } $fullName = $directory.'/'.$file; $old = $now - filemtime($fullName); if (is_dir($fullName)) { // Directories are recursively crawled if (static::dropOldFiles($fullName, $days, $verbose)) { self::drop($fullName, $verbose); } else { $allDropped = false; } } else { if ($old > (24 * 60 * 60 * $days)) { self::drop($fullName, $verbose); } else { $allDropped = false; } } } closedir($dir); return $allDropped; }
[ "public", "static", "function", "dropOldFiles", "(", "$", "directory", ",", "$", "days", "=", "30", ",", "$", "verbose", "=", "false", ")", "{", "$", "allDropped", "=", "true", ";", "$", "now", "=", "time", "(", ")", ";", "$", "dir", "=", "opendir"...
Drops old files of a directory. @param string $directory the name of the target directory @param int $days the number of days to consider a file old @param bool $verbose enable verbose output @return true if all the files/directories of a directory was wiped
[ "Drops", "old", "files", "of", "a", "directory", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/GarbageCollect.php#L22-L65
train
Gregwar/Image
GarbageCollect.php
GarbageCollect.drop
public static function drop($file, $verbose = false) { if (is_dir($file)) { @rmdir($file); } else { @unlink($file); } if ($verbose) { echo "> Dropping $file...\n"; } }
php
public static function drop($file, $verbose = false) { if (is_dir($file)) { @rmdir($file); } else { @unlink($file); } if ($verbose) { echo "> Dropping $file...\n"; } }
[ "public", "static", "function", "drop", "(", "$", "file", ",", "$", "verbose", "=", "false", ")", "{", "if", "(", "is_dir", "(", "$", "file", ")", ")", "{", "@", "rmdir", "(", "$", "file", ")", ";", "}", "else", "{", "@", "unlink", "(", "$", ...
Drops a file or an empty directory.
[ "Drops", "a", "file", "or", "an", "empty", "directory", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/GarbageCollect.php#L70-L81
train
Gregwar/Image
Image.php
Image.getCacheSystem
public function getCacheSystem() { if (is_null($this->cache)) { $this->cache = new \Gregwar\Cache\Cache(); $this->cache->setCacheDirectory($this->cacheDir); } return $this->cache; }
php
public function getCacheSystem() { if (is_null($this->cache)) { $this->cache = new \Gregwar\Cache\Cache(); $this->cache->setCacheDirectory($this->cacheDir); } return $this->cache; }
[ "public", "function", "getCacheSystem", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "cache", ")", ")", "{", "$", "this", "->", "cache", "=", "new", "\\", "Gregwar", "\\", "Cache", "\\", "Cache", "(", ")", ";", "$", "this", "->", ...
Get the cache system. @return \Gregwar\Cache\CacheInterface
[ "Get", "the", "cache", "system", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L123-L131
train
Gregwar/Image
Image.php
Image.setPrettyName
public function setPrettyName($name, $prefix = true) { if (empty($name)) { return $this; } $this->prettyName = $this->urlize($name); $this->prettyPrefix = $prefix; return $this; }
php
public function setPrettyName($name, $prefix = true) { if (empty($name)) { return $this; } $this->prettyName = $this->urlize($name); $this->prettyPrefix = $prefix; return $this; }
[ "public", "function", "setPrettyName", "(", "$", "name", ",", "$", "prefix", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "prettyName", "=", "$", "this", "->", "ur...
Sets the pretty name of the image.
[ "Sets", "the", "pretty", "name", "of", "the", "image", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L184-L194
train
Gregwar/Image
Image.php
Image.urlize
protected function urlize($name) { $transliterator = '\Behat\Transliterator\Transliterator'; if (class_exists($transliterator)) { $name = $transliterator::transliterate($name); $name = $transliterator::urlize($name); } else { $name = strtolower($name); $name = str_replace(' ', '-', $name); $name = preg_replace('/([^a-z0-9\-]+)/m', '', $name); } return $name; }
php
protected function urlize($name) { $transliterator = '\Behat\Transliterator\Transliterator'; if (class_exists($transliterator)) { $name = $transliterator::transliterate($name); $name = $transliterator::urlize($name); } else { $name = strtolower($name); $name = str_replace(' ', '-', $name); $name = preg_replace('/([^a-z0-9\-]+)/m', '', $name); } return $name; }
[ "protected", "function", "urlize", "(", "$", "name", ")", "{", "$", "transliterator", "=", "'\\Behat\\Transliterator\\Transliterator'", ";", "if", "(", "class_exists", "(", "$", "transliterator", ")", ")", "{", "$", "name", "=", "$", "transliterator", "::", "t...
Urlizes the prettyName.
[ "Urlizes", "the", "prettyName", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L199-L213
train
Gregwar/Image
Image.php
Image.setFallback
public function setFallback($fallback = null) { if ($fallback === null) { $this->fallback = __DIR__.'/images/error.jpg'; } else { $this->fallback = $fallback; } return $this; }
php
public function setFallback($fallback = null) { if ($fallback === null) { $this->fallback = __DIR__.'/images/error.jpg'; } else { $this->fallback = $fallback; } return $this; }
[ "public", "function", "setFallback", "(", "$", "fallback", "=", "null", ")", "{", "if", "(", "$", "fallback", "===", "null", ")", "{", "$", "this", "->", "fallback", "=", "__DIR__", ".", "'/images/error.jpg'", ";", "}", "else", "{", "$", "this", "->", ...
Sets the fallback image to use.
[ "Sets", "the", "fallback", "image", "to", "use", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L260-L269
train
Gregwar/Image
Image.php
Image.getCacheFallback
public function getCacheFallback() { $fallback = $this->fallback; return $this->getCacheSystem()->getOrCreateFile('fallback.jpg', array(), function ($target) use ($fallback) { copy($fallback, $target); }); }
php
public function getCacheFallback() { $fallback = $this->fallback; return $this->getCacheSystem()->getOrCreateFile('fallback.jpg', array(), function ($target) use ($fallback) { copy($fallback, $target); }); }
[ "public", "function", "getCacheFallback", "(", ")", "{", "$", "fallback", "=", "$", "this", "->", "fallback", ";", "return", "$", "this", "->", "getCacheSystem", "(", ")", "->", "getOrCreateFile", "(", "'fallback.jpg'", ",", "array", "(", ")", ",", "functi...
Gets the fallback into the cache dir.
[ "Gets", "the", "fallback", "into", "the", "cache", "dir", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L282-L289
train
Gregwar/Image
Image.php
Image.serializeOperations
public function serializeOperations() { $datas = array(); foreach ($this->operations as $operation) { $method = $operation[0]; $args = $operation[1]; foreach ($args as &$arg) { if ($arg instanceof self) { $arg = $arg->getHash(); } } $datas[] = array($method, $args); } return serialize($datas); }
php
public function serializeOperations() { $datas = array(); foreach ($this->operations as $operation) { $method = $operation[0]; $args = $operation[1]; foreach ($args as &$arg) { if ($arg instanceof self) { $arg = $arg->getHash(); } } $datas[] = array($method, $args); } return serialize($datas); }
[ "public", "function", "serializeOperations", "(", ")", "{", "$", "datas", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "operations", "as", "$", "operation", ")", "{", "$", "method", "=", "$", "operation", "[", "0", "]", ";", "$", ...
Serialization of operations.
[ "Serialization", "of", "operations", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L409-L427
train
Gregwar/Image
Image.php
Image.generateHash
public function generateHash($type = 'guess', $quality = 80) { $inputInfos = $this->source->getInfos(); $datas = array( $inputInfos, $this->serializeOperations(), $type, $quality, ); $this->hash = sha1(serialize($datas)); }
php
public function generateHash($type = 'guess', $quality = 80) { $inputInfos = $this->source->getInfos(); $datas = array( $inputInfos, $this->serializeOperations(), $type, $quality, ); $this->hash = sha1(serialize($datas)); }
[ "public", "function", "generateHash", "(", "$", "type", "=", "'guess'", ",", "$", "quality", "=", "80", ")", "{", "$", "inputInfos", "=", "$", "this", "->", "source", "->", "getInfos", "(", ")", ";", "$", "datas", "=", "array", "(", "$", "inputInfos"...
Generates the hash.
[ "Generates", "the", "hash", "." ]
03534d5760cbea5c96e6292041ff81a3bb205c36
https://github.com/Gregwar/Image/blob/03534d5760cbea5c96e6292041ff81a3bb205c36/Image.php#L432-L444
train