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
Victoire/victoire
Bundle/CoreBundle/Builder/ViewCssBuilder.php
ViewCssBuilder.removeCssFile
public function removeCssFile($hash) { $file = $this->getViewCssFileFromHash($hash); if (file_exists($file)) { unlink($file); } }
php
public function removeCssFile($hash) { $file = $this->getViewCssFileFromHash($hash); if (file_exists($file)) { unlink($file); } }
[ "public", "function", "removeCssFile", "(", "$", "hash", ")", "{", "$", "file", "=", "$", "this", "->", "getViewCssFileFromHash", "(", "$", "hash", ")", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "unlink", "(", "$", "file", ")", ...
Remove css file. @param $hash
[ "Remove", "css", "file", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Builder/ViewCssBuilder.php#L107-L113
train
Victoire/victoire
Bundle/CoreBundle/Builder/ViewCssBuilder.php
ViewCssBuilder.clearViewCssFolder
public function clearViewCssFolder() { if (!is_dir($this->viewCssDir)) { return; } $files = glob($this->viewCssDir.DIRECTORY_SEPARATOR.'*'); foreach ($files as $file) { if (is_file($file)) { unlink($file); } } }
php
public function clearViewCssFolder() { if (!is_dir($this->viewCssDir)) { return; } $files = glob($this->viewCssDir.DIRECTORY_SEPARATOR.'*'); foreach ($files as $file) { if (is_file($file)) { unlink($file); } } }
[ "public", "function", "clearViewCssFolder", "(", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "viewCssDir", ")", ")", "{", "return", ";", "}", "$", "files", "=", "glob", "(", "$", "this", "->", "viewCssDir", ".", "DIRECTORY_SEPARATOR", "...
Remove all views css files.
[ "Remove", "all", "views", "css", "files", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Builder/ViewCssBuilder.php#L118-L130
train
Victoire/victoire
Bundle/CoreBundle/Builder/ViewCssBuilder.php
ViewCssBuilder.cssFileExists
public function cssFileExists(View $view) { $file = $this->getViewCssFileFromHash($view->getCssHash()); return file_exists($file); }
php
public function cssFileExists(View $view) { $file = $this->getViewCssFileFromHash($view->getCssHash()); return file_exists($file); }
[ "public", "function", "cssFileExists", "(", "View", "$", "view", ")", "{", "$", "file", "=", "$", "this", "->", "getViewCssFileFromHash", "(", "$", "view", "->", "getCssHash", "(", ")", ")", ";", "return", "file_exists", "(", "$", "file", ")", ";", "}"...
Tell if css file exists for a given View. @param View $view @return bool
[ "Tell", "if", "css", "file", "exists", "for", "a", "given", "View", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Builder/ViewCssBuilder.php#L139-L144
train
Victoire/victoire
Bundle/CoreBundle/Builder/ViewCssBuilder.php
ViewCssBuilder.writeCssFile
private function writeCssFile(View $view, $css) { $oldmask = umask(0); if (!is_dir($this->viewCssDir)) { mkdir($this->viewCssDir, 0777, true); } $file = $this->getViewCssFile($view); file_put_contents($file, $css); umask($oldmask); }
php
private function writeCssFile(View $view, $css) { $oldmask = umask(0); if (!is_dir($this->viewCssDir)) { mkdir($this->viewCssDir, 0777, true); } $file = $this->getViewCssFile($view); file_put_contents($file, $css); umask($oldmask); }
[ "private", "function", "writeCssFile", "(", "View", "$", "view", ",", "$", "css", ")", "{", "$", "oldmask", "=", "umask", "(", "0", ")", ";", "if", "(", "!", "is_dir", "(", "$", "this", "->", "viewCssDir", ")", ")", "{", "mkdir", "(", "$", "this"...
Write css file. @param $view @param $css
[ "Write", "css", "file", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Builder/ViewCssBuilder.php#L164-L173
train
Victoire/victoire
Bundle/WidgetBundle/Model/WidgetManager.php
WidgetManager.newWidget
public function newWidget($mode, $type, $slot, $view, $position, $parentWidgetMap, $quantum) { $quantum = $this->widgetFormBuilder->convertToString($quantum); $widget = $this->widgetHelper->newWidgetInstance($type, $view, $slot, $mode); $widgets = [$widget]; /** @var BusinessEntity[] $classes */ $classes = $this->cacheReader->getBusinessClassesForWidget($widget); $forms = $this->widgetFormBuilder->renderNewQuantumForms($slot, $view, $widgets, $widget, $classes, $position, $parentWidgetMap, $quantum); return [ 'widget' => $widget, 'html' => $this->templating->render( 'VictoireCoreBundle:Widget:Form/new.html.twig', [ 'id' => time(), 'view' => $view, 'slot' => $slot, 'position' => $position, 'parentWidgetMap' => $parentWidgetMap, 'classes' => $classes, 'widgets' => $widgets, 'widget' => $widget, 'forms' => $forms, ] ), ]; }
php
public function newWidget($mode, $type, $slot, $view, $position, $parentWidgetMap, $quantum) { $quantum = $this->widgetFormBuilder->convertToString($quantum); $widget = $this->widgetHelper->newWidgetInstance($type, $view, $slot, $mode); $widgets = [$widget]; /** @var BusinessEntity[] $classes */ $classes = $this->cacheReader->getBusinessClassesForWidget($widget); $forms = $this->widgetFormBuilder->renderNewQuantumForms($slot, $view, $widgets, $widget, $classes, $position, $parentWidgetMap, $quantum); return [ 'widget' => $widget, 'html' => $this->templating->render( 'VictoireCoreBundle:Widget:Form/new.html.twig', [ 'id' => time(), 'view' => $view, 'slot' => $slot, 'position' => $position, 'parentWidgetMap' => $parentWidgetMap, 'classes' => $classes, 'widgets' => $widgets, 'widget' => $widget, 'forms' => $forms, ] ), ]; }
[ "public", "function", "newWidget", "(", "$", "mode", ",", "$", "type", ",", "$", "slot", ",", "$", "view", ",", "$", "position", ",", "$", "parentWidgetMap", ",", "$", "quantum", ")", "{", "$", "quantum", "=", "$", "this", "->", "widgetFormBuilder", ...
new widget. @param string $type @param string $slot @param View $view @param int $position @return array
[ "new", "widget", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Model/WidgetManager.php#L120-L148
train
Victoire/victoire
Bundle/WidgetBundle/Model/WidgetManager.php
WidgetManager.createWidget
public function createWidget($mode, $type, $slotId, View $view, $entity, $position, $widgetReference, $quantum) { //services $formErrorHelper = $this->formErrorHelper; $request = $this->getRequest(); if ($view instanceof VirtualBusinessPage) { $this->virtualToBpTransformer->transform($view); } //create a new widget $widget = $this->widgetHelper->newWidgetInstance($type, $view, $slotId, $mode); $form = $this->widgetFormBuilder->callBuildFormSwitchParameters($widget, $view, $entity, $position, $widgetReference, $slotId, $quantum); $noValidate = $request->query->get('novalidate', false); $form->handleRequest($request); if ($noValidate === false && $form->isValid()) { if (!$view->getId()) { //create a view for the business entity instance if we are currently on a virtual one $this->entityManager->persist($view); } //get the widget from the form $widget = $form->getData(); //update fields of the widget $widget->setBusinessEntityId($entity); //persist the widget $this->entityManager->persist($widget); $this->entityManager->flush(); $this->widgetMapManager->insert($widget, $view, $slotId, $position, $widgetReference); $this->entityManager->persist($view); $this->entityManager->flush(); $widget->setCurrentView($view); $event = new WidgetFlushedEvent($widget); $this->eventDispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_FLUSH, $event); $this->eventDispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_FLUSH.'_'.strtoupper($type), $event); $this->widgetMapBuilder->build($view); //get the html for the widget $htmlWidget = $this->widgetRenderer->renderContainer($widget, $view); $response = [ 'success' => true, 'widgetId' => $widget->getId(), 'html' => $htmlWidget, ]; } else { //get the errors as a string $response = [ 'success' => false, 'message' => $noValidate === false ? $formErrorHelper->getRecursiveReadableErrors($form) : null, 'html' => $this->widgetFormBuilder->renderNewForm($form, $widget, $slotId, $view, $quantum, $entity), ]; } return $response; }
php
public function createWidget($mode, $type, $slotId, View $view, $entity, $position, $widgetReference, $quantum) { //services $formErrorHelper = $this->formErrorHelper; $request = $this->getRequest(); if ($view instanceof VirtualBusinessPage) { $this->virtualToBpTransformer->transform($view); } //create a new widget $widget = $this->widgetHelper->newWidgetInstance($type, $view, $slotId, $mode); $form = $this->widgetFormBuilder->callBuildFormSwitchParameters($widget, $view, $entity, $position, $widgetReference, $slotId, $quantum); $noValidate = $request->query->get('novalidate', false); $form->handleRequest($request); if ($noValidate === false && $form->isValid()) { if (!$view->getId()) { //create a view for the business entity instance if we are currently on a virtual one $this->entityManager->persist($view); } //get the widget from the form $widget = $form->getData(); //update fields of the widget $widget->setBusinessEntityId($entity); //persist the widget $this->entityManager->persist($widget); $this->entityManager->flush(); $this->widgetMapManager->insert($widget, $view, $slotId, $position, $widgetReference); $this->entityManager->persist($view); $this->entityManager->flush(); $widget->setCurrentView($view); $event = new WidgetFlushedEvent($widget); $this->eventDispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_FLUSH, $event); $this->eventDispatcher->dispatch(VictoireCmsEvents::WIDGET_POST_FLUSH.'_'.strtoupper($type), $event); $this->widgetMapBuilder->build($view); //get the html for the widget $htmlWidget = $this->widgetRenderer->renderContainer($widget, $view); $response = [ 'success' => true, 'widgetId' => $widget->getId(), 'html' => $htmlWidget, ]; } else { //get the errors as a string $response = [ 'success' => false, 'message' => $noValidate === false ? $formErrorHelper->getRecursiveReadableErrors($form) : null, 'html' => $this->widgetFormBuilder->renderNewForm($form, $widget, $slotId, $view, $quantum, $entity), ]; } return $response; }
[ "public", "function", "createWidget", "(", "$", "mode", ",", "$", "type", ",", "$", "slotId", ",", "View", "$", "view", ",", "$", "entity", ",", "$", "position", ",", "$", "widgetReference", ",", "$", "quantum", ")", "{", "//services", "$", "formErrorH...
Create a widget. @param string $mode @param string $type @param string $slotId @param View $view @param string $entity @param string $type @throws \Exception @return Template
[ "Create", "a", "widget", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Model/WidgetManager.php#L164-L228
train
Victoire/victoire
Bundle/WidgetBundle/Model/WidgetManager.php
WidgetManager.editWidgetStyle
public function editWidgetStyle(Request $request, Widget $widget, View $view, $viewReference = null, $activeQuantum = null) { if ($request->getMethod() === 'POST') { $form = $this->widgetFormBuilder->buildWidgetStyleForm($widget, $viewReference, $activeQuantum); $form->handleRequest($request); if ($request->query->get('novalidate', false) === false && $form->isValid()) { if ($form->has('deleteBackground') && $form->get('deleteBackground')->getData()) { // @todo: dynamic responsive key foreach (['', 'XS', 'SM', 'MD', 'LG'] as $key) { $widget->{'deleteBackground'.$key}(); } } $this->entityManager->flush(); $params = [ 'view' => $view, 'success' => true, 'html' => $this->widgetRenderer->render($widget, $view), 'widgetId' => $widget->getId(), 'viewCssHash' => $view->getCssHash(), ]; } else { $template = ($request->query->get('novalidate', false) !== false) ? 'VictoireCoreBundle:Widget/Form/stylize:form.html.twig' : 'VictoireCoreBundle:Widget/Form:stylize.html.twig'; $params = [ 'success' => !$form->isSubmitted(), 'html' => $this->templating->render( $template, [ 'view' => $view, 'form' => $form->createView(), 'widget' => $widget, 'victoire_twig_responsive' => $this->twigResponsive, ] ), ]; } } else { $widgets = $widget->getWidgetMap()->getWidgets(); $forms = $this->widgetFormBuilder->renderQuantumStyleForms($viewReference, $widgets, $widget); $params = [ 'html' => $this->templating->render( 'VictoireCoreBundle:Widget/Form:stylize.html.twig', [ 'view' => $view, 'forms' => $forms, 'widget' => $widget, 'widgets' => $widgets, 'victoire_twig_responsive' => $this->twigResponsive, ] ), ]; } return new JsonResponse($params); }
php
public function editWidgetStyle(Request $request, Widget $widget, View $view, $viewReference = null, $activeQuantum = null) { if ($request->getMethod() === 'POST') { $form = $this->widgetFormBuilder->buildWidgetStyleForm($widget, $viewReference, $activeQuantum); $form->handleRequest($request); if ($request->query->get('novalidate', false) === false && $form->isValid()) { if ($form->has('deleteBackground') && $form->get('deleteBackground')->getData()) { // @todo: dynamic responsive key foreach (['', 'XS', 'SM', 'MD', 'LG'] as $key) { $widget->{'deleteBackground'.$key}(); } } $this->entityManager->flush(); $params = [ 'view' => $view, 'success' => true, 'html' => $this->widgetRenderer->render($widget, $view), 'widgetId' => $widget->getId(), 'viewCssHash' => $view->getCssHash(), ]; } else { $template = ($request->query->get('novalidate', false) !== false) ? 'VictoireCoreBundle:Widget/Form/stylize:form.html.twig' : 'VictoireCoreBundle:Widget/Form:stylize.html.twig'; $params = [ 'success' => !$form->isSubmitted(), 'html' => $this->templating->render( $template, [ 'view' => $view, 'form' => $form->createView(), 'widget' => $widget, 'victoire_twig_responsive' => $this->twigResponsive, ] ), ]; } } else { $widgets = $widget->getWidgetMap()->getWidgets(); $forms = $this->widgetFormBuilder->renderQuantumStyleForms($viewReference, $widgets, $widget); $params = [ 'html' => $this->templating->render( 'VictoireCoreBundle:Widget/Form:stylize.html.twig', [ 'view' => $view, 'forms' => $forms, 'widget' => $widget, 'widgets' => $widgets, 'victoire_twig_responsive' => $this->twigResponsive, ] ), ]; } return new JsonResponse($params); }
[ "public", "function", "editWidgetStyle", "(", "Request", "$", "request", ",", "Widget", "$", "widget", ",", "View", "$", "view", ",", "$", "viewReference", "=", "null", ",", "$", "activeQuantum", "=", "null", ")", "{", "if", "(", "$", "request", "->", ...
Edit widget style. @param Request $request @param Widget $widget @param View $view @param string $viewReference @param string $activeQuantum @return JsonResponse
[ "Edit", "widget", "style", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Model/WidgetManager.php#L337-L391
train
Victoire/victoire
Bundle/WidgetBundle/Model/WidgetManager.php
WidgetManager.deleteWidget
public function deleteWidget(Widget $widget, View $view) { //we update the widget map of the view $this->widgetMapBuilder->build($view); $widgetMap = $widget->getWidgetMap(); //the widget is removed only if the current view is the view of the widget if ($widgetMap->getView() == $view && $widgetMap->getAction() != WidgetMap::ACTION_DELETE) { //we remove the widget $this->entityManager->remove($widget); } //update the view deleting the widget $this->widgetMapManager->delete($view, $widget); //we update the view $this->entityManager->persist($view); $this->entityManager->flush(); }
php
public function deleteWidget(Widget $widget, View $view) { //we update the widget map of the view $this->widgetMapBuilder->build($view); $widgetMap = $widget->getWidgetMap(); //the widget is removed only if the current view is the view of the widget if ($widgetMap->getView() == $view && $widgetMap->getAction() != WidgetMap::ACTION_DELETE) { //we remove the widget $this->entityManager->remove($widget); } //update the view deleting the widget $this->widgetMapManager->delete($view, $widget); //we update the view $this->entityManager->persist($view); $this->entityManager->flush(); }
[ "public", "function", "deleteWidget", "(", "Widget", "$", "widget", ",", "View", "$", "view", ")", "{", "//we update the widget map of the view", "$", "this", "->", "widgetMapBuilder", "->", "build", "(", "$", "view", ")", ";", "$", "widgetMap", "=", "$", "w...
Remove a widget. @param Widget $widget @param View $view @return void
[ "Remove", "a", "widget", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Model/WidgetManager.php#L401-L419
train
Victoire/victoire
Bundle/WidgetBundle/Model/WidgetManager.php
WidgetManager.overwriteWidget
public function overwriteWidget(View $view, Widget $widget) { $widgetCopy = $this->cloneEntity($widget); $originalWidgetMap = $widget->getWidgetMap(); $this->widgetMapManager->overwrite($view, $originalWidgetMap, $widgetCopy); return $widgetCopy; }
php
public function overwriteWidget(View $view, Widget $widget) { $widgetCopy = $this->cloneEntity($widget); $originalWidgetMap = $widget->getWidgetMap(); $this->widgetMapManager->overwrite($view, $originalWidgetMap, $widgetCopy); return $widgetCopy; }
[ "public", "function", "overwriteWidget", "(", "View", "$", "view", ",", "Widget", "$", "widget", ")", "{", "$", "widgetCopy", "=", "$", "this", "->", "cloneEntity", "(", "$", "widget", ")", ";", "$", "originalWidgetMap", "=", "$", "widget", "->", "getWid...
Overwrite the widget for the current view because the widget is not linked to the current view, a copy is created. @param View $view @param Widget $widget @throws \Exception The slot does not exists @return Widget The widget
[ "Overwrite", "the", "widget", "for", "the", "current", "view", "because", "the", "widget", "is", "not", "linked", "to", "the", "current", "view", "a", "copy", "is", "created", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Model/WidgetManager.php#L431-L438
train
Victoire/victoire
Bundle/WidgetBundle/Resolver/WidgetContentResolver.php
WidgetContentResolver.getWidgetContent
public function getWidgetContent(Widget $widget) { //the mode of display of the widget $mode = $widget->getMode(); //the widget must have a mode if ($mode === null) { throw new \Exception('The widget ['.$widget->getId().'] has no mode.'); } $resolver = $this->widgetContentResolverChain->getResolverForWidget($widget); switch ($mode) { case Widget::MODE_STATIC: $parameters = $resolver->getWidgetStaticContent($widget); break; case Widget::MODE_ENTITY: //get the content of the widget with its entity $parameters = $resolver->getWidgetEntityContent($widget); break; case Widget::MODE_BUSINESS_ENTITY: //get the content of the widget with its entity $parameters = $resolver->getWidgetBusinessEntityContent($widget); break; case Widget::MODE_QUERY: $parameters = $resolver->getWidgetQueryContent($widget); break; default: throw new \Exception('The mode ['.$mode.'] is not supported by the widget manager. Widget ID:['.$widget->getId().']'); } return $parameters; }
php
public function getWidgetContent(Widget $widget) { //the mode of display of the widget $mode = $widget->getMode(); //the widget must have a mode if ($mode === null) { throw new \Exception('The widget ['.$widget->getId().'] has no mode.'); } $resolver = $this->widgetContentResolverChain->getResolverForWidget($widget); switch ($mode) { case Widget::MODE_STATIC: $parameters = $resolver->getWidgetStaticContent($widget); break; case Widget::MODE_ENTITY: //get the content of the widget with its entity $parameters = $resolver->getWidgetEntityContent($widget); break; case Widget::MODE_BUSINESS_ENTITY: //get the content of the widget with its entity $parameters = $resolver->getWidgetBusinessEntityContent($widget); break; case Widget::MODE_QUERY: $parameters = $resolver->getWidgetQueryContent($widget); break; default: throw new \Exception('The mode ['.$mode.'] is not supported by the widget manager. Widget ID:['.$widget->getId().']'); } return $parameters; }
[ "public", "function", "getWidgetContent", "(", "Widget", "$", "widget", ")", "{", "//the mode of display of the widget", "$", "mode", "=", "$", "widget", "->", "getMode", "(", ")", ";", "//the widget must have a mode", "if", "(", "$", "mode", "===", "null", ")",...
Get content for the widget. @param Widget $widget @throws \Exception @return array
[ "Get", "content", "for", "the", "widget", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Resolver/WidgetContentResolver.php#L26-L58
train
Victoire/victoire
Bundle/BlogBundle/Repository/BlogRepository.php
BlogRepository.hasMultipleBlog
public function hasMultipleBlog() { $queryBuilder = $this->createQueryBuilder('blog') ->select('b_translation.id') ->join('blog.translations', 'b_translation'); return count($queryBuilder->getQuery()->getResult()) >= 1; }
php
public function hasMultipleBlog() { $queryBuilder = $this->createQueryBuilder('blog') ->select('b_translation.id') ->join('blog.translations', 'b_translation'); return count($queryBuilder->getQuery()->getResult()) >= 1; }
[ "public", "function", "hasMultipleBlog", "(", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'blog'", ")", "->", "select", "(", "'b_translation.id'", ")", "->", "join", "(", "'blog.translations'", ",", "'b_translation'", ")", ...
Return true if at least one Blog has multiple translations. @return bool
[ "Return", "true", "if", "at", "least", "one", "Blog", "has", "multiple", "translations", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/BlogRepository.php#L17-L24
train
Victoire/victoire
Bundle/BlogBundle/Repository/BlogRepository.php
BlogRepository.getUsedLocales
public function getUsedLocales() { $queryBuilder = $this->createQueryBuilder('blog') ->select('DISTINCT(b_translation.locale) AS locale') ->join('blog.translations', 'b_translation'); $locales = []; foreach ($queryBuilder->getQuery()->getResult() as $locale) { $locales[] = $locale['locale']; } return $locales; }
php
public function getUsedLocales() { $queryBuilder = $this->createQueryBuilder('blog') ->select('DISTINCT(b_translation.locale) AS locale') ->join('blog.translations', 'b_translation'); $locales = []; foreach ($queryBuilder->getQuery()->getResult() as $locale) { $locales[] = $locale['locale']; } return $locales; }
[ "public", "function", "getUsedLocales", "(", ")", "{", "$", "queryBuilder", "=", "$", "this", "->", "createQueryBuilder", "(", "'blog'", ")", "->", "select", "(", "'DISTINCT(b_translation.locale) AS locale'", ")", "->", "join", "(", "'blog.translations'", ",", "'b...
Get all locales used by Blogs. @return array
[ "Get", "all", "locales", "used", "by", "Blogs", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/BlogRepository.php#L31-L43
train
Victoire/victoire
Bundle/BlogBundle/Repository/BlogRepository.php
BlogRepository.getBlogsForLocale
public function getBlogsForLocale($locale) { $blogs = $this->joinTranslations($locale)->getInstance()->getQuery()->getResult(); $this->clearInstance(); return $blogs; }
php
public function getBlogsForLocale($locale) { $blogs = $this->joinTranslations($locale)->getInstance()->getQuery()->getResult(); $this->clearInstance(); return $blogs; }
[ "public", "function", "getBlogsForLocale", "(", "$", "locale", ")", "{", "$", "blogs", "=", "$", "this", "->", "joinTranslations", "(", "$", "locale", ")", "->", "getInstance", "(", ")", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "$"...
Get all Blogs for a given locale. @param $locale @return array
[ "Get", "all", "Blogs", "for", "a", "given", "locale", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Repository/BlogRepository.php#L52-L59
train
Victoire/victoire
Bundle/BusinessPageBundle/Listener/BusinessPageMenuListener.php
BusinessPageMenuListener.addGlobal
public function addGlobal(Event $event) { $this->mainItem = $this->menuBuilder->getBottomLeftNavbar()->getChild('menu.additionals'); if ($this->menuBuilder->isGranted('ROLE_VICTOIRE_BET')) { $this ->mainItem ->addChild( 'menu.business_template', [ 'route' => 'victoire_business_template_index', 'linkAttributes' => [ 'class' => 'v-drop__anchor', ], ] ) ->setLinkAttribute('data-toggle', 'vic-modal'); } return $this->mainItem; }
php
public function addGlobal(Event $event) { $this->mainItem = $this->menuBuilder->getBottomLeftNavbar()->getChild('menu.additionals'); if ($this->menuBuilder->isGranted('ROLE_VICTOIRE_BET')) { $this ->mainItem ->addChild( 'menu.business_template', [ 'route' => 'victoire_business_template_index', 'linkAttributes' => [ 'class' => 'v-drop__anchor', ], ] ) ->setLinkAttribute('data-toggle', 'vic-modal'); } return $this->mainItem; }
[ "public", "function", "addGlobal", "(", "Event", "$", "event", ")", "{", "$", "this", "->", "mainItem", "=", "$", "this", "->", "menuBuilder", "->", "getBottomLeftNavbar", "(", ")", "->", "getChild", "(", "'menu.additionals'", ")", ";", "if", "(", "$", "...
Add a global menu item. @param Event $event @return \Knp\Menu\ItemInterface @SuppressWarnings checkUnusedFunctionParameters
[ "Add", "a", "global", "menu", "item", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Listener/BusinessPageMenuListener.php#L36-L56
train
Victoire/victoire
Bundle/BusinessPageBundle/Listener/BusinessPageMenuListener.php
BusinessPageMenuListener.addContextual
public function addContextual($event) { $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar(); //if there is a template, we add the link in the top bar $bottomRightNavbar->addChild('menu.page.settings', [ 'route' => 'victoire_business_template_edit', 'routeParameters' => ['id' => $event->getPage()->getId()], 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', ], ] )->setLinkAttribute('data-toggle', 'vic-modal'); $bottomRightNavbar->addChild('menu.page.seoSettings', [ 'route' => 'victoire_seo_pageSeo_settings', 'routeParameters' => ['id' => $event->getPage()->getId()], 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', ], ] )->setLinkAttribute('data-toggle', 'vic-modal'); }
php
public function addContextual($event) { $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar(); //if there is a template, we add the link in the top bar $bottomRightNavbar->addChild('menu.page.settings', [ 'route' => 'victoire_business_template_edit', 'routeParameters' => ['id' => $event->getPage()->getId()], 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', ], ] )->setLinkAttribute('data-toggle', 'vic-modal'); $bottomRightNavbar->addChild('menu.page.seoSettings', [ 'route' => 'victoire_seo_pageSeo_settings', 'routeParameters' => ['id' => $event->getPage()->getId()], 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', ], ] )->setLinkAttribute('data-toggle', 'vic-modal'); }
[ "public", "function", "addContextual", "(", "$", "event", ")", "{", "$", "bottomRightNavbar", "=", "$", "this", "->", "menuBuilder", "->", "getBottomRightNavbar", "(", ")", ";", "//if there is a template, we add the link in the top bar", "$", "bottomRightNavbar", "->", ...
Add the parent menu for a page that extends another one. @param PageMenuContextualEvent $event @return \Knp\Menu\ItemInterface
[ "Add", "the", "parent", "menu", "for", "a", "page", "that", "extends", "another", "one", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Listener/BusinessPageMenuListener.php#L65-L88
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.indexAction
public function indexAction(Request $request, $blog = null, $tab = 'articles') { /** @var BlogRepository $blogRepo */ $blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog'); // Default value for locale $locale = $request->getLocale(); // Overwrite locale when a locale is chosen in the form if ($chooseBlog = $request->request->get('choose_blog')) { if (array_key_exists('locale', $chooseBlog)) { $locale = $chooseBlog['locale']; } } $parameters = [ 'locale' => $locale, 'blog' => $blog, 'currentTab' => $tab, 'tabs' => ['articles', 'drafts', 'settings', 'category'], 'businessProperties' => $blog ? $this->getBusinessProperties($blog) : null, ]; if ($blogRepo->hasMultipleBlog()) { $chooseBlogForm = $this->createForm(ChooseBlogType::class, null, [ 'blog' => $blog, 'locale' => $locale, ]); $chooseBlogForm->handleRequest($request); $parameters = array_merge( $parameters, ['chooseBlogForm' => $chooseBlogForm->createView()], $chooseBlogForm->getData() ); } return $this->render( 'VictoireBlogBundle:Blog:index.html.twig', $parameters ); }
php
public function indexAction(Request $request, $blog = null, $tab = 'articles') { /** @var BlogRepository $blogRepo */ $blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog'); // Default value for locale $locale = $request->getLocale(); // Overwrite locale when a locale is chosen in the form if ($chooseBlog = $request->request->get('choose_blog')) { if (array_key_exists('locale', $chooseBlog)) { $locale = $chooseBlog['locale']; } } $parameters = [ 'locale' => $locale, 'blog' => $blog, 'currentTab' => $tab, 'tabs' => ['articles', 'drafts', 'settings', 'category'], 'businessProperties' => $blog ? $this->getBusinessProperties($blog) : null, ]; if ($blogRepo->hasMultipleBlog()) { $chooseBlogForm = $this->createForm(ChooseBlogType::class, null, [ 'blog' => $blog, 'locale' => $locale, ]); $chooseBlogForm->handleRequest($request); $parameters = array_merge( $parameters, ['chooseBlogForm' => $chooseBlogForm->createView()], $chooseBlogForm->getData() ); } return $this->render( 'VictoireBlogBundle:Blog:index.html.twig', $parameters ); }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ",", "$", "blog", "=", "null", ",", "$", "tab", "=", "'articles'", ")", "{", "/** @var BlogRepository $blogRepo */", "$", "blogRepo", "=", "$", "this", "->", "get", "(", "'doctrine.orm.entity...
List all Blogs. @Route("/index/{blogId}/{tab}", name="victoire_blog_index", defaults={"blogId" = null, "tab" = "articles"}) @ParamConverter("blog", class="VictoireBlogBundle:Blog", options={"id" = "blogId"}) @param Request $request @throws \OutOfBoundsException @return JsonResponse
[ "List", "all", "Blogs", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L42-L81
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.feedAction
public function feedAction(Request $request, Blog $blog) { $articles = $blog->getPublishedArticles(); if ($categoryId = $request->query->get('category')) { $entityManager = $this->getDoctrine()->getManager(); /** @var Category $category */ $category = $entityManager->getRepository('VictoireBlogBundle:BlogCategory')->find($categoryId); $categoryIds = []; function findIds(BlogCategory $category, &$categoryIds) { $categoryIds[] = $category->getId(); foreach ($category->getChildren() as $childCategory) { findIds($childCategory, $categoryIds); } } findIds($category, $categoryIds); $articles = $articles->filter(function ($article) use ($categoryIds) { /* @var Article $article */ return $article->getCategory() && in_array($article->getCategory()->getId(), $categoryIds, true); }); } return $this->render('VictoireBlogBundle:Blog:feed.rss.twig', [ 'blog' => $blog, 'articles' => $articles, ]); }
php
public function feedAction(Request $request, Blog $blog) { $articles = $blog->getPublishedArticles(); if ($categoryId = $request->query->get('category')) { $entityManager = $this->getDoctrine()->getManager(); /** @var Category $category */ $category = $entityManager->getRepository('VictoireBlogBundle:BlogCategory')->find($categoryId); $categoryIds = []; function findIds(BlogCategory $category, &$categoryIds) { $categoryIds[] = $category->getId(); foreach ($category->getChildren() as $childCategory) { findIds($childCategory, $categoryIds); } } findIds($category, $categoryIds); $articles = $articles->filter(function ($article) use ($categoryIds) { /* @var Article $article */ return $article->getCategory() && in_array($article->getCategory()->getId(), $categoryIds, true); }); } return $this->render('VictoireBlogBundle:Blog:feed.rss.twig', [ 'blog' => $blog, 'articles' => $articles, ]); }
[ "public", "function", "feedAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "articles", "=", "$", "blog", "->", "getPublishedArticles", "(", ")", ";", "if", "(", "$", "categoryId", "=", "$", "request", "->", "query", "-...
Display Blogs RSS feed. @Route("/feed/{id}.rss", name="victoire_blog_rss", defaults={"_format" = "rss"}) @param Request $request @return Response
[ "Display", "Blogs", "RSS", "feed", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L92-L122
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.settingsAction
public function settingsAction(Request $request, BasePage $blog) { $form = $this->getSettingsForm($blog); $form->handleRequest($request); if ($request->isMethod('POST')) { if ($form->isValid()) { $this->getDoctrine()->getManager()->flush(); $form = $this->getSettingsForm($blog); } else { $this->warn('error_occured'); } } return $this->render( 'VictoireBlogBundle:Blog/Tabs:_settings.html.twig', [ 'blog' => $blog, 'form' => $form->createView(), 'businessProperties' => [], ], new Response(null, 200, [ 'X-Inject-Alertify' => true, ]) ); }
php
public function settingsAction(Request $request, BasePage $blog) { $form = $this->getSettingsForm($blog); $form->handleRequest($request); if ($request->isMethod('POST')) { if ($form->isValid()) { $this->getDoctrine()->getManager()->flush(); $form = $this->getSettingsForm($blog); } else { $this->warn('error_occured'); } } return $this->render( 'VictoireBlogBundle:Blog/Tabs:_settings.html.twig', [ 'blog' => $blog, 'form' => $form->createView(), 'businessProperties' => [], ], new Response(null, 200, [ 'X-Inject-Alertify' => true, ]) ); }
[ "public", "function", "settingsAction", "(", "Request", "$", "request", ",", "BasePage", "$", "blog", ")", "{", "$", "form", "=", "$", "this", "->", "getSettingsForm", "(", "$", "blog", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ...
Display a form to edit Blog settings. @param Request $request @param BasePage $blog @Route("/{id}/settings", name="victoire_blog_settings") @Method(methods={"GET", "POST"}) @ParamConverter("blog", class="VictoirePageBundle:BasePage") @throws \InvalidArgumentException @return Response
[ "Display", "a", "form", "to", "edit", "Blog", "settings", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L164-L189
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.categoryAction
public function categoryAction(Request $request, BasePage $blog) { $entityManager = $this->getDoctrine()->getManager(); $form = $this->createForm($this->getPageCategoryType(), $blog); $businessProperties = $this->getBusinessProperties($blog); $form->handleRequest($request); if ($form->isValid()) { $entityManager->persist($blog); $entityManager->flush(); return new JsonResponse([ 'success' => true, 'url' => $this->generateUrl('victoire_core_page_show', ['_locale' => $blog->getCurrentLocale(), 'url' => $blog->getUrl()]), ]); } //we display the form $errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form); if ($errors != '') { return new JsonResponse( [ 'html' => $this->container->get('templating')->render( 'VictoireBlogBundle:Blog:Tabs/_category.html.twig', [ 'blog' => $blog, 'form' => $form->createView(), 'businessProperties' => $businessProperties, ] ), 'message' => $errors, ] ); } return new Response( $this->container->get('templating')->render( $this->getBaseTemplatePath().':Tabs/_category.html.twig', [ 'blog' => $blog, 'form' => $form->createView(), 'businessProperties' => $businessProperties, ] ) ); }
php
public function categoryAction(Request $request, BasePage $blog) { $entityManager = $this->getDoctrine()->getManager(); $form = $this->createForm($this->getPageCategoryType(), $blog); $businessProperties = $this->getBusinessProperties($blog); $form->handleRequest($request); if ($form->isValid()) { $entityManager->persist($blog); $entityManager->flush(); return new JsonResponse([ 'success' => true, 'url' => $this->generateUrl('victoire_core_page_show', ['_locale' => $blog->getCurrentLocale(), 'url' => $blog->getUrl()]), ]); } //we display the form $errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form); if ($errors != '') { return new JsonResponse( [ 'html' => $this->container->get('templating')->render( 'VictoireBlogBundle:Blog:Tabs/_category.html.twig', [ 'blog' => $blog, 'form' => $form->createView(), 'businessProperties' => $businessProperties, ] ), 'message' => $errors, ] ); } return new Response( $this->container->get('templating')->render( $this->getBaseTemplatePath().':Tabs/_category.html.twig', [ 'blog' => $blog, 'form' => $form->createView(), 'businessProperties' => $businessProperties, ] ) ); }
[ "public", "function", "categoryAction", "(", "Request", "$", "request", ",", "BasePage", "$", "blog", ")", "{", "$", "entityManager", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "form", "=", "$", "this", "->...
List Blog Categories. @param Request $request @param BasePage $blog @Route("/{id}/category", name="victoire_blog_category") @ParamConverter("blog", class="VictoirePageBundle:BasePage") @return Response
[ "List", "Blog", "Categories", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L202-L246
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.articlesAction
public function articlesAction(Request $request, BasePage $blog, $articleLocale = null) { $articles = $this->getDoctrine() ->getRepository(Article::class) ->getArticles($blog); return new Response($this->container->get('templating')->render( $this->getBaseTemplatePath().':Tabs/_articles.html.twig', [ 'locale' => $articleLocale ? $articleLocale : $request->getLocale(), 'blog' => $blog, 'articles' => $articles, ] )); }
php
public function articlesAction(Request $request, BasePage $blog, $articleLocale = null) { $articles = $this->getDoctrine() ->getRepository(Article::class) ->getArticles($blog); return new Response($this->container->get('templating')->render( $this->getBaseTemplatePath().':Tabs/_articles.html.twig', [ 'locale' => $articleLocale ? $articleLocale : $request->getLocale(), 'blog' => $blog, 'articles' => $articles, ] )); }
[ "public", "function", "articlesAction", "(", "Request", "$", "request", ",", "BasePage", "$", "blog", ",", "$", "articleLocale", "=", "null", ")", "{", "$", "articles", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "Article",...
List Blog articles. @param Request $request @param BasePage $blog @Route("/{id}/articles/{articleLocale}", name="victoire_blog_articles") @ParamConverter("blog", class="VictoirePageBundle:BasePage") @throws \InvalidArgumentException @return Response
[ "List", "Blog", "articles", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L261-L275
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.deleteAction
public function deleteAction(BasePage $blog) { if (!$this->get('security.authorization_checker')->isGranted('ROLE_VICTOIRE', $blog)) { throw new AccessDeniedException("Nop ! you can't do such an action"); } foreach ($blog->getArticles() as $_article) { $bep = $this->get('victoire_page.page_helper')->findPageByParameters( [ 'templateId' => $_article->getTemplate()->getId(), 'entityId' => $_article->getId(), ] ); $this->get('victoire_blog.manager.article')->delete($_article, $bep); } return new JsonResponse(parent::deleteAction($blog)); }
php
public function deleteAction(BasePage $blog) { if (!$this->get('security.authorization_checker')->isGranted('ROLE_VICTOIRE', $blog)) { throw new AccessDeniedException("Nop ! you can't do such an action"); } foreach ($blog->getArticles() as $_article) { $bep = $this->get('victoire_page.page_helper')->findPageByParameters( [ 'templateId' => $_article->getTemplate()->getId(), 'entityId' => $_article->getId(), ] ); $this->get('victoire_blog.manager.article')->delete($_article, $bep); } return new JsonResponse(parent::deleteAction($blog)); }
[ "public", "function", "deleteAction", "(", "BasePage", "$", "blog", ")", "{", "if", "(", "!", "$", "this", "->", "get", "(", "'security.authorization_checker'", ")", "->", "isGranted", "(", "'ROLE_VICTOIRE'", ",", "$", "blog", ")", ")", "{", "throw", "new"...
Delete a Blog. @param BasePage $blog @Route("/{id}/delete", name="victoire_blog_delete") @ParamConverter("blog", class="VictoirePageBundle:BasePage") @throws \Victoire\Bundle\ViewReferenceBundle\Exception\ViewReferenceNotFoundException @return JsonResponse
[ "Delete", "a", "Blog", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L318-L335
train
Victoire/victoire
Bundle/BlogBundle/Controller/BlogController.php
BlogController.getBlog
protected function getBlog(Request $request, $blogId) { /** @var BlogRepository $blogRepo */ $blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog'); if ($blogId) { $blog = $blogRepo->find($blogId); } else { $blogs = $blogRepo->joinTranslations($request->getLocale())->run(); $blog = reset($blogs); } return $blog; }
php
protected function getBlog(Request $request, $blogId) { /** @var BlogRepository $blogRepo */ $blogRepo = $this->get('doctrine.orm.entity_manager')->getRepository('VictoireBlogBundle:Blog'); if ($blogId) { $blog = $blogRepo->find($blogId); } else { $blogs = $blogRepo->joinTranslations($request->getLocale())->run(); $blog = reset($blogs); } return $blog; }
[ "protected", "function", "getBlog", "(", "Request", "$", "request", ",", "$", "blogId", ")", "{", "/** @var BlogRepository $blogRepo */", "$", "blogRepo", "=", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", "->", "getRepository", "(", "'Victo...
Get Blog from id if defined. If not return the first Blog. @param Request $request @param $blogId @return Blog|false
[ "Get", "Blog", "from", "id", "if", "defined", ".", "If", "not", "return", "the", "first", "Blog", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Controller/BlogController.php#L386-L399
train
Victoire/victoire
Bundle/BusinessEntityBundle/Entity/Traits/BusinessEntityTrait.php
BusinessEntityTrait.setProxy
public function setProxy(\Victoire\Bundle\CoreBundle\Entity\EntityProxy $proxy = null) { $this->proxy = $proxy; return $this; }
php
public function setProxy(\Victoire\Bundle\CoreBundle\Entity\EntityProxy $proxy = null) { $this->proxy = $proxy; return $this; }
[ "public", "function", "setProxy", "(", "\\", "Victoire", "\\", "Bundle", "\\", "CoreBundle", "\\", "Entity", "\\", "EntityProxy", "$", "proxy", "=", "null", ")", "{", "$", "this", "->", "proxy", "=", "$", "proxy", ";", "return", "$", "this", ";", "}" ]
Set proxy. @param \Victoire\Bundle\CoreBundle\Entity\EntityProxy $proxy @return BusinessEntityTrait
[ "Set", "proxy", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Entity/Traits/BusinessEntityTrait.php#L31-L36
train
Victoire/victoire
Bundle/BusinessEntityBundle/Entity/Traits/BusinessEntityTrait.php
BusinessEntityTrait.getEntityAttributeValue
public function getEntityAttributeValue($field) { if ($field) { $functionName = 'get'.ucfirst($field); // Avoid error when the widget refer to a property that has been removed if (!method_exists($this, $functionName)) { return; } $fieldValue = $this->{$functionName}(); } else { $fieldValue = null; } return $fieldValue; }
php
public function getEntityAttributeValue($field) { if ($field) { $functionName = 'get'.ucfirst($field); // Avoid error when the widget refer to a property that has been removed if (!method_exists($this, $functionName)) { return; } $fieldValue = $this->{$functionName}(); } else { $fieldValue = null; } return $fieldValue; }
[ "public", "function", "getEntityAttributeValue", "(", "$", "field", ")", "{", "if", "(", "$", "field", ")", "{", "$", "functionName", "=", "'get'", ".", "ucfirst", "(", "$", "field", ")", ";", "// Avoid error when the widget refer to a property that has been removed...
Get the content of an attribute of the current entity. @param string $field @return mixed
[ "Get", "the", "content", "of", "an", "attribute", "of", "the", "current", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Entity/Traits/BusinessEntityTrait.php#L79-L95
train
Victoire/victoire
Bundle/BlogBundle/Entity/Blog.php
Blog.getAvailableLocales
public function getAvailableLocales() { $availableLocales = []; $translations = $this->getTranslations(); foreach ($translations as $translation) { $availableLocales[] = $translation->getLocale(); } return $availableLocales; }
php
public function getAvailableLocales() { $availableLocales = []; $translations = $this->getTranslations(); foreach ($translations as $translation) { $availableLocales[] = $translation->getLocale(); } return $availableLocales; }
[ "public", "function", "getAvailableLocales", "(", ")", "{", "$", "availableLocales", "=", "[", "]", ";", "$", "translations", "=", "$", "this", "->", "getTranslations", "(", ")", ";", "foreach", "(", "$", "translations", "as", "$", "translation", ")", "{",...
Get available locales for Articles from this Blog. @return array
[ "Get", "available", "locales", "for", "Articles", "from", "this", "Blog", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/Blog.php#L53-L62
train
Victoire/victoire
Bundle/BlogBundle/Entity/Blog.php
Blog.setCategories
public function setCategories($categories) { foreach ($categories as $category) { $category->setBlog($this); } $this->categories = $categories; return $this; }
php
public function setCategories($categories) { foreach ($categories as $category) { $category->setBlog($this); } $this->categories = $categories; return $this; }
[ "public", "function", "setCategories", "(", "$", "categories", ")", "{", "foreach", "(", "$", "categories", "as", "$", "category", ")", "{", "$", "category", "->", "setBlog", "(", "$", "this", ")", ";", "}", "$", "this", "->", "categories", "=", "$", ...
Set categories. @param string $categories @return Blog
[ "Set", "categories", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/Blog.php#L115-L123
train
Victoire/victoire
Bundle/BlogBundle/Entity/Blog.php
Blog.getRootCategories
public function getRootCategories() { $rootCategories = []; foreach ($this->categories as $categories) { if ($categories->getLvl() == 0) { $rootCategories[] = $categories; } } return $rootCategories; }
php
public function getRootCategories() { $rootCategories = []; foreach ($this->categories as $categories) { if ($categories->getLvl() == 0) { $rootCategories[] = $categories; } } return $rootCategories; }
[ "public", "function", "getRootCategories", "(", ")", "{", "$", "rootCategories", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "categories", "as", "$", "categories", ")", "{", "if", "(", "$", "categories", "->", "getLvl", "(", ")", "==", "0", ...
Get root categories. @return string
[ "Get", "root", "categories", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Entity/Blog.php#L167-L177
train
Victoire/victoire
Bundle/CoreBundle/Repository/RouteRepository.php
RouteRepository.findOneMostRecentByUrl
public function findOneMostRecentByUrl($url) { $entity = null; $qb = $this->createQueryBuilder('route'); $qb->where('route.url = :url'); $qb->setParameter(':url', $url); $qb->orderBy('route.id', 'DESC'); $qb->setMaxResults(1); $results = $qb->getQuery()->getResult(); if (count($results) > 0) { $entity = $results[0]; } return $entity; }
php
public function findOneMostRecentByUrl($url) { $entity = null; $qb = $this->createQueryBuilder('route'); $qb->where('route.url = :url'); $qb->setParameter(':url', $url); $qb->orderBy('route.id', 'DESC'); $qb->setMaxResults(1); $results = $qb->getQuery()->getResult(); if (count($results) > 0) { $entity = $results[0]; } return $entity; }
[ "public", "function", "findOneMostRecentByUrl", "(", "$", "url", ")", "{", "$", "entity", "=", "null", ";", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'route'", ")", ";", "$", "qb", "->", "where", "(", "'route.url = :url'", ")", ";", ...
Get the most recent route by url. @param string $url The url to search @return Route
[ "Get", "the", "most", "recent", "route", "by", "url", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Repository/RouteRepository.php#L19-L36
train
Victoire/victoire
Bundle/WidgetBundle/Entity/Widget.php
Widget.getViewId
public function getViewId() { $viewId = null; $widgetMap = $this->getWidgetMap(); if ($widgetMap !== null && $view = $widgetMap->getView() !== null) { $viewId = $view->getId(); } return $viewId; }
php
public function getViewId() { $viewId = null; $widgetMap = $this->getWidgetMap(); if ($widgetMap !== null && $view = $widgetMap->getView() !== null) { $viewId = $view->getId(); } return $viewId; }
[ "public", "function", "getViewId", "(", ")", "{", "$", "viewId", "=", "null", ";", "$", "widgetMap", "=", "$", "this", "->", "getWidgetMap", "(", ")", ";", "if", "(", "$", "widgetMap", "!==", "null", "&&", "$", "view", "=", "$", "widgetMap", "->", ...
Get the view id. @return int The view id
[ "Get", "the", "view", "id", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Entity/Widget.php#L317-L328
train
Victoire/victoire
Bundle/WidgetBundle/Entity/Widget.php
Widget.getEntity
public function getEntity() { //if there is no entity if ($this->entity === null) { //we try to get one from the proxy $entityProxy = $this->getEntityProxy(); //if there is a proxy if ($entityProxy !== null && $this->getBusinessEntityId()) { $entity = $entityProxy->getEntity($this->getBusinessEntityId()); $this->entity = $entity; } } return $this->entity; }
php
public function getEntity() { //if there is no entity if ($this->entity === null) { //we try to get one from the proxy $entityProxy = $this->getEntityProxy(); //if there is a proxy if ($entityProxy !== null && $this->getBusinessEntityId()) { $entity = $entityProxy->getEntity($this->getBusinessEntityId()); $this->entity = $entity; } } return $this->entity; }
[ "public", "function", "getEntity", "(", ")", "{", "//if there is no entity", "if", "(", "$", "this", "->", "entity", "===", "null", ")", "{", "//we try to get one from the proxy", "$", "entityProxy", "=", "$", "this", "->", "getEntityProxy", "(", ")", ";", "//...
Get the entity. @return number
[ "Get", "the", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Entity/Widget.php#L388-L403
train
Victoire/victoire
Bundle/WidgetBundle/Entity/Widget.php
Widget.generateCacheId
public function generateCacheId() { if (!$this->getCurrentView()) { throw new \Exception(sprintf( 'Cannot generate an hash for widget %s if currentView is not defined.', $this->getId() )); } return sprintf( '%s-%s-%s', $this->getId(), $this->getUpdatedAt()->getTimestamp(), $this->getCurrentView()->getReference()->getId() ); }
php
public function generateCacheId() { if (!$this->getCurrentView()) { throw new \Exception(sprintf( 'Cannot generate an hash for widget %s if currentView is not defined.', $this->getId() )); } return sprintf( '%s-%s-%s', $this->getId(), $this->getUpdatedAt()->getTimestamp(), $this->getCurrentView()->getReference()->getId() ); }
[ "public", "function", "generateCacheId", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getCurrentView", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Cannot generate an hash for widget %s if currentView is not defined.'", ",", ...
Generate the CacheId, insert params that can invalid the cache. @return string
[ "Generate", "the", "CacheId", "insert", "params", "that", "can", "invalid", "the", "cache", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetBundle/Entity/Widget.php#L502-L517
train
Victoire/victoire
Bundle/BusinessEntityBundle/Transliterator/Transliterator.php
Transliterator.postProcessText
private static function postProcessText($text, $separator, $excludeTwig) { if (function_exists('mb_strtolower')) { $text = mb_strtolower($text); } else { $text = strtolower($text); } if (!$excludeTwig) { $text = preg_replace('/\W/', ' ', $text); } $text = preg_replace('/::/', '/', $text); $text = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $text); $text = preg_replace('/([a-z\d])([A-Z])/', '\1_\2', $text); if ($excludeTwig) { // this regex match all word, characters, number, twig variables. $text = preg_replace('/(?:\\{\\{\\s*%\\s*[^}]+\\}\\})|(\\{\\{\\s*(?!%)\\s*(?>(?!\\.)[^\\s{}%]*)(?<!%)\\s*\\}\\}|\\w+)|(?:.)/mx', '$1 ', $text); $text = preg_replace('!\s+!', $separator, $text); } else { $text = preg_replace('/[^A-Za-z0-9\/]+/', $separator, $text); } $text = strtolower($text); $text = trim($text, '-'); return $text; }
php
private static function postProcessText($text, $separator, $excludeTwig) { if (function_exists('mb_strtolower')) { $text = mb_strtolower($text); } else { $text = strtolower($text); } if (!$excludeTwig) { $text = preg_replace('/\W/', ' ', $text); } $text = preg_replace('/::/', '/', $text); $text = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $text); $text = preg_replace('/([a-z\d])([A-Z])/', '\1_\2', $text); if ($excludeTwig) { // this regex match all word, characters, number, twig variables. $text = preg_replace('/(?:\\{\\{\\s*%\\s*[^}]+\\}\\})|(\\{\\{\\s*(?!%)\\s*(?>(?!\\.)[^\\s{}%]*)(?<!%)\\s*\\}\\}|\\w+)|(?:.)/mx', '$1 ', $text); $text = preg_replace('!\s+!', $separator, $text); } else { $text = preg_replace('/[^A-Za-z0-9\/]+/', $separator, $text); } $text = strtolower($text); $text = trim($text, '-'); return $text; }
[ "private", "static", "function", "postProcessText", "(", "$", "text", ",", "$", "separator", ",", "$", "excludeTwig", ")", "{", "if", "(", "function_exists", "(", "'mb_strtolower'", ")", ")", "{", "$", "text", "=", "mb_strtolower", "(", "$", "text", ")", ...
Cleans up the text and adds separator and keep twig variable. @param string $text @param string $separator @param bool $excludeTwig @return string
[ "Cleans", "up", "the", "text", "and", "adds", "separator", "and", "keep", "twig", "variable", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Transliterator/Transliterator.php#L36-L61
train
Victoire/victoire
Bundle/MediaBundle/Helper/Menu/MenuItem.php
MenuItem.getChildren
public function getChildren() { if (is_null($this->children)) { $this->children = $this->menu->getChildren($this); } return $this->children; }
php
public function getChildren() { if (is_null($this->children)) { $this->children = $this->menu->getChildren($this); } return $this->children; }
[ "public", "function", "getChildren", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "children", ")", ")", "{", "$", "this", "->", "children", "=", "$", "this", "->", "menu", "->", "getChildren", "(", "$", "this", ")", ";", "}", "retur...
Get children of current menu item. @return MenuItem[]
[ "Get", "children", "of", "current", "menu", "item", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuItem.php#L217-L224
train
Victoire/victoire
Bundle/MediaBundle/Helper/Menu/MenuItem.php
MenuItem.getNavigationChildren
public function getNavigationChildren() { $result = []; $children = $this->getChildren(); foreach ($children as $child) { if ($child->getAppearInNavigation()) { $result[] = $child; } } return $result; }
php
public function getNavigationChildren() { $result = []; $children = $this->getChildren(); foreach ($children as $child) { if ($child->getAppearInNavigation()) { $result[] = $child; } } return $result; }
[ "public", "function", "getNavigationChildren", "(", ")", "{", "$", "result", "=", "[", "]", ";", "$", "children", "=", "$", "this", "->", "getChildren", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "if", "(", "$", "...
Get children of current menu item that have the appearInNavigation flag set. @return MenuItem[]
[ "Get", "children", "of", "current", "menu", "item", "that", "have", "the", "appearInNavigation", "flag", "set", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuItem.php#L245-L256
train
Victoire/victoire
Bundle/MediaBundle/Helper/Menu/MenuItem.php
MenuItem.getTopChildren
public function getTopChildren() { $result = []; $children = $this->getChildren(); foreach ($children as $child) { if ($child instanceof TopMenuItem) { $result[] = $child; } } return $result; }
php
public function getTopChildren() { $result = []; $children = $this->getChildren(); foreach ($children as $child) { if ($child instanceof TopMenuItem) { $result[] = $child; } } return $result; }
[ "public", "function", "getTopChildren", "(", ")", "{", "$", "result", "=", "[", "]", ";", "$", "children", "=", "$", "this", "->", "getChildren", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child",...
Return top children of current menu item. @return TopMenuItem[]
[ "Return", "top", "children", "of", "current", "menu", "item", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/MediaBundle/Helper/Menu/MenuItem.php#L263-L274
train
Victoire/victoire
Bundle/ConfigBundle/Controller/GlobalController.php
GlobalController.editAction
public function editAction(Request $request) { $entityManager = $this->getDoctrine()->getManager(); /** @var GlobalConfigRepository $globalConfigRepository */ $globalConfigRepository = $entityManager->getRepository(GlobalConfig::class); $globalConfig = $globalConfigRepository->findLast() ?: new GlobalConfig(); $form = $this->createForm(GlobalConfigType::class, $globalConfig, []); $initialLogo = $globalConfig->getLogo(); $form->handleRequest($request); $success = true; if ($form->isSubmitted()) { if (true === $success = $form->isValid()) { //cloning the entity will give it a new id in order to invalidate browser cache (in meta.html.twig) $entityManager->clear(GlobalConfig::class); $entityManager->persist($globalConfig); $entityManager->flush(); if ($initialLogo !== $globalConfig->getLogo() && $globalConfig->getLogo() !== null) { $this->container->get(FaviconGenerator::class)->generate( $globalConfig, $this->getParameter('kernel.project_dir').'/faviconConfig.json' ); } $this->congrat('victoire.config.global.edit.success'); return new JsonResponse([ 'url' => $this->generateUrl('victoire_core_homepage_show'), 'success' => true, ]); } } return new JsonResponse([ 'html' => $this->renderView('VictoireConfigBundle:global:edit.html.twig', [ 'form' => $form->createView(), ]), 'success' => $success, ]); }
php
public function editAction(Request $request) { $entityManager = $this->getDoctrine()->getManager(); /** @var GlobalConfigRepository $globalConfigRepository */ $globalConfigRepository = $entityManager->getRepository(GlobalConfig::class); $globalConfig = $globalConfigRepository->findLast() ?: new GlobalConfig(); $form = $this->createForm(GlobalConfigType::class, $globalConfig, []); $initialLogo = $globalConfig->getLogo(); $form->handleRequest($request); $success = true; if ($form->isSubmitted()) { if (true === $success = $form->isValid()) { //cloning the entity will give it a new id in order to invalidate browser cache (in meta.html.twig) $entityManager->clear(GlobalConfig::class); $entityManager->persist($globalConfig); $entityManager->flush(); if ($initialLogo !== $globalConfig->getLogo() && $globalConfig->getLogo() !== null) { $this->container->get(FaviconGenerator::class)->generate( $globalConfig, $this->getParameter('kernel.project_dir').'/faviconConfig.json' ); } $this->congrat('victoire.config.global.edit.success'); return new JsonResponse([ 'url' => $this->generateUrl('victoire_core_homepage_show'), 'success' => true, ]); } } return new JsonResponse([ 'html' => $this->renderView('VictoireConfigBundle:global:edit.html.twig', [ 'form' => $form->createView(), ]), 'success' => $success, ]); }
[ "public", "function", "editAction", "(", "Request", "$", "request", ")", "{", "$", "entityManager", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var GlobalConfigRepository $globalConfigRepository */", "$", "globalConfigRe...
Method used to edit global config. @param Request $request @return \Symfony\Component\HttpFoundation\Response @Route("/", name="victoire_config_global_edit")
[ "Method", "used", "to", "edit", "global", "config", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ConfigBundle/Controller/GlobalController.php#L33-L71
train
Victoire/victoire
Bundle/CoreBundle/Listener/MenuDispatcher.php
MenuDispatcher.onKernelRequest
public function onKernelRequest(GetResponseEvent $event) { if ($this->tokenStorage->getToken() && $this->authorizationChecker->isGranted('ROLE_VICTOIRE')) { $this->eventDispatcher->dispatch('victoire_core.build_menu', $event); } }
php
public function onKernelRequest(GetResponseEvent $event) { if ($this->tokenStorage->getToken() && $this->authorizationChecker->isGranted('ROLE_VICTOIRE')) { $this->eventDispatcher->dispatch('victoire_core.build_menu', $event); } }
[ "public", "function", "onKernelRequest", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "&&", "$", "this", "->", "authorizationChecker", "->", "isGranted", "(", "'ROLE_VICTOIRE'", ")",...
Dispatch event to build the Victoire's global menu items. @param GetResponseEvent $event
[ "Dispatch", "event", "to", "build", "the", "Victoire", "s", "global", "menu", "items", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Listener/MenuDispatcher.php#L38-L43
train
Victoire/victoire
Bundle/CoreBundle/EventSubscriber/WidgetSubscriber.php
WidgetSubscriber.onFlush
public function onFlush(OnFlushEventArgs $args) { $this->em = $args->getEntityManager(); $this->uow = $this->em->getUnitOfWork(); $this->widgetRepo = $this->em->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget'); $this->viewRepo = $this->em->getRepository('Victoire\Bundle\CoreBundle\Entity\View'); $updatedEntities = $this->uow->getScheduledEntityUpdates(); $deletedEntities = $this->uow->getScheduledEntityDeletions(); //Update View's CSS and inheritors of updated and deleted widgets foreach (array_merge($updatedEntities, $deletedEntities) as $entity) { if (!($entity instanceof Widget)) { continue; } /* @var Widget $entity */ $widgetMap = $entity->getWidgetMap(); if ($widgetMap->getAction() !== WidgetMap::ACTION_DELETE) { $view = $widgetMap->getView(); if ($this->em->contains($view)) { $this->updateViewCss($view); $this->setTemplateInheritorsCssToUpdate($view); } } } //Remove CSS of deleted View and update its inheritors foreach ($deletedEntities as $entity) { if (!($entity instanceof View)) { continue; } $this->viewCssBuilder->removeCssFile($entity->getCssHash()); $this->setTemplateInheritorsCssToUpdate($entity); } //Update CSS of updated View and its inheritors foreach ($updatedEntities as $entity) { if (!($entity instanceof View)) { continue; } $this->updateViewCss($entity); $this->setTemplateInheritorsCssToUpdate($entity); } $this->uow->computeChangeSets(); }
php
public function onFlush(OnFlushEventArgs $args) { $this->em = $args->getEntityManager(); $this->uow = $this->em->getUnitOfWork(); $this->widgetRepo = $this->em->getRepository('Victoire\Bundle\WidgetBundle\Entity\Widget'); $this->viewRepo = $this->em->getRepository('Victoire\Bundle\CoreBundle\Entity\View'); $updatedEntities = $this->uow->getScheduledEntityUpdates(); $deletedEntities = $this->uow->getScheduledEntityDeletions(); //Update View's CSS and inheritors of updated and deleted widgets foreach (array_merge($updatedEntities, $deletedEntities) as $entity) { if (!($entity instanceof Widget)) { continue; } /* @var Widget $entity */ $widgetMap = $entity->getWidgetMap(); if ($widgetMap->getAction() !== WidgetMap::ACTION_DELETE) { $view = $widgetMap->getView(); if ($this->em->contains($view)) { $this->updateViewCss($view); $this->setTemplateInheritorsCssToUpdate($view); } } } //Remove CSS of deleted View and update its inheritors foreach ($deletedEntities as $entity) { if (!($entity instanceof View)) { continue; } $this->viewCssBuilder->removeCssFile($entity->getCssHash()); $this->setTemplateInheritorsCssToUpdate($entity); } //Update CSS of updated View and its inheritors foreach ($updatedEntities as $entity) { if (!($entity instanceof View)) { continue; } $this->updateViewCss($entity); $this->setTemplateInheritorsCssToUpdate($entity); } $this->uow->computeChangeSets(); }
[ "public", "function", "onFlush", "(", "OnFlushEventArgs", "$", "args", ")", "{", "$", "this", "->", "em", "=", "$", "args", "->", "getEntityManager", "(", ")", ";", "$", "this", "->", "uow", "=", "$", "this", "->", "em", "->", "getUnitOfWork", "(", "...
Change cssHash of views when a widget is updated or deleted. @param OnFlushEventArgs $args
[ "Change", "cssHash", "of", "views", "when", "a", "widget", "is", "updated", "or", "deleted", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/EventSubscriber/WidgetSubscriber.php#L59-L107
train
Victoire/victoire
Bundle/CoreBundle/EventSubscriber/WidgetSubscriber.php
WidgetSubscriber.updateViewCss
public function updateViewCss(View $view) { $view->changeCssHash(); //Update css file $this->widgetMapBuilder->build($view, true); $widgets = $this->widgetRepo->findAllWidgetsForView($view); //Generate CSS file and set View's CSS as up to date $oldHash = $view->getCssHash(); $view->changeCssHash(); $this->viewCssBuilder->updateViewCss($oldHash, $view, $widgets); $view->setCssUpToDate(true); //Persist new hash and upToDate bool $metadata = $this->em->getClassMetadata(get_class($view)); $this->uow->recomputeSingleEntityChangeSet($metadata, $view); }
php
public function updateViewCss(View $view) { $view->changeCssHash(); //Update css file $this->widgetMapBuilder->build($view, true); $widgets = $this->widgetRepo->findAllWidgetsForView($view); //Generate CSS file and set View's CSS as up to date $oldHash = $view->getCssHash(); $view->changeCssHash(); $this->viewCssBuilder->updateViewCss($oldHash, $view, $widgets); $view->setCssUpToDate(true); //Persist new hash and upToDate bool $metadata = $this->em->getClassMetadata(get_class($view)); $this->uow->recomputeSingleEntityChangeSet($metadata, $view); }
[ "public", "function", "updateViewCss", "(", "View", "$", "view", ")", "{", "$", "view", "->", "changeCssHash", "(", ")", ";", "//Update css file", "$", "this", "->", "widgetMapBuilder", "->", "build", "(", "$", "view", ",", "true", ")", ";", "$", "widget...
Change view cssHash, update css file and persist new cssHash. @param View $view
[ "Change", "view", "cssHash", "update", "css", "file", "and", "persist", "new", "cssHash", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/EventSubscriber/WidgetSubscriber.php#L114-L131
train
Victoire/victoire
Bundle/BlogBundle/Listener/BlogMenuListener.php
BlogMenuListener.addBlogContextual
public function addBlogContextual($event) { $floatActionDropdown = $this->menuBuilder->getFloatActionDropdown(); $floatActionDropdown->addChild( 'menu.blog.article.new', [ 'route' => 'victoire_blog_article_new', 'routeParameters' => ['id' => $event->getPage()->getId()], ] )->setLinkAttribute('data-toggle', 'vic-modal'); }
php
public function addBlogContextual($event) { $floatActionDropdown = $this->menuBuilder->getFloatActionDropdown(); $floatActionDropdown->addChild( 'menu.blog.article.new', [ 'route' => 'victoire_blog_article_new', 'routeParameters' => ['id' => $event->getPage()->getId()], ] )->setLinkAttribute('data-toggle', 'vic-modal'); }
[ "public", "function", "addBlogContextual", "(", "$", "event", ")", "{", "$", "floatActionDropdown", "=", "$", "this", "->", "menuBuilder", "->", "getFloatActionDropdown", "(", ")", ";", "$", "floatActionDropdown", "->", "addChild", "(", "'menu.blog.article.new'", ...
add a blog contextual menu item. @param PageMenuContextualEvent $event @return \Knp\Menu\ItemInterface
[ "add", "a", "blog", "contextual", "menu", "item", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Listener/BlogMenuListener.php#L60-L71
train
Victoire/victoire
Bundle/BusinessPageBundle/Repository/BusinessTemplateRepository.php
BusinessTemplateRepository.findOneByLikeUrl
public function findOneByLikeUrl($url) { $pagePattern = null; $qb = $this->createQueryBuilder('BusinessTemplate'); $qb->where($qb->expr()->like('BusinessTemplate.url', $qb->expr()->literal($url))); $qb->orderBy('BusinessTemplate.updatedAt', 'ASC'); $results = $qb->getQuery()->getResult(); if (count($results) > 0) { $pagePattern = $results[0]; } return $pagePattern; }
php
public function findOneByLikeUrl($url) { $pagePattern = null; $qb = $this->createQueryBuilder('BusinessTemplate'); $qb->where($qb->expr()->like('BusinessTemplate.url', $qb->expr()->literal($url))); $qb->orderBy('BusinessTemplate.updatedAt', 'ASC'); $results = $qb->getQuery()->getResult(); if (count($results) > 0) { $pagePattern = $results[0]; } return $pagePattern; }
[ "public", "function", "findOneByLikeUrl", "(", "$", "url", ")", "{", "$", "pagePattern", "=", "null", ";", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'BusinessTemplate'", ")", ";", "$", "qb", "->", "where", "(", "$", "qb", "->", "ex...
Find the business entity page pattern that looks like this url. @param string $url @return array The list of pagePatterns
[ "Find", "the", "business", "entity", "page", "pattern", "that", "looks", "like", "this", "url", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Repository/BusinessTemplateRepository.php#L59-L75
train
Victoire/victoire
Bundle/I18nBundle/Subscriber/LocaleSubscriber.php
LocaleSubscriber.onLogin
public function onLogin(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($user instanceof VictoireUserInterface) { // set the victoireLocale $event->getRequest()->getSession()->set('victoire_locale', $user->getLocale()); } }
php
public function onLogin(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($user instanceof VictoireUserInterface) { // set the victoireLocale $event->getRequest()->getSession()->set('victoire_locale', $user->getLocale()); } }
[ "public", "function", "onLogin", "(", "InteractiveLoginEvent", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getAuthenticationToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "VictoireUserInterface", ")...
This method will be called on user login in order to set the victoire locale. @param InteractiveLoginEvent $event
[ "This", "method", "will", "be", "called", "on", "user", "login", "in", "order", "to", "set", "the", "victoire", "locale", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/I18nBundle/Subscriber/LocaleSubscriber.php#L56-L64
train
Victoire/victoire
Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php
ViewReferenceManager.saveReferences
public function saveReferences(array $viewReferences, $parentId = null, $parentLocale = null, $reset = true) { // Reset redis if wanted if ($reset) { $this->manager->reset(); } // Parse the viewReferences foreach ($viewReferences as $viewReference) { /** @var View $view */ $view = $viewReference['view']; foreach ($view->getReferences() as $locale => $reference) { if ($reference !== null) { // save the viewReference $id = $this->saveReference($reference, $parentId, $parentLocale); // if children, save them if (array_key_exists('children', $viewReference) && !empty($children = $viewReference['children'])) { $this->saveReferences($children, $id, $reference->getLocale(), false); } } } } }
php
public function saveReferences(array $viewReferences, $parentId = null, $parentLocale = null, $reset = true) { // Reset redis if wanted if ($reset) { $this->manager->reset(); } // Parse the viewReferences foreach ($viewReferences as $viewReference) { /** @var View $view */ $view = $viewReference['view']; foreach ($view->getReferences() as $locale => $reference) { if ($reference !== null) { // save the viewReference $id = $this->saveReference($reference, $parentId, $parentLocale); // if children, save them if (array_key_exists('children', $viewReference) && !empty($children = $viewReference['children'])) { $this->saveReferences($children, $id, $reference->getLocale(), false); } } } } }
[ "public", "function", "saveReferences", "(", "array", "$", "viewReferences", ",", "$", "parentId", "=", "null", ",", "$", "parentLocale", "=", "null", ",", "$", "reset", "=", "true", ")", "{", "// Reset redis if wanted", "if", "(", "$", "reset", ")", "{", ...
This method save a tree of viewReferences. @param array $viewReferences @param string $parentId @param string $parentLocale @param bool $reset
[ "This", "method", "save", "a", "tree", "of", "viewReferences", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php#L42-L64
train
Victoire/victoire
Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php
ViewReferenceManager.saveReference
public function saveReference(ViewReference $viewReference, $parentId = null, $parentLocale = null) { // Transform the viewReference in array $arrayTransformer = $this->transformer->getViewReferenceTransformer( $viewReference->getViewNamespace(), 'array' ); $referenceArray = $arrayTransformer->reverseTransform($viewReference); // Remove old url if exist $this->removeUrlForViewReference($viewReference); // Update/create the viewReference $this->manager->update($referenceArray['id'], $referenceArray); // Build the url for reference $this->manager->buildUrl($viewReference->getId()); // Set parent if exist if ($parentId && $parentLocale === $viewReference->getLocale()) { $this->manager->addChild($parentId, $referenceArray['id']); } return $referenceArray['id']; }
php
public function saveReference(ViewReference $viewReference, $parentId = null, $parentLocale = null) { // Transform the viewReference in array $arrayTransformer = $this->transformer->getViewReferenceTransformer( $viewReference->getViewNamespace(), 'array' ); $referenceArray = $arrayTransformer->reverseTransform($viewReference); // Remove old url if exist $this->removeUrlForViewReference($viewReference); // Update/create the viewReference $this->manager->update($referenceArray['id'], $referenceArray); // Build the url for reference $this->manager->buildUrl($viewReference->getId()); // Set parent if exist if ($parentId && $parentLocale === $viewReference->getLocale()) { $this->manager->addChild($parentId, $referenceArray['id']); } return $referenceArray['id']; }
[ "public", "function", "saveReference", "(", "ViewReference", "$", "viewReference", ",", "$", "parentId", "=", "null", ",", "$", "parentLocale", "=", "null", ")", "{", "// Transform the viewReference in array", "$", "arrayTransformer", "=", "$", "this", "->", "tran...
This method save a Reference. @param ViewReference $viewReference @param string $parentId @param string $parentLocale @return mixed
[ "This", "method", "save", "a", "Reference", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php#L75-L94
train
Victoire/victoire
Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php
ViewReferenceManager.removeReference
public function removeReference(ViewReference $viewReference) { $referenceId = $viewReference->getId(); if ($url = $this->repository->findValueForId('url', $referenceId)) { // Remove url $this->manager->removeUrl($url, $viewReference->getLocale()); } // Remove reference $this->manager->remove($referenceId); }
php
public function removeReference(ViewReference $viewReference) { $referenceId = $viewReference->getId(); if ($url = $this->repository->findValueForId('url', $referenceId)) { // Remove url $this->manager->removeUrl($url, $viewReference->getLocale()); } // Remove reference $this->manager->remove($referenceId); }
[ "public", "function", "removeReference", "(", "ViewReference", "$", "viewReference", ")", "{", "$", "referenceId", "=", "$", "viewReference", "->", "getId", "(", ")", ";", "if", "(", "$", "url", "=", "$", "this", "->", "repository", "->", "findValueForId", ...
This method remove reference for a ViewReference. @param ViewReference $viewReference
[ "This", "method", "remove", "reference", "for", "a", "ViewReference", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php#L101-L110
train
Victoire/victoire
Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php
ViewReferenceManager.removeUrlForViewReference
public function removeUrlForViewReference(ViewReference $viewReference) { $id = $viewReference->getId(); if ($url = $this->repository->findValueForId('url', $id)) { $this->manager->removeUrl($url, $this->repository->findValueForId('locale', $id)); } }
php
public function removeUrlForViewReference(ViewReference $viewReference) { $id = $viewReference->getId(); if ($url = $this->repository->findValueForId('url', $id)) { $this->manager->removeUrl($url, $this->repository->findValueForId('locale', $id)); } }
[ "public", "function", "removeUrlForViewReference", "(", "ViewReference", "$", "viewReference", ")", "{", "$", "id", "=", "$", "viewReference", "->", "getId", "(", ")", ";", "if", "(", "$", "url", "=", "$", "this", "->", "repository", "->", "findValueForId", ...
Remove an url for a viewReference with his reference in redis. @param ViewReference $viewReference
[ "Remove", "an", "url", "for", "a", "viewReference", "with", "his", "reference", "in", "redis", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/ViewReferenceBundle/Connector/ViewReferenceManager.php#L135-L141
train
Victoire/victoire
Bundle/SitemapBundle/Domain/Sort/SitemapSortHandler.php
SitemapSortHandler.handle
public function handle(array $sorted) { $pageRepo = $this->entityManager->getRepository('VictoirePageBundle:BasePage'); $depths = []; foreach ($sorted as $item) { $depths[$item['depth']][$item['item_id']] = 1; $page = $pageRepo->findOneById($item['item_id']); if ($page !== null) { if ($item['parent_id'] !== '') { $parent = $pageRepo->findOneById($item['parent_id']); $page->setParent($parent); } else { $page->setParent(null); } $page->setPosition(count($depths[$item['depth']])); $this->entityManager->persist($page); } } $this->entityManager->flush(); }
php
public function handle(array $sorted) { $pageRepo = $this->entityManager->getRepository('VictoirePageBundle:BasePage'); $depths = []; foreach ($sorted as $item) { $depths[$item['depth']][$item['item_id']] = 1; $page = $pageRepo->findOneById($item['item_id']); if ($page !== null) { if ($item['parent_id'] !== '') { $parent = $pageRepo->findOneById($item['parent_id']); $page->setParent($parent); } else { $page->setParent(null); } $page->setPosition(count($depths[$item['depth']])); $this->entityManager->persist($page); } } $this->entityManager->flush(); }
[ "public", "function", "handle", "(", "array", "$", "sorted", ")", "{", "$", "pageRepo", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "'VictoirePageBundle:BasePage'", ")", ";", "$", "depths", "=", "[", "]", ";", "foreach", "(", "$", ...
Reorder pages positions. @param array $sorted The sorted array from Nested Sortable
[ "Reorder", "pages", "positions", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Domain/Sort/SitemapSortHandler.php#L31-L51
train
Victoire/victoire
Bundle/FormBundle/Form/Type/LinkType.php
LinkType.manageRefreshTarget
protected function manageRefreshTarget($form, $options) { $rootFormName = $form->getRoot()->getName(); $linkTypeConfig = $form->get('linkType')->getConfig(); $linkTypeOptions = $linkTypeConfig->getOptions(); $form->add( 'linkType', get_class($linkTypeConfig->getType()->getInnerType()), array_replace( $linkTypeOptions, [ 'attr' => [ 'data-refreshOnChange' => 'true', 'data-target' => $options['refresh-target'] ?: 'form[name="'.$rootFormName.'"]', ], ] ) ); }
php
protected function manageRefreshTarget($form, $options) { $rootFormName = $form->getRoot()->getName(); $linkTypeConfig = $form->get('linkType')->getConfig(); $linkTypeOptions = $linkTypeConfig->getOptions(); $form->add( 'linkType', get_class($linkTypeConfig->getType()->getInnerType()), array_replace( $linkTypeOptions, [ 'attr' => [ 'data-refreshOnChange' => 'true', 'data-target' => $options['refresh-target'] ?: 'form[name="'.$rootFormName.'"]', ], ] ) ); }
[ "protected", "function", "manageRefreshTarget", "(", "$", "form", ",", "$", "options", ")", "{", "$", "rootFormName", "=", "$", "form", "->", "getRoot", "(", ")", "->", "getName", "(", ")", ";", "$", "linkTypeConfig", "=", "$", "form", "->", "get", "("...
By default set data-target to root Form. @param FormInterface $form @param array $options
[ "By", "default", "set", "data", "-", "target", "to", "root", "Form", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/FormBundle/Form/Type/LinkType.php#L106-L125
train
Victoire/victoire
Bundle/FormBundle/Form/Type/LinkType.php
LinkType.manageLinkTypeRelatedFields
protected function manageLinkTypeRelatedFields($linkType, $locale, $form, FormBuilderInterface $builder, $options) { $form->remove('route'); $form->remove('url'); $form->remove('attachedWidget'); $form->remove('viewReference'); $form->remove('locale'); $this->addTargetField($form, $options); switch ($linkType) { case Link::TYPE_VIEW_REFERENCE: $locale = $locale ?: $this->requestStack->getCurrentRequest()->getLocale(); $form->add('viewReference', ChoiceType::class, [ 'label' => 'form.link_type.view_reference.label', 'required' => true, 'attr' => ['novalidate' => 'novalidate'], 'placeholder' => 'form.link_type.view_reference.blank', 'choices' => $this->viewReferenceRepository->getChoices($locale), 'choices_as_values' => true, 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], ])->add('locale', ChoiceType::class, [ 'label' => 'form.link_type.locale.label', 'choices' => array_combine($this->availableLocales, $this->availableLocales), 'attr' => [ 'data-refreshOnChange' => 'true', 'data-target' => $options['refresh-target'], ], ]); break; case Link::TYPE_ROUTE: $form->add('route', null, [ 'label' => 'form.link_type.route.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route.placeholder'], ]) ->add('route_parameters', JsonType::class, [ 'label' => 'form.link_type.route_parameters.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route_parameters.placeholder'], ]); break; case Link::TYPE_URL: $form->add('url', null, [ 'label' => 'form.link_type.url.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.url.placeholder'], ]); break; case Link::TYPE_WIDGET: $form->add('attachedWidget', EntityType::class, [ 'label' => 'form.link_type.attachedWidget.label', 'placeholder' => 'form.link_type.attachedWidget.blank', 'class' => 'VictoireWidgetBundle:Widget', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate'], ]); break; case Link::TYPE_NONE: case null: $form->remove('target'); break; } }
php
protected function manageLinkTypeRelatedFields($linkType, $locale, $form, FormBuilderInterface $builder, $options) { $form->remove('route'); $form->remove('url'); $form->remove('attachedWidget'); $form->remove('viewReference'); $form->remove('locale'); $this->addTargetField($form, $options); switch ($linkType) { case Link::TYPE_VIEW_REFERENCE: $locale = $locale ?: $this->requestStack->getCurrentRequest()->getLocale(); $form->add('viewReference', ChoiceType::class, [ 'label' => 'form.link_type.view_reference.label', 'required' => true, 'attr' => ['novalidate' => 'novalidate'], 'placeholder' => 'form.link_type.view_reference.blank', 'choices' => $this->viewReferenceRepository->getChoices($locale), 'choices_as_values' => true, 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], ])->add('locale', ChoiceType::class, [ 'label' => 'form.link_type.locale.label', 'choices' => array_combine($this->availableLocales, $this->availableLocales), 'attr' => [ 'data-refreshOnChange' => 'true', 'data-target' => $options['refresh-target'], ], ]); break; case Link::TYPE_ROUTE: $form->add('route', null, [ 'label' => 'form.link_type.route.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route.placeholder'], ]) ->add('route_parameters', JsonType::class, [ 'label' => 'form.link_type.route_parameters.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.route_parameters.placeholder'], ]); break; case Link::TYPE_URL: $form->add('url', null, [ 'label' => 'form.link_type.url.label', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate', 'placeholder' => 'form.link_type.url.placeholder'], ]); break; case Link::TYPE_WIDGET: $form->add('attachedWidget', EntityType::class, [ 'label' => 'form.link_type.attachedWidget.label', 'placeholder' => 'form.link_type.attachedWidget.blank', 'class' => 'VictoireWidgetBundle:Widget', 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group'], 'required' => true, 'attr' => ['novalidate' => 'novalidate'], ]); break; case Link::TYPE_NONE: case null: $form->remove('target'); break; } }
[ "protected", "function", "manageLinkTypeRelatedFields", "(", "$", "linkType", ",", "$", "locale", ",", "$", "form", ",", "FormBuilderInterface", "$", "builder", ",", "$", "options", ")", "{", "$", "form", "->", "remove", "(", "'route'", ")", ";", "$", "for...
Add the types related to the LinkType value. @param $linkType @param $locale @param FormBuilderInterface|FormInterface $form @param FormBuilderInterface $builder @param array $options
[ "Add", "the", "types", "related", "to", "the", "LinkType", "value", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/FormBundle/Form/Type/LinkType.php#L136-L201
train
Victoire/victoire
Bundle/FormBundle/Form/Type/LinkType.php
LinkType.manageTargetRelatedFields
protected function manageTargetRelatedFields($target, $form, $options) { if ($target == Link::TARGET_MODAL && count($this->modalLayouts) > 1) { $form->add('modalLayout', ChoiceType::class, [ 'label' => 'form.link_type.target.modalLayouts.label', 'required' => true, 'choices' => $this->modalLayouts, 'choice_label' => function ($value, $key, $index) { return 'form.link_type.target.modalLayouts.choices.'.$value; }, 'choices_as_values' => true, 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group viewReference-type page-type url-type route-type attachedWidget-type'], ]); } else { $form->remove('modalLayout'); } }
php
protected function manageTargetRelatedFields($target, $form, $options) { if ($target == Link::TARGET_MODAL && count($this->modalLayouts) > 1) { $form->add('modalLayout', ChoiceType::class, [ 'label' => 'form.link_type.target.modalLayouts.label', 'required' => true, 'choices' => $this->modalLayouts, 'choice_label' => function ($value, $key, $index) { return 'form.link_type.target.modalLayouts.choices.'.$value; }, 'choices_as_values' => true, 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group viewReference-type page-type url-type route-type attachedWidget-type'], ]); } else { $form->remove('modalLayout'); } }
[ "protected", "function", "manageTargetRelatedFields", "(", "$", "target", ",", "$", "form", ",", "$", "options", ")", "{", "if", "(", "$", "target", "==", "Link", "::", "TARGET_MODAL", "&&", "count", "(", "$", "this", "->", "modalLayouts", ")", ">", "1",...
Add the types related to the target value. @param string $target @param FormBuilderInterface|FormInterface $form @param array $options
[ "Add", "the", "types", "related", "to", "the", "target", "value", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/FormBundle/Form/Type/LinkType.php#L210-L226
train
Victoire/victoire
Bundle/FormBundle/Form/Type/LinkType.php
LinkType.addTargetField
protected function addTargetField($form, array $options) { $rootFormName = $form->getRoot()->getName(); if ($options['withTarget']) { $form->add('target', ChoiceType::class, [ 'label' => 'form.link_type.target.label', 'required' => true, 'choices' => [ 'form.link_type.choice.target.parent' => Link::TARGET_PARENT, 'form.link_type.choice.target.blank' => Link::TARGET_BLANK, 'form.link_type.choice.target.ajax-modal' => Link::TARGET_MODAL, ], 'choices_as_values' => true, 'attr' => [ 'data-refreshOnChange' => 'true', 'data-target' => $options['refresh-target'] ?: 'form[name="'.$rootFormName.'"]', ], 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group viewReference-type page-type url-type route-type attachedWidget-type'], ]); } }
php
protected function addTargetField($form, array $options) { $rootFormName = $form->getRoot()->getName(); if ($options['withTarget']) { $form->add('target', ChoiceType::class, [ 'label' => 'form.link_type.target.label', 'required' => true, 'choices' => [ 'form.link_type.choice.target.parent' => Link::TARGET_PARENT, 'form.link_type.choice.target.blank' => Link::TARGET_BLANK, 'form.link_type.choice.target.ajax-modal' => Link::TARGET_MODAL, ], 'choices_as_values' => true, 'attr' => [ 'data-refreshOnChange' => 'true', 'data-target' => $options['refresh-target'] ?: 'form[name="'.$rootFormName.'"]', ], 'vic_vic_widget_form_group_attr' => ['class' => 'vic-form-group viewReference-type page-type url-type route-type attachedWidget-type'], ]); } }
[ "protected", "function", "addTargetField", "(", "$", "form", ",", "array", "$", "options", ")", "{", "$", "rootFormName", "=", "$", "form", "->", "getRoot", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "$", "options", "[", "'withTarget'", "]", ...
add the target Field. @param FormBuilderInterface|FormInterface $form @param array $options
[ "add", "the", "target", "Field", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/FormBundle/Form/Type/LinkType.php#L271-L292
train
Victoire/victoire
Bundle/CoreBundle/Helper/UrlBuilder.php
UrlBuilder.getParentSlugs
protected function getParentSlugs(WebViewInterface $view, array $slugs) { $parent = $view->getParent(); if ($parent !== null) { if (!(method_exists($parent, 'isHomepage') && $parent->isHomepage())) { array_push($slugs, $parent->getSlug()); } if ($parent->getParent() !== null) { $slugs = $this->getParentSlugs($parent, $slugs); } } return array_unique($slugs); }
php
protected function getParentSlugs(WebViewInterface $view, array $slugs) { $parent = $view->getParent(); if ($parent !== null) { if (!(method_exists($parent, 'isHomepage') && $parent->isHomepage())) { array_push($slugs, $parent->getSlug()); } if ($parent->getParent() !== null) { $slugs = $this->getParentSlugs($parent, $slugs); } } return array_unique($slugs); }
[ "protected", "function", "getParentSlugs", "(", "WebViewInterface", "$", "view", ",", "array", "$", "slugs", ")", "{", "$", "parent", "=", "$", "view", "->", "getParent", "(", ")", ";", "if", "(", "$", "parent", "!==", "null", ")", "{", "if", "(", "!...
Get the array of slugs of the parents. @param WebViewInterface $view @param string[] $slugs @return string[]
[ "Get", "the", "array", "of", "slugs", "of", "the", "parents", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Helper/UrlBuilder.php#L46-L61
train
Victoire/victoire
Bundle/BusinessEntityBundle/Reader/BusinessEntityCacheReader.php
BusinessEntityCacheReader.fetch
protected function fetch($key) { $results = $this->cache->get($key, null); if (!$results) { //Reparse all entities to find some @VIC Annotation foreach ($this->driver->getAllClassNames() as $className) { $this->driver->parse(new \ReflectionClass($className)); } $results = $this->cache->get($key, []); } return $results; }
php
protected function fetch($key) { $results = $this->cache->get($key, null); if (!$results) { //Reparse all entities to find some @VIC Annotation foreach ($this->driver->getAllClassNames() as $className) { $this->driver->parse(new \ReflectionClass($className)); } $results = $this->cache->get($key, []); } return $results; }
[ "protected", "function", "fetch", "(", "$", "key", ")", "{", "$", "results", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "key", ",", "null", ")", ";", "if", "(", "!", "$", "results", ")", "{", "//Reparse all entities to find some @VIC Annotat...
Fetch in Cache system and try to reparse Annotation if no results. @param $key @throws \Doctrine\ORM\Mapping\MappingException @return mixed
[ "Fetch", "in", "Cache", "system", "and", "try", "to", "reparse", "Annotation", "if", "no", "results", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessEntityBundle/Reader/BusinessEntityCacheReader.php#L115-L128
train
Victoire/victoire
Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php
WidgetMapBuilder.build
public function build(View $view, $updatePage = true) { $builtWidgetMap = []; $widgetMaps = $this->contextualViewWarmer->warm($view); $slots = $this->removeOverwritedWidgetMaps($widgetMaps); $this->removeDeletedWidgetMaps($slots); foreach ($slots as $slot => $slotWidgetMaps) { $mainWidgetMap = null; $builtWidgetMap[$slot] = []; $rootWidgetMap = $this->findRootWidgetMap($slotWidgetMaps); if ($rootWidgetMap) { $builtWidgetMap[$slot][] = $rootWidgetMap; $builtWidgetMap = $this->orderizeWidgetMap($rootWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, $view); } } if ($updatePage) { $view->setBuiltWidgetMap($builtWidgetMap); } return $builtWidgetMap; }
php
public function build(View $view, $updatePage = true) { $builtWidgetMap = []; $widgetMaps = $this->contextualViewWarmer->warm($view); $slots = $this->removeOverwritedWidgetMaps($widgetMaps); $this->removeDeletedWidgetMaps($slots); foreach ($slots as $slot => $slotWidgetMaps) { $mainWidgetMap = null; $builtWidgetMap[$slot] = []; $rootWidgetMap = $this->findRootWidgetMap($slotWidgetMaps); if ($rootWidgetMap) { $builtWidgetMap[$slot][] = $rootWidgetMap; $builtWidgetMap = $this->orderizeWidgetMap($rootWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, $view); } } if ($updatePage) { $view->setBuiltWidgetMap($builtWidgetMap); } return $builtWidgetMap; }
[ "public", "function", "build", "(", "View", "$", "view", ",", "$", "updatePage", "=", "true", ")", "{", "$", "builtWidgetMap", "=", "[", "]", ";", "$", "widgetMaps", "=", "$", "this", "->", "contextualViewWarmer", "->", "warm", "(", "$", "view", ")", ...
This method build widgetmaps relativly to given view and it's templates. @param View $view @param bool $updatePage @return array
[ "This", "method", "build", "widgetmaps", "relativly", "to", "given", "view", "and", "it", "s", "templates", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php#L42-L69
train
Victoire/victoire
Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php
WidgetMapBuilder.getAvailablePosition
public function getAvailablePosition(View $view) { $widgetMaps = $view->getBuiltWidgetMap(); $availablePositions = []; foreach ($widgetMaps as $slot => $widgetMap) { foreach ($widgetMap as $_widgetMap) { $availablePositions[$slot][$_widgetMap->getId()]['id'] = $_widgetMap->getId(); $availablePositions[$slot][$_widgetMap->getId()][WidgetMap::POSITION_BEFORE] = true; $availablePositions[$slot][$_widgetMap->getId()][WidgetMap::POSITION_AFTER] = true; if ($_widgetMap->getReplaced()) { $availablePositions[$slot][$_widgetMap->getId()]['replaced'] = $_widgetMap->getReplaced()->getId(); } } /** @var WidgetMap $_widgetMap */ foreach ($widgetMap as $_widgetMap) { if ($_widgetMap->getParent()) { if ($substitute = $_widgetMap->getParent()->getSubstituteForView($view)) { $availablePositions[$slot][$substitute->getId()][$_widgetMap->getPosition()] = false; } else { $availablePositions[$slot][$_widgetMap->getParent()->getId()][$_widgetMap->getPosition()] = false; } } } } return $availablePositions; }
php
public function getAvailablePosition(View $view) { $widgetMaps = $view->getBuiltWidgetMap(); $availablePositions = []; foreach ($widgetMaps as $slot => $widgetMap) { foreach ($widgetMap as $_widgetMap) { $availablePositions[$slot][$_widgetMap->getId()]['id'] = $_widgetMap->getId(); $availablePositions[$slot][$_widgetMap->getId()][WidgetMap::POSITION_BEFORE] = true; $availablePositions[$slot][$_widgetMap->getId()][WidgetMap::POSITION_AFTER] = true; if ($_widgetMap->getReplaced()) { $availablePositions[$slot][$_widgetMap->getId()]['replaced'] = $_widgetMap->getReplaced()->getId(); } } /** @var WidgetMap $_widgetMap */ foreach ($widgetMap as $_widgetMap) { if ($_widgetMap->getParent()) { if ($substitute = $_widgetMap->getParent()->getSubstituteForView($view)) { $availablePositions[$slot][$substitute->getId()][$_widgetMap->getPosition()] = false; } else { $availablePositions[$slot][$_widgetMap->getParent()->getId()][$_widgetMap->getPosition()] = false; } } } } return $availablePositions; }
[ "public", "function", "getAvailablePosition", "(", "View", "$", "view", ")", "{", "$", "widgetMaps", "=", "$", "view", "->", "getBuiltWidgetMap", "(", ")", ";", "$", "availablePositions", "=", "[", "]", ";", "foreach", "(", "$", "widgetMaps", "as", "$", ...
This method takes the builtWidgetMap for view and creates an array that indicate, for each widgetmap, if the position "after" and "before" are available. @param View $view @return array
[ "This", "method", "takes", "the", "builtWidgetMap", "for", "view", "and", "creates", "an", "array", "that", "indicate", "for", "each", "widgetmap", "if", "the", "position", "after", "and", "before", "are", "available", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php#L79-L106
train
Victoire/victoire
Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php
WidgetMapBuilder.orderizeWidgetMap
protected function orderizeWidgetMap(WidgetMap $currentWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, View $view) { $children = $this->resolver->getChildren($currentWidgetMap, $view); foreach ($children as $child) { // check if the founded child belongs to the view if (in_array($child, $slotWidgetMaps, true)) { // Find the position of the "currentWidgetMap" inside the builtWidgetMap, // add "1" to this position if wanted position is "after", 0 is it's before. $offset = array_search($currentWidgetMap, $builtWidgetMap[$slot]) + ($child->getPosition() == WidgetMap::POSITION_AFTER ? 1 : 0); // insert the child in builtWidgetMap at offset position array_splice($builtWidgetMap[$slot], $offset, 0, [$child]); // call myself with child $builtWidgetMap = $this->orderizeWidgetMap($child, $builtWidgetMap, $slot, $slotWidgetMaps, $view); } } return $builtWidgetMap; }
php
protected function orderizeWidgetMap(WidgetMap $currentWidgetMap, $builtWidgetMap, $slot, $slotWidgetMaps, View $view) { $children = $this->resolver->getChildren($currentWidgetMap, $view); foreach ($children as $child) { // check if the founded child belongs to the view if (in_array($child, $slotWidgetMaps, true)) { // Find the position of the "currentWidgetMap" inside the builtWidgetMap, // add "1" to this position if wanted position is "after", 0 is it's before. $offset = array_search($currentWidgetMap, $builtWidgetMap[$slot]) + ($child->getPosition() == WidgetMap::POSITION_AFTER ? 1 : 0); // insert the child in builtWidgetMap at offset position array_splice($builtWidgetMap[$slot], $offset, 0, [$child]); // call myself with child $builtWidgetMap = $this->orderizeWidgetMap($child, $builtWidgetMap, $slot, $slotWidgetMaps, $view); } } return $builtWidgetMap; }
[ "protected", "function", "orderizeWidgetMap", "(", "WidgetMap", "$", "currentWidgetMap", ",", "$", "builtWidgetMap", ",", "$", "slot", ",", "$", "slotWidgetMaps", ",", "View", "$", "view", ")", "{", "$", "children", "=", "$", "this", "->", "resolver", "->", ...
Get the children of given WidgetMap and place them recursively in the "builtWidgetMap" array at the right place depending of the children parents and positions. @param WidgetMap $currentWidgetMap @param $builtWidgetMap @param $slot @param $slotWidgetMaps @param View $view @return mixed
[ "Get", "the", "children", "of", "given", "WidgetMap", "and", "place", "them", "recursively", "in", "the", "builtWidgetMap", "array", "at", "the", "right", "place", "depending", "of", "the", "children", "parents", "and", "positions", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php#L120-L137
train
Victoire/victoire
Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php
WidgetMapBuilder.removeDeletedWidgetMaps
protected function removeDeletedWidgetMaps(&$slots) { foreach ($slots as $slot => $widgetMaps) { foreach ($widgetMaps as $key => $widgetMap) { if ($widgetMap->getAction() == WidgetMap::ACTION_DELETE) { unset($slots[$slot][$key]); } } } }
php
protected function removeDeletedWidgetMaps(&$slots) { foreach ($slots as $slot => $widgetMaps) { foreach ($widgetMaps as $key => $widgetMap) { if ($widgetMap->getAction() == WidgetMap::ACTION_DELETE) { unset($slots[$slot][$key]); } } } }
[ "protected", "function", "removeDeletedWidgetMaps", "(", "&", "$", "slots", ")", "{", "foreach", "(", "$", "slots", "as", "$", "slot", "=>", "$", "widgetMaps", ")", "{", "foreach", "(", "$", "widgetMaps", "as", "$", "key", "=>", "$", "widgetMap", ")", ...
If "delete" widgetmaps are found, remove it because they're not rendered. @param $slots
[ "If", "delete", "widgetmaps", "are", "found", "remove", "it", "because", "they", "re", "not", "rendered", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Builder/WidgetMapBuilder.php#L174-L183
train
Victoire/victoire
Bundle/TemplateBundle/Entity/Template.php
Template.addPage
public function addPage(BasePage $page) { $page->setTemplate($this); $this->pages[] = $page; return $this; }
php
public function addPage(BasePage $page) { $page->setTemplate($this); $this->pages[] = $page; return $this; }
[ "public", "function", "addPage", "(", "BasePage", "$", "page", ")", "{", "$", "page", "->", "setTemplate", "(", "$", "this", ")", ";", "$", "this", "->", "pages", "[", "]", "=", "$", "page", ";", "return", "$", "this", ";", "}" ]
add page. @param BasePage $page @return Template
[ "add", "page", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/TemplateBundle/Entity/Template.php#L63-L69
train
Victoire/victoire
Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php
SitemapExportHandler.handle
public function handle($locale) { $homepage = $this->entityManager->getRepository(Page::class) ->findOneByHomepage($locale); /** @var ViewReference $tree */ $tree = $this->viewReferenceRepo->getOneReferenceByParameters( ['viewId' => $homepage->getId(), 'locale' => $locale], true, true ); $ids = [$tree->getViewId()]; $getChildrenIds = function (ViewReference $tree) use (&$getChildrenIds, $ids) { foreach ($tree->getChildren() as $child) { if (null !== $child->getViewId()) { $ids[] = $child->getViewId(); $ids = array_merge($ids, $getChildrenIds($child)); } } return array_unique($ids); }; $ids = $getChildrenIds($tree); $pages = $this->entityManager->getRepository(BasePage::class) ->getAll(true) ->joinSeo() ->joinSeoTranslations($locale) ->filterByIds($ids) ->run(); /** @var Page $page */ foreach ($pages as $page) { $page->setCurrentLocale($locale); $this->entityManager->refresh($page); $page->translate($locale); } $items = array_merge($pages, $this->getBusinessPages($tree)); usort( $items, function ($a, $b) { return strcmp($a->getUrl(), $b->getUrl()); } ); return $items; }
php
public function handle($locale) { $homepage = $this->entityManager->getRepository(Page::class) ->findOneByHomepage($locale); /** @var ViewReference $tree */ $tree = $this->viewReferenceRepo->getOneReferenceByParameters( ['viewId' => $homepage->getId(), 'locale' => $locale], true, true ); $ids = [$tree->getViewId()]; $getChildrenIds = function (ViewReference $tree) use (&$getChildrenIds, $ids) { foreach ($tree->getChildren() as $child) { if (null !== $child->getViewId()) { $ids[] = $child->getViewId(); $ids = array_merge($ids, $getChildrenIds($child)); } } return array_unique($ids); }; $ids = $getChildrenIds($tree); $pages = $this->entityManager->getRepository(BasePage::class) ->getAll(true) ->joinSeo() ->joinSeoTranslations($locale) ->filterByIds($ids) ->run(); /** @var Page $page */ foreach ($pages as $page) { $page->setCurrentLocale($locale); $this->entityManager->refresh($page); $page->translate($locale); } $items = array_merge($pages, $this->getBusinessPages($tree)); usort( $items, function ($a, $b) { return strcmp($a->getUrl(), $b->getUrl()); } ); return $items; }
[ "public", "function", "handle", "(", "$", "locale", ")", "{", "$", "homepage", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "Page", "::", "class", ")", "->", "findOneByHomepage", "(", "$", "locale", ")", ";", "/** @var ViewReference $...
Get the whole list of published pages for a given locale. #1 Parse recursively and extract every persisted pages ids #2 load these pages with seo (if exists) #3 parse recursively and extract every VirtualBusinessPages references #4 prepare VirtualBusinessPages. @param $locale @return array
[ "Get", "the", "whole", "list", "of", "published", "pages", "for", "a", "given", "locale", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php#L56-L103
train
Victoire/victoire
Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php
SitemapExportHandler.getBusinessPages
private function getBusinessPages(ViewReference $tree, $businessPages = []) { foreach ($tree->getChildren() as $child) { if ($child instanceof BusinessPageReference && $child->getViewNamespace() === VirtualBusinessPage::class ) { /** @var WebViewInterface $businessPage */ $businessPage = $this->pageHelper->findPageByReference($child); if ($businessPage->isPublished()) { $businessPage->setReference($child); $businessPages[] = $businessPage; } } $businessPages = $this->getBusinessPages($child, $businessPages); } return $businessPages; }
php
private function getBusinessPages(ViewReference $tree, $businessPages = []) { foreach ($tree->getChildren() as $child) { if ($child instanceof BusinessPageReference && $child->getViewNamespace() === VirtualBusinessPage::class ) { /** @var WebViewInterface $businessPage */ $businessPage = $this->pageHelper->findPageByReference($child); if ($businessPage->isPublished()) { $businessPage->setReference($child); $businessPages[] = $businessPage; } } $businessPages = $this->getBusinessPages($child, $businessPages); } return $businessPages; }
[ "private", "function", "getBusinessPages", "(", "ViewReference", "$", "tree", ",", "$", "businessPages", "=", "[", "]", ")", "{", "foreach", "(", "$", "tree", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "if", "(", "$", "child", "instan...
Get all VirtualBusinessPage recursively. @param ViewReference $tree @param array $businessPages @throws \Exception @return array
[ "Get", "all", "VirtualBusinessPage", "recursively", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Domain/Export/SitemapExportHandler.php#L143-L160
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.findPageByParameters
public function findPageByParameters($parameters) { if (!empty($parameters['id']) && !preg_match('/^ref_/', $parameters['id'])) { $page = $this->entityManager->getRepository('VictoireCoreBundle:View')->findOneBy([ 'id' => $parameters['id'], ]); $this->checkPageValidity($page, $parameters); } else { if (isset($parameters['id']) && isset($parameters['locale'])) { //if locale is missing, we add append locale if (preg_match('/^ref_[0-9]*$/', $parameters['id'])) { $parameters['id'] .= '_'.$parameters['locale']; } } $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters); if ($viewReference === null && !empty($parameters['viewId'])) { $parameters['templateId'] = $parameters['viewId']; unset($parameters['viewId']); $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters); } if ($viewReference instanceof ViewReference) { $page = $this->findPageByReference($viewReference); } else { throw new ViewReferenceNotFoundException($parameters); } $page->setReference($viewReference, $viewReference->getLocale()); } return $page; }
php
public function findPageByParameters($parameters) { if (!empty($parameters['id']) && !preg_match('/^ref_/', $parameters['id'])) { $page = $this->entityManager->getRepository('VictoireCoreBundle:View')->findOneBy([ 'id' => $parameters['id'], ]); $this->checkPageValidity($page, $parameters); } else { if (isset($parameters['id']) && isset($parameters['locale'])) { //if locale is missing, we add append locale if (preg_match('/^ref_[0-9]*$/', $parameters['id'])) { $parameters['id'] .= '_'.$parameters['locale']; } } $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters); if ($viewReference === null && !empty($parameters['viewId'])) { $parameters['templateId'] = $parameters['viewId']; unset($parameters['viewId']); $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters); } if ($viewReference instanceof ViewReference) { $page = $this->findPageByReference($viewReference); } else { throw new ViewReferenceNotFoundException($parameters); } $page->setReference($viewReference, $viewReference->getLocale()); } return $page; }
[ "public", "function", "findPageByParameters", "(", "$", "parameters", ")", "{", "if", "(", "!", "empty", "(", "$", "parameters", "[", "'id'", "]", ")", "&&", "!", "preg_match", "(", "'/^ref_/'", ",", "$", "parameters", "[", "'id'", "]", ")", ")", "{", ...
Generates a response from parameters. @param array $parameters @throws ViewReferenceNotFoundException @return View
[ "Generates", "a", "response", "from", "parameters", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L138-L169
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.renderPageByUrl
public function renderPageByUrl($uri, $url, $locale, $layout = null) { $page = null; if ($viewReference = $this->viewReferenceRepository->getReferenceByUrl($url, $locale)) { $page = $this->findPageByReference($viewReference); $this->checkPageValidity($page, ['url' => $url, 'locale' => $locale]); $page->setReference($viewReference); if ($page instanceof BasePage && $page->getSeo() && $page->getSeo()->getRedirectTo() && $page->getSeo()->getRedirectTo()->getLinkType() != Link::TYPE_NONE && !$this->session->get('victoire.edit_mode', false)) { $link = $page->getSeo()->getRedirectTo(); return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl($link->getParameters())); } return $this->renderPage($page, $layout); } else { try { /** @var Error404 $error404 */ $error404 = $this->entityManager->getRepository('VictoireSeoBundle:Error404')->findOneBy(['url' => $uri]); /** @var Redirection $redirection */ $redirection = $this->entityManager->getRepository('VictoireSeoBundle:Redirection')->findOneBy(['url' => $uri]); $result = $this->redirectionHandler->handleError($redirection, $error404); if ($result instanceof Redirection) { return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl( $result->getLink()->getParameters() ), Response::HTTP_MOVED_PERMANENTLY); } elseif ($result->getRedirection()) { return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl( $result->getRedirection()->getLink()->getParameters() )); } } catch (NoResultException $e) { $error = new Error404(); $error->setUrl($uri); $error->setType($this->redirectionHandler->handleErrorExtension(pathinfo($uri, PATHINFO_EXTENSION))); $this->entityManager->persist($error); $this->entityManager->flush(); } throw new NotFoundHttpException(sprintf('Page not found (url: "%s", locale: "%s")', $url, $locale)); } }
php
public function renderPageByUrl($uri, $url, $locale, $layout = null) { $page = null; if ($viewReference = $this->viewReferenceRepository->getReferenceByUrl($url, $locale)) { $page = $this->findPageByReference($viewReference); $this->checkPageValidity($page, ['url' => $url, 'locale' => $locale]); $page->setReference($viewReference); if ($page instanceof BasePage && $page->getSeo() && $page->getSeo()->getRedirectTo() && $page->getSeo()->getRedirectTo()->getLinkType() != Link::TYPE_NONE && !$this->session->get('victoire.edit_mode', false)) { $link = $page->getSeo()->getRedirectTo(); return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl($link->getParameters())); } return $this->renderPage($page, $layout); } else { try { /** @var Error404 $error404 */ $error404 = $this->entityManager->getRepository('VictoireSeoBundle:Error404')->findOneBy(['url' => $uri]); /** @var Redirection $redirection */ $redirection = $this->entityManager->getRepository('VictoireSeoBundle:Redirection')->findOneBy(['url' => $uri]); $result = $this->redirectionHandler->handleError($redirection, $error404); if ($result instanceof Redirection) { return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl( $result->getLink()->getParameters() ), Response::HTTP_MOVED_PERMANENTLY); } elseif ($result->getRedirection()) { return new RedirectResponse($this->container->get('victoire_widget.twig.link_extension')->victoireLinkUrl( $result->getRedirection()->getLink()->getParameters() )); } } catch (NoResultException $e) { $error = new Error404(); $error->setUrl($uri); $error->setType($this->redirectionHandler->handleErrorExtension(pathinfo($uri, PATHINFO_EXTENSION))); $this->entityManager->persist($error); $this->entityManager->flush(); } throw new NotFoundHttpException(sprintf('Page not found (url: "%s", locale: "%s")', $url, $locale)); } }
[ "public", "function", "renderPageByUrl", "(", "$", "uri", ",", "$", "url", ",", "$", "locale", ",", "$", "layout", "=", "null", ")", "{", "$", "page", "=", "null", ";", "if", "(", "$", "viewReference", "=", "$", "this", "->", "viewReferenceRepository",...
Generates a response from a page url. If seo redirect, return target. @param string $uri @param string $url @param $locale @param string|null $layout @return Response
[ "Generates", "a", "response", "from", "a", "page", "url", ".", "If", "seo", "redirect", "return", "target", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L182-L231
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.renderPage
public function renderPage($view, $layout = null) { $event = new PageMenuContextualEvent($view); //Set currentView and dispatch victoire.on_render_page event with this currentView $pageRenderEvent = new PageRenderEvent($view); $this->eventDispatcher->dispatch('victoire.on_render_page', $pageRenderEvent); $this->currentViewHelper->setCurrentView($view); //Build WidgetMap $this->widgetMapBuilder->build($view, true); //Populate widgets with their data $this->widgetDataWarmer->warm($this->entityManager, $view); //Dispatch contextual event regarding page type if (in_array($view->getType(), ['business_page', 'virtual_business_page'])) { //Dispatch also an event with the Business entity name $eventName = 'victoire_core.page_menu.contextual'; if (!$view->getId()) { $eventName = 'victoire_core.business_template_menu.contextual'; $event = new PageMenuContextualEvent($view->getTemplate()); } $this->eventDispatcher->dispatch($eventName, $event); $type = $view->getBusinessEntityId(); } else { $type = $view->getType(); } $eventName = 'victoire_core.'.$type.'_menu.contextual'; $this->eventDispatcher->dispatch($eventName, $event); if (null === $layout) { //Determine which layout to use $layout = $this->guessBestLayoutForView($view); } $globalConfig = $this->entityManager->getRepository(GlobalConfig::class)->findLast() ?: new GlobalConfig(); //Create the response $response = $this->container->get('templating')->renderResponse('VictoireCoreBundle:Layout:'.$layout.'.html.twig', [ 'globalConfig' => $globalConfig, 'victoire_i18n_available_locales' => $this->availableLocales, 'victoire_twig_responsive' => $this->twigResponsive, 'view' => $view, ]); return $response; }
php
public function renderPage($view, $layout = null) { $event = new PageMenuContextualEvent($view); //Set currentView and dispatch victoire.on_render_page event with this currentView $pageRenderEvent = new PageRenderEvent($view); $this->eventDispatcher->dispatch('victoire.on_render_page', $pageRenderEvent); $this->currentViewHelper->setCurrentView($view); //Build WidgetMap $this->widgetMapBuilder->build($view, true); //Populate widgets with their data $this->widgetDataWarmer->warm($this->entityManager, $view); //Dispatch contextual event regarding page type if (in_array($view->getType(), ['business_page', 'virtual_business_page'])) { //Dispatch also an event with the Business entity name $eventName = 'victoire_core.page_menu.contextual'; if (!$view->getId()) { $eventName = 'victoire_core.business_template_menu.contextual'; $event = new PageMenuContextualEvent($view->getTemplate()); } $this->eventDispatcher->dispatch($eventName, $event); $type = $view->getBusinessEntityId(); } else { $type = $view->getType(); } $eventName = 'victoire_core.'.$type.'_menu.contextual'; $this->eventDispatcher->dispatch($eventName, $event); if (null === $layout) { //Determine which layout to use $layout = $this->guessBestLayoutForView($view); } $globalConfig = $this->entityManager->getRepository(GlobalConfig::class)->findLast() ?: new GlobalConfig(); //Create the response $response = $this->container->get('templating')->renderResponse('VictoireCoreBundle:Layout:'.$layout.'.html.twig', [ 'globalConfig' => $globalConfig, 'victoire_i18n_available_locales' => $this->availableLocales, 'victoire_twig_responsive' => $this->twigResponsive, 'view' => $view, ]); return $response; }
[ "public", "function", "renderPage", "(", "$", "view", ",", "$", "layout", "=", "null", ")", "{", "$", "event", "=", "new", "PageMenuContextualEvent", "(", "$", "view", ")", ";", "//Set currentView and dispatch victoire.on_render_page event with this currentView", "$",...
Generates a response from a page. @param View $view @param string|null $layout @return Response
[ "Generates", "a", "response", "from", "a", "page", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L241-L288
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.updatePageWithEntity
public function updatePageWithEntity(BusinessTemplate $page, $entity) { $page = $this->businessPageBuilder->generateEntityPageFromTemplate($page, $entity, $this->entityManager); $this->pageSeoHelper->updateSeoByEntity($page, $entity); //update the parameters of the page $this->businessPageBuilder->updatePageParametersByEntity($page, $entity); return $page; }
php
public function updatePageWithEntity(BusinessTemplate $page, $entity) { $page = $this->businessPageBuilder->generateEntityPageFromTemplate($page, $entity, $this->entityManager); $this->pageSeoHelper->updateSeoByEntity($page, $entity); //update the parameters of the page $this->businessPageBuilder->updatePageParametersByEntity($page, $entity); return $page; }
[ "public", "function", "updatePageWithEntity", "(", "BusinessTemplate", "$", "page", ",", "$", "entity", ")", "{", "$", "page", "=", "$", "this", "->", "businessPageBuilder", "->", "generateEntityPageFromTemplate", "(", "$", "page", ",", "$", "entity", ",", "$"...
Populate the page with given entity. @param BusinessTemplate $page @param BusinessEntity $entity
[ "Populate", "the", "page", "with", "given", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L296-L305
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.findPageByReference
public function findPageByReference($viewReference) { $page = null; if ($viewReference instanceof BusinessPageReference) { if ($viewReference->getViewId()) { //BusinessPage $page = $this->entityManager->getRepository('VictoireCoreBundle:View') ->findOneBy([ 'id' => $viewReference->getViewId(), ]); $page->setCurrentLocale($viewReference->getLocale()); } else { //VirtualBusinessPage $page = $this->entityManager->getRepository('VictoireCoreBundle:View') ->findOneBy([ 'id' => $viewReference->getTemplateId(), ]); if ($entity = $this->findEntityByReference($viewReference)) { if ($page instanceof BusinessTemplate) { $page = $this->updatePageWithEntity($page, $entity); } if ($page instanceof BusinessPage) { if ($page->getSeo()) { $page->getSeo()->setCurrentLocale($viewReference->getLocale()); } $this->pageSeoHelper->updateSeoByEntity($page, $entity); } } } } elseif ($viewReference instanceof ViewReference) { $page = $this->entityManager->getRepository('VictoireCoreBundle:View') ->findOneBy([ 'id' => $viewReference->getViewId(), ]); $page->setCurrentLocale($viewReference->getLocale()); } else { throw new \Exception(sprintf('Oh no! Cannot find a page for this ViewReference (%s)', ClassUtils::getClass($viewReference))); } return $page; }
php
public function findPageByReference($viewReference) { $page = null; if ($viewReference instanceof BusinessPageReference) { if ($viewReference->getViewId()) { //BusinessPage $page = $this->entityManager->getRepository('VictoireCoreBundle:View') ->findOneBy([ 'id' => $viewReference->getViewId(), ]); $page->setCurrentLocale($viewReference->getLocale()); } else { //VirtualBusinessPage $page = $this->entityManager->getRepository('VictoireCoreBundle:View') ->findOneBy([ 'id' => $viewReference->getTemplateId(), ]); if ($entity = $this->findEntityByReference($viewReference)) { if ($page instanceof BusinessTemplate) { $page = $this->updatePageWithEntity($page, $entity); } if ($page instanceof BusinessPage) { if ($page->getSeo()) { $page->getSeo()->setCurrentLocale($viewReference->getLocale()); } $this->pageSeoHelper->updateSeoByEntity($page, $entity); } } } } elseif ($viewReference instanceof ViewReference) { $page = $this->entityManager->getRepository('VictoireCoreBundle:View') ->findOneBy([ 'id' => $viewReference->getViewId(), ]); $page->setCurrentLocale($viewReference->getLocale()); } else { throw new \Exception(sprintf('Oh no! Cannot find a page for this ViewReference (%s)', ClassUtils::getClass($viewReference))); } return $page; }
[ "public", "function", "findPageByReference", "(", "$", "viewReference", ")", "{", "$", "page", "=", "null", ";", "if", "(", "$", "viewReference", "instanceof", "BusinessPageReference", ")", "{", "if", "(", "$", "viewReference", "->", "getViewId", "(", ")", "...
find the page according to given url. @return View
[ "find", "the", "page", "according", "to", "given", "url", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L327-L365
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.createPageInstanceFromBusinessTemplate
public function createPageInstanceFromBusinessTemplate(BusinessTemplate $BusinessTemplate, $entity, $url) { //create a new page $newPage = new Page(); $parentPage = $BusinessTemplate->getParent(); //set the page parameter by the business entity page $newPage->setParent($parentPage); $newPage->setTemplate($BusinessTemplate); $newPage->setUrl($url); $newPage->setTitle($BusinessTemplate->getTitle()); //update the parameters of the page $this->businessPageBuilder->updatePageParametersByEntity($newPage, $entity); $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity); $entityProxy = new EntityProxy(); $entityProxy->setEntity($entity, $businessEntity->getName()); $newPage->setEntityProxy($entityProxy); return $newPage; }
php
public function createPageInstanceFromBusinessTemplate(BusinessTemplate $BusinessTemplate, $entity, $url) { //create a new page $newPage = new Page(); $parentPage = $BusinessTemplate->getParent(); //set the page parameter by the business entity page $newPage->setParent($parentPage); $newPage->setTemplate($BusinessTemplate); $newPage->setUrl($url); $newPage->setTitle($BusinessTemplate->getTitle()); //update the parameters of the page $this->businessPageBuilder->updatePageParametersByEntity($newPage, $entity); $businessEntity = $this->businessEntityHelper->findByEntityInstance($entity); $entityProxy = new EntityProxy(); $entityProxy->setEntity($entity, $businessEntity->getName()); $newPage->setEntityProxy($entityProxy); return $newPage; }
[ "public", "function", "createPageInstanceFromBusinessTemplate", "(", "BusinessTemplate", "$", "BusinessTemplate", ",", "$", "entity", ",", "$", "url", ")", "{", "//create a new page", "$", "newPage", "=", "new", "Page", "(", ")", ";", "$", "parentPage", "=", "$"...
Create an instance of the business entity page. @param BusinessTemplate $BusinessTemplate The business entity page @param entity $entity The entity @param string $url The new url @return \Victoire\Bundle\PageBundle\Entity\Page
[ "Create", "an", "instance", "of", "the", "business", "entity", "page", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L435-L459
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.guessBestLayoutForView
private function guessBestLayoutForView(View $view) { if (method_exists($view, 'getLayout') && $view->getLayout()) { $viewLayout = $view->getLayout(); } else { $viewLayout = $view->getTemplate()->getLayout(); } return $viewLayout; }
php
private function guessBestLayoutForView(View $view) { if (method_exists($view, 'getLayout') && $view->getLayout()) { $viewLayout = $view->getLayout(); } else { $viewLayout = $view->getTemplate()->getLayout(); } return $viewLayout; }
[ "private", "function", "guessBestLayoutForView", "(", "View", "$", "view", ")", "{", "if", "(", "method_exists", "(", "$", "view", ",", "'getLayout'", ")", "&&", "$", "view", "->", "getLayout", "(", ")", ")", "{", "$", "viewLayout", "=", "$", "view", "...
Guess which layout to use for a given View. @param View $view @return string
[ "Guess", "which", "layout", "to", "use", "for", "a", "given", "View", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L468-L477
train
Victoire/victoire
Bundle/PageBundle/Helper/PageHelper.php
PageHelper.setPosition
public function setPosition(BasePage $page) { if ($page->getParent()) { $pageNb = count($page->getParent()->getChildren()); } else { $pageNb = count($this->entityManager->getRepository('VictoirePageBundle:BasePage')->findByParent(null)); } // + 1 because position start at 1, not 0 $page->setPosition($pageNb + 1); return $page; }
php
public function setPosition(BasePage $page) { if ($page->getParent()) { $pageNb = count($page->getParent()->getChildren()); } else { $pageNb = count($this->entityManager->getRepository('VictoirePageBundle:BasePage')->findByParent(null)); } // + 1 because position start at 1, not 0 $page->setPosition($pageNb + 1); return $page; }
[ "public", "function", "setPosition", "(", "BasePage", "$", "page", ")", "{", "if", "(", "$", "page", "->", "getParent", "(", ")", ")", "{", "$", "pageNb", "=", "count", "(", "$", "page", "->", "getParent", "(", ")", "->", "getChildren", "(", ")", "...
Set Page position. @param BasePage $page @return BasePage $page
[ "Set", "Page", "position", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/PageBundle/Helper/PageHelper.php#L518-L530
train
Victoire/victoire
Bundle/BlogBundle/Manager/ArticleManager.php
ArticleManager.create
public function create(Article $article, User $author) { $article->setAuthor($author); /** @var Tag[] $tags */ $tags = $article->getTags(); if (is_array($tags)) { foreach ($tags as $tag) { $tag->setBlog($article->getBlog()); $this->entityManager->persist($tag); } } //Article has to be persisted before BusinessPage generation $this->entityManager->persist($article); $this->entityManager->flush(); $page = $this->businessPageBuilder->generateEntityPageFromTemplate( $article->getTemplate(), $article, $this->entityManager ); //Transform VBP into BP $this->virtualToBusinessPageTransformer->transform($page); $page->setParent($article->getBlog()); $page->setStatus($article->getStatus()); $this->entityManager->persist($page); $this->entityManager->flush(); return $page; }
php
public function create(Article $article, User $author) { $article->setAuthor($author); /** @var Tag[] $tags */ $tags = $article->getTags(); if (is_array($tags)) { foreach ($tags as $tag) { $tag->setBlog($article->getBlog()); $this->entityManager->persist($tag); } } //Article has to be persisted before BusinessPage generation $this->entityManager->persist($article); $this->entityManager->flush(); $page = $this->businessPageBuilder->generateEntityPageFromTemplate( $article->getTemplate(), $article, $this->entityManager ); //Transform VBP into BP $this->virtualToBusinessPageTransformer->transform($page); $page->setParent($article->getBlog()); $page->setStatus($article->getStatus()); $this->entityManager->persist($page); $this->entityManager->flush(); return $page; }
[ "public", "function", "create", "(", "Article", "$", "article", ",", "User", "$", "author", ")", "{", "$", "article", "->", "setAuthor", "(", "$", "author", ")", ";", "/** @var Tag[] $tags */", "$", "tags", "=", "$", "article", "->", "getTags", "(", ")",...
Create Article with its author, tags. Create BusinessPage for this Article. @param Article $article @param User $author @return BusinessPage
[ "Create", "Article", "with", "its", "author", "tags", ".", "Create", "BusinessPage", "for", "this", "Article", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Manager/ArticleManager.php#L54-L86
train
Victoire/victoire
Bundle/BlogBundle/Manager/ArticleManager.php
ArticleManager.updateSettings
public function updateSettings(Article $article) { //Update Tags /** @var Tag[] $tags */ $tags = $article->getTags(); if (is_array($tags)) { foreach ($tags as $tag) { $tag->setBlog($article->getBlog()); $this->entityManager->persist($tag); } } //Update BusinessPage $businessPage = $this->pageHelper->findPageByParameters([ 'viewId' => $article->getTemplate()->getId(), 'entityId' => $article->getId(), ]); $template = $article->getTemplate(); $businessPage->setTemplate($template); //Update Page $page = $this->pageHelper->findPageByParameters([ 'viewId' => $template->getId(), 'entityId' => $article->getId(), ]); $page->setName($article->getName()); $page->setSlug($article->getSlug()); $page->setStatus($article->getStatus()); $this->entityManager->flush(); //Set ViewReference for Page redirection $viewReference = $this->viewReferenceRepo->getOneReferenceByParameters( ['viewId' => $page->getId()] ); $page->setReference($viewReference); return $page; }
php
public function updateSettings(Article $article) { //Update Tags /** @var Tag[] $tags */ $tags = $article->getTags(); if (is_array($tags)) { foreach ($tags as $tag) { $tag->setBlog($article->getBlog()); $this->entityManager->persist($tag); } } //Update BusinessPage $businessPage = $this->pageHelper->findPageByParameters([ 'viewId' => $article->getTemplate()->getId(), 'entityId' => $article->getId(), ]); $template = $article->getTemplate(); $businessPage->setTemplate($template); //Update Page $page = $this->pageHelper->findPageByParameters([ 'viewId' => $template->getId(), 'entityId' => $article->getId(), ]); $page->setName($article->getName()); $page->setSlug($article->getSlug()); $page->setStatus($article->getStatus()); $this->entityManager->flush(); //Set ViewReference for Page redirection $viewReference = $this->viewReferenceRepo->getOneReferenceByParameters( ['viewId' => $page->getId()] ); $page->setReference($viewReference); return $page; }
[ "public", "function", "updateSettings", "(", "Article", "$", "article", ")", "{", "//Update Tags", "/** @var Tag[] $tags */", "$", "tags", "=", "$", "article", "->", "getTags", "(", ")", ";", "if", "(", "is_array", "(", "$", "tags", ")", ")", "{", "foreach...
Update Blog Article settings. @param Article $article @throws ViewReferenceNotFoundException @return View
[ "Update", "Blog", "Article", "settings", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Manager/ArticleManager.php#L97-L135
train
Victoire/victoire
Bundle/BlogBundle/Manager/ArticleManager.php
ArticleManager.delete
public function delete(Article $article) { $bep = $this->pageHelper->findPageByParameters( [ 'templateId' => $article->getTemplate()->getId(), 'entityId' => $article->getId(), ] ); $this->entityManager->remove($bep); $article->setVisibleOnFront(0); $article->setDeletedAt(new \DateTime()); $article->setStatus(PageStatus::DELETED); $this->entityManager->flush(); }
php
public function delete(Article $article) { $bep = $this->pageHelper->findPageByParameters( [ 'templateId' => $article->getTemplate()->getId(), 'entityId' => $article->getId(), ] ); $this->entityManager->remove($bep); $article->setVisibleOnFront(0); $article->setDeletedAt(new \DateTime()); $article->setStatus(PageStatus::DELETED); $this->entityManager->flush(); }
[ "public", "function", "delete", "(", "Article", "$", "article", ")", "{", "$", "bep", "=", "$", "this", "->", "pageHelper", "->", "findPageByParameters", "(", "[", "'templateId'", "=>", "$", "article", "->", "getTemplate", "(", ")", "->", "getId", "(", "...
Delete a given Article. @param Article $article
[ "Delete", "a", "given", "Article", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BlogBundle/Manager/ArticleManager.php#L142-L157
train
Victoire/victoire
Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php
BusinessPageBuilder.getBusinessProperties
public function getBusinessProperties(BusinessEntity $businessEntity) { //the business properties usable in a url $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter'); //the business properties usable in a url $seoBusinessProps = $businessEntity->getBusinessPropertiesByType('seoable'); //the business properties are the identifier and the seoables properties $businessProperties = array_merge($businessProperties, $seoBusinessProps); return $businessProperties; }
php
public function getBusinessProperties(BusinessEntity $businessEntity) { //the business properties usable in a url $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter'); //the business properties usable in a url $seoBusinessProps = $businessEntity->getBusinessPropertiesByType('seoable'); //the business properties are the identifier and the seoables properties $businessProperties = array_merge($businessProperties, $seoBusinessProps); return $businessProperties; }
[ "public", "function", "getBusinessProperties", "(", "BusinessEntity", "$", "businessEntity", ")", "{", "//the business properties usable in a url", "$", "businessProperties", "=", "$", "businessEntity", "->", "getBusinessPropertiesByType", "(", "'businessParameter'", ")", ";"...
Get the list of business properties usable for the url. @param BusinessEntity $businessEntity @return BusinessProperty[] The list of business properties
[ "Get", "the", "list", "of", "business", "properties", "usable", "for", "the", "url", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php#L157-L169
train
Victoire/victoire
Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php
BusinessPageBuilder.getEntityAttributeValue
protected function getEntityAttributeValue($entity, $field) { $functionName = 'get'.ucfirst($field); $fieldValue = call_user_func([$entity, $functionName]); return $fieldValue; }
php
protected function getEntityAttributeValue($entity, $field) { $functionName = 'get'.ucfirst($field); $fieldValue = call_user_func([$entity, $functionName]); return $fieldValue; }
[ "protected", "function", "getEntityAttributeValue", "(", "$", "entity", ",", "$", "field", ")", "{", "$", "functionName", "=", "'get'", ".", "ucfirst", "(", "$", "field", ")", ";", "$", "fieldValue", "=", "call_user_func", "(", "[", "$", "entity", ",", "...
Get the content of an attribute of an entity given. @param BusinessPage $entity @param string $field @return mixed
[ "Get", "the", "content", "of", "an", "attribute", "of", "an", "entity", "given", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php#L215-L222
train
Victoire/victoire
Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php
BusinessPageBuilder.setEntityAttributeValue
protected function setEntityAttributeValue($entity, $field, $value) { $functionName = 'set'.ucfirst($field); call_user_func([$entity, $functionName], $value); }
php
protected function setEntityAttributeValue($entity, $field, $value) { $functionName = 'set'.ucfirst($field); call_user_func([$entity, $functionName], $value); }
[ "protected", "function", "setEntityAttributeValue", "(", "$", "entity", ",", "$", "field", ",", "$", "value", ")", "{", "$", "functionName", "=", "'set'", ".", "ucfirst", "(", "$", "field", ")", ";", "call_user_func", "(", "[", "$", "entity", ",", "$", ...
Update the value of the entity. @param BusinessPage $entity @param string $field @param string $value @return mixed
[ "Update", "the", "value", "of", "the", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Builder/BusinessPageBuilder.php#L233-L238
train
Victoire/victoire
Bundle/CoreBundle/EventSubscriber/EntityProxySubscriber.php
EntityProxySubscriber.loadClassMetadata
public static function loadClassMetadata($eventArgs) { if ($eventArgs instanceof LoadClassMetadataEventArgs) { /** @var ClassMetadata $metadatas */ $metadatas = $eventArgs->getClassMetadata(); if ($metadatas->name === 'Victoire\Bundle\CoreBundle\Entity\EntityProxy') { foreach (self::$cacheReader->getBusinessClasses() as $entity) { if (!$metadatas->hasAssociation($entity->getId())) { $metadatas->mapOneToOne([ 'fieldName' => $entity->getId(), 'targetEntity' => $entity->getClass(), 'cascade' => ['persist'], ] ); $metadatas->associationMappings[$entity->getId()]['joinColumns'][0]['onDelete'] = 'CASCADE'; } } } } }
php
public static function loadClassMetadata($eventArgs) { if ($eventArgs instanceof LoadClassMetadataEventArgs) { /** @var ClassMetadata $metadatas */ $metadatas = $eventArgs->getClassMetadata(); if ($metadatas->name === 'Victoire\Bundle\CoreBundle\Entity\EntityProxy') { foreach (self::$cacheReader->getBusinessClasses() as $entity) { if (!$metadatas->hasAssociation($entity->getId())) { $metadatas->mapOneToOne([ 'fieldName' => $entity->getId(), 'targetEntity' => $entity->getClass(), 'cascade' => ['persist'], ] ); $metadatas->associationMappings[$entity->getId()]['joinColumns'][0]['onDelete'] = 'CASCADE'; } } } } }
[ "public", "static", "function", "loadClassMetadata", "(", "$", "eventArgs", ")", "{", "if", "(", "$", "eventArgs", "instanceof", "LoadClassMetadataEventArgs", ")", "{", "/** @var ClassMetadata $metadatas */", "$", "metadatas", "=", "$", "eventArgs", "->", "getClassMet...
Insert enabled widgets in base widget add relationship between BusinessEntities and EntityProxy. @param LoadClassMetadataEventArgs $eventArgs
[ "Insert", "enabled", "widgets", "in", "base", "widget", "add", "relationship", "between", "BusinessEntities", "and", "EntityProxy", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/EventSubscriber/EntityProxySubscriber.php#L44-L63
train
Victoire/victoire
Bundle/FormBundle/DependencyInjection/Configuration.php
Configuration.addIconsConfig
protected function addIconsConfig(ArrayNodeDefinition $rootNode) { $iconSets = ['glyphicons', 'fontawesome', 'fontawesome4']; $rootNode ->children() ->arrayNode('icons') ->addDefaultsIfNotSet() ->children() ->scalarNode('icon_set') ->info('Icon set to use: '.json_encode($iconSets)) ->defaultValue('glyphicons') ->validate() ->ifNotInArray($iconSets) ->thenInvalid('Must choose one of '.json_encode($iconSets)) ->end() ->end() ->scalarNode('shortcut') ->info('Alias for vic_mopa_bootstrap_icon()') ->defaultValue('icon') ->end() ->end() ->end() ->end(); }
php
protected function addIconsConfig(ArrayNodeDefinition $rootNode) { $iconSets = ['glyphicons', 'fontawesome', 'fontawesome4']; $rootNode ->children() ->arrayNode('icons') ->addDefaultsIfNotSet() ->children() ->scalarNode('icon_set') ->info('Icon set to use: '.json_encode($iconSets)) ->defaultValue('glyphicons') ->validate() ->ifNotInArray($iconSets) ->thenInvalid('Must choose one of '.json_encode($iconSets)) ->end() ->end() ->scalarNode('shortcut') ->info('Alias for vic_mopa_bootstrap_icon()') ->defaultValue('icon') ->end() ->end() ->end() ->end(); }
[ "protected", "function", "addIconsConfig", "(", "ArrayNodeDefinition", "$", "rootNode", ")", "{", "$", "iconSets", "=", "[", "'glyphicons'", ",", "'fontawesome'", ",", "'fontawesome4'", "]", ";", "$", "rootNode", "->", "children", "(", ")", "->", "arrayNode", ...
Add icon configuration. @param ArrayNodeDefinition $rootNode The root node
[ "Add", "icon", "configuration", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/FormBundle/DependencyInjection/Configuration.php#L228-L252
train
Victoire/victoire
Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php
AnalyticsViewHelper.getMostReadByViewType
public function getMostReadByViewType($viewNamespace, $number) { $views = []; switch ($viewNamespace) { case 'Victoire\Bundle\PageBundle\Entity\Page': $viewReferences = []; $repo = $this->entityManager->getRepository($viewNamespace); //get pages and viewReferenceIds foreach ($repo->getAll()->run() as $key => $page) { $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters( [ 'viewNamespace' => $viewNamespace, 'viewId' => $page->getId(), ] ); $viewReferences[$viewReference->getId()] = $viewReference; } //get pager $browseEvents = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') ->getMostVisitedFromReferences(array_keys($viewReferences), $number) ->getQuery() ->getResult(); //Now we get the most visited references, we'll get views with PageHelper foreach ($browseEvents as $browseEvent) { $views[] = $this->pageHelper->findPageByReference( $viewReferences[$browseEvent->getViewReferenceId()] ); } break; default: // code... break; } return $views; }
php
public function getMostReadByViewType($viewNamespace, $number) { $views = []; switch ($viewNamespace) { case 'Victoire\Bundle\PageBundle\Entity\Page': $viewReferences = []; $repo = $this->entityManager->getRepository($viewNamespace); //get pages and viewReferenceIds foreach ($repo->getAll()->run() as $key => $page) { $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters( [ 'viewNamespace' => $viewNamespace, 'viewId' => $page->getId(), ] ); $viewReferences[$viewReference->getId()] = $viewReference; } //get pager $browseEvents = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') ->getMostVisitedFromReferences(array_keys($viewReferences), $number) ->getQuery() ->getResult(); //Now we get the most visited references, we'll get views with PageHelper foreach ($browseEvents as $browseEvent) { $views[] = $this->pageHelper->findPageByReference( $viewReferences[$browseEvent->getViewReferenceId()] ); } break; default: // code... break; } return $views; }
[ "public", "function", "getMostReadByViewType", "(", "$", "viewNamespace", ",", "$", "number", ")", "{", "$", "views", "=", "[", "]", ";", "switch", "(", "$", "viewNamespace", ")", "{", "case", "'Victoire\\Bundle\\PageBundle\\Entity\\Page'", ":", "$", "viewRefere...
Get the most read views by type. @return View[]
[ "Get", "the", "most", "read", "views", "by", "type", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php#L39-L78
train
Victoire/victoire
Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php
AnalyticsViewHelper.getMostReadArticlesByBlog
public function getMostReadArticlesByBlog($blog, $number, $excludeUnpublished = true) { $viewReferences = []; //get articles and viewReferenceIds $articles = $this->entityManager->getRepository('Victoire\Bundle\BlogBundle\Entity\Article') ->getAll($excludeUnpublished) ->filterByBlog($blog) ->run(); foreach ($articles as $key => $article) { if ($viewReference = $this->viewReferenceRepository->getOneReferenceByParameters( [ 'entityNamespace' => 'Victoire\Bundle\BlogBundle\Entity\Article', 'entityId' => $article->getId(), ] )) { $viewReferences[$viewReference->getId()] = $viewReference; } } //get pager $browseEvents = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') ->getMostVisitedFromReferences(array_keys($viewReferences), $number) ->getQuery() ->getResult(); $views = []; //Now we get the most visited references, we'll get views with PageHelper foreach ($browseEvents as $browseEvent) { $views[] = $this->pageHelper->findPageByReference( $viewReferences[$browseEvent->getViewReferenceId()] ); } return $views; }
php
public function getMostReadArticlesByBlog($blog, $number, $excludeUnpublished = true) { $viewReferences = []; //get articles and viewReferenceIds $articles = $this->entityManager->getRepository('Victoire\Bundle\BlogBundle\Entity\Article') ->getAll($excludeUnpublished) ->filterByBlog($blog) ->run(); foreach ($articles as $key => $article) { if ($viewReference = $this->viewReferenceRepository->getOneReferenceByParameters( [ 'entityNamespace' => 'Victoire\Bundle\BlogBundle\Entity\Article', 'entityId' => $article->getId(), ] )) { $viewReferences[$viewReference->getId()] = $viewReference; } } //get pager $browseEvents = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') ->getMostVisitedFromReferences(array_keys($viewReferences), $number) ->getQuery() ->getResult(); $views = []; //Now we get the most visited references, we'll get views with PageHelper foreach ($browseEvents as $browseEvent) { $views[] = $this->pageHelper->findPageByReference( $viewReferences[$browseEvent->getViewReferenceId()] ); } return $views; }
[ "public", "function", "getMostReadArticlesByBlog", "(", "$", "blog", ",", "$", "number", ",", "$", "excludeUnpublished", "=", "true", ")", "{", "$", "viewReferences", "=", "[", "]", ";", "//get articles and viewReferenceIds", "$", "articles", "=", "$", "this", ...
Get the most read articles by blog. @return Article[]
[ "Get", "the", "most", "read", "articles", "by", "blog", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php#L85-L119
train
Victoire/victoire
Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php
AnalyticsViewHelper.getVisitorCountForViewReference
public function getVisitorCountForViewReference($viewReferenceId) { $viewCount = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') ->getNumberOfEventForViewReferenceId($viewReferenceId) ->getQuery() ->getSingleScalarResult(); return $viewCount; }
php
public function getVisitorCountForViewReference($viewReferenceId) { $viewCount = $this->entityManager->getRepository('Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') ->getNumberOfEventForViewReferenceId($viewReferenceId) ->getQuery() ->getSingleScalarResult(); return $viewCount; }
[ "public", "function", "getVisitorCountForViewReference", "(", "$", "viewReferenceId", ")", "{", "$", "viewCount", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "'Victoire\\Bundle\\AnalyticsBundle\\Entity\\BrowseEvent'", ")", "->", "getNumberOfEventFor...
Get number of unique visitor for a viewReference. @param string $viewReferenceId
[ "Get", "number", "of", "unique", "visitor", "for", "a", "viewReference", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/AnalyticsBundle/Helper/AnalyticsViewHelper.php#L126-L134
train
Victoire/victoire
Bundle/SeoBundle/Listener/RedirectionMenuListener.php
RedirectionMenuListener.addGlobal
public function addGlobal() { $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar(); $bottomRightNavbar ->addChild('<i class="fa fa-exclamation"></i>', [ 'route' => 'victoire_404_index', 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', 'id' => 'v-404-link', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); $bottomRightNavbar ->addChild('<i class="fa fa-random"></i>', [ 'route' => 'victoire_redirection_index', 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', 'id' => 'v-redirection-link', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); return $bottomRightNavbar; }
php
public function addGlobal() { $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar(); $bottomRightNavbar ->addChild('<i class="fa fa-exclamation"></i>', [ 'route' => 'victoire_404_index', 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', 'id' => 'v-404-link', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); $bottomRightNavbar ->addChild('<i class="fa fa-random"></i>', [ 'route' => 'victoire_redirection_index', 'linkAttributes' => [ 'class' => 'v-btn v-btn--sm v-btn--transparent', 'id' => 'v-redirection-link', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); return $bottomRightNavbar; }
[ "public", "function", "addGlobal", "(", ")", "{", "$", "bottomRightNavbar", "=", "$", "this", "->", "menuBuilder", "->", "getBottomRightNavbar", "(", ")", ";", "$", "bottomRightNavbar", "->", "addChild", "(", "'<i class=\"fa fa-exclamation\"></i>'", ",", "[", "'ro...
Add global menu items. @return ItemInterface
[ "Add", "global", "menu", "items", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SeoBundle/Listener/RedirectionMenuListener.php#L30-L53
train
Victoire/victoire
Bundle/SitemapBundle/Controller/SitemapController.php
SitemapController.xmlAction
public function xmlAction(Request $request) { $redis = $this->get('snc_redis.victoire_client'); $locale = $request->getLocale(); $cacheKey = "sitemap.$locale"; $pages = $redis->get($cacheKey); if ($pages === null) { $exportHandler = $this->get('victoire_sitemap.export.handler'); $pages = $exportHandler->serialize( $exportHandler->handle($locale) ); } return $this->render('VictoireSitemapBundle:Sitemap:sitemap.xml.twig', [ 'pages' => json_decode($pages), ]); }
php
public function xmlAction(Request $request) { $redis = $this->get('snc_redis.victoire_client'); $locale = $request->getLocale(); $cacheKey = "sitemap.$locale"; $pages = $redis->get($cacheKey); if ($pages === null) { $exportHandler = $this->get('victoire_sitemap.export.handler'); $pages = $exportHandler->serialize( $exportHandler->handle($locale) ); } return $this->render('VictoireSitemapBundle:Sitemap:sitemap.xml.twig', [ 'pages' => json_decode($pages), ]); }
[ "public", "function", "xmlAction", "(", "Request", "$", "request", ")", "{", "$", "redis", "=", "$", "this", "->", "get", "(", "'snc_redis.victoire_client'", ")", ";", "$", "locale", "=", "$", "request", "->", "getLocale", "(", ")", ";", "$", "cacheKey",...
Get Sitemap as XML. @Route(".{_format}", name="victoire_sitemap_xml", Requirements={"_format" = "xml"}) @return Response
[ "Get", "Sitemap", "as", "XML", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Controller/SitemapController.php#L29-L47
train
Victoire/victoire
Bundle/SitemapBundle/Controller/SitemapController.php
SitemapController.reorganizeAction
public function reorganizeAction(Request $request) { if ($request->isMethod('POST')) { $this->get('victoire_sitemap.sort.handler')->handle( $request->request->get('sorted') ); $response['message'] = $this->get('translator')->trans('sitemap.changed.success', [], 'victoire'); } $basePageRepo = $this->getDoctrine()->getManager()->getRepository('VictoirePageBundle:BasePage'); $basePages = $basePageRepo ->getAll() ->joinSeo() ->joinSeoTranslations($request->getLocale()) ->run(); $forms = []; foreach ($basePages as $_page) { $_pageSeo = $_page->getSeo() ?: new PageSeo(); $forms[$_page->getId()] = $this->createSitemapPriorityType($_page, $_pageSeo)->createView(); } $response['success'] = true; $response['html'] = $this->container->get('templating')->render( 'VictoireSitemapBundle:Sitemap:reorganize.html.twig', [ 'pages' => $basePageRepo->findByParent(null, ['position' => 'ASC']), 'forms' => $forms, ] ); return new JsonResponse($response); }
php
public function reorganizeAction(Request $request) { if ($request->isMethod('POST')) { $this->get('victoire_sitemap.sort.handler')->handle( $request->request->get('sorted') ); $response['message'] = $this->get('translator')->trans('sitemap.changed.success', [], 'victoire'); } $basePageRepo = $this->getDoctrine()->getManager()->getRepository('VictoirePageBundle:BasePage'); $basePages = $basePageRepo ->getAll() ->joinSeo() ->joinSeoTranslations($request->getLocale()) ->run(); $forms = []; foreach ($basePages as $_page) { $_pageSeo = $_page->getSeo() ?: new PageSeo(); $forms[$_page->getId()] = $this->createSitemapPriorityType($_page, $_pageSeo)->createView(); } $response['success'] = true; $response['html'] = $this->container->get('templating')->render( 'VictoireSitemapBundle:Sitemap:reorganize.html.twig', [ 'pages' => $basePageRepo->findByParent(null, ['position' => 'ASC']), 'forms' => $forms, ] ); return new JsonResponse($response); }
[ "public", "function", "reorganizeAction", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "request", "->", "isMethod", "(", "'POST'", ")", ")", "{", "$", "this", "->", "get", "(", "'victoire_sitemap.sort.handler'", ")", "->", "handle", "(", "$", ...
Show Sitemap as tree and save new order if necessary. @Route("/reorganize", name="victoire_sitemap_reorganize", options={"expose"=true}) @return JsonResponse
[ "Show", "Sitemap", "as", "tree", "and", "save", "new", "order", "if", "necessary", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Controller/SitemapController.php#L56-L88
train
Victoire/victoire
Bundle/SitemapBundle/Controller/SitemapController.php
SitemapController.changePriorityAction
public function changePriorityAction(Request $request, BasePage $page) { $em = $this->get('doctrine.orm.entity_manager'); $pageSeo = $page->getSeo() ?: new PageSeo(); $pageSeo->setCurrentLocale($request->getLocale()); $form = $this->createSitemapPriorityType($page, $pageSeo); $form->handleRequest($request); $params = [ 'success' => $form->isValid(), ]; if ($form->isValid()) { $page->setSeo($pageSeo); $em->persist($pageSeo); $em->flush(); } return new JsonResponse($params); }
php
public function changePriorityAction(Request $request, BasePage $page) { $em = $this->get('doctrine.orm.entity_manager'); $pageSeo = $page->getSeo() ?: new PageSeo(); $pageSeo->setCurrentLocale($request->getLocale()); $form = $this->createSitemapPriorityType($page, $pageSeo); $form->handleRequest($request); $params = [ 'success' => $form->isValid(), ]; if ($form->isValid()) { $page->setSeo($pageSeo); $em->persist($pageSeo); $em->flush(); } return new JsonResponse($params); }
[ "public", "function", "changePriorityAction", "(", "Request", "$", "request", ",", "BasePage", "$", "page", ")", "{", "$", "em", "=", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", ";", "$", "pageSeo", "=", "$", "page", "->", "getSeo"...
Change the sitemap priority for the given page. @Route("/changePriority/{id}", name="victoire_sitemap_changePriority", options={"expose"=true}) @return JsonResponse
[ "Change", "the", "sitemap", "priority", "for", "the", "given", "page", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Controller/SitemapController.php#L97-L117
train
Victoire/victoire
Bundle/SitemapBundle/Controller/SitemapController.php
SitemapController.createSitemapPriorityType
protected function createSitemapPriorityType(BasePage $page, PageSeo $pageSeo) { $form = $this->createForm(SitemapPriorityPageSeoType::class, $pageSeo, [ 'action' => $this->generateUrl('victoire_sitemap_changePriority', [ 'id' => $page->getId(), ] ), 'method' => 'PUT', 'attr' => [ 'class' => 'sitemapPriorityForm form-inline', 'data-pageId' => $page->getId(), 'id' => 'sitemap-priority-type-'.$page->getId(), 'style' => 'display: inline;', ], ] ); return $form; }
php
protected function createSitemapPriorityType(BasePage $page, PageSeo $pageSeo) { $form = $this->createForm(SitemapPriorityPageSeoType::class, $pageSeo, [ 'action' => $this->generateUrl('victoire_sitemap_changePriority', [ 'id' => $page->getId(), ] ), 'method' => 'PUT', 'attr' => [ 'class' => 'sitemapPriorityForm form-inline', 'data-pageId' => $page->getId(), 'id' => 'sitemap-priority-type-'.$page->getId(), 'style' => 'display: inline;', ], ] ); return $form; }
[ "protected", "function", "createSitemapPriorityType", "(", "BasePage", "$", "page", ",", "PageSeo", "$", "pageSeo", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "SitemapPriorityPageSeoType", "::", "class", ",", "$", "pageSeo", ",", "[", ...
Create a sitemap priority type. @param BasePage $page @param PageSeo $pageSeo @return \Symfony\Component\Form\Form
[ "Create", "a", "sitemap", "priority", "type", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/SitemapBundle/Controller/SitemapController.php#L127-L145
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.indexAction
public function indexAction() { $businessEntityHelper = $this->get('victoire_core.helper.business_entity_helper'); //services $em = $this->get('doctrine.orm.entity_manager'); //the repository $repository = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate'); $BusinessTemplates = []; $businessEntities = $businessEntityHelper->getBusinessEntities(); foreach ($businessEntities as $businessEntity) { $name = $businessEntity->getName(); //retrieve the pagePatterns $pagePatterns = $repository->findPagePatternByBusinessEntity($businessEntity); $BusinessTemplates[$name] = $pagePatterns; } return new JsonResponse([ 'html' => $this->container->get('templating')->render( 'VictoireBusinessPageBundle:BusinessEntity:index.html.twig', [ 'businessEntities' => $businessEntities, 'BusinessTemplates' => $BusinessTemplates, ] ), 'success' => true, ]); }
php
public function indexAction() { $businessEntityHelper = $this->get('victoire_core.helper.business_entity_helper'); //services $em = $this->get('doctrine.orm.entity_manager'); //the repository $repository = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate'); $BusinessTemplates = []; $businessEntities = $businessEntityHelper->getBusinessEntities(); foreach ($businessEntities as $businessEntity) { $name = $businessEntity->getName(); //retrieve the pagePatterns $pagePatterns = $repository->findPagePatternByBusinessEntity($businessEntity); $BusinessTemplates[$name] = $pagePatterns; } return new JsonResponse([ 'html' => $this->container->get('templating')->render( 'VictoireBusinessPageBundle:BusinessEntity:index.html.twig', [ 'businessEntities' => $businessEntities, 'BusinessTemplates' => $BusinessTemplates, ] ), 'success' => true, ]); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "businessEntityHelper", "=", "$", "this", "->", "get", "(", "'victoire_core.helper.business_entity_helper'", ")", ";", "//services", "$", "em", "=", "$", "this", "->", "get", "(", "'doctrine.orm.entity_manag...
List all business entity page pattern. @Route("/", name="victoire_business_template_index") @return JsonResponse
[ "List", "all", "business", "entity", "page", "pattern", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L36-L69
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.showAction
public function showAction(BusinessTemplate $view) { //add the view to twig $this->get('twig')->addGlobal('view', $view); $view->setReference(new ViewReference($view->getId())); return $this->container->get('victoire_page.page_helper')->renderPage($view); }
php
public function showAction(BusinessTemplate $view) { //add the view to twig $this->get('twig')->addGlobal('view', $view); $view->setReference(new ViewReference($view->getId())); return $this->container->get('victoire_page.page_helper')->renderPage($view); }
[ "public", "function", "showAction", "(", "BusinessTemplate", "$", "view", ")", "{", "//add the view to twig", "$", "this", "->", "get", "(", "'twig'", ")", "->", "addGlobal", "(", "'view'", ",", "$", "view", ")", ";", "$", "view", "->", "setReference", "("...
Show BusinessTemplate. @param BusinessTemplate $view @Route("/show/{id}", name="victoire_business_template_show") @ParamConverter("template", class="VictoireBusinessPageBundle:BusinessTemplate") @return Response
[ "Show", "BusinessTemplate", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L81-L88
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.createAction
public function createAction(Request $request, $id) { //get the business entity $businessEntity = $this->getBusinessEntity($id); /** @var BusinessTemplate $view */ $view = $this->get('victoire_business_page.BusinessTemplate_chain')->getBusinessTemplate($id); $view->setBusinessEntityId($businessEntity->getId()); $form = $this->createCreateForm($view); $form->handleRequest($request); $params = [ 'success' => false, ]; if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($view); $em->flush(); //redirect to the page of the pagePattern $params['url'] = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]); $params['success'] = true; $this->congrat($this->get('translator')->trans('victoire.business_template.create.success', [], 'victoire')); } else { //get the errors as a string $params['message'] = $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form); } return new JsonResponse($params); }
php
public function createAction(Request $request, $id) { //get the business entity $businessEntity = $this->getBusinessEntity($id); /** @var BusinessTemplate $view */ $view = $this->get('victoire_business_page.BusinessTemplate_chain')->getBusinessTemplate($id); $view->setBusinessEntityId($businessEntity->getId()); $form = $this->createCreateForm($view); $form->handleRequest($request); $params = [ 'success' => false, ]; if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($view); $em->flush(); //redirect to the page of the pagePattern $params['url'] = $this->generateUrl('victoire_business_template_show', ['id' => $view->getId()]); $params['success'] = true; $this->congrat($this->get('translator')->trans('victoire.business_template.create.success', [], 'victoire')); } else { //get the errors as a string $params['message'] = $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form); } return new JsonResponse($params); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "//get the business entity", "$", "businessEntity", "=", "$", "this", "->", "getBusinessEntity", "(", "$", "id", ")", ";", "/** @var BusinessTemplate $view */", "$", ...
Creates a new BusinessTemplate entity. @param Request $request @param int $id @throws \Exception @Route("{id}/create", name="victoire_business_template_create") @Method("POST") @return JsonResponse
[ "Creates", "a", "new", "BusinessTemplate", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L103-L136
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.createCreateForm
private function createCreateForm(BusinessTemplate $view) { $id = $view->getBusinessEntityId(); $businessProperties = $this->getBusinessProperties($view); $form = $this->createForm( BusinessTemplateType::class, $view, [ 'action' => $this->generateUrl('victoire_business_template_create', ['id' => $id]), 'method' => 'POST', 'vic_business_properties' => $businessProperties, ] ); return $form; }
php
private function createCreateForm(BusinessTemplate $view) { $id = $view->getBusinessEntityId(); $businessProperties = $this->getBusinessProperties($view); $form = $this->createForm( BusinessTemplateType::class, $view, [ 'action' => $this->generateUrl('victoire_business_template_create', ['id' => $id]), 'method' => 'POST', 'vic_business_properties' => $businessProperties, ] ); return $form; }
[ "private", "function", "createCreateForm", "(", "BusinessTemplate", "$", "view", ")", "{", "$", "id", "=", "$", "view", "->", "getBusinessEntityId", "(", ")", ";", "$", "businessProperties", "=", "$", "this", "->", "getBusinessProperties", "(", "$", "view", ...
Creates a form to create a BusinessTemplate entity. @param BusinessTemplate $view The entity @throws \Exception @return \Symfony\Component\Form\Form The form @return Form
[ "Creates", "a", "form", "to", "create", "a", "BusinessTemplate", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L148-L164
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.newAction
public function newAction($id) { //get the business entity $businessEntity = $this->getBusinessEntity($id); /** @var BusinessTemplate $view */ $view = $this->get('victoire_business_page.BusinessTemplate_chain')->getBusinessTemplate($id); $view->setBusinessEntityId($businessEntity->getId()); $form = $this->createCreateForm($view); $parameters = [ 'entity' => $view, 'form' => $form->createView(), ]; return new JsonResponse([ 'html' => $this->container->get('templating')->render( 'VictoireBusinessPageBundle:BusinessTemplate:new.html.twig', $parameters ), 'success' => true, ]); }
php
public function newAction($id) { //get the business entity $businessEntity = $this->getBusinessEntity($id); /** @var BusinessTemplate $view */ $view = $this->get('victoire_business_page.BusinessTemplate_chain')->getBusinessTemplate($id); $view->setBusinessEntityId($businessEntity->getId()); $form = $this->createCreateForm($view); $parameters = [ 'entity' => $view, 'form' => $form->createView(), ]; return new JsonResponse([ 'html' => $this->container->get('templating')->render( 'VictoireBusinessPageBundle:BusinessTemplate:new.html.twig', $parameters ), 'success' => true, ]); }
[ "public", "function", "newAction", "(", "$", "id", ")", "{", "//get the business entity", "$", "businessEntity", "=", "$", "this", "->", "getBusinessEntity", "(", "$", "id", ")", ";", "/** @var BusinessTemplate $view */", "$", "view", "=", "$", "this", "->", "...
Displays a form to create a new BusinessTemplate entity. @param string $id The id of the businessEntity @throws \Exception @Route("/{id}/new", name="victoire_business_template_new") @Method("GET") @return JsonResponse The entity and the form
[ "Displays", "a", "form", "to", "create", "a", "new", "BusinessTemplate", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L178-L201
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.editAction
public function editAction(View $view) { $editForm = $this->createEditForm($view); $deleteForm = $this->createDeleteForm($view->getId()); $parameters = [ 'entity' => $view, 'form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ]; return new JsonResponse([ 'html' => $this->container->get('templating')->render( 'VictoireBusinessPageBundle:BusinessTemplate:edit.html.twig', $parameters ), 'success' => true, ]); }
php
public function editAction(View $view) { $editForm = $this->createEditForm($view); $deleteForm = $this->createDeleteForm($view->getId()); $parameters = [ 'entity' => $view, 'form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), ]; return new JsonResponse([ 'html' => $this->container->get('templating')->render( 'VictoireBusinessPageBundle:BusinessTemplate:edit.html.twig', $parameters ), 'success' => true, ]); }
[ "public", "function", "editAction", "(", "View", "$", "view", ")", "{", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "view", ")", ";", "$", "deleteForm", "=", "$", "this", "->", "createDeleteForm", "(", "$", "view", "->", "getId...
Displays a form to edit an existing BusinessTemplate entity. @Route("/{id}/edit", name="victoire_business_template_edit") @Method("GET") @ParamConverter("id", class="VictoireCoreBundle:View") @throws \Exception @return JsonResponse The entity and the form
[ "Displays", "a", "form", "to", "edit", "an", "existing", "BusinessTemplate", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L214-L232
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.createEditForm
private function createEditForm(BusinessTemplate $view) { $businessProperties = $this->getBusinessProperties($view); $form = $this->createForm(BusinessTemplateType::class, $view, [ 'action' => $this->generateUrl('victoire_business_template_update', ['id' => $view->getId()]), 'method' => 'PUT', 'vic_business_properties' => $businessProperties, ]); return $form; }
php
private function createEditForm(BusinessTemplate $view) { $businessProperties = $this->getBusinessProperties($view); $form = $this->createForm(BusinessTemplateType::class, $view, [ 'action' => $this->generateUrl('victoire_business_template_update', ['id' => $view->getId()]), 'method' => 'PUT', 'vic_business_properties' => $businessProperties, ]); return $form; }
[ "private", "function", "createEditForm", "(", "BusinessTemplate", "$", "view", ")", "{", "$", "businessProperties", "=", "$", "this", "->", "getBusinessProperties", "(", "$", "view", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "Business...
Creates a form to edit a BusinessTemplate entity. @param BusinessTemplate $view The entity @throws \Exception @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "BusinessTemplate", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L243-L254
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.updateAction
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); /** @var BusinessTemplate $pagePattern */ $pagePattern = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->find($id); if (!$pagePattern) { throw $this->createNotFoundException('Unable to find BusinessTemplate entity.'); } $editForm = $this->createEditForm($pagePattern); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); //redirect to the page of the template $completeUrl = $this->generateUrl('victoire_business_template_show', ['id' => $pagePattern->getId()]); $message = $this->get('translator')->trans('victoire.business_template.edit.success', [], 'victoire'); $success = true; } else { $success = false; $completeUrl = null; $message = $this->get('translator')->trans('victoire.business_template.edit.error', [], 'victoire'); } return new JsonResponse([ 'success' => $success, 'url' => $completeUrl, 'message' => $message, ]); }
php
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); /** @var BusinessTemplate $pagePattern */ $pagePattern = $em->getRepository('VictoireBusinessPageBundle:BusinessTemplate')->find($id); if (!$pagePattern) { throw $this->createNotFoundException('Unable to find BusinessTemplate entity.'); } $editForm = $this->createEditForm($pagePattern); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); //redirect to the page of the template $completeUrl = $this->generateUrl('victoire_business_template_show', ['id' => $pagePattern->getId()]); $message = $this->get('translator')->trans('victoire.business_template.edit.success', [], 'victoire'); $success = true; } else { $success = false; $completeUrl = null; $message = $this->get('translator')->trans('victoire.business_template.edit.error', [], 'victoire'); } return new JsonResponse([ 'success' => $success, 'url' => $completeUrl, 'message' => $message, ]); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "/** @var BusinessTemplate $pagePattern */", "$", "pagePattern", "=...
Edits an existing BusinessTemplate entity. @param Request $request @param string $id @Route("/{id}", name="victoire_business_template_update") @Method("PUT") @throws \Exception @return JsonResponse The parameter for the response
[ "Edits", "an", "existing", "BusinessTemplate", "entity", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L269-L302
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.listEntitiesAction
public function listEntitiesAction(BusinessTemplate $view) { //services $bepHelper = $this->get('victoire_business_page.business_page_helper'); //parameters for the view return $this->render('@VictoireBusinessPage/BusinessTemplate/listEntities.html.twig', [ 'BusinessTemplate' => $view, 'items' => $bepHelper->getEntitiesAllowed($view, $this->get('doctrine.orm.entity_manager')), ]); }
php
public function listEntitiesAction(BusinessTemplate $view) { //services $bepHelper = $this->get('victoire_business_page.business_page_helper'); //parameters for the view return $this->render('@VictoireBusinessPage/BusinessTemplate/listEntities.html.twig', [ 'BusinessTemplate' => $view, 'items' => $bepHelper->getEntitiesAllowed($view, $this->get('doctrine.orm.entity_manager')), ]); }
[ "public", "function", "listEntitiesAction", "(", "BusinessTemplate", "$", "view", ")", "{", "//services", "$", "bepHelper", "=", "$", "this", "->", "get", "(", "'victoire_business_page.business_page_helper'", ")", ";", "//parameters for the view", "return", "$", "this...
List the entities that matches the query of the BusinessTemplate. @param BusinessTemplate $view @Route("/listEntities/{id}", name="victoire_business_template_listentities") @ParamConverter("id", class="VictoireBusinessPageBundle:BusinessTemplate") @throws \Exception @return Response The list of items for this template
[ "List", "the", "entities", "that", "matches", "the", "query", "of", "the", "BusinessTemplate", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L365-L375
train
Victoire/victoire
Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php
BusinessTemplateController.getBusinessProperties
private function getBusinessProperties(BusinessTemplate $view) { $businessTemplateHelper = $this->get('victoire_business_page.business_page_helper'); //the business property link to the page $businessEntityId = $view->getBusinessEntityId(); $businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId); $businessProperties = $businessTemplateHelper->getBusinessProperties($businessEntity); return $businessProperties; }
php
private function getBusinessProperties(BusinessTemplate $view) { $businessTemplateHelper = $this->get('victoire_business_page.business_page_helper'); //the business property link to the page $businessEntityId = $view->getBusinessEntityId(); $businessEntity = $this->get('victoire_core.helper.business_entity_helper')->findById($businessEntityId); $businessProperties = $businessTemplateHelper->getBusinessProperties($businessEntity); return $businessProperties; }
[ "private", "function", "getBusinessProperties", "(", "BusinessTemplate", "$", "view", ")", "{", "$", "businessTemplateHelper", "=", "$", "this", "->", "get", "(", "'victoire_business_page.business_page_helper'", ")", ";", "//the business property link to the page", "$", "...
Get an array of business properties by the business entity page pattern. @param BusinessTemplate $view @throws \Exception @return array of business properties
[ "Get", "an", "array", "of", "business", "properties", "by", "the", "business", "entity", "page", "pattern", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Controller/BusinessTemplateController.php#L386-L396
train
Victoire/victoire
Bundle/CoreBundle/Annotations/BusinessProperty.php
BusinessProperty.getTypes
public function getTypes() { if (!array_key_exists('value', $this->types)) { return; } //return an array, no matter one or many types defined if (is_array($this->types['value']) && count($this->types['value']) > 1) { return $this->types['value']; } else { return [$this->types['value']]; } }
php
public function getTypes() { if (!array_key_exists('value', $this->types)) { return; } //return an array, no matter one or many types defined if (is_array($this->types['value']) && count($this->types['value']) > 1) { return $this->types['value']; } else { return [$this->types['value']]; } }
[ "public", "function", "getTypes", "(", ")", "{", "if", "(", "!", "array_key_exists", "(", "'value'", ",", "$", "this", "->", "types", ")", ")", "{", "return", ";", "}", "//return an array, no matter one or many types defined", "if", "(", "is_array", "(", "$", ...
Get types. @return null|multitype:NULL
[ "Get", "types", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/CoreBundle/Annotations/BusinessProperty.php#L29-L41
train
Victoire/victoire
Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php
BusinessPageHelper.isEntityAllowed
public function isEntityAllowed(BusinessTemplate $businessTemplate, $entity, EntityManager $em = null) { $allowed = true; //test that an entity is given if ($entity === null) { throw new \Exception('The entity is required.'); } $queryHelper = $this->queryHelper; //the page id $entityId = $entity->getId(); //the base of the query $baseQuery = $queryHelper->getQueryBuilder($businessTemplate, $em); $baseQuery->andWhere('main_item.id = '.$entityId); //filter with the query of the page $items = $queryHelper->buildWithSubQuery($businessTemplate, $baseQuery, $em) ->getQuery()->getResult(); //only one page can be found because we filter on the if (count($items) > 1) { throw new \Exception('More than 1 item was found, there should not be more than 1 item with this query.'); } if (count($items) === 0) { $allowed = false; } return $allowed; }
php
public function isEntityAllowed(BusinessTemplate $businessTemplate, $entity, EntityManager $em = null) { $allowed = true; //test that an entity is given if ($entity === null) { throw new \Exception('The entity is required.'); } $queryHelper = $this->queryHelper; //the page id $entityId = $entity->getId(); //the base of the query $baseQuery = $queryHelper->getQueryBuilder($businessTemplate, $em); $baseQuery->andWhere('main_item.id = '.$entityId); //filter with the query of the page $items = $queryHelper->buildWithSubQuery($businessTemplate, $baseQuery, $em) ->getQuery()->getResult(); //only one page can be found because we filter on the if (count($items) > 1) { throw new \Exception('More than 1 item was found, there should not be more than 1 item with this query.'); } if (count($items) === 0) { $allowed = false; } return $allowed; }
[ "public", "function", "isEntityAllowed", "(", "BusinessTemplate", "$", "businessTemplate", ",", "$", "entity", ",", "EntityManager", "$", "em", "=", "null", ")", "{", "$", "allowed", "=", "true", ";", "//test that an entity is given", "if", "(", "$", "entity", ...
Is the entity allowed for the business entity page. @param BusinessTemplate $businessTemplate @param object|null $entity @param EntityManager $em @throws \Exception @return bool
[ "Is", "the", "entity", "allowed", "for", "the", "business", "entity", "page", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php#L57-L90
train
Victoire/victoire
Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php
BusinessPageHelper.getIdentifierPositionInUrl
public function getIdentifierPositionInUrl(BusinessTemplate $businessTemplate) { $position = null; $url = $businessTemplate->getUrl(); // split on the / character $keywords = preg_split("/\//", $url); // preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches); //the business property link to the page $businessEntityId = $businessTemplate->getBusinessEntityId(); $businessEntity = $this->businessEntityHelper->findById($businessEntityId); //the business properties usable in a url $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter'); //we parse the words of the url foreach ($keywords as $index => $keyword) { foreach ($businessProperties as $businessProperty) { $entityProperty = $businessProperty->getEntityProperty(); $searchWord = '{{item.'.$entityProperty.'}}'; if ($searchWord === $keyword) { //the array start at index 0 but we want the position to start at 1 $position = [ 'position' => $index + 1, 'businessProperty' => $businessProperty, ]; } } } return $position; }
php
public function getIdentifierPositionInUrl(BusinessTemplate $businessTemplate) { $position = null; $url = $businessTemplate->getUrl(); // split on the / character $keywords = preg_split("/\//", $url); // preg_match_all('/\{\%\s*([^\%\}]*)\s*\%\}|\{\{\s*([^\}\}]*)\s*\}\}/i', $url, $matches); //the business property link to the page $businessEntityId = $businessTemplate->getBusinessEntityId(); $businessEntity = $this->businessEntityHelper->findById($businessEntityId); //the business properties usable in a url $businessProperties = $businessEntity->getBusinessPropertiesByType('businessParameter'); //we parse the words of the url foreach ($keywords as $index => $keyword) { foreach ($businessProperties as $businessProperty) { $entityProperty = $businessProperty->getEntityProperty(); $searchWord = '{{item.'.$entityProperty.'}}'; if ($searchWord === $keyword) { //the array start at index 0 but we want the position to start at 1 $position = [ 'position' => $index + 1, 'businessProperty' => $businessProperty, ]; } } } return $position; }
[ "public", "function", "getIdentifierPositionInUrl", "(", "BusinessTemplate", "$", "businessTemplate", ")", "{", "$", "position", "=", "null", ";", "$", "url", "=", "$", "businessTemplate", "->", "getUrl", "(", ")", ";", "// split on the / character", "$", "keyword...
Get the position of the identifier in the url of a business entity page pattern. @param BusinessTemplate $businessTemplate @return int The position
[ "Get", "the", "position", "of", "the", "identifier", "in", "the", "url", "of", "a", "business", "entity", "page", "pattern", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php#L158-L193
train
Victoire/victoire
Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php
BusinessPageHelper.guessBestPatternIdForEntity
public function guessBestPatternIdForEntity($refClass, $entityId, $em, $originalRefClassName = null) { $templateId = null; $refClassName = $em->getClassMetadata($refClass->name)->name; $viewReference = null; if (!$originalRefClassName) { $originalRefClassName = $refClassName; } $businessEntity = $this->businessEntityHelper->findByEntityClassname($refClassName); if ($businessEntity) { $parameters = [ 'entityId' => $entityId, 'entityNamespace' => $originalRefClassName, ]; $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters); } if (!$viewReference) { $parentRefClass = $refClass->getParentClass(); if ($parentRefClass) { $templateId = $this->guessBestPatternIdForEntity($parentRefClass, $entityId, $em, $originalRefClassName); } else { throw new \Exception(sprintf('Cannot find a BusinessTemplate that can display the requested BusinessEntity ("%s", "%s".)', $refClassName, $entityId)); } } elseif ($viewReference instanceof BusinessPageReference) { $templateId = $viewReference->getTemplateId(); } return $templateId; }
php
public function guessBestPatternIdForEntity($refClass, $entityId, $em, $originalRefClassName = null) { $templateId = null; $refClassName = $em->getClassMetadata($refClass->name)->name; $viewReference = null; if (!$originalRefClassName) { $originalRefClassName = $refClassName; } $businessEntity = $this->businessEntityHelper->findByEntityClassname($refClassName); if ($businessEntity) { $parameters = [ 'entityId' => $entityId, 'entityNamespace' => $originalRefClassName, ]; $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters); } if (!$viewReference) { $parentRefClass = $refClass->getParentClass(); if ($parentRefClass) { $templateId = $this->guessBestPatternIdForEntity($parentRefClass, $entityId, $em, $originalRefClassName); } else { throw new \Exception(sprintf('Cannot find a BusinessTemplate that can display the requested BusinessEntity ("%s", "%s".)', $refClassName, $entityId)); } } elseif ($viewReference instanceof BusinessPageReference) { $templateId = $viewReference->getTemplateId(); } return $templateId; }
[ "public", "function", "guessBestPatternIdForEntity", "(", "$", "refClass", ",", "$", "entityId", ",", "$", "em", ",", "$", "originalRefClassName", "=", "null", ")", "{", "$", "templateId", "=", "null", ";", "$", "refClassName", "=", "$", "em", "->", "getCl...
Guess the best pattern to represent given reflectionClass. @param \ReflectionClass $refClass @param int $entityId @param EntityManager $em @param string $originalRefClassName When digging into parentClass, we do not have to forget originalClass to be able to get reference after all @throws \Exception @return View
[ "Guess", "the", "best", "pattern", "to", "represent", "given", "reflectionClass", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/BusinessPageBundle/Helper/BusinessPageHelper.php#L207-L239
train
Victoire/victoire
Bundle/WidgetMapBundle/Resolver/WidgetMapChildrenResolver.php
WidgetMapChildrenResolver.getChildren
public function getChildren(WidgetMap $widgetMap, View $view = null) { $positions = [WidgetMap::POSITION_BEFORE, WidgetMap::POSITION_AFTER]; $children = []; foreach ($positions as $position) { $matchingChildren = []; //Position is null by default $children[$position] = null; //Pass through all current WidgetMap children for a given position foreach ($widgetMap->getContextualChildren($position) as $_child) { //If child don't have a substitute for this View and Templates, this is the one if (null === $_child->getSubstituteForView($view)) { $children[$position] = $_child; $matchingChildren[] = $_child->getId(); } } //If children has not been found for this position //and current WidgetMap is a substitute if (!$children[$position] && $widgetMap->getReplaced()) { //Pass through all replaced WidgetMap children for a given position foreach ($widgetMap->getReplaced()->getContextualChildren($position) as $_child) { //If child don't have a substitute for this View and Templates, this is the one if (null === $_child->getSubstituteForView($view)) { $children[$position] = $_child; $matchingChildren[] = $_child->getId(); } } } $matchingChildren = array_unique($matchingChildren); if (count($matchingChildren) > 1) { $this->logger->critical(sprintf( 'Conflict found between WidgetMaps %s for View %s', implode(', ', $matchingChildren), $view->getId() )); } } return $children; }
php
public function getChildren(WidgetMap $widgetMap, View $view = null) { $positions = [WidgetMap::POSITION_BEFORE, WidgetMap::POSITION_AFTER]; $children = []; foreach ($positions as $position) { $matchingChildren = []; //Position is null by default $children[$position] = null; //Pass through all current WidgetMap children for a given position foreach ($widgetMap->getContextualChildren($position) as $_child) { //If child don't have a substitute for this View and Templates, this is the one if (null === $_child->getSubstituteForView($view)) { $children[$position] = $_child; $matchingChildren[] = $_child->getId(); } } //If children has not been found for this position //and current WidgetMap is a substitute if (!$children[$position] && $widgetMap->getReplaced()) { //Pass through all replaced WidgetMap children for a given position foreach ($widgetMap->getReplaced()->getContextualChildren($position) as $_child) { //If child don't have a substitute for this View and Templates, this is the one if (null === $_child->getSubstituteForView($view)) { $children[$position] = $_child; $matchingChildren[] = $_child->getId(); } } } $matchingChildren = array_unique($matchingChildren); if (count($matchingChildren) > 1) { $this->logger->critical(sprintf( 'Conflict found between WidgetMaps %s for View %s', implode(', ', $matchingChildren), $view->getId() )); } } return $children; }
[ "public", "function", "getChildren", "(", "WidgetMap", "$", "widgetMap", ",", "View", "$", "view", "=", "null", ")", "{", "$", "positions", "=", "[", "WidgetMap", "::", "POSITION_BEFORE", ",", "WidgetMap", "::", "POSITION_AFTER", "]", ";", "$", "children", ...
Return "after" and "before" children, based on contextual View and its Templates. @return array
[ "Return", "after", "and", "before", "children", "based", "on", "contextual", "View", "and", "its", "Templates", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/WidgetMapBundle/Resolver/WidgetMapChildrenResolver.php#L29-L72
train
Victoire/victoire
Bundle/TemplateBundle/Listener/TemplateMenuListener.php
TemplateMenuListener.addGlobal
public function addGlobal(Event $event) { $menuTemplate = $this->menuBuilder->getBottomRightNavbar()->getChild('menu.template'); $menuTemplate->addChild('menu.template.new', [ 'route' => 'victoire_template_new', 'linkAttributes' => [ 'class' => 'v-drop__anchor', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); $menuTemplate->addChild('menu.template.index', [ 'route' => 'victoire_template_index', 'linkAttributes' => [ 'class' => 'v-drop__anchor', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); }
php
public function addGlobal(Event $event) { $menuTemplate = $this->menuBuilder->getBottomRightNavbar()->getChild('menu.template'); $menuTemplate->addChild('menu.template.new', [ 'route' => 'victoire_template_new', 'linkAttributes' => [ 'class' => 'v-drop__anchor', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); $menuTemplate->addChild('menu.template.index', [ 'route' => 'victoire_template_index', 'linkAttributes' => [ 'class' => 'v-drop__anchor', ], ])->setLinkAttribute('data-toggle', 'vic-modal'); }
[ "public", "function", "addGlobal", "(", "Event", "$", "event", ")", "{", "$", "menuTemplate", "=", "$", "this", "->", "menuBuilder", "->", "getBottomRightNavbar", "(", ")", "->", "getChild", "(", "'menu.template'", ")", ";", "$", "menuTemplate", "->", "addCh...
add a global menu item. @param Event $event @return \Knp\Menu\ItemInterface <\Knp\Menu\ItemInterface, NULL>
[ "add", "a", "global", "menu", "item", "." ]
53c314c578dcf92adfb6538b27dbc7a2ec16f432
https://github.com/Victoire/victoire/blob/53c314c578dcf92adfb6538b27dbc7a2ec16f432/Bundle/TemplateBundle/Listener/TemplateMenuListener.php#L56-L73
train