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
aegis-security/JWT
src/Signer/Ecdsa.php
Ecdsa.createSignatureHash
private function createSignatureHash(Signature $signature) { $length = $this->getSignatureLength(); return pack( 'H*', sprintf( '%s%s', str_pad($this->adapter->decHex($signature->getR()), $length, '0', STR_PAD_LEFT), str_pad($this->adapter->decHex($signature->getS()), $length, '0', STR_PAD_LEFT) ) ); }
php
private function createSignatureHash(Signature $signature) { $length = $this->getSignatureLength(); return pack( 'H*', sprintf( '%s%s', str_pad($this->adapter->decHex($signature->getR()), $length, '0', STR_PAD_LEFT), str_pad($this->adapter->decHex($signature->getS()), $length, '0', STR_PAD_LEFT) ) ); }
[ "private", "function", "createSignatureHash", "(", "Signature", "$", "signature", ")", "{", "$", "length", "=", "$", "this", "->", "getSignatureLength", "(", ")", ";", "return", "pack", "(", "'H*'", ",", "sprintf", "(", "'%s%s'", ",", "str_pad", "(", "$", ...
Creates a binary signature with R and S coordinates @param Signature $signature @return string
[ "Creates", "a", "binary", "signature", "with", "R", "and", "S", "coordinates" ]
b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23
https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Signer/Ecdsa.php#L77-L89
train
aegis-security/JWT
src/Signer/Ecdsa.php
Ecdsa.extractSignature
private function extractSignature($value) { $length = $this->getSignatureLength(); $value = unpack('H*', $value)[1]; return new Signature( $this->adapter->hexDec(substr($value, 0, $length)), $this->adapter->hexDec(substr($value, $length)) ); }
php
private function extractSignature($value) { $length = $this->getSignatureLength(); $value = unpack('H*', $value)[1]; return new Signature( $this->adapter->hexDec(substr($value, 0, $length)), $this->adapter->hexDec(substr($value, $length)) ); }
[ "private", "function", "extractSignature", "(", "$", "value", ")", "{", "$", "length", "=", "$", "this", "->", "getSignatureLength", "(", ")", ";", "$", "value", "=", "unpack", "(", "'H*'", ",", "$", "value", ")", "[", "1", "]", ";", "return", "new",...
Extracts R and S values from given data @param string $value @return \Mdanter\Ecc\Crypto\Signature\Signature
[ "Extracts", "R", "and", "S", "values", "from", "given", "data" ]
b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23
https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Signer/Ecdsa.php#L122-L131
train
aegis-security/JWT
src/Signer/Ecdsa/KeyParser.php
KeyParser.getKeyContent
private function getKeyContent(Key $key, $header) { $match = null; preg_match( '/^[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}$/', str_replace([PHP_EOL, "\n", "\r"], '', $key->getContent()), $match ); if (isset($match[1])) { return $match[1]; } throw new \InvalidArgumentException('This is not a valid ECDSA key.'); }
php
private function getKeyContent(Key $key, $header) { $match = null; preg_match( '/^[\-]{5}BEGIN ' . $header . '[\-]{5}(.*)[\-]{5}END ' . $header . '[\-]{5}$/', str_replace([PHP_EOL, "\n", "\r"], '', $key->getContent()), $match ); if (isset($match[1])) { return $match[1]; } throw new \InvalidArgumentException('This is not a valid ECDSA key.'); }
[ "private", "function", "getKeyContent", "(", "Key", "$", "key", ",", "$", "header", ")", "{", "$", "match", "=", "null", ";", "preg_match", "(", "'/^[\\-]{5}BEGIN '", ".", "$", "header", ".", "'[\\-]{5}(.*)[\\-]{5}END '", ".", "$", "header", ".", "'[\\-]{5}$...
Extracts the base 64 value from the PEM certificate @param Key $key @param string $header @return string @throws \InvalidArgumentException When given key is not a ECDSA key
[ "Extracts", "the", "base", "64", "value", "from", "the", "PEM", "certificate" ]
b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23
https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Signer/Ecdsa/KeyParser.php#L82-L97
train
Opifer/Cms
src/MediaBundle/Twig/MediaExtension.php
MediaExtension.sourceUrl
public function sourceUrl($media) { return new \Twig_Markup( $this->pool->getProvider($media->getProvider())->getUrl($media), 'utf8' ); }
php
public function sourceUrl($media) { return new \Twig_Markup( $this->pool->getProvider($media->getProvider())->getUrl($media), 'utf8' ); }
[ "public", "function", "sourceUrl", "(", "$", "media", ")", "{", "return", "new", "\\", "Twig_Markup", "(", "$", "this", "->", "pool", "->", "getProvider", "(", "$", "media", "->", "getProvider", "(", ")", ")", "->", "getUrl", "(", "$", "media", ")", ...
Gets the source url of a media item @param Media $media @return \Twig_Markup
[ "Gets", "the", "source", "url", "of", "a", "media", "item" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Twig/MediaExtension.php#L42-L48
train
Opifer/Cms
src/ContentBundle/Block/Service/SearchResultsBlockService.php
SearchResultsBlockService.getSearchResults
public function getSearchResults() { $term = $this->getRequest()->get('search', null); // Avoid querying ALL content when no search value is provided if (!$term) { return []; } $host = $this->getRequest()->getHost(); $locale = $this->getRequest()->attributes->get('content')->getLocale(); return $this->contentManager->getRepository()->search($term, $host, $locale); }
php
public function getSearchResults() { $term = $this->getRequest()->get('search', null); // Avoid querying ALL content when no search value is provided if (!$term) { return []; } $host = $this->getRequest()->getHost(); $locale = $this->getRequest()->attributes->get('content')->getLocale(); return $this->contentManager->getRepository()->search($term, $host, $locale); }
[ "public", "function", "getSearchResults", "(", ")", "{", "$", "term", "=", "$", "this", "->", "getRequest", "(", ")", "->", "get", "(", "'search'", ",", "null", ")", ";", "// Avoid querying ALL content when no search value is provided", "if", "(", "!", "$", "t...
Get the search results @return Content[]
[ "Get", "the", "search", "results" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/Service/SearchResultsBlockService.php#L68-L81
train
avored/install
src/Controllers/InstallController.php
InstallController.index
public function index() { Session::forget('install-module'); $result = []; foreach ($this->extensions as $ext) { if (extension_loaded($ext)) { $result [$ext] = 'true'; } else { $result [$ext] = false; } } return view('avored-install::install.extension')->with('result', $result); }
php
public function index() { Session::forget('install-module'); $result = []; foreach ($this->extensions as $ext) { if (extension_loaded($ext)) { $result [$ext] = 'true'; } else { $result [$ext] = false; } } return view('avored-install::install.extension')->with('result', $result); }
[ "public", "function", "index", "(", ")", "{", "Session", "::", "forget", "(", "'install-module'", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "extensions", "as", "$", "ext", ")", "{", "if", "(", "extension_loaded", ...
Display all needed PHP Extension for the AvoRed E commerce App @return \Illuminate\Http\Response
[ "Display", "all", "needed", "PHP", "Extension", "for", "the", "AvoRed", "E", "commerce", "App" ]
a218f4bbe9c40b6f172833666164679a9d4fd17e
https://github.com/avored/install/blob/a218f4bbe9c40b6f172833666164679a9d4fd17e/src/Controllers/InstallController.php#L64-L78
train
Opifer/Cms
src/CmsBundle/OpiferCmsBundle.php
OpiferCmsBundle.build
public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new ConfigurationCompilerPass()); $container->addCompilerPass(new VendorCompilerPass()); }
php
public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new ConfigurationCompilerPass()); $container->addCompilerPass(new VendorCompilerPass()); }
[ "public", "function", "build", "(", "ContainerBuilder", "$", "container", ")", "{", "parent", "::", "build", "(", "$", "container", ")", ";", "$", "container", "->", "addCompilerPass", "(", "new", "ConfigurationCompilerPass", "(", ")", ")", ";", "$", "contai...
Registers the compiler passes @param ContainerBuilder $container
[ "Registers", "the", "compiler", "passes" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/OpiferCmsBundle.php#L17-L23
train
Opifer/Cms
src/CmsBundle/Form/Type/UserFormType.php
UserFormType.flattenRoles
public function flattenRoles($data) { $result = array(); foreach ($data as $key => $value) { if (substr($key, 0, 4) === 'ROLE') { $result[$key] = $key; } if (is_array($value)) { $tmpresult = $this->flattenRoles($value); if (count($tmpresult) > 0) { $result = array_merge($result, $tmpresult); } } else { $result[$value] = $value; } } return array_unique($result); }
php
public function flattenRoles($data) { $result = array(); foreach ($data as $key => $value) { if (substr($key, 0, 4) === 'ROLE') { $result[$key] = $key; } if (is_array($value)) { $tmpresult = $this->flattenRoles($value); if (count($tmpresult) > 0) { $result = array_merge($result, $tmpresult); } } else { $result[$value] = $value; } } return array_unique($result); }
[ "public", "function", "flattenRoles", "(", "$", "data", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "4",...
Flatten roles. @param array $data @return array
[ "Flatten", "roles", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Form/Type/UserFormType.php#L70-L88
train
Opifer/Cms
src/MailingListBundle/DependencyInjection/Configuration.php
Configuration.addBlocksSection
private function addBlocksSection(ArrayNodeDefinition $node) { $node ->children() ->arrayNode('blocks') ->addDefaultsIfNotSet() ->children() ->arrayNode('subscribe') ->addDefaultsIfNotSet() ->children() ->scalarNode('view')->defaultValue('OpiferMailingListBundle:Block:subscribe.html.twig')->end() ->arrayNode('templates') ->prototype('scalar')->end() ->normalizeKeys(false) ->useAttributeAsKey('name') ->defaultValue([]) ->end() ->end() ->end() ->end() ->end() ->end() ; }
php
private function addBlocksSection(ArrayNodeDefinition $node) { $node ->children() ->arrayNode('blocks') ->addDefaultsIfNotSet() ->children() ->arrayNode('subscribe') ->addDefaultsIfNotSet() ->children() ->scalarNode('view')->defaultValue('OpiferMailingListBundle:Block:subscribe.html.twig')->end() ->arrayNode('templates') ->prototype('scalar')->end() ->normalizeKeys(false) ->useAttributeAsKey('name') ->defaultValue([]) ->end() ->end() ->end() ->end() ->end() ->end() ; }
[ "private", "function", "addBlocksSection", "(", "ArrayNodeDefinition", "$", "node", ")", "{", "$", "node", "->", "children", "(", ")", "->", "arrayNode", "(", "'blocks'", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "arrayNod...
Add Block specific configuration. @param ArrayNodeDefinition $node
[ "Add", "Block", "specific", "configuration", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/DependencyInjection/Configuration.php#L53-L76
train
Opifer/Cms
src/MailingListBundle/Controller/MailingListController.php
MailingListController.createAction
public function createAction(Request $request) { $mailingList = new MailingList(); $form = $this->createForm(MailingListType::class, $mailingList, [ 'action' => $this->generateUrl('opifer_mailing_list_mailing_list_create'), ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($mailingList); $em->flush(); return $this->redirectToRoute('opifer_mailing_list_mailing_list_index'); } return $this->render('OpiferMailingListBundle:MailingList:create.html.twig', [ 'form' => $form->createView(), ]); }
php
public function createAction(Request $request) { $mailingList = new MailingList(); $form = $this->createForm(MailingListType::class, $mailingList, [ 'action' => $this->generateUrl('opifer_mailing_list_mailing_list_create'), ]); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($mailingList); $em->flush(); return $this->redirectToRoute('opifer_mailing_list_mailing_list_index'); } return $this->render('OpiferMailingListBundle:MailingList:create.html.twig', [ 'form' => $form->createView(), ]); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "mailingList", "=", "new", "MailingList", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "MailingListType", "::", "class", ",", "$", "mailingList",...
Add new Mailing List.
[ "Add", "new", "Mailing", "List", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Controller/MailingListController.php#L73-L94
train
Opifer/Cms
src/MailingListBundle/Controller/MailingListController.php
MailingListController.editAction
public function editAction(Request $request, $id) { $mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id); $form = $this->createForm(MailingListType::class, $mailingList); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->flush(); return $this->redirectToRoute('opifer_mailing_list_mailing_list_index'); } return $this->render('OpiferMailingListBundle:MailingList:edit.html.twig', [ 'form' => $form->createView(), 'mailing_list' => $mailingList, ]); }
php
public function editAction(Request $request, $id) { $mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id); $form = $this->createForm(MailingListType::class, $mailingList); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->flush(); return $this->redirectToRoute('opifer_mailing_list_mailing_list_index'); } return $this->render('OpiferMailingListBundle:MailingList:edit.html.twig', [ 'form' => $form->createView(), 'mailing_list' => $mailingList, ]); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "mailingList", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'OpiferMailingListBundle:MailingList'", ")", "->", "find", "(", "$...
Edit Mailing List. @param Request $request @param int $id
[ "Edit", "Mailing", "List", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Controller/MailingListController.php#L102-L120
train
Opifer/Cms
src/MailingListBundle/Controller/MailingListController.php
MailingListController.deleteAction
public function deleteAction($id) { $mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id); if (!empty($mailingList)) { $em = $this->getDoctrine()->getManager(); $em->remove($mailingList); $em->flush(); } return $this->redirectToRoute('opifer_mailing_list_mailing_list_index'); }
php
public function deleteAction($id) { $mailingList = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id); if (!empty($mailingList)) { $em = $this->getDoctrine()->getManager(); $em->remove($mailingList); $em->flush(); } return $this->redirectToRoute('opifer_mailing_list_mailing_list_index'); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "$", "mailingList", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'OpiferMailingListBundle:MailingList'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "("...
Delete Mailing List. @param int $id
[ "Delete", "Mailing", "List", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Controller/MailingListController.php#L127-L138
train
Opifer/Cms
src/ContentBundle/Controller/Api/ContentController.php
ContentController.idsAction
public function idsAction($ids) { $items = $this->get('opifer.content.content_manager') ->getRepository() ->findOrderedByIds($ids); $stringHelper = $this->container->get('opifer.content.string_helper'); $contents = $this->get('jms_serializer')->serialize($items, 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks()); $contents = $stringHelper->replaceLinks($contents); $data = [ 'results' => json_decode($contents, true), 'total_results' => count($items), ]; return new JsonResponse($data); }
php
public function idsAction($ids) { $items = $this->get('opifer.content.content_manager') ->getRepository() ->findOrderedByIds($ids); $stringHelper = $this->container->get('opifer.content.string_helper'); $contents = $this->get('jms_serializer')->serialize($items, 'json', SerializationContext::create()->setGroups(['list'])->enableMaxDepthChecks()); $contents = $stringHelper->replaceLinks($contents); $data = [ 'results' => json_decode($contents, true), 'total_results' => count($items), ]; return new JsonResponse($data); }
[ "public", "function", "idsAction", "(", "$", "ids", ")", "{", "$", "items", "=", "$", "this", "->", "get", "(", "'opifer.content.content_manager'", ")", "->", "getRepository", "(", ")", "->", "findOrderedByIds", "(", "$", "ids", ")", ";", "$", "stringHelpe...
Get a content items by a list of ids. @param string $ids @return JsonResponse
[ "Get", "a", "content", "items", "by", "a", "list", "of", "ids", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Api/ContentController.php#L298-L314
train
Opifer/Cms
src/ContentBundle/Controller/Api/ContentController.php
ContentController.viewAction
public function viewAction(Request $request, $id, $structure = 'tree') { $response = new JsonResponse(); /** @var ContentRepository $contentRepository */ $contentRepository = $this->get('opifer.content.content_manager')->getRepository(); $content = $contentRepository->findOneByIdOrSlug($id, true); if ($content->getSlug() === '404') { // If the original content was not found and the 404 page was returned, set the correct status code $response->setStatusCode(404); } $version = $request->query->get('_version'); $debug = $this->getParameter('kernel.debug'); $response->setLastModified($content->getLastUpdateDate()); $response->setPublic(); if (null === $version && false == $debug && $response->isNotModified($request)) { // return the 304 Response immediately return $response; } /** @var Environment $environment */ $environment = $this->get('opifer.content.block_environment'); $environment->setObject($content); if (null !== $version && $this->isGranted('ROLE_ADMIN')) { $environment->setDraft(true); } $environment->load(); $context = SerializationContext::create() ->addExclusionStrategy(new BlockExclusionStrategy($content)) // ->setGroups(['Default', 'detail']) ; if ($structure == 'tree') { $blocks = $environment->getRootBlocks(); $context->setGroups(['Default', 'tree', 'detail']); } else { $blocks = $environment->getBlocks(); $context->setGroups(['Default', 'detail']) ->enableMaxDepthChecks(); } $contentItem = [ 'id' => $content->getId(), 'created_at' => $content->getCreatedAt(), 'updated_at' => $content->getUpdatedAt(), 'published_at' => $content->getPublishAt(), 'title' => $content->getTitle(), 'shortTitle' => $content->getShortTitle(), 'description' => $content->getDescription(), 'slug' => $content->getSlug(), 'alias' => $content->getAlias(), 'blocks' => $blocks, 'attributes' => $content->getPivotedAttributes(), 'medias' => $content->getMedias(), ]; $stringHelper = $this->container->get('opifer.content.string_helper'); $json = $this->get('jms_serializer')->serialize($contentItem, 'json', $context); $json = $stringHelper->replaceLinks($json); $response->setData(json_decode($json, true)); return $response; }
php
public function viewAction(Request $request, $id, $structure = 'tree') { $response = new JsonResponse(); /** @var ContentRepository $contentRepository */ $contentRepository = $this->get('opifer.content.content_manager')->getRepository(); $content = $contentRepository->findOneByIdOrSlug($id, true); if ($content->getSlug() === '404') { // If the original content was not found and the 404 page was returned, set the correct status code $response->setStatusCode(404); } $version = $request->query->get('_version'); $debug = $this->getParameter('kernel.debug'); $response->setLastModified($content->getLastUpdateDate()); $response->setPublic(); if (null === $version && false == $debug && $response->isNotModified($request)) { // return the 304 Response immediately return $response; } /** @var Environment $environment */ $environment = $this->get('opifer.content.block_environment'); $environment->setObject($content); if (null !== $version && $this->isGranted('ROLE_ADMIN')) { $environment->setDraft(true); } $environment->load(); $context = SerializationContext::create() ->addExclusionStrategy(new BlockExclusionStrategy($content)) // ->setGroups(['Default', 'detail']) ; if ($structure == 'tree') { $blocks = $environment->getRootBlocks(); $context->setGroups(['Default', 'tree', 'detail']); } else { $blocks = $environment->getBlocks(); $context->setGroups(['Default', 'detail']) ->enableMaxDepthChecks(); } $contentItem = [ 'id' => $content->getId(), 'created_at' => $content->getCreatedAt(), 'updated_at' => $content->getUpdatedAt(), 'published_at' => $content->getPublishAt(), 'title' => $content->getTitle(), 'shortTitle' => $content->getShortTitle(), 'description' => $content->getDescription(), 'slug' => $content->getSlug(), 'alias' => $content->getAlias(), 'blocks' => $blocks, 'attributes' => $content->getPivotedAttributes(), 'medias' => $content->getMedias(), ]; $stringHelper = $this->container->get('opifer.content.string_helper'); $json = $this->get('jms_serializer')->serialize($contentItem, 'json', $context); $json = $stringHelper->replaceLinks($json); $response->setData(json_decode($json, true)); return $response; }
[ "public", "function", "viewAction", "(", "Request", "$", "request", ",", "$", "id", ",", "$", "structure", "=", "'tree'", ")", "{", "$", "response", "=", "new", "JsonResponse", "(", ")", ";", "/** @var ContentRepository $contentRepository */", "$", "contentRepos...
Get a single content item. @param Request $request @param int $id @param string $structure @return JsonResponse
[ "Get", "a", "single", "content", "item", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Api/ContentController.php#L325-L394
train
Opifer/Cms
src/ContentBundle/Controller/Api/ContentController.php
ContentController.deleteAction
public function deleteAction($id) { /** @var ContentManager $manager */ $manager = $this->get('opifer.content.content_manager'); $content = $manager->getRepository()->find($id); //generate new slug so deleted slug can be used again $hashedSlug = $content->getSlug().'-'.sha1(date('Y-m-d H:i:s')); $content->setSlug($hashedSlug); $manager->save($content); $manager->remove($content); return new JsonResponse(['success' => true]); }
php
public function deleteAction($id) { /** @var ContentManager $manager */ $manager = $this->get('opifer.content.content_manager'); $content = $manager->getRepository()->find($id); //generate new slug so deleted slug can be used again $hashedSlug = $content->getSlug().'-'.sha1(date('Y-m-d H:i:s')); $content->setSlug($hashedSlug); $manager->save($content); $manager->remove($content); return new JsonResponse(['success' => true]); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "/** @var ContentManager $manager */", "$", "manager", "=", "$", "this", "->", "get", "(", "'opifer.content.content_manager'", ")", ";", "$", "content", "=", "$", "manager", "->", "getRepository", "...
Delete content. @param int $id @return Response
[ "Delete", "content", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Api/ContentController.php#L403-L418
train
aegis-security/JWT
src/ValidationData.php
ValidationData.setCurrentTime
public function setCurrentTime($currentTime) { $this->items['iat'] = (int) $currentTime; $this->items['nbf'] = (int) $currentTime; $this->items['exp'] = (int) $currentTime; }
php
public function setCurrentTime($currentTime) { $this->items['iat'] = (int) $currentTime; $this->items['nbf'] = (int) $currentTime; $this->items['exp'] = (int) $currentTime; }
[ "public", "function", "setCurrentTime", "(", "$", "currentTime", ")", "{", "$", "this", "->", "items", "[", "'iat'", "]", "=", "(", "int", ")", "$", "currentTime", ";", "$", "this", "->", "items", "[", "'nbf'", "]", "=", "(", "int", ")", "$", "curr...
Configures the time that "iat", "nbf" and "exp" should be based on @param int $currentTime
[ "Configures", "the", "time", "that", "iat", "nbf", "and", "exp", "should", "be", "based", "on" ]
b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23
https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/ValidationData.php#L87-L92
train
aegis-security/JWT
src/ValidationData.php
ValidationData.get
public function get($name) { return isset($this->items[$name]) ? $this->items[$name] : null; }
php
public function get($name) { return isset($this->items[$name]) ? $this->items[$name] : null; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "name", "]", ")", "?", "$", "this", "->", "items", "[", "$", "name", "]", ":", "null", ";", "}" ]
Returns the requested item @param string $name @return mixed
[ "Returns", "the", "requested", "item" ]
b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23
https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/ValidationData.php#L101-L104
train
Opifer/Cms
src/CmsBundle/Controller/Backend/LocaleController.php
LocaleController.createAction
public function createAction(Request $request) { $this->denyAccessUnlessGranted('ROLE_ADMIN'); $locale = new Locale(); $form = $this->createForm(new LocaleType(), $locale); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($locale); $em->flush(); $this->addFlash('success', 'Locale has been created successfully'); return $this->redirectToRoute('opifer_cms_locale_edit', ['id' => $locale->getId()]); } return $this->render('OpiferCmsBundle:Backend/Locale:create.html.twig', [ 'locale' => $locale, 'form' => $form->createView() ]); }
php
public function createAction(Request $request) { $this->denyAccessUnlessGranted('ROLE_ADMIN'); $locale = new Locale(); $form = $this->createForm(new LocaleType(), $locale); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($locale); $em->flush(); $this->addFlash('success', 'Locale has been created successfully'); return $this->redirectToRoute('opifer_cms_locale_edit', ['id' => $locale->getId()]); } return $this->render('OpiferCmsBundle:Backend/Locale:create.html.twig', [ 'locale' => $locale, 'form' => $form->createView() ]); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ROLE_ADMIN'", ")", ";", "$", "locale", "=", "new", "Locale", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createF...
Create a locale @param Request $request @return RedirectResponse|Response
[ "Create", "a", "locale" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/LocaleController.php#L43-L66
train
Opifer/Cms
src/CmsBundle/Controller/Backend/LocaleController.php
LocaleController.editAction
public function editAction(Request $request, $id = null) { $this->denyAccessUnlessGranted('ROLE_ADMIN'); $em = $this->getDoctrine()->getManager(); if (is_numeric($id)) { $locale = $em->getRepository(Locale::class)->find($id); } else { $locale = $em->getRepository(Locale::class)->findOneByLocale($id); } $form = $this->createForm(new LocaleType(), $locale); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em->persist($locale); $em->flush(); $this->addFlash('success', 'Locale has been updated successfully'); return $this->redirectToRoute('opifer_cms_locale_edit', ['id' => $locale->getId()]); } return $this->render('OpiferCmsBundle:Backend/Locale:edit.html.twig', [ 'locale' => $locale, 'form' => $form->createView() ]); }
php
public function editAction(Request $request, $id = null) { $this->denyAccessUnlessGranted('ROLE_ADMIN'); $em = $this->getDoctrine()->getManager(); if (is_numeric($id)) { $locale = $em->getRepository(Locale::class)->find($id); } else { $locale = $em->getRepository(Locale::class)->findOneByLocale($id); } $form = $this->createForm(new LocaleType(), $locale); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em->persist($locale); $em->flush(); $this->addFlash('success', 'Locale has been updated successfully'); return $this->redirectToRoute('opifer_cms_locale_edit', ['id' => $locale->getId()]); } return $this->render('OpiferCmsBundle:Backend/Locale:edit.html.twig', [ 'locale' => $locale, 'form' => $form->createView() ]); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "$", "id", "=", "null", ")", "{", "$", "this", "->", "denyAccessUnlessGranted", "(", "'ROLE_ADMIN'", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "g...
Edit a Locale @param Request $request @param $id @return RedirectResponse|Response
[ "Edit", "a", "Locale" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/LocaleController.php#L75-L103
train
Opifer/Cms
src/ContentBundle/Entity/ContentListValue.php
ContentListValue.getOrdered
public function getOrdered() { if (!$this->sort) { return $this->content; } $unordered = []; foreach ($this->content as $content) { $unordered[$content->getId()] = $content; } $ordered = []; $sort = json_decode($this->sort, true); $order = $sort['order']; foreach ($order as $id) { if (isset($unordered[$id])) { $ordered[] = $unordered[$id]; } } return $ordered; }
php
public function getOrdered() { if (!$this->sort) { return $this->content; } $unordered = []; foreach ($this->content as $content) { $unordered[$content->getId()] = $content; } $ordered = []; $sort = json_decode($this->sort, true); $order = $sort['order']; foreach ($order as $id) { if (isset($unordered[$id])) { $ordered[] = $unordered[$id]; } } return $ordered; }
[ "public", "function", "getOrdered", "(", ")", "{", "if", "(", "!", "$", "this", "->", "sort", ")", "{", "return", "$", "this", "->", "content", ";", "}", "$", "unordered", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "content", "as", "$...
Get content items ordered by the sort property @return array
[ "Get", "content", "items", "ordered", "by", "the", "sort", "property" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Entity/ContentListValue.php#L144-L165
train
Opifer/Cms
src/ContentBundle/DependencyInjection/OpiferContentExtension.php
OpiferContentExtension.prepend
public function prepend(ContainerBuilder $container) { $configs = $container->getExtensionConfig($this->getAlias()); $config = $this->processConfiguration(new Configuration(), $configs); $container->setAlias('opifer.content.content_manager', $config['content_manager']); $container->setDefinition('opifer.content.cache_provider', new Definition($config['cache_provider'])); $parameters = $this->getParameters($config); foreach ($parameters as $key => $value) { $container->setParameter($key, $value); } $this->prependExtensionConfig($container, $config); }
php
public function prepend(ContainerBuilder $container) { $configs = $container->getExtensionConfig($this->getAlias()); $config = $this->processConfiguration(new Configuration(), $configs); $container->setAlias('opifer.content.content_manager', $config['content_manager']); $container->setDefinition('opifer.content.cache_provider', new Definition($config['cache_provider'])); $parameters = $this->getParameters($config); foreach ($parameters as $key => $value) { $container->setParameter($key, $value); } $this->prependExtensionConfig($container, $config); }
[ "public", "function", "prepend", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "configs", "=", "$", "container", "->", "getExtensionConfig", "(", "$", "this", "->", "getAlias", "(", ")", ")", ";", "$", "config", "=", "$", "this", "->", "proce...
Prepend our config before other bundles, so we can preset their config with our parameters. @param ContainerBuilder $container
[ "Prepend", "our", "config", "before", "other", "bundles", "so", "we", "can", "preset", "their", "config", "with", "our", "parameters", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/DependencyInjection/OpiferContentExtension.php#L35-L49
train
Opifer/Cms
src/EavBundle/Form/Transformer/CollectionToStringTransformer.php
CollectionToStringTransformer.transform
public function transform($value) { if (null === $value || !($value instanceof Collection)) { return ''; } $string = ''; foreach ($value as $item) { $string .= $item->getId(); if ($value->last() != $item) { $string .= ','; } } return $string; }
php
public function transform($value) { if (null === $value || !($value instanceof Collection)) { return ''; } $string = ''; foreach ($value as $item) { $string .= $item->getId(); if ($value->last() != $item) { $string .= ','; } } return $string; }
[ "public", "function", "transform", "(", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", "||", "!", "(", "$", "value", "instanceof", "Collection", ")", ")", "{", "return", "''", ";", "}", "$", "string", "=", "''", ";", "foreach", "("...
Transforms an ArrayCollection Object to a single Object. @param \Doctrine\ORM\PersistentCollection $value @return Object
[ "Transforms", "an", "ArrayCollection", "Object", "to", "a", "single", "Object", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Form/Transformer/CollectionToStringTransformer.php#L33-L49
train
Opifer/Cms
src/ContentBundle/Serializer/BlockExclusionStrategy.php
BlockExclusionStrategy.shouldSkipClass
public function shouldSkipClass(ClassMetadata $metadata, Context $context) { $obj = null; // Get the last item of the visiting set foreach ($context->getVisitingSet() as $item) { $obj = $item; } if ($obj && $obj instanceof Block && $obj->getParent() && $obj->getParent()->getTemplate() && $obj->getContent() && $obj->getContentId() != $this->content->getId()) { return true; } return false; }
php
public function shouldSkipClass(ClassMetadata $metadata, Context $context) { $obj = null; // Get the last item of the visiting set foreach ($context->getVisitingSet() as $item) { $obj = $item; } if ($obj && $obj instanceof Block && $obj->getParent() && $obj->getParent()->getTemplate() && $obj->getContent() && $obj->getContentId() != $this->content->getId()) { return true; } return false; }
[ "public", "function", "shouldSkipClass", "(", "ClassMetadata", "$", "metadata", ",", "Context", "$", "context", ")", "{", "$", "obj", "=", "null", ";", "// Get the last item of the visiting set", "foreach", "(", "$", "context", "->", "getVisitingSet", "(", ")", ...
Skip blocks of a content item that are children of a template block and do not match the content id. The reason for this is that template blocks could have children from different content items {@inheritdoc}
[ "Skip", "blocks", "of", "a", "content", "item", "that", "are", "children", "of", "a", "template", "block", "and", "do", "not", "match", "the", "content", "id", ".", "The", "reason", "for", "this", "is", "that", "template", "blocks", "could", "have", "chi...
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Serializer/BlockExclusionStrategy.php#L33-L46
train
Opifer/Cms
src/ExpressionEngine/Prototype/PrototypeCollection.php
PrototypeCollection.add
public function add(Prototype $prototype) { if ($this->has($prototype->getKey())) { throw new \Exception(sprintf('A prototype with the key %s already exists', $prototype->getKey())); } $this->collection[] = $prototype; }
php
public function add(Prototype $prototype) { if ($this->has($prototype->getKey())) { throw new \Exception(sprintf('A prototype with the key %s already exists', $prototype->getKey())); } $this->collection[] = $prototype; }
[ "public", "function", "add", "(", "Prototype", "$", "prototype", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "prototype", "->", "getKey", "(", ")", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'A prototype with t...
Adds a prototype to the collection and increments the count. @param Prototype $prototype @throws \Exception If the a prototype with the current key already exists
[ "Adds", "a", "prototype", "to", "the", "collection", "and", "increments", "the", "count", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ExpressionEngine/Prototype/PrototypeCollection.php#L31-L38
train
Opifer/Cms
src/ExpressionEngine/Prototype/PrototypeCollection.php
PrototypeCollection.has
public function has($key) { foreach ($this->collection as $prototype) { if ($key == $prototype->getKey()) { return true; } } return false; }
php
public function has($key) { foreach ($this->collection as $prototype) { if ($key == $prototype->getKey()) { return true; } } return false; }
[ "public", "function", "has", "(", "$", "key", ")", "{", "foreach", "(", "$", "this", "->", "collection", "as", "$", "prototype", ")", "{", "if", "(", "$", "key", "==", "$", "prototype", "->", "getKey", "(", ")", ")", "{", "return", "true", ";", "...
Check if the collection has a prototype with the given key. @param string $key @return bool
[ "Check", "if", "the", "collection", "has", "a", "prototype", "with", "the", "given", "key", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ExpressionEngine/Prototype/PrototypeCollection.php#L57-L66
train
Opifer/Cms
src/EavBundle/Model/Schema.php
Schema.getAttribute
public function getAttribute($name) { foreach ($this->attributes as $attribute) { if ($attribute->getName() == $name) { return $attribute; } } return false; }
php
public function getAttribute($name) { foreach ($this->attributes as $attribute) { if ($attribute->getName() == $name) { return $attribute; } } return false; }
[ "public", "function", "getAttribute", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attribute", ")", "{", "if", "(", "$", "attribute", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "return", "$", ...
Get an attribute by its name @param string $name @return AttributeInterface|false
[ "Get", "an", "attribute", "by", "its", "name" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/Schema.php#L140-L149
train
Opifer/Cms
src/CmsBundle/Repository/ContentRepository.php
ContentRepository.findLastUpdated
public function findLastUpdated($limit = 5) { $query = $this->createQueryBuilder('c') ->orderBy('c.updatedAt', 'DESC') ->where('c.layout = :layout') ->setParameter(':layout', false) ->setMaxResults($limit) ->getQuery(); return $query->getResult(); }
php
public function findLastUpdated($limit = 5) { $query = $this->createQueryBuilder('c') ->orderBy('c.updatedAt', 'DESC') ->where('c.layout = :layout') ->setParameter(':layout', false) ->setMaxResults($limit) ->getQuery(); return $query->getResult(); }
[ "public", "function", "findLastUpdated", "(", "$", "limit", "=", "5", ")", "{", "$", "query", "=", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", "->", "orderBy", "(", "'c.updatedAt'", ",", "'DESC'", ")", "->", "where", "(", "'c.layout = :layout...
Find the last updated content items. @param int $limit @return ArrayCollection
[ "Find", "the", "last", "updated", "content", "items", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Repository/ContentRepository.php#L29-L39
train
Opifer/Cms
src/CmsBundle/Repository/ContentRepository.php
ContentRepository.findLastCreated
public function findLastCreated($limit = 5) { $query = $this->createQueryBuilder('c') ->orderBy('c.createdAt', 'DESC') ->setMaxResults($limit) ->getQuery(); return $query->getResult(); }
php
public function findLastCreated($limit = 5) { $query = $this->createQueryBuilder('c') ->orderBy('c.createdAt', 'DESC') ->setMaxResults($limit) ->getQuery(); return $query->getResult(); }
[ "public", "function", "findLastCreated", "(", "$", "limit", "=", "5", ")", "{", "$", "query", "=", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", "->", "orderBy", "(", "'c.createdAt'", ",", "'DESC'", ")", "->", "setMaxResults", "(", "$", "limi...
Find the last created content items. @param int $limit @return ArrayCollection
[ "Find", "the", "last", "created", "content", "items", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Repository/ContentRepository.php#L48-L56
train
Opifer/Cms
src/CmsBundle/Repository/ContentRepository.php
ContentRepository.findIndexable
public function findIndexable() { return $this->createQueryBuilder('c') ->where('c.indexable = :indexable') ->Andwhere('c.active = :active') ->Andwhere('c.layout = :layout') ->setParameters([ 'active' => true, 'layout' => false, 'indexable' => true ]) ->orderBy('c.slug', 'ASC') ->getQuery() ->getResult(); }
php
public function findIndexable() { return $this->createQueryBuilder('c') ->where('c.indexable = :indexable') ->Andwhere('c.active = :active') ->Andwhere('c.layout = :layout') ->setParameters([ 'active' => true, 'layout' => false, 'indexable' => true ]) ->orderBy('c.slug', 'ASC') ->getQuery() ->getResult(); }
[ "public", "function", "findIndexable", "(", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", "->", "where", "(", "'c.indexable = :indexable'", ")", "->", "Andwhere", "(", "'c.active = :active'", ")", "->", "Andwhere", "(", "'c.layout...
Find all active and addressable content items. @return ArrayCollection|array
[ "Find", "all", "active", "and", "addressable", "content", "items", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Repository/ContentRepository.php#L63-L77
train
CI-Craftsman/CLI
src/Traits/Migration/Info.php
Info.summary
protected function summary($signal, $time_start, $time_end, $query_exec_time, $exec_queries) { $this->newLine(); $this->text(sprintf( '<info>%s</info> query process (%s s)', $signal, number_format($query_exec_time, 4) )); $this->newLine(); $this->text(sprintf('<comment>%s</comment>', str_repeat('-', 30))); $this->newLine(); $this->text(sprintf( '<info>++</info> finished in %s s', number_format(($time_end - $time_start), 4) )); $this->text(sprintf('<info>++</info> %s sql queries', $exec_queries)); }
php
protected function summary($signal, $time_start, $time_end, $query_exec_time, $exec_queries) { $this->newLine(); $this->text(sprintf( '<info>%s</info> query process (%s s)', $signal, number_format($query_exec_time, 4) )); $this->newLine(); $this->text(sprintf('<comment>%s</comment>', str_repeat('-', 30))); $this->newLine(); $this->text(sprintf( '<info>++</info> finished in %s s', number_format(($time_end - $time_start), 4) )); $this->text(sprintf('<info>++</info> %s sql queries', $exec_queries)); }
[ "protected", "function", "summary", "(", "$", "signal", ",", "$", "time_start", ",", "$", "time_end", ",", "$", "query_exec_time", ",", "$", "exec_queries", ")", "{", "$", "this", "->", "newLine", "(", ")", ";", "$", "this", "->", "text", "(", "sprintf...
Display in the console all the migration processes @param string $signal Migration command signal (++,--) @param float $time_start Unix timestamp with microseconds from the start of process @param float $time_end Unix timestamp with microseconds from the end of process @param float $query_exec_time Queries execution time in seconds @param int $exec_queries Amount of executed queries
[ "Display", "in", "the", "console", "all", "the", "migration", "processes" ]
74b900f931548ec5a81ad8c2158d215594f4d601
https://github.com/CI-Craftsman/CLI/blob/74b900f931548ec5a81ad8c2158d215594f4d601/src/Traits/Migration/Info.php#L49-L62
train
Opifer/Cms
src/EavBundle/Form/Transformer/CollectionToObjectTransformer.php
CollectionToObjectTransformer.reverseTransform
public function reverseTransform($value) { if ($value instanceof Collection) { return $value; } $collection = new ArrayCollection(); if(null !== $value) { $collection->add($value); } return $collection; }
php
public function reverseTransform($value) { if ($value instanceof Collection) { return $value; } $collection = new ArrayCollection(); if(null !== $value) { $collection->add($value); } return $collection; }
[ "public", "function", "reverseTransform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Collection", ")", "{", "return", "$", "value", ";", "}", "$", "collection", "=", "new", "ArrayCollection", "(", ")", ";", "if", "(", "null", ...
Transforms a single Object to an ArrayCollection @param Object $value @return ArrayCollection
[ "Transforms", "a", "single", "Object", "to", "an", "ArrayCollection" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Form/Transformer/CollectionToObjectTransformer.php#L34-L46
train
CI-Craftsman/CLI
src/Commands/Serve.php
Serve.configure
protected function configure() { parent::configure(); $this ->addOption( 'host', NULL, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost' ) ->addOption( 'docroot', NULL, InputOption::VALUE_OPTIONAL, 'Specify an explicit document root.', FALSE ) ->addOption( 'port', NULL, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000 ); }
php
protected function configure() { parent::configure(); $this ->addOption( 'host', NULL, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost' ) ->addOption( 'docroot', NULL, InputOption::VALUE_OPTIONAL, 'Specify an explicit document root.', FALSE ) ->addOption( 'port', NULL, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000 ); }
[ "protected", "function", "configure", "(", ")", "{", "parent", "::", "configure", "(", ")", ";", "$", "this", "->", "addOption", "(", "'host'", ",", "NULL", ",", "InputOption", "::", "VALUE_OPTIONAL", ",", "'The host address to serve the application on.'", ",", ...
Command configuration method. Configure all the arguments and options.
[ "Command", "configuration", "method", ".", "Configure", "all", "the", "arguments", "and", "options", "." ]
74b900f931548ec5a81ad8c2158d215594f4d601
https://github.com/CI-Craftsman/CLI/blob/74b900f931548ec5a81ad8c2158d215594f4d601/src/Commands/Serve.php#L30-L56
train
Opifer/Cms
src/CmsBundle/Controller/Frontend/SitemapController.php
SitemapController.sitemapAction
public function sitemapAction() { /* @var ContentInterface[] $content */ $contents = $this->get('opifer.content.content_manager')->getRepository()->findIndexable(); $event = new SitemapEvent(); foreach ($contents as $content) { $event->addUrl($this->generateUrl('_content', ['slug' => $content->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), $content->getUpdatedAt()); } $dispatcher = $this->get('event_dispatcher'); $dispatcher->dispatch(Events::POPULATE_SITEMAP, $event); return $this->render('OpiferCmsBundle:Sitemap:sitemap.xml.twig', [ 'urls' => $event->getUrls(), ]); }
php
public function sitemapAction() { /* @var ContentInterface[] $content */ $contents = $this->get('opifer.content.content_manager')->getRepository()->findIndexable(); $event = new SitemapEvent(); foreach ($contents as $content) { $event->addUrl($this->generateUrl('_content', ['slug' => $content->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), $content->getUpdatedAt()); } $dispatcher = $this->get('event_dispatcher'); $dispatcher->dispatch(Events::POPULATE_SITEMAP, $event); return $this->render('OpiferCmsBundle:Sitemap:sitemap.xml.twig', [ 'urls' => $event->getUrls(), ]); }
[ "public", "function", "sitemapAction", "(", ")", "{", "/* @var ContentInterface[] $content */", "$", "contents", "=", "$", "this", "->", "get", "(", "'opifer.content.content_manager'", ")", "->", "getRepository", "(", ")", "->", "findIndexable", "(", ")", ";", "$"...
Renders the sitemap. @return Response
[ "Renders", "the", "sitemap", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Frontend/SitemapController.php#L19-L36
train
Opifer/Cms
src/ContentBundle/Entity/PointerBlock.php
PointerBlock.getChildren
public function getChildren() { $children = new ArrayCollection(); if ($this->reference) { $children->add($this->reference); } return $children; }
php
public function getChildren() { $children = new ArrayCollection(); if ($this->reference) { $children->add($this->reference); } return $children; }
[ "public", "function", "getChildren", "(", ")", "{", "$", "children", "=", "new", "ArrayCollection", "(", ")", ";", "if", "(", "$", "this", "->", "reference", ")", "{", "$", "children", "->", "add", "(", "$", "this", "->", "reference", ")", ";", "}", ...
Overrides the CompositeBlock's getChildren method to pass the reference as this block's children {@inheritdoc}
[ "Overrides", "the", "CompositeBlock", "s", "getChildren", "method", "to", "pass", "the", "reference", "as", "this", "block", "s", "children" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Entity/PointerBlock.php#L46-L54
train
Opifer/Cms
src/MediaBundle/Provider/YoutubeProvider.php
YoutubeProvider.getUrl
public function getUrl(MediaInterface $media) { $metadata = $media->getMetaData(); return sprintf('%s?v=%s', self::WATCH_URL, $metadata['id']); }
php
public function getUrl(MediaInterface $media) { $metadata = $media->getMetaData(); return sprintf('%s?v=%s', self::WATCH_URL, $metadata['id']); }
[ "public", "function", "getUrl", "(", "MediaInterface", "$", "media", ")", "{", "$", "metadata", "=", "$", "media", "->", "getMetaData", "(", ")", ";", "return", "sprintf", "(", "'%s?v=%s'", ",", "self", "::", "WATCH_URL", ",", "$", "metadata", "[", "'id'...
Get the full url to the original video. @param MediaInterface $media @return string
[ "Get", "the", "full", "url", "to", "the", "original", "video", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MediaBundle/Provider/YoutubeProvider.php#L243-L248
train
CI-Craftsman/CLI
src/Core/Command.php
Command.configure
protected function configure() { $this ->setName($this->name) ->setDescription($this->description) ->setAliases($this->aliases) ->addOption( 'env', null, InputOption::VALUE_REQUIRED, 'Set the environment variable file', sprintf('%s/%s', getcwd(), '.craftsman') ); }
php
protected function configure() { $this ->setName($this->name) ->setDescription($this->description) ->setAliases($this->aliases) ->addOption( 'env', null, InputOption::VALUE_REQUIRED, 'Set the environment variable file', sprintf('%s/%s', getcwd(), '.craftsman') ); }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "setName", "(", "$", "this", "->", "name", ")", "->", "setDescription", "(", "$", "this", "->", "description", ")", "->", "setAliases", "(", "$", "this", "->", "aliases", ")", "->"...
Configure default attributes
[ "Configure", "default", "attributes" ]
74b900f931548ec5a81ad8c2158d215594f4d601
https://github.com/CI-Craftsman/CLI/blob/74b900f931548ec5a81ad8c2158d215594f4d601/src/Core/Command.php#L64-L77
train
CI-Craftsman/CLI
src/Core/Command.php
Command.initialize
protected function initialize(InputInterface $input, OutputInterface $output) { try { $this->input = $input; $this->output = $output; $this->style = new SymfonyStyle($input, $output); $file = new \SplFileInfo($this->getOption('env')); // Create an environment instance $this->env = new Dotenv( $file->getPathInfo()->getRealPath(), $file->getFilename() ); $this->env->load(); $this->env->required(['BASEPATH','APPPATH'])->notEmpty(); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); } }
php
protected function initialize(InputInterface $input, OutputInterface $output) { try { $this->input = $input; $this->output = $output; $this->style = new SymfonyStyle($input, $output); $file = new \SplFileInfo($this->getOption('env')); // Create an environment instance $this->env = new Dotenv( $file->getPathInfo()->getRealPath(), $file->getFilename() ); $this->env->load(); $this->env->required(['BASEPATH','APPPATH'])->notEmpty(); } catch (Exception $e) { throw new \RuntimeException($e->getMessage()); } }
[ "protected", "function", "initialize", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "try", "{", "$", "this", "->", "input", "=", "$", "input", ";", "$", "this", "->", "output", "=", "$", "output", ";", "$", "thi...
Initialize the objects @param InputInterface $input @param OutputInterface $output
[ "Initialize", "the", "objects" ]
74b900f931548ec5a81ad8c2158d215594f4d601
https://github.com/CI-Craftsman/CLI/blob/74b900f931548ec5a81ad8c2158d215594f4d601/src/Core/Command.php#L85-L108
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.createValuedQueryBuilder
public function createValuedQueryBuilder($entityAlias) { return $this->createQueryBuilder($entityAlias) ->select($entityAlias, 'vs', 'v', 'a', 'p', 's') ->leftJoin($entityAlias.'.valueSet', 'vs') ->leftJoin('vs.schema', 's') ->leftJoin('vs.values', 'v') ->leftJoin('s.attributes', 'a') ->leftJoin('v.options', 'p'); }
php
public function createValuedQueryBuilder($entityAlias) { return $this->createQueryBuilder($entityAlias) ->select($entityAlias, 'vs', 'v', 'a', 'p', 's') ->leftJoin($entityAlias.'.valueSet', 'vs') ->leftJoin('vs.schema', 's') ->leftJoin('vs.values', 'v') ->leftJoin('s.attributes', 'a') ->leftJoin('v.options', 'p'); }
[ "public", "function", "createValuedQueryBuilder", "(", "$", "entityAlias", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "$", "entityAlias", ")", "->", "select", "(", "$", "entityAlias", ",", "'vs'", ",", "'v'", ",", "'a'", ",", "'p'", ...
Used by Elastica to transform results to model. @param string $entityAlias @return \Doctrine\ORM\QueryBuilder
[ "Used", "by", "Elastica", "to", "transform", "results", "to", "model", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L23-L32
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.getContentFromRequest
public function getContentFromRequest(Request $request) { $qb = $this->createValuedQueryBuilder('c'); if ($request->get('q')) { $qb->leftJoin('c.template', 't'); $qb->andWhere('c.title LIKE :query OR c.alias LIKE :query OR c.slug LIKE :query OR t.displayName LIKE :query'); $qb->setParameter('query', '%'.$request->get('q').'%'); } if ($ids = $request->get('ids')) { $ids = explode(',', $ids); $qb->andWhere('c.id IN (:ids)')->setParameter('ids', $ids); } $qb->andWhere('c.deletedAt IS NULL AND c.layout = :layout'); // @TODO fix SoftDeleteAble & layout filter $qb->setParameter('layout', false); $qb->orderBy('c.slug'); return $qb->getQuery() ->getResult(); }
php
public function getContentFromRequest(Request $request) { $qb = $this->createValuedQueryBuilder('c'); if ($request->get('q')) { $qb->leftJoin('c.template', 't'); $qb->andWhere('c.title LIKE :query OR c.alias LIKE :query OR c.slug LIKE :query OR t.displayName LIKE :query'); $qb->setParameter('query', '%'.$request->get('q').'%'); } if ($ids = $request->get('ids')) { $ids = explode(',', $ids); $qb->andWhere('c.id IN (:ids)')->setParameter('ids', $ids); } $qb->andWhere('c.deletedAt IS NULL AND c.layout = :layout'); // @TODO fix SoftDeleteAble & layout filter $qb->setParameter('layout', false); $qb->orderBy('c.slug'); return $qb->getQuery() ->getResult(); }
[ "public", "function", "getContentFromRequest", "(", "Request", "$", "request", ")", "{", "$", "qb", "=", "$", "this", "->", "createValuedQueryBuilder", "(", "'c'", ")", ";", "if", "(", "$", "request", "->", "get", "(", "'q'", ")", ")", "{", "$", "qb", ...
Get a querybuilder by request. @param Request $request @return \Doctrine\ORM\QueryBuilder
[ "Get", "a", "querybuilder", "by", "request", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L41-L64
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findOneById
public function findOneById($id) { $query = $this->createValuedQueryBuilder('c') ->where('c.id = :id') ->setParameter('id', $id) ->getQuery(); return $query->useResultCache(true, self::CACHE_TTL)->getSingleResult(); }
php
public function findOneById($id) { $query = $this->createValuedQueryBuilder('c') ->where('c.id = :id') ->setParameter('id', $id) ->getQuery(); return $query->useResultCache(true, self::CACHE_TTL)->getSingleResult(); }
[ "public", "function", "findOneById", "(", "$", "id", ")", "{", "$", "query", "=", "$", "this", "->", "createValuedQueryBuilder", "(", "'c'", ")", "->", "where", "(", "'c.id = :id'", ")", "->", "setParameter", "(", "'id'", ",", "$", "id", ")", "->", "ge...
Find one by ID. @param int $id @return ContentInterface
[ "Find", "one", "by", "ID", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L73-L81
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findOneBySlug
public function findOneBySlug($slug) { $query = $this->createQueryBuilder('c') ->where('c.slug = :slug') ->setParameter('slug', $slug) ->andWhere('c.publishAt < :now OR c.publishAt IS NULL') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->setParameter('now', new \DateTime()) ->setParameter('active', true) ->setParameter('layout', false) ->setMaxResults(1) ->getQuery(); return $query->useResultCache(true, self::CACHE_TTL)->getOneOrNullResult(); }
php
public function findOneBySlug($slug) { $query = $this->createQueryBuilder('c') ->where('c.slug = :slug') ->setParameter('slug', $slug) ->andWhere('c.publishAt < :now OR c.publishAt IS NULL') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->setParameter('now', new \DateTime()) ->setParameter('active', true) ->setParameter('layout', false) ->setMaxResults(1) ->getQuery(); return $query->useResultCache(true, self::CACHE_TTL)->getOneOrNullResult(); }
[ "public", "function", "findOneBySlug", "(", "$", "slug", ")", "{", "$", "query", "=", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", "->", "where", "(", "'c.slug = :slug'", ")", "->", "setParameter", "(", "'slug'", ",", "$", "slug", ")", "->",...
Find one by slug. @param string $slug @return ContentInterface
[ "Find", "one", "by", "slug", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L90-L105
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findOneByIdOrSlug
public function findOneByIdOrSlug($idOrSlug, $allow404 = false) { if (is_numeric($idOrSlug)) { $content = $this->find($idOrSlug); } else { $content = $this->findOneBySlug($idOrSlug); } // If no content was found for the passed id, return the 404 page if (!$content && $allow404 == true) { $content = $this->findOneBySlug('404'); } return $content; }
php
public function findOneByIdOrSlug($idOrSlug, $allow404 = false) { if (is_numeric($idOrSlug)) { $content = $this->find($idOrSlug); } else { $content = $this->findOneBySlug($idOrSlug); } // If no content was found for the passed id, return the 404 page if (!$content && $allow404 == true) { $content = $this->findOneBySlug('404'); } return $content; }
[ "public", "function", "findOneByIdOrSlug", "(", "$", "idOrSlug", ",", "$", "allow404", "=", "false", ")", "{", "if", "(", "is_numeric", "(", "$", "idOrSlug", ")", ")", "{", "$", "content", "=", "$", "this", "->", "find", "(", "$", "idOrSlug", ")", ";...
Finds a content item by its id or slug. When $allow404 is set to true, it will look for a 404 page @param int|string $idOrSlug @param bool $allow404 @return null|object|ContentInterface
[ "Finds", "a", "content", "item", "by", "its", "id", "or", "slug", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L117-L131
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findActiveBySlug
public function findActiveBySlug($slug, $host) { $query = $this->createValuedQueryBuilder('c') ->leftJoin('c.site', 'os') ->leftJoin('os.domains', 'd') ->where('c.slug = :slug') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->andWhere('c.publishAt < :now OR c.publishAt IS NULL') ->andWhere('d.domain = :host OR c.site IS NULL') ->setParameters([ 'slug' => $slug, 'active' => true, 'layout' => false, 'now' => new \DateTime(), 'host' => $host ]) ->getQuery(); return $query->getSingleResult(); }
php
public function findActiveBySlug($slug, $host) { $query = $this->createValuedQueryBuilder('c') ->leftJoin('c.site', 'os') ->leftJoin('os.domains', 'd') ->where('c.slug = :slug') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->andWhere('c.publishAt < :now OR c.publishAt IS NULL') ->andWhere('d.domain = :host OR c.site IS NULL') ->setParameters([ 'slug' => $slug, 'active' => true, 'layout' => false, 'now' => new \DateTime(), 'host' => $host ]) ->getQuery(); return $query->getSingleResult(); }
[ "public", "function", "findActiveBySlug", "(", "$", "slug", ",", "$", "host", ")", "{", "$", "query", "=", "$", "this", "->", "createValuedQueryBuilder", "(", "'c'", ")", "->", "leftJoin", "(", "'c.site'", ",", "'os'", ")", "->", "leftJoin", "(", "'os.do...
Find one by slug with active status. @param string $slug @return ContentInterface
[ "Find", "one", "by", "slug", "with", "active", "status", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L140-L160
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findActiveByAlias
public function findActiveByAlias($alias, $host) { $query = $this->createValuedQueryBuilder('c') ->leftJoin('c.site', 'os') ->leftJoin('os.domains', 'd') ->where('c.alias = :alias') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->andWhere('(c.publishAt < :now OR c.publishAt IS NULL)') ->andWhere('d.domain = :host OR c.site IS NULL') ->setParameters([ 'alias' => $alias, 'active' => true, 'layout' => false, 'now' => new \DateTime(), 'host' => $host ]) ->getQuery(); return $query->getSingleResult(); }
php
public function findActiveByAlias($alias, $host) { $query = $this->createValuedQueryBuilder('c') ->leftJoin('c.site', 'os') ->leftJoin('os.domains', 'd') ->where('c.alias = :alias') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->andWhere('(c.publishAt < :now OR c.publishAt IS NULL)') ->andWhere('d.domain = :host OR c.site IS NULL') ->setParameters([ 'alias' => $alias, 'active' => true, 'layout' => false, 'now' => new \DateTime(), 'host' => $host ]) ->getQuery(); return $query->getSingleResult(); }
[ "public", "function", "findActiveByAlias", "(", "$", "alias", ",", "$", "host", ")", "{", "$", "query", "=", "$", "this", "->", "createValuedQueryBuilder", "(", "'c'", ")", "->", "leftJoin", "(", "'c.site'", ",", "'os'", ")", "->", "leftJoin", "(", "'os....
Find one by alias with active status. @param string $alias @return ContentInterface
[ "Find", "one", "by", "alias", "with", "active", "status", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L169-L189
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findByIds
public function findByIds($ids) { if (!is_array($ids)) { $ids = explode(',', $ids); } if (!$ids) { return []; } return $this->createValuedQueryBuilder('c') ->andWhere('c.id IN (:ids)')->setParameter('ids', $ids) ->andWhere('c.deletedAt IS NULL') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')->setParameter('now', new \DateTime()) ->setParameter('active', true) ->setParameter('layout', false) ->getQuery() ->useResultCache(true, self::CACHE_TTL) ->getResult(); }
php
public function findByIds($ids) { if (!is_array($ids)) { $ids = explode(',', $ids); } if (!$ids) { return []; } return $this->createValuedQueryBuilder('c') ->andWhere('c.id IN (:ids)')->setParameter('ids', $ids) ->andWhere('c.deletedAt IS NULL') ->andWhere('c.active = :active') ->andWhere('c.layout = :layout') ->andWhere('c.publishAt < :now OR c.publishAt IS NULL')->setParameter('now', new \DateTime()) ->setParameter('active', true) ->setParameter('layout', false) ->getQuery() ->useResultCache(true, self::CACHE_TTL) ->getResult(); }
[ "public", "function", "findByIds", "(", "$", "ids", ")", "{", "if", "(", "!", "is_array", "(", "$", "ids", ")", ")", "{", "$", "ids", "=", "explode", "(", "','", ",", "$", "ids", ")", ";", "}", "if", "(", "!", "$", "ids", ")", "{", "return", ...
Find content items by multiple ids. @param array $ids @return Content[]
[ "Find", "content", "items", "by", "multiple", "ids", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L239-L260
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.sortByArray
private function sortByArray($items, array $order) { $unordered = []; foreach ($items as $content) { $unordered[$content->getId()] = $content; } $ordered = []; foreach ($order as $id) { if (isset($unordered[$id])) { $ordered[] = $unordered[$id]; } } return $ordered; }
php
private function sortByArray($items, array $order) { $unordered = []; foreach ($items as $content) { $unordered[$content->getId()] = $content; } $ordered = []; foreach ($order as $id) { if (isset($unordered[$id])) { $ordered[] = $unordered[$id]; } } return $ordered; }
[ "private", "function", "sortByArray", "(", "$", "items", ",", "array", "$", "order", ")", "{", "$", "unordered", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "content", ")", "{", "$", "unordered", "[", "$", "content", "->", "getId", ...
Sort the items by an array of ids. @param ArrayCollection $items @param array $order @return array
[ "Sort", "the", "items", "by", "an", "array", "of", "ids", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L281-L296
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.findByLevels
public function findByLevels($levels = 1, $ids = array()) { $query = $this->createQueryBuilder('c'); if ($levels > 0) { $selects = ['c']; for ($i = 1; $i <= $levels; ++$i) { $selects[] = 'c'.$i; } $query->select($selects); for ($i = 1; $i <= $levels; ++$i) { $previous = ($i - 1 == 0) ? '' : ($i - 1); $query->leftJoin('c'.$previous.'.children', 'c'.$i, 'WITH', 'c'.$i.'.active = :active AND c'.$i.'.showInNavigation = :show'); } } if ($ids) { $query->andWhere('c.id IN (:ids)')->setParameter('ids', $ids); } else { $query->andWhere('c.parent IS NULL'); } $query->andWhere('c.active = :active')->setParameter('active', true); $query->andWhere('c.layout = :layout')->setParameter('layout', false); $query->andWhere('c.showInNavigation = :show')->setParameter('show', true); return $query->getQuery()->getResult(); }
php
public function findByLevels($levels = 1, $ids = array()) { $query = $this->createQueryBuilder('c'); if ($levels > 0) { $selects = ['c']; for ($i = 1; $i <= $levels; ++$i) { $selects[] = 'c'.$i; } $query->select($selects); for ($i = 1; $i <= $levels; ++$i) { $previous = ($i - 1 == 0) ? '' : ($i - 1); $query->leftJoin('c'.$previous.'.children', 'c'.$i, 'WITH', 'c'.$i.'.active = :active AND c'.$i.'.showInNavigation = :show'); } } if ($ids) { $query->andWhere('c.id IN (:ids)')->setParameter('ids', $ids); } else { $query->andWhere('c.parent IS NULL'); } $query->andWhere('c.active = :active')->setParameter('active', true); $query->andWhere('c.layout = :layout')->setParameter('layout', false); $query->andWhere('c.showInNavigation = :show')->setParameter('show', true); return $query->getQuery()->getResult(); }
[ "public", "function", "findByLevels", "(", "$", "levels", "=", "1", ",", "$", "ids", "=", "array", "(", ")", ")", "{", "$", "query", "=", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", ";", "if", "(", "$", "levels", ">", "0", ")", "{",...
Joins and selects the toplevel content items and its children recursively. @param int $levels @return array
[ "Joins", "and", "selects", "the", "toplevel", "content", "items", "and", "its", "children", "recursively", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L305-L334
train
Opifer/Cms
src/ContentBundle/Model/ContentRepository.php
ContentRepository.sortSearchResults
public function sortSearchResults($results, $term) { $sortedResults = []; if (!empty($results)) { foreach ($results as $result) { if (stripos($result->getTitle(), $term) !== false) { array_unshift($sortedResults, $result); } else { $sortedResults[] = $result; } } } return $sortedResults; }
php
public function sortSearchResults($results, $term) { $sortedResults = []; if (!empty($results)) { foreach ($results as $result) { if (stripos($result->getTitle(), $term) !== false) { array_unshift($sortedResults, $result); } else { $sortedResults[] = $result; } } } return $sortedResults; }
[ "public", "function", "sortSearchResults", "(", "$", "results", ",", "$", "term", ")", "{", "$", "sortedResults", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "results", ")", ")", "{", "foreach", "(", "$", "results", "as", "$", "result", ...
Sort search results by giving priority to founded by title. @param array $results @param string $term @return ArrayCollection
[ "Sort", "search", "results", "by", "giving", "priority", "to", "founded", "by", "title", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Model/ContentRepository.php#L384-L399
train
Opifer/Cms
src/CmsBundle/Entity/Cron.php
Cron.setState
public function setState($newState) { if ($newState === $this->state) { return; } switch ($newState) { case self::STATE_RUNNING: $this->startedAt = new \DateTime(); break; case self::STATE_FINISHED: case self::STATE_FAILED: case self::STATE_TERMINATED: $this->endedAt = new \DateTime(); break; default: break; } $this->state = $newState; return $this; }
php
public function setState($newState) { if ($newState === $this->state) { return; } switch ($newState) { case self::STATE_RUNNING: $this->startedAt = new \DateTime(); break; case self::STATE_FINISHED: case self::STATE_FAILED: case self::STATE_TERMINATED: $this->endedAt = new \DateTime(); break; default: break; } $this->state = $newState; return $this; }
[ "public", "function", "setState", "(", "$", "newState", ")", "{", "if", "(", "$", "newState", "===", "$", "this", "->", "state", ")", "{", "return", ";", "}", "switch", "(", "$", "newState", ")", "{", "case", "self", "::", "STATE_RUNNING", ":", "$", ...
Set state. @param bool $state
[ "Set", "state", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Entity/Cron.php#L168-L192
train
Opifer/Cms
src/CmsBundle/Entity/Cron.php
Cron.getNextRunDate
public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getCronExpression()->getNextRunDate($currentTime, $nth, $allowCurrentDate); }
php
public function getNextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getCronExpression()->getNextRunDate($currentTime, $nth, $allowCurrentDate); }
[ "public", "function", "getNextRunDate", "(", "$", "currentTime", "=", "'now'", ",", "$", "nth", "=", "0", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "return", "$", "this", "->", "getCronExpression", "(", ")", "->", "getNextRunDate", "(", "$", ...
Get a next run date relative to the current date or a specific date. @param string|\DateTime $currentTime Relative calculation date @param int $nth Number of matches to skip before returning a matching next run date. 0, the default, will return the current date and time if the next run date falls on the current date and time. Setting this value to 1 will skip the first match and go to the second match. Setting this value to 2 will skip the first 2 matches and so on. @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression. @return \DateTime @throws \RuntimeException on too many iterations
[ "Get", "a", "next", "run", "date", "relative", "to", "the", "current", "date", "or", "a", "specific", "date", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Entity/Cron.php#L341-L344
train
Opifer/Cms
src/CmsBundle/Entity/Cron.php
Cron.getPreviousRunDate
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getCronExpression()->getPreviousRunDate($currentTime, $nth, $allowCurrentDate); }
php
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getCronExpression()->getPreviousRunDate($currentTime, $nth, $allowCurrentDate); }
[ "public", "function", "getPreviousRunDate", "(", "$", "currentTime", "=", "'now'", ",", "$", "nth", "=", "0", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "return", "$", "this", "->", "getCronExpression", "(", ")", "->", "getPreviousRunDate", "(", ...
Get a previous run date relative to the current date or a specific date. @param string|\DateTime $currentTime Relative calculation date @param int $nth Number of matches to skip before returning @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression @return \DateTime @throws \RuntimeException on too many iterations @see Cron\CronExpression::getNextRunDate
[ "Get", "a", "previous", "run", "date", "relative", "to", "the", "current", "date", "or", "a", "specific", "date", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Entity/Cron.php#L360-L363
train
Opifer/Cms
src/CmsBundle/Entity/Cron.php
Cron.getMultipleRunDates
public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate = false) { return $this->getCronExpression()->getMultipleRunDates($total, $currentTime, $invert, $allowCurrentDate); }
php
public function getMultipleRunDates($total, $currentTime = 'now', $invert = false, $allowCurrentDate = false) { return $this->getCronExpression()->getMultipleRunDates($total, $currentTime, $invert, $allowCurrentDate); }
[ "public", "function", "getMultipleRunDates", "(", "$", "total", ",", "$", "currentTime", "=", "'now'", ",", "$", "invert", "=", "false", ",", "$", "allowCurrentDate", "=", "false", ")", "{", "return", "$", "this", "->", "getCronExpression", "(", ")", "->",...
Get multiple run dates starting at the current date or a specific date. @param int $total Set the total number of dates to calculate @param string|\DateTime $currentTime Relative calculation date @param bool $invert Set to TRUE to retrieve previous dates @param bool $allowCurrentDate Set to TRUE to return the current date if it matches the cron expression @return array Returns an array of run dates
[ "Get", "multiple", "run", "dates", "starting", "at", "the", "current", "date", "or", "a", "specific", "date", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Entity/Cron.php#L376-L379
train
Opifer/Cms
src/EavBundle/Entity/SelectValue.php
SelectValue.getValue
public function getValue() { $options = parent::getValue(); if (count($options)) { if (empty( $options[0] )) { $collection = $options->getValues(); return $collection[0]->getName(); } return $options[0]->getName(); } return ''; }
php
public function getValue() { $options = parent::getValue(); if (count($options)) { if (empty( $options[0] )) { $collection = $options->getValues(); return $collection[0]->getName(); } return $options[0]->getName(); } return ''; }
[ "public", "function", "getValue", "(", ")", "{", "$", "options", "=", "parent", "::", "getValue", "(", ")", ";", "if", "(", "count", "(", "$", "options", ")", ")", "{", "if", "(", "empty", "(", "$", "options", "[", "0", "]", ")", ")", "{", "$",...
Get the selected value @return string
[ "Get", "the", "selected", "value" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Entity/SelectValue.php#L20-L35
train
Opifer/Cms
src/CmsBundle/Controller/Backend/UserController.php
UserController.editAction
public function editAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('OpiferCmsBundle:User')->find($id); $form = $this->createForm(UserFormType::class, $user); $form->handleRequest($request); if ($form->isValid()) { if ($user->isTwoFactorEnabled() == false) { $user->setGoogleAuthenticatorSecret(null); } $this->get('fos_user.user_manager')->updateUser($user, true); $this->addFlash('success', $this->get('translator')->trans('user.edit.success', [ '%username%' => ucfirst($user->getUsername()), ])); return $this->redirectToRoute('opifer_cms_user_index'); } return $this->render('OpiferCmsBundle:Backend/User:edit.html.twig', [ 'form' => $form->createView(), 'user' => $user, ]); }
php
public function editAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('OpiferCmsBundle:User')->find($id); $form = $this->createForm(UserFormType::class, $user); $form->handleRequest($request); if ($form->isValid()) { if ($user->isTwoFactorEnabled() == false) { $user->setGoogleAuthenticatorSecret(null); } $this->get('fos_user.user_manager')->updateUser($user, true); $this->addFlash('success', $this->get('translator')->trans('user.edit.success', [ '%username%' => ucfirst($user->getUsername()), ])); return $this->redirectToRoute('opifer_cms_user_index'); } return $this->render('OpiferCmsBundle:Backend/User:edit.html.twig', [ 'form' => $form->createView(), 'user' => $user, ]); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "user", "=", "$", "em", "->", "getRepository", "(", "'...
Edit a user. @param Request $request @param int $id @return Response
[ "Edit", "a", "user", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/UserController.php#L79-L106
train
Opifer/Cms
src/CmsBundle/Controller/Backend/UserController.php
UserController.profileAction
public function profileAction(Request $request) { $user = $this->getUser(); $form = $this->createForm(ProfileType::class, $user); $form->handleRequest($request); if ($form->isValid()) { if ($user->isTwoFactorEnabled() == false) { $user->setGoogleAuthenticatorSecret(null); } $this->get('fos_user.user_manager')->updateUser($user, true); if ($user->isTwoFactorEnabled() == true && empty($user->getGoogleAuthenticatorSecret())) { return $this->redirectToRoute('opifer_cms_user_activate_2fa'); } $this->addFlash('success', 'Your profile was updated successfully!'); return $this->redirectToRoute('opifer_cms_user_profile'); } return $this->render('OpiferCmsBundle:Backend/User:profile.html.twig', [ 'form' => $form->createView(), 'user' => $user, ]); }
php
public function profileAction(Request $request) { $user = $this->getUser(); $form = $this->createForm(ProfileType::class, $user); $form->handleRequest($request); if ($form->isValid()) { if ($user->isTwoFactorEnabled() == false) { $user->setGoogleAuthenticatorSecret(null); } $this->get('fos_user.user_manager')->updateUser($user, true); if ($user->isTwoFactorEnabled() == true && empty($user->getGoogleAuthenticatorSecret())) { return $this->redirectToRoute('opifer_cms_user_activate_2fa'); } $this->addFlash('success', 'Your profile was updated successfully!'); return $this->redirectToRoute('opifer_cms_user_profile'); } return $this->render('OpiferCmsBundle:Backend/User:profile.html.twig', [ 'form' => $form->createView(), 'user' => $user, ]); }
[ "public", "function", "profileAction", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "ProfileType", "::", "class", ",", "$", "user", ")...
Edit the current users' profile. @param Request $request @return Response
[ "Edit", "the", "current", "users", "profile", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/UserController.php#L115-L143
train
Opifer/Cms
src/CmsBundle/Controller/Backend/UserController.php
UserController.activateGoogleAuthAction
public function activateGoogleAuthAction(Request $request) { $user = $this->getUser(); $secret = $this->container->get("scheb_two_factor.security.google_authenticator")->generateSecret(); $user->setGoogleAuthenticatorSecret($secret); //Generate QR url $qrUrl = $this->container->get("scheb_two_factor.security.google_authenticator")->getUrl($user); $form = $this->createForm(GoogleAuthType::class, $user); $form->handleRequest($request); if ($form->isValid()) { $this->get('fos_user.user_manager')->updateUser($user, true); $this->addFlash('success', 'Your profile was updated successfully!'); return $this->redirectToRoute('opifer_cms_user_profile'); } return $this->render('OpiferCmsBundle:Backend/User:google_auth.html.twig', [ 'form' => $form->createView(), 'secret' => $secret, 'user' => $user, 'qrUrl' => $qrUrl, ]); }
php
public function activateGoogleAuthAction(Request $request) { $user = $this->getUser(); $secret = $this->container->get("scheb_two_factor.security.google_authenticator")->generateSecret(); $user->setGoogleAuthenticatorSecret($secret); //Generate QR url $qrUrl = $this->container->get("scheb_two_factor.security.google_authenticator")->getUrl($user); $form = $this->createForm(GoogleAuthType::class, $user); $form->handleRequest($request); if ($form->isValid()) { $this->get('fos_user.user_manager')->updateUser($user, true); $this->addFlash('success', 'Your profile was updated successfully!'); return $this->redirectToRoute('opifer_cms_user_profile'); } return $this->render('OpiferCmsBundle:Backend/User:google_auth.html.twig', [ 'form' => $form->createView(), 'secret' => $secret, 'user' => $user, 'qrUrl' => $qrUrl, ]); }
[ "public", "function", "activateGoogleAuthAction", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "$", "this", "->", "getUser", "(", ")", ";", "$", "secret", "=", "$", "this", "->", "container", "->", "get", "(", "\"scheb_two_factor.security.goog...
Activate Google Authenticator @param Request $request @return Response
[ "Activate", "Google", "Authenticator" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Backend/UserController.php#L152-L179
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.getService
public function getService($block) { $blockType = ($block instanceof BlockInterface) ? $block->getBlockType() : $block; if (!isset($this->services[$blockType])) { throw new \Exception(sprintf("No BlockService available by the alias %s, available: %s", $blockType, implode(', ', array_keys($this->services)))); } return $this->services[$blockType]; }
php
public function getService($block) { $blockType = ($block instanceof BlockInterface) ? $block->getBlockType() : $block; if (!isset($this->services[$blockType])) { throw new \Exception(sprintf("No BlockService available by the alias %s, available: %s", $blockType, implode(', ', array_keys($this->services)))); } return $this->services[$blockType]; }
[ "public", "function", "getService", "(", "$", "block", ")", "{", "$", "blockType", "=", "(", "$", "block", "instanceof", "BlockInterface", ")", "?", "$", "block", "->", "getBlockType", "(", ")", ":", "$", "block", ";", "if", "(", "!", "isset", "(", "...
Returns the block service @param string|BlockInterface $block @return BlockServiceInterface @throws \Exception
[ "Returns", "the", "block", "service" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L131-L139
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.find
public function find($id, $draft = false) { if ($draft) { $this->setDraftVersionFilter(! $draft); } $block = $this->getRepository()->find($id); if ($draft) { if (null !== $revision = $this->revisionManager->getDraftRevision($block)) { $this->revisionManager->revert($block, $revision); } } return $block; }
php
public function find($id, $draft = false) { if ($draft) { $this->setDraftVersionFilter(! $draft); } $block = $this->getRepository()->find($id); if ($draft) { if (null !== $revision = $this->revisionManager->getDraftRevision($block)) { $this->revisionManager->revert($block, $revision); } } return $block; }
[ "public", "function", "find", "(", "$", "id", ",", "$", "draft", "=", "false", ")", "{", "if", "(", "$", "draft", ")", "{", "$", "this", "->", "setDraftVersionFilter", "(", "!", "$", "draft", ")", ";", "}", "$", "block", "=", "$", "this", "->", ...
Find a Block in the repository with optional specified version. @param integer $id @param bool $draft @return BlockInterface
[ "Find", "a", "Block", "in", "the", "repository", "with", "optional", "specified", "version", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L149-L164
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.findById
public function findById($id, $draft = true) { if ($draft) { $this->setDraftVersionFilter(! $draft); } $blocks = $this->getRepository()->findById($id); if ($draft) { foreach ($blocks as $block) { if (null !== $revision = $this->revisionManager->getDraftRevision($block)) { $this->revisionManager->revert($block, $revision); } } } return $blocks; }
php
public function findById($id, $draft = true) { if ($draft) { $this->setDraftVersionFilter(! $draft); } $blocks = $this->getRepository()->findById($id); if ($draft) { foreach ($blocks as $block) { if (null !== $revision = $this->revisionManager->getDraftRevision($block)) { $this->revisionManager->revert($block, $revision); } } } return $blocks; }
[ "public", "function", "findById", "(", "$", "id", ",", "$", "draft", "=", "true", ")", "{", "if", "(", "$", "draft", ")", "{", "$", "this", "->", "setDraftVersionFilter", "(", "!", "$", "draft", ")", ";", "}", "$", "blocks", "=", "$", "this", "->...
Find a Block in the repository in optional draft @param integer $id @param bool $draft @return BlockInterface
[ "Find", "a", "Block", "in", "the", "repository", "in", "optional", "draft" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L174-L191
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.findDescendants
public function findDescendants($parent, $draft = true) { $this->setDraftVersionFilter(! $draft); $iterator = new \RecursiveIteratorIterator( new RecursiveBlockIterator([$parent]), \RecursiveIteratorIterator::SELF_FIRST ); $blocks = []; foreach ($iterator as $descendant) { $blocks[] = $descendant; } if ($draft) { $this->revertToDraft($blocks); } return $blocks; }
php
public function findDescendants($parent, $draft = true) { $this->setDraftVersionFilter(! $draft); $iterator = new \RecursiveIteratorIterator( new RecursiveBlockIterator([$parent]), \RecursiveIteratorIterator::SELF_FIRST ); $blocks = []; foreach ($iterator as $descendant) { $blocks[] = $descendant; } if ($draft) { $this->revertToDraft($blocks); } return $blocks; }
[ "public", "function", "findDescendants", "(", "$", "parent", ",", "$", "draft", "=", "true", ")", "{", "$", "this", "->", "setDraftVersionFilter", "(", "!", "$", "draft", ")", ";", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new",...
Finds the block and all its children recursively @param BlockInterface $parent @param bool $draft @return BlockInterface[]
[ "Finds", "the", "block", "and", "all", "its", "children", "recursively" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L216-L235
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.publish
public function publish($blocks) { if ($blocks instanceof PersistentCollection) { $blocks = $blocks->getValues(); } if (!$blocks || (is_array($blocks) && !count($blocks))) { return; } if (! is_array($blocks)) { $blocks = [$blocks]; } $this->disableRevisionListener(); $deletes = []; foreach ($blocks as $block) { if (null !== $revision = $this->revisionManager->getDraftRevision($block)) { try { $this->revisionManager->revert($block, $revision); } catch (DeletedException $e) { // $this->em->remove($block); $deletes[] = $block; } } } $this->em->flush(); // Cycle through all deleted blocks to perform cascades manually foreach ($deletes as $block) { if ($block instanceof CompositeBlock) { $descendants = $this->findDescendants($block, false); } else { $descendants = [$block]; } foreach ($descendants as $descendant) { $descendant->setDeletedAt(new \DateTime); $this->em->flush($descendant); } } $cacheDriver = $this->em->getConfiguration()->getResultCacheImpl(); $cacheDriver->deleteAll(); $this->enableRevisionListener(); }
php
public function publish($blocks) { if ($blocks instanceof PersistentCollection) { $blocks = $blocks->getValues(); } if (!$blocks || (is_array($blocks) && !count($blocks))) { return; } if (! is_array($blocks)) { $blocks = [$blocks]; } $this->disableRevisionListener(); $deletes = []; foreach ($blocks as $block) { if (null !== $revision = $this->revisionManager->getDraftRevision($block)) { try { $this->revisionManager->revert($block, $revision); } catch (DeletedException $e) { // $this->em->remove($block); $deletes[] = $block; } } } $this->em->flush(); // Cycle through all deleted blocks to perform cascades manually foreach ($deletes as $block) { if ($block instanceof CompositeBlock) { $descendants = $this->findDescendants($block, false); } else { $descendants = [$block]; } foreach ($descendants as $descendant) { $descendant->setDeletedAt(new \DateTime); $this->em->flush($descendant); } } $cacheDriver = $this->em->getConfiguration()->getResultCacheImpl(); $cacheDriver->deleteAll(); $this->enableRevisionListener(); }
[ "public", "function", "publish", "(", "$", "blocks", ")", "{", "if", "(", "$", "blocks", "instanceof", "PersistentCollection", ")", "{", "$", "blocks", "=", "$", "blocks", "->", "getValues", "(", ")", ";", "}", "if", "(", "!", "$", "blocks", "||", "(...
Publishes a block TODO: cleanup created and deleted blocks in revision that were never published. @param BlockInterface|BlockInterface[]|array $blocks
[ "Publishes", "a", "block" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L281-L331
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.duplicate
public function duplicate($blocks, $owner = null) { if ($blocks instanceof BlockInterface) { $blocks = array($blocks); } $iterator = new \RecursiveIteratorIterator( new RecursiveBlockIterator($blocks), \RecursiveIteratorIterator::SELF_FIRST ); $originalIdMap = array(); $originalParentMap = array(); $clones = array(); // iterate over all owned blocks and disconnect parents keeping ids /** @var Block $block */ foreach ($iterator as $block) { $blockId = $block->getId(); $parentId = false; if (in_array($block->getId(), $originalIdMap)) { continue; } $clone = clone $block; $clone->setId(null); $clone->setParent(null); $clone->setOwner($owner); // if it has a parent we need to keep the id as reference for later if ($block->getParent()) { $parentId = $block->getParent()->getId(); } if ($clone instanceof BlockContainerInterface) { $clone->setChildren(null); } $this->em->persist($clone); $this->em->flush($clone); // the block gets a new id $originalIdMap[$clone->getId()] = $blockId; if ($parentId) { $originalParentMap[$clone->getId()] = $parentId; } $clones[] = $clone; } // iterate over all new blocks and reset their parents foreach ($clones as $clone) { if (isset($originalParentMap[$clone->getId()])) { foreach ($clones as $parent) { if (isset($originalParentMap[$clone->getId()]) && $originalParentMap[$clone->getId()] === $originalIdMap[$parent->getId()]) { $clone->setParent($parent); $parent->addChild($clone); $this->em->flush($clone); $this->em->flush($parent); } } } } return $clones; }
php
public function duplicate($blocks, $owner = null) { if ($blocks instanceof BlockInterface) { $blocks = array($blocks); } $iterator = new \RecursiveIteratorIterator( new RecursiveBlockIterator($blocks), \RecursiveIteratorIterator::SELF_FIRST ); $originalIdMap = array(); $originalParentMap = array(); $clones = array(); // iterate over all owned blocks and disconnect parents keeping ids /** @var Block $block */ foreach ($iterator as $block) { $blockId = $block->getId(); $parentId = false; if (in_array($block->getId(), $originalIdMap)) { continue; } $clone = clone $block; $clone->setId(null); $clone->setParent(null); $clone->setOwner($owner); // if it has a parent we need to keep the id as reference for later if ($block->getParent()) { $parentId = $block->getParent()->getId(); } if ($clone instanceof BlockContainerInterface) { $clone->setChildren(null); } $this->em->persist($clone); $this->em->flush($clone); // the block gets a new id $originalIdMap[$clone->getId()] = $blockId; if ($parentId) { $originalParentMap[$clone->getId()] = $parentId; } $clones[] = $clone; } // iterate over all new blocks and reset their parents foreach ($clones as $clone) { if (isset($originalParentMap[$clone->getId()])) { foreach ($clones as $parent) { if (isset($originalParentMap[$clone->getId()]) && $originalParentMap[$clone->getId()] === $originalIdMap[$parent->getId()]) { $clone->setParent($parent); $parent->addChild($clone); $this->em->flush($clone); $this->em->flush($parent); } } } } return $clones; }
[ "public", "function", "duplicate", "(", "$", "blocks", ",", "$", "owner", "=", "null", ")", "{", "if", "(", "$", "blocks", "instanceof", "BlockInterface", ")", "{", "$", "blocks", "=", "array", "(", "$", "blocks", ")", ";", "}", "$", "iterator", "=",...
Clones blocks and persists to database @param BlockInterface $block @param BlockOwnerInterface $owner @return BlockInterface
[ "Clones", "blocks", "and", "persists", "to", "database" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L369-L437
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.setDraftVersionFilter
public function setDraftVersionFilter($enabled = true) { if ($this->em->getFilters()->isEnabled('draft') && ! $enabled) { $this->em->getFilters()->disable('draft'); } else if (! $this->em->getFilters()->isEnabled('draft') && $enabled) { $this->em->getFilters()->enable('draft'); } }
php
public function setDraftVersionFilter($enabled = true) { if ($this->em->getFilters()->isEnabled('draft') && ! $enabled) { $this->em->getFilters()->disable('draft'); } else if (! $this->em->getFilters()->isEnabled('draft') && $enabled) { $this->em->getFilters()->enable('draft'); } }
[ "public", "function", "setDraftVersionFilter", "(", "$", "enabled", "=", "true", ")", "{", "if", "(", "$", "this", "->", "em", "->", "getFilters", "(", ")", "->", "isEnabled", "(", "'draft'", ")", "&&", "!", "$", "enabled", ")", "{", "$", "this", "->...
Kills the DraftVersionFilter
[ "Kills", "the", "DraftVersionFilter" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L463-L470
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.disableRevisionListener
public function disableRevisionListener() { foreach ($this->em->getEventManager()->getListeners() as $event => $listeners) { foreach ($listeners as $hash => $listener) { if ($listener instanceof RevisionListener) { $this->revisionListener = $listener; break 2; } } } if ($this->revisionListener) { $this->revisionListener->setActive(false); } }
php
public function disableRevisionListener() { foreach ($this->em->getEventManager()->getListeners() as $event => $listeners) { foreach ($listeners as $hash => $listener) { if ($listener instanceof RevisionListener) { $this->revisionListener = $listener; break 2; } } } if ($this->revisionListener) { $this->revisionListener->setActive(false); } }
[ "public", "function", "disableRevisionListener", "(", ")", "{", "foreach", "(", "$", "this", "->", "em", "->", "getEventManager", "(", ")", "->", "getListeners", "(", ")", "as", "$", "event", "=>", "$", "listeners", ")", "{", "foreach", "(", "$", "listen...
Removes the RevisionListener from the EventManager
[ "Removes", "the", "RevisionListener", "from", "the", "EventManager" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L475-L489
train
Opifer/Cms
src/ContentBundle/Block/BlockManager.php
BlockManager.getSiblings
public function getSiblings(BlockInterface $block, $version = false) { $owner = $block->getOwner(); $family = $this->findByOwner($owner, $version); $siblings = array(); foreach ($family as $member) { if ($member->getParent() && $member->getParent()->getId() == $block->getParent()->getId()) { array_push($siblings, $member); } } return $siblings; }
php
public function getSiblings(BlockInterface $block, $version = false) { $owner = $block->getOwner(); $family = $this->findByOwner($owner, $version); $siblings = array(); foreach ($family as $member) { if ($member->getParent() && $member->getParent()->getId() == $block->getParent()->getId()) { array_push($siblings, $member); } } return $siblings; }
[ "public", "function", "getSiblings", "(", "BlockInterface", "$", "block", ",", "$", "version", "=", "false", ")", "{", "$", "owner", "=", "$", "block", "->", "getOwner", "(", ")", ";", "$", "family", "=", "$", "this", "->", "findByOwner", "(", "$", "...
Gets the Block nodes siblings at a version. Retrieving siblings from the database could be simple if we did not need to take the changesets into account, because then we would just get all blocks with the same parent. However the changesets in BlockLogEntry probably store changed parents and so they must be applied on the entire tree first before we can tell. @param BlockInterface $block @param integer|bool $version @return false|ArrayCollection
[ "Gets", "the", "Block", "nodes", "siblings", "at", "a", "version", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Block/BlockManager.php#L679-L693
train
Opifer/Cms
src/CmsBundle/Router/ExceptionRouter.php
ExceptionRouter.match
public function match($pathinfo) { $urlMatcher = new UrlMatcher($this->routeCollection, $this->getContext()); $result = $urlMatcher->match($pathinfo); return $result; }
php
public function match($pathinfo) { $urlMatcher = new UrlMatcher($this->routeCollection, $this->getContext()); $result = $urlMatcher->match($pathinfo); return $result; }
[ "public", "function", "match", "(", "$", "pathinfo", ")", "{", "$", "urlMatcher", "=", "new", "UrlMatcher", "(", "$", "this", "->", "routeCollection", ",", "$", "this", "->", "getContext", "(", ")", ")", ";", "$", "result", "=", "$", "urlMatcher", "->"...
Matches anything. @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) @return array An array of parameters
[ "Matches", "anything", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Router/ExceptionRouter.php#L45-L51
train
Opifer/Cms
src/EavBundle/EventListener/EmptyValueListener.php
EmptyValueListener.postLoad
public function postLoad(LifeCycleEventArgs $args) { $entity = $args->getEntity(); if ($entity instanceof ValueSetInterface && $entity->getValues() !== null) { $this->eavManager->replaceEmptyValues($entity); } }
php
public function postLoad(LifeCycleEventArgs $args) { $entity = $args->getEntity(); if ($entity instanceof ValueSetInterface && $entity->getValues() !== null) { $this->eavManager->replaceEmptyValues($entity); } }
[ "public", "function", "postLoad", "(", "LifeCycleEventArgs", "$", "args", ")", "{", "$", "entity", "=", "$", "args", "->", "getEntity", "(", ")", ";", "if", "(", "$", "entity", "instanceof", "ValueSetInterface", "&&", "$", "entity", "->", "getValues", "(",...
Create empty values for non-persisted values. @param LifeCycleEventArgs $args
[ "Create", "empty", "values", "for", "non", "-", "persisted", "values", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/EventListener/EmptyValueListener.php#L36-L43
train
Opifer/Cms
src/EavBundle/EventListener/EmptyValueListener.php
EmptyValueListener.postPersist
public function postPersist(LifeCycleEventArgs $args) { $entity = $args->getEntity(); $entityManager = $args->getEntityManager(); if ($entity instanceof ValueInterface && $entity->isEmpty()) { $entityManager->remove($entity); } }
php
public function postPersist(LifeCycleEventArgs $args) { $entity = $args->getEntity(); $entityManager = $args->getEntityManager(); if ($entity instanceof ValueInterface && $entity->isEmpty()) { $entityManager->remove($entity); } }
[ "public", "function", "postPersist", "(", "LifeCycleEventArgs", "$", "args", ")", "{", "$", "entity", "=", "$", "args", "->", "getEntity", "(", ")", ";", "$", "entityManager", "=", "$", "args", "->", "getEntityManager", "(", ")", ";", "if", "(", "$", "...
Remove empty values after persisting, to avoid null 'Value' values in the database. @param LifeCycleEventArgs $args
[ "Remove", "empty", "values", "after", "persisting", "to", "avoid", "null", "Value", "values", "in", "the", "database", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/EventListener/EmptyValueListener.php#L51-L59
train
Opifer/Cms
src/EavBundle/Repository/SchemaRepository.php
SchemaRepository.findByRequest
public function findByRequest(Request $request) { $qb = $this->createQueryBuilder('s'); if ($request->get('attribute')) { $qb->join('s.allowedInAttributes', 'a') ->andWhere('a.id = :attributeId') ->setParameter('attributeId', $request->get('attribute')); } return $qb->getQuery()->getArrayResult(); }
php
public function findByRequest(Request $request) { $qb = $this->createQueryBuilder('s'); if ($request->get('attribute')) { $qb->join('s.allowedInAttributes', 'a') ->andWhere('a.id = :attributeId') ->setParameter('attributeId', $request->get('attribute')); } return $qb->getQuery()->getArrayResult(); }
[ "public", "function", "findByRequest", "(", "Request", "$", "request", ")", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'s'", ")", ";", "if", "(", "$", "request", "->", "get", "(", "'attribute'", ")", ")", "{", "$", "qb", "->"...
Find schemas by request @param Request $request @return \Doctrine\Common\Collections\ArrayCollection
[ "Find", "schemas", "by", "request" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Repository/SchemaRepository.php#L17-L28
train
Opifer/Cms
src/EavBundle/ValueProvider/Pool.php
Pool.addValue
public function addValue(ValueProviderInterface $value, $alias) { if (false === $value->isEnabled()) { return; } $this->values[$alias] = $value; }
php
public function addValue(ValueProviderInterface $value, $alias) { if (false === $value->isEnabled()) { return; } $this->values[$alias] = $value; }
[ "public", "function", "addValue", "(", "ValueProviderInterface", "$", "value", ",", "$", "alias", ")", "{", "if", "(", "false", "===", "$", "value", "->", "isEnabled", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "values", "[", "$", "al...
Adds all the values, tagged with 'opifer.media.value' to the value pool @param ValueProviderInterface $value @param string $alias
[ "Adds", "all", "the", "values", "tagged", "with", "opifer", ".", "media", ".", "value", "to", "the", "value", "pool" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/ValueProvider/Pool.php#L28-L35
train
Opifer/Cms
src/EavBundle/ValueProvider/Pool.php
Pool.getValueByEntity
public function getValueByEntity($entity) { if (is_object($entity)) { $entity = get_class($entity); } /** @var ValueProviderInterface $provider */ foreach ($this->getValues() as $provider) { if ($entity === $provider->getEntity()) { return $provider; } } return false; }
php
public function getValueByEntity($entity) { if (is_object($entity)) { $entity = get_class($entity); } /** @var ValueProviderInterface $provider */ foreach ($this->getValues() as $provider) { if ($entity === $provider->getEntity()) { return $provider; } } return false; }
[ "public", "function", "getValueByEntity", "(", "$", "entity", ")", "{", "if", "(", "is_object", "(", "$", "entity", ")", ")", "{", "$", "entity", "=", "get_class", "(", "$", "entity", ")", ";", "}", "/** @var ValueProviderInterface $provider */", "foreach", ...
Get a valueprovider by it's entity class @param string|object $entity @return ValueProviderInterface
[ "Get", "a", "valueprovider", "by", "it", "s", "entity", "class" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/ValueProvider/Pool.php#L56-L70
train
borodulin/yii2-codemirror
CodemirrorAsset.php
CodemirrorAsset.registerAssetFiles
public function registerAssetFiles($view) { if (is_array(self::$_assets)) { $this->css = array_values(array_intersect_key(self::$_css, self::$_assets)); $this->js = array_values(array_intersect_key(self::$_js, self::$_assets)); } array_unshift($this->css, self::$_css['lib']); array_unshift($this->js, self::$_js['lib']); parent::registerAssetFiles($view); }
php
public function registerAssetFiles($view) { if (is_array(self::$_assets)) { $this->css = array_values(array_intersect_key(self::$_css, self::$_assets)); $this->js = array_values(array_intersect_key(self::$_js, self::$_assets)); } array_unshift($this->css, self::$_css['lib']); array_unshift($this->js, self::$_js['lib']); parent::registerAssetFiles($view); }
[ "public", "function", "registerAssetFiles", "(", "$", "view", ")", "{", "if", "(", "is_array", "(", "self", "::", "$", "_assets", ")", ")", "{", "$", "this", "->", "css", "=", "array_values", "(", "array_intersect_key", "(", "self", "::", "$", "_css", ...
Registers the CSS and JS files with the given view. @param \yii\web\View $view the view that the asset files are to be registered with.
[ "Registers", "the", "CSS", "and", "JS", "files", "with", "the", "given", "view", "." ]
427485df607720d44ddf964081ba3525b849ae4c
https://github.com/borodulin/yii2-codemirror/blob/427485df607720d44ddf964081ba3525b849ae4c/CodemirrorAsset.php#L492-L501
train
Opifer/Cms
src/CmsBundle/Entity/Site.php
Site.getDefaultDomain
public function getDefaultDomain() { if ($this->defaultDomain) { return $this->defaultDomain; } elseif ($first = $this->getDomains()->first()) { return $first->getDomain(); } else { return null; } }
php
public function getDefaultDomain() { if ($this->defaultDomain) { return $this->defaultDomain; } elseif ($first = $this->getDomains()->first()) { return $first->getDomain(); } else { return null; } }
[ "public", "function", "getDefaultDomain", "(", ")", "{", "if", "(", "$", "this", "->", "defaultDomain", ")", "{", "return", "$", "this", "->", "defaultDomain", ";", "}", "elseif", "(", "$", "first", "=", "$", "this", "->", "getDomains", "(", ")", "->",...
Get defaultDomain. @return string
[ "Get", "defaultDomain", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Entity/Site.php#L255-L264
train
meng-tian/soap-http-binding
src/HttpBinding.php
HttpBinding.request
public function request($name, array $arguments, array $options = null, $inputHeaders = null) { $soapRequest = $this->interpreter->request($name, $arguments, $options, $inputHeaders); if ($soapRequest->getSoapVersion() == '1') { $this->builder->isSOAP11(); } else { $this->builder->isSOAP12(); } $this->builder->setEndpoint($soapRequest->getEndpoint()); $this->builder->setSoapAction($soapRequest->getSoapAction()); $stream = new Stream('php://temp', 'r+'); $stream->write($soapRequest->getSoapMessage()); $stream->rewind(); $this->builder->setSoapMessage($stream); try { return $this->builder->getSoapHttpRequest(); } catch (RequestException $exception) { $stream->close(); throw $exception; } }
php
public function request($name, array $arguments, array $options = null, $inputHeaders = null) { $soapRequest = $this->interpreter->request($name, $arguments, $options, $inputHeaders); if ($soapRequest->getSoapVersion() == '1') { $this->builder->isSOAP11(); } else { $this->builder->isSOAP12(); } $this->builder->setEndpoint($soapRequest->getEndpoint()); $this->builder->setSoapAction($soapRequest->getSoapAction()); $stream = new Stream('php://temp', 'r+'); $stream->write($soapRequest->getSoapMessage()); $stream->rewind(); $this->builder->setSoapMessage($stream); try { return $this->builder->getSoapHttpRequest(); } catch (RequestException $exception) { $stream->close(); throw $exception; } }
[ "public", "function", "request", "(", "$", "name", ",", "array", "$", "arguments", ",", "array", "$", "options", "=", "null", ",", "$", "inputHeaders", "=", "null", ")", "{", "$", "soapRequest", "=", "$", "this", "->", "interpreter", "->", "request", "...
Embed SOAP messages in PSR-7 HTTP Requests @param string $name The name of the SOAP function to bind. @param array $arguments An array of the arguments to the SOAP function. @param array $options An associative array of options. The location option is the URL of the remote Web service. The uri option is the target namespace of the SOAP service. The soapaction option is the action to call. @param mixed $inputHeaders An array of headers to be bound along with the SOAP request. @return RequestInterface @throws RequestException If SOAP HTTP binding failed using the given parameters.
[ "Embed", "SOAP", "messages", "in", "PSR", "-", "7", "HTTP", "Requests" ]
18e76763d7fd467e9c2542646beb45f071dbbae6
https://github.com/meng-tian/soap-http-binding/blob/18e76763d7fd467e9c2542646beb45f071dbbae6/src/HttpBinding.php#L34-L56
train
meng-tian/soap-http-binding
src/HttpBinding.php
HttpBinding.response
public function response(ResponseInterface $response, $name, array &$outputHeaders = null) { return $this->interpreter->response($response->getBody()->__toString(), $name, $outputHeaders); }
php
public function response(ResponseInterface $response, $name, array &$outputHeaders = null) { return $this->interpreter->response($response->getBody()->__toString(), $name, $outputHeaders); }
[ "public", "function", "response", "(", "ResponseInterface", "$", "response", ",", "$", "name", ",", "array", "&", "$", "outputHeaders", "=", "null", ")", "{", "return", "$", "this", "->", "interpreter", "->", "response", "(", "$", "response", "->", "getBod...
Retrieve SOAP messages from PSR-7 HTTP responses and interpret messages to PHP values. @param ResponseInterface $response @param string $name The name of the SOAP function to unbind. @param array $outputHeaders If supplied, this array will be filled with the headers from the SOAP response. @return mixed @throws \SoapFault If the SOAP message contains SOAP faults.
[ "Retrieve", "SOAP", "messages", "from", "PSR", "-", "7", "HTTP", "responses", "and", "interpret", "messages", "to", "PHP", "values", "." ]
18e76763d7fd467e9c2542646beb45f071dbbae6
https://github.com/meng-tian/soap-http-binding/blob/18e76763d7fd467e9c2542646beb45f071dbbae6/src/HttpBinding.php#L68-L71
train
aegis-security/JWT
src/Claim/Factory.php
Factory.create
public function create($name, $value) { if (!empty($this->callbacks[$name])) { return call_user_func($this->callbacks[$name], $name, $value); } return $this->createBasic($name, $value); }
php
public function create($name, $value) { if (!empty($this->callbacks[$name])) { return call_user_func($this->callbacks[$name], $name, $value); } return $this->createBasic($name, $value); }
[ "public", "function", "create", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "callbacks", "[", "$", "name", "]", ")", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "callbacks", "[",...
Create a new claim @param string $name @param mixed $value @return Claim
[ "Create", "a", "new", "claim" ]
b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23
https://github.com/aegis-security/JWT/blob/b5eb646d60d0e9c9bbad5e47a9ec16b5f0d17e23/src/Claim/Factory.php#L51-L58
train
Opifer/Cms
src/ContentBundle/Controller/Api/ContentEditorController.php
ContentEditorController.clipboardBlockAction
public function clipboardBlockAction($id) { /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); /** @var ClipboardBlockService $clipboardService */ $clipboardService = $this->get('opifer.content.clipboard_block'); $response = new JsonResponse; try { $block = $manager->find($id, true); $clipboardService->addToClipboard($block); $blockService = $manager->getService($block); $response->setData(['message' => sprintf('%s copied to clipboard', $blockService->getName())]); } catch (\Exception $e) { $response->setStatusCode(500); $response->setData(['error' => $e->getMessage()]); } return $response; }
php
public function clipboardBlockAction($id) { /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); /** @var ClipboardBlockService $clipboardService */ $clipboardService = $this->get('opifer.content.clipboard_block'); $response = new JsonResponse; try { $block = $manager->find($id, true); $clipboardService->addToClipboard($block); $blockService = $manager->getService($block); $response->setData(['message' => sprintf('%s copied to clipboard', $blockService->getName())]); } catch (\Exception $e) { $response->setStatusCode(500); $response->setData(['error' => $e->getMessage()]); } return $response; }
[ "public", "function", "clipboardBlockAction", "(", "$", "id", ")", "{", "/** @var BlockManager $manager */", "$", "manager", "=", "$", "this", "->", "get", "(", "'opifer.content.block_manager'", ")", ";", "/** @var ClipboardBlockService $clipboardService */", "$", "clipbo...
Copies a reference of a block to the clipboard @param integer $id @return JsonResponse
[ "Copies", "a", "reference", "of", "a", "block", "to", "the", "clipboard" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Api/ContentEditorController.php#L138-L159
train
Opifer/Cms
src/ContentBundle/Controller/Api/ContentEditorController.php
ContentEditorController.publishSharedAction
public function publishSharedAction(Request $request) { $this->getDoctrine()->getManager()->getFilters()->disable('draft'); /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); $response = new JsonResponse; $id = (int) $request->request->get('id'); try { $block = $manager->find($id, true); $block->setUpdatedAt(new \DateTime()); $manager->publish($block); if ($block instanceof CompositeBlock) { $manager->publish($manager->findDescendants($block)); } $response->setStatusCode(200); $response->setData(['state' => 'published']); } catch (\Exception $e) { $response->setStatusCode(500); $response->setData(['error' => $e->getMessage() . $e->getTraceAsString()]); } return $response; }
php
public function publishSharedAction(Request $request) { $this->getDoctrine()->getManager()->getFilters()->disable('draft'); /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); $response = new JsonResponse; $id = (int) $request->request->get('id'); try { $block = $manager->find($id, true); $block->setUpdatedAt(new \DateTime()); $manager->publish($block); if ($block instanceof CompositeBlock) { $manager->publish($manager->findDescendants($block)); } $response->setStatusCode(200); $response->setData(['state' => 'published']); } catch (\Exception $e) { $response->setStatusCode(500); $response->setData(['error' => $e->getMessage() . $e->getTraceAsString()]); } return $response; }
[ "public", "function", "publishSharedAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "getFilters", "(", ")", "->", "disable", "(", "'draft'", ")", ";", "/** @var BlockManager $...
Publishes a shared block and it's members @param Request $request @return JsonResponse
[ "Publishes", "a", "shared", "block", "and", "it", "s", "members" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Api/ContentEditorController.php#L233-L259
train
Opifer/Cms
src/ContentBundle/Controller/Api/ContentEditorController.php
ContentEditorController.discardBlockAction
public function discardBlockAction(Request $request) { $this->getDoctrine()->getManager()->getFilters()->disable('draft'); /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); $response = new JsonResponse; $id = (int) $request->request->get('id'); try { $manager->discardAll($id); $response->setStatusCode(200); $response->setData(['state' => 'discarded']); } catch (\Exception $e) { $response->setStatusCode(500); $response->setData(['error' => $e->getMessage()]); } return $response; }
php
public function discardBlockAction(Request $request) { $this->getDoctrine()->getManager()->getFilters()->disable('draft'); /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); $response = new JsonResponse; $id = (int) $request->request->get('id'); try { $manager->discardAll($id); $response->setStatusCode(200); $response->setData(['state' => 'discarded']); } catch (\Exception $e) { $response->setStatusCode(500); $response->setData(['error' => $e->getMessage()]); } return $response; }
[ "public", "function", "discardBlockAction", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", "->", "getFilters", "(", ")", "->", "disable", "(", "'draft'", ")", ";", "/** @var BlockManager $m...
Discards all changes to block and it's members @param Request $request @return JsonResponse
[ "Discards", "all", "changes", "to", "block", "and", "it", "s", "members" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Api/ContentEditorController.php#L308-L329
train
Opifer/Cms
src/MailingListBundle/Repository/SubscriptionRepository.php
SubscriptionRepository.findPendingSynchronisation
public function findPendingSynchronisation() { return $this->createQueryBuilder('s') ->innerjoin('s.mailingList', 'm') ->andWhere('s.status = :pending OR s.status = :failed') ->setParameters([ 'pending' => Subscription::STATUS_PENDING, 'failed' => Subscription::STATUS_FAILED, ]) ->getQuery() ->getResult(); }
php
public function findPendingSynchronisation() { return $this->createQueryBuilder('s') ->innerjoin('s.mailingList', 'm') ->andWhere('s.status = :pending OR s.status = :failed') ->setParameters([ 'pending' => Subscription::STATUS_PENDING, 'failed' => Subscription::STATUS_FAILED, ]) ->getQuery() ->getResult(); }
[ "public", "function", "findPendingSynchronisation", "(", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'s'", ")", "->", "innerjoin", "(", "'s.mailingList'", ",", "'m'", ")", "->", "andWhere", "(", "'s.status = :pending OR s.status = :failed'", "...
Finds all subscriptions pending synchronisation. @return Subscription[]
[ "Finds", "all", "subscriptions", "pending", "synchronisation", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Repository/SubscriptionRepository.php#L20-L31
train
Opifer/Cms
src/MailingListBundle/Repository/SubscriptionRepository.php
SubscriptionRepository.findPendingSynchronisationList
public function findPendingSynchronisationList(MailingList $mailingList) { return $this->createQueryBuilder('s') ->innerjoin('s.mailingList', 'm') ->where('s.mailingList = :mailingList') ->andWhere('s.status = :pending OR s.status = :failed') ->setParameters([ 'mailingList' => $mailingList, 'pending' => Subscription::STATUS_PENDING, 'failed' => Subscription::STATUS_FAILED, ]) ->getQuery() ->getResult(); }
php
public function findPendingSynchronisationList(MailingList $mailingList) { return $this->createQueryBuilder('s') ->innerjoin('s.mailingList', 'm') ->where('s.mailingList = :mailingList') ->andWhere('s.status = :pending OR s.status = :failed') ->setParameters([ 'mailingList' => $mailingList, 'pending' => Subscription::STATUS_PENDING, 'failed' => Subscription::STATUS_FAILED, ]) ->getQuery() ->getResult(); }
[ "public", "function", "findPendingSynchronisationList", "(", "MailingList", "$", "mailingList", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'s'", ")", "->", "innerjoin", "(", "'s.mailingList'", ",", "'m'", ")", "->", "where", "(", "'s.mail...
Finds all subscriptions pending synchronisation for a specific mailinglist. @param MailingList $mailingList @return Subscription[]
[ "Finds", "all", "subscriptions", "pending", "synchronisation", "for", "a", "specific", "mailinglist", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/MailingListBundle/Repository/SubscriptionRepository.php#L40-L53
train
Opifer/Cms
src/EavBundle/Model/Attribute.php
Attribute.getOptionByName
public function getOptionByName($name) { foreach ($this->options as $option) { if ($option->getName() == $name) { return $option; } } return false; }
php
public function getOptionByName($name) { foreach ($this->options as $option) { if ($option->getName() == $name) { return $option; } } return false; }
[ "public", "function", "getOptionByName", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "options", "as", "$", "option", ")", "{", "if", "(", "$", "option", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "return", "$", "opti...
Get an option by its name. @param string $name @return OptionInterface|false
[ "Get", "an", "option", "by", "its", "name", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/Attribute.php#L345-L354
train
Opifer/Cms
src/EavBundle/Model/Attribute.php
Attribute.addAllowedSchema
public function addAllowedSchema(SchemaInterface $schema) { $exists = false; foreach ($this->allowedSchemas as $allowedSchema) { if ($allowedSchema->getId() == $schema->getId()) { $exists = true; } } if (!$exists) { $this->allowedSchemas[] = $schema; } return $this; }
php
public function addAllowedSchema(SchemaInterface $schema) { $exists = false; foreach ($this->allowedSchemas as $allowedSchema) { if ($allowedSchema->getId() == $schema->getId()) { $exists = true; } } if (!$exists) { $this->allowedSchemas[] = $schema; } return $this; }
[ "public", "function", "addAllowedSchema", "(", "SchemaInterface", "$", "schema", ")", "{", "$", "exists", "=", "false", ";", "foreach", "(", "$", "this", "->", "allowedSchemas", "as", "$", "allowedSchema", ")", "{", "if", "(", "$", "allowedSchema", "->", "...
Add allowed schema. @param SchemaInterface $schema @return AttributeInterface
[ "Add", "allowed", "schema", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Model/Attribute.php#L399-L413
train
Opifer/Cms
src/CmsBundle/DependencyInjection/OpiferCmsExtension.php
OpiferCmsExtension.mapClassParameters
protected function mapClassParameters(array $classes, ContainerBuilder $container) { foreach ($classes as $model => $serviceClasses) { foreach ($serviceClasses as $service => $class) { $container->setParameter( sprintf( 'opifer_cms.%s_%s', $model, $service ), $class ); } } }
php
protected function mapClassParameters(array $classes, ContainerBuilder $container) { foreach ($classes as $model => $serviceClasses) { foreach ($serviceClasses as $service => $class) { $container->setParameter( sprintf( 'opifer_cms.%s_%s', $model, $service ), $class ); } } }
[ "protected", "function", "mapClassParameters", "(", "array", "$", "classes", ",", "ContainerBuilder", "$", "container", ")", "{", "foreach", "(", "$", "classes", "as", "$", "model", "=>", "$", "serviceClasses", ")", "{", "foreach", "(", "$", "serviceClasses", ...
Remap class parameters. @param array $classes @param ContainerBuilder $container
[ "Remap", "class", "parameters", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/DependencyInjection/OpiferCmsExtension.php#L85-L99
train
Opifer/Cms
src/FormBundle/Twig/FormExtension.php
FormExtension.createFormView
public function createFormView(FormInterface $form) { $post = $this->eavManager->initializeEntity($form->getSchema()); $form = $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]); return $form->createView(); }
php
public function createFormView(FormInterface $form) { $post = $this->eavManager->initializeEntity($form->getSchema()); $form = $this->formFactory->create(PostType::class, $post, ['form_id' => $form->getId()]); return $form->createView(); }
[ "public", "function", "createFormView", "(", "FormInterface", "$", "form", ")", "{", "$", "post", "=", "$", "this", "->", "eavManager", "->", "initializeEntity", "(", "$", "form", "->", "getSchema", "(", ")", ")", ";", "$", "form", "=", "$", "this", "-...
Builds a Symfony form from the passed Form entity and returns the related FormView, so we can use our Form as a standard Symfony form in our templates. @param FormInterface $form @return \Symfony\Component\Form\FormView
[ "Builds", "a", "Symfony", "form", "from", "the", "passed", "Form", "entity", "and", "returns", "the", "related", "FormView", "so", "we", "can", "use", "our", "Form", "as", "a", "standard", "Symfony", "form", "in", "our", "templates", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/FormBundle/Twig/FormExtension.php#L48-L55
train
Opifer/Cms
src/ContentBundle/Controller/Frontend/BlockController.php
BlockController.viewAction
public function viewAction($id) { /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); /** @var BlockInterface $block */ $block = $manager->getRepository()->find($id); if (!$block) { throw $this->createNotFoundException(); } $response = new Response(); /** @var Environment $environment */ $environment = $this->get('opifer.content.block_environment'); $environment->setObject($block->getOwner()); $service = $manager->getService($block); $response = $service->execute($block, $response, [ 'partial' => true, 'environment' => $environment ]); return $response; }
php
public function viewAction($id) { /** @var BlockManager $manager */ $manager = $this->get('opifer.content.block_manager'); /** @var BlockInterface $block */ $block = $manager->getRepository()->find($id); if (!$block) { throw $this->createNotFoundException(); } $response = new Response(); /** @var Environment $environment */ $environment = $this->get('opifer.content.block_environment'); $environment->setObject($block->getOwner()); $service = $manager->getService($block); $response = $service->execute($block, $response, [ 'partial' => true, 'environment' => $environment ]); return $response; }
[ "public", "function", "viewAction", "(", "$", "id", ")", "{", "/** @var BlockManager $manager */", "$", "manager", "=", "$", "this", "->", "get", "(", "'opifer.content.block_manager'", ")", ";", "/** @var BlockInterface $block */", "$", "block", "=", "$", "manager",...
Renders a single block Useful for Edge Side Includes (ESI) @param $id @return Response
[ "Renders", "a", "single", "block" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Frontend/BlockController.php#L25-L51
train
Opifer/Cms
src/ContentBundle/Controller/Backend/BlockController.php
BlockController.sharedAction
public function sharedAction() { $blocks = $this->get('opifer.content.block_manager')->getRepository() ->findBy(['shared' => true]); return $this->render($this->getParameter('opifer_content.block_shared_view'), [ 'blocks' => $blocks, ]); }
php
public function sharedAction() { $blocks = $this->get('opifer.content.block_manager')->getRepository() ->findBy(['shared' => true]); return $this->render($this->getParameter('opifer_content.block_shared_view'), [ 'blocks' => $blocks, ]); }
[ "public", "function", "sharedAction", "(", ")", "{", "$", "blocks", "=", "$", "this", "->", "get", "(", "'opifer.content.block_manager'", ")", "->", "getRepository", "(", ")", "->", "findBy", "(", "[", "'shared'", "=>", "true", "]", ")", ";", "return", "...
Block shared view. The template defaults to `OpiferContentBundle:Block:shared.html.twig`, but can easily be overwritten in the bundle configuration. @return Response
[ "Block", "shared", "view", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Backend/BlockController.php#L18-L26
train
Opifer/Cms
src/ContentBundle/EventListener/Serializer/BlockEventSubscriber.php
BlockEventSubscriber.setChildren
protected function setChildren(Block $block) { if (method_exists($block, 'setChildren')) { $children = $this->environment->getBlockChildren($block); $block->setChildren($children); } }
php
protected function setChildren(Block $block) { if (method_exists($block, 'setChildren')) { $children = $this->environment->getBlockChildren($block); $block->setChildren($children); } }
[ "protected", "function", "setChildren", "(", "Block", "$", "block", ")", "{", "if", "(", "method_exists", "(", "$", "block", ",", "'setChildren'", ")", ")", "{", "$", "children", "=", "$", "this", "->", "environment", "->", "getBlockChildren", "(", "$", ...
Maps the block children from the environment to the block @param Block $block
[ "Maps", "the", "block", "children", "from", "the", "environment", "to", "the", "block" ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/EventListener/Serializer/BlockEventSubscriber.php#L64-L70
train
Opifer/Cms
src/ContentBundle/Controller/Backend/ContentTypeController.php
ContentTypeController.indexAction
public function indexAction() { $contentTypes = $this->get('opifer.content.content_type_manager')->getRepository() ->findAll(); return $this->render($this->getParameter('opifer_content.content_type_index_view'), [ 'content_types' => $contentTypes, ]); }
php
public function indexAction() { $contentTypes = $this->get('opifer.content.content_type_manager')->getRepository() ->findAll(); return $this->render($this->getParameter('opifer_content.content_type_index_view'), [ 'content_types' => $contentTypes, ]); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "contentTypes", "=", "$", "this", "->", "get", "(", "'opifer.content.content_type_manager'", ")", "->", "getRepository", "(", ")", "->", "findAll", "(", ")", ";", "return", "$", "this", "->", "render",...
ContentType index view. The template defaults to `OpiferContentBundle:ContentType:index.html.twig`, but can easily be overwritten in the bundle configuration. @return Response
[ "ContentType", "index", "view", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Backend/ContentTypeController.php#L23-L31
train
Opifer/Cms
src/ContentBundle/Controller/Backend/ContentTypeController.php
ContentTypeController.createAction
public function createAction(Request $request) { $contentTypeManager = $this->get('opifer.content.content_type_manager'); $contentType = $contentTypeManager->create(); $form = $this->createForm(ContentTypeType::class, $contentType); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { foreach ($form->getData()->getSchema()->getAttributes() as $attribute) { $attribute->setSchema($contentType->getSchema()); foreach ($attribute->getOptions() as $option) { $option->setAttribute($attribute); } } $contentTypeManager->save($contentType); $this->addFlash('success', 'Content type has been created successfully'); return $this->redirectToRoute('opifer_content_contenttype_edit', ['id' => $contentType->getId()]); } return $this->render($this->getParameter('opifer_content.content_type_create_view'), [ 'content_type' => $contentType, 'form' => $form->createView(), ]); }
php
public function createAction(Request $request) { $contentTypeManager = $this->get('opifer.content.content_type_manager'); $contentType = $contentTypeManager->create(); $form = $this->createForm(ContentTypeType::class, $contentType); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { foreach ($form->getData()->getSchema()->getAttributes() as $attribute) { $attribute->setSchema($contentType->getSchema()); foreach ($attribute->getOptions() as $option) { $option->setAttribute($attribute); } } $contentTypeManager->save($contentType); $this->addFlash('success', 'Content type has been created successfully'); return $this->redirectToRoute('opifer_content_contenttype_edit', ['id' => $contentType->getId()]); } return $this->render($this->getParameter('opifer_content.content_type_create_view'), [ 'content_type' => $contentType, 'form' => $form->createView(), ]); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "contentTypeManager", "=", "$", "this", "->", "get", "(", "'opifer.content.content_type_manager'", ")", ";", "$", "contentType", "=", "$", "contentTypeManager", "->", "create", ...
Create a ContentType. @param Request $request @return RedirectResponse|Response
[ "Create", "a", "ContentType", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ContentBundle/Controller/Backend/ContentTypeController.php#L40-L69
train
Opifer/Cms
src/CmsBundle/Controller/CKEditorController.php
CKEditorController.contentAction
public function contentAction(Request $request) { return $this->render('OpiferCmsBundle:CKEditor:content.html.twig', [ 'funcNum' => $request->get('CKEditorFuncNum'), 'CKEditor' => $request->get('CKEditor'), 'type' => $request->get('type'), ]); }
php
public function contentAction(Request $request) { return $this->render('OpiferCmsBundle:CKEditor:content.html.twig', [ 'funcNum' => $request->get('CKEditorFuncNum'), 'CKEditor' => $request->get('CKEditor'), 'type' => $request->get('type'), ]); }
[ "public", "function", "contentAction", "(", "Request", "$", "request", ")", "{", "return", "$", "this", "->", "render", "(", "'OpiferCmsBundle:CKEditor:content.html.twig'", ",", "[", "'funcNum'", "=>", "$", "request", "->", "get", "(", "'CKEditorFuncNum'", ")", ...
Content browser for CKEditor. @param Request $request @return Response
[ "Content", "browser", "for", "CKEditor", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/CKEditorController.php#L18-L25
train
Opifer/Cms
src/CmsBundle/Controller/CKEditorController.php
CKEditorController.mediaAction
public function mediaAction(Request $request) { $providers = $this->get('opifer.media.provider.pool')->getProviders(); return $this->render('OpiferCmsBundle:CKEditor:media.html.twig', [ 'providers' => $providers, 'funcNum' => $request->get('CKEditorFuncNum'), 'CKEditor' => $request->get('CKEditor'), 'type' => $request->get('type'), ]); }
php
public function mediaAction(Request $request) { $providers = $this->get('opifer.media.provider.pool')->getProviders(); return $this->render('OpiferCmsBundle:CKEditor:media.html.twig', [ 'providers' => $providers, 'funcNum' => $request->get('CKEditorFuncNum'), 'CKEditor' => $request->get('CKEditor'), 'type' => $request->get('type'), ]); }
[ "public", "function", "mediaAction", "(", "Request", "$", "request", ")", "{", "$", "providers", "=", "$", "this", "->", "get", "(", "'opifer.media.provider.pool'", ")", "->", "getProviders", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'Opi...
Image browser for CKEditor. @param Request $request @return Response
[ "Image", "browser", "for", "CKEditor", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/CKEditorController.php#L34-L44
train
Opifer/Cms
src/CmsBundle/Command/CronRunCommand.php
CronRunCommand.isLocked
protected function isLocked(Cron $cron) { $hourAgo = new \DateTime('-65 minutes'); if ($cron->getState() === Cron::STATE_RUNNING && $cron->getStartedAt() > $hourAgo) { return true; } return false; }
php
protected function isLocked(Cron $cron) { $hourAgo = new \DateTime('-65 minutes'); if ($cron->getState() === Cron::STATE_RUNNING && $cron->getStartedAt() > $hourAgo) { return true; } return false; }
[ "protected", "function", "isLocked", "(", "Cron", "$", "cron", ")", "{", "$", "hourAgo", "=", "new", "\\", "DateTime", "(", "'-65 minutes'", ")", ";", "if", "(", "$", "cron", "->", "getState", "(", ")", "===", "Cron", "::", "STATE_RUNNING", "&&", "$", ...
Checks if the cronjob is currently locked. This can be overridden with any other lock check. E.g. usage of Redis in case of a load balanced environment @param Cron $cron @return bool
[ "Checks", "if", "the", "cronjob", "is", "currently", "locked", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Command/CronRunCommand.php#L83-L91
train
Opifer/Cms
src/CmsBundle/Command/CronRunCommand.php
CronRunCommand.startCron
private function startCron(Cron $cron) { if ($this->isLocked($cron)) { return; } $this->output->writeln(sprintf('Started %s.', $cron)); $this->changeState($cron, Cron::STATE_RUNNING); $pb = $this->getCommandProcessBuilder(); $parts = explode(' ', $cron->getCommand()); foreach ($parts as $part) { $pb->add($part); } $process = $pb->getProcess(); $process->setTimeout(3600); try { $process->mustRun(); $this->output->writeln(' > '.$process->getOutput()); if (!$process->isSuccessful()) { $this->output->writeln(' > '.$process->getErrorOutput()); if(strpos($process->getErrorOutput(), 'timeout') !== false) { $this->changeState($cron, Cron::STATE_TERMINATED, $process->getErrorOutput()); } else { $this->changeState($cron, Cron::STATE_FAILED, $process->getErrorOutput()); } } else { $this->changeState($cron, Cron::STATE_FINISHED); } } catch (\Exception $e) { $message = $e->getMessage(); if(strpos($e->getMessage(), 'timeout') !== false) { $this->output->writeln(' > '.$e->getMessage()); $this->changeState($cron, Cron::STATE_TERMINATED, $e->getMessage()); } else { $this->output->writeln(' > '.$e->getMessage()); $this->changeState($cron, Cron::STATE_FAILED, $e->getMessage()); } } }
php
private function startCron(Cron $cron) { if ($this->isLocked($cron)) { return; } $this->output->writeln(sprintf('Started %s.', $cron)); $this->changeState($cron, Cron::STATE_RUNNING); $pb = $this->getCommandProcessBuilder(); $parts = explode(' ', $cron->getCommand()); foreach ($parts as $part) { $pb->add($part); } $process = $pb->getProcess(); $process->setTimeout(3600); try { $process->mustRun(); $this->output->writeln(' > '.$process->getOutput()); if (!$process->isSuccessful()) { $this->output->writeln(' > '.$process->getErrorOutput()); if(strpos($process->getErrorOutput(), 'timeout') !== false) { $this->changeState($cron, Cron::STATE_TERMINATED, $process->getErrorOutput()); } else { $this->changeState($cron, Cron::STATE_FAILED, $process->getErrorOutput()); } } else { $this->changeState($cron, Cron::STATE_FINISHED); } } catch (\Exception $e) { $message = $e->getMessage(); if(strpos($e->getMessage(), 'timeout') !== false) { $this->output->writeln(' > '.$e->getMessage()); $this->changeState($cron, Cron::STATE_TERMINATED, $e->getMessage()); } else { $this->output->writeln(' > '.$e->getMessage()); $this->changeState($cron, Cron::STATE_FAILED, $e->getMessage()); } } }
[ "private", "function", "startCron", "(", "Cron", "$", "cron", ")", "{", "if", "(", "$", "this", "->", "isLocked", "(", "$", "cron", ")", ")", "{", "return", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'Started %s.'",...
Start a cron. @param Cron $cron
[ "Start", "a", "cron", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Command/CronRunCommand.php#L98-L142
train
Opifer/Cms
src/CmsBundle/Command/CronRunCommand.php
CronRunCommand.changeState
private function changeState(Cron $cron, $state, $lastError = null) { $cron->setState($state); $cron->setLastError($lastError); $em = $this->getEntityManager(); $em->persist($cron); $em->flush($cron); }
php
private function changeState(Cron $cron, $state, $lastError = null) { $cron->setState($state); $cron->setLastError($lastError); $em = $this->getEntityManager(); $em->persist($cron); $em->flush($cron); }
[ "private", "function", "changeState", "(", "Cron", "$", "cron", ",", "$", "state", ",", "$", "lastError", "=", "null", ")", "{", "$", "cron", "->", "setState", "(", "$", "state", ")", ";", "$", "cron", "->", "setLastError", "(", "$", "lastError", ")"...
Change the state of the cron. @param Cron $cron @param string $state
[ "Change", "the", "state", "of", "the", "cron", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Command/CronRunCommand.php#L150-L158
train
Opifer/Cms
src/CmsBundle/Command/CronRunCommand.php
CronRunCommand.getCommandProcessBuilder
private function getCommandProcessBuilder() { $pb = new ProcessBuilder(); // PHP wraps the process in "sh -c" by default, but we need to control // the process directly. if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { $pb->add('exec'); } $pb ->add('php') ->add($this->getContainer()->getParameter('kernel.root_dir').'/console') ->add('--env='.$this->env) ; return $pb; }
php
private function getCommandProcessBuilder() { $pb = new ProcessBuilder(); // PHP wraps the process in "sh -c" by default, but we need to control // the process directly. if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { $pb->add('exec'); } $pb ->add('php') ->add($this->getContainer()->getParameter('kernel.root_dir').'/console') ->add('--env='.$this->env) ; return $pb; }
[ "private", "function", "getCommandProcessBuilder", "(", ")", "{", "$", "pb", "=", "new", "ProcessBuilder", "(", ")", ";", "// PHP wraps the process in \"sh -c\" by default, but we need to control", "// the process directly.", "if", "(", "!", "defined", "(", "'PHP_WINDOWS_VE...
Get the process builder. @return \Symfony\Component\Process\ProcessBuilder
[ "Get", "the", "process", "builder", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Command/CronRunCommand.php#L165-L182
train
Opifer/Cms
src/EavBundle/Repository/OptionRepository.php
OptionRepository.findByIds
public function findByIds($ids) { if (!is_array($ids)) { $ids = explode(',', trim($ids)); } return $this->createQueryBuilder('o') ->where('o.id IN (:ids)') ->setParameters([ 'ids' => $ids, ]) ->getQuery() ->getResult(); }
php
public function findByIds($ids) { if (!is_array($ids)) { $ids = explode(',', trim($ids)); } return $this->createQueryBuilder('o') ->where('o.id IN (:ids)') ->setParameters([ 'ids' => $ids, ]) ->getQuery() ->getResult(); }
[ "public", "function", "findByIds", "(", "$", "ids", ")", "{", "if", "(", "!", "is_array", "(", "$", "ids", ")", ")", "{", "$", "ids", "=", "explode", "(", "','", ",", "trim", "(", "$", "ids", ")", ")", ";", "}", "return", "$", "this", "->", "...
Find all options by an array or comma-separated list of ids. @param array|string $ids @return array
[ "Find", "all", "options", "by", "an", "array", "or", "comma", "-", "separated", "list", "of", "ids", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/EavBundle/Repository/OptionRepository.php#L33-L46
train
lichunqiang/yii2-sweet-submit
SweetSubmitAsset.php
SweetSubmitAsset.initOptions
protected function initOptions() { $view = Yii::$app->view; $opts = [ 'confirmButtonText' => Yii::t('sweetsubmit', 'Ok'), 'cancelButtonText' => Yii::t('sweetsubmit', 'Cancel'), ]; $opts = Json::encode($opts); $view->registerJs("yii.sweetSubmitOptions = $opts;", View::POS_END); }
php
protected function initOptions() { $view = Yii::$app->view; $opts = [ 'confirmButtonText' => Yii::t('sweetsubmit', 'Ok'), 'cancelButtonText' => Yii::t('sweetsubmit', 'Cancel'), ]; $opts = Json::encode($opts); $view->registerJs("yii.sweetSubmitOptions = $opts;", View::POS_END); }
[ "protected", "function", "initOptions", "(", ")", "{", "$", "view", "=", "Yii", "::", "$", "app", "->", "view", ";", "$", "opts", "=", "[", "'confirmButtonText'", "=>", "Yii", "::", "t", "(", "'sweetsubmit'", ",", "'Ok'", ")", ",", "'cancelButtonText'", ...
Init plugin optins.
[ "Init", "plugin", "optins", "." ]
987c6ea570f1283cfa1b48fd9f4405fed1862f19
https://github.com/lichunqiang/yii2-sweet-submit/blob/987c6ea570f1283cfa1b48fd9f4405fed1862f19/SweetSubmitAsset.php#L55-L66
train
Opifer/Cms
src/CmsBundle/Controller/Frontend/ExceptionController.php
ExceptionController.error404Action
public function error404Action(Request $request) { $host = $request->getHost(); $slugParts = explode('/', $request->getPathInfo()); $locale = $this->getDoctrine()->getRepository(Locale::class) ->findOneByLocale($slugParts[1]); /** @var ContentRepository $contentRepository */ $contentRepository = $this->getDoctrine()->getRepository('OpiferCmsBundle:Content'); $content = $contentRepository->findActiveBySlug('404', $host); if(!$content) { $content = $contentRepository->findOneBySlug($locale->getLocale().'/404'); } if (!$content) { $content = $contentRepository->findOneBySlug('404'); } if ($content) { return $this->forward('OpiferContentBundle:Frontend/Content:view', [ 'content' => $content, 'statusCode' => 404, ]); } $response = new Response(); $response->setStatusCode(404); return $this->render('OpiferCmsBundle:Exception:error404.html.twig', [], $response); }
php
public function error404Action(Request $request) { $host = $request->getHost(); $slugParts = explode('/', $request->getPathInfo()); $locale = $this->getDoctrine()->getRepository(Locale::class) ->findOneByLocale($slugParts[1]); /** @var ContentRepository $contentRepository */ $contentRepository = $this->getDoctrine()->getRepository('OpiferCmsBundle:Content'); $content = $contentRepository->findActiveBySlug('404', $host); if(!$content) { $content = $contentRepository->findOneBySlug($locale->getLocale().'/404'); } if (!$content) { $content = $contentRepository->findOneBySlug('404'); } if ($content) { return $this->forward('OpiferContentBundle:Frontend/Content:view', [ 'content' => $content, 'statusCode' => 404, ]); } $response = new Response(); $response->setStatusCode(404); return $this->render('OpiferCmsBundle:Exception:error404.html.twig', [], $response); }
[ "public", "function", "error404Action", "(", "Request", "$", "request", ")", "{", "$", "host", "=", "$", "request", "->", "getHost", "(", ")", ";", "$", "slugParts", "=", "explode", "(", "'/'", ",", "$", "request", "->", "getPathInfo", "(", ")", ")", ...
404 error page. @param Request $request @return Response
[ "404", "error", "page", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/CmsBundle/Controller/Frontend/ExceptionController.php#L19-L50
train
Opifer/Cms
src/ExpressionEngine/ExpressionEngine.php
ExpressionEngine.transform
protected function transform(Expression $expression) { $constraint = $expression->getConstraint(); $getter = 'get'.ucfirst($expression->getSelector()); return Expr::method($getter, new $constraint($expression->getValue())); }
php
protected function transform(Expression $expression) { $constraint = $expression->getConstraint(); $getter = 'get'.ucfirst($expression->getSelector()); return Expr::method($getter, new $constraint($expression->getValue())); }
[ "protected", "function", "transform", "(", "Expression", "$", "expression", ")", "{", "$", "constraint", "=", "$", "expression", "->", "getConstraint", "(", ")", ";", "$", "getter", "=", "'get'", ".", "ucfirst", "(", "$", "expression", "->", "getSelector", ...
Transform the expression to Webmozarts' Expression. @param Expression $expression @return \Webmozart\Expression\Expression
[ "Transform", "the", "expression", "to", "Webmozarts", "Expression", "." ]
fa288bc9d58bf9078c2fa265fa63064fa9323797
https://github.com/Opifer/Cms/blob/fa288bc9d58bf9078c2fa265fa63064fa9323797/src/ExpressionEngine/ExpressionEngine.php#L90-L96
train