idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
9,000 | public function authorizationCodeUrl ( ) { if ( ! $ this -> endpointDiscovery ( ) ) return false ; $ url = $ this -> authorization_endpoint ; $ url .= '?response_type=code' ; $ url .= '&client_id=' . $ this -> mpClientId ; $ url .= '&scope=' . $ this -> scope . ' openid' ; $ url .= '&redirect_uri=' . $ this -> mpRedire... | Build the authorization code request URL |
9,001 | public function acquireAccessToken ( $ code ) { if ( ! $ this -> credentials ) { $ this -> credentials = new Credentials ( 'authorization_code' ) ; $ this -> endpointDiscovery ( ) ; $ body = $ this -> acquireToken ( $ code ) ; $ this -> credentials -> set ( $ body ) ; $ userInfo = $ this -> acquireUserInfo ( ) ; $ this... | Use the Authorization Code to get an Access Token |
9,002 | public function acquireUserInfo ( ) { $ client = new Client ( ) ; $ this -> buildHttpHeader ( ) ; $ endpoint = $ this -> userinfo_endpoint ; try { $ response = $ client -> request ( 'GET' , $ endpoint , [ 'header' => $ this -> headers , 'curl' => $ this -> setGetCurlopts ( ) , ] ) ; return json_decode ( $ response -> g... | Get user info from the OAuth server |
9,003 | private function getAccessTokenFields ( $ code ) { $ this -> oAuthFields = [ 'grant_type' => 'authorization_code' , 'code' => $ code , 'redirect_uri' => $ this -> mpRedirectURL , 'client_id' => $ this -> mpClientId , 'client_secret' => $ this -> mpClientSecret , ] ; $ this -> fieldCount = count ( $ this -> oAuthFields ... | Field list for Access Token Request |
9,004 | public function clear ( ) { if ( ! $ this -> credentials ) { $ this -> credentials = new Credentials ; } $ this -> credentials -> forget ( ) ; return true ; } | Erase the credentials |
9,005 | public function createRowAction ( Request $ request ) { $ container = $ this -> findContainer ( intval ( $ request -> attributes -> get ( 'containerId' ) ) ) ; $ target = is_null ( $ container -> getCopy ( ) ) ? $ container : $ container -> getCopy ( ) ; try { $ row = $ this -> getEditor ( ) -> createDefaultRow ( [ ] ,... | Create and append a new row to the container . |
9,006 | public function editAction ( Request $ request ) { $ container = $ this -> findContainerByRequest ( $ request ) ; try { $ response = $ this -> getEditor ( ) -> getContainerManager ( ) -> update ( $ container , $ request ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } if ( $ r... | Edit the container . |
9,007 | public function layoutAction ( Request $ request ) { $ container = $ this -> findContainerByRequest ( $ request ) ; $ data = $ request -> request -> get ( 'data' , [ ] ) ; try { $ this -> getEditor ( ) -> getLayoutAdapter ( ) -> updateContainerLayout ( $ container , $ data ) ; } catch ( EditorExceptionInterface $ e ) {... | Updates the container layout . |
9,008 | public function removeAction ( Request $ request ) { $ container = $ this -> findContainerByRequest ( $ request ) ; $ content = $ container -> getContent ( ) ; try { $ this -> getEditor ( ) -> getContainerManager ( ) -> delete ( $ container ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException... | Remove the container . |
9,009 | public function moveDownAction ( Request $ request ) { $ container = $ this -> findContainerByRequest ( $ request ) ; try { $ sibling = $ this -> getEditor ( ) -> getContainerManager ( ) -> moveDown ( $ container ) ; } catch ( EditorExceptionInterface $ e ) { return $ this -> handleException ( $ e ) ; } $ content = $ c... | Move down the container . |
9,010 | public function relationsErrors ( \ Asgard \ Entity \ Entity $ entity , $ groups = [ ] ) { $ data = [ ] ; $ validator = $ this -> createValidator ( $ entity ) ; $ validator -> set ( 'entity' , $ entity ) ; $ validator -> set ( 'dataMapper' , $ this ) ; foreach ( $ this -> relations ( $ this -> getEntityDefinition ( $ e... | Return relations errors . |
9,011 | protected function entityORM ( \ Asgard \ Entity \ Entity $ entity ) { if ( $ entity -> isNew ( ) ) return $ this -> orm ( $ entity -> getClass ( ) ) ; else return $ this -> orm ( $ entity -> getClass ( ) ) -> where ( [ 'id' => $ entity -> id ] ) ; } | Create an ORM instance for a specific entity . |
9,012 | public function getAllByPostType ( $ lang = "" , $ postTypeID ) { $ orderBy = ( isset ( $ _GET [ 'order' ] ) ) ? $ orderBy = $ _GET [ 'order' ] : 'tagID' ; $ orderType = ( isset ( $ _GET [ 'type' ] ) ) ? $ orderType = $ _GET [ 'type' ] : 'DESC' ; return Tag :: where ( 'postTypeID' , $ postTypeID ) -> orderBy ( $ orderB... | Get list of the tags for a specific post type . |
9,013 | public function delete ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'Tags' , 'delete' ) ) { return $ this -> noPermission ( ) ; } $ tagDeleteRes = $ this -> deleteTag ( $ id ) ; if ( gettype ( $ tagDeleteRes ) == "boolean" ) { if ( $ tagDeleteRes ) { return $ this -> response ( 'Tag is successfully deleted' ) ; } } e... | Delete request for a single tag . |
9,014 | public function bulkDelete ( Request $ request ) { if ( ! User :: hasAccess ( 'Tags' , 'delete' ) ) { return $ this -> noPermission ( ) ; } if ( count ( $ request -> all ( ) ) <= 0 ) { return $ this -> response ( 'Please select items to be deleted' , 500 ) ; } foreach ( $ request -> all ( ) as $ id ) { $ tagDeleteRes =... | Bulk Delete tags delete many tags with one request . |
9,015 | private function deleteTag ( $ id ) { $ tags = Tag :: find ( $ id ) ; if ( Tag :: hasPosts ( $ id ) ) { return $ this -> response ( "You can't delete this Tag. There are posts associated with it." , 403 ) ; } if ( $ tags -> delete ( ) ) { return true ; } return false ; } | Deletes tag by id . |
9,016 | public function store ( Request $ request ) { if ( ! User :: hasAccess ( 'Tags' , 'create' ) ) { return $ this -> noPermission ( ) ; } $ validatorData = [ 'title' => 'required' , 'postTypeID' => 'required' , 'slug' => 'required|max:500|unique:tags' , ] ; if ( isset ( $ request -> formData [ 'id' ] ) ) { $ tags = Tag ::... | Store a new tag in database . |
9,017 | public function detailsJSON ( $ lang , $ id ) { if ( ! User :: hasAccess ( 'Tags' , 'update' ) ) { return $ this -> noPermission ( ) ; } $ tags = Tag :: find ( $ id ) ; $ media = Media :: find ( $ tags -> featuredImageID ) ; $ final = array ( 'details' => $ tags , 'featuredImage' => $ media ) ; $ final [ 'events' ] = E... | JSON object with details for a specific tag . All data used in update form . |
9,018 | public function getAllWithoutPaginationByPostType ( $ lang = "" , $ postType = "" ) { return DB :: table ( 'tags' ) -> join ( 'post_type' , 'post_type.postTypeID' , 'tags.postTypeID' ) -> where ( 'post_type.slug' , $ postType ) -> orderBy ( 'name' , 'postTypeID' ) -> get ( ) ; } | Get all categories without pagination filtering by post type . |
9,019 | public function findByName ( $ name ) { $ this -> loadMenus ( ) ; $ rootId = 0 ; if ( 0 < strpos ( $ name , ':' ) ) { list ( $ rootName , $ name ) = explode ( ':' , $ name ) ; if ( null === $ root = $ this -> findByName ( $ rootName ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Root menu "%s" not found.' , $ ... | Finds the menu by his name . |
9,020 | public function get ( $ name , array $ options = [ ] ) { if ( null === $ menu = $ this -> findByName ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The menu "%s" is not defined.' , $ name ) ) ; } return $ this -> buildItem ( $ menu , array_merge ( [ 'attributes' => [ 'id' => $ menu [ 'name' ] . '-nav'... | Retrieves a menu by its name . |
9,021 | private function buildItem ( array $ data , array $ options = [ ] ) { $ options = array_merge ( $ options , [ 'label' => $ data [ 'title' ] , ] ) ; if ( ! empty ( $ data [ 'attributes' ] ) ) { $ options [ 'attributes' ] = $ data [ 'attributes' ] ; } if ( 0 < strlen ( $ data [ 'path' ] ) ) { $ options [ 'uri' ] = $ data... | Builds the menu item . |
9,022 | public function filter ( string $ column , $ value , bool $ negate = false ) : self { $ sql = $ this -> filterSQL ( $ column , $ value , $ negate ) ; return strlen ( $ sql [ 0 ] ) ? $ this -> where ( $ sql [ 0 ] , $ sql [ 1 ] ) : $ this ; } | Filter the results by a column and a value |
9,023 | public function any ( array $ criteria ) : self { $ sql = [ ] ; $ par = [ ] ; foreach ( $ criteria as $ row ) { if ( isset ( $ row [ 1 ] ) ) { $ temp = $ this -> filterSQL ( $ row [ 0 ] , $ row [ 1 ] ?? null , $ row [ 2 ] ?? false ) ; $ sql [ ] = $ temp [ 0 ] ; $ par = array_merge ( $ par , $ temp [ 1 ] ) ; } } return ... | Filter the results matching any of the criteria |
9,024 | public function sort ( string $ column , bool $ desc = false ) : self { return $ this -> order ( $ this -> getColumn ( $ column ) [ 'name' ] . ' ' . ( $ desc ? 'DESC' : 'ASC' ) ) ; } | Sort by a column |
9,025 | public function paginate ( int $ page = 1 , int $ perPage = 25 ) : self { return $ this -> limit ( $ perPage , ( $ page - 1 ) * $ perPage ) ; } | Get a part of the data |
9,026 | public function reset ( ) : self { $ this -> where = [ ] ; $ this -> joins = [ ] ; $ this -> group = [ ] ; $ this -> withr = [ ] ; $ this -> order = [ ] ; $ this -> having = [ ] ; $ this -> aliases = [ ] ; $ this -> li_of = [ 0 , 0 , 0 ] ; $ this -> qiterator = null ; return $ this ; } | Remove all filters sorting etc |
9,027 | public function groupBy ( string $ sql , array $ params = [ ] ) : self { $ this -> qiterator = null ; $ this -> group = [ $ sql , $ params ] ; return $ this ; } | Apply advanced grouping |
9,028 | public function order ( string $ sql , array $ params = [ ] ) : self { $ this -> qiterator = null ; $ name = null ; if ( ! count ( $ params ) ) { $ name = preg_replace ( '(\s+(ASC|DESC)\s*$)i' , '' , $ sql ) ; try { $ name = $ this -> getColumn ( trim ( $ name ) ) [ 'name' ] ; } catch ( \ Exception $ e ) { $ name = nul... | Apply advanced sorting |
9,029 | public function limit ( int $ limit , int $ offset = 0 , bool $ limitOnMainTable = false ) : self { $ this -> qiterator = null ; $ this -> li_of = [ $ limit , $ offset , $ limitOnMainTable ? 1 : 0 ] ; return $ this ; } | Apply an advanced limit |
9,030 | public function insert ( array $ data ) : array { $ table = $ this -> definition -> getName ( ) ; $ columns = $ this -> definition -> getFullColumns ( ) ; $ insert = [ ] ; foreach ( $ data as $ column => $ value ) { if ( isset ( $ columns [ $ column ] ) ) { $ insert [ $ column ] = $ this -> normalizeValue ( $ columns [... | Insert a new row in the table |
9,031 | public function update ( array $ data ) : int { $ table = $ this -> definition -> getName ( ) ; $ columns = $ this -> definition -> getFullColumns ( ) ; $ update = [ ] ; foreach ( $ data as $ column => $ value ) { if ( isset ( $ columns [ $ column ] ) ) { $ update [ $ column ] = $ this -> normalizeValue ( $ columns [ $... | Update the filtered rows with new data |
9,032 | public function delete ( ) : int { $ table = $ this -> definition -> getName ( ) ; $ sql = 'DELETE FROM ' . $ table . ' ' ; $ par = [ ] ; if ( count ( $ this -> where ) ) { $ sql .= 'WHERE ' ; $ tmp = [ ] ; foreach ( $ this -> where as $ v ) { $ tmp [ ] = $ v [ 0 ] ; $ par = array_merge ( $ par , $ v [ 1 ] ) ; } $ sql ... | Delete the filtered rows from the DB |
9,033 | public function with ( string $ relation ) : self { $ this -> qiterator = null ; $ parts = explode ( '.' , $ relation ) ; $ table = $ this -> definition ; array_reduce ( $ parts , function ( $ carry , $ item ) use ( & $ table ) { $ relation = $ table -> getRelation ( $ item ) ; if ( ! $ relation ) { throw new DBExcepti... | Solve the n + 1 queries problem by prefetching a relation by name |
9,034 | public function getList ( $ db = true ) { if ( ! file_exists ( $ this -> dir . '/migrations.json' ) ) return [ ] ; $ migrations = json_decode ( file_get_contents ( $ this -> dir . '/migrations.json' ) , true ) ; if ( $ db ) { $ tracking = [ ] ; $ this -> createTable ( ) ; foreach ( $ this -> db -> dal ( ) -> from ( '_m... | Return the list of registered migratins . |
9,035 | public function getDownList ( ) { $ list = $ this -> getList ( ) ; foreach ( $ list as $ migration => $ params ) { if ( isset ( $ params [ 'migrated' ] ) ) unset ( $ list [ $ migration ] ) ; } return $ list ; } | Return the list of down migrations . |
9,036 | public function getUpList ( ) { $ list = $ this -> getList ( ) ; foreach ( $ list as $ migration => $ params ) { if ( ! isset ( $ params [ 'migrated' ] ) ) unset ( $ list [ $ migration ] ) ; } return $ list ; } | Return the list of up migrations . |
9,037 | public function getNext ( ) { $ list = $ this -> getList ( ) ; foreach ( $ list as $ migration => $ params ) { if ( ! isset ( $ params [ 'migrated' ] ) ) return $ migration ; } } | Return the next migration to be executed . |
9,038 | public function getLast ( ) { $ list = array_reverse ( $ this -> getList ( ) ) ; foreach ( $ list as $ migration => $ params ) { if ( isset ( $ params [ 'migrated' ] ) ) return $ migration ; } } | Return the last executed migration . |
9,039 | public function getRevereMigratedUntil ( $ untilMigration ) { $ list = [ ] ; if ( ! in_array ( $ untilMigration , array_keys ( $ this -> getList ( ) ) ) ) throw new \ Exception ( $ untilMigration . ' is not in the list.' ) ; foreach ( array_reverse ( $ this -> getList ( ) ) as $ migration => $ params ) { if ( isset ( $... | Get all migrations until a given migration name |
9,040 | public function add ( $ migrationName ) { $ list = $ this -> getList ( false ) ; if ( isset ( $ list [ $ migrationName ] ) ) return ; $ list [ $ migrationName ] = [ 'added' => time ( ) + microtime ( true ) ] ; $ this -> writeMigrations ( $ list ) ; } | Register a migration . |
9,041 | public function remove ( $ migrationName ) { $ list = $ this -> getList ( false ) ; unset ( $ list [ $ migrationName ] ) ; $ this -> writeMigrations ( $ list ) ; } | Remove a migration . |
9,042 | public function unmigrate ( $ migrationName ) { $ this -> createTable ( ) ; $ this -> db -> dal ( ) -> from ( '_migrations' ) -> where ( 'name' , $ migrationName ) -> delete ( ) ; } | Mark a migration as unmigrated . |
9,043 | public function migrate ( $ migrationName ) { $ this -> createTable ( ) ; $ this -> db -> dal ( ) -> into ( '_migrations' ) -> insert ( [ 'name' => $ migrationName , 'migrated' => date ( 'Y-m-d H:i:s' ) ] ) ; } | Mark a migration as migrated . |
9,044 | protected function writeMigrations ( $ res ) { uasort ( $ res , function ( $ a , $ b ) { if ( isset ( $ a [ 'migrated' ] ) && ! isset ( $ b [ 'migrated' ] ) ) return - 1 ; elseif ( ! isset ( $ a [ 'migrated' ] ) && isset ( $ b [ 'migrated' ] ) ) return 1 ; elseif ( isset ( $ a [ 'migrated' ] ) && isset ( $ b [ 'migrate... | Persist migrations list . |
9,045 | public function detect ( Request $ request ) { if ( $ request -> isMethod ( 'post' ) ) { return $ request -> request -> get ( $ this -> parameterName ) ; } return $ request -> query -> get ( $ this -> parameterName ) ; } | Detects the current locale |
9,046 | public function GetTracksAround ( string $ community = NULL ) { $ result = $ this -> ExecuteCall ( "GetTracksAround" , ( object ) [ "community" => $ community ] , GnResponseType :: ListGnTrack , FALSE , PHP_INT_MAX ) ; return $ result ; } | Return the Tracks around . |
9,047 | public function getParent ( ) { $ master = $ this -> getMaster ( ) ; if ( empty ( $ master ) ) { return null ; } $ parent = $ master -> getParent ( ) ; if ( empty ( $ parent ) ) { return null ; } $ parentData = $ parent -> getLocalization ( $ this -> locale ) ; return $ parentData ; } | Loads localization item parent |
9,048 | public function getPublicChildren ( ) { $ coll = $ this -> getChildren ( PageLocalization :: CN ( ) ) ; foreach ( $ coll as $ key => $ child ) { if ( ! $ child instanceof PageLocalization ) { $ coll -> remove ( $ key ) ; continue ; } if ( ! $ child -> isPublic ( ) ) { $ coll -> remove ( $ key ) ; continue ; } } return ... | Loads only public children |
9,049 | public function setPagePriority ( $ pagePriority ) { if ( $ pagePriority < 0 || $ pagePriority > 1 ) { throw new \ UnexpectedValueException ( sprintf ( 'The valid range is from 0.0 to 1.0, [%s] received.' , $ pagePriority ) ) ; } $ this -> pagePriority = $ pagePriority ; } | The valid range is from 0 . 0 to 1 . 0 with 1 . 0 being the most important . |
9,050 | private function createDefaultTheme ( ) { $ this -> info ( "Creating default theme..." ) ; $ defaultThemePath = base_path ( 'themes/' . config ( 'project.defaultTheme' ) ) ; if ( file_exists ( $ defaultThemePath ) ) { File :: deleteDirectory ( $ defaultThemePath ) ; } else { ( new DummyTheme ( [ 'title' => 'Default The... | Create dummy theme . |
9,051 | private function setBar ( $ steps = 14 ) { if ( $ this -> option ( 'deleteUploads' ) ) { $ steps ++ ; } $ this -> bar = $ this -> output -> createProgressBar ( $ steps ) ; return $ this ; } | Set progress bar |
9,052 | private function welcomeMessage ( ) { $ this -> block ( ' -- Welcome to CMS -- ' , 'fg=white;bg=green;options=bold' ) ; $ this -> line ( '' ) ; $ this -> line ( 'Please answer the following questions:' ) ; $ this -> line ( '' ) ; return $ this ; } | Set welcome message |
9,053 | private function successfullyInstalled ( ) { $ this -> line ( '' ) ; $ this -> block ( 'Success! Accio is now installed' , 'fg=black;bg=green' ) ; $ this -> line ( '' ) ; $ this -> header ( 'Next steps' ) ; $ this -> line ( '' ) ; $ instructions = [ 'Visit your website <options=bold>' . $ this -> APP_URL . '</>' , 'Vis... | The response when accio is installed sucessfully |
9,054 | private function createDummyContent ( ) { $ this -> info ( "Creating default roles..." ) ; UserGroup :: createDefaultRoles ( ) ; $ this -> advanceBar ( ) ; $ this -> info ( "Creating admin user..." ) ; $ this -> createAdminUser ( ) ; $ this -> advanceBar ( ) ; $ this -> info ( "Creating default language..." ) ; factory... | Create dummy content |
9,055 | private function saveConfiguration ( ) { $ this -> info ( "Writing configuration file..." ) ; $ this -> env -> setEnv ( [ 'APP_URL' => $ this -> APP_URL , 'DB_CONNECTION' => $ this -> DB_TYPE , 'DB_HOST' => $ this -> DB_HOST , 'DB_PORT' => $ this -> DB_PORT , 'DB_DATABASE' => $ this -> DB_DATABASE , 'DB_USERNAME' => $ ... | Save configuration in . env file and in config run time . |
9,056 | private function askInstallingQuestions ( ) { $ this -> DB_TYPE = $ this -> ask ( 'Your Database type' , config ( 'database.default' ) ) ; $ this -> DB_HOST = $ this -> ask ( 'Your DB_HOST' , config ( 'database.connections.' . $ this -> DB_TYPE . '.host' ) ) ; $ this -> DB_PORT = $ this -> ask ( 'Your DB PORT' , config... | Ask installing questions |
9,057 | private function setSettings ( ) { Settings :: setSetting ( 'siteTitle' , $ this -> APP_NAME ) ; Settings :: setSetting ( 'adminEmail' , $ this -> ADMIN_EMAIL ) ; Settings :: setSetting ( 'defaultUserRole' , 'admin' ) ; Settings :: setSetting ( 'timezone' , $ this -> TIMEZONE ) ; Settings :: setSetting ( 'logo' , 1 ) ;... | Set CMS Settings |
9,058 | private function createAdminUser ( ) { $ user = factory ( User :: class ) -> create ( [ 'firstName' => $ this -> ADMIN_FIRST_NAME , 'lastName' => $ this -> ADMIN_LAST_NAME , 'slug' => str_slug ( $ this -> ADMIN_FIRST_NAME . '-' . $ this -> ADMIN_LAST_NAME ) , 'email' => $ this -> ADMIN_EMAIL , 'password' => Hash :: mak... | Forks a process to create the admin user . |
9,059 | private function DBConnectComand ( ) { switch ( $ this -> DB_TYPE ) { case 'sqlite' : $ dsn = 'sqlite:' . $ this -> DB_DATABASE ; $ this -> validateSqliteFile ( $ this -> DB_DATABASE ) ; break ; case 'pgsql' : $ dsn = 'pgsql:host=' . $ this -> DB_HOST . ';dbname=' . $ this -> DB_DATABASE . ';port=' . $ this -> DB_PORT ... | Create db connection command for PDO |
9,060 | protected function validateSqliteFile ( $ DB_DATABASE ) { if ( ! file_exists ( $ DB_DATABASE ) ) { $ directory = dirname ( $ DB_DATABASE ) ; if ( ! is_dir ( $ directory ) ) { mkdir ( $ directory , 0644 , true ) ; } new \ PDO ( 'sqlite:' . $ DB_DATABASE ) ; } return ; } | Validate that sql file exist |
9,061 | private function askAboutDefaultLanguage ( ) { $ languageList = [ ] ; foreach ( Language :: ISOlist ( ) as $ language ) { $ languageList [ ] = $ language -> name ; } $ languageName = $ this -> anticipate ( 'What is your site\'s primary language?' , $ languageList , 'English' ) ; $ this -> PRIMARY_LANGUAGE = Language ::... | Ask about default langauge |
9,062 | public function buildContent ( Model \ ContentInterface $ content ) { $ view = new ContentView ( ) ; $ attributes = $ view -> getAttributes ( ) -> addClass ( 'cms-content' ) ; if ( $ this -> editor -> isEnabled ( ) ) { $ attributes -> setId ( 'cms-content-' . $ content -> getId ( ) ) -> setData ( [ 'id' => $ content ->... | Builds the content view . |
9,063 | public function buildContainer ( Model \ ContainerInterface $ container ) { $ source = is_null ( $ container -> getCopy ( ) ) ? $ container : $ container -> getCopy ( ) ; $ view = new ContainerView ( ) ; $ attributes = $ view -> getAttributes ( ) -> addClass ( 'cms-container' ) ; $ attributes -> setId ( 'cms-container-... | Builds the container view . |
9,064 | public function buildRow ( Model \ RowInterface $ row ) { $ view = new RowView ( ) ; $ attributes = $ view -> getAttributes ( ) -> addClass ( 'cms-row' ) ; if ( $ this -> editor -> isEnabled ( ) ) { $ container = $ row -> getContainer ( ) ; $ attributes -> setId ( 'cms-row-' . $ row -> getId ( ) ) -> setData ( [ 'id' =... | Builds the row view . |
9,065 | public function buildBlock ( Model \ BlockInterface $ block ) { $ editable = $ this -> editor -> isEnabled ( ) ; $ view = new BlockView ( ) ; $ attributes = $ view -> getAttributes ( ) -> addClass ( 'cms-block' ) ; if ( $ editable ) { $ row = $ block -> getRow ( ) ; $ attributes -> setId ( 'cms-block-' . $ block -> get... | Builds the block view . |
9,066 | public function getDirList ( ) : array { if ( ! $ this -> hasDirs ( ) ) { return [ ] ; } $ path = \ str_replace ( '\\' , '/' , \ trim ( $ this -> dirs ) ) ; $ path = \ trim ( $ path , '/' ) ; while ( false !== \ strpos ( $ path , '//' ) ) { $ path = \ str_replace ( '//' , '/' , $ path ) ; } if ( '' !== $ path ) { retur... | Provides a lightly cleaned up array of the directory path parts without wrappers or root . |
9,067 | public function normalizeFile ( string $ file , int $ options = self :: MODE_DEFAULT ) : string { $ file = \ str_replace ( '\\' , '/' , $ file ) ; if ( false === \ strrpos ( $ file , '/' ) ) { $ mess = 'An empty path is NOT allowed' ; throw new \ DomainException ( $ mess ) ; } [ $ fileName , $ path ] = \ explode ( '/' ... | Used to normalize a file with a path . |
9,068 | public function normalizePath ( string $ path , int $ options = self :: MODE_DEFAULT ) : string { $ this -> validateOptions ( $ options ) ; $ pathInfo = $ this -> getPathInfo ( ) ; $ pathInfo -> initAll ( $ path ) ; $ this -> checkWrappers ( $ options ) ; $ this -> absoluteChecks ( $ options ) ; $ path = '' ; if ( $ pa... | Used to normalize a file path without all the shortcomings of the built - in functions . |
9,069 | protected function checkWrappers ( int $ options ) { $ hasWrappers = $ this -> getPathInfo ( ) -> hasWrappers ( ) ; if ( ( $ options & self :: WRAPPER_DISABLED ) && $ hasWrappers ) { $ mess = 'Given wrapper when wrapper(s) are disabled' ; throw new \ DomainException ( $ mess ) ; } if ( ( $ options & self :: WRAPPER_REQ... | Use to make check on the wrapper part of path . |
9,070 | protected function cleanPartsPath ( ) : array { $ parts = [ ] ; foreach ( $ this -> getPathInfo ( ) -> getDirList ( ) as $ part ) { if ( '.' === $ part ) { continue ; } if ( '..' === $ part ) { if ( \ count ( $ parts ) < 1 ) { $ mess = 'Unusual above root path found' ; throw new \ DomainException ( $ mess ) ; } \ array... | Cleans up the actual path part of the given string . |
9,071 | public function getFpn ( ) : FilePathNormalizerInterface { if ( null === $ this -> fpn ) { $ this -> fpn = new FilePathNormalizer ( ) ; } return $ this -> fpn ; } | Get the instance of FilePathNormalizerInterface . |
9,072 | public static function factory ( $ config = array ( ) ) { $ defaults = array ( ) ; $ required = array ( 'base_url' , 'login' , 'password' ) ; $ config = Collection :: fromConfig ( $ config , $ defaults , $ required ) ; $ client = new self ( $ config [ 'base_url' ] , $ config ) ; return $ client ; } | Basic factory method to create a new client . Extend this method in subclasses to build more complex clients . |
9,073 | protected function initialize ( ) { if ( is_null ( $ this -> synchronizerToken ) ) { $ this -> synchronizerToken = new SynchronizerTokenNativeSession ( ) ; } if ( is_null ( $ this -> validator ) ) { $ this -> validator = new Validator ( $ this -> configuration , $ this -> getTranslator ( ) ) ; } } | initialize dependencies like synchronizer token validator |
9,074 | protected function prepareConfiguration ( array $ options = null ) { $ configuration = clone $ this -> configuration ; if ( is_array ( $ options ) ) { $ options = array_replace ( $ configuration -> all ( ) , $ options ) ; $ configuration = new Configuration ( $ options ) ; } return $ configuration ; } | prepare configuration with optional deviating options |
9,075 | public function createFormCollection ( array $ entities , $ name , array $ options = null ) { $ configuration = $ this -> prepareConfiguration ( $ options ) ; $ this -> initialize ( ) ; $ form = new FormCollection ( $ entities , $ name , $ configuration ) ; if ( ! is_null ( $ validator = $ this -> validator ) ) { $ for... | create form collection |
9,076 | public function toXML ( DOMDocument $ dom ) { $ blockNode = $ dom -> createElement ( 'block' ) ; foreach ( $ this -> attributes as $ attrName => $ attrValue ) { switch ( $ attrName ) { case 'id' : $ blockNode -> setAttribute ( 'id' , 'id_' . $ attrValue ) ; break ; case 'action' : $ blockNode -> setAttribute ( 'action'... | Creates DOMElement with block data |
9,077 | public static function createFromXML ( DOMElement $ node ) { $ newObj = new eZPageBlock ( ) ; if ( $ node -> hasAttributes ( ) ) { foreach ( $ node -> attributes as $ attr ) { if ( $ attr -> name == 'id' ) { $ value = explode ( '_' , $ attr -> value ) ; $ newObj -> setAttribute ( $ attr -> name , $ value [ 1 ] ) ; } el... | Creates and return eZPageBlock object from given XML |
9,078 | public function removeProcessed ( ) { if ( $ this -> hasAttribute ( 'action' ) ) { unset ( $ this -> attributes [ 'action' ] ) ; } if ( $ this -> getItemCount ( ) > 0 ) { unset ( $ this -> attributes [ 'items' ] ) ; } return $ this ; } | Cleanup processed objects removes action attribute removes all items marked with remove action |
9,079 | protected function merge ( $ items , $ mergeAdded = false ) { $ itemObjects = array ( ) ; foreach ( $ items as $ item ) { $ oid = $ item [ 'object_id' ] ; $ itemObjects [ $ oid ] = new eZPageBlockItem ( $ item , false ) ; } if ( isset ( $ this -> attributes [ 'items' ] ) && $ this -> attributes [ 'items' ] ) { foreach ... | Merges existing object items with those coming from database |
9,080 | protected function getWaitingItems ( ) { $ waitingItems = eZFlowPool :: waitingItems ( $ this -> id ( ) ) ; $ merged = $ this -> merge ( $ waitingItems , true ) ; usort ( $ merged , array ( $ this , 'sortItems' ) ) ; return $ merged ; } | Fetches waiting items and do merge with those already available |
9,081 | protected function getValidItems ( ) { $ validItems = eZFlowPool :: validItems ( $ this -> id ( ) ) ; $ merged = $ this -> merge ( $ validItems ) ; usort ( $ merged , array ( $ this , 'sortItemsByPriority' ) ) ; return $ merged ; } | Fetches valid items and do merge with those already available |
9,082 | protected function getLastValidItem ( ) { $ validItems = $ this -> getValidItems ( ) ; $ result = null ; if ( ! empty ( $ validItems ) ) { $ result = null ; $ lastTime = 0 ; foreach ( $ validItems as $ item ) { if ( $ item -> attribute ( 'ts_visible' ) >= $ lastTime ) { $ lastTime = $ item -> attribute ( 'ts_visible' )... | Fetch last valid item in valid list if valid is empty return null in case of the same valid items return the last one in order |
9,083 | public function sortItems ( eZPageBlockItem $ a , eZPageBlockItem $ b ) { if ( $ a -> attribute ( 'priority' ) == $ b -> attribute ( 'priority' ) ) { if ( $ a -> attribute ( 'ts_publication' ) > $ b -> attribute ( 'ts_publication' ) ) { return 1 ; } else if ( $ a -> attribute ( 'ts_publication' ) < $ b -> attribute ( '... | Sorting items based on the ts_publication and priority attributes |
9,084 | public function sortItemsByPriority ( eZPageBlockItem $ a , eZPageBlockItem $ b ) { if ( $ a -> attribute ( 'priority' ) > $ b -> attribute ( 'priority' ) ) { return - 1 ; } else if ( $ a -> attribute ( 'priority' ) < $ b -> attribute ( 'priority' ) ) { return 1 ; } else { return 0 ; } } | Sorting items based on the priority attribute |
9,085 | protected function iocContainer ( ) { if ( property_exists ( $ this , 'container' ) && isset ( $ this -> container ) && $ this -> container instanceof ContainerInterface ) { return $ this -> container ; } return self :: $ staticContainer ; } | Get instance of container associated with given object uses global container as fallback if not . Method generally used by traits . |
9,086 | public function renderTableRow ( $ model , $ key , $ index ) { $ cells = [ ] ; foreach ( $ this -> columns as $ column ) { $ cells [ ] = $ column -> renderDataCell ( $ model , $ key , $ index ) ; } if ( $ this -> rowOptions instanceof Closure ) { $ options = call_user_func ( $ this -> rowOptions , $ model , $ key , $ i... | Renders a table row with the given data model and key . |
9,087 | public function renderTableFooter ( ) { $ cells = [ ] ; foreach ( $ this -> columns as $ column ) { $ cells [ ] = $ column -> renderFooterCell ( ) ; } $ content = Html :: tag ( 'tr' , implode ( '' , $ cells ) , $ this -> footerRowOptions ) ; return "<tfoot>\n" . $ content . "\n</tfoot>" ; } | Renders the table footer . |
9,088 | public function renderItems ( ) { $ rows = [ ] ; $ this -> dataProvider -> setKeys ( [ ] ) ; $ models = array_values ( $ this -> dataProvider -> getModels ( ) ) ; $ models = $ this -> normalizeData ( $ models , $ this -> parentRootValue ) ; $ this -> dataProvider -> setModels ( $ models ) ; $ this -> dataProvider -> se... | Renders the data models for the grid view . |
9,089 | protected function normalizeData ( array $ data , $ parentId = null ) { $ result = [ ] ; foreach ( $ data as $ element ) { if ( ArrayHelper :: getValue ( $ element , $ this -> parentColumnName ) === $ parentId ) { $ result [ ] = $ element ; $ children = $ this -> normalizeData ( $ data , ArrayHelper :: getValue ( $ ele... | Normalize tree data |
9,090 | public static function notify ( $ msg ) { self :: $ msg = $ msg ; add_action ( 'wp_footer' , [ self :: class , 'print_message' ] , 999 ) ; if ( isset ( $ _GET [ 'page' ] ) && 'geot-settings' == $ _GET [ 'page' ] ) { add_action ( 'admin_footer' , [ self :: class , 'print_message' ] , 999 ) ; } } | Display front end notice to admin |
9,091 | public function build ( array $ elements ) { $ parsedElements = $ this -> parse ( $ elements ) ; $ result = $ this -> group ( $ parsedElements ) ; return $ result ; } | Builds the menu |
9,092 | public function setLanguage ( $ lang = 'en' , $ langDir = __DIR__ . '/lang/' ) { $ this -> lang = $ lang ; $ this -> langDir = $ langDir ; $ langFile = realpath ( $ langDir . $ lang . '.php' ) ; if ( ! file_exists ( $ langFile ) ) { throw new \ InvalidArgumentException ( 'No such file: ' . $ langDir . $ lang . '.php' )... | Set the rules of this Validator . |
9,093 | public function setRuleMessage ( string $ name , string $ message ) { $ this -> messages [ 'rules' ] [ $ name ] = $ message ; return $ this ; } | Set the message for the rule with the given name . |
9,094 | public function setAttributeMessage ( string $ name , string $ message ) { $ this -> messages [ 'custom' ] [ $ name ] = $ message ; return $ this ; } | Set the message for the attribute with the given name . |
9,095 | public function reset ( ) { $ this -> rules = [ ] ; $ this -> messages = [ 'rules' => [ ] , 'custom' => [ ] ] ; $ this -> clear ( ) ; Validate :: addRuleSet ( $ this ) ; $ this -> setLanguage ( $ this -> lang , $ this -> langDir ) ; return $ this ; } | Resets the validator to its initial state . |
9,096 | public function getProcessedErrors ( ) { $ errors = [ ] ; foreach ( $ this -> errors as $ error ) { $ message = ArrDots :: get ( $ this -> messages [ 'custom' ] , $ error [ 'attribute' ] ) ?? ArrDots :: get ( $ this -> messages [ 'rules' ] , $ error [ 'rule' ] ) ; foreach ( $ error [ 'replacements' ] as $ search => $ r... | Return a processed array of errors . |
9,097 | protected function onSuccess ( ) { $ redirectionUrl = "" ; if ( isset ( $ this -> model -> redirectUrl ) ) { $ redirectionUrl = $ this -> model -> redirectUrl ; } if ( ! $ redirectionUrl ) { $ redirectionUrl = $ this -> getDefaultSuccessUrl ( ) ; } if ( ! $ redirectionUrl ) { $ redirectionUrl = "/" ; } else { if ( ! $ ... | Handles the behaviour if the login is successful . |
9,098 | protected function isRedirectionUrlValid ( string $ url ) { if ( stripos ( trim ( $ url ) , "http" ) === 0 ) { return false ; } if ( stripos ( $ url , "://" ) !== false ) { return false ; } return true ; } | Checks to make sure the URL is a relative or absolute path on the existing domain . |
9,099 | public static function stripslashes ( array $ input ) : array { $ result = [ ] ; foreach ( $ input as $ k => $ v ) { $ result [ $ k ] = \ is_array ( $ v ) ? self :: stripslashes ( $ v ) : \ stripslashes ( $ v ) ; } return $ result ; } | Recursively strip slashes from the given array . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.