idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
44,500
public function mapCollectionReferences ( array $ data ) : array { $ collectionReferences = [ ] ; foreach ( $ data as $ dataItem ) { $ collectionReferences [ ] = CollectionReference :: fromArray ( [ 'blockId' => ( int ) $ dataItem [ 'block_id' ] , 'blockStatus' => ( int ) $ dataItem [ 'block_status' ] , 'collectionId' ...
Maps data from database to collection reference values .
44,501
private function getRulePriority ( RuleCreateStruct $ ruleCreateStruct ) : int { if ( is_int ( $ ruleCreateStruct -> priority ) ) { return $ ruleCreateStruct -> priority ; } $ lowestRulePriority = $ this -> queryHandler -> getLowestRulePriority ( ) ; if ( $ lowestRulePriority !== null ) { return $ lowestRulePriority - ...
Returns the rule priority when creating a new rule .
44,502
public function buildQueryType ( string $ type , QueryTypeHandlerInterface $ handler , array $ config ) : QueryTypeInterface { $ parameterBuilder = $ this -> parameterBuilderFactory -> createParameterBuilder ( ) ; $ handler -> buildParameters ( $ parameterBuilder ) ; $ parameterDefinitions = $ parameterBuilder -> build...
Builds the query type .
44,503
private function getViewProvider ( $ value ) : ViewProviderInterface { foreach ( $ this -> viewProviders as $ viewProvider ) { if ( $ viewProvider -> supports ( $ value ) ) { return $ viewProvider ; } } throw ViewProviderException :: noViewProvider ( get_class ( $ value ) ) ; }
Returns the view provider that supports the given value .
44,504
public function renderBlock ( string $ blockName ) : string { if ( ! $ this -> template -> hasBlock ( $ blockName , $ this -> context , $ this -> blocks ) ) { return '' ; } $ level = ob_get_level ( ) ; ob_start ( ) ; try { $ this -> template -> displayBlock ( $ blockName , $ this -> context , $ this -> blocks ) ; } cat...
Renders the provided block . If block does not exist an empty string will be returned .
44,505
private function getRealName ( string $ name ) : string { if ( mb_strpos ( $ name , '@ngbm/' ) !== 0 ) { return $ name ; } if ( ! isset ( $ this -> templateMap [ $ name ] ) ) { $ this -> templateMap [ $ name ] = str_replace ( '@ngbm/' , '@ngbm_' . $ this -> configuration -> getParameter ( 'design' ) . '/' , $ name ) ; ...
Returns the name of the template converted from the virtual Twig namespace (
44,506
private function getThemeDirs ( ContainerBuilder $ container , array $ themeList ) : array { $ paths = array_map ( static function ( array $ bundleMetadata ) : string { return $ bundleMetadata [ 'path' ] . '/Resources/views/ngbm/themes' ; } , array_reverse ( $ container -> getParameter ( 'kernel.bundles_metadata' ) ) )...
Returns an array with all found paths for provided theme list .
44,507
private function getAppDir ( ContainerBuilder $ container ) : string { if ( $ container -> hasParameter ( 'kernel.project_dir' ) ) { return ( string ) $ container -> getParameter ( 'kernel.project_dir' ) . '/' . ( string ) $ container -> getParameter ( 'kernel.name' ) ; } return ( string ) $ container -> getParameter (...
Returns the current app dir abstracting Symfony 3 . 3 + where kernel . project_dir is available and Symfony 2 . 8 support where only kernel . root_dir exists .
44,508
private function buildVersionedValues ( iterable $ values , int $ version ) : Generator { foreach ( $ values as $ key => $ value ) { yield $ key => new VersionedValue ( $ value , $ version ) ; } }
Builds the list of VersionedValue objects for provided list of values .
44,509
private function updateQueryTranslations ( QueryTypeInterface $ queryType , PersistenceQuery $ persistenceQuery , APIQueryUpdateStruct $ queryUpdateStruct ) : PersistenceQuery { if ( $ queryUpdateStruct -> locale === $ persistenceQuery -> mainLocale ) { $ persistenceQuery = $ this -> collectionHandler -> updateQueryTra...
Updates translations for specified query .
44,510
public function setConfigStruct ( string $ configKey , ConfigStruct $ configStruct ) : void { $ this -> configStructs [ $ configKey ] = $ configStruct ; }
Sets the config struct to this struct .
44,511
public function getConfigStruct ( string $ configKey ) : ConfigStruct { if ( ! $ this -> hasConfigStruct ( $ configKey ) ) { throw ConfigException :: noConfigStruct ( $ configKey ) ; } return $ this -> configStructs [ $ configKey ] ; }
Gets the config struct with provided config key .
44,512
private function createItemPosition ( Collection $ collection , ? int $ newPosition ) : int { if ( ! $ this -> isCollectionDynamic ( $ collection ) ) { return $ this -> positionHelper -> createPosition ( $ this -> getPositionHelperItemConditions ( $ collection -> id , $ collection -> status ) , $ newPosition ) ; } if (...
Creates space for a new manual item by shifting positions of other items below the new position .
44,513
private function moveItemToPosition ( Collection $ collection , Item $ item , int $ newPosition ) : int { if ( ! $ this -> isCollectionDynamic ( $ collection ) ) { return $ this -> positionHelper -> moveToPosition ( $ this -> getPositionHelperItemConditions ( $ collection -> id , $ collection -> status ) , $ item -> po...
Moves the item to provided position .
44,514
private function importData ( string $ data ) : int { $ errorCount = 0 ; foreach ( $ this -> importer -> importData ( $ data ) as $ index => $ result ) { if ( $ result instanceof SuccessResult ) { $ this -> io -> note ( sprintf ( 'Imported %1$s #%2$d into %1$s ID %3$d' , $ result -> getEntityType ( ) , $ index + 1 , $ ...
Import new entities from the given data and returns the error count .
44,515
public function hasItem ( int $ position ) : bool { return $ this -> items -> exists ( static function ( $ key , APIItem $ item ) use ( $ position ) : bool { return $ item -> getPosition ( ) === $ position ; } ) ; }
Returns if the item exists at specified position .
44,516
public function getItem ( int $ position ) : ? APIItem { foreach ( $ this -> items as $ item ) { if ( $ item -> getPosition ( ) === $ position ) { return $ item ; } } return null ; }
Returns the item at specified position .
44,517
private function getMaxPages ( Block $ block ) : ? int { if ( ! $ block -> getDefinition ( ) -> hasPlugin ( PagedCollectionsPlugin :: class ) ) { return null ; } if ( $ block -> getParameter ( 'paged_collections:enabled' ) -> getValue ( ) !== true ) { return null ; } return $ block -> getParameter ( 'paged_collections:...
Returns the maximum number of the pages for the provided block if paging is enabled and maximum number of pages is set for a block .
44,518
public function buildItemDefinition ( string $ valueType , array $ configDefinitionHandlers ) : ItemDefinitionInterface { $ configDefinitions = [ ] ; foreach ( $ configDefinitionHandlers as $ configKey => $ configDefinitionHandler ) { $ configDefinitions [ $ configKey ] = $ this -> configDefinitionFactory -> buildConfi...
Builds the item definition .
44,519
public function newBlockCreateStruct ( BlockDefinitionInterface $ blockDefinition ) : BlockCreateStruct { $ viewTypeIdentifier = $ blockDefinition -> getViewTypeIdentifiers ( ) [ 0 ] ; $ viewType = $ blockDefinition -> getViewType ( $ viewTypeIdentifier ) ; $ itemViewTypeIdentifier = $ viewType -> getItemViewTypeIdenti...
Creates a new block create struct from data found in provided block definition .
44,520
public function newBlockUpdateStruct ( string $ locale , ? Block $ block = null ) : BlockUpdateStruct { $ blockUpdateStruct = new BlockUpdateStruct ( ) ; $ blockUpdateStruct -> locale = $ locale ; if ( ! $ block instanceof Block ) { return $ blockUpdateStruct ; } $ blockUpdateStruct -> viewType = $ block -> getViewType...
Creates a new block update struct in specified locale .
44,521
private function getNodes ( ) : array { return [ new ConfigurationNode \ ViewNode ( ) , new ConfigurationNode \ DesignNode ( ) , new ConfigurationNode \ DesignListNode ( ) , new ConfigurationNode \ DefaultViewTemplatesNode ( ) , new ConfigurationNode \ HttpCacheNode ( ) , new ConfigurationNode \ BlockDefinitionNode ( )...
Returns available configuration nodes for the bundle .
44,522
private function updateLayoutModifiedDate ( Layout $ layout ) : void { $ updatedLayout = clone $ layout ; $ updatedLayout -> modified = time ( ) ; $ this -> queryHandler -> updateLayout ( $ updatedLayout ) ; }
Updates the layout modified date to the current timestamp .
44,523
private function setTotalCount ( ResultSet $ result ) : void { $ this -> totalCount = $ result -> getTotalCount ( ) - $ this -> startingOffset ; $ this -> totalCount = $ this -> totalCount > 0 ? $ this -> totalCount : 0 ; if ( $ this -> maxTotalCount !== null && $ this -> totalCount >= $ this -> maxTotalCount ) { $ thi...
Sets the total count of the results to the adapter while taking into account the injected maximum number of pages to use .
44,524
public function onView ( GetResponseForControllerResultEvent $ event ) : void { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ controllerResult = $ event -> getControllerResult ( ) ; if ( ! $ controllerResult instanceof ViewInterface ) { return ; } $ event -> getRequest ( ) -> attributes -> set ( 'ngbmView' , $...
Sets the Netgen Layouts view provided by the controller to the request .
44,525
private function parseJson ( string $ data ) : stdClass { $ data = json_decode ( $ data ) ; if ( $ data instanceof stdClass ) { return $ data ; } $ errorCode = json_last_error ( ) ; if ( $ errorCode !== JSON_ERROR_NONE ) { throw JsonValidationException :: parseError ( json_last_error_msg ( ) , $ errorCode ) ; } throw J...
Parses JSON data .
44,526
public function buildConfigUpdateStructs ( ConfigAwareValue $ configAwareValue , ConfigAwareStruct $ configAwareStruct ) : void { foreach ( $ configAwareValue -> getConfigs ( ) as $ configKey => $ config ) { $ configStruct = new ConfigStruct ( ) ; $ configStruct -> fillParametersFromConfig ( $ config ) ; $ configAwareS...
Fills the provided config aware struct with config structs according to the provided value .
44,527
public static function buildValueType ( string $ identifier , array $ config ) : ValueType { return ValueType :: fromArray ( [ 'identifier' => $ identifier , 'isEnabled' => $ config [ 'enabled' ] , 'name' => $ config [ 'name' ] , ] ) ; }
Builds the value type .
44,528
public function setVoters ( array $ voters ) : void { $ this -> voters = array_filter ( $ voters , static function ( VisibilityVoterInterface $ voter ) : bool { return true ; } ) ; }
Sets the available voters .
44,529
public function loadLayoutData ( $ layoutId , int $ status ) : array { $ query = $ this -> getLayoutSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'l.id' , ':id' ) ) -> setParameter ( 'id' , $ layoutId , Type :: INTEGER ) ; $ this -> applyStatusCondition ( $ query , $ status , 'l.status' ) ; return $ ...
Loads all data for layout with specified ID .
44,530
public function loadRelatedLayoutsData ( Layout $ sharedLayout ) : array { $ query = $ this -> getLayoutSelectQuery ( ) ; $ query -> innerJoin ( 'l' , 'ngbm_zone' , 'z' , $ query -> expr ( ) -> andX ( $ query -> expr ( ) -> eq ( 'z.layout_id' , 'l.id' ) , $ query -> expr ( ) -> eq ( 'z.status' , 'l.status' ) , $ query ...
Loads all data for layouts related to provided shared layout .
44,531
public function getRelatedLayoutsCount ( Layout $ sharedLayout ) : int { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'count(DISTINCT ngbm_layout.id) AS count' ) -> from ( 'ngbm_layout' ) -> innerJoin ( 'ngbm_layout' , 'ngbm_zone' , 'z' , $ query -> expr ( ) -> andX ( $ query -> expr (...
Loads the count of layouts related to provided shared layout .
44,532
public function loadZoneData ( $ layoutId , int $ status , string $ identifier ) : array { $ query = $ this -> getZoneSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> andX ( $ query -> expr ( ) -> eq ( 'layout_id' , ':layout_id' ) , $ query -> expr ( ) -> eq ( 'identifier' , ':identifier' ) ) ) -> setParamet...
Loads all zone data with provided identifier .
44,533
public function loadLayoutZonesData ( Layout $ layout ) : array { $ query = $ this -> getZoneSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'layout_id' , ':layout_id' ) ) -> setParameter ( 'layout_id' , $ layout -> id , Type :: INTEGER ) -> orderBy ( 'identifier' , 'ASC' ) ; $ this -> applyStatusCondi...
Loads all data for zones that belong to provided layout .
44,534
public function zoneExists ( $ layoutId , int $ status , string $ identifier ) : bool { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'count(*) AS count' ) -> from ( 'ngbm_zone' ) -> where ( $ query -> expr ( ) -> andX ( $ query -> expr ( ) -> eq ( 'identifier' , ':identifier' ) , $ que...
Returns if the zone exists .
44,535
public function layoutNameExists ( string $ name , $ excludedLayoutId = null ) : bool { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'count(*) AS count' ) -> from ( 'ngbm_layout' ) -> where ( $ query -> expr ( ) -> andX ( $ query -> expr ( ) -> eq ( 'name' , ':name' ) ) ) -> setParamet...
Returns if the layout with provided name exists .
44,536
public function createLayout ( Layout $ layout ) : Layout { $ query = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'ngbm_layout' ) -> values ( [ 'id' => ':id' , 'status' => ':status' , 'type' => ':type' , 'name' => ':name' , 'description' => ':description' , 'created' => ':created' , 'modified' => ':modif...
Creates a layout .
44,537
public function createLayoutTranslation ( Layout $ layout , string $ locale ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'ngbm_layout_translation' ) -> values ( [ 'layout_id' => ':layout_id' , 'status' => ':status' , 'locale' => ':locale' , ] ) -> setParameter ( 'layout_id' , $ layout...
Creates a layout translation .
44,538
public function createZone ( Zone $ zone ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'ngbm_zone' ) -> values ( [ 'identifier' => ':identifier' , 'layout_id' => ':layout_id' , 'status' => ':status' , 'root_block_id' => ':root_block_id' , 'linked_layout_id' => ':linked_layout_id' , 'li...
Creates a zone .
44,539
public function updateLayout ( Layout $ layout ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngbm_layout' ) -> set ( 'type' , ':type' ) -> set ( 'name' , ':name' ) -> set ( 'description' , ':description' ) -> set ( 'created' , ':created' ) -> set ( 'modified' , ':modified' )...
Updates a layout .
44,540
public function updateZone ( Zone $ zone ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngbm_zone' ) -> set ( 'root_block_id' , ':root_block_id' ) -> set ( 'linked_layout_id' , ':linked_layout_id' ) -> set ( 'linked_zone_identifier' , ':linked_zone_identifier' ) -> where ( $ ...
Updates a zone .
44,541
public function deleteLayoutZones ( $ layoutId , ? int $ status = null ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> delete ( 'ngbm_zone' ) -> where ( $ query -> expr ( ) -> eq ( 'layout_id' , ':layout_id' ) ) -> setParameter ( 'layout_id' , $ layoutId , Type :: INTEGER ) ; if ( $ sta...
Deletes all layout zones .
44,542
public function deleteZone ( $ layoutId , string $ zoneIdentifier , ? int $ status = null ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> delete ( 'ngbm_zone' ) -> where ( $ query -> expr ( ) -> andX ( $ query -> expr ( ) -> eq ( 'layout_id' , ':layout_id' ) , $ query -> expr ( ) -> eq ...
Deletes the zone .
44,543
private function getZoneSelectQuery ( ) : QueryBuilder { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'DISTINCT ngbm_zone.*' ) -> from ( 'ngbm_zone' ) ; return $ query ; }
Builds and returns a zone database SELECT query .
44,544
private function validateAddItems ( Block $ block , string $ collectionIdentifier , $ items ) : void { $ this -> validate ( $ items , [ new Constraints \ Type ( [ 'type' => 'array' ] ) , new Constraints \ NotBlank ( ) , new Constraints \ All ( [ 'constraints' => new Constraints \ Collection ( [ 'fields' => [ 'value' =>...
Validates item creation parameters from the request .
44,545
private function validateCreateLayout ( ParameterBag $ data ) : void { $ this -> validate ( $ data -> get ( 'layout_type' ) , [ new Constraints \ NotBlank ( ) , new Constraints \ Type ( [ 'type' => 'string' ] ) , ] , 'layout_type' ) ; $ this -> validate ( $ data -> get ( 'locale' ) , [ new Constraints \ NotBlank ( ) , ...
Validates layout creation parameters from the request .
44,546
public function validateCollectionCreateStruct ( CollectionCreateStruct $ collectionCreateStruct ) : void { if ( $ collectionCreateStruct -> queryCreateStruct !== null ) { $ this -> validate ( $ collectionCreateStruct -> queryCreateStruct , [ new Constraints \ Type ( [ 'type' => QueryCreateStruct :: class ] ) , ] , 'qu...
Validates the provided collection create struct .
44,547
public function validateCollectionUpdateStruct ( Collection $ collection , CollectionUpdateStruct $ collectionUpdateStruct ) : void { if ( $ collectionUpdateStruct -> offset !== null ) { $ offsetConstraints = [ new Constraints \ NotBlank ( ) , new Constraints \ Type ( [ 'type' => 'int' ] ) , ] ; $ offsetConstraints [ ]...
Validates the provided collection update struct .
44,548
public function validateItemCreateStruct ( ItemCreateStruct $ itemCreateStruct ) : void { $ this -> validate ( $ itemCreateStruct -> definition , [ new Constraints \ NotNull ( ) , new Constraints \ Type ( [ 'type' => ItemDefinitionInterface :: class ] ) , ] , 'definition' ) ; if ( $ itemCreateStruct -> value !== null )...
Validates the provided item create struct .
44,549
public function validateItemUpdateStruct ( Item $ item , ItemUpdateStruct $ itemUpdateStruct ) : void { $ this -> validate ( $ itemUpdateStruct , new ConfigAwareStructConstraint ( [ 'payload' => $ item -> getDefinition ( ) , 'allowMissingFields' => true , ] ) ) ; }
Validates the provided item update struct .
44,550
public function validateQueryCreateStruct ( QueryCreateStruct $ queryCreateStruct ) : void { $ this -> validate ( $ queryCreateStruct , [ new ParameterStruct ( [ 'parameterDefinitions' => $ queryCreateStruct -> getQueryType ( ) , ] ) , ] , 'parameterValues' ) ; }
Validates the provided query create struct .
44,551
public function validateQueryUpdateStruct ( Query $ query , QueryUpdateStruct $ queryUpdateStruct ) : void { $ this -> validate ( $ queryUpdateStruct , [ new QueryUpdateStructConstraint ( [ 'payload' => $ query , ] ) , ] ) ; }
Validates the provided query update struct .
44,552
private function buildValueTypes ( ContainerBuilder $ container , array $ valueTypes ) : Generator { foreach ( $ valueTypes as $ identifier => $ valueType ) { $ this -> validateBrowserType ( $ container , $ identifier ) ; $ serviceIdentifier = sprintf ( 'netgen_block_manager.item.value_type.%s' , $ identifier ) ; $ con...
Builds the value type objects from provided configuration .
44,553
private function validateBrowserType ( ContainerBuilder $ container , string $ valueType ) : void { if ( $ container -> has ( sprintf ( 'netgen_content_browser.config.%s' , $ valueType ) ) ) { return ; } throw new RuntimeException ( sprintf ( 'Netgen Content Browser backend for "%s" value type does not exist.' , $ valu...
Validates that the provided Content Browser item type exists in the system .
44,554
public function getOption ( string $ option ) { if ( ! $ this -> hasOption ( $ option ) ) { throw ParameterException :: noOption ( $ option ) ; } return $ this -> options [ $ option ] ; }
Returns the provided parameter option .
44,555
public function getParameterDefinition ( string $ parameterName ) : ParameterDefinition { if ( ! $ this -> hasParameterDefinition ( $ parameterName ) ) { throw ParameterException :: noParameterDefinition ( $ parameterName ) ; } return $ this -> parameterDefinitions [ $ parameterName ] ; }
Returns the parameter definition with provided name .
44,556
public static function createFromTimestamp ( ? int $ timestamp = null , ? string $ timeZone = null ) : DateTimeInterface { $ dateTimeZone = is_string ( $ timeZone ) ? new DateTimeZone ( $ timeZone ) : null ; $ timestamp = is_int ( $ timestamp ) ? $ timestamp : time ( ) ; $ dateTime = new DateTimeImmutable ( 'now' , $ d...
Creates a new \ DateTimeImmutable instance from provided timestamp and timezone identifiers .
44,557
public static function createFromArray ( array $ datetime ) : ? DateTimeInterface { $ dateAndTime = $ datetime [ 'datetime' ] ?? '' ; $ timeZone = $ datetime [ 'timezone' ] ?? '' ; if ( $ dateAndTime === '' || ! is_string ( $ dateAndTime ) ) { return null ; } if ( $ timeZone === '' || ! is_string ( $ timeZone ) ) { ret...
Creates a new \ DateTimeImmutable instance from provided array .
44,558
public static function isBetweenDates ( ? DateTimeInterface $ date = null , ? DateTimeInterface $ from = null , ? DateTimeInterface $ to = null ) : bool { $ date = $ date ?? self :: createFromTimestamp ( ) ; if ( $ from instanceof DateTimeInterface && $ date < $ from ) { return false ; } if ( $ to instanceof DateTimeIn...
Returns if the provided DateTime instance is between the provided dates .
44,559
private static function parseTimeZone ( string $ timeZone ) : array { $ parts = explode ( '/' , $ timeZone ) ; if ( count ( $ parts ) > 2 ) { return [ $ parts [ 0 ] , $ parts [ 1 ] . ' / ' . $ parts [ 2 ] ] ; } if ( count ( $ parts ) > 1 ) { return [ $ parts [ 0 ] , $ parts [ 1 ] ] ; } return [ 'Other' , $ parts [ 0 ] ...
Returns the array with human readable region and timezone name for the provided timezone identifier .
44,560
public function getLayoutView ( ) { $ currentRequest = $ this -> requestStack -> getCurrentRequest ( ) ; $ masterRequest = $ this -> requestStack -> getMasterRequest ( ) ; if ( ! $ currentRequest instanceof Request || ! $ masterRequest instanceof Request ) { return null ; } if ( $ masterRequest -> attributes -> has ( '...
Returns the currently resolved layout view .
44,561
public function getLayout ( ) : ? Layout { $ layoutView = $ this -> getLayoutView ( ) ; if ( ! $ layoutView instanceof LayoutViewInterface ) { return null ; } return $ layoutView -> getLayout ( ) ; }
Returns the currently resolved layout or null if no layout was resolved .
44,562
public function getRule ( ) : ? Rule { $ layoutView = $ this -> getLayoutView ( ) ; if ( ! $ layoutView instanceof LayoutViewInterface ) { return null ; } return $ layoutView -> getParameter ( 'rule' ) ; }
Returns the rule used to resolve the current layout or null if no layout was resolved .
44,563
public function getPageLayoutTemplate ( ) : string { $ this -> pageLayoutTemplate = $ this -> pageLayoutTemplate ?? $ this -> pageLayoutResolver -> resolvePageLayout ( ) ; return $ this -> pageLayoutTemplate ; }
Returns the pagelayout template .
44,564
public function getLayoutTemplate ( string $ context = ViewInterface :: CONTEXT_DEFAULT ) : ? string { $ layoutView = $ this -> buildLayoutView ( $ context ) ; if ( ! $ layoutView instanceof LayoutViewInterface ) { return $ this -> getPageLayoutTemplate ( ) ; } return $ layoutView -> getTemplate ( ) ; }
Returns the currently valid layout template or base pagelayout if no layout was resolved .
44,565
private function buildLayoutView ( string $ context = ViewInterface :: CONTEXT_DEFAULT ) { $ currentRequest = $ this -> requestStack -> getCurrentRequest ( ) ; $ masterRequest = $ this -> requestStack -> getMasterRequest ( ) ; if ( ! $ currentRequest instanceof Request || ! $ masterRequest instanceof Request ) { return...
Resolves the used layout based on current conditions .
44,566
public function newLayoutCreateStruct ( LayoutTypeInterface $ layoutType , string $ name , string $ mainLocale ) : LayoutCreateStruct { $ struct = new LayoutCreateStruct ( ) ; $ struct -> layoutType = $ layoutType ; $ struct -> name = $ name ; $ struct -> mainLocale = $ mainLocale ; return $ struct ; }
Creates a new layout create struct from the provided values .
44,567
public function newLayoutUpdateStruct ( ? Layout $ layout = null ) : LayoutUpdateStruct { $ layoutUpdateStruct = new LayoutUpdateStruct ( ) ; if ( ! $ layout instanceof Layout ) { return $ layoutUpdateStruct ; } $ layoutUpdateStruct -> name = $ layout -> getName ( ) ; $ layoutUpdateStruct -> description = $ layout -> g...
Creates a new layout update struct .
44,568
public function newLayoutCopyStruct ( ? Layout $ layout = null ) : LayoutCopyStruct { $ layoutCopyStruct = new LayoutCopyStruct ( ) ; if ( ! $ layout instanceof Layout ) { return $ layoutCopyStruct ; } $ layoutCopyStruct -> name = $ layout -> getName ( ) . ' (copy)' ; return $ layoutCopyStruct ; }
Creates a new layout copy struct .
44,569
public function newTargetCreateStruct ( string $ type ) : TargetCreateStruct { $ struct = new TargetCreateStruct ( ) ; $ struct -> type = $ type ; return $ struct ; }
Creates a new target create struct from the provided values .
44,570
public function newConditionCreateStruct ( string $ type ) : ConditionCreateStruct { $ struct = new ConditionCreateStruct ( ) ; $ struct -> type = $ type ; return $ struct ; }
Creates a new condition create struct from the provided values .
44,571
private function disableUntranslatableForms ( FormBuilderInterface $ builder ) : void { foreach ( $ builder as $ form ) { $ innerType = $ form -> getType ( ) -> getInnerType ( ) ; $ disabled = ! $ innerType instanceof ParametersType ; $ parameterDefinition = $ form -> getOption ( 'ngbm_parameter_definition' ) ; if ( $ ...
Disables all inputs for parameters which are not translatable .
44,572
public function loadCollectionData ( $ collectionId , int $ status ) : array { $ query = $ this -> getCollectionSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'c.id' , ':id' ) ) -> setParameter ( 'id' , $ collectionId , Type :: INTEGER ) ; $ this -> applyStatusCondition ( $ query , $ status , 'c.statu...
Loads all collection data for collection with specified ID .
44,573
public function loadItemData ( $ itemId , int $ status ) : array { $ query = $ this -> getItemSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'id' , ':id' ) ) -> setParameter ( 'id' , $ itemId , Type :: INTEGER ) ; $ this -> applyStatusCondition ( $ query , $ status ) ; return $ query -> execute ( ) ->...
Loads all data for an item .
44,574
public function loadItemWithPositionData ( Collection $ collection , int $ position ) : array { $ query = $ this -> getItemSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> andX ( $ query -> expr ( ) -> eq ( 'collection_id' , ':collection_id' ) , $ query -> expr ( ) -> eq ( 'position' , ':position' ) ) ) -> s...
Loads an item with specified position in specified collection .
44,575
public function loadQueryData ( $ queryId , int $ status ) : array { $ query = $ this -> getQuerySelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'q.id' , ':id' ) ) -> setParameter ( 'id' , $ queryId , Type :: INTEGER ) ; $ this -> applyStatusCondition ( $ query , $ status , 'q.status' ) ; return $ quer...
Loads all data for a query .
44,576
public function loadCollectionItemsData ( Collection $ collection ) : array { $ query = $ this -> getItemSelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'collection_id' , ':collection_id' ) ) -> setParameter ( 'collection_id' , $ collection -> id , Type :: INTEGER ) ; $ this -> applyStatusCondition ( $...
Loads all data for items that belong to collection with specified ID .
44,577
public function loadCollectionQueryData ( Collection $ collection ) : array { $ query = $ this -> getQuerySelectQuery ( ) ; $ query -> where ( $ query -> expr ( ) -> eq ( 'q.collection_id' , ':collection_id' ) ) -> setParameter ( 'collection_id' , $ collection -> id , Type :: INTEGER ) ; $ this -> applyStatusCondition ...
Loads all data for queries that belong to collection with specified ID .
44,578
public function collectionExists ( $ collectionId , int $ status ) : bool { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'count(*) AS count' ) -> from ( 'ngbm_collection' ) -> where ( $ query -> expr ( ) -> eq ( 'id' , ':id' ) ) -> setParameter ( 'id' , $ collectionId , Type :: INTEGER...
Returns if the collection exists .
44,579
public function createCollectionTranslation ( Collection $ collection , string $ locale ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'ngbm_collection_translation' ) -> values ( [ 'collection_id' => ':collection_id' , 'status' => ':status' , 'locale' => ':locale' , ] ) -> setParameter ...
Creates a collection translation .
44,580
public function updateCollection ( Collection $ collection ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngbm_collection' ) -> set ( 'start' , ':start' ) -> set ( 'length' , ':length' ) -> set ( 'translatable' , ':translatable' ) -> set ( 'main_locale' , ':main_locale' ) -> ...
Updates a collection .
44,581
public function deleteCollectionTranslations ( $ collectionId , ? int $ status = null , ? string $ locale = null ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> delete ( 'ngbm_collection_translation' ) -> where ( $ query -> expr ( ) -> eq ( 'collection_id' , ':collection_id' ) ) -> setP...
Deletes collection translations .
44,582
public function updateItem ( Item $ item ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( 'ngbm_collection_item' ) -> set ( 'collection_id' , ':collection_id' ) -> set ( 'position' , ':position' ) -> set ( 'value' , ':value' ) -> set ( 'value_type' , ':value_type' ) -> set ( 'co...
Updates an item .
44,583
public function createQuery ( Query $ query ) : Query { $ dbQuery = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'ngbm_collection_query' ) -> values ( [ 'id' => ':id' , 'status' => ':status' , 'collection_id' => ':collection_id' , 'type' => ':type' , ] ) -> setValue ( 'id' , $ query -> id !== null ? ( int...
Creates a query .
44,584
public function createQueryTranslation ( Query $ query , string $ locale ) : void { $ dbQuery = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'ngbm_collection_query_translation' ) -> values ( [ 'query_id' => ':query_id' , 'status' => ':status' , 'locale' => ':locale' , 'parameters' => ':parameters' , ] ) -...
Creates a query translation .
44,585
public function updateQueryTranslation ( Query $ query , string $ locale ) : void { $ dbQuery = $ this -> connection -> createQueryBuilder ( ) ; $ dbQuery -> update ( 'ngbm_collection_query_translation' ) -> set ( 'parameters' , ':parameters' ) -> where ( $ dbQuery -> expr ( ) -> andX ( $ dbQuery -> expr ( ) -> eq ( 'q...
Updates a query translation .
44,586
public function deleteQueryTranslations ( array $ queryIds , ? int $ status = null , ? string $ locale = null ) : void { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> delete ( 'ngbm_collection_query_translation' ) -> where ( $ query -> expr ( ) -> in ( 'query_id' , [ ':query_id' ] ) ) -> setPara...
Deletes the query translations with provided query IDs .
44,587
private function getItemSelectQuery ( ) : QueryBuilder { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'DISTINCT ngbm_collection_item.*' ) -> from ( 'ngbm_collection_item' ) ; return $ query ; }
Builds and returns an item database SELECT query .
44,588
private function getQuerySelectQuery ( ) : QueryBuilder { $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( 'DISTINCT q.*, qt.*' ) -> from ( 'ngbm_collection_query' , 'q' ) -> innerJoin ( 'q' , 'ngbm_collection_query_translation' , 'qt' , $ query -> expr ( ) -> andX ( $ query -> expr ( ) ->...
Builds and returns a block database SELECT query .
44,589
public function mapRules ( array $ data ) : array { $ rules = [ ] ; foreach ( $ data as $ dataItem ) { $ rules [ ] = Rule :: fromArray ( [ 'id' => ( int ) $ dataItem [ 'id' ] , 'status' => ( int ) $ dataItem [ 'status' ] , 'layoutId' => $ dataItem [ 'layout_id' ] !== null ? ( int ) $ dataItem [ 'layout_id' ] : null , '...
Maps data from database to rule values .
44,590
public function mapTargets ( array $ data ) : array { $ targets = [ ] ; foreach ( $ data as $ dataItem ) { $ targets [ ] = Target :: fromArray ( [ 'id' => ( int ) $ dataItem [ 'id' ] , 'status' => ( int ) $ dataItem [ 'status' ] , 'ruleId' => ( int ) $ dataItem [ 'rule_id' ] , 'type' => $ dataItem [ 'type' ] , 'value' ...
Maps data from database to target values .
44,591
public function mapConditions ( array $ data ) : array { $ conditions = [ ] ; foreach ( $ data as $ dataItem ) { $ conditions [ ] = Condition :: fromArray ( [ 'id' => ( int ) $ dataItem [ 'id' ] , 'status' => ( int ) $ dataItem [ 'status' ] , 'ruleId' => ( int ) $ dataItem [ 'rule_id' ] , 'type' => $ dataItem [ 'type' ...
Maps data from database to condition values .
44,592
public static function buildBlockType ( string $ identifier , array $ config , BlockDefinitionInterface $ blockDefinition ) : BlockType { return BlockType :: fromArray ( [ 'identifier' => $ identifier , 'isEnabled' => $ config [ 'enabled' ] , 'name' => $ config [ 'name' ] , 'icon' => $ config [ 'icon' ] , 'definition' ...
Builds the block type .
44,593
public function buildContainerDefinition ( string $ identifier , ContainerDefinitionHandlerInterface $ handler , array $ config , array $ configDefinitionHandlers ) : ContainerDefinitionInterface { $ commonData = $ this -> getCommonBlockDefinitionData ( $ identifier , $ handler , $ config , $ configDefinitionHandlers )...
Builds the container definition .
44,594
private function getCommonBlockDefinitionData ( string $ identifier , BlockDefinitionHandlerInterface $ handler , array $ config , array $ configDefinitionHandlers ) : array { $ parameterBuilder = $ this -> parameterBuilderFactory -> createParameterBuilder ( ) ; $ handler -> buildParameters ( $ parameterBuilder ) ; $ h...
Returns the data common to all block definition types .
44,595
private function compileContextNode ( Compiler $ compiler ) : void { $ contextNode = null ; if ( $ this -> hasNode ( 'context' ) ) { $ contextNode = $ this -> getNode ( 'context' ) ; } if ( $ contextNode instanceof Node ) { $ compiler -> write ( '$ngbmContext = ' ) -> subcompile ( $ this -> getNode ( 'context' ) ) -> w...
Compiles the context node .
44,596
public function renderCollectionPager ( Pagerfanta $ pagerfanta , Block $ block , string $ collectionIdentifier , array $ options = [ ] ) : string { $ options [ 'block' ] = $ block ; $ options [ 'collection_identifier' ] = $ collectionIdentifier ; return $ this -> pagerfantaView -> render ( $ pagerfanta , $ this -> rou...
Renders the provided Pagerfanta view .
44,597
public function getCollectionPageUrl ( Pagerfanta $ pagerfanta , Block $ block , string $ collectionIdentifier , int $ page = 1 ) : string { if ( $ page < 1 || $ page > $ pagerfanta -> getNbPages ( ) ) { throw new InvalidArgumentException ( 'page' , sprintf ( 'Page %d is out of bounds' , $ page ) ) ; } return call_user...
Returns the URL of the provided pager and page number .
44,598
private function hasLayouts ( ) : bool { $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'COUNT(id) as count' ) -> from ( 'ngbm_layout' ) ; $ result = $ queryBuilder -> execute ( ) -> fetchAll ( PDO :: FETCH_ASSOC ) ; return ( int ) $ result [ 0 ] [ 'count' ] > 0 ; }
Returns if the database already contains some layouts .
44,599
private function askDefaultLocale ( ) : string { $ io = new SymfonyStyle ( new ArgvInput ( ) , new ConsoleOutput ( ) ) ; return $ io -> ask ( 'Please input the default locale for existing layouts' , '' , static function ( string $ locale ) : string { if ( ! Locales :: exists ( $ locale ) ) { throw new RuntimeException ...
Asks the user for default layout locale and returns it .