idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
42,800 | public function fetch ( ) { $ this -> parse ( ) ; $ parseEvent = new QueryEvent ( $ this ) ; $ this -> getEntityManager ( ) -> getEventManager ( ) -> dispatch ( QueryEvents :: PARSE , $ parseEvent ) ; $ result = call_user_func ( $ this -> handlers [ $ this -> getOperation ( ) ] , $ this ) ; $ executeEvent = new QueryEv... | Runs the query and fetches the results . |
42,801 | public function addOperation ( $ operation ) { if ( ! in_array ( $ operation , $ this -> operations , true ) ) { $ this -> operations [ ] = $ operation ; } } | Adds a new operation to the list supported . |
42,802 | public function removeOperation ( $ operation ) { if ( in_array ( $ operation , $ this -> operations , true ) ) { $ key = array_search ( $ operation , $ this -> operations , true ) ; unset ( $ this -> operations [ $ key ] ) ; } } | Removes an operation from the list supported . |
42,803 | private function addAsset ( AssetInterface $ asset ) { if ( $ asset instanceof FileAssetInterface ) { $ this -> normalizeAsset ( $ asset ) ; } $ this -> assets [ ] = $ asset ; } | Add an file snippet or widget asset to the render queue . |
42,804 | private function normalizeAsset ( FileAssetInterface $ asset ) { $ path = $ asset -> getPath ( ) ; if ( $ path === null ) { throw new \ RuntimeException ( 'Extension file assets must have a path set.' ) ; } if ( $ asset -> getPackageName ( ) ) { return ; } if ( $ this -> isAbsoluteUrl ( $ path ) ) { $ asset -> setPacka... | Normalizes the path and package name of the asset file . |
42,805 | public function deleteUser ( $ id ) { $ user = $ this -> getRepository ( ) -> find ( $ id ) ; if ( ! $ user ) { $ this -> app [ 'logger.flash' ] -> warning ( Trans :: __ ( 'general.phrase.user-not-exist' ) ) ; return false ; } $ userId = $ user -> getId ( ) ; if ( $ result = $ this -> getRepository ( ) -> delete ( $ us... | Remove a user from the database . |
42,806 | public function getUsers ( ) { if ( ! empty ( $ this -> users ) ) { return $ this -> users ; } try { if ( ! $ tempusers = $ this -> getRepository ( ) -> getUsers ( ) ) { return [ ] ; } foreach ( $ tempusers as $ userEntity ) { $ id = $ userEntity -> getId ( ) ; $ this -> users [ $ id ] = $ userEntity -> toArray ( ) ; }... | Get an array with the current users . |
42,807 | public function getUser ( $ userId ) { $ this -> getUsers ( ) ; if ( $ userId && array_key_exists ( $ userId , $ this -> users ) ) { return $ this -> users [ $ userId ] ; } try { if ( $ userEntity = $ this -> getRepository ( ) -> getUser ( $ userId ) ) { return $ userEntity -> toArray ( ) ; } } catch ( TableNotFoundExc... | Get a user specified by ID username or email address . |
42,808 | public function getCurrentUser ( ) { if ( $ this -> currentuser === null ) { $ this -> currentuser = $ this -> app [ 'session' ] -> isStarted ( ) ? $ this -> app [ 'session' ] -> get ( 'authentication' ) : null ; if ( $ this -> currentuser instanceof AccessControl \ Token \ Token ) { $ this -> currentuser = $ this -> c... | Get the current user as an array . |
42,809 | public function getCurrentUserProperty ( $ property ) { $ currentuser = $ this -> getCurrentUser ( ) ; return isset ( $ currentuser [ $ property ] ) ? $ currentuser [ $ property ] : null ; } | Get the current user s property . |
42,810 | public function isEnabled ( $ id = false ) { $ user = $ id ? $ this -> getUser ( $ id ) : $ this -> getCurrentUser ( ) ; return ( bool ) $ user [ 'enabled' ] ; } | Check a user s enable status . |
42,811 | public function setEnabled ( $ id , $ enabled = true ) { if ( ! $ user = $ this -> getUser ( $ id ) ) { return false ; } $ user [ 'enabled' ] = ( int ) $ enabled ; return $ this -> saveUser ( $ user ) ; } | Enable or disable a user specified by id . |
42,812 | public function hasRole ( $ id , $ role ) { if ( ! $ user = $ this -> getUser ( $ id ) ) { return false ; } return in_array ( $ role , $ user [ 'roles' ] ) ; } | Check if a certain user has a specific role . |
42,813 | public function addRole ( $ id , $ role ) { if ( empty ( $ role ) || ! $ user = $ this -> getUser ( $ id ) ) { return false ; } $ user [ 'roles' ] [ ] = $ role ; return $ this -> saveUser ( $ user ) ; } | Add a certain role from a specific user . |
42,814 | public function removeRole ( $ id , $ role ) { $ user = $ this -> getUser ( $ id ) ; if ( empty ( $ user ) || empty ( $ role ) ) { return false ; } $ user [ 'roles' ] = array_diff ( $ user [ 'roles' ] , [ ( string ) $ role ] ) ; return $ this -> saveUser ( $ user ) ; } | Remove a certain role from a specific user . |
42,815 | public function filterManipulatableRoles ( $ id , array $ newRoles ) { $ oldRoles = [ ] ; if ( $ id && $ user = $ this -> getUser ( $ id ) ) { $ oldRoles = $ user [ 'roles' ] ; } $ manipulatableRoles = $ this -> app [ 'permissions' ] -> getManipulatableRoles ( $ this -> getCurrentUser ( ) ) ; $ roles = [ ] ; foreach ( ... | Ensure changes to the user s roles match what the current user has permissions to manipulate . |
42,816 | public function checkForRoot ( ) { if ( $ this -> getCurrentUser ( ) === false ) { return false ; } foreach ( $ this -> getUsers ( ) as $ user ) { if ( in_array ( 'root' , $ user [ 'roles' ] ) ) { return true ; } } $ this -> app [ 'schema' ] -> update ( ) ; $ this -> app [ 'logger.flash' ] -> info ( Trans :: __ ( 'gene... | Check for a user with the root role . |
42,817 | public function isContentStatusTransitionAllowed ( $ fromStatus , $ toStatus , $ contenttype , $ contentid = null ) { $ user = $ this -> getCurrentUser ( ) ; return $ this -> app [ 'permissions' ] -> isContentStatusTransitionAllowed ( $ fromStatus , $ toStatus , $ user , $ contenttype , $ contentid ) ; } | Check to see if the current user can change the status on the record . |
42,818 | private function canonicalizeFieldValue ( $ fieldname , $ fieldvalue ) { switch ( $ fieldname ) { case 'email' : return strtolower ( trim ( $ fieldvalue ) ) ; case 'username' : return strtolower ( preg_replace ( '/[^a-zA-Z0-9_\\-]/' , '' , $ fieldvalue ) ) ; default : return trim ( $ fieldvalue ) ; } } | Create a correctly canonicalized value for a field depending on its name . |
42,819 | public function checkAvailability ( $ fieldname , $ value , $ currentid = 0 ) { foreach ( $ this -> users as $ user ) { if ( ( $ this -> canonicalizeFieldValue ( $ fieldname , $ user [ $ fieldname ] ) === $ this -> canonicalizeFieldValue ( $ fieldname , $ value ) ) && ( $ user [ 'id' ] != $ currentid ) ) { return false... | Check if a certain field with a certain value doesn t exist already . Depending on the field type different pre - massaging of the compared values are applied because what constitutes equal for the purpose of this filtering depends on the field type . |
42,820 | public function setGlobalOverride ( $ uri ) { if ( is_string ( $ uri ) ) { if ( strpos ( $ uri , 'http' ) !== 0 ) { $ uri = 'http://' . $ uri ; } $ uri = new Uri ( $ uri ) ; } Assert :: nullOrIsInstanceOf ( $ uri , UriInterface :: class , 'Expected a string, UriInterface, or null. Got: %s' ) ; $ this -> globalOverride ... | This overrides the scheme and host for all urls generated including the canonical one . |
42,821 | public function setOverride ( $ uri ) { if ( is_string ( $ uri ) ) { $ uri = new Uri ( $ uri ) ; } Assert :: nullOrIsInstanceOf ( $ uri , UriInterface :: class , 'Expected a string, UriInterface, or null. Got: %s' ) ; $ this -> override = $ uri ; } | This overrides the the canonical url . It will be resolved against the current request . |
42,822 | public function getUrl ( ) { if ( $ this -> request === null ) { return null ; } if ( ! $ this -> request -> attributes -> get ( '_route' ) ) { return null ; } if ( $ this -> override ) { $ this -> resolveCurrentOverride ( ) ; return ( string ) $ this -> override ; } return $ this -> urlGenerator -> generate ( $ this -... | Returns the canonical url for the current request or null if called outside of the request cycle . |
42,823 | private function setRequest ( Request $ request = null ) { $ this -> request = $ request ; $ this -> override = null ; } | Set the current request and reset the current override . |
42,824 | private function resolveCurrentOverride ( ) { if ( $ this -> override -> getHost ( ) !== '' ) { return ; } $ context = $ this -> urlGenerator -> getContext ( ) ; if ( Uri :: isRelativePathReference ( $ this -> override ) ) { $ this -> override = $ this -> override -> withPath ( $ context -> getPathInfo ( ) . '/' . $ th... | If there is a current override resolve it to an absolute url based on current request . |
42,825 | protected function handleLoginRetreat ( Request $ request , RedirectResponse $ response ) { $ route = $ request -> attributes -> get ( '_route' ) ; if ( $ response -> getTargetUrl ( ) === $ this -> urlGenerator -> generate ( 'login' ) && $ route !== 'logout' ) { $ this -> session -> set ( 'retreat' , [ 'route' => $ rou... | When redirecting to login page set the retreat variable in the session . This allows a redirect back to the current page after successful login . |
42,826 | private function getCallableResult ( ) { if ( is_callable ( $ this -> callback ) ) { return call_user_func_array ( $ this -> callback , ( array ) $ this -> callbackArguments ) ; } elseif ( is_string ( $ this -> callback ) || $ this -> callback instanceof Markup ) { return ( string ) $ this -> callback ; } try { $ msg =... | Get the output from the callback . |
42,827 | public function getSchemaTables ( Schema $ schema ) { $ tables = [ ] ; foreach ( $ this -> tables -> keys ( ) as $ name ) { $ table = $ this -> tables [ $ name ] ; $ tables [ $ name ] = $ table -> buildTable ( $ schema , $ name , $ this -> charset , $ this -> collate ) ; } foreach ( $ this -> tableGenerators as $ gener... | Get all the registered extension tables . |
42,828 | public static function tokenName ( $ tokenType ) { switch ( $ tokenType ) { case self :: T_UNDEFINED : return 'T_UNDEFINED' ; case self :: T_OPEN_PARENS : return 'T_OPEN_PARENS' ; case self :: T_CLOSE_PARENS : return 'T_CLOSE_PARENS' ; case self :: T_OR : return 'T_OR' ; case self :: T_AND : return 'T_AND' ; case self ... | Get the symbolic name of a lexer token type . |
42,829 | public function getClassMetadata ( ) { $ class = $ this -> class ; if ( $ this -> classMetadata === null ) { $ classMetadata = $ this -> metadata -> loadMetadataForClass ( $ class ) ; $ this -> classMetadata = $ classMetadata ; } return $ this -> classMetadata ; } | Gets the metadata instance . |
42,830 | public function getEntity ( $ entity = null ) { if ( $ entity === null ) { $ class = $ this -> class ; $ entity = new $ class ( ) ; } if ( $ entity instanceof Content && ! $ entity -> getContenttype ( ) && $ ct = $ this -> getClassMetadata ( ) -> getBoltName ( ) ) { $ contentType = $ this -> metadata -> createContentTy... | Returns a new empty entity class . |
42,831 | public function create ( $ data , $ entity = null ) { $ entity = $ this -> getEntity ( $ entity ) ; $ fields = $ this -> getFields ( ) ; foreach ( $ fields as $ key => $ mapping ) { $ fieldType = $ this -> fieldManager -> get ( $ mapping [ 'fieldtype' ] , $ mapping ) ; $ mappedType = $ mapping [ 'fieldtype' ] ; $ handl... | Creates a new entity object . |
42,832 | public function createFromDatabaseValues ( $ data , $ entity = null ) { $ entity = $ this -> getEntity ( $ entity ) ; $ fields = $ this -> getFields ( ) ; foreach ( $ fields as $ key => $ mapping ) { $ fieldType = $ this -> fieldManager -> get ( $ mapping [ 'fieldtype' ] , $ mapping ) ; if ( $ fieldType instanceof Fiel... | Performs database to PHP transforms before creating new entity . |
42,833 | public function refresh ( $ entity ) { $ fields = $ this -> getFields ( ) ; foreach ( $ fields as $ key => $ mapping ) { $ fieldType = $ this -> fieldManager -> get ( $ mapping [ 'fieldtype' ] , $ mapping ) ; $ getter = 'get' . ucfirst ( $ key ) ; $ value = $ entity -> $ getter ( ) ; if ( $ value ) { $ fieldType -> set... | Refresh an entities values . |
42,834 | public function initialize ( Request $ request ) { if ( ! $ this -> request ) { $ this -> request = $ request ; $ pagers = $ this -> decodeHttpQuery ( ) ; if ( array_intersect_key ( $ pagers , $ this -> pagers ) ) { throw new PagerOverrideException ( ) ; } $ this -> pagers = $ pagers ; } } | Initializer of pager objects from request query parameters . |
42,835 | public function decodeHttpQuery ( ) { $ values = [ ] ; foreach ( $ this -> getRequest ( ) -> query -> all ( ) as $ key => $ parameter ) { if ( strpos ( $ key , self :: PAGE ) === 0 ) { $ chunks = explode ( '_' , $ key ) ; $ contextId = end ( $ chunks ) ; $ pager = new Pager ( $ this ) ; $ pager -> setFor ( $ contextId ... | Decodes HTTP query url and stores in addressable format . |
42,836 | public function encodeHttpQuery ( $ qparams = null ) { $ qparams = ( $ qparams === null ) ? $ this -> getRequest ( ) -> query -> all ( ) : $ qparams ; return http_build_query ( array_merge ( $ qparams , $ this -> remapPagers ( ) ) ) ; } | Encodes Http GET query string from actual parts of query parameters and from current values of pager objects . |
42,837 | public function offsetSet ( $ contextId , $ pager ) { if ( ! $ pager -> manager ) { $ pager -> setManager ( $ this ) ; } $ this -> pagers [ $ this -> makeParameterId ( $ contextId ) ] = $ pager ; } | Set the Pager object . |
42,838 | public function keys ( ) { return array_map ( function ( $ key ) { $ chunks = explode ( '_' , $ key ) ; return array_pop ( $ chunks ) ; } , array_keys ( $ this -> pagers ) ) ; } | Returns context ids array . |
42,839 | public function createPager ( $ contextId = null ) { $ pager = new Pager ( $ this ) ; $ pager -> setFor ( $ contextId ) ; return $ this -> pagers [ $ this -> makeParameterId ( $ contextId ) ] = $ pager ; } | Factory method creating a Pager object . |
42,840 | protected function findInitializedPagerId ( ) { foreach ( $ this -> pagers as $ key => $ pager ) { if ( isset ( $ pager -> totalpages ) ) { return $ key ; } } return '' ; } | Finds any initialized pager and gets its pager id . |
42,841 | public function queryNextRunTime ( $ interimName ) { $ oldname = strtolower ( str_replace ( 'cron.' , '' , $ interimName ) ) ; $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> select ( 'id, lastrun, interim' ) -> where ( 'interim = :interim' ) -> orWhere ( 'interim = :oldname' ) -> orderBy ( 'lastrun' , 'DESC' ) -> se... | Build the query for a run time . |
42,842 | public function embed ( UriInterface $ url , $ providerName ) { $ adapter = $ this -> getUrlAdapter ( $ url ) ; $ providers = $ adapter -> getProviders ( ) ; if ( ! isset ( $ providers [ $ providerName ] ) ) { return [ ] ; } $ provider = $ providers [ $ providerName ] ; return $ provider -> getBag ( ) -> getAll ( ) ; } | Return embed information from a given URL . |
42,843 | private function getUrlAdapter ( UriInterface $ url ) { $ embedFactory = $ this -> embedFactory ; $ url = Url :: create ( ( string ) $ url ) ; try { $ adapter = $ embedFactory ( $ url ) ; } catch ( InvalidUrlException $ e ) { throw new EmbedResolverException ( $ e -> getMessage ( ) , 1 , $ e ) ; } catch ( EmbedExceptio... | Return an API adapter matching the pattern of the given URL . |
42,844 | public function homepage ( $ content ) { $ templates = [ ] ; if ( $ template = $ this -> config -> get ( 'theme/homepage_template' ) ) { $ templates [ ] = $ template ; } if ( $ template = $ this -> config -> get ( 'general/homepage_template' ) ) { $ templates [ ] = $ template ; } if ( empty ( $ content ) ) { $ template... | Choose a template for the homepage . |
42,845 | public function listing ( $ contenttype ) { $ templates = [ ] ; if ( ! empty ( $ contenttype [ 'listing_template' ] ) ) { $ templates [ ] = $ contenttype [ 'listing_template' ] ; } $ templates [ ] = $ contenttype [ 'slug' ] . '.twig' ; if ( $ template = $ this -> config -> get ( 'theme/listing_template' ) ) { $ templat... | Select a template for listing pages . |
42,846 | public function taxonomy ( $ taxonomyslug ) { $ templates = [ ] ; if ( $ template = $ this -> config -> get ( 'taxonomy/' . $ taxonomyslug . '/listing_template' ) ) { $ templates [ ] = $ template ; } if ( $ template = $ this -> config -> get ( 'theme/listing_template' ) ) { $ templates [ ] = $ template ; } $ templates ... | Select a template for taxonomy . |
42,847 | public function search ( ) { $ templates = [ ] ; if ( $ template = $ this -> config -> get ( 'theme/search_results_template' ) ) { $ templates [ ] = $ template ; } if ( $ template = $ this -> config -> get ( 'general/search_results_template' ) ) { $ templates [ ] = $ template ; } $ templates [ ] = $ this -> config -> g... | Select a search template . |
42,848 | public function maintenance ( ) { $ templates = [ ] ; if ( $ template = $ this -> config -> get ( 'theme/maintenance_template' ) ) { $ templates [ ] = $ template ; } $ templates [ ] = $ this -> config -> get ( 'general/maintenance_template' ) ; return $ templates ; } | Select a template to use for the maintenance page . |
42,849 | public function link ( $ referenceType = UrlGeneratorInterface :: ABSOLUTE_PATH ) { list ( $ name , $ params ) = $ this -> getRouteNameAndParams ( ) ; $ urlGenerator = $ this -> app [ 'url_generator' ] ; return $ name ? $ urlGenerator -> generate ( $ name , $ params , $ referenceType ) : null ; } | Creates a URL for the content record . |
42,850 | public function isHome ( ) { $ config = $ this -> app [ 'config' ] ; $ homepage = $ config -> get ( 'theme/homepage' ) ? : $ config -> get ( 'general/homepage' ) ; $ uriID = $ this -> contenttype [ 'singular_slug' ] . '/' . $ this -> get ( 'id' ) ; $ uriSlug = $ this -> contenttype [ 'singular_slug' ] . '/' . $ this ->... | Checks if the current record is set as the homepage . |
42,851 | protected function getRouteConfig ( ) { $ allroutes = $ this -> app [ 'config' ] -> get ( 'routing' ) ; foreach ( $ allroutes as $ binding => $ config ) { if ( $ this -> isApplicableRoute ( $ config ) ) { return [ $ binding , $ config ] ; } } if ( ! empty ( $ allroutes [ 'contentlink' ] ) ) { return [ 'contentlink' , $... | Retrieves the first route applicable to the content as a two - element array consisting of the binding and the route array . Returns null if there is no applicable route . |
42,852 | protected function getRouteRequirementParams ( array $ route ) { $ params = [ ] ; if ( isset ( $ route [ 'requirements' ] ) ) { foreach ( $ route [ 'requirements' ] as $ fieldName => $ requirement ) { if ( '\d{4}-\d{2}-\d{2}' === $ requirement ) { $ params [ $ fieldName ] = substr ( $ this -> get ( $ fieldName ) , 0 , ... | Build a ContentType s route parameters . |
42,853 | protected function isApplicableRoute ( array $ route ) { return ( isset ( $ route [ 'contenttype' ] ) && $ route [ 'contenttype' ] === $ this -> contenttype [ 'singular_slug' ] ) || ( isset ( $ route [ 'contenttype' ] ) && $ route [ 'contenttype' ] === $ this -> contenttype [ 'slug' ] ) || ( isset ( $ route [ 'recordsl... | Check if a route is applicable to this record . |
42,854 | private function getLinkSlug ( ) { if ( $ this instanceof Content ) { return $ this -> slug ? : $ this -> id ; } if ( isset ( $ this -> values [ 'slug' ] ) ) { return $ this -> values [ 'slug' ] ; } return $ this -> id ; } | Get a record s slug depending on the type of object used . |
42,855 | protected function getContent ( $ textQuery , $ parameters = [ ] , & $ pager = [ ] , $ whereParameters = [ ] ) { $ query = $ this -> app [ 'query' ] ; return $ query -> getContent ( $ textQuery , $ parameters ) ; } | Temporary override for back - end . |
42,856 | protected function setAuthenticationCookie ( Request $ request , Response $ response , $ token ) { $ response -> setVary ( 'Cookies' , false ) -> setMaxAge ( 0 ) -> setPrivate ( ) ; $ response -> headers -> setCookie ( new Cookie ( $ this -> app [ 'token.authentication.name' ] , $ token , time ( ) + $ this -> getOption... | Set the authentication cookie in the response . |
42,857 | private function checkFirstUser ( Application $ app , $ route ) { $ repo = $ app [ 'storage' ] -> getRepository ( Entity \ Users :: class ) ; try { $ userCount = $ repo -> count ( ) ; } catch ( TableNotFoundException $ e ) { $ app [ 'schema' ] -> update ( ) ; $ app [ 'logger.flash' ] -> info ( Trans :: __ ( 'general.ph... | Check and handle first user set up . |
42,858 | private function setup ( ) { if ( $ this -> started ) { return ; } if ( $ this -> app [ 'extend.writeable' ] ) { try { $ this -> updateJson ( ) ; } catch ( ParseException $ e ) { $ this -> app [ 'logger.flash' ] -> danger ( Trans :: __ ( 'Error reading extensions/composer.json file: %ERROR%' , [ '%ERROR%' => $ e -> get... | Set up function . |
42,859 | public function showPackage ( $ target , $ package = '' , $ version = '' , $ root = false ) { return $ this -> app [ 'extend.action' ] [ 'show' ] -> execute ( $ target , $ package , $ version , $ root ) ; } | Show packages . |
42,860 | public function getAllPackages ( ) { $ collection = new PackageCollection ( ) ; if ( $ this -> started === false ) { return $ collection ; } $ installed = $ this -> app [ 'extend.action' ] [ 'show' ] -> execute ( 'installed' ) ; foreach ( $ installed as $ composerPackage ) { $ composerPackage = $ composerPackage [ 'pac... | Get packages that a properly installed pending installed and locally installed . |
42,861 | private function linkConfig ( ResolvedExtension $ extension ) { $ file = $ this -> app [ 'filesystem' ] -> getFile ( strtolower ( "extensions_config://{$extension->getName()}.{$extension->getVendor()}.yml" ) ) ; if ( $ file -> exists ( ) ) { return $ this -> app [ 'url_generator' ] -> generate ( 'fileedit' , [ 'namespa... | Return the URI for a package s config file edit window . |
42,862 | private function loadTheme ( ) { if ( $ this -> isThemeCacheValid ( ) ) { return ; } $ this -> invalidateCache ( ) ; $ themeDir = $ this -> app [ 'filesystem' ] -> getDir ( 'themes://' . $ this -> get ( 'general/theme' ) ) ; $ this -> data [ 'theme' ] = $ this -> parseTheme ( $ themeDir , $ this -> data [ 'general' ] )... | Checks if cache is valid for theme ; if not invalidate and load it . |
42,863 | protected function parseConfigYaml ( $ filename , DirectoryInterface $ directory = null ) { $ directory = $ directory ? : $ this -> app [ 'filesystem' ] -> getDir ( 'config://' ) ; try { $ file = $ directory -> get ( $ filename ) ; } catch ( FileNotFoundException $ e ) { $ distFiles = [ 'config.yml' , 'contenttypes.yml... | Read and parse a YAML configuration file . |
42,864 | public function set ( $ path , $ value ) { Arr :: set ( $ this -> data , $ path , $ value ) ; return true ; } | Set a config value using a path . |
42,865 | public function getConfig ( ) { $ config = [ ] ; $ config [ 'general' ] = $ this -> parseGeneral ( ) ; $ config [ 'taxonomy' ] = $ this -> parseTaxonomy ( ) ; $ config [ 'contenttypes' ] = $ this -> parseContentTypes ( $ config [ 'general' ] ) ; $ config [ 'menu' ] = $ this -> parseConfigYaml ( 'menu.yml' ) ; $ config ... | Load the configuration from the various YML files . |
42,866 | protected function parseGeneral ( ) { $ tempconfig = $ this -> parseConfigYaml ( 'config.yml' ) ; $ tempconfiglocal = $ this -> parseConfigYaml ( 'config_local.yml' ) ; $ general = Arr :: replaceRecursive ( $ tempconfig , $ tempconfiglocal ) ; $ general = Arr :: replaceRecursive ( $ this -> defaultConfig , $ general ) ... | Read and parse the config . yml and config_local . yml configuration files . |
42,867 | protected function parseTaxonomy ( array $ taxonomies = null ) { $ taxonomies = $ taxonomies ? : $ this -> parseConfigYaml ( 'taxonomy.yml' ) ; $ slugify = Slugify :: create ( ) ; foreach ( $ taxonomies as $ key => $ taxonomy ) { if ( ! isset ( $ taxonomy [ 'name' ] ) ) { $ taxonomy [ 'name' ] = ucwords ( str_replace (... | Read and parse the taxonomy . yml configuration file . |
42,868 | protected function parseContentTypes ( array $ generalConfig ) { $ contentTypes = [ ] ; $ tempContentTypes = $ this -> parseConfigYaml ( 'contenttypes.yml' ) ; foreach ( $ tempContentTypes as $ key => $ contentType ) { try { $ contentType = $ this -> parseContentType ( $ key , $ contentType , $ generalConfig ) ; $ cont... | Read and parse the contenttypes . yml configuration file . |
42,869 | protected function parseTheme ( DirectoryInterface $ themeDir , array $ generalConfig ) { $ themeConfig = $ this -> parseConfigYaml ( 'theme.yml' , $ themeDir ) ; if ( empty ( $ themeConfig ) ) { $ themeConfig = $ this -> parseConfigYaml ( 'config.yml' , $ themeDir ) ; } if ( ( isset ( $ themeConfig [ 'templatefields' ... | Read and parse the current theme s config . yml configuration file . |
42,870 | protected function parseTemplatefields ( ) { $ theme = $ this -> data [ 'theme' ] ; if ( isset ( $ theme [ 'templatefields' ] ) ) { foreach ( $ this -> data [ 'contenttypes' ] as $ key => $ ct ) { foreach ( $ ct [ 'fields' ] as $ field ) { if ( isset ( $ field [ 'type' ] ) && $ field [ 'type' ] === 'templateselect' ) {... | This method pulls the templatefields config from the theme config and appends it to the contenttypes configuration . |
42,871 | protected function parseFieldsAndGroups ( array $ fields , array $ generalConfig ) { $ acceptableFileTypes = $ generalConfig [ 'accept_file_types' ] ; $ currentGroup = 'ungrouped' ; $ groups = [ ] ; $ hasGroups = false ; foreach ( $ fields as $ key => $ field ) { unset ( $ fields [ $ key ] ) ; $ key = str_replace ( '-'... | Parse a Contenttype s filed and determine the grouping . |
42,872 | private function parseFieldRepeaters ( array $ fields , $ key ) { $ blacklist = [ 'repeater' , 'slug' , 'templatefield' ] ; $ repeater = $ fields [ $ key ] ; if ( ! isset ( $ repeater [ 'fields' ] ) || ! is_array ( $ repeater [ 'fields' ] ) ) { return ; } foreach ( $ repeater [ 'fields' ] as $ repeaterKey => $ repeater... | Basic validation of repeater fields . |
42,873 | protected function parseDatabase ( array $ options ) { if ( substr ( $ options [ 'prefix' ] , strlen ( $ options [ 'prefix' ] ) - 1 ) !== '_' ) { $ options [ 'prefix' ] .= '_' ; } $ master = $ this -> parseConnectionParams ( $ options ) ; $ options = array_replace ( $ options , $ master ) ; $ driver = \ Bolt \ Common \... | Parse and fine - tune the database configuration . |
42,874 | protected function parseSqliteOptions ( array $ config ) { if ( isset ( $ config [ 'memory' ] ) && $ config [ 'memory' ] ) { unset ( $ config [ 'path' ] ) ; return $ config ; } unset ( $ config [ 'memory' ] ) ; $ path = isset ( $ config [ 'path' ] ) ? $ config [ 'path' ] : $ this -> app [ 'path_resolver' ] -> resolve (... | Fine - tune Sqlite configuration parameters . |
42,875 | protected function parseConnectionParams ( $ params , $ defaults = [ ] ) { if ( is_string ( $ params ) ) { $ params = [ 'host' => $ params ] ; } $ replacements = [ 'databasename' => 'dbname' , 'username' => 'user' , ] ; foreach ( $ replacements as $ old => $ new ) { if ( isset ( $ params [ $ old ] ) ) { $ params [ $ ne... | Parses params to valid connection parameters . |
42,876 | private function checkTaxonomy ( ) { foreach ( $ this -> data [ 'taxonomy' ] as $ key => $ taxonomy ) { if ( empty ( $ taxonomy [ 'options' ] ) || ! is_array ( $ taxonomy [ 'options' ] ) ) { continue ; } foreach ( $ taxonomy [ 'options' ] as $ optionKey => $ optionValue ) { if ( strpos ( $ optionKey , '/' ) === false )... | Sanity check for slashes in in taxonomy slugs . |
42,877 | protected function getDefaults ( ) { return [ 'database' => [ 'driver' => 'sqlite' , 'host' => 'localhost' , 'slaves' => [ ] , 'dbname' => 'bolt' , 'prefix' => 'bolt_' , 'charset' => 'utf8' , 'collate' => 'utf8_unicode_ci' , 'randomfunction' => '' , ] , 'sitename' => 'Default Bolt site' , 'locale' => null , 'recordsper... | Assume sensible defaults for a number of options . |
42,878 | public function getTwigPath ( ) { Deprecated :: method ( 3.3 ) ; $ themepath = $ this -> app [ 'resources' ] -> getPath ( 'templatespath' ) ; $ twigpath = [ ] ; if ( file_exists ( $ themepath ) ) { $ twigpath [ ] = $ themepath ; } else { $ relativethemepath = basename ( $ this -> get ( 'general/theme' ) ) ; $ theme = $... | Build an array of Twig paths . |
42,879 | protected function loadCache ( ) { if ( $ this -> isCacheValid ( ) === false ) { return null ; } $ data = null ; try { $ data = $ this -> cacheFile -> parse ( ) ; } catch ( ParseException $ e ) { $ this -> invalidateCache ( ) ; } catch ( IOException $ e ) { $ part = Translator :: __ ( 'Try logging in with your ftp-clie... | Attempt to load cached configuration files . |
42,880 | private function isCacheValid ( ) { if ( ! $ this -> cacheFile -> exists ( ) ) { return false ; } $ cachedConfigTimestamp = $ this -> cacheFile -> getTimestamp ( ) ; $ configFs = $ this -> app [ 'filesystem' ] -> getFilesystem ( 'config' ) ; $ configFiles = [ 'config.yml' , 'config_local.yml' , 'contenttypes.yml' , 'ex... | Check if the cached config file exists and is newer than the authoritative source . |
42,881 | private function isThemeCacheValid ( ) { if ( ! $ this -> cacheFile -> exists ( ) ) { return false ; } $ themeDir = $ this -> app [ 'filesystem' ] -> getDir ( 'themes://' . $ this -> get ( 'general/theme' ) ) ; $ timestampTheme = 0 ; $ themeFile = $ themeDir -> getFile ( 'theme.yml' ) ; if ( $ themeFile -> exists ( ) )... | Check if the cache is still valid with theme file as well . |
42,882 | public function getTimestamp ( $ when ) { Deprecated :: method ( 3.3 ) ; $ timezone = $ this -> get ( 'general/timezone' ) ; $ now = date_format ( new \ DateTime ( $ when , new \ DateTimeZone ( $ timezone ) ) , 'Y-m-d H:i:s' ) ; return $ now ; } | Get a timestamp corrected to the timezone . |
42,883 | public function getCurrentTimestamp ( ) { Deprecated :: method ( 3.3 ) ; $ timezone = $ this -> get ( 'general/timezone' ) ; $ now = date_format ( new \ DateTime ( $ timezone ) , 'Y-m-d H:i:s' ) ; return $ now ; } | Get the current timestamp corrected to the timezone . |
42,884 | public function render ( $ templateName , $ context = [ ] , $ globals = [ ] ) { Deprecated :: method ( 3.3 ) ; $ template = $ this -> app [ 'twig' ] -> resolveTemplate ( $ templateName ) ; foreach ( $ globals as $ name => $ value ) { $ this -> app [ 'twig' ] -> addGlobal ( $ name , $ value ) ; } $ html = twig_include (... | Render a template possibly store it in cache . Or if applicable return the cached result . |
42,885 | public function fetchCachedRequest ( ) { Deprecated :: method ( 3.3 ) ; $ response = false ; if ( $ this -> checkCacheConditions ( 'request' , true ) ) { $ key = md5 ( $ this -> app [ 'request' ] -> getPathInfo ( ) . $ this -> app [ 'request' ] -> getQueryString ( ) ) ; $ result = $ this -> app [ 'cache' ] -> fetch ( $... | Retrieve a fully cached page from cache . |
42,886 | public function checkCacheConditions ( $ type = 'template' , $ checkoverride = false ) { Deprecated :: method ( 3.3 ) ; if ( $ this -> safe ) { return false ; } if ( $ this -> app [ 'request' ] -> getMethod ( ) !== 'GET' ) { return false ; } if ( ! $ this -> app [ 'config' ] -> get ( 'general/caching/' . $ type ) ) { r... | Check if the current conditions are suitable for caching . |
42,887 | public function add ( FileAssetInterface $ asset ) { if ( ! $ asset -> getPackageName ( ) ) { $ asset -> setPackageName ( 'extensions' ) ; } $ key = $ asset -> getPackageName ( ) . "/" . $ asset -> getPath ( ) ; if ( $ asset -> getType ( ) === 'javascript' ) { $ this -> javascript [ $ key ] = $ asset ; } elseif ( $ ass... | Add a file asset to the queue . |
42,888 | protected function processAsset ( FileAssetInterface $ asset , Request $ request , Response $ response ) { $ url = $ this -> packages -> getUrl ( $ asset -> getPath ( ) , $ asset -> getPackageName ( ) ) ; $ asset -> setUrl ( $ url ) ; if ( $ asset -> getZone ( ) !== Zone :: get ( $ request ) ) { return ; } if ( $ asset... | Process a single asset . |
42,889 | protected function addJquery ( Request $ request , Response $ response ) { if ( ! $ this -> config -> get ( 'general/add_jquery' , false ) && ! $ this -> config -> get ( 'theme/add_jquery' , false ) ) { return ; } if ( Zone :: isFrontend ( $ request ) === false ) { return ; } $ html = $ response -> getContent ( ) ; $ r... | Insert jQuery if it s not inserted already . |
42,890 | protected function hasEntity ( $ value , Constraint $ constraint ) { $ repo = $ this -> em -> getRepository ( $ constraint -> className ) ; $ formEntity = $ this -> context -> getRoot ( ) -> getData ( ) ; $ query = $ repo -> createQueryBuilder ( ) -> setParameter ( 'value' , $ value ) ; foreach ( ( array ) $ constraint... | Check if the validating entity has a record with a matching field value . |
42,891 | public function singleTaxonomy ( $ taxonomyName , $ emptyValue = 'none' ) { $ taxonomyValues = $ this -> config -> get ( 'taxonomy/' . $ taxonomyName . '/options' ) ; if ( empty ( $ taxonomyValues ) ) { return '[a-z0-9-_]+' ; } $ taxonomyValues = array_keys ( $ taxonomyValues ) ; $ requirements = implode ( '|' , $ taxo... | Return slugs of existing taxonomy values . |
42,892 | protected function configAssert ( $ key , $ singular ) { $ types = $ this -> config -> get ( $ key ) ; if ( empty ( $ types ) ) { return '$.' ; } $ slugs = [ ] ; foreach ( $ types as $ type ) { $ slugs [ ] = $ type [ 'slug' ] ; if ( $ singular ) { $ slugs [ ] = $ type [ 'singular_slug' ] ; } } return implode ( '|' , $ ... | Gets slugs from config imploded for regex . |
42,893 | private function getRecords ( $ contentTypeKey , $ limit ) { $ repo = $ this -> em -> getRepository ( $ contentTypeKey ) ; $ qb = $ repo -> createQueryBuilder ( ) -> setMaxResults ( $ limit ) -> orderBy ( 'datechanged' , 'DESC' ) ; return $ repo -> findWith ( $ qb ) ; } | Fetch recently changed records for a given ContentType . |
42,894 | public function onPrePackage ( PackageEvent $ event ) { if ( $ event -> getIO ( ) instanceof BufferIO ) { $ this -> logger -> debug ( $ event -> getIO ( ) -> getOutput ( ) , [ 'event' => 'extensions' ] ) ; } } | Composer pre - package action events . |
42,895 | public function onException ( GetResponseForExceptionEvent $ event ) { if ( ! $ this -> isApplicable ( $ event -> getRequest ( ) ) ) { return ; } $ response = $ this -> convert ( $ event -> getException ( ) ) ; $ event -> setResponse ( $ response ) ; } | Listen for exceptions and convert them to JSON responses if necessary . |
42,896 | protected function convert ( \ Exception $ exception ) { $ statusCode = $ exception instanceof HttpExceptionInterface ? $ exception -> getStatusCode ( ) : Response :: HTTP_INTERNAL_SERVER_ERROR ; $ file = Path :: makeRelative ( $ exception -> getFile ( ) , $ this -> pathResolver -> resolve ( 'root' ) ) ; $ response = n... | Convert the exception to a response . |
42,897 | protected function getErrorType ( \ Exception $ exception ) { $ errorType = get_class ( $ exception ) ; $ pos = strrpos ( $ errorType , '\\' ) ; if ( $ pos !== false ) { $ errorType = substr ( $ errorType , $ pos ) ; } $ errorType = Str :: replaceLast ( $ errorType , 'Exception' , '' ) ; if ( ! $ errorType ) { $ errorT... | Convert the exception to an error type . |
42,898 | protected function reconcileDatabaseSchema ( InputInterface $ input , OutputInterface $ output ) { if ( $ this -> isDbSetup === false ) { return true ; } $ this -> step ( ++ $ this -> step , 'Checking Database Schema' ) ; $ command = $ this -> getApplication ( ) -> find ( 'database:check' ) ; $ buffer = $ this -> getBu... | Check the database schema exists is consistent with the configuration . |
42,899 | protected function reconcileRootUser ( OutputInterface $ output ) { if ( $ this -> isDbSetup === false ) { return true ; } $ repo = $ this -> app [ 'storage' ] -> getRepository ( Entity \ Users :: class ) ; if ( $ repo -> count ( ) > 0 ) { return true ; } $ this -> step ( ++ $ this -> step , 'Creating First User' ) ; i... | Create first user with the root role . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.