idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
43,300 | protected function getContent ( $ contentTypeSlug , array $ contentParameters , ListingOptions $ options ) { $ contentParameters = array_filter ( $ contentParameters ) ; $ records = $ this -> query -> getContent ( $ contentTypeSlug , $ contentParameters ) ; if ( $ records === null && $ options -> getPage ( ) !== null )... | Get the content records and fallback a page if none found . |
43,301 | public function onBootException ( GetResponseForExceptionEvent $ event ) { if ( $ this -> isProfilerRequest ( $ event -> getRequest ( ) ) ) { return ; } $ exception = $ event -> getException ( ) ; if ( $ exception instanceof BootException ) { $ event -> setResponse ( $ exception -> getResponse ( ) ) ; } } | Handle boot initialisation exceptions . |
43,302 | public function onKernelException ( GetResponseForExceptionEvent $ event ) { if ( $ this -> isProfilerRequest ( $ event -> getRequest ( ) ) ) { return ; } $ exception = $ event -> getException ( ) ; if ( $ exception instanceof DatabaseExceptionInterface ) { $ html = $ this -> renderDatabaseException ( $ exception ) ; }... | Handle errors thrown in the application . |
43,303 | protected function getContext ( \ Exception $ exception = null ) { if ( $ exception ) { $ this -> saveException ( $ exception ) ; } $ loggedOnUser = ( bool ) $ this -> users -> getCurrentUser ( ) ? : false ; $ showLoggedOff = ( bool ) $ this -> config -> get ( 'general/debug_show_loggedoff' , false ) ; $ traceLimit = (... | Get a pre - packaged Twig context array . |
43,304 | protected function saveException ( \ Exception $ exception ) { if ( $ this -> debug !== true ) { return ; } $ serialised = Serialization :: dump ( FlattenException :: create ( $ exception ) ) ; $ sourceFile = str_replace ( $ this -> rootPath , '' , $ exception -> getFile ( ) ) ; $ sourceFile = substr ( $ sourceFile , -... | Attempt to save the serialised exception if in debug mode . |
43,305 | public function classToTableName ( $ className ) { $ className = $ this -> getRelativeClass ( $ className ) ; $ className = ltrim ( strtolower ( preg_replace ( '/[A-Z]/' , '_$0' , $ className ) ) , '_' ) ; return $ this -> prefix . $ className ; } | Takes either a global or absolute class name and returns an underscored table name . |
43,306 | public function classToAlias ( $ className ) { $ className = $ this -> getRelativeClass ( $ className ) ; return ltrim ( strtolower ( preg_replace ( '/[A-Z]/' , '_$0' , $ className ) ) , '_' ) ; } | Creates an automatic alias from a class name . |
43,307 | public function getRelativeClass ( $ className ) { if ( strpos ( $ className , '\\' ) !== false ) { $ className = substr ( $ className , strrpos ( $ className , '\\' ) + 1 ) ; } return $ className ; } | Returns a class name with namespaces removed . |
43,308 | private function getEmailHtml ( ) { return $ this -> app [ 'twig' ] -> render ( 'email/pingtest.twig' , [ 'sitename' => $ this -> app [ 'config' ] -> get ( 'general/sitename' ) , 'user' => $ this -> options [ 'user' ] [ 'displayname' ] , 'ip' => $ this -> options [ 'ip' ] , ] ) ; } | Render HTML for the sample email . |
43,309 | private function sendMessage ( $ senderMail , $ senderName , $ mailhtml ) { try { $ message = $ this -> app [ 'mailer' ] -> createMessage ( 'message' ) -> setSubject ( 'Test email from ' . $ this -> app [ 'config' ] -> get ( 'general/sitename' ) ) -> setFrom ( [ $ senderMail => $ senderName ] ) -> setReplyTo ( [ $ send... | Attempt to send the email message . |
43,310 | public function get ( $ key , $ throwEx = false ) { if ( $ throwEx && ! $ this -> parsed -> hasPath ( $ key ) ) { throw new \ InvalidArgumentException ( sprintf ( "The key '%s' was not found in %s." , $ key , $ this -> file -> getFullPath ( ) ) ) ; } $ value = $ this -> parsed -> getPath ( $ key ) ; if ( is_array ( $ v... | Return a value for a key from the yml file . |
43,311 | public function change ( $ key , $ value , $ backup = true ) { $ yaml = $ this -> lines -> join ( "\n" ) ; $ pattern = '/^' . str_replace ( '/' , ':.*?' , $ key ) . '(:\s*)/mis' ; preg_match ( $ pattern , $ yaml , $ matches , PREG_OFFSET_CAPTURE ) ; if ( ! $ matches ) { if ( func_num_args ( ) === 4 && func_get_arg ( 3 ... | Updates a single value with replacement for given key in yml file . |
43,312 | protected function save ( $ backup ) { $ yaml = $ this -> lines -> join ( "\n" ) ; Yaml :: parse ( $ yaml , true , true ) ; if ( $ backup ) { $ this -> file -> copy ( $ this -> file -> getPath ( ) . '.' . date ( 'Ymd-His' ) ) ; } $ this -> file -> update ( $ yaml ) ; } | Save our modified . yml file . |
43,313 | protected function isProfilerRequest ( Request $ request ) { $ route = $ request -> attributes -> get ( '_route' ) ; return $ route === '_wdt' || strpos ( $ route , '_profiler' ) === 0 ; } | Check to see if the request has matched one of the profiler s routes . |
43,314 | public function admin ( ) { $ currentuser = $ this -> getUser ( ) ; $ users = $ this -> users ( ) -> getUsers ( ) ; $ sessions = $ this -> accessControl ( ) -> getActiveSessions ( ) ; foreach ( $ users as $ name => $ user ) { if ( ( $ key = array_search ( Permissions :: ROLE_EVERYONE , $ user [ 'roles' ] , true ) ) !==... | All users admin page . |
43,315 | public function edit ( Request $ request , $ id ) { $ currentUser = $ this -> getUser ( ) ; $ userEntity = $ this -> getUserEntity ( $ id ) ; if ( $ userEntity === false ) { return $ this -> redirectToRoute ( 'users' ) ; } $ permissions = $ this -> app [ 'permissions' ] ; $ availableRoles = array_flip ( array_map ( fun... | User edit route . |
43,316 | public function profile ( Request $ request ) { $ userEntity = $ this -> getUser ( ) ; if ( $ userEntity === false ) { return $ this -> redirectToRoute ( 'users' ) ; } $ form = $ this -> createFormBuilder ( FormType \ UserProfileType :: class , $ userEntity ) -> getForm ( ) -> handleRequest ( $ request ) ; if ( $ form ... | User profile page route . |
43,317 | public function viewRoles ( ) { $ contenttypes = $ this -> getOption ( 'contenttypes' ) ; $ permissions = $ this -> app [ 'permissions' ] -> getContentTypePermissions ( ) ; $ effectivePermissions = [ ] ; foreach ( $ contenttypes as $ contenttype ) { foreach ( array_keys ( $ permissions ) as $ permission ) { $ effective... | Route to view the configured user roles . |
43,318 | private function getUserEntity ( $ id = null ) { if ( empty ( $ id ) ) { return new Entity \ Users ( ) ; } elseif ( ! $ userEntity = $ this -> getUser ( $ id ) ) { $ this -> flashes ( ) -> error ( Trans :: __ ( 'general.phrase.user-not-exist' ) ) ; return false ; } $ currentUser = $ this -> getUser ( ) ; if ( ! $ this ... | Get the user we want to edit or a new entity object if null . |
43,319 | private function notifyUserSetupEmail ( Request $ request , $ displayName , $ email ) { $ logger = $ this -> app [ 'logger.system' ] ; $ mailer = $ this -> app [ 'mailer' ] ; $ transport = $ this -> app [ 'swiftmailer.spooltransport' ] ; $ mailHtml = $ this -> app [ 'twig' ] -> render ( '@bolt/email/firstuser.twig' , [... | Send a welcome email to test mail settings . |
43,320 | private function updateDistBundles ( ) { $ fs = $ this -> app [ 'filesystem' ] -> getFilesystem ( 'root' ) ; $ files = [ '.bolt.yml' , 'composer.json' , 'composer.lock' , 'src/Site/CustomisationExtension.php' , ] ; foreach ( $ files as $ file ) { $ dist = $ fs -> getFile ( $ file . '.dist' ) ; if ( ! $ fs -> has ( $ fi... | Archive distributions have the site bundle files installed as . dist files to prevent the real files being overridden . If the . dist file exists but the original doesn t then we should rename them . |
43,321 | public function build ( MenuEntry $ root ) { $ contentRoot = $ root -> add ( MenuEntry :: create ( 'content' , '' ) -> setLabel ( Trans :: __ ( 'general.phrase.content' ) ) -> setIcon ( 'fa:file-text' ) -> setPermission ( 'dashboard' ) ) ; $ mainContentRoot = $ contentRoot -> add ( MenuEntry :: create ( 'main' ) -> set... | Build the Content menu . |
43,322 | private function addContentType ( MenuEntry $ contentRoot , $ contentTypeKey , Bag $ contentType ) { $ icon = $ contentType -> get ( 'singleton' ) ? $ contentType -> get ( 'icon_one' ) : $ contentType -> get ( 'icon_many' ) ; $ contentTypeEntry = $ contentRoot -> add ( MenuEntry :: create ( $ contentTypeKey ) -> setRou... | Add a ContentType s menu and sub - menu . |
43,323 | private function addGroupedContentTypes ( MenuEntry $ groupEntry , array $ contentTypes ) { foreach ( $ contentTypes as $ contentTypeKey => $ contentType ) { $ groupEntry -> add ( MenuEntry :: create ( $ contentTypeKey ) -> setRoute ( 'overview' , [ 'contenttypeslug' => $ contentTypeKey ] ) -> setLabel ( $ contentType ... | Add a group s children . |
43,324 | public function addCustomFields ( $ fieldName , $ type , $ addIndex ) { if ( ! $ this -> table -> hasColumn ( $ fieldName ) ) { $ this -> { $ this -> typeMap [ $ type ] } ( $ fieldName ) ; } if ( $ addIndex ) { $ this -> table -> addIndex ( [ $ fieldName ] ) ; } } | Add the contenttype s specific fields . |
43,325 | public function getDirMode ( ) { $ dirMode = $ this -> get ( 'dir-mode' , 0777 ) ; $ dirMode = is_string ( $ dirMode ) ? octdec ( $ dirMode ) : $ dirMode ; return $ dirMode ; } | Returns the directory mode . |
43,326 | public function get ( $ key , $ default = null ) { if ( $ value = $ this -> getEnv ( $ key ) ) { return $ value ; } $ key = strtolower ( str_replace ( '_' , '-' , $ key ) ) ; if ( strpos ( $ key , 'bolt-' ) !== 0 ) { $ key = 'bolt-' . $ key ; } return isset ( $ this -> composerExtra [ $ key ] ) ? $ this -> composerExtr... | Get an option from environment variable or composer s extra section . |
43,327 | protected function getSearchParameter ( ) { if ( strpos ( $ this -> search , '+' ) ) { $ words = preg_split ( '/[\s\+]+/' , $ this -> search ) ; return '%' . implode ( '% && %' , $ words ) . '%' ; } $ words = explode ( ' ' , $ this -> search ) ; return '%' . implode ( '% || %' , $ words ) . '%' ; } | This is an internal helper method to get the search words prepared to be passed to the expression builder . |
43,328 | protected function processFilters ( ) { $ params = $ this -> params ; if ( ! $ this -> contentType ) { throw new QueryParseException ( 'You have attempted to run a search query without specifying a ContentType' , 1 ) ; } if ( isset ( $ params [ 'invisible' ] ) && $ params [ 'invisible' ] === true ) { $ this -> config -... | This overrides the SelectQuery default to do some extra preparation for a search query . Firstly it builds separate filters for the search query and then it removes the filter from the params and the others will then get processed normally by the parent . |
43,329 | public function serialize ( ) { $ output = [ ] ; foreach ( $ this as $ element ) { $ proxy = $ element -> getProxy ( ) ; $ output [ ] = $ proxy -> getContenttype ( ) . '/' . $ proxy -> getSlug ( ) ; } return $ output ; } | Force loads the proxy objects and returns the real objects |
43,330 | public function getIterator ( ) { $ els = parent :: getIterator ( ) ; return new CallbackFilterIterator ( $ els , function ( & $ current ) { $ current = $ current -> getProxy ( ) ; return true ; } ) ; } | This overrides the base getIterator method and on access swaps out the EntityProxy objects for real entities . |
43,331 | public function get ( $ id ) { $ resolved = $ this -> getResolved ( $ id ) ; return $ resolved ? $ resolved -> getInnerExtension ( ) : null ; } | Get an installed extension class . |
43,332 | public function getResolved ( $ id ) { if ( isset ( $ this -> extensions [ $ id ] ) ) { return $ this -> extensions [ $ id ] ; } elseif ( isset ( $ this -> composerNames [ $ id ] ) ) { $ id = ( string ) $ this -> composerNames [ $ id ] ; return $ this -> extensions [ $ id ] ; } return null ; } | Get the resolved form of an installed extension class . |
43,333 | public function add ( ExtensionInterface $ extension , DirectoryInterface $ baseDir = null , DirectoryInterface $ webDir = null , $ composerName = null ) { if ( $ this -> registered ) { throw new \ RuntimeException ( 'Can not add extensions after they are registered.' ) ; } if ( $ baseDir === null ) { $ reflector = new... | Add an extension to be registered . |
43,334 | public function addManagedExtensions ( ) { if ( $ this -> loaded ) { throw new \ RuntimeException ( 'Extensions already loaded.' ) ; } try { $ this -> extFs -> includeFile ( 'vendor/autoload.php' ) ; } catch ( FileNotFoundException $ e ) { $ this -> loaded = true ; return ; } $ descriptors = $ this -> loadPackageDescri... | Load a collection of extension classes . |
43,335 | private function loadPackageDescriptors ( ) { $ descriptors = [ ] ; try { $ autoload = $ this -> extFs -> get ( 'vendor/autoload.json' ) ; } catch ( FileNotFoundException $ e ) { return $ descriptors ; } foreach ( ( array ) $ autoload -> parse ( ) as $ name => $ loader ) { $ descriptors [ $ name ] = PackageDescriptor :... | Load the extension autoload . json cache file and build the PackageDescriptor array . |
43,336 | private function addManagedExtension ( PackageDescriptor $ descriptor ) { $ className = $ descriptor -> getClass ( ) ; if ( $ this -> isClassLoadable ( $ className ) === false ) { $ this -> flashLogger -> error ( Trans :: __ ( 'page.extend.error-class-invalid' , [ '%NAME%' => $ descriptor -> getName ( ) , '%CLASS%' => ... | Load a single extension . |
43,337 | private function isClassLoadable ( $ className ) { try { $ exists = class_exists ( $ className ) ; } catch ( ContextErrorException $ e ) { if ( $ e -> getSeverity ( ) === E_WARNING && basename ( $ e -> getFile ( ) ) === 'ClassLoader.php' ) { return false ; } throw $ e ; } return $ exists ; } | Check if a class is loadable . |
43,338 | public function getRelation ( $ filterContentType = null , $ options = [ ] ) { if ( empty ( $ this -> relation ) ) { return false ; } if ( ! is_array ( $ options ) ) { $ options = [ 'id' => $ options , ] ; } $ records = [ ] ; foreach ( $ this -> relation as $ contenttype => $ ids ) { if ( ! empty ( $ filterContentType ... | Gets one or more related records . |
43,339 | public function setRelation ( $ contentType , $ id ) { if ( empty ( $ this -> relation [ $ contentType ] ) || ! in_array ( $ id , $ this -> relation [ $ contentType ] , false ) ) { $ this -> relation [ $ contentType ] [ ] = $ id ; } } | Add a relation . |
43,340 | protected function addRoutes ( ControllerCollection $ c ) { $ c -> get ( '' , 'overview' ) -> bind ( 'extensions' ) ; $ c -> get ( '' , 'overview' ) -> bind ( 'extend' ) ; $ c -> get ( '/check' , 'check' ) -> bind ( 'check' ) ; $ c -> get ( '/depends' , 'dependsPackage' ) -> bind ( 'dependsPackage' ) ; $ c -> get ( '/p... | Returns routes to connect to the application . |
43,341 | public function check ( ) { try { return $ this -> json ( $ this -> manager ( ) -> checkPackage ( ) ) ; } catch ( PackageManagerException $ e ) { return $ this -> getJsonException ( $ e ) ; } } | Check a package . |
43,342 | public function dependsPackage ( Request $ request ) { $ package = $ request -> get ( 'needle' ) ; $ constraint = $ request -> get ( 'constraint' , '*' ) ; try { $ response = $ this -> manager ( ) -> dependsPackage ( $ package , $ constraint ) ; } catch ( \ Exception $ e ) { return $ this -> getJsonException ( $ e ) ; ... | Find depends package dependencies . |
43,343 | public function generateTheme ( Request $ request ) { $ theme = $ request -> query -> get ( 'theme' ) ; $ newName = $ request -> query -> get ( 'name' ) ; if ( empty ( $ theme ) ) { return new Response ( Trans :: __ ( 'page.extend.theme.generation.missing.name' ) ) ; } if ( ! $ newName ) { $ newName = basename ( $ them... | Generate a copy of a theme package . |
43,344 | public function installAll ( ) { try { $ response = $ this -> manager ( ) -> installPackages ( ) ; } catch ( \ Exception $ e ) { return $ this -> getJsonException ( $ e ) ; } if ( $ response === 0 ) { return new Response ( $ this -> manager ( ) -> getOutput ( ) ) ; } return $ this -> getJsonException ( new PackageManag... | Install all packages that are in the composer . json but not in vendor . |
43,345 | public function installed ( ) { try { return $ this -> json ( $ this -> manager ( ) -> getAllPackages ( ) ) ; } catch ( \ Exception $ e ) { return $ this -> getJsonException ( $ e ) ; } } | Get a list of all installed packages . |
43,346 | public function installPackage ( ) { try { return $ this -> render ( '@bolt/extend/_action-modal.twig' , $ this -> getRenderContext ( ) ) ; } catch ( \ Exception $ e ) { return $ this -> getJsonException ( $ e ) ; } } | Package install chooser modal . |
43,347 | public function overview ( ) { $ pinger = $ this -> app [ 'extend.ping' ] ; $ this -> app [ 'extend.online' ] = $ pinger -> ping ( true ) ; try { return $ this -> render ( '@bolt/extend/extend.twig' , $ this -> getRenderContext ( ) ) ; } catch ( \ Exception $ e ) { return $ this -> getJsonException ( $ e ) ; } } | The main Extensions page . |
43,348 | public function packageInfo ( Request $ request ) { $ packageName = $ request -> get ( 'package' ) ; $ reqVersion = $ request -> get ( 'version' ) ; try { $ response = $ this -> manager ( ) -> showPackage ( 'installed' , $ packageName , $ reqVersion ) ; } catch ( \ Exception $ e ) { return $ this -> getJsonException ( ... | Show installed packages . |
43,349 | private function getRenderContext ( ) { $ bundled = array_filter ( $ this -> app [ 'extensions' ] -> all ( ) , function ( ResolvedExtension $ ext ) { return $ ext -> isBundled ( ) ; } ) ; return [ 'messages' => $ this -> app [ 'extend.ping' ] -> getMessages ( ) , 'enabled' => $ this -> app [ 'extend.enabled' ] , 'write... | Get render parameters for Twig . |
43,350 | private function getJsonException ( \ Exception $ e ) { $ file = Path :: makeRelative ( $ e -> getFile ( ) , $ this -> app [ 'path_resolver' ] -> resolve ( 'root' ) ) ; $ error = [ 'error' => [ 'type' => get_class ( $ e ) , 'file' => $ file , 'line' => $ e -> getLine ( ) , 'message' => $ e -> getMessage ( ) , ] , ] ; r... | Return an exception formatted as JSON . |
43,351 | public static function conversionFailedSerialization ( $ value , $ format , $ error , Exception $ e = null ) { $ actualType = is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ; return new self ( sprintf ( "Could not convert PHP type '%s' to '%s', as an error was triggered by the serialization: %s" , ... | Thrown when a value failed serialisation . |
43,352 | private function loadTwig ( Environment $ twig ) { foreach ( $ this -> registerTwigFunctions ( ) as $ name => $ options ) { if ( is_string ( $ options ) ) { $ this -> addTwigFunction ( $ name , $ options ) ; } else { $ this -> addTwigFunction ( $ name , $ options [ 0 ] , isset ( $ options [ 1 ] ) ? $ options [ 1 ] : [ ... | Adds filters and functions to Twig Environment . |
43,353 | private function addTwigPath ( $ path , array $ options = [ ] ) { if ( $ path === 'templates' && $ this -> pathAdded ) { return ; } $ app = $ this -> getContainer ( ) ; $ position = isset ( $ options [ 'position' ] ) ? $ options [ 'position' ] : 'append' ; $ namespace = isset ( $ options [ 'namespace' ] ) ? $ options [... | Append a path to Twig s path array . |
43,354 | protected function addTwigFunction ( $ name , $ callback , $ options = [ ] ) { if ( is_string ( $ callback ) && method_exists ( $ this , $ callback ) ) { $ callback = [ $ this , $ callback ] ; } $ safe = method_exists ( $ this , 'isSafe' ) && $ this -> isSafe ( ) ; if ( isset ( $ options [ 'safe' ] ) ) { $ safe = ( boo... | Add a Twig Function . |
43,355 | protected function addTwigFilter ( $ name , $ callback , $ options = [ ] ) { if ( is_string ( $ callback ) && method_exists ( $ this , $ callback ) ) { $ callback = [ $ this , $ callback ] ; } $ safe = method_exists ( $ this , 'isSafe' ) && $ this -> isSafe ( ) ; if ( isset ( $ options [ 'safe' ] ) ) { $ safe = ( bool ... | Add a Twig Filter . |
43,356 | public function resolve ( $ path , $ absolute = true ) { $ path = $ this -> normalizeName ( $ path ) ; if ( isset ( $ this -> paths [ $ path ] ) ) { $ path = $ this -> paths [ $ path ] ; } $ path = preg_replace_callback ( '#%(.+)%#' , function ( $ match ) use ( $ path ) { $ alias = $ match [ 1 ] ; if ( ! isset ( $ this... | Resolve a path . |
43,357 | public function raw ( $ name ) { $ name = $ this -> normalizeName ( $ name ) ; return isset ( $ this -> paths [ $ name ] ) ? $ this -> paths [ $ name ] : null ; } | Returns the raw path definition for the name given . |
43,358 | public function getSortedNames ( ) { $ sorted = [ ] ; $ toSort = $ this -> getDependencies ( ) ; while ( count ( $ toSort ) > 0 ) { foreach ( $ toSort as $ name => $ dependencies ) { if ( ! array_diff ( $ dependencies , $ sorted ) ) { $ sorted [ ] = $ name ; unset ( $ toSort [ $ name ] ) ; } } } return $ sorted ; } | Returns the list of path names sorted by least dependent first . |
43,359 | private function getDependencies ( ) { $ dependencies = [ ] ; foreach ( $ this -> resolver -> names ( ) as $ name ) { $ dependencies [ $ name ] = $ this -> getDependenciesRecursive ( $ name ) ; } return $ dependencies ; } | Returns path names with their dependencies . |
43,360 | private function getDependenciesRecursive ( $ path , $ dependencies = [ ] ) { $ raw = $ this -> resolver -> raw ( $ path ) ; if ( $ raw !== null ) { $ path = $ raw ; } preg_match_all ( '#%([^/\\\\]+)%#' , $ path , $ matches ) ; foreach ( $ matches [ 1 ] as $ alias ) { if ( ! in_array ( $ alias , $ dependencies , true )... | Returns dependencies recursively for a path . |
43,361 | public function getFile ( $ path , $ throwException = true ) { if ( $ path instanceof FileInterface ) { return $ path ; } if ( ! $ this -> filesystem instanceof AggregateFilesystemInterface || $ this -> containsMountPoint ( $ path ) ) { $ file = $ this -> filesystem -> getFile ( $ path ) ; if ( $ file -> exists ( ) ) {... | Gets the file object for the path given . Paths with the mount point included are preferred but are not required for BC . If the mount point is not included a list of filesystems are checked and chosen if the file exists in that filesystem . |
43,362 | public function onEvent ( $ event ) { if ( ! $ event -> isMasterRequest ( ) ) { return ; } $ session = $ event -> getRequest ( ) -> getSession ( ) ; if ( $ session && $ session -> isStarted ( ) ) { $ this -> attachFlashBag ( $ session ) ; } } | Attach session s flash bag to flash logger if it is started . |
43,363 | public function isCheckRequired ( ) { if ( $ this -> expired === false ) { return false ; } if ( $ this -> cacheFile -> exists ( ) ) { $ expiryTimestamp = ( int ) $ this -> cacheFile -> read ( ) ; } else { $ expiryTimestamp = 0 ; } $ ts = Carbon :: createFromTimestamp ( $ expiryTimestamp + self :: CHECK_INTERVAL ) ; re... | Check if we have determined that we need to do a database check . |
43,364 | public function setCheckRequired ( ) { try { $ this -> expired = true ; $ this -> cacheFile -> delete ( ) ; } catch ( FileNotFoundException $ e ) { } catch ( IOException $ e ) { $ message = sprintf ( 'Unable to remove database schema check timestamp: %s' , $ e -> getMessage ( ) ) ; throw new StorageException ( $ messag... | Invalidate our database check by removing the timestamp file from cache . |
43,365 | protected function doFlush ( ) { $ result = parent :: doFlush ( ) ; if ( $ this -> filesystem instanceof CompositeFilesystemInterface ) { $ cacheFs = $ this -> filesystem -> getFilesystem ( 'cache' ) ; if ( $ cacheFs -> has ( 'config-cache.json' ) ) { $ cacheFs -> delete ( 'config-cache.json' ) ; } $ this -> flushDirec... | Clear the cache . Both the doctrine FilesystemCache as well as twig and thumbnail temp files . |
43,366 | private function createPathIfNeeded ( ) { if ( ! is_dir ( $ this -> directory ) ) { return @ mkdir ( $ this -> directory , 0777 & ( ~ $ this -> umask ) , true ) && ! is_dir ( $ this -> directory ) ; } return true ; } | Create base path path if needed . |
43,367 | public function create ( ) { if ( $ this -> rootPath === null ) { throw new \ LogicException ( 'Root path must be set before PathResolver can be created' ) ; } return new PathResolver ( $ this -> rootPath , $ this -> paths ) ; } | Create PathResolver . |
43,368 | public function create ( $ className , $ data , ClassMetadataInterface $ metadata = null ) { $ repo = $ this -> getRepository ( $ className ) ; return $ repo -> create ( $ data , $ metadata ) ; } | Creates an entity of the given class with the data supplied . |
43,369 | public function getEntityBuilder ( $ className = null , ClassMetadata $ classMetadata = null ) { $ builder = new Entity \ Builder ( $ this -> getMapper ( ) , $ this -> getFieldManager ( ) ) ; if ( $ className !== null ) { $ builder -> setClass ( $ className ) ; } if ( $ classMetadata !== null ) { $ builder -> setClassM... | Get an entity builder instance for a given class . |
43,370 | public function createCollection ( $ className ) { $ className = ( string ) $ className ; if ( array_key_exists ( $ className , $ this -> aliases ) ) { $ className = $ this -> aliases [ $ className ] ; } return $ this -> getCollectionManager ( ) -> create ( $ className ) ; } | Shorthand access method to create collection . Consults aliases to allow short names . |
43,371 | public function find ( $ className , $ id ) { $ repo = $ this -> getRepository ( $ className ) ; return $ repo -> find ( $ id ) ; } | Finds an object by its identifier . |
43,372 | public function save ( $ object ) { if ( method_exists ( $ object , 'getContenttype' ) ) { $ entityName = $ object -> getContenttype ( ) ; } else { $ entityName = get_class ( $ object ) ; } $ repo = $ this -> getRepository ( $ entityName ) ; return $ repo -> save ( $ object ) ; } | The object will be entered into the database as a result of this operation . |
43,373 | public function getDefaultRepositoryFactory ( $ classMetadata ) { if ( ! is_callable ( $ this -> defaultRepositoryFactory ) ) { throw new \ RuntimeException ( 'Unable to handle unmapped data without a defaultRepositoryFactory set' , 1 ) ; } $ factory = $ this -> defaultRepositoryFactory ; return $ factory ( $ classMeta... | Returns the default repository factory set on this object . |
43,374 | public function getContent ( $ textquery , $ parameters = [ ] , & $ pager = [ ] , $ whereparameters = [ ] ) { if ( $ this -> legacyStorage !== null ) { return $ this -> legacy ( ) -> getContent ( $ textquery , $ parameters , $ pager , $ whereparameters ) ; } elseif ( $ this -> queryService !== null ) { return $ this ->... | Note that this method is explicitly defined here because the magic method above cannot pass dynamic variables by reference . |
43,375 | public function getContentType ( $ alias ) { if ( $ this -> legacyStorage !== null ) { return $ this -> legacy ( ) -> getContentType ( $ alias ) ; } return $ this -> mapping -> createContentType ( $ alias ) ; } | Drop in replacement for the legacy storage getContentType method . |
43,376 | public function initialize ( ) { $ this -> initializeShortAliases ( ) ; $ this -> initializeDefaultAliases ( ) ; foreach ( $ this -> schemaManager -> getSchemaTables ( ) as $ table ) { $ this -> loadMetadataForTable ( $ table ) ; } $ this -> initialized = true ; } | Reads the schema from Bolt \ Storage \ Database \ Schema \ Manager and creates mapping data . |
43,377 | public function initializeShortAliases ( ) { foreach ( $ this -> schemaManager -> getSchemaTables ( ) as $ table ) { if ( $ tableName = $ table -> getName ( ) ) { $ mainAlias = $ this -> getContentTypeFromAlias ( $ table -> getOption ( 'alias' ) ) ; $ this -> aliases [ $ mainAlias ] = $ tableName ; $ slugAlias = $ this... | Setup some short aliases so non prefixed keys can be used to get metadata . |
43,378 | public function initializeDefaultAliases ( ) { foreach ( $ this -> defaultAliases as $ def => $ entityClass ) { $ table = $ this -> namingStrategy -> classToTableName ( $ entityClass ) ; $ this -> defaultAliases [ $ table ] = $ entityClass ; } foreach ( $ this -> aliases as $ prefixed ) { $ entity = isset ( $ this -> d... | This seeds the defaultAliases array with the correctly prefixed mappings . |
43,379 | protected function normalizeFieldTypes ( array & $ fields ) { foreach ( $ fields as $ rkey => & $ value ) { $ value [ 'fieldname' ] = $ rkey ; if ( $ value [ 'type' ] === 'select' && isset ( $ value [ 'multiple' ] ) && $ value [ 'multiple' ] === true ) { $ value [ 'type' ] = 'selectmultiple' ; } if ( isset ( $ this -> ... | Internal method to fix or patch any field mappings |
43,380 | public function getRepeaterMapping ( array $ config ) { $ mapping = [ 'data' => null ] ; $ mapping [ 'data' ] = $ this -> setRepeaters ( null , null , $ config ) ; return $ mapping ; } | This is a helper method to get a correct mapping from an array config . It s designed to take raw array config to generate a correct format mapping for repeaters . |
43,381 | public function setRelations ( $ contentKey , $ className ) { if ( ! isset ( $ this -> contenttypes [ $ contentKey ] [ 'relations' ] ) ) { return ; } foreach ( $ this -> contenttypes [ $ contentKey ] [ 'relations' ] as $ key => $ data ) { if ( isset ( $ data [ 'alias' ] ) ) { $ relationKey = $ data [ 'alias' ] ; } else... | Set the relationship . |
43,382 | public function setTaxonomies ( $ contentKey , $ className ) { if ( ! isset ( $ this -> contenttypes [ $ contentKey ] [ 'taxonomy' ] ) ) { return ; } foreach ( $ this -> contenttypes [ $ contentKey ] [ 'taxonomy' ] as $ taxonomytype ) { $ taxonomyConfig = $ this -> taxonomies [ $ taxonomytype ] ; if ( isset ( $ taxonom... | Set the taxonomy . |
43,383 | public function setTemplatefields ( $ contentKey , $ className ) { if ( ! isset ( $ this -> contenttypes [ $ contentKey ] [ 'templatefields' ] ) ) { return ; } $ config = $ this -> contenttypes [ $ contentKey ] [ 'templatefields' ] ; foreach ( $ config as & $ template ) { foreach ( $ template [ 'fields' ] as & $ field ... | Setup a templatefields field if needed . |
43,384 | public function getFieldTypeFor ( $ name , $ column , $ field = null ) { $ type = null ; if ( $ column instanceof Column ) { if ( $ column -> getType ( ) ) { $ type = get_class ( $ column -> getType ( ) ) ; } $ column = $ column -> getName ( ) ; } if ( $ field !== null ) { if ( isset ( $ this -> contenttypes [ $ name ]... | Get the field type for a given column . |
43,385 | public function getClassMetadata ( $ className ) { if ( ! $ this -> initialized ) { $ this -> initialize ( ) ; } if ( array_key_exists ( $ className , $ this -> metadata ) ) { return $ this -> metadata [ $ className ] ; } return false ; } | Returns the metadata for a given class name . |
43,386 | public function getContentTypeFromAlias ( $ alias , $ forceSlug = false ) { foreach ( $ this -> contenttypes -> getData ( ) as $ key => $ contenttype ) { if ( $ forceSlug && $ forceSlug === 'singular' ) { if ( isset ( $ contenttype [ 'singular_slug' ] ) && ( $ contenttype [ 'slug' ] === $ alias || $ contenttype [ 'tabl... | Given a tablename or slug get the correct Bolt keyname from the config . |
43,387 | protected function normalizeBoltName ( $ alias ) { $ metadata = $ this -> loadMetadataForClass ( $ alias ) ; return $ metadata ? $ metadata -> getBoltName ( ) : null ; } | This helper function takes all of the potential alias names for a contenttype and resolves it to the standardized Bolt name . |
43,388 | public function run ( ) { if ( ! class_exists ( CustomisationExtension :: class ) ) { return ; } $ contents = $ this -> load ( ) ; $ this -> updateSiteBundleLoader ( $ contents ) ; if ( ! $ contents -> isEmpty ( ) ) { $ this -> save ( $ contents ) ; } } | Setup . bolt . yml file if needed . |
43,389 | private function load ( ) { if ( file_exists ( static :: FILENAME ) ) { return MutableBag :: from ( Yaml :: parse ( file_get_contents ( static :: FILENAME ) ) ? : [ ] ) ; } return MutableBag :: of ( ) ; } | Load data from . bolt . yml if it exists . |
43,390 | private function updateSiteBundleLoader ( MutableBag $ contents ) { if ( ! $ this -> io -> confirm ( 'Would you like to enable the default site Bundle?' ) ) { return ; } $ extensions = ( array ) $ contents -> get ( 'extensions' , [ ] ) ; foreach ( $ extensions as $ extension ) { if ( is_a ( $ extension , CustomisationE... | Add the default site bundle if it exists . |
43,391 | public function getOrder ( $ contentType ) { if ( isset ( $ this -> orderBys [ $ contentType ] ) ) { return $ this -> orderBys [ $ contentType ] ; } return false ; } | Get the default order setting for a given content type . |
43,392 | protected function parseContenttypes ( ) { $ contentTypes = $ this -> config -> get ( 'contenttypes' ) ; foreach ( $ contentTypes as $ type => $ values ) { $ sort = $ values [ 'sort' ] ? : '-datepublish' ; $ this -> orderBys [ $ type ] = $ sort ; if ( isset ( $ values [ 'singular_slug' ] ) ) { $ this -> orderBys [ $ va... | Iterates over the main config and sets up what the default ordering should be |
43,393 | public function recordInstall ( $ package , $ version ) { $ url = sprintf ( $ this -> extendSite . $ this -> urls [ 'install' ] , $ package , $ version ) ; try { $ this -> client -> head ( $ url ) ; } catch ( RequestException $ e ) { $ this -> loggerSystem -> critical ( $ e -> getMessage ( ) , [ 'event' => 'exception' ... | Record an extension install . |
43,394 | public function setZone ( Request $ request ) { if ( $ zone = Zone :: get ( $ request ) ) { return $ zone ; } $ zone = $ this -> determineZone ( $ request ) ; Zone :: set ( $ request , $ zone ) ; return $ zone ; } | Sets the request s zone if needed and returns it . |
43,395 | protected function determineZone ( Request $ request ) { if ( $ request -> isXmlHttpRequest ( ) || $ this -> isPathApplicable ( $ request , Zone :: ASYNC ) ) { return Zone :: ASYNC ; } elseif ( $ this -> isPathApplicable ( $ request , Zone :: BACKEND ) ) { return Zone :: BACKEND ; } return Zone :: FRONTEND ; } | Determine the zone and return it . |
43,396 | protected function isPathApplicable ( Request $ request , $ zone ) { $ prefix = $ this -> app [ "controller.$zone.mount_prefix" ] ; return $ this -> startsWith ( $ request -> getPathInfo ( ) , $ prefix ) ; } | Check is a request applies to a zone . |
43,397 | public function setApp ( Application $ app ) { $ this -> app = $ app ; AppSingleton :: set ( $ app ) ; $ this -> pathResolver = $ app [ 'path_resolver' ] ; $ default = true ; if ( isset ( $ this -> app [ 'config.validator.apache_enabled' ] ) ) { $ default = $ this -> app [ 'config.validator.apache_enabled' ] ; } $ this... | Don t use! |
43,398 | public function setPath ( $ name , $ value , $ applyToResolver = true ) { if ( $ applyToResolver && $ this -> callerNotSelfOrChild ( ) ) { Deprecated :: method ( 3.3 , 'Use Bolt\Filesystem (recommended) or PathResolver::resolve instead.' ) ; } if ( strpos ( $ value , '%' ) !== false ) { $ path = function ( ) use ( $ va... | Set a resource path . |
43,399 | public function getPath ( $ name ) { if ( $ this -> callerNotSelfOrPathsProxy ( ) ) { Deprecated :: method ( 3.3 , 'Use Bolt\Filesystem (recommended) or PathResolver::resolve instead.' ) ; } return $ this -> getPathObject ( $ name ) -> string ( ) ; } | Gets a path as a string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.