idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
5,400
public function createFormBuilder ( $ model , $ form = 'default' , $ context = [ ] , $ options = [ ] ) { $ fb = $ this -> formFactory -> createBuilder ( FormType :: class , $ model , $ options ) ; $ this -> populateFormBuilder ( $ fb , $ model , $ form , $ context ) ; return $ fb ; }
Creates FormBuilder and populates it .
5,401
public function createNamedFormBuilder ( $ name , $ model , $ form = 'default' , $ context = [ ] , $ options = [ ] ) { $ fb = $ this -> formFactory -> createNamedBuilder ( $ name , FormType :: class , $ model , $ options ) ; $ this -> populateFormBuilder ( $ fb , $ model , $ form , $ context ) ; return $ fb ; }
Creates named FormBuilder and populates it .
5,402
public function populateFormBuilder ( FormBuilderInterface $ fb , $ model , $ form = 'default' , $ context = [ ] ) { $ configuration = $ this -> formConfigurationFactory -> getConfiguration ( $ form , $ model , $ context ) ; foreach ( $ this -> adjusterRegistry -> getFormConfigurationModifiers ( ) as $ modifier ) { if ...
Populates FormBuilder .
5,403
private function replaceInsertTag ( array $ elements ) : string { if ( 3 !== \ count ( $ elements ) ) { return '' ; } list ( $ source , $ value , $ property ) = $ elements ; $ tag = $ this -> registry -> get ( $ source ) -> find ( $ value ) ; if ( null === $ tag ) { return '' ; } if ( 'name' === $ property ) { return $...
Replace the insert tag .
5,404
public static function createTagFromModel ( Model $ model ) { return new Tag ( ( string ) $ model -> id , $ model -> name , $ model -> row ( ) ) ; }
Create the tag from model .
5,405
private function createTags ( Collection $ models ) : array { $ tags = [ ] ; foreach ( $ models as $ model ) { $ tags [ ] = static :: createTagFromModel ( $ model ) ; } return $ tags ; }
Create the tags .
5,406
public static function getHighlighter ( $ highlighter = null , array $ arguments = [ ] ) { if ( $ highlighter instanceof HighlighterInterface ) { return $ highlighter ; } switch ( $ highlighter ) { case 'pygments' : case null : $ highlighterClass = PygmentsHighlighter :: class ; break ; default : $ highlighterClass = (...
Returns an instance of a highlighter by name or fully - qualified classname
5,407
protected function user ( $ request ) { if ( ! $ token = $ this -> auth -> setRequest ( $ request ) -> getToken ( ) ) { return 401 ; } try { $ user = $ this -> auth -> authenticate ( $ token ) ; } catch ( JWTException $ e ) { return 401 ; } if ( ! $ user ) { return 401 ; } return $ user ; }
Get the currently authenticated user or null .
5,408
public function getConfiguration ( $ form , $ model , $ context ) { $ fields = null ; foreach ( $ this -> adjusterRegistry -> getFormViewProviders ( ) as $ provider ) { if ( $ provider -> supports ( $ form , $ model , $ context ) ) { $ fields = $ provider -> getFields ( $ model , $ context ) ; break ; } } if ( $ fields...
Generates initial form configuration .
5,409
public function onLoadDataContainer ( string $ table ) : void { if ( ! isset ( $ GLOBALS [ 'TL_DCA' ] [ $ table ] [ 'fields' ] ) || ! \ is_array ( $ GLOBALS [ 'TL_DCA' ] [ $ table ] [ 'fields' ] ) ) { return ; } $ hasTagsFields = false ; foreach ( $ GLOBALS [ 'TL_DCA' ] [ $ table ] [ 'fields' ] as $ name => & $ field )...
On load the data container .
5,410
public function onFieldSave ( string $ value , DataContainer $ dc ) : string { $ manager = $ this -> getManagerFromDca ( $ dc ) ; if ( $ manager instanceof DcaAwareInterface ) { $ value = $ manager -> saveDcaField ( $ value , $ dc ) ; } return $ value ; }
On the field save .
5,411
public function onOptionsCallback ( DataContainer $ dc ) : array { $ value = [ ] ; $ manager = $ this -> getManagerFromDca ( $ dc ) ; if ( $ manager instanceof DcaFilterAwareInterface ) { $ value = $ manager -> getFilterOptions ( $ dc ) ; } return $ value ; }
On options callback .
5,412
private function getManagerFromDca ( DataContainer $ dc ) : ManagerInterface { return $ this -> registry -> get ( $ GLOBALS [ 'TL_DCA' ] [ $ dc -> table ] [ 'fields' ] [ $ dc -> field ] [ 'eval' ] [ 'tagsManager' ] ) ; }
Get the manager from DCA .
5,413
private function addAssets ( ) : void { $ GLOBALS [ 'TL_CSS' ] [ ] = Debug :: uncompressedFile ( 'bundles/codefogtags/selectize.min.css' ) ; $ GLOBALS [ 'TL_CSS' ] [ ] = Debug :: uncompressedFile ( 'bundles/codefogtags/backend.min.css' ) ; if ( ! \ in_array ( 'assets/jquery/js/jquery.min.js' , ( array ) $ GLOBALS [ 'TL...
Add the widget assets .
5,414
public function onLoadCallback ( DataContainer $ dc ) : void { if ( ! ( $ dc instanceof Driver ) ) { return ; } $ ids = [ ] ; foreach ( $ this -> registry -> getAliases ( ) as $ alias ) { $ manager = $ this -> registry -> get ( $ alias ) ; if ( $ manager instanceof DefaultManager ) { foreach ( $ manager -> getTopTagIds...
On load callback .
5,415
public function onPanelCallback ( DataContainer $ dc ) : string { $ bag = $ this -> session -> getBag ( 'contao_backend' ) ; $ session = $ bag -> all ( ) ; $ sorting = [ '_default' , 'total_asc' , 'total_desc' ] ; $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( 'tl_filters' === $ request -> request -...
On generate panel callback .
5,416
public function generateLabel ( array $ row , $ label , DataContainer $ dc , array $ args ) : array { $ manager = $ this -> getManager ( $ row [ 'source' ] ) ; if ( null !== ( $ tag = $ manager -> find ( $ row [ 'id' ] ) ) ) { $ args [ 2 ] = $ manager -> countSourceRecords ( $ tag ) ; } return $ args ; }
Generate the label .
5,417
public function addAliasButton ( array $ buttons , DataContainer $ dc ) { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; if ( 'tl_select' === $ request -> request -> get ( 'FORM_SUBMIT' ) && $ request -> request -> has ( 'alias' ) ) { $ ids = $ this -> session -> all ( ) [ 'CURRENT' ] [ 'IDS' ] ; $ contr...
Automatically generate the folder URL aliases .
5,418
public static function setRoutePermissionsRoles ( $ route , $ permissions = [ ] , $ roles = [ ] ) { $ routePermission = parent :: firstOrNew ( [ 'route' => $ route ] ) ; if ( count ( $ permissions ) ) { $ routePermission -> permissions = json_encode ( $ permissions ) ; } if ( count ( $ roles ) ) { $ routePermission -> ...
Set route permissions and roles
5,419
public static function getRoutePermissionsRoles ( $ route ) { $ routePermission = parent :: where ( 'route' , $ route ) -> first ( ) ; if ( empty ( $ routePermission ) ) { return null ; } $ routePermission -> permissions = json_decode ( $ routePermission -> permissions ) ; $ routePermission -> roles = json_decode ( $ r...
Get permissions and roles of an route
5,420
public static function browse ( $ options = [ ] ) { $ find = new RoutePermission ( ) ; $ fillable = $ find -> fillable ; if ( ! empty ( $ options [ 'filters' ] ) ) { $ inFilters = array_intersect ( $ fillable , array_keys ( $ options [ 'filters' ] ) ) ; if ( ! empty ( $ inFilters ) ) { foreach ( $ inFilters as $ key ) ...
List permissions and roles of all route
5,421
public function findByAlias ( string $ alias ) : ? Tag { $ adapter = $ this -> framework -> getAdapter ( TagModel :: class ) ; $ criteria = $ this -> getCriteria ( ) ; $ criteria [ 'alias' ] = $ alias ; if ( null === ( $ model = $ adapter -> findOneByCriteria ( $ criteria ) ) ) { return null ; } return ModelCollection ...
Find the tag by alias .
5,422
public function findRelatedSourceRecords ( int $ sourceId , int $ limit = null ) : array { $ relations = $ this -> framework -> getAdapter ( Relations :: class ) ; if ( false === ( $ relation = $ relations -> getRelation ( $ this -> sourceTable , $ this -> sourceField ) ) ) { throw new \ RuntimeException ( \ sprintf ( ...
Find the related source records .
5,423
public function getTopTagIds ( array $ sourceIds = [ ] , int $ limit = null , bool $ withCount = false ) : array { $ model = $ this -> framework -> getAdapter ( Model :: class ) ; $ tagIds = $ model -> getRelatedValues ( $ this -> sourceTable , $ this -> sourceField , $ sourceIds ) ; $ tagIds = \ array_map ( 'intval' ,...
Get the top tag IDs .
5,424
protected function createTag ( string $ value ) : Tag { $ model = $ this -> framework -> createInstance ( TagModel :: class ) ; $ model -> tstamp = \ time ( ) ; $ model -> name = $ value ; $ model -> source = $ this -> alias ; $ model -> save ( ) ; return ModelCollection :: createTagFromModel ( $ model ) ; }
Create the tag .
5,425
protected function getCriteria ( array $ criteria = [ ] ) : array { $ criteria [ 'source' ] = $ this -> alias ; $ criteria [ 'sourceTable' ] = $ this -> sourceTable ; $ criteria [ 'sourceField' ] = $ this -> sourceField ; return $ criteria ; }
Get the criteria with necessary data .
5,426
protected function parseLexer ( array $ options ) { if ( ! empty ( $ options [ 'lang' ] ) && strtolower ( $ options [ 'lang' ] ) === 'plain' ) { return static :: DEFAULT_LEXER ; } if ( ! empty ( $ options [ 'lang' ] ) ) { return $ options [ 'lang' ] ; } return static :: DEFAULT_LEXER ; }
Returns the programming language from the options
5,427
protected function parsePygmentsOptions ( array $ options , $ code ) { $ pygmentsOptions = [ 'encoding' => 'utf-8' ] ; if ( ! empty ( $ options [ 'linenos' ] ) && $ options [ 'linenos' ] === true ) { $ pygmentsOptions [ 'linenos' ] = 'table' ; } if ( ! empty ( $ options [ 'start' ] ) ) { $ pygmentsOptions [ 'linenostar...
Returns an array of options formatted for use with pygmentize
5,428
protected function parseMarks ( $ marks ) { $ markedLines = [ ] ; foreach ( explode ( ',' , $ marks ) as $ nums ) { if ( strpos ( $ nums , '-' ) !== false ) { list ( $ from , $ to ) = explode ( '-' , $ nums ) ; $ markedLines = array_merge ( $ markedLines , range ( $ from , $ to ) ) ; } else { $ markedLines [ ] = $ nums...
Parses the marked lines in a way that pygmentize can use
5,429
public function generateColumns ( $ value , $ dataContainer ) { if ( ! $ dataContainer -> activeRecord ) { return null ; } $ current = $ dataContainer -> activeRecord ; if ( $ value && $ dataContainer -> activeRecord ) { $ stopElement = $ this -> getStopElement ( $ current ) ; $ nextElements = $ this -> getNextElements...
Generate the columns .
5,430
public function addClass ( string $ class ) : self { $ classes = explode ( ' ' , $ class ) ; foreach ( $ classes as $ class ) { if ( ! in_array ( $ class , $ this -> rowClasses ) ) { $ this -> rowClasses [ ] = $ class ; } } return $ this ; }
Add a class to the row .
5,431
public function buildResets ( int $ index ) : array { $ resets = [ ] ; foreach ( $ this -> columns as $ size => $ columns ) { $ column = $ this -> getColumnByIndex ( $ columns , $ index ) ; if ( $ column ) { $ resets = $ column -> buildReset ( $ resets , $ size ) ; } } return $ resets ; }
Build reset classes .
5,432
private function getColumnByIndex ( array $ columns , int $ index ) : ? Column { $ currentIndex = $ index ; if ( ! array_key_exists ( $ currentIndex , $ columns ) && $ currentIndex > 0 ) { $ currentIndex = ( $ currentIndex % count ( $ columns ) ) ; } if ( array_key_exists ( $ currentIndex , $ columns ) ) { return $ col...
Get a column by index .
5,433
protected function createSeparators ( int $ value , $ current , int $ sorting ) : int { for ( $ count = 1 ; $ count <= $ value ; $ count ++ ) { $ sorting = ( $ sorting + 8 ) ; $ this -> createGridElement ( $ current , 'bs_gridSeparator' , $ sorting ) ; } return $ sorting ; }
Create separators .
5,434
protected function updateSortings ( array $ elements , int $ lastSorting ) : int { foreach ( $ elements as $ element ) { if ( $ lastSorting > $ element -> sorting ) { $ element -> sorting = ( $ lastSorting + 8 ) ; $ element -> save ( ) ; } $ lastSorting = ( int ) $ element -> sorting ; } return $ lastSorting ; }
Update the sorting of given elements .
5,435
protected function createStopElement ( $ current , int $ sorting ) : Model { $ sorting = ( $ sorting + 8 ) ; return $ this -> createGridElement ( $ current , 'bs_gridStop' , $ sorting ) ; }
Create the stop element .
5,436
public static function bootCascadesDeletes ( ) { static :: deleting ( function ( $ model ) { $ model -> getConnectionResolver ( ) -> transaction ( function ( ) use ( $ model ) { $ relations = $ model -> getCascadeDeletesRelations ( ) ; if ( $ invalidRelations = $ model -> getInvalidCascadeDeletesRelations ( $ relations...
Use the boot function to setup model event listeners .
5,437
public function getCascadeDeletesRelations ( ) { $ names = $ this -> getCascadeDeletesRelationNames ( ) ; return array_combine ( $ names , array_map ( function ( $ name ) { $ relation = method_exists ( $ this , $ name ) ? $ this -> $ name ( ) : null ; return $ relation instanceof Relation ? $ relation : null ; } , $ na...
Get an array of the cascading relation names mapped to their relation types .
5,438
public function getCascadeDeletesRelationQuery ( $ relation ) { $ query = $ this -> $ relation ( ) ; if ( $ this -> isCascadeDeletesForceDeleting ( ) ) { if ( ! class_exists ( SoftDeletingScope :: class ) || ! is_null ( $ query -> getMacro ( 'withTrashed' ) ) ) { $ query = $ query -> withTrashed ( ) ; } } return $ quer...
Get the relationship query to use for the specified relation .
5,439
public function isCascadeDeletesForceDeleting ( ) { if ( property_exists ( $ this , 'softDelete' ) && ! class_exists ( SoftDeletingScope :: class ) ) { return ! $ this -> softDelete ; } return property_exists ( $ this , 'forceDeleting' ) && $ this -> forceDeleting ; }
Check if this cascading delete is a force delete .
5,440
public function build ( array $ classes , string $ size = '' ) : array { $ sizeSuffix = $ size ? '-' . $ size : $ size ; if ( $ this -> width === 'auto' ) { $ classes [ ] = 'col' . $ sizeSuffix . '-auto' ; } elseif ( $ this -> width === null || $ this -> width > 0 ) { $ widthSuffix = ( $ this -> width > 0 ) ? '-' . $ t...
Build the column definition .
5,441
public function buildReset ( array $ resets , string $ size = '' ) : array { if ( $ this -> reset === true ) { $ resets [ ] = sprintf ( 'd-none d%s-block' , $ size ? '-' . $ size : '' ) ; } elseif ( $ this -> reset !== false ) { $ resets [ ] = sprintf ( 'd-none d%s-block d-%s-none' , $ size ? '-' . $ size : '' , $ this...
Build the reset for the column .
5,442
private function buildAlign ( array & $ classes , string $ sizeSuffix = '' ) : void { if ( $ this -> align ) { $ classes [ ] = 'align-self' . $ sizeSuffix . '-' . $ this -> align ; } }
Build the align setting .
5,443
private function buildJustify ( array & $ classes , string $ sizeSuffix = '' ) : void { if ( $ this -> justify ) { $ classes [ ] = 'justify-content' . $ sizeSuffix . '-' . $ this -> justify ; } }
Build the justify setting .
5,444
private function buildOrder ( array & $ classes , string $ sizeSuffix ) : void { if ( $ this -> order ) { $ classes [ ] = 'order' . $ sizeSuffix . '-' . $ this -> order ; } }
Build the order setting .
5,445
private function buildOffset ( array & $ classes , string $ sizeSuffix ) : void { if ( $ this -> offset === null ) { return ; } if ( is_int ( $ this -> offset ) ) { $ classes [ ] = 'offset' . $ sizeSuffix . '-' . $ this -> offset ; } elseif ( strlen ( $ this -> offset ) ) { $ classes [ ] = $ this -> offset ; } }
Build offset setting .
5,446
public function onExtractThemeFiles ( \ DOMDocument $ xml , ZipReader $ archive , $ themeId ) : void { $ tables = $ xml -> getElementsByTagName ( 'table' ) ; for ( $ index = 0 ; $ index < $ tables -> length ; $ index ++ ) { if ( $ tables -> item ( $ index ) -> getAttribute ( 'name' ) !== 'tl_bs_grid' ) { continue ; } $...
Handle the extract theme files hook .
5,447
private function importGrid ( \ DOMElement $ item , int $ themeId ) : void { $ rows = $ item -> childNodes ; for ( $ index = 0 ; $ index < $ rows -> length ; $ index ++ ) { $ values = $ this -> getRowValues ( $ rows -> item ( $ index ) , $ themeId ) ; $ model = new GridModel ( ) ; $ model -> setRow ( $ values ) ; $ mod...
Import the grid definition .
5,448
private function getRowValues ( \ DOMElement $ item , int $ themeId ) : array { $ fields = $ item -> childNodes ; $ values = [ ] ; for ( $ index = 0 ; $ index < $ fields -> length ; $ index ++ ) { $ value = $ fields -> item ( $ index ) -> nodeValue ; $ name = $ fields -> item ( $ index ) -> getAttribute ( 'name' ) ; sw...
Prepare row values .
5,449
public function buildThemeConfig ( BuildContextConfig $ command ) : void { $ context = $ command -> getContext ( ) ; if ( ! $ context instanceof ThemeContext ) { return ; } $ theme = ThemeModel :: findByPk ( $ context -> getThemeId ( ) ) ; if ( $ theme && $ theme -> bs_grid_columns ) { $ config = $ command -> getConfig...
Build theme config .
5,450
protected function prepareFiles ( Collection $ collection , array $ auxDate = [ ] , $ deep = true ) : array { foreach ( $ collection as $ fileModel ) { if ( isset ( $ this -> images [ $ fileModel -> path ] ) || ! file_exists ( TL_ROOT . '/' . $ fileModel -> path ) ) { continue ; } if ( $ fileModel -> type == 'file' ) {...
Prepare all file data and return the aux dates .
5,451
protected function applySorting ( array $ auxDate , array & $ data ) : void { switch ( $ this -> get ( 'sortBy' ) ) { default : case 'name_asc' : uksort ( $ this -> images , 'basename_natcasecmp' ) ; break ; case 'name_desc' : uksort ( $ this -> images , 'basename_natcasercmp' ) ; break ; case 'date_asc' : array_multis...
Apply the sorting .
5,452
protected function preparePagination ( & $ offset , & $ limit ) : ? string { $ total = count ( $ this -> images ) ; $ perPage = $ this -> get ( 'perPage' ) ; if ( $ perPage > 0 && $ this -> get ( 'sortBy' ) != 'random' ) { $ parameter = 'page_g' . $ this -> get ( 'id' ) ; $ page = ( Input :: get ( $ parameter ) !== nul...
Prepare pagination .
5,453
protected function compileImages ( $ offset , $ limit ) : array { $ lightBoxId = 'lightbox[lb' . $ this -> get ( 'id' ) . ']' ; $ body = [ ] ; $ imageSizes = StringUtil :: deserialize ( $ this -> get ( 'bs_image_sizes' ) , true ) ; for ( $ index = $ offset ; $ index < $ limit ; $ index ++ ) { if ( ! isset ( $ this -> i...
Compile all images .
5,454
protected function getGalleryTemplateName ( ) : string { $ templateName = 'bs_gallery_default' ; if ( TL_MODE == 'FE' && $ this -> get ( 'galleryTpl' ) != '' ) { return ( string ) $ this -> get ( 'galleryTpl' ) ; } return $ templateName ; }
Get the gallery template name .
5,455
protected function applyCustomSorting ( ) : void { if ( $ this -> get ( 'orderSRC' ) != '' ) { $ tmp = StringUtil :: deserialize ( $ this -> get ( 'orderSRC' ) ) ; if ( ! empty ( $ tmp ) && is_array ( $ tmp ) ) { $ order = array_map ( function ( ) { } , array_flip ( $ tmp ) ) ; foreach ( $ this -> images as $ k => $ v ...
Apply custom sorting .
5,456
public function getGrid ( int $ gridId ) : Grid { if ( ! isset ( $ this -> grids [ $ gridId ] ) ) { $ this -> grids [ $ gridId ] = $ this -> builder -> build ( $ gridId ) ; } return $ this -> grids [ $ gridId ] ; }
Get a grid .
5,457
protected function generateModules ( array $ config , array $ modules , ? GridIterator $ iterator = null ) : array { $ buffer = [ ] ; foreach ( $ config as $ entry ) { if ( $ entry [ 'inactive' ] || ! $ entry [ 'module' ] ) { continue ; } if ( is_numeric ( $ entry [ 'module' ] ) ) { if ( ! empty ( $ modules [ $ entry [...
Generate all modules .
5,458
protected function getModuleIds ( array $ config ) : array { $ moduleIds = array_filter ( array_map ( function ( $ item ) { return $ item [ 'module' ] ; } , array_filter ( $ config , function ( $ item ) { return $ item [ 'inactive' ] == '' ; } ) ) , 'is_numeric' ) ; return $ moduleIds ; }
Get the module ids .
5,459
protected function preCompileModules ( array $ moduleIds ) : array { $ collection = ModuleModel :: findMultipleByIds ( $ moduleIds ) ; $ modules = [ ] ; if ( $ collection ) { foreach ( $ collection as $ model ) { $ modules [ $ model -> id ] = Controller :: getFrontendModule ( $ model , $ this -> getColumn ( ) ) ; } } r...
Precompile the modules .
5,460
private function migrateRow ( array $ row ) : void { $ data = [ 'tstamp' => time ( ) ] ; foreach ( self :: SIZES as $ size ) { $ size .= 'Size' ; $ data [ $ size ] = $ this -> migrateSize ( $ row [ $ size ] ) ; } $ this -> connection -> update ( 'tl_bs_grid' , $ data , [ 'id' => $ row [ 'id' ] ] ) ; }
Migrate a grid definition row .
5,461
private function migrateSize ( ? string $ size ) : ? string { if ( $ size === null ) { return null ; } $ columns = array_map ( function ( array $ column ) { if ( $ column [ 'width' ] === 'auto' ) { $ column [ 'width' ] = 'equal' ; } return $ column ; } , StringUtil :: deserialize ( $ size , true ) ) ; return serialize ...
Migrate a grid size .
5,462
protected function loadModel ( int $ gridId ) : void { $ model = GridModel :: findByPk ( $ gridId ) ; if ( ! $ model ) { throw new RuntimeException ( sprintf ( 'Grid ID "%s" not found' , $ gridId ) ) ; } $ this -> model = $ model ; }
Load grid model from the database .
5,463
private function createGrid ( ) : void { $ this -> grid = new Grid ( ) ; $ sizes = StringUtil :: deserialize ( $ this -> model -> sizes , true ) ; $ this -> buildRow ( ) ; foreach ( $ sizes as $ size ) { $ field = $ size . 'Size' ; $ definition = StringUtil :: deserialize ( $ this -> model -> { $ field } , true ) ; if ...
Create the grid from the model .
5,464
private function buildSize ( string $ size , array $ definition , array $ sizes ) : void { foreach ( $ definition as $ columnDefinition ) { $ column = $ this -> buildColumn ( $ columnDefinition , $ size , $ sizes ) ; $ this -> grid -> addColumn ( $ column , $ size ) ; } }
Build a grid size .
5,465
private function finish ( ) : Grid { $ grid = $ this -> grid ; $ this -> grid = null ; $ this -> model = null ; return $ grid ; }
Finish the grid building .
5,466
private function parseOffset ( $ offset ) { if ( $ offset === 'null' ) { $ offset = 0 ; } elseif ( is_numeric ( $ offset ) ) { $ offset = ( int ) $ offset ; } return $ offset ; }
Parse the offset definition value .
5,467
private function buildColumnWidth ( array $ definition , Column $ column ) : void { if ( $ definition [ 'width' ] ) { switch ( $ definition [ 'width' ] ) { case 'variable' : $ column -> variableWidth ( ) ; break ; case 'auto' : case 'equal' : break ; case 'null' : $ column -> width ( 0 ) ; break ; default : $ column ->...
Build the column width .
5,468
private function buildColumnResets ( array $ definition , Column $ column , string $ size , array $ sizes ) : void { switch ( $ definition [ 'reset' ] ) { case '2' : $ key = array_search ( $ size , $ sizes ) ; $ next = ( $ sizes [ ( $ key + 1 ) ] ?? null ) ; if ( $ next ) { $ column -> limitedReset ( ( string ) $ next ...
Build the column resets .
5,469
public function handle ( NodeInterface $ node , array $ data ) { if ( $ node -> getNodeType ( ) -> hasConfiguration ( 'options.template' ) ) { $ templateConfiguration = $ node -> getNodeType ( ) -> getConfiguration ( 'options.template' ) ; } else { return ; } $ propertyMappingConfiguration = $ this -> propertyMapper ->...
Create child nodes and change properties upon node creation
5,470
public function initializeDca ( ) : void { $ input = $ this -> framework -> getAdapter ( Input :: class ) ; if ( $ input -> get ( 'act' ) !== 'edit' ) { return ; } $ model = $ this -> repository -> findByPk ( Input :: get ( 'id' ) ) ; if ( ! $ model || $ model -> type !== 'bs_grid_gallery' ) { return ; } $ GLOBALS [ 'T...
Initialize the dca .
5,471
public function setMultiSrcFlags ( $ value , DataContainer $ dataContainer ) { if ( $ dataContainer -> activeRecord && $ dataContainer -> activeRecord -> type === 'bs_grid_gallery' ) { $ fieldsDca = & $ GLOBALS [ 'TL_DCA' ] [ $ dataContainer -> table ] [ 'fields' ] [ $ dataContainer -> field ] [ 'eval' ] ; $ fieldsDca ...
Dynamically add flags to the multiSRC field .
5,472
protected function createGridElement ( $ current , string $ type , int & $ sorting ) : Model { $ model = new ContentModel ( ) ; $ model -> tstamp = time ( ) ; $ model -> pid = $ current -> pid ; $ model -> ptable = $ current -> ptable ; $ model -> sorting = $ sorting ; $ model -> type = $ type ; $ model -> bs_grid_pare...
Create a grid element .
5,473
public function getAllModules ( \ MultiColumnWizard $ multiColumnWizard = null ) : array { if ( $ multiColumnWizard && $ multiColumnWizard -> dataContainer && $ multiColumnWizard -> dataContainer -> activeRecord ) { $ collection = ModuleModel :: findBy ( [ 'tl_module.pid = ?' , 'tl_module.id != ?' ] , [ $ multiColumnWi...
Get all modules for the grid module .
5,474
public function enterContext ( ) : void { if ( Input :: get ( 'act' ) === 'edit' ) { $ model = GridModel :: findByPk ( Input :: get ( 'id' ) ) ; if ( $ model ) { $ this -> environment -> enterContext ( ThemeContext :: forTheme ( ( int ) $ model -> pid ) ) ; } } }
Enter a bootstrap environment context .
5,475
public function initializePalette ( ) : void { if ( Input :: get ( 'act' ) === 'edit' ) { $ model = GridModel :: findByPk ( Input :: get ( 'id' ) ) ; $ sizes = array_map ( function ( $ value ) { return $ value . 'Size' ; } , StringUtil :: deserialize ( $ model -> sizes , true ) ) ; PaletteManipulator :: create ( ) -> a...
Initialize the palette .
5,476
public function getWidths ( ) : array { $ columns = $ this -> getColumns ( ) ; $ values = [ 'equal' , 'variable' , 'null' ] ; $ values = array_merge ( $ values , range ( 1 , $ columns ) ) ; return array_combine ( $ values , $ values ) ; }
Get all widths .
5,477
protected function setVersion ( $ version ) { if ( $ version == self :: V3 || $ version == self :: V4 || $ version == self :: V5 ) { $ this -> version = $ version ; } else { throw new Exception ( 'An invalid UUID version was specified.' ) ; } }
Set the version of the UUID .
5,478
function getUuid ( ) { return $ this -> time_low . '-' . $ this -> time_mid . '-' . $ this -> time_hi_version . '-' . $ this -> clock_seq_hi_variant . $ this -> clock_seq_low . '-' . $ this -> node ; }
Get the UUID .
5,479
protected function parse ( $ uuid ) { if ( is_string ( $ uuid ) ) { if ( substr ( $ uuid , 0 , 1 ) === '{' && substr ( $ uuid , - 1 , 1 ) === '}' ) { $ string = substr ( $ uuid , 1 , strlen ( $ uuid ) - 2 ) ; $ this -> parseStringToParts ( $ string ) ; } elseif ( substr ( $ uuid , 0 , 9 ) === 'urn:uuid:' ) { $ string =...
Parse the UUID from the available formats .
5,480
protected function parseStringToParts ( $ string ) { $ parts = explode ( '-' , $ string ) ; if ( count ( $ parts ) != 5 ) { throw new Exception ( 'The UUID string supplied could not be parsed.' ) ; } foreach ( $ parts as $ id => $ part ) { switch ( $ id ) { case 0 : $ this -> time_low = $ part ; break ; case 1 : $ this...
Parse a string in the form of 12345678 - 1234 - 5678 - 1234 - 567812345678 .
5,481
public static function createV5 ( $ namespace , $ name ) { if ( ! self :: isValid ( $ namespace ) ) { throw new Exception ( 'The UUID provided for the namespace is not valid.' ) ; } $ bin = self :: bin ( $ namespace ) ; $ hash = sha1 ( $ bin . $ name ) ; return new self ( sprintf ( '{%08s-%04s-%04x-%04x-%12s}' , substr...
Version 5 UUIDs are based on a namespace and name .
5,482
public static function createV4 ( ) { return new self ( sprintf ( '{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}' , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 4095 ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) ) )...
Version 4 UUIDs are random .
5,483
public static function createV3 ( $ namespace , $ name ) { if ( ! self :: isValid ( $ namespace ) ) { throw new Exception ( 'The UUID provided for the namespace is not valid.' ) ; } $ bin = self :: bin ( $ namespace ) ; $ hash = md5 ( $ bin . $ name ) ; return new self ( sprintf ( '{%08s-%04s-%04x-%04x-%12s}' , substr ...
Version 3 UUID are based on namespace and name utilizing a md5 hash .
5,484
public static function bin ( $ uuid ) { if ( ! self :: isValid ( $ uuid ) ) { throw new Exception ( 'The UUID provided for the namespace is not valid.' ) ; } $ hex = str_replace ( array ( '-' , '{' , '}' ) , '' , $ uuid ) ; $ bin = '' ; for ( $ i = 0 ; $ i < strlen ( $ hex ) ; $ i += 2 ) { $ bin .= chr ( hexdec ( $ hex...
Utility function to convert hex into bin for a UUID .
5,485
public function onExportTheme ( DOMDocument $ xml , ZipWriter $ archive , $ themeId ) : void { $ table = $ xml -> createElement ( 'table' ) ; $ table -> setAttribute ( 'name' , 'tl_bs_grid' ) ; $ tables = $ xml -> getElementsByTagName ( 'tables' ) -> item ( 0 ) ; $ table = $ tables -> appendChild ( $ table ) ; $ adapte...
Handle the export theme hook .
5,486
public function getGridOptions ( ) : array { $ collection = GridModel :: findAll ( [ 'order' => 'tl_bs_grid.title' ] ) ; $ options = [ ] ; if ( $ collection ) { foreach ( $ collection as $ model ) { $ parent = sprintf ( '%s [ID %s]' , $ model -> getRelated ( 'pid' ) -> name , $ model -> pid ) ; $ options [ $ parent ] [...
Get all available grids .
5,487
public function generateGridName ( $ value , $ dataContainer ) : string { if ( ! $ value ) { $ value = 'grid_' . $ dataContainer -> activeRecord -> id ; } return $ value ; }
Generate a grid name if not given .
5,488
public function apply ( NodeInterface $ node , array $ context ) { $ context [ 'node' ] = $ node ; if ( ! $ this -> isApplicable ( $ context ) ) { return ; } $ this -> setProperties ( $ node , $ context ) ; foreach ( $ this -> childNodes as $ childNodeTemplate ) { $ childNodeTemplate -> createOrFetchAndApply ( $ node ,...
Apply this template to the given node while providing context for EEL processing
5,489
public function set ( $ key , $ value ) { $ data = & $ this -> data ; if ( $ this -> isDotNotation ( $ key ) ) { $ keys = explode ( '.' , $ key ) ; $ key = array_pop ( $ keys ) ; foreach ( $ keys as $ segment ) { if ( ! isset ( $ data [ $ segment ] ) || ! is_array ( $ data [ $ segment ] ) ) { $ data [ $ segment ] = [ ]...
Set an array item to a given value using dot notation If no key is given to the method the entire array will be replaced
5,490
public function get ( $ key , $ default = null ) { if ( array_key_exists ( $ key , $ this -> data ) ) { return $ this -> data [ $ key ] ; } $ value = $ default ; if ( $ this -> isDotNotation ( $ key ) ) { $ keys = explode ( '.' , $ key ) ; $ value = $ this -> data ; foreach ( $ keys as $ segment ) { if ( ! is_array ( $...
Get an item from an array using dot notation
5,491
public function has ( $ key ) { $ result = array_key_exists ( $ key , $ this -> data ) ; if ( ! $ result && $ this -> isDotNotation ( $ key ) ) { $ result = true ; $ keys = explode ( '.' , $ key ) ; $ data = $ this -> data ; foreach ( $ keys as $ key ) { if ( ! is_array ( $ data ) || ! array_key_exists ( $ key , $ data...
Check if an item exists in an array using dot notation
5,492
public static function load ( $ source ) { self :: $ variables = is_array ( $ source ) ? $ source : require $ source ; self :: $ isLoaded = true ; self :: checkRequiredVariables ( ) ; }
Load . env . php file or array .
5,493
public static function get ( $ key , $ default = null ) { return isset ( self :: $ variables [ $ key ] ) ? self :: $ variables [ $ key ] : $ default ; }
Get env variable .
5,494
public static function set ( $ keys , $ value = null ) { if ( is_array ( $ keys ) ) { self :: $ variables = array_merge ( self :: $ variables , $ keys ) ; } else { self :: $ variables [ $ keys ] = $ value ; } }
Set env variable .
5,495
protected static function checkRequiredVariables ( ) { foreach ( self :: $ required as $ key ) { if ( ! isset ( self :: $ variables [ $ key ] ) ) { throw new MissingVariableException ( ".env variable '{$key}' is missing" ) ; } } }
Throw exception if any of required variables was not loaded .
5,496
protected function sendRequest ( $ method , $ endpoint , $ data = null ) { return $ this -> httpClient -> request ( $ method , $ this -> getEndpoint ( ) . $ endpoint , $ this -> getHeaders ( ) , $ data ) ; }
Execute the Guzzle request .
5,497
public function start ( ) { foreach ( $ this -> callbacks as $ event => $ callback ) { $ this -> client -> on ( $ event , $ callback ) ; } $ this -> connect ( ) ; }
start async client
5,498
public function isFormAction ( $ action ) { $ formActionss = preg_split ( '/[\s,]+/' , $ this -> formActions , - 1 , PREG_SPLIT_NO_EMPTY ) ; return ! empty ( $ this -> modelClass ) && in_array ( $ action , $ formActionss ) ; }
Check if action use for render form
5,499
private function createRequest ( RequestInterface $ request ) { $ buzzRequest = new BuzzRequest ( ) ; $ buzzRequest -> setMethod ( $ request -> getMethod ( ) ) ; $ buzzRequest -> fromUrl ( $ request -> getUri ( ) -> __toString ( ) ) ; $ buzzRequest -> setProtocolVersion ( $ request -> getProtocolVersion ( ) ) ; $ buzzR...
Converts a PSR request into a BuzzRequest request .