idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
43,100 | private static function getConsoleMode ( ) { $ info = static :: runCommand ( 'mode CON' ) ; if ( $ info && preg_match ( '/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/' , $ info , $ matches ) ) { return [ ( int ) $ matches [ 2 ] , ( int ) $ matches [ 1 ] ] ; } return [ ] ; } | Run console mode command and parse output to width & height . |
43,101 | private static function getSttyColumns ( ) { $ info = static :: runCommand ( 'stty -a | grep columns' ) ; if ( $ info && preg_match ( '/rows.(\d+);.columns.(\d+);/i' , $ info , $ matches ) ) { } elseif ( $ info && preg_match ( '/;.(\d+).rows;.(\d+).columns/i' , $ info , $ matches ) ) { } else { return [ ] ; } return [ ... | Run stty command and parse output to width & height . |
43,102 | private static function runCommand ( $ command ) { if ( ! function_exists ( 'proc_open' ) ) { return null ; } $ descriptorSpec = [ 1 => [ 'pipe' , 'w' ] , 2 => [ 'pipe' , 'w' ] , ] ; $ process = proc_open ( $ command , $ descriptorSpec , $ pipes , null , null , [ 'suppress_errors' => true ] ) ; if ( ! is_resource ( $ p... | Run a command . |
43,103 | private function menuHelper ( $ item ) { if ( isset ( $ item [ 'submenu' ] ) && is_array ( $ item [ 'submenu' ] ) ) { $ item [ 'submenu' ] = $ this -> menuHelper ( $ item [ 'submenu' ] ) ; } if ( isset ( $ item [ 'route' ] ) ) { $ item [ 'link' ] = $ this -> resolveRouteToLink ( $ item ) ; } elseif ( isset ( $ item [ '... | Updates a menu item to have at least a link key . |
43,104 | private function resolveRouteToLink ( array $ item ) { $ param = ! empty ( $ item [ 'param' ] ) ? $ item [ 'param' ] : [ ] ; if ( isset ( $ item [ 'add' ] ) ) { Deprecated :: warn ( 'Menu item property "add"' , null , 'Use "#" under "param" instead.' ) ; $ add = $ item [ 'add' ] ; if ( ! empty ( $ add ) && $ add [ 0 ] ... | Resolve the route to a generated url . |
43,105 | private function resolvePathToContent ( array $ item ) { if ( $ item [ 'path' ] === 'homepage' ) { $ item [ 'link' ] = $ this -> app [ 'url_generator' ] -> generate ( 'homepage' ) ; return $ item ; } if ( preg_match ( '#^(https?://|//)#i' , $ item [ 'path' ] ) ) { $ item [ 'link' ] = $ item [ 'path' ] ; $ this -> app [... | Determine the type of path we have . |
43,106 | private function populateItemFromRecord ( array $ item , $ path ) { $ engine = $ this -> app [ $ this -> storageAccessor ] ; $ content = $ engine -> getContent ( $ path , [ 'hydrate' => false ] ) ; if ( $ content ) { if ( empty ( $ item [ 'label' ] ) ) { $ item [ 'label' ] = ! empty ( $ content -> values [ 'title' ] ) ... | Populate a single menu item . |
43,107 | public static function fromEvent ( Event $ event ) { $ vendorDir = $ event -> getComposer ( ) -> getConfig ( ) -> get ( 'vendor-dir' ) ; $ boltDir = $ vendorDir . '/bolt/bolt' ; if ( file_exists ( $ boltDir ) ) { $ userApp = require $ boltDir . '/app/bootstrap.php' ; $ userResolver = $ userApp [ 'path_resolver' ] ; $ a... | Create from Composer Event . |
43,108 | private function mirror ( $ origin , $ target , $ delete = false ) { $ this -> filesystem -> mirror ( $ origin , $ target , null , [ 'override' => true , 'delete' => $ delete ] ) ; } | Helper to make mirror calls shorter . |
43,109 | public function before ( Request $ request ) { $ this -> app [ 'stopwatch' ] -> start ( 'bolt.frontend.before' ) ; if ( ! $ this -> hasUsers ( ) ) { $ this -> flashes ( ) -> info ( Trans :: __ ( 'general.phrase.users-none-create-first' ) ) ; return $ this -> redirectToRoute ( 'userfirst' ) ; } if ( $ this -> getOption ... | The default before filter for the controllers in this file . |
43,110 | public function homepage ( Request $ request ) { $ homepage = $ this -> getOption ( 'theme/homepage' ) ? : $ this -> getOption ( 'general/homepage' ) ; $ listingParameters = $ this -> getListingParameters ( $ homepage , true ) ; $ content = $ this -> getContent ( $ homepage , $ listingParameters ) ; $ template = $ this... | Controller for the Homepage route . Usually the front page of the website . |
43,111 | public function preview ( Request $ request , $ contenttypeslug ) { if ( ! $ request -> isMethod ( 'POST' ) ) { throw new MethodNotAllowedHttpException ( [ 'POST' ] , 'This route only accepts POST requests.' ) ; } $ contenttype = $ this -> getContentType ( $ contenttypeslug ) ; $ formValues = $ request -> request -> al... | The controller for previewing a content from posted data . |
43,112 | private function fixBlockFieldsForPreview ( $ record ) { foreach ( $ record -> contenttype [ 'fields' ] as $ fieldSlug => $ fieldSettings ) { if ( $ fieldSettings [ 'type' ] === 'block' ) { $ fieldValue = $ this -> getBlockFieldValue ( $ record , $ fieldSlug ) ; if ( $ fieldValue ) { $ newArray = [ ] ; foreach ( $ fiel... | Helper function to prefill block fields with an additional block field per item . |
43,113 | private function fixHTMLFieldsForPreview ( $ record ) { foreach ( $ record -> contenttype [ 'fields' ] as $ fieldSlug => $ fieldSettings ) { if ( in_array ( $ fieldSettings [ 'type' ] , [ 'html' , 'text' , 'textarea' , 'markdown' ] ) ) { $ fieldValue = new \ Twig_Markup ( $ this -> getFieldValue ( $ record , $ fieldSlu... | Helper function to make sure HTML - like fields are Twig_Markup and image fields are an image . Like they are in a real page . |
43,114 | public function listing ( Request $ request , $ contenttypeslug ) { $ listingParameters = $ this -> getListingParameters ( $ contenttypeslug ) ; $ content = $ this -> getContent ( $ contenttypeslug , $ listingParameters ) ; $ contenttype = $ this -> getContentType ( $ contenttypeslug ) ; $ template = $ this -> template... | The listing page controller . |
43,115 | protected function isTaxonomyValid ( $ content , $ slug , array $ taxonomy ) { if ( $ taxonomy [ 'behaves_like' ] === 'tags' && ! $ content ) { return false ; } $ isNotTag = in_array ( $ taxonomy [ 'behaves_like' ] , [ 'categories' , 'grouping' ] ) ; $ options = isset ( $ taxonomy [ 'options' ] ) ? array_keys ( $ taxon... | Check if the taxonomy is valid . |
43,116 | private function getListingParameters ( $ contentTypeSlug , $ allowViewless = false ) { $ contentType = $ this -> getContentType ( current ( explode ( '/' , $ contentTypeSlug ) ) ) ; if ( $ contentType === false ) { return [ ] ; } if ( $ contentType [ 'viewless' ] && ! $ allowViewless ) { $ this -> abort ( Response :: ... | Returns an array of the parameters used in getContent for listing pages . |
43,117 | private function getListingOrder ( $ contentType ) { if ( isset ( $ contentType [ 'taxonomy' ] ) ) { $ taxonomies = $ this -> getOption ( 'taxonomy' ) ; foreach ( $ contentType [ 'taxonomy' ] as $ taxonomyName ) { if ( $ taxonomies [ $ taxonomyName ] [ 'has_sortorder' ] ) { return null ; } } } return $ this -> getOptio... | Return the listing order . |
43,118 | public function askThenRemove ( InputInterface $ input , OverwritableOutputInterface $ output , Question $ question ) { if ( ! $ input -> isInteractive ( ) ) { return $ question -> getDefault ( ) ; } $ this -> remove = true ; $ this -> question = $ question ; $ this -> output = $ output ; $ this -> autocomplete = $ thi... | Ask a question to the user and then remove the question & answer . |
43,119 | protected function onRead ( $ data ) { if ( ! $ this -> remove || $ this -> autocomplete || $ this -> question -> isHidden ( ) ) { return ; } $ this -> output -> captureUserInput ( $ data ) ; } | On input stream read . |
43,120 | protected function instantiateController ( $ class ) { $ refCls = new \ ReflectionClass ( $ class ) ; if ( $ refCls -> implementsInterface ( ExtensionInterface :: class ) ) { Deprecated :: warn ( 'Using Extension class name' , 3.3 , 'Use controller object in route definition or make the controller a service and use the... | If class name passed in is an extension then return the extension instance instead of creating a new class . |
43,121 | private function loadTranslationsFromDefaultPath ( ) { $ baseDir = $ this -> getBaseDirectory ( ) ; $ filesystem = $ this -> getBaseDirectory ( ) -> getFilesystem ( ) ; if ( $ filesystem -> has ( $ baseDir -> getFullPath ( ) . '/translations' ) === false ) { return null ; } $ translations = [ ] ; $ local = $ filesystem... | Load translations from every extensions translations directory . |
43,122 | public function add ( Package $ package ) { $ name = $ package -> getName ( ) ; if ( isset ( $ this -> packages [ $ name ] ) ) { return ; } $ this -> packages [ $ name ] = $ package ; } | Add a package to the collection . |
43,123 | public function get ( $ name ) { if ( ! isset ( $ this -> packages [ $ name ] ) ) { return null ; } return $ this -> packages [ $ name ] ; } | Get a package from the collection . |
43,124 | public function removeCheck ( $ check ) { if ( in_array ( $ check , $ this -> checks ) ) { $ this -> checks = array_diff ( $ this -> checks , [ $ check ] ) ; } } | Remove a check from the list causing it to be skipped . |
43,125 | public function addCheck ( $ check , $ top = false ) { if ( ! in_array ( $ check , $ this -> checks ) ) { if ( $ top ) { array_unshift ( $ this -> checks , $ check ) ; } else { $ this -> checks [ ] = $ check ; } } } | Add a check . |
43,126 | public function doChecks ( ) { foreach ( $ this -> checks as $ check ) { $ method = 'check' . ucfirst ( $ check ) ; $ this -> $ method ( ) ; } foreach ( $ this -> configChecks as $ check ) { $ this -> lowlevelConfigFix ( $ check ) ; } } | Perform the checks . |
43,127 | protected function lowlevelConfigFix ( $ name ) { $ distname = realpath ( __DIR__ . '/../../app/config/' . $ name . '.yml.dist' ) ; $ ymlname = $ this -> config -> getPath ( 'config' ) . '/' . $ name . '.yml' ; if ( file_exists ( $ ymlname ) && ! is_readable ( $ ymlname ) ) { $ error = sprintf ( "Couldn't read <code>%s... | Check if a config file is present and writable . If not try to create it from the filename . dist . |
43,128 | public function hasPending ( $ fromTables , $ toTables , array $ protectedTableNames ) { if ( $ this -> pending !== null ) { return $ this -> pending ; } $ this -> compare ( $ fromTables , $ toTables , $ protectedTableNames ) ; return $ this -> pending ; } | Are database updates required . |
43,129 | public function compare ( $ fromTables , $ toTables , array $ protectedTableNames , $ force = false ) { if ( $ this -> response !== null && $ force === false ) { return $ this -> getResponse ( ) ; } if ( $ force === false ) { $ this -> setIgnoredChanges ( ) ; } $ this -> checkTables ( $ fromTables , $ toTables ) ; if (... | Run the update checks and flag if we need an update . |
43,130 | public function getCreates ( ) { if ( $ this -> tablesCreate === null ) { return [ ] ; } $ platform = $ this -> connection -> getDatabasePlatform ( ) ; $ flags = AbstractPlatform :: CREATE_INDEXES | AbstractPlatform :: CREATE_FOREIGNKEYS ; $ queries = [ ] ; foreach ( $ this -> tablesCreate as $ tableName => $ table ) {... | Get the table creation SQL queries . |
43,131 | public function getAlters ( ) { $ queries = [ ] ; if ( $ this -> tablesAlter === null ) { return $ queries ; } $ platform = $ this -> connection -> getDatabasePlatform ( ) ; foreach ( $ this -> tablesAlter as $ tableName => $ tableDiff ) { $ queries [ $ tableName ] = $ platform -> getAlterTableSQL ( $ tableDiff ) ; } r... | Get the table alteration SQL queries . |
43,132 | protected function checkTables ( $ fromTables , $ toTables ) { foreach ( $ toTables as $ toTableAlias => $ toTable ) { $ tableName = $ toTable -> getName ( ) ; if ( ! isset ( $ fromTables [ $ toTableAlias ] ) ) { $ this -> pending = true ; $ this -> tablesCreate [ $ tableName ] = $ toTable ; $ this -> getResponse ( ) -... | Run the checks on the tables to see if they firstly exist then if they require update . |
43,133 | protected function checkTable ( Table $ fromTable , Table $ toTable ) { $ tableName = $ fromTable -> getName ( ) ; $ diff = ( new Comparator ( ) ) -> diffTable ( $ fromTable , $ toTable ) ; if ( $ diff !== false ) { $ this -> removeIgnoredChanges ( $ diff ) ; $ this -> diffs [ $ tableName ] = $ diff ; } } | Check that a single table s columns and indices are valid . |
43,134 | protected function adjustContentTypeDiffs ( TableDiff $ tableDiff , array $ protectedTableNames ) { $ alias = str_replace ( $ this -> prefix , '' , $ tableDiff -> fromTable -> getName ( ) ) ; if ( in_array ( $ alias , $ protectedTableNames ) ) { $ tableDiff -> removedColumns = [ ] ; } } | Clear removedColumns attribute from ContentType table diffs to prevent accidental data removal . |
43,135 | protected function addAlterResponses ( ) { $ platform = $ this -> connection -> getDatabasePlatform ( ) ; $ response = $ this -> getResponse ( ) ; $ this -> setIgnoredChanges ( ) ; foreach ( $ this -> diffs as $ tableName => $ tableDiff ) { $ this -> pending = true ; $ this -> tablesAlter [ $ tableName ] = $ tableDiff ... | Add required changes to the response object . |
43,136 | protected function toString ( ) { if ( $ this -> rendered !== null ) { return $ this -> rendered ; } if ( is_callable ( $ this -> callback ) ) { try { return $ this -> rendered = $ this -> invokeCallable ( $ this -> callback , $ this -> callbackArguments ) ; } catch ( \ Exception $ e ) { trigger_error ( $ e -> getMessa... | Either return the passed in content or the result of the callback . |
43,137 | private function assertMaintenanceMode ( ) { $ helper = $ this -> getHelper ( 'container' ) ; $ app = $ helper -> getContainer ( ) ; $ config = $ app [ 'config' ] ; if ( $ config -> get ( 'general/maintenance_mode' ) !== true ) { throw new RuntimeException ( 'Site is not in maintenance mode!' ) ; } } | Ensure the site is in maintenance mode . |
43,138 | public function current ( $ content ) { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; $ requestUri = $ request -> getRequestUri ( ) ; $ routeParams = $ request -> get ( '_route_params' ) ; if ( is_string ( $ content ) && in_array ( $ content , $ routeParams ) ) { return true ; } if ( is_array ( $ conten... | Returns true if the given content is the current content . |
43,139 | public function excerpt ( $ content , $ length = 200 , $ focus = null , $ stripFields = null ) { $ excerpter = new Excerpt ( $ content ) ; return $ excerpter -> getExcerpt ( $ length , false , $ focus , $ stripFields ) ; } | Create an excerpt for the given content . |
43,140 | public function getFirstImage ( $ content ) { Deprecated :: method ( '3.4' ) ; $ contentType = $ content -> getContenttype ( ) ; if ( ! $ contentType instanceof ContentType ) { return null ; } $ fields = $ contentType -> getFields ( ) ; if ( ! is_array ( $ fields ) ) { return null ; } foreach ( $ fields as $ key => $ f... | Gets the first image from the given content record . |
43,141 | public function pager ( Environment $ env , $ pagerName = '' , $ surr = 4 , $ template = '_sub_pager.twig' , $ class = '' ) { if ( $ this -> pagerManager -> isEmptyPager ( ) ) { return '' ; } $ thisPager = $ this -> pagerManager -> getPager ( $ pagerName ) ; $ context = [ 'pager' => $ thisPager , 'surr' => $ surr , 'su... | Output a simple pager for paginated listing pages . |
43,142 | public function selectField ( $ content , $ fieldName , $ startempty = false , $ keyName = 'id' , $ contentType = null ) { $ retval = $ startempty ? [ ] : [ '' => '' ] ; if ( empty ( $ content ) ) { return $ retval ; } foreach ( $ content as $ c ) { if ( is_string ( $ contentType ) && $ contentType !== '' ) { $ content... | Return a selected field from a contentset . |
43,143 | public function onRequest ( GetResponseEvent $ event ) { if ( ! $ event -> isMasterRequest ( ) ) { return ; } if ( ! $ session = $ event -> getRequest ( ) -> getSession ( ) ) { return ; } if ( $ this -> debugLoggedOff || ( $ session -> isStarted ( ) && $ session -> has ( 'authentication' ) ) ) { $ this -> dispatcher ->... | Enable toolbar if logged in or debug mode is enabled . |
43,144 | public function browse ( Request $ request , $ namespace , $ path ) { $ directory = $ this -> filesystem ( ) -> getDir ( "$namespace://$path" ) ; $ listing = new Listing ( $ directory ) ; $ showHidden = $ this -> isAllowed ( 'files:hidden' ) ; try { $ directories = $ listing -> getDirectories ( $ showHidden ) ; $ files... | List browse on the server so we can insert them in the file input . |
43,145 | public function createFolder ( Request $ request ) { $ namespace = $ request -> request -> get ( 'namespace' ) ; $ parentPath = $ request -> request -> get ( 'parent' ) ; $ folderName = $ request -> request -> get ( 'foldername' ) ; try { $ dir = $ this -> filesystem ( ) -> getDir ( "$namespace://$parentPath/$folderNam... | Create a new folder . |
43,146 | public function deleteFile ( Request $ request ) { $ namespace = $ request -> request -> get ( 'namespace' ) ; $ filename = $ request -> request -> get ( 'filename' ) ; try { $ this -> filesystem ( ) -> delete ( "$namespace://$filename" ) ; return $ this -> json ( $ filename , Response :: HTTP_OK ) ; } catch ( Exceptio... | Delete a file on the server . |
43,147 | public function duplicateFile ( Request $ request ) { $ namespace = $ request -> request -> get ( 'namespace' ) ; $ filename = $ request -> request -> get ( 'filename' ) ; $ filesystem = $ this -> filesystem ( ) -> getFilesystem ( $ namespace ) ; $ extensionPos = strrpos ( $ filename , '.' ) ? : strlen ( $ filename ) ;... | Duplicate a file on the server . |
43,148 | public function filesAutoComplete ( Request $ request ) { $ term = $ request -> query -> get ( 'term' , '.*' ) ; $ dir = Path :: getDirectory ( $ term ) ; $ term = Path :: getFilename ( $ term ) ; $ term = preg_quote ( $ term ) ; $ extensions = implode ( '|' , explode ( ',' , $ request -> query -> get ( 'ext' , '.*' ) ... | Return autocomplete data for a file name . |
43,149 | public function recordBrowser ( ) { $ results = [ ] ; foreach ( $ this -> app [ 'config' ] -> get ( 'contenttypes' ) as $ contenttype ) { if ( $ contenttype [ 'viewless' ] ) { continue ; } $ slug = $ contenttype [ 'slug' ] ; $ records = $ this -> getContent ( $ slug , [ 'published' => true , 'hydrate' => false ] ) ; fo... | List records to easily insert links through the WYSIWYG editor . |
43,150 | public function removeFolder ( Request $ request ) { $ namespace = $ request -> request -> get ( 'namespace' ) ; $ parent = $ request -> request -> get ( 'parent' ) ; $ folderName = $ request -> request -> get ( 'foldername' ) ; try { $ this -> filesystem ( ) -> deleteDir ( "$namespace://$parent/$folderName" ) ; return... | Delete a folder recursively if writeable . |
43,151 | public function renameFile ( Request $ request ) { $ namespace = $ request -> request -> get ( 'namespace' ) ; $ parent = $ request -> request -> get ( 'parent' ) ; $ oldName = $ request -> request -> get ( 'oldname' ) ; $ newName = $ request -> request -> get ( 'newname' ) ; if ( ! $ this -> isExtensionChangedAndIsCha... | Rename a file within the files directory tree . |
43,152 | public function renameFolder ( Request $ request ) { $ namespace = $ request -> request -> get ( 'namespace' ) ; $ parent = $ request -> request -> get ( 'parent' ) ; $ oldName = $ request -> request -> get ( 'oldname' ) ; $ newName = $ request -> request -> get ( 'newname' ) ; try { $ dir = $ this -> filesystem ( ) ->... | Rename a folder within the files directory tree . |
43,153 | private function isExtensionChangedAndIsChangeAllowed ( $ oldName , $ newName ) { $ user = $ this -> getUser ( ) ; if ( $ this -> users ( ) -> hasRole ( $ user [ 'id' ] , 'root' ) || $ this -> users ( ) -> hasRole ( $ user [ 'id' ] , 'admin' ) ) { return true ; } $ oldFile = new \ SplFileInfo ( $ oldName ) ; $ newFile ... | Check that file extensions are not being changed . |
43,154 | private function logException ( $ message , $ exception ) { return $ this -> app [ 'logger.system' ] -> error ( $ message . ': ' . $ exception -> getMessage ( ) , [ 'event' => 'exception' , 'exception' => $ exception ] ) ; } | Log an exception to the system log . |
43,155 | public function getConfig ( $ contentType ) { if ( array_key_exists ( $ contentType , $ this -> searchableTypes ) ) { return $ this -> searchableTypes [ $ contentType ] ; } if ( $ this -> canSearchInvisible ( ) && array_key_exists ( $ contentType , $ this -> invisibleTypes ) ) { return $ this -> invisibleTypes [ $ cont... | Get the config of all fields for a given content type . |
43,156 | public function getFieldConfig ( $ contentType , $ field ) { if ( isset ( $ this -> searchableTypes [ $ contentType ] [ $ field ] ) ) { return $ this -> searchableTypes [ $ contentType ] [ $ field ] ; } if ( $ this -> canSearchInvisible ( ) && isset ( $ this -> invisibleTypes [ $ contentType ] [ $ field ] ) ) { return ... | Get the config of one given field for a given content type . |
43,157 | protected function parseContenttypes ( ) { $ contentTypes = $ this -> config -> get ( 'contenttypes' ) ; foreach ( $ contentTypes as $ type => $ values ) { $ this -> getSearchableColumns ( $ type ) ; if ( isset ( $ values [ 'taxonomy' ] ) ) { $ this -> parseTaxonomies ( $ type , $ values [ 'taxonomy' ] ) ; } } } | Iterates over the main config and delegates weighting to both searchable columns and searchable taxonomies . |
43,158 | protected function parseTaxonomies ( $ contentType , $ taxonomies ) { foreach ( ( array ) $ taxonomies as $ taxonomy ) { $ taxonomyConfig = $ this -> config -> get ( 'taxonomy/' . $ taxonomy ) ; if ( isset ( $ taxonomyConfig [ 'searchweight' ] ) ) { $ weight = $ taxonomyConfig [ 'searchweight' ] ; } elseif ( isset ( $ ... | Iterates the taxonomies for a given ContentType then assigns a weighting based on type . |
43,159 | protected function getSearchableColumns ( $ type ) { $ fields = $ this -> config -> get ( 'contenttypes/' . $ type . '/fields' ) ; foreach ( $ fields as $ field => $ options ) { if ( in_array ( $ options [ 'type' ] , [ 'text' , 'textarea' , 'html' , 'markdown' ] ) || ( isset ( $ options [ 'searchable' ] ) && $ options ... | Determine what columns are searchable for a given ContentType . |
43,160 | protected function isInvisible ( $ contentType ) { $ info = $ this -> config -> get ( 'contenttypes/' . $ contentType ) ; if ( $ info ) { if ( array_key_exists ( 'viewless' , $ info ) && $ info [ 'viewless' ] === true ) { return true ; } if ( array_key_exists ( 'searchable' , $ info ) && $ info [ 'searchable' ] === fal... | Does some checks to see whether a ContentType should appear in search results . This is based on ContentType options . |
43,161 | private function sortPattern ( array $ routes ) { uasort ( $ routes , function ( Route $ a , Route $ b ) { if ( $ a -> getPath ( ) === $ b -> getPath ( ) ) { return 0 ; } $ a = str_replace ( '{' , '' , str_replace ( '}' , '' , $ a -> getPath ( ) ) ) ; $ b = str_replace ( '{' , '' , str_replace ( '}' , '' , $ b -> getPa... | Sort routes by their URI pattern . |
43,162 | private function getMethods ( Route $ route ) { $ methods = $ route -> getMethods ( ) ; sort ( $ methods ) ; return implode ( '|' , $ methods ) ? : 'ANY' ; } | Get a route s HTTP methods as a sorted string . |
43,163 | private function dumpSql ( ) { $ this -> app [ 'schema' ] -> check ( ) ; $ context = [ 'alters' => $ this -> app [ 'schema.comparator' ] -> getAlters ( ) , 'creates' => $ this -> app [ 'schema.comparator' ] -> getCreates ( ) , ] ; foreach ( $ context as $ section ) { foreach ( $ section as $ sql ) { $ this -> io -> wri... | Dump the output . |
43,164 | public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ this -> isProfilerRequest ( $ request ) ) { return ; } $ token = $ this -> session -> isStarted ( ) ? $ this -> session -> get ( 'authentication' ) : null ; if ( $ this -> debug && ( $ token instanceof Token ... | Request listener to prevent access to profiler routes when debugging is not enabled or the user is logged off & debugging is not configured to show when logged off . |
43,165 | private function setupAutoloader ( ) { $ this -> io -> title ( 'Updating autoloaders' ) ; $ result = $ this -> app [ 'extend.action' ] [ 'autoload' ] -> execute ( ) ; $ this -> outputResult ( $ result ) ; } | Set up the Composer autoloader . |
43,166 | private function outputResult ( $ result ) { $ this -> io -> writeln ( sprintf ( '<comment>%s</comment>' , $ this -> app [ 'extend.action.io' ] -> getOutput ( ) ) , OutputInterface :: OUTPUT_PLAIN ) ; if ( $ result === 0 ) { $ this -> io -> success ( 'Autoloaders updated' ) ; $ this -> auditLog ( __CLASS__ , 'Autoloade... | Output the relevant result . |
43,167 | public function printFirebug ( $ var , $ msg ) { if ( ! $ this -> allowDebug ( ) ) { return ; } if ( is_string ( $ msg ) ) { $ this -> firebugLogger -> info ( $ msg , ( array ) $ var ) ; } elseif ( is_string ( $ var ) ) { $ this -> firebugLogger -> info ( $ var , ( array ) $ msg ) ; } } | Send debug data to the developers FirePHP instance in - browser . |
43,168 | protected function checkTransaction ( array $ context ) { if ( ! in_array ( $ context [ 'action' ] , $ this -> allowed ) ) { throw new \ UnexpectedValueException ( "Invalid action '{$context['action']}' specified for changelog (must be one of [ " . implode ( ', ' , $ this -> allowed ) . ' ])' ) ; } if ( empty ( $ conte... | Check that the requested log transaction is valid . |
43,169 | protected function getData ( array $ context ) { $ data = [ ] ; switch ( $ context [ 'action' ] ) { case 'UPDATE' : $ diff = $ this -> diff ( $ context [ 'old' ] , $ context [ 'new' ] ) ; foreach ( $ diff as $ item ) { list ( $ k , $ old , $ new ) = $ item ; if ( isset ( $ context [ 'new' ] [ $ k ] ) ) { $ data [ $ k ]... | Get the context data . |
43,170 | protected function getContentObject ( array $ contenttype , array $ values ) { if ( empty ( $ contenttype [ 'class' ] ) ) { return new Content ( $ this -> app , $ contenttype , $ values ) ; } if ( class_exists ( $ contenttype [ 'class' ] ) ) { $ content = new $ contenttype [ 'class' ] ( $ this -> app , $ contenttype , ... | Get the content object . |
43,171 | private function initialize ( ) { $ this -> tablename = sprintf ( '%s%s' , $ this -> app [ 'config' ] -> get ( 'general/database/prefix' , 'bolt_' ) , 'log_change' ) ; $ this -> allowed = [ 'INSERT' , 'UPDATE' , 'DELETE' ] ; $ this -> initialized = true ; } | Initialize class parameters . |
43,172 | public function setGroup ( $ group , $ name , $ taxonomytype , $ sortorder = 0 ) { $ this -> group = [ 'slug' => $ group , 'name' => $ name , ] ; $ hasSortOrder = $ this -> app [ 'config' ] -> get ( 'taxonomy/' . $ taxonomytype . '/has_sortorder' ) ; if ( $ hasSortOrder !== false ) { $ this -> group [ 'order' ] = ( int... | Set the group groupname and sortorder properties of the current object . |
43,173 | public function setTaxonomy ( $ taxonomyType , $ slug , $ name = '' , $ sortorder = 0 ) { if ( is_array ( $ slug ) ) { foreach ( $ slug as $ single ) { $ this -> setTaxonomy ( $ taxonomyType , $ single , '' , $ sortorder ) ; } return true ; } if ( ! isset ( $ this -> contenttype [ 'taxonomy' ] ) || ! in_array ( $ taxon... | Set a taxonomy for the current object . |
43,174 | public function sortTaxonomy ( ) { if ( empty ( $ this -> taxonomy ) ) { return ; } foreach ( array_keys ( $ this -> taxonomy ) as $ type ) { $ taxonomytype = $ this -> app [ 'config' ] -> get ( 'taxonomy/' . $ type ) ; if ( $ taxonomytype [ 'behaves_like' ] == 'tags' ) { continue ; } $ new = [ ] ; foreach ( $ this -> ... | Sort the taxonomy of the current object based on the order given in taxonomy . yml . |
43,175 | public function deleteUserQuery ( $ userId ) { $ qb = $ this -> createQueryBuilder ( ) ; $ qb -> delete ( $ this -> getTableName ( ) ) ; if ( is_numeric ( $ userId ) ) { $ qb -> where ( 'id = :userId' ) ; } else { $ qb -> where ( 'username = :userId' ) -> orWhere ( 'email = :userId' ) ; } $ qb -> setParameter ( 'userId... | Get the user deletion query . |
43,176 | public function getUser ( $ userId ) { if ( isset ( $ this -> userEntities [ $ userId ] ) ) { return $ this -> userEntities [ $ userId ] ; } $ query = $ this -> getUserQuery ( $ userId ) ; if ( $ userEntity = $ this -> findOneWith ( $ query ) ) { $ this -> unsetSensitiveFields ( $ userEntity ) ; } $ this -> userEntitie... | Get a user . |
43,177 | public function getUsers ( ) { $ userEntities = $ this -> findAll ( ) ; if ( $ userEntities ) { foreach ( $ userEntities as $ userEntity ) { $ this -> unsetSensitiveFields ( $ userEntity ) ; } } return $ userEntities ; } | Get all the system users . |
43,178 | protected function unsetSensitiveFields ( Entity \ Users $ entity ) { $ entity -> setPassword ( null ) ; $ entity -> setShadowpassword ( null ) ; $ entity -> setShadowtoken ( null ) ; $ entity -> setShadowvalidity ( null ) ; } | Null sensitive data that doesn t need to be passed around . |
43,179 | public function getContentForTwig ( $ textQuery , array $ parameters = [ ] ) { if ( func_num_args ( ) === 3 ) { $ whereparameters = func_get_arg ( 2 ) ; if ( is_array ( $ whereparameters ) && ! empty ( $ whereparameters ) ) { $ parameters = array_merge ( $ parameters , $ whereparameters ) ; } } return $ this -> records... | Helper to be called from Twig that is passed via a TwigRecordsView rather than the raw records . |
43,180 | public function resolve ( MenuEntry $ menu , Entity \ Users $ user ) { foreach ( $ menu -> children ( ) as $ name => $ child ) { $ this -> doResolve ( $ menu , $ child , $ user ) ; if ( $ child -> children ( ) === [ ] && $ child -> getUri ( ) === null ) { $ menu -> remove ( $ name ) ; } } } | Resolve the access permissions on each menu child recursively and remove the child if access is not granted . Should a parent have no remaining children & isn t routed it should then be removed . |
43,181 | public function init ( $ file , array $ data = null ) { if ( $ data === null ) { $ data = $ this -> setJsonDefaults ( [ ] ) ; } $ this -> app [ 'filesystem' ] -> write ( $ file , Json :: dump ( $ data , Json :: HUMAN ) ) ; } | Initialise a JSON file at given location with optional data input . |
43,182 | public function update ( ) { $ jsonFile = $ this -> app [ 'filesystem' ] -> get ( 'extensions://composer.json' , new JsonFile ( ) ) ; if ( ! $ jsonFile -> exists ( ) ) { try { $ this -> init ( 'extensions://composer.json' ) ; } catch ( IOException $ e ) { $ this -> messages [ ] = Trans :: __ ( 'page.extend.error-compos... | Set up Composer JSON file . |
43,183 | private function setJsonDefaults ( array $ json ) { $ config = $ this -> app [ 'config' ] ; $ pathResolver = $ this -> app [ 'path_resolver' ] ; $ rootPath = $ pathResolver -> resolve ( 'root' ) ; $ extensionsPath = $ pathResolver -> resolve ( 'extensions' ) ; $ webPath = $ pathResolver -> resolve ( 'web' ) ; $ pathToR... | Enforce the default JSON settings . |
43,184 | public function overwrite ( ) { if ( ! $ this -> previouslyRendered ) { $ this -> previouslyRendered = true ; } else { $ this -> output -> remove ( ) ; } $ this -> output -> capture ( ) ; $ this -> render ( ) ; } | Remove previously rendered table then render again with new data . |
43,185 | public function weight ( ) { $ scores = [ ] ; foreach ( $ this -> results as $ result ) { $ scores [ ] = $ this -> getResultScore ( $ result ) ; } return $ scores ; } | This is the public method that gets a score for a the set of results . |
43,186 | protected function buildResultIndex ( $ result ) { $ corpus = [ ] ; foreach ( $ this -> getContentFields ( ) as $ field => $ weightings ) { $ textualContent = $ result -> { $ field } ; if ( is_array ( $ textualContent ) ) { $ textualContent = implode ( ' ' , $ textualContent ) ; } $ textualContent = strip_tags ( $ text... | This is a simple version of the Vector Space Model . |
43,187 | protected function getResultScore ( $ result ) { $ output = [ ] ; $ corpus = $ this -> buildResultIndex ( $ result ) ; $ count = count ( $ corpus [ 'count' ] ) ; foreach ( $ this -> searchWords as $ word ) { $ word = mb_strtolower ( $ word ) ; if ( isset ( $ corpus [ 'dictionary' ] [ $ word ] ) ) { $ entry = $ corpus [... | This method uses the index built in the method above to do some quick score calculations for each word of the query versus each word of the index dictionary . |
43,188 | public function checkVersion ( ) { if ( $ this -> checkCacheVersion ( ) ) { return ; } $ this -> syncAssets ( ) ; $ this -> cache -> flushAll ( ) ; $ this -> updateAutoloader ( ) ; $ this -> updateCacheVersion ( ) ; } | Check Bolt s version against a cached key . If there is a change we flush the cache data and if required synchronise asset directories . |
43,189 | protected function checkCacheVersion ( ) { $ fileName = $ this -> getVersionFileName ( ) ; if ( ! file_exists ( $ fileName ) ) { return false ; } $ version = md5 ( $ this -> boltVersion ) ; $ cached = file_get_contents ( $ fileName ) ; if ( $ version === $ cached ) { return true ; } $ this -> versionChange = true ; ret... | Check if the cache version matches Bolt s current version . |
43,190 | protected function updateAutoloader ( ) { $ cwd = getcwd ( ) ; try { $ autoload = $ this -> actions [ 'autoload' ] ; $ autoload -> execute ( ) ; } catch ( PackageManagerException $ e ) { } chdir ( $ cwd ) ; } | Update the extension autoloader . |
43,191 | public function collect ( Request $ request , Response $ response , \ Exception $ exception = null ) { $ this -> data = [ 'version' => Bolt \ Version :: VERSION , 'payoff' => 'Sophisticated, lightweight & simple CMS' , 'dashboardlink' => sprintf ( '<a href="%s">%s</a>' , $ this -> app [ 'url_generator' ] -> generate ( ... | Collect the date for the Toolbar item . |
43,192 | public function getOriginal ( $ entity ) { foreach ( $ this as $ k => $ existing ) { if ( $ existing -> getContentId ( ) === $ entity -> getContentId ( ) && $ existing -> getTaxonomytype ( ) === $ entity -> getTaxonomytype ( ) && $ existing -> getSlug ( ) === $ entity -> getSlug ( ) ) { return $ existing ; } } return $... | This loops over the existing collection to see if the properties in the incoming are already available on a saved record . To do this it checks the three key properties content_id taxonomytype and slug if there s a match it returns the original otherwise it returns the new and adds the new one to the collection . |
43,193 | protected function showCreates ( ) { $ creates = $ this -> app [ 'schema.comparator' ] -> getCreates ( ) ; if ( $ creates ) { $ this -> io -> section ( 'Tables to be created' ) ; foreach ( $ creates as $ tableName => $ sql ) { $ this -> io -> writeln ( \ SqlFormatter :: format ( $ sql [ 0 ] ) ) ; } } } | Display a section of tables to be created . |
43,194 | protected function showAlterations ( ) { $ alters = $ this -> app [ 'schema.comparator' ] -> getAlters ( ) ; if ( $ alters ) { $ this -> io -> section ( 'Tables to be altered:' ) ; $ tableCount = count ( $ alters ) ; foreach ( $ alters as $ tableName => $ sql ) { $ this -> io -> comment ( $ tableName ) ; foreach ( $ sq... | Display a section of tables to be altered . |
43,195 | public function onException ( GetResponseForExceptionEvent $ event ) { if ( $ event -> isMasterRequest ( ) ) { return ; } $ exception = $ event -> getException ( ) ; $ level = LogLevel :: CRITICAL ; if ( $ exception instanceof HttpExceptionInterface && $ exception -> getStatusCode ( ) < 500 ) { $ level = LogLevel :: WA... | Log exceptions thrown in the application . |
43,196 | public function localeDateTime ( $ dateTime , $ format = '%B %e, %Y %H:%M' , $ locale = 0 ) { if ( ! $ dateTime instanceof \ DateTime ) { $ dateTime = new \ DateTime ( $ dateTime ) ; } $ os = strtoupper ( substr ( PHP_OS , 0 , 3 ) ) ; $ format = $ os !== 'WIN' ? $ format : preg_replace ( '#(?<!%)((?:%%)*)%e#' , '\1%#d'... | Returns the date time in a particular format . Takes the locale into account . |
43,197 | public function pregReplace ( $ str , $ pattern , $ replacement = '' , $ limit = - 1 ) { return preg_replace ( $ pattern , $ replacement , $ str , $ limit ) ; } | Perform a regular expression search and replace on the given string . |
43,198 | public function safeString ( $ str , $ strict = false , $ extrachars = '' ) { return Str :: makeSafe ( $ str , $ strict , $ extrachars ) ; } | Return a safe string version of a given string . |
43,199 | public function slug ( $ str ) { if ( is_array ( $ str ) ) { $ str = implode ( ' ' , $ str ) ; } return $ this -> slugify -> slugify ( $ str ) ; } | Return the sluggified version of a string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.