idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
27,500 | public function removeCssFile ( $ hash ) { $ file = $ this -> getViewCssFileFromHash ( $ hash ) ; if ( file_exists ( $ file ) ) { unlink ( $ file ) ; } } | Remove css file . |
27,501 | 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 ) ; } } } | Remove all views css files . |
27,502 | public function cssFileExists ( View $ view ) { $ file = $ this -> getViewCssFileFromHash ( $ view -> getCssHash ( ) ) ; return file_exists ( $ file ) ; } | Tell if css file exists for a given View . |
27,503 | 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 ) ; } | Write css file . |
27,504 | 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 ] ; $ 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 , ] ) , ] ; } | new widget . |
27,505 | public function createWidget ( $ mode , $ type , $ slotId , View $ view , $ entity , $ position , $ widgetReference , $ quantum ) { $ formErrorHelper = $ this -> formErrorHelper ; $ request = $ this -> getRequest ( ) ; if ( $ view instanceof VirtualBusinessPage ) { $ this -> virtualToBpTransformer -> transform ( $ view ) ; } $ 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 ( ) ) { $ this -> entityManager -> persist ( $ view ) ; } $ widget = $ form -> getData ( ) ; $ widget -> setBusinessEntityId ( $ entity ) ; $ 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 ) ; $ htmlWidget = $ this -> widgetRenderer -> renderContainer ( $ widget , $ view ) ; $ response = [ 'success' => true , 'widgetId' => $ widget -> getId ( ) , 'html' => $ htmlWidget , ] ; } else { $ response = [ 'success' => false , 'message' => $ noValidate === false ? $ formErrorHelper -> getRecursiveReadableErrors ( $ form ) : null , 'html' => $ this -> widgetFormBuilder -> renderNewForm ( $ form , $ widget , $ slotId , $ view , $ quantum , $ entity ) , ] ; } return $ response ; } | Create a widget . |
27,506 | 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 ( ) ) { 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 ) ; } | Edit widget style . |
27,507 | public function deleteWidget ( Widget $ widget , View $ view ) { $ this -> widgetMapBuilder -> build ( $ view ) ; $ widgetMap = $ widget -> getWidgetMap ( ) ; if ( $ widgetMap -> getView ( ) == $ view && $ widgetMap -> getAction ( ) != WidgetMap :: ACTION_DELETE ) { $ this -> entityManager -> remove ( $ widget ) ; } $ this -> widgetMapManager -> delete ( $ view , $ widget ) ; $ this -> entityManager -> persist ( $ view ) ; $ this -> entityManager -> flush ( ) ; } | Remove a widget . |
27,508 | public function overwriteWidget ( View $ view , Widget $ widget ) { $ widgetCopy = $ this -> cloneEntity ( $ widget ) ; $ originalWidgetMap = $ widget -> getWidgetMap ( ) ; $ this -> widgetMapManager -> overwrite ( $ view , $ originalWidgetMap , $ widgetCopy ) ; return $ widgetCopy ; } | Overwrite the widget for the current view because the widget is not linked to the current view a copy is created . |
27,509 | public function getWidgetContent ( Widget $ widget ) { $ mode = $ widget -> getMode ( ) ; 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 : $ parameters = $ resolver -> getWidgetEntityContent ( $ widget ) ; break ; case Widget :: MODE_BUSINESS_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 ; } | Get content for the widget . |
27,510 | public function hasMultipleBlog ( ) { $ queryBuilder = $ this -> createQueryBuilder ( 'blog' ) -> select ( 'b_translation.id' ) -> join ( 'blog.translations' , 'b_translation' ) ; return count ( $ queryBuilder -> getQuery ( ) -> getResult ( ) ) >= 1 ; } | Return true if at least one Blog has multiple translations . |
27,511 | 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 ; } | Get all locales used by Blogs . |
27,512 | public function getBlogsForLocale ( $ locale ) { $ blogs = $ this -> joinTranslations ( $ locale ) -> getInstance ( ) -> getQuery ( ) -> getResult ( ) ; $ this -> clearInstance ( ) ; return $ blogs ; } | Get all Blogs for a given locale . |
27,513 | 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 ; } | Add a global menu item . |
27,514 | public function addContextual ( $ event ) { $ bottomRightNavbar = $ this -> menuBuilder -> getBottomRightNavbar ( ) ; $ 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' ) ; } | Add the parent menu for a page that extends another one . |
27,515 | public function indexAction ( Request $ request , $ blog = null , $ tab = 'articles' ) { $ blogRepo = $ this -> get ( 'doctrine.orm.entity_manager' ) -> getRepository ( 'VictoireBlogBundle:Blog' ) ; $ locale = $ request -> getLocale ( ) ; 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 ) ; } | List all Blogs . |
27,516 | public function feedAction ( Request $ request , Blog $ blog ) { $ articles = $ blog -> getPublishedArticles ( ) ; if ( $ categoryId = $ request -> query -> get ( 'category' ) ) { $ entityManager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ 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 ) { return $ article -> getCategory ( ) && in_array ( $ article -> getCategory ( ) -> getId ( ) , $ categoryIds , true ) ; } ) ; } return $ this -> render ( 'VictoireBlogBundle:Blog:feed.rss.twig' , [ 'blog' => $ blog , 'articles' => $ articles , ] ) ; } | Display Blogs RSS feed . |
27,517 | 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 , ] ) ) ; } | Display a form to edit Blog settings . |
27,518 | 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 ( ) ] ) , ] ) ; } $ 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 , ] ) ) ; } | List Blog Categories . |
27,519 | 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 , ] ) ) ; } | List Blog articles . |
27,520 | 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 ) ) ; } | Delete a Blog . |
27,521 | protected function getBlog ( Request $ request , $ blogId ) { $ 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 ; } | Get Blog from id if defined . If not return the first Blog . |
27,522 | public function setProxy ( \ Victoire \ Bundle \ CoreBundle \ Entity \ EntityProxy $ proxy = null ) { $ this -> proxy = $ proxy ; return $ this ; } | Set proxy . |
27,523 | public function getEntityAttributeValue ( $ field ) { if ( $ field ) { $ functionName = 'get' . ucfirst ( $ field ) ; if ( ! method_exists ( $ this , $ functionName ) ) { return ; } $ fieldValue = $ this -> { $ functionName } ( ) ; } else { $ fieldValue = null ; } return $ fieldValue ; } | Get the content of an attribute of the current entity . |
27,524 | public function getAvailableLocales ( ) { $ availableLocales = [ ] ; $ translations = $ this -> getTranslations ( ) ; foreach ( $ translations as $ translation ) { $ availableLocales [ ] = $ translation -> getLocale ( ) ; } return $ availableLocales ; } | Get available locales for Articles from this Blog . |
27,525 | public function setCategories ( $ categories ) { foreach ( $ categories as $ category ) { $ category -> setBlog ( $ this ) ; } $ this -> categories = $ categories ; return $ this ; } | Set categories . |
27,526 | public function getRootCategories ( ) { $ rootCategories = [ ] ; foreach ( $ this -> categories as $ categories ) { if ( $ categories -> getLvl ( ) == 0 ) { $ rootCategories [ ] = $ categories ; } } return $ rootCategories ; } | Get root categories . |
27,527 | 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 ; } | Get the most recent route by url . |
27,528 | public function getViewId ( ) { $ viewId = null ; $ widgetMap = $ this -> getWidgetMap ( ) ; if ( $ widgetMap !== null && $ view = $ widgetMap -> getView ( ) !== null ) { $ viewId = $ view -> getId ( ) ; } return $ viewId ; } | Get the view id . |
27,529 | public function getEntity ( ) { if ( $ this -> entity === null ) { $ entityProxy = $ this -> getEntityProxy ( ) ; if ( $ entityProxy !== null && $ this -> getBusinessEntityId ( ) ) { $ entity = $ entityProxy -> getEntity ( $ this -> getBusinessEntityId ( ) ) ; $ this -> entity = $ entity ; } } return $ this -> entity ; } | Get the entity . |
27,530 | 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 ( ) ) ; } | Generate the CacheId insert params that can invalid the cache . |
27,531 | 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 ) { $ 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 ; } | Cleans up the text and adds separator and keep twig variable . |
27,532 | public function getChildren ( ) { if ( is_null ( $ this -> children ) ) { $ this -> children = $ this -> menu -> getChildren ( $ this ) ; } return $ this -> children ; } | Get children of current menu item . |
27,533 | public function getNavigationChildren ( ) { $ result = [ ] ; $ children = $ this -> getChildren ( ) ; foreach ( $ children as $ child ) { if ( $ child -> getAppearInNavigation ( ) ) { $ result [ ] = $ child ; } } return $ result ; } | Get children of current menu item that have the appearInNavigation flag set . |
27,534 | public function getTopChildren ( ) { $ result = [ ] ; $ children = $ this -> getChildren ( ) ; foreach ( $ children as $ child ) { if ( $ child instanceof TopMenuItem ) { $ result [ ] = $ child ; } } return $ result ; } | Return top children of current menu item . |
27,535 | public function editAction ( Request $ request ) { $ entityManager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ 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 ( ) ) { $ 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 , ] ) ; } | Method used to edit global config . |
27,536 | public function onKernelRequest ( GetResponseEvent $ event ) { if ( $ this -> tokenStorage -> getToken ( ) && $ this -> authorizationChecker -> isGranted ( 'ROLE_VICTOIRE' ) ) { $ this -> eventDispatcher -> dispatch ( 'victoire_core.build_menu' , $ event ) ; } } | Dispatch event to build the Victoire s global menu items . |
27,537 | 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 ( ) ; foreach ( array_merge ( $ updatedEntities , $ deletedEntities ) as $ entity ) { if ( ! ( $ entity instanceof Widget ) ) { continue ; } $ widgetMap = $ entity -> getWidgetMap ( ) ; if ( $ widgetMap -> getAction ( ) !== WidgetMap :: ACTION_DELETE ) { $ view = $ widgetMap -> getView ( ) ; if ( $ this -> em -> contains ( $ view ) ) { $ this -> updateViewCss ( $ view ) ; $ this -> setTemplateInheritorsCssToUpdate ( $ view ) ; } } } foreach ( $ deletedEntities as $ entity ) { if ( ! ( $ entity instanceof View ) ) { continue ; } $ this -> viewCssBuilder -> removeCssFile ( $ entity -> getCssHash ( ) ) ; $ this -> setTemplateInheritorsCssToUpdate ( $ entity ) ; } foreach ( $ updatedEntities as $ entity ) { if ( ! ( $ entity instanceof View ) ) { continue ; } $ this -> updateViewCss ( $ entity ) ; $ this -> setTemplateInheritorsCssToUpdate ( $ entity ) ; } $ this -> uow -> computeChangeSets ( ) ; } | Change cssHash of views when a widget is updated or deleted . |
27,538 | public function updateViewCss ( View $ view ) { $ view -> changeCssHash ( ) ; $ this -> widgetMapBuilder -> build ( $ view , true ) ; $ widgets = $ this -> widgetRepo -> findAllWidgetsForView ( $ view ) ; $ oldHash = $ view -> getCssHash ( ) ; $ view -> changeCssHash ( ) ; $ this -> viewCssBuilder -> updateViewCss ( $ oldHash , $ view , $ widgets ) ; $ view -> setCssUpToDate ( true ) ; $ metadata = $ this -> em -> getClassMetadata ( get_class ( $ view ) ) ; $ this -> uow -> recomputeSingleEntityChangeSet ( $ metadata , $ view ) ; } | Change view cssHash update css file and persist new cssHash . |
27,539 | 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' ) ; } | add a blog contextual menu item . |
27,540 | 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 ; } | Find the business entity page pattern that looks like this url . |
27,541 | public function onLogin ( InteractiveLoginEvent $ event ) { $ user = $ event -> getAuthenticationToken ( ) -> getUser ( ) ; if ( $ user instanceof VictoireUserInterface ) { $ event -> getRequest ( ) -> getSession ( ) -> set ( 'victoire_locale' , $ user -> getLocale ( ) ) ; } } | This method will be called on user login in order to set the victoire locale . |
27,542 | public function saveReferences ( array $ viewReferences , $ parentId = null , $ parentLocale = null , $ reset = true ) { if ( $ reset ) { $ this -> manager -> reset ( ) ; } foreach ( $ viewReferences as $ viewReference ) { $ view = $ viewReference [ 'view' ] ; foreach ( $ view -> getReferences ( ) as $ locale => $ reference ) { if ( $ reference !== null ) { $ id = $ this -> saveReference ( $ reference , $ parentId , $ parentLocale ) ; if ( array_key_exists ( 'children' , $ viewReference ) && ! empty ( $ children = $ viewReference [ 'children' ] ) ) { $ this -> saveReferences ( $ children , $ id , $ reference -> getLocale ( ) , false ) ; } } } } } | This method save a tree of viewReferences . |
27,543 | public function saveReference ( ViewReference $ viewReference , $ parentId = null , $ parentLocale = null ) { $ arrayTransformer = $ this -> transformer -> getViewReferenceTransformer ( $ viewReference -> getViewNamespace ( ) , 'array' ) ; $ referenceArray = $ arrayTransformer -> reverseTransform ( $ viewReference ) ; $ this -> removeUrlForViewReference ( $ viewReference ) ; $ this -> manager -> update ( $ referenceArray [ 'id' ] , $ referenceArray ) ; $ this -> manager -> buildUrl ( $ viewReference -> getId ( ) ) ; if ( $ parentId && $ parentLocale === $ viewReference -> getLocale ( ) ) { $ this -> manager -> addChild ( $ parentId , $ referenceArray [ 'id' ] ) ; } return $ referenceArray [ 'id' ] ; } | This method save a Reference . |
27,544 | public function removeReference ( ViewReference $ viewReference ) { $ referenceId = $ viewReference -> getId ( ) ; if ( $ url = $ this -> repository -> findValueForId ( 'url' , $ referenceId ) ) { $ this -> manager -> removeUrl ( $ url , $ viewReference -> getLocale ( ) ) ; } $ this -> manager -> remove ( $ referenceId ) ; } | This method remove reference for a ViewReference . |
27,545 | public function removeUrlForViewReference ( ViewReference $ viewReference ) { $ id = $ viewReference -> getId ( ) ; if ( $ url = $ this -> repository -> findValueForId ( 'url' , $ id ) ) { $ this -> manager -> removeUrl ( $ url , $ this -> repository -> findValueForId ( 'locale' , $ id ) ) ; } } | Remove an url for a viewReference with his reference in redis . |
27,546 | 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 ( ) ; } | Reorder pages positions . |
27,547 | 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 . '"]' , ] , ] ) ) ; } | By default set data - target to root Form . |
27,548 | 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 ; } } | Add the types related to the LinkType value . |
27,549 | 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' ) ; } } | Add the types related to the target value . |
27,550 | 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' ] , ] ) ; } } | add the target Field . |
27,551 | 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 ) ; } | Get the array of slugs of the parents . |
27,552 | protected function fetch ( $ key ) { $ results = $ this -> cache -> get ( $ key , null ) ; if ( ! $ results ) { foreach ( $ this -> driver -> getAllClassNames ( ) as $ className ) { $ this -> driver -> parse ( new \ ReflectionClass ( $ className ) ) ; } $ results = $ this -> cache -> get ( $ key , [ ] ) ; } return $ results ; } | Fetch in Cache system and try to reparse Annotation if no results . |
27,553 | 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 ; } | This method build widgetmaps relativly to given view and it s templates . |
27,554 | 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 ( ) ; } } 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 ; } | This method takes the builtWidgetMap for view and creates an array that indicate for each widgetmap if the position after and before are available . |
27,555 | protected function orderizeWidgetMap ( WidgetMap $ currentWidgetMap , $ builtWidgetMap , $ slot , $ slotWidgetMaps , View $ view ) { $ children = $ this -> resolver -> getChildren ( $ currentWidgetMap , $ view ) ; foreach ( $ children as $ child ) { if ( in_array ( $ child , $ slotWidgetMaps , true ) ) { $ offset = array_search ( $ currentWidgetMap , $ builtWidgetMap [ $ slot ] ) + ( $ child -> getPosition ( ) == WidgetMap :: POSITION_AFTER ? 1 : 0 ) ; array_splice ( $ builtWidgetMap [ $ slot ] , $ offset , 0 , [ $ child ] ) ; $ builtWidgetMap = $ this -> orderizeWidgetMap ( $ child , $ builtWidgetMap , $ slot , $ slotWidgetMaps , $ view ) ; } } return $ builtWidgetMap ; } | 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 . |
27,556 | protected function removeDeletedWidgetMaps ( & $ slots ) { foreach ( $ slots as $ slot => $ widgetMaps ) { foreach ( $ widgetMaps as $ key => $ widgetMap ) { if ( $ widgetMap -> getAction ( ) == WidgetMap :: ACTION_DELETE ) { unset ( $ slots [ $ slot ] [ $ key ] ) ; } } } } | If delete widgetmaps are found remove it because they re not rendered . |
27,557 | public function addPage ( BasePage $ page ) { $ page -> setTemplate ( $ this ) ; $ this -> pages [ ] = $ page ; return $ this ; } | add page . |
27,558 | public function handle ( $ locale ) { $ homepage = $ this -> entityManager -> getRepository ( Page :: class ) -> findOneByHomepage ( $ locale ) ; $ 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 ( ) ; 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 ; } | Get the whole list of published pages for a given locale . |
27,559 | private function getBusinessPages ( ViewReference $ tree , $ businessPages = [ ] ) { foreach ( $ tree -> getChildren ( ) as $ child ) { if ( $ child instanceof BusinessPageReference && $ child -> getViewNamespace ( ) === VirtualBusinessPage :: class ) { $ businessPage = $ this -> pageHelper -> findPageByReference ( $ child ) ; if ( $ businessPage -> isPublished ( ) ) { $ businessPage -> setReference ( $ child ) ; $ businessPages [ ] = $ businessPage ; } } $ businessPages = $ this -> getBusinessPages ( $ child , $ businessPages ) ; } return $ businessPages ; } | Get all VirtualBusinessPage recursively . |
27,560 | 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 ( 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 ; } | Generates a response from parameters . |
27,561 | 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 { $ error404 = $ this -> entityManager -> getRepository ( 'VictoireSeoBundle:Error404' ) -> findOneBy ( [ 'url' => $ uri ] ) ; $ 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 ) ) ; } } | Generates a response from a page url . If seo redirect return target . |
27,562 | public function renderPage ( $ view , $ layout = null ) { $ event = new PageMenuContextualEvent ( $ view ) ; $ pageRenderEvent = new PageRenderEvent ( $ view ) ; $ this -> eventDispatcher -> dispatch ( 'victoire.on_render_page' , $ pageRenderEvent ) ; $ this -> currentViewHelper -> setCurrentView ( $ view ) ; $ this -> widgetMapBuilder -> build ( $ view , true ) ; $ this -> widgetDataWarmer -> warm ( $ this -> entityManager , $ view ) ; if ( in_array ( $ view -> getType ( ) , [ 'business_page' , 'virtual_business_page' ] ) ) { $ 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 ) { $ layout = $ this -> guessBestLayoutForView ( $ view ) ; } $ globalConfig = $ this -> entityManager -> getRepository ( GlobalConfig :: class ) -> findLast ( ) ? : new GlobalConfig ( ) ; $ 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 ; } | Generates a response from a page . |
27,563 | public function updatePageWithEntity ( BusinessTemplate $ page , $ entity ) { $ page = $ this -> businessPageBuilder -> generateEntityPageFromTemplate ( $ page , $ entity , $ this -> entityManager ) ; $ this -> pageSeoHelper -> updateSeoByEntity ( $ page , $ entity ) ; $ this -> businessPageBuilder -> updatePageParametersByEntity ( $ page , $ entity ) ; return $ page ; } | Populate the page with given entity . |
27,564 | public function findPageByReference ( $ viewReference ) { $ page = null ; if ( $ viewReference instanceof BusinessPageReference ) { if ( $ viewReference -> getViewId ( ) ) { $ page = $ this -> entityManager -> getRepository ( 'VictoireCoreBundle:View' ) -> findOneBy ( [ 'id' => $ viewReference -> getViewId ( ) , ] ) ; $ page -> setCurrentLocale ( $ viewReference -> getLocale ( ) ) ; } else { $ 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 ; } | find the page according to given url . |
27,565 | public function createPageInstanceFromBusinessTemplate ( BusinessTemplate $ BusinessTemplate , $ entity , $ url ) { $ newPage = new Page ( ) ; $ parentPage = $ BusinessTemplate -> getParent ( ) ; $ newPage -> setParent ( $ parentPage ) ; $ newPage -> setTemplate ( $ BusinessTemplate ) ; $ newPage -> setUrl ( $ url ) ; $ newPage -> setTitle ( $ BusinessTemplate -> getTitle ( ) ) ; $ this -> businessPageBuilder -> updatePageParametersByEntity ( $ newPage , $ entity ) ; $ businessEntity = $ this -> businessEntityHelper -> findByEntityInstance ( $ entity ) ; $ entityProxy = new EntityProxy ( ) ; $ entityProxy -> setEntity ( $ entity , $ businessEntity -> getName ( ) ) ; $ newPage -> setEntityProxy ( $ entityProxy ) ; return $ newPage ; } | Create an instance of the business entity page . |
27,566 | private function guessBestLayoutForView ( View $ view ) { if ( method_exists ( $ view , 'getLayout' ) && $ view -> getLayout ( ) ) { $ viewLayout = $ view -> getLayout ( ) ; } else { $ viewLayout = $ view -> getTemplate ( ) -> getLayout ( ) ; } return $ viewLayout ; } | Guess which layout to use for a given View . |
27,567 | public function setPosition ( BasePage $ page ) { if ( $ page -> getParent ( ) ) { $ pageNb = count ( $ page -> getParent ( ) -> getChildren ( ) ) ; } else { $ pageNb = count ( $ this -> entityManager -> getRepository ( 'VictoirePageBundle:BasePage' ) -> findByParent ( null ) ) ; } $ page -> setPosition ( $ pageNb + 1 ) ; return $ page ; } | Set Page position . |
27,568 | public function create ( Article $ article , User $ author ) { $ article -> setAuthor ( $ author ) ; $ tags = $ article -> getTags ( ) ; if ( is_array ( $ tags ) ) { foreach ( $ tags as $ tag ) { $ tag -> setBlog ( $ article -> getBlog ( ) ) ; $ this -> entityManager -> persist ( $ tag ) ; } } $ this -> entityManager -> persist ( $ article ) ; $ this -> entityManager -> flush ( ) ; $ page = $ this -> businessPageBuilder -> generateEntityPageFromTemplate ( $ article -> getTemplate ( ) , $ article , $ this -> entityManager ) ; $ this -> virtualToBusinessPageTransformer -> transform ( $ page ) ; $ page -> setParent ( $ article -> getBlog ( ) ) ; $ page -> setStatus ( $ article -> getStatus ( ) ) ; $ this -> entityManager -> persist ( $ page ) ; $ this -> entityManager -> flush ( ) ; return $ page ; } | Create Article with its author tags . Create BusinessPage for this Article . |
27,569 | public function updateSettings ( Article $ article ) { $ tags = $ article -> getTags ( ) ; if ( is_array ( $ tags ) ) { foreach ( $ tags as $ tag ) { $ tag -> setBlog ( $ article -> getBlog ( ) ) ; $ this -> entityManager -> persist ( $ tag ) ; } } $ businessPage = $ this -> pageHelper -> findPageByParameters ( [ 'viewId' => $ article -> getTemplate ( ) -> getId ( ) , 'entityId' => $ article -> getId ( ) , ] ) ; $ template = $ article -> getTemplate ( ) ; $ businessPage -> setTemplate ( $ template ) ; $ 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 ( ) ; $ viewReference = $ this -> viewReferenceRepo -> getOneReferenceByParameters ( [ 'viewId' => $ page -> getId ( ) ] ) ; $ page -> setReference ( $ viewReference ) ; return $ page ; } | Update Blog Article settings . |
27,570 | 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 ( ) ; } | Delete a given Article . |
27,571 | public function getBusinessProperties ( BusinessEntity $ businessEntity ) { $ businessProperties = $ businessEntity -> getBusinessPropertiesByType ( 'businessParameter' ) ; $ seoBusinessProps = $ businessEntity -> getBusinessPropertiesByType ( 'seoable' ) ; $ businessProperties = array_merge ( $ businessProperties , $ seoBusinessProps ) ; return $ businessProperties ; } | Get the list of business properties usable for the url . |
27,572 | protected function getEntityAttributeValue ( $ entity , $ field ) { $ functionName = 'get' . ucfirst ( $ field ) ; $ fieldValue = call_user_func ( [ $ entity , $ functionName ] ) ; return $ fieldValue ; } | Get the content of an attribute of an entity given . |
27,573 | protected function setEntityAttributeValue ( $ entity , $ field , $ value ) { $ functionName = 'set' . ucfirst ( $ field ) ; call_user_func ( [ $ entity , $ functionName ] , $ value ) ; } | Update the value of the entity . |
27,574 | public static function loadClassMetadata ( $ eventArgs ) { if ( $ eventArgs instanceof LoadClassMetadataEventArgs ) { $ 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' ; } } } } } | Insert enabled widgets in base widget add relationship between BusinessEntities and EntityProxy . |
27,575 | 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 ( ) ; } | Add icon configuration . |
27,576 | public function getMostReadByViewType ( $ viewNamespace , $ number ) { $ views = [ ] ; switch ( $ viewNamespace ) { case 'Victoire\Bundle\PageBundle\Entity\Page' : $ viewReferences = [ ] ; $ repo = $ this -> entityManager -> getRepository ( $ viewNamespace ) ; foreach ( $ repo -> getAll ( ) -> run ( ) as $ key => $ page ) { $ viewReference = $ this -> viewReferenceRepository -> getOneReferenceByParameters ( [ 'viewNamespace' => $ viewNamespace , 'viewId' => $ page -> getId ( ) , ] ) ; $ viewReferences [ $ viewReference -> getId ( ) ] = $ viewReference ; } $ browseEvents = $ this -> entityManager -> getRepository ( 'Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent' ) -> getMostVisitedFromReferences ( array_keys ( $ viewReferences ) , $ number ) -> getQuery ( ) -> getResult ( ) ; foreach ( $ browseEvents as $ browseEvent ) { $ views [ ] = $ this -> pageHelper -> findPageByReference ( $ viewReferences [ $ browseEvent -> getViewReferenceId ( ) ] ) ; } break ; default : break ; } return $ views ; } | Get the most read views by type . |
27,577 | public function getMostReadArticlesByBlog ( $ blog , $ number , $ excludeUnpublished = true ) { $ viewReferences = [ ] ; $ 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 ; } } $ browseEvents = $ this -> entityManager -> getRepository ( 'Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent' ) -> getMostVisitedFromReferences ( array_keys ( $ viewReferences ) , $ number ) -> getQuery ( ) -> getResult ( ) ; $ views = [ ] ; foreach ( $ browseEvents as $ browseEvent ) { $ views [ ] = $ this -> pageHelper -> findPageByReference ( $ viewReferences [ $ browseEvent -> getViewReferenceId ( ) ] ) ; } return $ views ; } | Get the most read articles by blog . |
27,578 | public function getVisitorCountForViewReference ( $ viewReferenceId ) { $ viewCount = $ this -> entityManager -> getRepository ( 'Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent' ) -> getNumberOfEventForViewReferenceId ( $ viewReferenceId ) -> getQuery ( ) -> getSingleScalarResult ( ) ; return $ viewCount ; } | Get number of unique visitor for a viewReference . |
27,579 | 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 ; } | Add global menu items . |
27,580 | 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 ) , ] ) ; } | Get Sitemap as XML . |
27,581 | 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 ) ; } | Show Sitemap as tree and save new order if necessary . |
27,582 | 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 ) ; } | Change the sitemap priority for the given page . |
27,583 | 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 ; } | Create a sitemap priority type . |
27,584 | public function indexAction ( ) { $ businessEntityHelper = $ this -> get ( 'victoire_core.helper.business_entity_helper' ) ; $ em = $ this -> get ( 'doctrine.orm.entity_manager' ) ; $ repository = $ em -> getRepository ( 'VictoireBusinessPageBundle:BusinessTemplate' ) ; $ BusinessTemplates = [ ] ; $ businessEntities = $ businessEntityHelper -> getBusinessEntities ( ) ; foreach ( $ businessEntities as $ businessEntity ) { $ name = $ businessEntity -> getName ( ) ; $ 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 , ] ) ; } | List all business entity page pattern . |
27,585 | public function showAction ( BusinessTemplate $ view ) { $ this -> get ( 'twig' ) -> addGlobal ( 'view' , $ view ) ; $ view -> setReference ( new ViewReference ( $ view -> getId ( ) ) ) ; return $ this -> container -> get ( 'victoire_page.page_helper' ) -> renderPage ( $ view ) ; } | Show BusinessTemplate . |
27,586 | public function createAction ( Request $ request , $ id ) { $ businessEntity = $ this -> getBusinessEntity ( $ id ) ; $ 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 ( ) ; $ 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 { $ params [ 'message' ] = $ this -> container -> get ( 'victoire_form.error_helper' ) -> getRecursiveReadableErrors ( $ form ) ; } return new JsonResponse ( $ params ) ; } | Creates a new BusinessTemplate entity . |
27,587 | 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 ; } | Creates a form to create a BusinessTemplate entity . |
27,588 | public function newAction ( $ id ) { $ businessEntity = $ this -> getBusinessEntity ( $ id ) ; $ 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 , ] ) ; } | Displays a form to create a new BusinessTemplate entity . |
27,589 | 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 , ] ) ; } | Displays a form to edit an existing BusinessTemplate entity . |
27,590 | 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 ; } | Creates a form to edit a BusinessTemplate entity . |
27,591 | public function updateAction ( Request $ request , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ 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 ( ) ; $ 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 , ] ) ; } | Edits an existing BusinessTemplate entity . |
27,592 | public function listEntitiesAction ( BusinessTemplate $ view ) { $ bepHelper = $ this -> get ( 'victoire_business_page.business_page_helper' ) ; return $ this -> render ( '@VictoireBusinessPage/BusinessTemplate/listEntities.html.twig' , [ 'BusinessTemplate' => $ view , 'items' => $ bepHelper -> getEntitiesAllowed ( $ view , $ this -> get ( 'doctrine.orm.entity_manager' ) ) , ] ) ; } | List the entities that matches the query of the BusinessTemplate . |
27,593 | private function getBusinessProperties ( BusinessTemplate $ view ) { $ businessTemplateHelper = $ this -> get ( 'victoire_business_page.business_page_helper' ) ; $ businessEntityId = $ view -> getBusinessEntityId ( ) ; $ businessEntity = $ this -> get ( 'victoire_core.helper.business_entity_helper' ) -> findById ( $ businessEntityId ) ; $ businessProperties = $ businessTemplateHelper -> getBusinessProperties ( $ businessEntity ) ; return $ businessProperties ; } | Get an array of business properties by the business entity page pattern . |
27,594 | public function getTypes ( ) { if ( ! array_key_exists ( 'value' , $ this -> types ) ) { return ; } if ( is_array ( $ this -> types [ 'value' ] ) && count ( $ this -> types [ 'value' ] ) > 1 ) { return $ this -> types [ 'value' ] ; } else { return [ $ this -> types [ 'value' ] ] ; } } | Get types . |
27,595 | public function isEntityAllowed ( BusinessTemplate $ businessTemplate , $ entity , EntityManager $ em = null ) { $ allowed = true ; if ( $ entity === null ) { throw new \ Exception ( 'The entity is required.' ) ; } $ queryHelper = $ this -> queryHelper ; $ entityId = $ entity -> getId ( ) ; $ baseQuery = $ queryHelper -> getQueryBuilder ( $ businessTemplate , $ em ) ; $ baseQuery -> andWhere ( 'main_item.id = ' . $ entityId ) ; $ items = $ queryHelper -> buildWithSubQuery ( $ businessTemplate , $ baseQuery , $ em ) -> getQuery ( ) -> getResult ( ) ; 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 ; } | Is the entity allowed for the business entity page . |
27,596 | public function getIdentifierPositionInUrl ( BusinessTemplate $ businessTemplate ) { $ position = null ; $ url = $ businessTemplate -> getUrl ( ) ; $ keywords = preg_split ( "/\//" , $ url ) ; $ businessEntityId = $ businessTemplate -> getBusinessEntityId ( ) ; $ businessEntity = $ this -> businessEntityHelper -> findById ( $ businessEntityId ) ; $ businessProperties = $ businessEntity -> getBusinessPropertiesByType ( 'businessParameter' ) ; foreach ( $ keywords as $ index => $ keyword ) { foreach ( $ businessProperties as $ businessProperty ) { $ entityProperty = $ businessProperty -> getEntityProperty ( ) ; $ searchWord = '{{item.' . $ entityProperty . '}}' ; if ( $ searchWord === $ keyword ) { $ position = [ 'position' => $ index + 1 , 'businessProperty' => $ businessProperty , ] ; } } } return $ position ; } | Get the position of the identifier in the url of a business entity page pattern . |
27,597 | 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 ; } | Guess the best pattern to represent given reflectionClass . |
27,598 | public function getChildren ( WidgetMap $ widgetMap , View $ view = null ) { $ positions = [ WidgetMap :: POSITION_BEFORE , WidgetMap :: POSITION_AFTER ] ; $ children = [ ] ; foreach ( $ positions as $ position ) { $ matchingChildren = [ ] ; $ children [ $ position ] = null ; foreach ( $ widgetMap -> getContextualChildren ( $ position ) as $ _child ) { if ( null === $ _child -> getSubstituteForView ( $ view ) ) { $ children [ $ position ] = $ _child ; $ matchingChildren [ ] = $ _child -> getId ( ) ; } } if ( ! $ children [ $ position ] && $ widgetMap -> getReplaced ( ) ) { foreach ( $ widgetMap -> getReplaced ( ) -> getContextualChildren ( $ position ) as $ _child ) { 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 ; } | Return after and before children based on contextual View and its Templates . |
27,599 | 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' ) ; } | add a global menu item . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.