idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
44,400
private function mainMenuIdent ( $ options = null ) { if ( $ this -> mainMenuIdentLoaded === false ) { $ mainMenuIdent = null ; if ( isset ( $ this [ 'main_menu_item' ] ) ) { $ mainMenuIdent = $ this [ 'main_menu_item' ] ; } if ( ! ( empty ( $ options ) && ! is_numeric ( $ options ) ) ) { if ( is_string ( $ options ) )...
Determine and retrieve the active main menu item s identifier .
44,401
protected function isObjTypeInSecondaryMenuItem ( $ objType , $ item ) { if ( isset ( $ item [ 'links' ] ) ) { foreach ( $ item [ 'links' ] as $ obj => $ i ) { if ( $ obj === $ objType ) { return true ; } } } if ( isset ( $ item [ 'groups' ] ) ) { foreach ( $ item [ 'groups' ] as $ group ) { if ( $ this -> isObjTypeInS...
Check for the objType in the secondary menu items returning true as soon as it its .
44,402
public function templateName ( ) { $ key = substr ( strrchr ( '\\' . get_class ( $ this ) , '\\' ) , 1 ) ; if ( ! isset ( static :: $ templateNameCache [ $ key ] ) ) { $ value = $ key ; if ( ! ctype_lower ( $ value ) ) { $ value = preg_replace ( '/\s+/u' , '' , $ value ) ; $ value = mb_strtolower ( preg_replace ( '/(.)...
Retrieve the template s identifier .
44,403
public function displayVal ( ) { $ selectedChoices = [ ] ; foreach ( $ this -> choices ( ) as $ choice ) { if ( $ this -> isChoiceSelected ( $ choice ) ) { $ selectedChoices [ ] = $ choice [ 'label' ] ; } } return implode ( ', ' , $ selectedChoices ) ; }
Retrieve the selected value and display it .
44,404
public function getDescription ( string $ resourceClass ) : array { $ description = [ ] ; $ properties = $ this -> properties ; if ( null === $ properties ) { $ family = $ this -> getFamily ( $ resourceClass ) ; $ properties = array_fill_keys ( array_keys ( $ family -> getAttributes ( ) ) , null ) ; } foreach ( $ prope...
Gets the description of this filter for the given resource .
44,405
public static function getVersion ( string $ version = '' ) : string { if ( $ version === '' ) { $ version = PrettyVersions :: getVersion ( 'api-clients/pusher' ) -> getFullVersion ( ) ; } list ( $ version , $ hash ) = explode ( '@' , $ version ) ; if ( strpos ( $ version , 'dev' ) !== false ) { return '0.0.1-' . $ has...
Create Pusher compatible version .
44,406
public static function createUrl ( string $ appId , string $ cluster = null ) : string { $ query = [ 'client' => 'api-clients/pusher (https://php-api-clients.org/clients/pusher)' , 'protocol' => 7 , 'version' => ApiSettings :: getVersion ( ) , ] ; $ host = ( $ cluster !== null ) ? "ws-{$cluster}.pusher.com" : 'ws.pushe...
Create WebSocket URL for given App ID .
44,407
public function cloneAction ( Request $ request , DataInterface $ data , FamilyInterface $ family = null ) { return $ this -> editAction ( $ request , clone $ data , $ family ) ; }
Dedicated permission for cloning ?
44,408
protected function getDataGridConfigCode ( ) : string { if ( $ this -> family ) { $ familyCode = $ this -> family -> getCode ( ) ; if ( isset ( $ this -> admin -> getOption ( 'families' ) [ $ familyCode ] [ 'datagrid' ] ) ) { return $ this -> admin -> getOption ( 'families' ) [ $ familyCode ] [ 'datagrid' ] ; } if ( $ ...
Resolve datagrid code .
44,409
protected function getPaginator ( ProcessState $ state , $ alias = 'e' ) { $ options = $ this -> getOptions ( $ state ) ; $ paginator = new Paginator ( $ this -> getQueryBuilder ( $ state , $ alias ) ) ; if ( null !== $ options [ 'limit' ] ) { $ paginator -> getQuery ( ) -> setMaxResults ( $ options [ 'limit' ] ) ; } i...
If a limit or an offset is specified we are forced to use a paginator to handle joins properly
44,410
public function next ( ProcessState $ state ) { if ( ! $ this -> iterator instanceof \ Iterator ) { throw new \ LogicException ( 'No iterator initialized' ) ; } $ this -> iterator -> next ( ) ; $ valid = $ this -> iterator -> valid ( ) ; if ( ! $ valid ) { $ this -> closed = true ; } return $ valid ; }
Moves the internal pointer to the next element return true if the task has a next element return false if the task has terminated it s iteration
44,411
public function getCollection ( string $ resourceClass , string $ operationName = null ) { if ( ! is_a ( $ resourceClass , FamilyInterface :: class , true ) ) { throw new ResourceClassNotSupportedException ( ) ; } return $ this -> familyRegistry -> getFamilies ( ) ; }
Retrieves a collection .
44,412
public function getRoles ( ) { $ roles = $ this -> roles ; foreach ( $ this -> getGroups ( ) as $ group ) { $ roles = array_merge ( $ roles , $ group -> getRoles ( ) ) ; } $ roles [ ] = static :: ROLE_DEFAULT ; return array_unique ( $ roles ) ; }
Returns the user roles .
44,413
public function previewAction ( Request $ request , DataInterface $ data ) { return $ this -> editAction ( $ request , $ data , $ data -> getFamily ( ) ) ; }
Alias for edit action but with custom form options
44,414
public static function getBundles ( ) : array { return [ new \ Mopa \ Bundle \ BootstrapBundle \ MopaBootstrapBundle ( ) , new \ WhiteOctober \ PagerfantaBundle \ WhiteOctoberPagerfantaBundle ( ) , new \ Pinano \ Select2Bundle \ PinanoSelect2Bundle ( ) , new \ Oneup \ UploaderBundle \ OneupUploaderBundle ( ) , new \ On...
Return the required bundles .
44,415
public function channel ( string $ channel ) : Observable { if ( isset ( $ this -> channels [ $ channel ] ) ) { return $ this -> channels [ $ channel ] ; } $ channelMessages = $ this -> messages -> filter ( function ( Event $ event ) use ( $ channel ) { return $ event -> getChannel ( ) !== '' && $ event -> getChannel (...
Listen on a channel .
44,416
private function timeout ( Observable $ events ) : Observable { $ timeoutDuration = $ this -> connected -> map ( function ( Event $ event ) { return ( $ event -> getData ( ) [ 'activity_timeout' ] ?? self :: NO_ACTIVITY_TIMEOUT ) * 1000 ; } ) ; return $ timeoutDuration -> combineLatest ( [ $ events ] ) -> pluck ( 0 ) -...
Returns an observable of TimeoutException . The timeout observable will get cancelled every time a new event is received .
44,417
public function create ( string $ resourceClass , array $ options = [ ] ) : PropertyNameCollection { $ propertyNameCollection = $ this -> propertyNameCollectionFactory -> create ( $ resourceClass , $ options ) ; if ( is_a ( $ resourceClass , DataInterface :: class , true ) ) { $ resolvedProperties = [ ] ; foreach ( $ p...
Creates the property name collection for the given class and options .
44,418
public function create ( string $ resourceClass , string $ property , array $ options = [ ] ) : PropertyMetadata { $ propertyMetadata = $ this -> propertyMetadata -> create ( $ resourceClass , $ property , $ options ) ; if ( 'code' === $ property && is_a ( $ resourceClass , FamilyInterface :: class , true ) ) { return ...
Creates a property metadata .
44,419
public function equals ( $ object ) { if ( ! ( $ object instanceof self ) || ! self :: compatibles ( get_class ( $ object ) , static :: class ) ) { return false ; } return $ this -> value ( ) == $ object -> value ( ) ; }
Checks if two enums are equal . Value and class are both matched . Value check is not type strict .
44,420
public static function labels ( ) { self :: bootClass ( ) ; $ result = [ ] ; foreach ( static :: values ( ) as $ value ) { $ result [ ] = static :: getLabel ( $ value ) ; } return $ result ; }
Returns the array of labels .
44,421
public static function choices ( ) { self :: bootClass ( ) ; $ result = [ ] ; foreach ( static :: values ( ) as $ value ) { $ result [ $ value ] = static :: getLabel ( $ value ) ; } return $ result ; }
Returns an array of value = > label pairs . Ready to pass to dropdowns .
44,422
private static function bootClass ( ) { if ( ! array_key_exists ( static :: class , self :: $ meta ) ) { self :: $ meta [ static :: class ] = ( new \ ReflectionClass ( static :: class ) ) -> getConstants ( ) ; unset ( self :: $ meta [ static :: class ] [ '__default' ] ) ; if ( method_exists ( static :: class , 'boot' )...
Initializes the constants array for the class if necessary .
44,423
private static function getLabel ( $ value ) { self :: bootClass ( ) ; if ( static :: hasLabels ( ) && isset ( static :: $ labels [ $ value ] ) ) { return ( string ) static :: $ labels [ $ value ] ; } return ( string ) $ value ; }
Returns the label for a given value .
44,424
public function getInputGroup ( Widget $ widget ) { if ( $ this -> widgetConfig [ $ widget -> type ] [ 'input_group' ] && $ widget -> bs_addInputGroup ) { return InputGroupHelper :: forWidget ( $ widget ) ; } return null ; }
Get the input group .
44,425
protected function getTemplate ( Widget $ widget , string $ section ) : string { if ( $ section === 'help' && empty ( $ this -> widgetConfig [ $ widget -> type ] [ 'help' ] ) ) { return '' ; } if ( isset ( $ this -> widgetConfig [ $ widget -> type ] [ 'templates' ] [ $ section ] ) ) { return $ this -> widgetConfig [ $ ...
Get a template for a section .
44,426
protected function fire ( $ action , $ params ) { if ( ! isset ( $ this -> events [ $ action ] ) ) { throw new HandlerException ( 'Action handler not exists' , HandlerException :: ACTION_HANDLER_NOT_EXISTS ) ; } $ callbackParams = $ params ; $ callbackParams [ 'client' ] = $ this -> getClient ( ) ; $ callbackParams = n...
fires handlers for a specific action
44,427
public function redirect_ajax_url ( $ url , $ path , $ blog_id ) { if ( strpos ( $ url , 'admin-ajax' ) ) { return home_url ( "/" . $ this -> keyword . "/" ) ; } else { return $ url ; } }
Function that handles rewriting the admin - ajax url to the one we want
44,428
public function rewrite ( ) { global $ wp_rewrite ; add_rewrite_tag ( "%no-admin-ajax%" , "([0-9]+)" ) ; $ default_rule = "^" . $ this -> keyword . "/?$" ; $ rule = apply_filters ( "no-admin-ajax/rule" , $ default_rule ) ; add_rewrite_rule ( $ rule , "index.php?no-admin-ajax=true" , "top" ) ; }
Creates the rewrite
44,429
public function run_ajax ( ) { global $ wp_query ; if ( $ wp_query -> get ( "no-admin-ajax" ) ) { define ( "DOING_AJAX" , true ) ; if ( ! isset ( $ _REQUEST [ "action" ] ) ) { die ( 0 ) ; } $ action = esc_attr ( $ _REQUEST [ "action" ] ) ; do_action ( "no-admin-ajax/before" ) ; do_action ( "no-admin-ajax/before/" . $ a...
Runs the ajax calls . Equivalent to the real admin - ajax . php
44,430
protected function prepareUrl ( $ url , $ query = array ( ) ) { $ processedUrl = $ url ; if ( $ query ) { if ( strpos ( $ url , '?' ) !== false ) { $ components = parse_url ( $ url ) ; $ params = array ( ) ; parse_str ( $ components [ 'query' ] , $ params ) ; $ params = $ params + $ query ; $ components [ 'query' ] = h...
return an URL with query string
44,431
protected function doRequest ( $ url , $ ctx , & $ responseHeaders , $ methodName ) { $ result = @ file_get_contents ( $ url , null , $ ctx ) ; if ( ! $ result ) { throw new \ Exception ( 'HTTP request failed' , HttpException :: REQUEST_FAILED ) ; } $ responseHeaders = $ this -> parseHeaders ( $ http_response_header ) ...
perform target request
44,432
public function getColumnClass ( bool $ withOffset = false ) : string { $ class = ( string ) $ this -> horizontalConfig [ 'control' ] ; if ( $ withOffset ) { $ class .= ' ' . $ this -> horizontalConfig [ 'offset' ] ; } return $ class ; }
Get the column class .
44,433
private function buildWidgetConfig ( string $ type , array $ config ) : array { $ type = substr ( $ type , 3 ) ; $ configKey = 'form.layouts.' . $ type . '.widgets' ; $ bootstrapConfig = $ this -> environment -> getConfig ( ) ; $ widgetConfig = ArrayUtil :: merge ( $ this -> widgetConfig , $ bootstrapConfig -> get ( 'f...
Build the widget config .
44,434
private function buildFallbackConfig ( string $ type , array $ config ) : array { $ type = substr ( $ type , 3 ) ; $ fallbackConfig = $ this -> environment -> getConfig ( ) -> get ( 'form.layouts.' . $ type , [ ] ) ; $ fallbackConfig = ArrayUtil :: merge ( $ this -> fallbackConfig , $ fallbackConfig ) ; foreach ( $ thi...
Build the fallback config .
44,435
private function buildHorizontalConfig ( array $ config ) : array { $ horizontalConfig = $ this -> environment -> getConfig ( ) -> get ( 'form.layouts.horizontal.classes' , [ ] ) ; foreach ( [ 'row' , 'label' , 'control' , 'offset' ] as $ key ) { if ( ! empty ( $ config [ 'bs_' . $ key ] ) ) { $ horizontalConfig [ $ ke...
Build horizontal config .
44,436
public function reset ( ) { $ this -> filters = array ( ) ; $ this -> limit = null ; $ this -> order = null ; $ this -> page = null ; return $ this ; }
reset filters object state
44,437
protected function getCriteria ( ) { $ result = array ( ) ; if ( $ this -> filters ) { $ result [ 'filters' ] = $ this -> filters ; } if ( $ this -> limit !== null ) { $ result [ 'limit' ] = $ this -> limit ; } if ( $ this -> order !== null ) { $ result [ 'order' ] = $ this -> order ; } if ( $ this -> page !== null ) {...
get an array with specified criteria
44,438
public function limit ( $ count ) { if ( $ count < 1 || $ count > 50 ) { throw new \ RuntimeException ( 'Limit beyond 1-50 range' , ResourceException :: LIMIT_BEYOND_RANGE ) ; } $ this -> limit = $ count ; return $ this ; }
set records limit
44,439
public function filters ( $ filters ) { if ( ! is_array ( $ filters ) ) { throw new \ RuntimeException ( 'Filters not specified' , ResourceException :: FILTERS_NOT_SPECIFIED ) ; } $ this -> filters = json_encode ( $ filters ) ; return $ this ; }
set filters for finding
44,440
public function order ( $ expr ) { $ matches = array ( ) ; $ expr = ( array ) $ expr ; $ result = array ( ) ; foreach ( $ expr as $ e ) { if ( preg_match ( '/([a-z_0-9.]+) (asc|desc)$/i' , $ e ) ) { $ result [ ] = $ e ; } else if ( preg_match ( '/([\+\-]?)([a-z_0-9.]+)/i' , $ e , $ matches ) ) { $ subResult = $ matches...
order record by column
44,441
public function head ( ) { $ query = $ this -> getCriteria ( ) ; $ args = func_get_args ( ) ; if ( empty ( $ args ) ) { $ args = null ; } $ response = '' ; try { $ response = $ this -> client -> request ( $ this , 'head' , $ args , array ( ) , $ query ) ; } catch ( Exception $ ex ) { $ this -> dispatchException ( $ ex ...
Read Resource without data
44,442
public static function forWidget ( Widget $ widget ) : self { $ values = StringUtil :: deserialize ( $ widget -> bs_inputGroup , true ) ; $ helper = new static ( ) ; foreach ( $ values as $ entry ) { if ( ! strlen ( $ entry [ 'addon' ] ) ) { continue ; } if ( $ entry [ 'position' ] === 'after' ) { $ helper -> addAfter ...
Create input group helper for a widget .
44,443
public function addAfter ( string $ content , bool $ text = true ) : self { $ this -> after [ ] = [ 'content' => $ content , 'text' => $ text ] ; return $ this ; }
Add after entry .
44,444
public function addBefore ( string $ content , bool $ text = true ) : self { $ this -> before [ ] = [ 'content' => $ content , 'text' => $ text ] ; return $ this ; }
Add before entry .
44,445
public function onGetPageLayout ( PageModel $ pageModel , LayoutModel $ layoutModel ) : void { if ( $ this -> manager -> hasDefaultThemeLayout ( ) ) { return ; } $ this -> manager -> setDefaultThemeLayout ( $ this -> factory -> create ( 'bs_default' , [ ] ) ) ; }
Create default bootstrap form layout .
44,446
public function onKernelRequest ( GetResponseEvent $ event ) : void { $ request = $ event -> getRequest ( ) ; if ( ! $ event -> isMasterRequest ( ) ) { return ; } if ( $ request -> attributes -> get ( SetIsApiRequestListener :: API_FLAG_NAME ) !== true ) { return ; } if ( ! $ this -> isDecodeable ( $ request ) ) { retu...
Decodes the request data into request parameter bag .
44,447
protected function addViewTypeForm ( FormBuilderInterface $ builder , array $ options ) : void { $ blockDefinition = $ options [ 'block' ] -> getDefinition ( ) ; $ this -> processViewTypeConfig ( $ blockDefinition ) ; $ builder -> add ( 'view_type' , ChoiceType :: class , [ 'label' => 'block.view_type' , 'choices' => a...
Adds view type and item view type forms to the provided form builder .
44,448
protected function addParametersForm ( FormBuilderInterface $ builder , array $ options , array $ groups = [ ] ) : void { $ blockDefinition = $ options [ 'block' ] -> getDefinition ( ) ; $ builder -> add ( 'parameters' , ParametersType :: class , [ 'label' => false , 'inherit_data' => true , 'property_path' => 'paramet...
Adds the parameters form to the provided builder .
44,449
private function processViewTypeConfig ( BlockDefinitionInterface $ blockDefinition ) : void { $ blockDefinitionParameters = array_keys ( $ blockDefinition -> getParameterDefinitions ( ) ) ; foreach ( $ blockDefinition -> getViewTypes ( ) as $ viewType ) { $ this -> viewTypes [ $ viewType -> getIdentifier ( ) ] = $ vie...
Generates the list of valid view types for every item view type and for every parameter according to config provided by the block definition .
44,450
public function onKernelResponse ( FilterResponseEvent $ event ) : void { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ blockView = $ event -> getRequest ( ) -> attributes -> get ( 'ngbmView' ) ; if ( ! $ blockView instanceof BlockViewInterface ) { return ; } $ this -> tagger -> tagBlock ( $ event -> getRespon...
Tags the response with the data for block provided by the event .
44,451
public function mapConfig ( array $ config , array $ configDefinitions ) : Generator { foreach ( $ configDefinitions as $ configKey => $ configDefinition ) { yield $ configKey => Config :: fromArray ( [ 'configKey' => $ configKey , 'definition' => $ configDefinition , 'parameters' => iterator_to_array ( $ this -> param...
Maps the provided config array to API values according to provided config definitions .
44,452
public function serializeValues ( array $ configStructs , array $ configDefinitions , array $ fallbackValues = [ ] ) : Generator { foreach ( $ configDefinitions as $ configKey => $ configDefinition ) { $ configValues = [ ] ; if ( isset ( $ configStructs [ $ configKey ] ) && $ configStructs [ $ configKey ] instanceof Pa...
Serializes the existing config struct values based on provided config definitions .
44,453
public function createPosition ( array $ conditions , ? int $ position = null , ? int $ endPosition = null , bool $ allowOutOfRange = false ) : int { $ nextPosition = $ this -> getNextPosition ( $ conditions ) ; if ( $ position === null ) { return $ nextPosition ; } if ( $ position < 0 ) { throw new BadStateException (...
Processes the database table to create space for an item which will be inserted at specified position .
44,454
public function moveToPosition ( array $ conditions , int $ originalPosition , int $ position , bool $ allowOutOfRange = false ) : int { $ nextPosition = $ this -> getNextPosition ( $ conditions ) ; if ( $ position < 0 ) { throw new BadStateException ( 'position' , 'Position cannot be negative.' ) ; } if ( ! $ allowOut...
Processes the database table to make space for the item which will be moved inside the table .
44,455
public function getNextPosition ( array $ conditions ) : int { $ columnName = $ conditions [ 'column' ] ; $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> select ( $ this -> connection -> getDatabasePlatform ( ) -> getMaxExpression ( $ columnName ) . ' AS ' . $ columnName ) -> from ( $ conditions [...
Returns the next available position in the table .
44,456
private function incrementPositions ( array $ conditions , ? int $ startPosition = null , ? int $ endPosition = null ) : void { $ columnName = $ conditions [ 'column' ] ; $ query = $ this -> connection -> createQueryBuilder ( ) ; $ query -> update ( $ conditions [ 'table' ] ) -> set ( $ columnName , $ columnName . ' + ...
Increments all positions in a table starting from provided position .
44,457
private function applyConditions ( QueryBuilder $ query , array $ conditions ) : void { foreach ( $ conditions as $ identifier => $ value ) { $ query -> andWhere ( $ query -> expr ( ) -> eq ( $ identifier , ':' . $ identifier ) ) ; $ query -> setParameter ( $ identifier , $ value , is_int ( $ value ) ? Type :: INTEGER ...
Applies the provided conditions to the query .
44,458
protected function buildView ( $ value , string $ context = ViewInterface :: CONTEXT_DEFAULT , array $ parameters = [ ] , ? Response $ response = null ) : ViewInterface { $ viewBuilder = $ this -> get ( 'netgen_block_manager.view.view_builder' ) ; $ view = $ viewBuilder -> buildView ( $ value , $ context , $ parameters...
Builds the view from provided value .
44,459
private function buildLayoutTypes ( ContainerBuilder $ container , array $ layoutTypes ) : Generator { foreach ( $ layoutTypes as $ identifier => $ layoutType ) { $ serviceIdentifier = sprintf ( 'netgen_block_manager.layout.layout_type.%s' , $ identifier ) ; $ container -> register ( $ serviceIdentifier , LayoutType ::...
Builds the layout type objects from provided configuration .
44,460
private function validateLayoutTypes ( array $ layoutTypes , array $ blockDefinitions ) : void { foreach ( $ layoutTypes as $ layoutType => $ layoutTypeConfig ) { foreach ( $ layoutTypeConfig [ 'zones' ] as $ zoneConfig ) { foreach ( $ zoneConfig [ 'allowed_block_definitions' ] as $ blockDefinition ) { if ( ! isset ( $...
Validates layout type config .
44,461
public function getItemPath ( $ value , ? string $ valueType = null ) : string { try { $ item = null ; if ( is_string ( $ value ) && $ valueType === null ) { $ itemUri = parse_url ( $ value ) ; if ( ! is_array ( $ itemUri ) || ( $ itemUri [ 'scheme' ] ?? '' ) === '' || ! isset ( $ itemUri [ 'host' ] ) ) { throw ItemExc...
The method returns the full path of provided item .
44,462
public function mapCollections ( array $ data ) : array { $ collections = [ ] ; foreach ( $ data as $ dataItem ) { $ collectionId = ( int ) $ dataItem [ 'id' ] ; $ locale = $ dataItem [ 'locale' ] ; if ( ! isset ( $ collections [ $ collectionId ] ) ) { $ collections [ $ collectionId ] = [ 'id' => $ collectionId , 'stat...
Maps data from database to collection values .
44,463
public function mapItems ( array $ data ) : array { $ items = [ ] ; foreach ( $ data as $ dataItem ) { $ items [ ] = Item :: fromArray ( [ 'id' => ( int ) $ dataItem [ 'id' ] , 'collectionId' => ( int ) $ dataItem [ 'collection_id' ] , 'position' => ( int ) $ dataItem [ 'position' ] , 'value' => $ dataItem [ 'value' ] ...
Maps data from database to item values .
44,464
public function mapQueries ( array $ data ) : array { $ queries = [ ] ; foreach ( $ data as $ dataItem ) { $ queryId = ( int ) $ dataItem [ 'id' ] ; $ locale = $ dataItem [ 'locale' ] ; if ( ! isset ( $ queries [ $ queryId ] ) ) { $ queries [ $ queryId ] = [ 'id' => $ queryId , 'collectionId' => ( int ) $ dataItem [ 'c...
Maps data from database to query values .
44,465
private function buildParameters ( string $ parameters ) : array { $ decodedParameters = json_decode ( $ parameters , true ) ; return is_array ( $ decodedParameters ) ? $ decodedParameters : [ ] ; }
Builds the array of parameters from provided JSON string .
44,466
private function validatePriorities ( Request $ request ) : void { $ this -> validate ( $ request -> request -> get ( 'rule_ids' ) , [ new Constraints \ NotBlank ( ) , new Constraints \ Type ( [ 'type' => 'array' ] ) , new Constraints \ All ( [ 'constraints' => [ new Constraints \ NotBlank ( ) , new Constraints \ Type ...
Validates list of rules from the request when updating priorities .
44,467
public function collectLayout ( LayoutViewInterface $ layoutView ) : void { $ layout = $ layoutView -> getLayout ( ) ; $ this -> data [ 'layout' ] = [ 'id' => $ layout -> getId ( ) , 'name' => $ layout -> getName ( ) , 'type' => $ layout -> getLayoutType ( ) -> getName ( ) , 'context' => $ layoutView -> getContext ( ) ...
Collects the layout data .
44,468
public function collectRule ( Rule $ rule ) : void { $ this -> data [ 'rule' ] = [ 'id' => $ rule -> getId ( ) , ] ; foreach ( $ rule -> getTargets ( ) as $ target ) { $ this -> data [ 'rule' ] [ 'targets' ] [ ] = [ 'type' => $ target -> getTargetType ( ) :: getType ( ) , 'value' => $ this -> formatVar ( $ target -> ge...
Collects the rule data .
44,469
public function collectBlockView ( BlockViewInterface $ blockView ) : void { $ block = $ blockView -> getBlock ( ) ; $ blockDefinition = $ block -> getDefinition ( ) ; $ blockData = [ 'id' => $ block -> getId ( ) , 'layout_id' => $ block -> getLayoutId ( ) , 'definition' => $ blockDefinition -> getName ( ) , 'view_type...
Collects the block view data .
44,470
public function onView ( GetResponseForControllerResultEvent $ event ) : void { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ request = $ event -> getRequest ( ) ; $ value = $ event -> getControllerResult ( ) ; if ( ! $ value instanceof AbstractValue ) { return ; } $ context = [ ] ; if ( $ request -> query -> ...
Serializes the value provided by the event .
44,471
private function buildParameterDefinition ( ParameterBuilderInterface $ builder ) : ParameterDefinition { $ data = [ 'name' => $ builder -> getName ( ) , 'type' => $ builder -> getType ( ) , 'options' => $ builder -> getOptions ( ) , 'isRequired' => $ builder -> isRequired ( ) , 'defaultValue' => $ builder -> getDefaul...
Builds the parameter definition .
44,472
private function resolveOptions ( array $ options ) : array { $ optionsResolver = new OptionsResolver ( ) ; $ optionsResolver -> setDefault ( 'default_value' , null ) ; $ optionsResolver -> setDefault ( 'required' , false ) ; $ optionsResolver -> setDefault ( 'label' , null ) ; $ optionsResolver -> setDefault ( 'groups...
Resolves the parameter options .
44,473
private function validateConstraints ( array $ constraints ) : bool { foreach ( $ constraints as $ constraint ) { if ( ! $ constraint instanceof Closure && ! $ constraint instanceof Constraint ) { return false ; } } return true ; }
Validates the list of constraints to be either a Symfony constraint or a closure .
44,474
public function extract ( $ object ) : array { if ( ! is_object ( $ object ) ) { throw new RuntimeException ( sprintf ( '%s expects the provided $object to be a PHP object' , __METHOD__ ) ) ; } return ( function ( ) : array { return get_object_vars ( $ this ) ; } ) -> call ( $ object ) ; }
Extract values from an object .
44,475
private function filterUntranslatedBlocks ( iterable $ blocks , ? array $ locales , bool $ useMainLocale ) : Generator { foreach ( $ blocks as $ block ) { try { yield $ this -> mapper -> mapBlock ( $ block , $ locales , $ useMainLocale ) ; } catch ( NotFoundException $ e ) { } } }
Returns all blocks from provided input with all untranslated blocks filtered out .
44,476
private function internalCreateBlock ( APIBlockCreateStruct $ blockCreateStruct , PersistenceBlock $ targetBlock , string $ placeholder , ? int $ position = null ) : Block { $ persistenceLayout = $ this -> layoutHandler -> loadLayout ( $ targetBlock -> layoutId , Value :: STATUS_DRAFT ) ; $ createdBlock = $ this -> tra...
Creates a block at specified target block and placeholder and position .
44,477
private function internalMoveBlock ( PersistenceBlock $ block , PersistenceBlock $ targetBlock , string $ placeholder , int $ position ) : PersistenceBlock { return $ this -> transaction ( function ( ) use ( $ block , $ targetBlock , $ placeholder , $ position ) : PersistenceBlock { if ( $ block -> parentId === $ targe...
Moves a block to specified target block and placeholder and position .
44,478
private function internalDisableTranslations ( PersistenceBlock $ block ) : PersistenceBlock { $ block = $ this -> blockHandler -> updateBlock ( $ block , BlockUpdateStruct :: fromArray ( [ 'isTranslatable' => false , ] ) ) ; foreach ( $ block -> availableLocales as $ locale ) { if ( $ locale !== $ block -> mainLocale ...
Disables the translations on provided block and removes all translations keeping only the main one .
44,479
private function updateBlockTranslations ( BlockDefinitionInterface $ blockDefinition , PersistenceBlock $ persistenceBlock , APIBlockUpdateStruct $ blockUpdateStruct ) : PersistenceBlock { if ( $ blockUpdateStruct -> locale === $ persistenceBlock -> mainLocale ) { $ persistenceBlock = $ this -> blockHandler -> updateB...
Updates translations for specified block .
44,480
public function mapCollection ( PersistenceCollection $ collection , ? array $ locales = null , bool $ useMainLocale = true ) : Collection { $ locales = is_array ( $ locales ) && count ( $ locales ) > 0 ? $ locales : [ $ collection -> mainLocale ] ; if ( $ useMainLocale && $ collection -> alwaysAvailable ) { $ locales ...
Builds the API collection value from persistence one .
44,481
public function mapItem ( PersistenceItem $ item ) : Item { try { $ itemDefinition = $ this -> itemDefinitionRegistry -> getItemDefinition ( $ item -> valueType ) ; } catch ( ItemDefinitionException $ e ) { $ itemDefinition = new NullItemDefinition ( $ item -> valueType ) ; } $ itemData = [ 'id' => $ item -> id , 'stat...
Builds the API item value from persistence one .
44,482
public function mapQuery ( PersistenceQuery $ query , ? array $ locales = null , bool $ useMainLocale = true ) : Query { try { $ queryType = $ this -> queryTypeRegistry -> getQueryType ( $ query -> type ) ; } catch ( QueryTypeException $ e ) { $ queryType = new NullQueryType ( $ query -> type ) ; } $ locales = is_array...
Builds the API query value from persistence one .
44,483
public function onKernelRequest ( GetResponseEvent $ event ) : void { foreach ( $ this -> extensions as $ extension ) { if ( ! class_exists ( $ extension ) || ! is_a ( $ extension , ExtensionInterface :: class , true ) ) { continue ; } if ( $ this -> twig -> hasExtension ( $ extension ) ) { continue ; } $ this -> twig ...
Adds the Twig extensions to the environment if they don t already exist .
44,484
public function renderItem ( array $ context , CmsItemInterface $ item , string $ viewType , array $ parameters = [ ] , ? string $ viewContext = null ) : string { try { return $ this -> renderer -> renderValue ( $ item , $ this -> getViewContext ( $ context , $ viewContext ) , [ 'view_type' => $ viewType ] + $ paramete...
Renders the provided item .
44,485
public function renderValue ( array $ context , $ value , array $ parameters = [ ] , ? string $ viewContext = null ) : string { try { return $ this -> renderer -> renderValue ( $ value , $ this -> getViewContext ( $ context , $ viewContext ) , $ parameters ) ; } catch ( Throwable $ t ) { $ message = sprintf ( 'Error re...
Renders the provided value .
44,486
public function displayZone ( Layout $ layout , string $ zoneIdentifier , string $ viewContext , ContextualizedTwigTemplate $ twigTemplate ) : void { $ locales = null ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( $ request instanceof Request ) { $ locales = $ this -> localeProvider -> getRequestL...
Displays the provided zone .
44,487
public function renderBlock ( array $ context , Block $ block , array $ parameters = [ ] , ? string $ viewContext = null ) : string { try { return $ this -> renderer -> renderValue ( $ block , $ this -> getViewContext ( $ context , $ viewContext ) , [ 'twig_template' => $ context [ 'twig_template' ] ?? null , ] + $ par...
Renders the provided block .
44,488
public function renderStringTemplate ( string $ string , array $ parameters = [ ] ) : string { try { $ parameters = iterator_to_array ( $ this -> getTemplateVariables ( $ parameters ) ) ; $ environment = new Environment ( new ArrayLoader ( ) ) ; $ template = $ environment -> createTemplate ( $ string ) ; return $ envir...
Renders the provided template with a reduced set of variables from the provided parameters list . Variables included are only those which can be safely printed .
44,489
private function getViewContext ( array $ context , ? string $ viewContext = null ) : string { return $ viewContext ?? $ context [ 'view_context' ] ?? ViewInterface :: CONTEXT_DEFAULT ; }
Returns the correct view context based on provided Twig context and view context provided through function call .
44,490
public function isContextual ( ) : bool { $ collectionQuery = $ this -> collection -> getQuery ( ) ; if ( ! $ collectionQuery instanceof Query ) { return false ; } return $ collectionQuery -> isContextual ( ) ; }
Returns if the result set is dependent on a context i . e . current request .
44,491
public function getLocaleName ( string $ locale , ? string $ displayLocale = null ) : ? string { return Locales :: getName ( $ locale , $ displayLocale ) ; }
Returns the locale name in specified locale .
44,492
public function getLayoutName ( $ layoutId ) : string { try { $ layout = $ this -> layoutService -> loadLayout ( $ layoutId ) ; return $ layout -> getName ( ) ; } catch ( Throwable $ t ) { return '' ; } }
Returns the layout name for specified layout ID .
44,493
public function getCountryFlag ( string $ countryCode ) : string { try { return FlagGenerator :: fromCountryCode ( $ countryCode ) ; } catch ( Throwable $ t ) { return $ countryCode ; } }
Returns the country flag as an emoji string for provided country code .
44,494
public function validateId ( $ id , ? string $ propertyPath = null ) : void { $ this -> validate ( $ id , [ new Constraints \ NotBlank ( ) , new Constraints \ Type ( [ 'type' => 'scalar' ] ) , ] , $ propertyPath ) ; }
Validates the provided ID to be an integer or string .
44,495
public function validateIdentifier ( string $ identifier , ? string $ propertyPath = null ) : void { $ constraints = [ new Constraints \ NotBlank ( ) , new Constraints \ Regex ( [ 'pattern' => '/^[A-Za-z0-9_]*[A-Za-z][A-Za-z0-9_]*$/' , ] ) , ] ; $ this -> validate ( $ identifier , $ constraints , $ propertyPath ) ; }
Validates the provided identifier to be a string .
44,496
public function validatePosition ( ? int $ position , ? string $ propertyPath = null , bool $ isRequired = false ) : void { if ( ! $ isRequired && $ position === null ) { return ; } $ constraints = [ new Constraints \ NotBlank ( ) , new Constraints \ GreaterThanOrEqual ( 0 ) , ] ; $ this -> validate ( $ position , $ co...
Validates the provided position to be an integer greater than or equal to 0 .
44,497
public function validateOffsetAndLimit ( ? int $ offset , ? int $ limit ) : void { $ this -> validate ( $ offset , [ new Constraints \ NotBlank ( ) , ] , 'offset' ) ; if ( $ limit !== null ) { $ this -> validate ( $ limit , [ new Constraints \ NotBlank ( ) , ] , 'limit' ) ; } }
Validates the provided offset and limit values to be integers .
44,498
public function validateLocale ( string $ locale , ? string $ propertyPath = null ) : void { $ this -> validate ( $ locale , [ new Constraints \ NotBlank ( ) , new LocaleConstraint ( ) , ] , $ propertyPath ) ; }
Validates the provided locale .
44,499
public function mapBlocks ( array $ data ) : array { $ blocks = [ ] ; foreach ( $ data as $ dataItem ) { $ blockId = ( int ) $ dataItem [ 'id' ] ; $ locale = $ dataItem [ 'locale' ] ; if ( ! isset ( $ blocks [ $ blockId ] ) ) { $ blocks [ $ blockId ] = [ 'id' => $ blockId , 'layoutId' => ( int ) $ dataItem [ 'layout_id...
Maps data from database to block values .