idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
27,700 | protected function settingsAction ( Request $ request , BasePage $ page ) { $ form = $ this -> createSettingsForm ( $ page ) ; return [ 'success' => true , 'html' => $ this -> get ( 'templating' ) -> render ( $ this -> getBaseTemplatePath ( ) . ':settings.html.twig' , [ 'page' => $ page , 'form' => $ form -> createView ( ) , 'businessProperties' => $ this -> getBusinessProperties ( $ page ) , ] ) , ] ; } | Display a form to edit Page settings . Route is defined in inherited controllers . |
27,701 | protected function settingsPostAction ( Request $ request , BasePage $ page ) { $ entityManager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ form = $ this -> createSettingsForm ( $ page ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ entityManager -> persist ( $ page ) ; $ entityManager -> flush ( ) ; $ this -> congrat ( $ this -> get ( 'translator' ) -> trans ( 'victoire_page.update.success' , [ ] , 'victoire' ) ) ; return $ this -> getViewReferenceRedirect ( $ request , $ page ) ; } return [ 'success' => false , 'message' => $ this -> get ( 'victoire_form.error_helper' ) -> getRecursiveReadableErrors ( $ form ) , 'html' => $ this -> get ( 'templating' ) -> render ( $ this -> getBaseTemplatePath ( ) . ':settings.html.twig' , [ 'page' => $ page , 'form' => $ form -> createView ( ) , 'businessProperties' => $ this -> getBusinessProperties ( $ page ) , ] ) , ] ; } | Save Page settings . Route is defined in inherited controllers . |
27,702 | protected function deleteAction ( BasePage $ page ) { try { if ( $ page -> isUndeletable ( ) ) { $ message = $ this -> get ( 'translator' ) -> trans ( 'page.undeletable' , [ ] , 'victoire' ) ; throw new \ Exception ( $ message ) ; } $ entityManager = $ this -> get ( 'doctrine.orm.entity_manager' ) ; $ entityManager -> remove ( $ page ) ; $ entityManager -> flush ( ) ; return [ 'success' => true , 'url' => $ this -> generateUrl ( 'victoire_core_homepage_show' ) , ] ; } catch ( \ Exception $ ex ) { return [ 'success' => false , 'message' => $ ex -> getMessage ( ) , ] ; } } | Delete a Page . Route is defined in inherited controllers . |
27,703 | protected function getViewReferenceRedirect ( Request $ request , BasePage $ page ) { $ parameters = [ 'viewId' => $ page -> getId ( ) , ] ; if ( ! ( $ page instanceof Blog ) ) { $ parameters [ 'locale' ] = $ request -> getLocale ( ) ; } $ viewReference = $ this -> get ( 'victoire_view_reference.repository' ) -> getOneReferenceByParameters ( $ parameters ) ; $ page -> setReference ( $ viewReference ) ; return [ 'success' => true , 'url' => $ this -> generateUrl ( 'victoire_core_page_show' , [ '_locale' => $ request -> getLocale ( ) , 'url' => $ viewReference -> getUrl ( ) , ] ) , ] ; } | Return an array for JsonResponse redirecting to a ViewReference . |
27,704 | protected function createSettingsForm ( BasePage $ page ) { $ form = $ this -> createForm ( $ this -> getPageSettingsType ( ) , $ page ) ; if ( $ page instanceof BusinessPage ) { $ form = $ this -> createForm ( $ this -> getBusinessPageType ( ) , $ page ) ; } return $ form ; } | Create Settings form according to Page type . |
27,705 | protected function getBusinessProperties ( BasePage $ page ) { $ businessProperties = [ ] ; if ( $ page instanceof BusinessTemplate ) { $ businessEntity = $ this -> get ( 'victoire_core.helper.business_entity_helper' ) -> findById ( $ page -> getBusinessEntityId ( ) ) ; $ businessProperties = $ businessEntity -> getBusinessPropertiesByType ( 'seoable' ) ; } return $ businessProperties ; } | Return BusinessEntity seaoable properties if Page is a BusinessTemplate . |
27,706 | public function transliterate ( $ text , $ separator , $ object ) { if ( $ object instanceof BusinessTemplate || ( in_array ( Translation :: class , class_uses ( $ object ) ) && $ object -> getTranslatable ( ) instanceof BusinessTemplate ) ) { $ slug = Transliterator :: urlize ( $ text , $ separator , true ) ; } else { $ slug = Transliterator :: urlize ( $ text , $ separator ) ; } return $ slug ; } | Transliterates the slug and keep twig variable . |
27,707 | public function getUnresolvedQuery ( $ order = 'redirection.counter' , $ direction = 'DESC' ) { $ this -> getAll ( ) ; return $ this -> qb -> orderBy ( $ order , $ direction ) ; } | Get all redirections in the repository . |
27,708 | public function updateSeoByEntity ( BasePage $ page , $ entity ) { if ( $ entity === null ) { if ( $ page -> getBusinessEntity ( ) !== null ) { $ entity = $ page -> getBusinessEntity ( ) ; } } if ( $ entity !== null ) { $ pageSeo = $ page -> getSeo ( ) ; if ( $ pageSeo !== null ) { $ businessEntity = $ this -> businessEntityHelper -> findByEntityInstance ( $ entity ) ; if ( $ businessEntity !== null ) { $ businessProperties = $ businessEntity -> getBusinessPropertiesByType ( 'seoable' ) ; foreach ( $ businessProperties as $ businessProperty ) { foreach ( $ this -> pageSeoAttributes as $ seoAttribute ) { $ value = $ this -> getEntityAttributeValue ( $ pageSeo , $ seoAttribute ) ; if ( is_string ( $ value ) && ( $ page instanceof VirtualBusinessPage || ( $ page instanceof BusinessPage && $ value == null ) ) ) { $ value = $ this -> parameterConverter -> setBusinessPropertyInstance ( $ value , $ businessProperty , $ entity ) ; } $ this -> setEntityAttributeValue ( $ pageSeo , $ seoAttribute , $ value ) ; } } } } } } | Generate a seo for the page using the current entity . |
27,709 | public function handle ( \ Exception $ ex , $ currentView , $ widget = null , $ widgetId = null ) { $ templating = $ this -> container -> get ( 'templating' ) ; $ result = '' ; if ( $ this -> debug ) { $ exceptionResult = '<div style="border: 3px solid #FF0000;height: 500px;overflow: auto;">' ; $ template = new TemplateReference ( 'TwigBundle' , 'Exception' , 'exception' , 'html' , 'twig' ) ; $ exception = FlattenException :: create ( $ ex ) ; $ exceptionResult = $ templating -> render ( $ template , [ 'status_code' => $ ex -> getCode ( ) , 'status_text' => 500 , 'exception' => $ exception , 'logger' => null , 'currentContent' => null , ] ) ; $ exceptionResult .= '</div>' ; $ result = $ templating -> render ( 'VictoireCoreBundle:Widget:showError.html.twig' , [ 'widget' => $ widget , 'widgetId' => $ widgetId , 'currentView' => $ currentView , 'error' => $ exceptionResult , ] ) ; } else { if ( $ this -> authorizationChecker -> isGranted ( 'ROLE_VICTOIRE' ) ) { $ result = $ templating -> render ( 'VictoireCoreBundle:Widget:showError.html.twig' , [ 'widget' => $ widget , 'widgetId' => $ widgetId , 'currentView' => $ currentView , 'error' => $ ex -> getMessage ( ) , ] ) ; } } return $ result ; } | Handle response for an exception for a widget . |
27,710 | public function getConfigTreeBuilder ( ) { $ treeBuilder = new TreeBuilder ( ) ; $ rootNode = $ treeBuilder -> root ( 'victoire_seo' ) ; $ rootNode -> addDefaultsIfNotSet ( ) -> children ( ) -> arrayNode ( 'analytics' ) -> useAttributeAsKey ( true ) -> prototype ( 'array' ) -> children ( ) -> booleanNode ( 'enabled' ) -> defaultValue ( 'false' ) -> end ( ) -> scalarNode ( 'key' ) -> defaultNull ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) -> end ( ) ; return $ treeBuilder ; } | Get the config tree builder . |
27,711 | public function index ( $ id , $ values ) { foreach ( $ values as $ name => $ value ) { $ key = $ this -> tools -> generateKey ( $ name . '_' . $ this -> alias , $ value ) ; $ this -> redis -> sadd ( $ key , $ id ) ; } } | This method index a reference . |
27,712 | public function setBusinessPropertyInstance ( $ string , BusinessProperty $ businessProperty , $ entity ) { if ( $ entity === null ) { throw new \ Exception ( 'The parameter entity can not be null' ) ; } $ entityProperty = $ businessProperty -> getEntityProperty ( ) ; $ stringToReplace = '{{item.' . $ entityProperty . '}}' ; $ attributeValue = $ entity -> getEntityAttributeValue ( $ entityProperty ) ; if ( $ attributeValue === null ) { $ attributeValue = '' ; } $ string = str_replace ( $ stringToReplace , $ attributeValue , $ string ) ; return $ string ; } | Replace the code string with the value of the entity attribute . |
27,713 | protected function addCriteriasFields ( $ builder , $ options ) { $ builder -> add ( 'criterias' , CriteriaCollectionType :: class , [ 'label' => 'victoire.widget.type.criterias.label' , 'entry_type' => CriteriaType :: class , 'required' => false , 'entry_options' => [ 'dataSources' => $ options [ 'dataSources' ] , ] , ] ) ; $ builder -> addEventListener ( FormEvents :: PRE_SET_DATA , function ( FormEvent $ event ) use ( $ options ) { $ dataSources = $ options [ 'dataSources' ] -> getDataSources ( ) ; $ widget = $ event -> getData ( ) ; foreach ( $ dataSources as $ alias => $ dataSource ) { if ( ! $ widget -> hasCriteriaNamed ( $ alias ) ) { $ criteria = new Criteria ( ) ; $ criteria -> setName ( $ alias ) ; $ widget -> addCriteria ( $ criteria ) ; } } } ) ; $ builder -> addEventListener ( FormEvents :: POST_SUBMIT , function ( FormEvent $ event ) use ( $ options ) { $ widget = $ event -> getData ( ) ; foreach ( $ widget -> getCriterias ( ) as $ criteria ) { if ( $ criteria -> getValue ( ) === null ) { $ widget -> removeCriteria ( $ criteria ) ; } } } ) ; } | Add the criterias fields . |
27,714 | protected function addEntityFields ( $ form , $ options ) { $ form -> add ( 'fields' , WidgetFieldsFormType :: class , [ 'label' => 'widget.form.entity.fields.label' , 'namespace' => $ options [ 'namespace' ] , 'widget' => $ options [ 'widget' ] , ] ) -> add ( 'entity_proxy' , EntityProxyFormType :: class , [ 'business_entity_id' => $ options [ 'businessEntityId' ] , 'namespace' => $ options [ 'namespace' ] , 'widget' => $ options [ 'widget' ] , ] ) ; } | Add the fields for the form and the entity mode . |
27,715 | protected function addQueryFields ( $ form , $ options ) { $ form -> add ( 'query' ) ; $ form -> add ( 'fields' , WidgetFieldsFormType :: class , [ 'label' => 'widget.form.entity.fields.label' , 'namespace' => $ options [ 'namespace' ] , 'widget' => $ options [ 'widget' ] , ] ) ; } | Add the fields to the form for the query mode . |
27,716 | public function findPageByBusinessEntityAndPattern ( BusinessTemplate $ pattern , $ entity , BusinessEntity $ businessEntity ) { if ( is_object ( $ entity ) ) { $ entity = $ entity -> getId ( ) ; } $ qb = $ this -> createQueryBuilder ( 'BusinessPage' ) ; $ qb -> join ( 'BusinessPage.entityProxy' , 'proxy' ) ; $ qb -> join ( 'BusinessPage.template' , 'template' ) ; $ qb -> join ( 'proxy.' . $ businessEntity -> getId ( ) , 'entity' ) ; $ qb -> where ( 'template.id = :templateId' ) ; $ qb -> andWhere ( 'entity.id = :entityId' ) ; $ qb -> setParameter ( ':templateId' , $ pattern ) ; $ qb -> setParameter ( ':entityId' , $ entity ) ; $ result = $ qb -> getQuery ( ) -> getOneOrNullResult ( ) ; return $ result ; } | Find the pagePatterns of the business entity . |
27,717 | public function redislize ( $ data ) { if ( ! is_string ( $ data ) && ! is_int ( $ data ) ) { return urlencode ( serialize ( $ data ) ) ; } return urlencode ( $ data ) ; } | This method generated a string that can be persisted for redis with data . |
27,718 | public function unredislize ( $ data ) { $ data = urldecode ( $ data ) ; if ( self :: isSerialized ( $ data ) ) { $ unserializedData = @ unserialize ( $ data ) ; if ( $ unserializedData !== false ) { return $ unserializedData ; } } return $ data ; } | This method unredislize a string . |
27,719 | public function renderNewForm ( $ form , $ widget , $ slot , View $ view , $ quantum = null , $ entity = null ) { $ templateName = $ this -> container -> get ( 'victoire_widget.widget_helper' ) -> getTemplateName ( 'new' , $ widget ) ; return $ this -> container -> get ( 'templating' ) -> render ( $ templateName , [ 'widget' => $ widget , 'form' => $ form -> createView ( ) , 'slot' => $ slot , 'entity' => $ entity , 'view' => $ view , 'quantum' => $ quantum , ] ) ; } | create form new for a widget . |
27,720 | public function renderForm ( Form $ form , Widget $ widget , $ entity = null ) { $ templateName = $ this -> container -> get ( 'victoire_widget.widget_helper' ) -> getTemplateName ( 'edit' , $ widget ) ; return $ this -> container -> get ( 'templating' ) -> render ( $ templateName , [ 'widget' => $ widget , 'slot' => $ widget -> getWidgetMap ( ) -> getSlot ( ) , 'view' => $ this -> container -> get ( 'victoire_core.current_view' ) -> getCurrentView ( ) , 'form' => $ form -> createView ( ) , 'id' => $ widget -> getId ( ) , 'entity' => $ entity , ] ) ; } | render Widget form . |
27,721 | public function renderQuantumStyleForms ( $ viewReference , $ widgets , Widget $ activeWidget ) { $ forms = [ ] ; foreach ( $ widgets as $ key => $ widget ) { $ _quantum = $ this -> convertToString ( $ key ) ; $ forms [ $ key ] [ 'form' ] = $ this -> buildWidgetStyleForm ( $ widget , $ viewReference , $ _quantum ) -> createView ( ) ; $ forms [ $ key ] [ 'quantum' ] = $ _quantum ; $ forms [ $ key ] [ 'active' ] = $ widget === $ activeWidget ? true : false ; } return $ forms ; } | Generates style forms for each quantum . |
27,722 | public function buildWidgetStyleForm ( Widget $ widget , $ viewReference , $ quantum ) { $ formFactory = $ this -> container -> get ( 'form.factory' ) ; $ options = [ 'method' => 'POST' , 'action' => $ this -> container -> get ( 'router' ) -> generate ( 'victoire_core_widget_stylize' , [ 'id' => $ widget -> getId ( ) , 'viewReference' => $ viewReference , 'quantum' => $ quantum , ] ) , ] ; $ mockForm = $ formFactory -> create ( WidgetStyleType :: class , $ widget , $ options ) ; $ builder = $ formFactory -> createNamed ( sprintf ( '%s_%s' , $ quantum , $ mockForm -> getName ( ) ) , WidgetStyleType :: class , $ widget , $ options ) ; return $ builder ; } | Create style form for given widget . |
27,723 | public function convertToString ( $ number , $ letter = 'a' , $ i = 0 ) { if ( ! is_numeric ( $ number ) ) { return $ number ; } while ( $ i < $ number ) { $ i ++ ; $ letter ++ ; } return $ letter ; } | This method converts a number to an alphabetic char . If the number is > 26 convert to aa ... az ... zz ... |
27,724 | public function callBuildFormSwitchParameters ( Widget $ widget , $ view , $ businessEntityId , $ position , $ parentWidgetMap , $ slotId , $ quantum ) { $ entityClass = null ; if ( $ businessEntityId ) { $ classes = $ this -> container -> get ( 'victoire_core.helper.business_entity_helper' ) -> getBusinessClassesForWidget ( $ widget ) ; if ( ! isset ( $ classes [ $ businessEntityId ] ) ) { throw new \ Exception ( 'The entity ' . $ businessEntityId . ' was not found int the business classes.' ) ; } $ entityClass = $ classes [ $ businessEntityId ] -> getClass ( ) ; } $ form = $ this -> buildForm ( $ widget , $ view , $ businessEntityId , $ entityClass , $ widget -> getMode ( ) , $ slotId , $ position , $ parentWidgetMap , $ quantum ) ; return $ form ; } | Call the build form with selected parameter switch the parameters The call is not the same if an entity is provided or not . |
27,725 | public function render ( Widget $ widget , View $ view ) { $ mode = $ widget -> getMode ( ) ; if ( $ mode == Widget :: MODE_BUSINESS_ENTITY && $ view instanceof BusinessPage ) { $ widget -> setEntity ( $ view -> getBusinessEntity ( ) ) ; } elseif ( $ view instanceof BusinessTemplate ) { $ entityManager = $ this -> container -> get ( 'doctrine.orm.entity_manager' ) ; if ( $ mock = $ this -> bepHelper -> getEntitiesAllowedQueryBuilder ( $ view , $ entityManager ) -> setMaxResults ( 1 ) -> getQuery ( ) -> getOneOrNullResult ( ) ) { $ widget -> setEntity ( $ mock ) ; } } $ templating = $ this -> container -> get ( 'templating' ) ; $ parameters = $ this -> container -> get ( 'victoire_widget.widget_content_resolver' ) -> getWidgetContent ( $ widget ) ; if ( $ widget -> getMode ( ) == Widget :: MODE_BUSINESS_ENTITY ) { $ this -> container -> get ( 'doctrine.orm.entity_manager' ) -> refresh ( $ widget ) ; } $ showView = 'show' . ucfirst ( $ widget -> getTheme ( ) ) ; $ templateName = $ this -> container -> get ( 'victoire_widget.widget_helper' ) -> getTemplateName ( $ showView , $ widget ) ; return $ templating -> render ( $ templateName , $ parameters ) ; } | render the Widget . |
27,726 | public function renderContainer ( Widget $ widget , View $ view ) { $ dispatcher = $ this -> container -> get ( 'event_dispatcher' ) ; $ dispatcher -> dispatch ( VictoireCmsEvents :: WIDGET_PRE_RENDER , new WidgetRenderEvent ( $ widget ) ) ; $ widgetMap = $ widget -> getWidgetMap ( ) ; $ directive = '' ; if ( $ this -> container -> get ( 'security.authorization_checker' ) -> isGranted ( 'ROLE_VICTOIRE' ) ) { $ directive = 'widget' ; } $ id = 'vic-widget-' . $ widget -> getId ( ) . '-container' ; $ html = sprintf ( '<div %s widget-map="%s" id="%s" class="vic-widget-container" data-id="%s">' , $ directive , $ widgetMap -> getId ( ) , $ id , $ widget -> getId ( ) ) ; if ( $ this -> widgetHelper -> isCacheEnabled ( $ widget ) ) { $ content = $ this -> widgetCache -> fetch ( $ widget ) ; if ( null === $ content ) { $ content = $ this -> render ( $ widget , $ view ) ; $ this -> widgetCache -> save ( $ widget , $ content ) ; } else { $ this -> victoireCollector -> addCachedWidget ( $ widget ) ; } } else { $ content = $ this -> render ( $ widget , $ view ) ; } $ html .= $ content ; $ html .= '</div>' ; $ dispatcher -> dispatch ( VictoireCmsEvents :: WIDGET_POST_RENDER , new WidgetRenderEvent ( $ widget , $ html ) ) ; return $ html ; } | render a widget . |
27,727 | public function prepareAsynchronousRender ( $ widgetId ) { $ ngControllerName = 'widget' . $ widgetId . 'AsynchronousLoadCtrl' ; $ ngDirectives = sprintf ( 'ng-controller="WidgetAsynchronousLoadController as %s" class="vic-widget" ng-init="%s.init(%d)" ng-bind-html="html"' , $ ngControllerName , $ ngControllerName , $ widgetId ) ; $ html = sprintf ( '<div class="vic-widget-container vic-widget-asynchronous" data-id="%d" %s></div>' , $ widgetId , $ ngDirectives ) ; return $ html ; } | prepare a widget to be rendered asynchronously . |
27,728 | public function computeOptions ( $ slotId , $ options = [ ] ) { $ slots = $ this -> container -> getParameter ( 'victoire_core.slots' ) ; $ availableWidgets = $ this -> container -> getParameter ( 'victoire_core.widgets' ) ; $ widgets = [ ] ; if ( ! empty ( $ slots [ $ slotId ] ) && ! empty ( $ slots [ $ slotId ] [ 'widgets' ] ) ) { $ slotWidgets = array_keys ( $ slots [ $ slotId ] [ 'widgets' ] ) ; } elseif ( ! empty ( $ options [ 'availableWidgets' ] ) ) { $ slotWidgets = $ options [ 'availableWidgets' ] ; } else { $ slotWidgets = array_keys ( $ availableWidgets ) ; } foreach ( $ slotWidgets as $ slotWidget ) { $ widgetParams = $ availableWidgets [ $ slotWidget ] ; $ widgets [ $ slotWidget ] [ 'params' ] = $ widgetParams ; } $ slots [ $ slotId ] [ 'availableWidgets' ] = $ widgets ; if ( isset ( $ options [ 'max' ] ) ) { $ slots [ $ slotId ] [ 'max' ] = $ options [ 'max' ] ; } return $ slots [ $ slotId ] ; } | Compute slot options . |
27,729 | public function getExtraCssClass ( Widget $ widget ) { $ cssClass = 'v-widget--' . strtolower ( $ this -> container -> get ( 'victoire_widget.widget_helper' ) -> getWidgetName ( $ widget ) ) ; return $ cssClass ; } | Get the extra classes for the css . |
27,730 | public function isPublished ( ) { if ( $ this -> getStatus ( ) === PageStatus :: PUBLISHED || ( $ this -> getStatus ( ) === PageStatus :: SCHEDULED && $ this -> getPublishedAt ( ) < new \ DateTime ( ) ) ) { return true ; } else { return false ; } } | Is this page published . |
27,731 | public function settingsAction ( Request $ request , View $ view ) { $ pageSeo = $ view -> getSeo ( ) ? : new PageSeo ( ) ; $ form = $ this -> createSettingsForm ( $ pageSeo , $ view ) ; $ form -> handleRequest ( $ request ) ; $ response = $ this -> getNotPersistedSettingsResponse ( $ form , $ view , $ request -> query -> get ( 'novalidate' , false ) ) ; return new JsonResponse ( $ response ) ; } | Display a form to edit Seo settings . |
27,732 | public function settingsPostAction ( Request $ request , View $ view ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ pageSeo = $ view -> getSeo ( ) ? : new PageSeo ( ) ; $ form = $ this -> createSettingsForm ( $ pageSeo , $ view ) ; $ form -> handleRequest ( $ request ) ; $ novalidate = $ request -> query -> get ( 'novalidate' , false ) ; if ( false === $ novalidate && $ form -> isValid ( ) ) { $ em -> persist ( $ pageSeo ) ; $ view -> setSeo ( $ pageSeo ) ; $ em -> persist ( $ view ) ; $ em -> flush ( ) ; $ this -> get ( 'victoire_core.current_view' ) -> setCurrentView ( $ view ) ; $ this -> congrat ( 'victoire_seo.save.success' ) ; $ response = [ 'success' => true , 'url' => $ this -> getViewUrl ( $ view ) , ] ; } else { $ response = $ this -> getNotPersistedSettingsResponse ( $ form , $ view , $ novalidate ) ; } return new JsonResponse ( $ response ) ; } | Save Seo settings . |
27,733 | private function createSettingsForm ( PageSeo $ pageSeo , View $ view ) { return $ this -> get ( 'form.factory' ) -> create ( PageSeoType :: class , $ pageSeo , [ 'action' => $ this -> get ( 'router' ) -> generate ( 'victoire_seo_pageSeo_settings_post' , [ 'id' => $ view -> getId ( ) , ] ) , 'method' => 'POST' , ] ) ; } | Create PageSeo Form . |
27,734 | private function getViewUrl ( View $ view ) { if ( ! method_exists ( $ view , 'getUrl' ) ) { return $ this -> generateUrl ( 'victoire_business_template_show' , [ 'id' => $ view -> getId ( ) ] ) ; } $ viewReference = $ this -> container -> get ( 'victoire_view_reference.repository' ) -> getOneReferenceByParameters ( [ 'viewId' => $ view -> getId ( ) ] ) ; $ view -> setReference ( $ viewReference ) ; return $ this -> generateUrl ( 'victoire_core_page_show' , [ 'url' => $ viewReference -> getUrl ( ) ] ) ; } | Get url for a View using ViewReferences if necessary . |
27,735 | private function getBusinessProperties ( View $ view ) { $ businessProperties = [ ] ; if ( $ view instanceof BusinessTemplate ) { $ businessEntity = $ this -> get ( 'victoire_core.helper.business_entity_helper' ) -> findById ( $ view -> getBusinessEntityId ( ) ) ; $ businessProperties = $ businessEntity -> getBusinessPropertiesByType ( 'seoable' ) ; } return $ businessProperties ; } | Return BusinessEntity seaoable properties if View is a BusinessTemplate . |
27,736 | public function getAll ( $ excludeUnpublished = false , Blog $ blog = null ) { $ this -> clearInstance ( ) ; $ this -> qb = $ this -> getInstance ( ) ; if ( $ excludeUnpublished ) { $ this -> qb -> andWhere ( 'article.status = :status' ) -> orWhere ( 'article.status = :scheduled_status AND article.publishedAt <= :now' ) -> setParameter ( 'status' , PageStatus :: PUBLISHED ) -> setParameter ( 'scheduled_status' , PageStatus :: SCHEDULED ) -> setParameter ( 'now' , new \ DateTime ( ) ) ; } if ( null != $ blog ) { $ this -> qb -> andWhere ( 'article.blog = :blog' ) -> setParameter ( 'blog' , $ blog -> getId ( ) ) ; } return $ this ; } | Get all articles in the repository . |
27,737 | public function run ( $ method = 'getResult' , $ hydrationMode = Query :: HYDRATE_OBJECT ) { return $ this -> getInstance ( ) -> getQuery ( ) -> $ method ( $ hydrationMode ) ; } | Get very next festivals query builder . |
27,738 | public function filterWithListingQuery ( $ listingQuery = null ) { if ( $ listingQuery ) { $ dql = $ this -> createQueryBuilder ( 'item' ) -> leftJoin ( 'item.blog' , 'blog' ) -> getDql ( ) ; $ dql = $ dql . ' ' . $ listingQuery ; $ this -> qb -> andWhere ( $ this -> qb -> expr ( ) -> in ( 'article' , $ dql ) ) ; } return $ this ; } | Use to assemble ArticleList Query with Filter Query . |
27,739 | public function getArticles ( Blog $ blog ) { $ queryBuilder = $ this -> getAll ( false , $ blog ) -> getInstance ( ) ; return $ queryBuilder -> andWhere ( 'article.status IN (:status)' ) -> setParameter ( 'status' , [ PageStatus :: PUBLISHED , PageStatus :: SCHEDULED , PageStatus :: UNPUBLISHED , ] ) -> orderBy ( 'article.publishedAt' , 'DESC' ) -> getQuery ( ) -> getResult ( ) ; } | Get Article by blog ordered by publication DESC . |
27,740 | public function getDrafts ( Blog $ blog ) { $ queryBuilder = $ this -> getAll ( false , $ blog ) -> getInstance ( ) ; return $ queryBuilder -> andWhere ( 'article.status = :status' ) -> setParameter ( 'status' , PageStatus :: DRAFT ) -> orderBy ( 'article.createdAt' , 'DESC' ) -> getQuery ( ) -> getResult ( ) ; } | Get articles by blog ordered by creation DESC . |
27,741 | public function getAll ( $ exceptRedirected = false ) { $ this -> clearInstance ( ) ; $ this -> qb = $ this -> getInstance ( 'error' ) ; if ( true === $ exceptRedirected ) { $ this -> qb -> andWhere ( 'error.redirection IS NULL' ) ; } return $ this ; } | Get every errors in the repository . |
27,742 | public function getRouteErrors ( $ order = 'error.counter' , $ direction = 'DESC' ) { $ this -> getAll ( true ) ; $ qb = $ this -> qb ; return $ qb -> andWhere ( 'error.type = :type' ) -> setParameter ( 'type' , HttpError :: TYPE_ROUTE ) -> orderBy ( $ order , $ direction ) ; } | Get every route errors in the repository . |
27,743 | public function getFileErrors ( $ order = 'error.counter' , $ direction = 'DESC' ) { $ this -> getAll ( true ) ; $ qb = $ this -> qb ; return $ qb -> andWhere ( 'error.type = :type' ) -> setParameter ( 'type' , HttpError :: TYPE_FILE ) -> orderBy ( $ order , $ direction ) ; } | Get every file errors in the repository . |
27,744 | public function getWidgetName ( Widget $ widget ) { $ widgets = $ this -> container -> getParameter ( 'victoire_core.widgets' ) ; foreach ( $ widgets as $ widgetParams ) { if ( $ widgetParams [ 'class' ] === ClassUtils :: getClass ( $ widget ) ) { return $ widgetParams [ 'name' ] ; } } throw new \ Exception ( 'Widget name not found for widget ' . get_class ( $ widget ) . '. Is this widget right declared in AppKernel ?' ) ; } | The name of the widget . |
27,745 | public function isWidgetAllowedForSlot ( Widget $ widget , $ slot ) { $ widgetName = $ this -> getWidgetName ( $ widget ) ; $ slots = $ this -> slots ; return ! empty ( $ slots [ $ slot ] ) && ( array_key_exists ( $ widgetName , $ slots [ $ slot ] [ 'widgets' ] ) ) ; } | check if widget is allowed for slot . |
27,746 | public function newWidgetInstance ( $ type , $ view , $ slot , $ mode ) { $ widgetAlias = 'victoire.widget.' . strtolower ( $ type ) ; $ widget = $ this -> container -> get ( $ widgetAlias ) ; $ widget -> setMode ( $ mode ) ; return $ widget ; } | create a new WidgetRedactor . |
27,747 | public function getTemplateName ( $ action , Widget $ widget ) { $ templateName = 'VictoireWidget' . $ this -> getWidgetName ( $ widget ) . 'Bundle::' . $ action . '.html.twig' ; return $ templateName ; } | Get the name of the template to display for an action . |
27,748 | public function deleteById ( $ widgetId ) { $ entityManager = $ this -> container -> get ( 'doctrine.orm.entity_manager' ) ; $ connection = $ entityManager -> getConnection ( ) ; $ statement = $ connection -> prepare ( 'DELETE FROM vic_widget WHERE id = :id' ) ; $ statement -> bindValue ( 'id' , $ widgetId ) ; $ statement -> execute ( ) ; } | Delete manually a widget with its id . |
27,749 | protected function execute ( InputInterface $ input , OutputInterface $ output ) { $ viewHelper = $ this -> getContainer ( ) -> get ( 'victoire_core.view_helper' ) ; $ viewsReferences = $ viewHelper -> buildViewsReferences ( ) ; $ this -> getContainer ( ) -> get ( 'victoire_view_reference.manager' ) -> saveReferences ( $ viewsReferences ) ; $ output -> writeln ( '<info>The ViewReference has been generated.</info>' ) ; } | Read declared business entities and BusinessEntityPatternPages to generate their urls . |
27,750 | public function generate ( GlobalConfig $ globalConfig , $ path = 'faviconConfig.json' ) { return $ this -> generateFromConfigFile ( $ this -> faviconConfigDumper -> dump ( $ globalConfig , $ path ) ) ; } | Generate favicons from realfavicon generator and a GlobalConfig object . |
27,751 | public function updateWidgetMap ( $ widgetMap ) { foreach ( $ this -> widgetMaps as $ key => $ _widgetMap ) { if ( $ _widgetMap -> getWidgetId ( ) === $ widgetMap -> getWidgetId ( ) ) { $ this -> widgetMaps [ $ key ] = $ widgetMap ; break ; } } return $ this ; } | Update the given widgetMap . |
27,752 | public function getWidgetMapByWidgetId ( $ widgetId ) { $ widgetMap = null ; $ widgetMaps = $ this -> widgetMaps ; foreach ( $ widgetMaps as $ wm ) { if ( $ wm -> getWidgetId ( ) === $ widgetId ) { $ widgetMap = $ wm ; break ; } } return $ widgetMap ; } | Get the widget map by the widget id . |
27,753 | public function removeWidgetMap ( WidgetMap $ widgetMap ) { $ widgetMaps = $ this -> widgetMaps ; foreach ( $ widgetMaps as $ index => $ wm ) { if ( $ wm -> getWidgetId ( ) === $ widgetMap -> getWidgetId ( ) ) { unset ( $ this -> widgetMaps [ $ index ] ) ; break ; } } } | Remove the widget map from the slot . |
27,754 | public function renderIcon ( $ icon , $ inverted = false ) { $ template = $ this -> getIconTemplate ( ) ; $ context = [ 'icon' => $ icon , 'inverted' => $ inverted , ] ; return $ template -> renderBlock ( $ this -> iconSet , $ context ) ; } | Renders the icon . |
27,755 | public function updateViewReference ( ViewReferenceEvent $ event ) { $ view = $ event -> getView ( ) ; if ( $ viewReference = $ this -> viewReferenceBuilder -> buildViewReference ( $ view , $ this -> em ) ) { $ this -> viewReferenceManager -> saveReference ( $ viewReference ) ; } } | This method is call when a viewReference need to be update . |
27,756 | public function removeViewReference ( ViewReferenceEvent $ event ) { $ view = $ event -> getView ( ) ; if ( $ viewReference = $ this -> viewReferenceBuilder -> buildViewReference ( $ view , $ this -> em ) ) { $ this -> viewReferenceManager -> removeReference ( $ viewReference ) ; } } | This method is call when a viewReference need to be remove . |
27,757 | public function getInstance ( $ alias = null ) { if ( ! $ alias && ! $ this -> mainAlias ) { $ namespace = explode ( '\\' , $ this -> _entityName ) ; $ alias = strtolower ( end ( $ namespace ) ) ; $ this -> mainAlias = $ alias ; } elseif ( $ alias ) { $ this -> mainAlias = $ alias ; } return $ this -> qb ? $ this -> qb : $ this -> qb = $ this -> createQueryBuilder ( $ this -> mainAlias ) ; } | Get query builder instance . |
27,758 | public function run ( $ method = 'getResult' , $ hydrationMode = Query :: HYDRATE_OBJECT , $ autoClear = true ) { $ results = $ this -> qb -> getQuery ( ) -> $ method ( $ hydrationMode ) ; if ( $ autoClear ) { $ this -> clearInstance ( ) ; } return $ results ; } | Run active query . |
27,759 | public function getCurrent ( ) { if ( $ this -> currentCache !== null ) { return $ this -> currentCache ; } $ active = null ; do { $ children = $ this -> getChildren ( $ active ) ; $ foundActiveChild = false ; foreach ( $ children as $ child ) { if ( $ child -> getActive ( ) ) { $ foundActiveChild = true ; $ active = $ child ; break ; } } } while ( $ foundActiveChild ) ; $ this -> currentCache = $ active ; return $ active ; } | Get current menu item . |
27,760 | public function getBreadCrumb ( ) { $ result = [ ] ; $ current = $ this -> getCurrent ( ) ; while ( ! is_null ( $ current ) ) { array_unshift ( $ result , $ current ) ; $ current = $ current -> getParent ( ) ; } return $ result ; } | Get breadcrumb path for current menu item . |
27,761 | public function getTopChildren ( ) { if ( is_null ( $ this -> topMenuItems ) ) { $ this -> topMenuItems = [ ] ; foreach ( $ this -> adaptors as $ menuAdaptor ) { $ menuAdaptor -> adaptChildren ( $ this , $ this -> topMenuItems , null , $ this -> getRequest ( ) ) ; } } return $ this -> topMenuItems ; } | Get all top menu items . |
27,762 | public function getChildren ( MenuItem $ parent = null ) { if ( $ parent == null ) { return $ this -> getTopChildren ( ) ; } $ result = [ ] ; foreach ( $ this -> adaptors as $ menuAdaptor ) { $ menuAdaptor -> adaptChildren ( $ this , $ result , $ parent , $ this -> getRequest ( ) ) ; } return $ result ; } | Get immediate children of the specified menu item . |
27,763 | public function checkLink ( ExecutionContextInterface $ context ) { $ violation = false ; switch ( $ this -> getLinkType ( ) ) { case self :: TYPE_VIEW_REFERENCE : $ violation = $ this -> getViewReference ( ) == null ; break ; case self :: TYPE_ROUTE : $ violation = $ this -> getRoute ( ) == null ; break ; case self :: TYPE_URL : $ violation = $ this -> getUrl ( ) == null ; break ; case self :: TYPE_WIDGET : $ violation = $ this -> getAttachedWidget ( ) == null ; break ; default : break ; } if ( $ violation ) { $ context -> buildViolation ( 'validator.link.error.message.' . $ this -> getLinkType ( ) . 'Missing' ) -> addViolation ( ) ; } } | undocumented function . |
27,764 | protected function removeLastPart ( $ url ) { $ shortenUrl = null ; if ( $ url !== null && $ url !== '' ) { $ keywords = preg_split ( "/\//" , $ url ) ; if ( count ( $ keywords ) > 0 ) { array_pop ( $ keywords ) ; $ shortenUrl = implode ( '/' , $ keywords ) ; } } return $ shortenUrl ; } | Remove the last part of the url . |
27,765 | protected function extractPartByPosition ( $ url , $ position ) { $ part = null ; if ( $ url !== null && $ url !== '' ) { $ keywords = preg_split ( "/\//" , $ url ) ; if ( count ( $ keywords ) > 0 ) { $ part = $ keywords [ $ position - 1 ] ; } } return $ part ; } | Extract a part of the url . |
27,766 | public function findByEntityInstance ( $ entity ) { $ businessEntity = null ; $ class = new \ ReflectionClass ( $ entity ) ; while ( ! $ businessEntity && $ class && $ class -> name !== null ) { $ businessEntity = $ this -> findByEntityClassname ( $ class -> name ) ; $ class = $ class -> getParentClass ( ) ; } return $ businessEntity ; } | Get a business entity . |
27,767 | public function findByEntityClassname ( $ classname ) { $ businessEntities = $ this -> getBusinessEntities ( ) ; $ businessEntity = null ; foreach ( $ businessEntities as $ tempBusinessEntity ) { if ( $ tempBusinessEntity -> getClass ( ) === $ classname ) { $ businessEntity = $ tempBusinessEntity ; continue ; } } return $ businessEntity ; } | Get a business entity by classname . |
27,768 | protected function findEntityByBusinessEntityAndAttribute ( BusinessEntity $ businessEntity , $ attributeName , $ attributeValue ) { if ( ! $ this -> entityManager ) { throw new \ Exception ( 'EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service' ) ; } $ class = $ businessEntity -> getClass ( ) ; $ repo = $ this -> entityManager -> getRepository ( $ class ) ; $ functionName = 'findOneBy' . ucfirst ( $ attributeName ) ; $ entity = call_user_func ( [ $ repo , $ functionName ] , $ attributeValue ) ; return $ entity ; } | Find a entity by the business entity and the attributeValue . Must be called by the service victoire_core . helper . queriable_business_entity_helper . |
27,769 | public function getEntityByPageAndBusinessIdentifier ( BusinessTemplate $ page , $ entityIdentifier , $ attributeName ) { if ( ! $ this -> entityManager ) { throw new \ Exception ( 'EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service' ) ; } $ entity = null ; $ businessEntityId = $ page -> getBusinessEntityId ( ) ; $ businessEntity = $ this -> findById ( $ businessEntityId ) ; if ( $ businessEntity === null ) { throw new \ Exception ( 'The business entity [' . $ businessEntityId . '] was not found.' ) ; } $ entity = $ this -> findEntityByBusinessEntityAndAttribute ( $ businessEntity , $ attributeName , $ entityIdentifier ) ; if ( $ entity === null ) { throw new \ Exception ( 'The entity [' . $ entityIdentifier . '] was not found.' ) ; } return $ entity ; } | Get the entity from the page and the id given . Must be called by the service victoire_core . helper . queriable_business_entity_helper . |
27,770 | public static function createBusinessEntity ( $ className , array $ businessProperties ) { $ businessEntity = new BusinessEntity ( ) ; $ classNameArray = explode ( '\\' , $ className ) ; $ entityName = array_pop ( $ classNameArray ) ; $ businessEntity -> setId ( strtolower ( $ entityName ) ) ; $ businessEntity -> setName ( $ entityName ) ; $ businessEntity -> setClass ( $ className ) ; foreach ( $ businessProperties as $ type => $ properties ) { foreach ( $ properties as $ property ) { $ businessProperty = new BusinessProperty ( ) ; $ businessProperty -> setType ( $ type ) ; $ businessProperty -> setEntityProperty ( $ property ) ; $ businessEntity -> addBusinessProperty ( $ businessProperty ) ; unset ( $ businessProperty ) ; } } return $ businessEntity ; } | create a BusinessEntity from an annotation object . |
27,771 | public function getByBusinessEntityAndId ( BusinessEntity $ businessEntity , $ id ) { if ( ! $ this -> entityManager ) { throw new \ Exception ( 'EntityManager not defined, you should use the "victoire_core.helper.queriable_business_entity_helper" service' ) ; } return $ this -> entityManager -> getRepository ( $ businessEntity -> getClass ( ) ) -> findOneById ( $ id ) ; } | Must be called by the service victoire_core . helper . queriable_business_entity_helper . |
27,772 | public function cmsPageCss ( ) { $ currentView = $ this -> currentViewHelper -> getCurrentView ( ) ; if ( ! $ currentView || ! $ this -> viewCssBuilder -> cssFileExists ( $ currentView ) ) { return '<!-- CSS File not found ; } return sprintf ( '<link href="%s" rel="stylesheet" type="text/css" rel="stylesheet"/>' , $ this -> viewCssBuilder -> getHref ( $ currentView ) ) ; } | Construct CSS link markup for the style of all the Widgets contained in the current View . |
27,773 | protected function getChildrenUrls ( BasePage $ page ) { $ urls = [ ] ; $ children = $ page -> getInstances ( ) ; foreach ( $ children as $ child ) { $ url = $ child -> getUrl ( ) ; $ urls [ ] = $ url ; unset ( $ url ) ; } return $ urls ; } | Get the list of urls of the children . |
27,774 | public function getAllClassNames ( ) { if ( ! $ this -> paths ) { throw MappingException :: pathRequired ( ) ; } $ classes = [ ] ; $ includedFiles = [ ] ; foreach ( $ this -> paths as $ path ) { if ( ! is_dir ( $ path ) ) { $ this -> logger -> warning ( sprintf ( 'The given path "%s" seems to be incorrect. You need to edit victoire_core.base_paths configuration.' , $ path ) ) ; continue ; } $ iterator = new \ RegexIterator ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path , \ FilesystemIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: LEAVES_ONLY ) , $ this -> regex , \ RecursiveRegexIterator :: GET_MATCH ) ; foreach ( $ iterator as $ file ) { $ sourceFile = realpath ( $ file [ 0 ] ) ; $ includedFiles [ ] = $ sourceFile ; } } foreach ( $ includedFiles as $ fileName ) { $ class = $ this -> getClassNameFromFile ( $ fileName ) ; if ( class_exists ( $ class ) && ! $ this -> isTransient ( $ class ) ) { $ classes [ ] = $ class ; } } return $ classes ; } | Get all class names . |
27,775 | public function parse ( \ ReflectionClass $ class ) { $ classPath = dirname ( $ class -> getFileName ( ) ) ; $ inPaths = false ; foreach ( $ this -> paths as $ key => $ _path ) { if ( strpos ( $ classPath , realpath ( $ _path ) ) === 0 ) { $ inPaths = true ; } } if ( $ inPaths ) { $ classAnnotations = $ this -> reader -> getClassAnnotations ( $ class ) ; if ( ! empty ( $ classAnnotations ) ) { foreach ( $ classAnnotations as $ key => $ annot ) { if ( ! is_numeric ( $ key ) ) { continue ; } $ classAnnotations [ get_class ( $ annot ) ] = $ annot ; } } if ( isset ( $ classAnnotations [ 'Victoire\Bundle\CoreBundle\Annotations\BusinessEntity' ] ) ) { $ annotationObj = $ classAnnotations [ 'Victoire\Bundle\CoreBundle\Annotations\BusinessEntity' ] ; $ businessEntity = BusinessEntityHelper :: createBusinessEntity ( $ class -> getName ( ) , $ this -> loadBusinessProperties ( $ class ) ) ; $ event = new BusinessEntityAnnotationEvent ( $ businessEntity , $ annotationObj -> getWidgets ( ) ) ; $ this -> eventDispatcher -> dispatch ( 'victoire.business_entity_annotation_load' , $ event ) ; } $ parentClass = $ class -> getParentClass ( ) ; $ isWidget = false ; while ( $ parentClass && ( $ parentClass = $ parentClass -> getParentClass ( ) ) && ! $ isWidget && $ parentClass -> name != null ) { $ isWidget = $ parentClass -> name === 'Victoire\\Bundle\\WidgetBundle\\Model\\Widget' ; } if ( $ isWidget ) { if ( $ this -> widgetHelper -> isEnabled ( new $ class -> name ( ) ) ) { $ event = new WidgetAnnotationEvent ( $ this -> widgetHelper -> getWidgetName ( new $ class -> name ( ) ) , $ this -> loadReceiverProperties ( $ class ) ) ; $ this -> eventDispatcher -> dispatch ( 'victoire.widget_annotation_load' , $ event ) ; } else { error_log ( sprintf ( 'Widget name not found for widget %s. Is this widget declared in AppKernel ?' , $ class -> name ) ) ; } } } } | Parse the given Class to find some annotations related to BusinessEntities . |
27,776 | protected function loadBusinessProperties ( \ ReflectionClass $ class ) { $ businessProperties = [ ] ; $ properties = $ class -> getProperties ( ) ; $ traits = $ class -> getTraits ( ) ; $ className = $ class -> getName ( ) ; if ( array_key_exists ( Translatable :: class , $ traits ) ) { $ translation = new \ ReflectionClass ( $ className :: getTranslationEntityClass ( ) ) ; $ translationProperties = $ translation -> getProperties ( ) ; $ properties = array_merge ( $ properties , $ translationProperties ) ; } foreach ( $ properties as $ property ) { $ annotations = $ this -> reader -> getPropertyAnnotations ( $ property ) ; foreach ( $ annotations as $ key => $ annotationObj ) { if ( $ annotationObj instanceof BusinessProperty && ! in_array ( $ class , $ businessProperties ) ) { if ( ! $ annotations [ $ key ] -> getTypes ( ) ) { $ message = $ class -> name . ':$' . $ property -> name . '" field' ; throw AnnotationException :: requiredError ( 'type' , 'BusinessProperty annotation' , $ message , 'array or string' ) ; } foreach ( $ annotations [ $ key ] -> getTypes ( ) as $ type ) { $ businessProperties [ $ type ] [ ] = $ property -> name ; } } } } $ parentClass = $ class -> getParentClass ( ) ; if ( $ parentClass ) { $ parentProperties = $ this -> loadBusinessProperties ( new \ ReflectionClass ( $ parentClass -> getName ( ) ) ) ; foreach ( $ parentProperties as $ key => $ parentProperty ) { if ( array_key_exists ( $ key , $ businessProperties ) ) { $ businessProperties [ $ key ] = array_unique ( array_merge ( $ parentProperty , $ businessProperties [ $ key ] ) ) ; } else { $ businessProperties [ $ key ] = $ parentProperty ; } } } return $ businessProperties ; } | load business properties from ReflectionClass . |
27,777 | protected function loadReceiverProperties ( \ ReflectionClass $ class ) { $ receiverPropertiesTypes = [ ] ; $ properties = $ class -> getProperties ( ) ; foreach ( $ properties as $ property ) { $ annotations = $ this -> reader -> getPropertyAnnotations ( $ property ) ; foreach ( $ annotations as $ key => $ annotationObj ) { if ( $ annotationObj instanceof ReceiverPropertyAnnotation && ! in_array ( $ class , $ receiverPropertiesTypes ) ) { if ( ! $ annotations [ $ key ] -> getTypes ( ) ) { $ message = $ class -> name . ':$' . $ property -> name . '" field' ; throw AnnotationException :: requiredError ( 'type' , 'ReceiverProperty annotation' , $ message , 'array or string' ) ; } foreach ( $ annotations [ $ key ] -> getTypes ( ) as $ type ) { $ receiverProperty = new ReceiverProperty ( ) ; $ receiverProperty -> setFieldName ( $ property -> name ) ; $ receiverPropertiesTypes [ $ type ] [ ] = $ receiverProperty ; } } } } foreach ( $ receiverPropertiesTypes as $ type => $ receiverProperties ) { foreach ( $ receiverProperties as $ receiverProperty ) { $ receiverPropertyName = $ receiverProperty -> getFieldName ( ) ; $ refProperty = $ class -> getProperty ( $ receiverPropertyName ) ; $ annotations = $ this -> reader -> getPropertyAnnotations ( $ refProperty ) ; foreach ( $ annotations as $ key => $ annotationObj ) { if ( $ annotationObj instanceof Column && $ annotationObj -> nullable === false ) { throw new Exception ( sprintf ( 'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence must have "nullable=true" for ORM\Column annotation' , $ refProperty -> name , $ refProperty -> class ) ) ; } elseif ( $ annotationObj instanceof NotBlank ) { throw new Exception ( sprintf ( 'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotBlank annotation' , $ refProperty -> name , $ refProperty -> class ) ) ; } elseif ( $ annotationObj instanceof NotNull ) { throw new Exception ( sprintf ( 'Property "%s" in class "%s" has a @ReceiverProperty annotation and by consequence can not use NotNull annotation' , $ refProperty -> name , $ refProperty -> class ) ) ; } elseif ( $ annotationObj instanceof ReceiverPropertyAnnotation && $ annotationObj -> isRequired ( ) ) { $ receiverProperty -> setRequired ( true ) ; } } } } return $ receiverPropertiesTypes ; } | Load receiver properties and NotBlank constraints from ReflectionClass . |
27,778 | public function getMainItem ( ) { $ menuPage = $ this -> menuBuilder -> getTopNavbar ( ) -> getChild ( 'menu.page' ) ; if ( $ menuPage ) { return $ menuPage ; } else { return $ this -> menuBuilder -> createDropdownMenuItem ( $ this -> menuBuilder -> getTopNavbar ( ) , 'menu.page' ) ; } } | Get the main item . |
27,779 | public function setCurrentView ( View $ currentView ) { if ( $ this -> currentView == null ) { $ this -> currentView = clone $ currentView ; } $ this -> updatedCurrentView = $ currentView ; return $ this ; } | Set currentView . |
27,780 | protected function addChildrenField ( $ form ) { $ form -> add ( 'children' , CollectionType :: class , [ 'entry_type' => self :: class , 'required' => false , 'allow_add' => true , 'allow_delete' => true , 'prototype' => true , 'by_reference' => false , ] ) ; } | Add the items field to the form . |
27,781 | public function setChildren ( $ children ) { $ this -> children = $ children ; if ( $ children !== null ) { foreach ( $ children as $ child ) { $ child -> setParent ( $ this ) ; } } return $ this ; } | Set children . |
27,782 | public function addWidgetMap ( WidgetMap $ widgetMap ) { if ( ! $ widgetMap -> getView ( ) ) { $ widgetMap -> setView ( $ this ) ; } $ this -> widgetMaps [ ] = $ widgetMap ; } | Add WidgetMap . |
27,783 | public function getWidgetMapsForViewAndTemplates ( ) { $ widgetMaps = [ ] ; foreach ( $ this -> getWidgetMaps ( ) as $ _widgetMap ) { $ widgetMaps [ ] = $ _widgetMap ; } if ( $ template = $ this -> getTemplate ( ) ) { $ templateWidgetMaps = $ template -> getWidgetMapsForViewAndTemplates ( ) ; $ widgetMaps = array_merge ( $ widgetMaps , $ templateWidgetMaps ) ; } return $ widgetMaps ; } | Get WidgetMaps for View and its Templates . |
27,784 | public function getReference ( $ locale = null ) { $ locale = $ locale ? : $ this -> getCurrentLocale ( ) ; if ( is_array ( $ this -> references ) && isset ( $ this -> references [ $ locale ] ) ) { return $ this -> references [ $ locale ] ; } } | Get reference according to the current locale . |
27,785 | public function setReference ( ViewReference $ reference = null , $ locale = null ) { $ locale = $ locale ? : $ this -> getCurrentLocale ( ) ; $ this -> references [ $ locale ] = $ reference ; return $ this ; } | Set reference . |
27,786 | public function getQueryBuilder ( VictoireQueryInterface $ containerEntity , EntityManager $ em ) { if ( $ containerEntity === null ) { throw new \ Exception ( 'The container entity parameter must not be null.' ) ; } $ businessEntityId = $ containerEntity -> getBusinessEntityId ( ) ; if ( $ businessEntityId === null || $ businessEntityId === '' ) { $ containerId = $ containerEntity -> getId ( ) ; throw new \ Exception ( 'The container entity [' . $ containerId . '] does not have any businessEntityId.' ) ; } $ businessEntity = $ this -> businessEntityHelper -> findById ( strtolower ( $ businessEntityId ) ) ; if ( $ businessEntity === null ) { throw new \ Exception ( 'The business entity was not found for the id:[' . $ businessEntityId . ']' ) ; } $ businessClass = $ businessEntity -> getClass ( ) ; $ itemsQueryBuilder = $ em -> createQueryBuilder ( ) -> select ( 'main_item' ) -> from ( $ businessClass , 'main_item' ) -> andWhere ( 'main_item.visibleOnFront = 1' ) ; $ view = null ; if ( $ containerEntity instanceof View ) { $ view = $ containerEntity ; } elseif ( $ containerEntity instanceof Widget ) { $ view = $ containerEntity -> getCurrentView ( ) ; } if ( $ view && in_array ( Translatable :: class , class_uses ( $ businessClass ) ) ) { $ itemsQueryBuilder -> join ( 'main_item.translations' , 'translation' ) -> andWhere ( 'translation.locale = :locale' ) -> setParameter ( ':locale' , $ view -> getCurrentLocale ( ) ) ; } $ refClass = new \ ReflectionClass ( $ businessClass ) ; if ( $ refClass -> hasMethod ( 'getDeletedAt' ) ) { $ itemsQueryBuilder -> andWhere ( 'main_item.deletedAt IS NULL' ) ; } return $ itemsQueryBuilder ; } | Get the query builder base . This makes a select from item XXX use the item for doing the left join or where dql . |
27,787 | private function isAssociationField ( \ ReflectionProperty $ field ) { $ annotations = $ this -> reader -> getPropertyAnnotations ( $ field ) ; foreach ( $ annotations as $ key => $ annotationObj ) { if ( $ annotationObj instanceof OneToOne || $ annotationObj instanceof OneToMany || $ annotationObj instanceof ManyToOne || $ annotationObj instanceof ManyToMany ) { return true ; } } return false ; } | Check if field is a OneToOne OneToMany ManyToOne or ManyToMany association . |
27,788 | public function getAll ( $ excludeUnpublished = false ) { $ this -> qb = $ this -> getInstance ( ) ; if ( $ excludeUnpublished ) { $ this -> qb -> andWhere ( $ this -> mainAlias . '.status = :status' ) -> orWhere ( $ this -> mainAlias . '.status = :scheduled_status AND ' . $ this -> mainAlias . '.publishedAt > :publicationDate' ) -> setParameter ( 'status' , PageStatus :: PUBLISHED ) -> setParameter ( 'scheduled_status' , PageStatus :: SCHEDULED ) -> setParameter ( 'publicationDate' , new \ DateTime ( ) ) ; } return $ this ; } | Get all rentals in the repository . |
27,789 | public function findByViewReferences ( array $ viewReferences ) { $ pageIds = [ ] ; foreach ( $ viewReferences as $ viewReference ) { if ( $ viewReference instanceof BusinessPageReference ) { $ pageIds [ ] = $ viewReference -> getTemplateId ( ) ; } else { $ pageIds [ ] = $ viewReference -> getViewId ( ) ; } } $ qb = $ this -> getInstance ( ) ; $ qb -> andWhere ( $ this -> mainAlias . '.id IN (:pageIds)' ) -> setParameter ( 'pageIds' , $ pageIds ) ; $ pages = $ qb -> getQuery ( ) -> getResult ( ) ; foreach ( $ pages as $ page ) { $ pageId = $ page -> getId ( ) ; $ viewReference = array_filter ( $ viewReferences , function ( $ e ) use ( $ pageId ) { return $ e -> getViewId ( ) == $ pageId ; } ) ; if ( ! empty ( $ viewReference [ 0 ] ) ) { $ page -> setCurrentLocale ( $ viewReference [ 0 ] -> getLocale ( ) ) ; } } return $ pages ; } | Find a large amount of views by ViewReferences . |
27,790 | public function findOneByHomepage ( $ locale = 'fr' ) { $ qb = $ this -> getInstance ( ) ; $ qb -> where ( $ this -> mainAlias . '.homepage = true' ) -> andWhere ( $ this -> mainAlias . '.status = :status' ) -> setMaxResults ( 1 ) -> setParameter ( 'status' , PageStatus :: PUBLISHED ) ; $ query = $ qb -> getQuery ( ) ; $ view = $ query -> getOneOrNullResult ( ) ; $ view -> translate ( $ locale ) ; return $ view ; } | Get the view that is a page and a published one . |
27,791 | public function joinSeoTranslations ( $ locale ) { $ this -> getInstance ( ) -> leftJoin ( 'seo.translations' , 'translation' , Expr \ Join :: WITH , 'translation.locale = :locale' ) -> setParameter ( 'locale' , $ locale ) ; return $ this ; } | Join PageSeoTranslation to PageSeo for a locale . |
27,792 | public function joinTranslations ( $ locale ) { $ this -> getInstance ( ) -> innerJoin ( $ this -> mainAlias . '.translations' , 'translation' , Expr \ Join :: WITH , 'translation.locale = :locale' ) -> setParameter ( 'locale' , $ locale ) ; return $ this ; } | Join ViewTranslation for a locale . |
27,793 | public function getEntity ( $ entityId ) { if ( $ entityId == null ) { throw new \ Exception ( 'The businessEntityId is not defined for the entityProxy with the id:' . $ this -> getId ( ) ) ; } $ functionName = 'get' . ucfirst ( $ entityId ) ; $ entity = call_user_func ( [ $ this , $ functionName ] ) ; return $ entity ; } | Get the entity of the proxy . |
27,794 | public function whereIsNull ( string $ fieldName , string $ logicalOperator = LogicalOperator :: AND ) { return $ this -> where ( $ fieldName , 'is' , null , $ logicalOperator ) ; } | where field is null |
27,795 | public function getOne ( $ id ) { return $ this -> api -> request ( 'GET' , '/apps/' . $ id , [ 'Authorization' => 'Basic ' . $ this -> api -> getConfig ( ) -> getUserAuthKey ( ) , ] ) ; } | Get information about application with provided ID . |
27,796 | public function add ( array $ data ) { $ data = $ this -> resolverFactory -> createAppResolver ( ) -> resolve ( $ data ) ; return $ this -> api -> request ( 'POST' , '/apps' , [ 'Authorization' => 'Basic ' . $ this -> api -> getConfig ( ) -> getUserAuthKey ( ) , ] , json_encode ( $ data ) ) ; } | Create a new application with provided data . |
27,797 | public function update ( $ id , array $ data ) { $ data = $ this -> resolverFactory -> createAppResolver ( ) -> resolve ( $ data ) ; return $ this -> api -> request ( 'PUT' , '/apps/' . $ id , [ 'Authorization' => 'Basic ' . $ this -> api -> getConfig ( ) -> getUserAuthKey ( ) , ] , json_encode ( $ data ) ) ; } | Update application with provided data . |
27,798 | public function request ( $ method , $ uri , array $ headers = [ ] , $ body = null ) { try { $ response = $ this -> client -> send ( $ method , self :: API_URL . $ uri , array_merge ( [ 'Content-Type' => 'application/json' , ] , $ headers ) , $ body ) ; return json_decode ( $ response -> getBody ( ) , true ) ; } catch ( \ Throwable $ t ) { throw new OneSignalException ( $ t -> getMessage ( ) ) ; } catch ( \ Exception $ e ) { throw new OneSignalException ( $ e -> getMessage ( ) ) ; } } | Make a custom api request . |
27,799 | public function getOne ( $ id ) { $ query = [ 'app_id' => $ this -> api -> getConfig ( ) -> getApplicationId ( ) , ] ; return $ this -> api -> request ( 'GET' , '/players/' . $ id . '?' . http_build_query ( $ query ) ) ; } | Get information about device with provided ID . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.