idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
43,000 | protected function getTaxonomy ( $ content ) { $ tablename = $ this -> getTablename ( "taxonomy" ) ; $ ids = Arr :: column ( $ content , 'id' ) ; if ( empty ( $ ids ) ) { return ; } $ first = reset ( $ content ) ; $ config = $ first -> contenttype ; $ contenttype = ( isset ( $ config [ 'key' ] ) ) ? $ config [ 'key' ] ... | Get the taxonomy for one or more units of content return the array with the taxonomy attached . |
43,001 | protected function getRelation ( $ content ) { $ tablename = $ this -> getTablename ( "relations" ) ; $ ids = Arr :: column ( $ content , 'id' ) ; if ( empty ( $ ids ) ) { return ; } $ first = reset ( $ content ) ; $ contenttype = isset ( $ first -> contenttype [ 'key' ] ) ? $ first -> contenttype [ 'key' ] : $ first -... | Get the relations for one or more units of content return the array with the taxonomy attached . |
43,002 | public function getContenttypeTablename ( $ contenttype ) { if ( is_string ( $ contenttype ) ) { $ contenttype = $ this -> getContentType ( $ contenttype ) ; } return $ this -> getTablename ( $ contenttype [ 'tablename' ] ) ; } | Get the tablename with prefix from a given Contenttype . |
43,003 | public function setPager ( $ name , $ pager ) { $ pg = $ this -> app [ 'pager' ] -> createPager ( $ name ) ; foreach ( $ pager as $ prop => $ value ) { $ pg -> $ prop = $ value ; } return $ this ; } | Setter for pager storage element . |
43,004 | protected function getRoleAccessCallback ( ) { return function ( $ key , $ val , $ index ) { if ( ! $ this -> session -> isStarted ( ) ) { return [ 'disabled' => 'disabled' ] ; } $ sessionAuth = $ this -> session -> get ( 'authentication' ) ; $ currentUser = $ sessionAuth -> getUser ( ) ; $ allowedRoles = $ this -> per... | Callback to disable role choices that a user doesn t have access to manipulate . |
43,005 | public function run ( ) { if ( ! $ this -> io -> isInteractive ( ) ) { return ; } $ cwd = getcwd ( ) ; $ info = <<<OUTAll paths are currently relative to the current working directory (`$cwd`)Paths can have aliases to other paths. These are specified with a word surrounded by percents.For example, if we defined `user`... | Run the customizer . |
43,006 | private function renderPaths ( ) { if ( ! $ this -> pathsTable ) { $ this -> pathsTable = new Table ( $ this -> io ) ; $ style = clone Table :: getStyleDefinition ( 'symfony-style-guide' ) ; $ this -> pathsTable -> setStyle ( $ style ) ; $ this -> pathsTable -> setHeaders ( [ '#' , 'Name' , 'Path' ] ) ; $ style = clone... | Render paths table . |
43,007 | private function askPathToModify ( ) { $ names = $ this -> resolver -> names ( ) ; $ count = count ( $ names ) ; $ question = new Question ( 'Enter # or name to modify or empty to continue' ) ; $ question -> setValidator ( function ( $ value ) use ( $ names , $ count ) { if ( $ value === null ) { return $ value ; } if ... | Ask which path to modify . |
43,008 | private function askAndSetNewPathValue ( $ name ) { $ previous = $ this -> resolver -> raw ( $ name ) ; $ question = new Question ( 'Enter new value for ' . $ name , $ previous ) ; $ question -> setValidator ( function ( $ value ) use ( $ name , $ previous ) { $ this -> resolver -> define ( $ name , $ value ) ; try { $... | Ask for the new value for the given path name and set it . |
43,009 | public function setupContenttype ( Entity \ Entity $ entity ) { $ contentType = $ entity -> getContenttype ( ) ; if ( is_string ( $ contentType ) ) { $ contentTypeData = $ this -> app [ 'storage' ] -> getContenttype ( $ contentType ) ; if ( $ contentTypeData instanceof ContentType ) { $ contentTypeObject = $ contentTyp... | Set the legacy ContentType object on the Entity . |
43,010 | public function getChangedFields ( array $ contentType ) { $ changedFields = [ ] ; if ( empty ( $ this -> diff ) ) { return $ changedFields ; } $ fields = $ contentType [ 'fields' ] ; $ hash = [ 'html' => 'fieldText' , 'markdown' => 'fieldText' , 'textarea' => 'fieldText' , 'filelist' => 'fieldList' , 'imagelist' => 'f... | Get changed fields . |
43,011 | private function fieldList ( $ key , $ value , array $ fields ) { return [ 'type' => $ fields [ $ key ] [ 'type' ] , 'before' => [ 'render' => Json :: parse ( $ value [ 0 ] ) ] , 'after' => [ 'render' => Json :: parse ( $ value [ 1 ] ) ] , ] ; } | Compile changes for list field types . |
43,012 | private function fieldGeolocation ( $ key , $ value , array $ fields ) { $ before = Json :: parse ( $ value [ 0 ] ) ; $ after = Json :: parse ( $ value [ 1 ] ) ; return [ 'type' => $ fields [ $ key ] [ 'type' ] , 'before' => [ 'render' => [ 'address' => $ before [ 'address' ] , 'latitude' => $ before [ 'latitude' ] , '... | Compile changes for geolocation field types . |
43,013 | private function fieldImage ( $ key , $ value , array $ fields ) { $ before = Json :: parse ( $ value [ 0 ] ) ; $ after = Json :: parse ( $ value [ 1 ] ) ; return [ 'type' => $ fields [ $ key ] [ 'type' ] , 'before' => [ 'render' => [ 'file' => $ before [ 'file' ] , 'title' => $ before [ 'title' ] , ] , ] , 'after' => ... | Compile changes for image field types . |
43,014 | private function fieldOembed ( $ key , $ value , array $ fields ) { $ before = Json :: parse ( $ value [ 0 ] ) ; $ after = Json :: parse ( $ value [ 1 ] ) ; return [ 'type' => $ fields [ $ key ] [ 'type' ] , 'before' => [ 'render' => [ 'url' => $ before [ 'url' ] , 'type' => $ before [ 'type' ] , 'author_name' => $ bef... | Compile changes for embed field types . |
43,015 | private function fieldSelect ( $ key , $ value , array $ fields ) { if ( isset ( $ fields [ $ key ] [ 'multiple' ] ) && $ fields [ $ key ] [ 'multiple' ] ) { $ before = $ value [ 0 ] ; $ after = $ value [ 1 ] ; } else { $ before = $ value [ 0 ] ; $ after = $ value [ 1 ] ; } return [ 'type' => $ fields [ $ key ] [ 'type... | Compile changes for select field types . |
43,016 | private function fieldVideo ( $ key , $ value , array $ fields ) { $ before = Json :: parse ( $ value [ 0 ] ) ; $ after = Json :: parse ( $ value [ 1 ] ) ; return [ 'type' => $ fields [ $ key ] [ 'type' ] , 'before' => [ 'render' => [ 'url' => $ before [ 'url' ] , 'title' => $ before [ 'title' ] , 'width' => $ before [... | Compile changes for video field types . |
43,017 | private function importContentType ( $ contentTypeName , Bag $ importData , MutableBag $ relationQueue , MutableBag $ responseBag , $ overwrite ) { $ count = 0 ; $ repo = $ this -> em -> getRepository ( $ contentTypeName ) ; $ relationFields = MutableBag :: from ( [ ] ) ; $ taxonomyFields = MutableBag :: from ( [ ] ) ;... | Perform an import for records under a single ContentType key . |
43,018 | private function addRelations ( Repository $ repo , MutableBag $ relationQueue , Bag $ importDatum , MutableBag $ relationFields ) { $ classMeta = $ repo -> getClassMetadata ( ) ; foreach ( $ relationFields as $ fieldName ) { $ relationName = $ classMeta -> getBoltName ( ) . '/' . $ importDatum -> get ( 'slug' ) ; $ ex... | Queue an entities relations for later processing . |
43,019 | private function processRelationQueue ( Bag $ relationQueue ) { foreach ( $ relationQueue as $ source => $ links ) { $ entity = $ this -> query -> getContent ( $ source ) ; $ relations = [ ] ; foreach ( $ links as $ linkKey ) { $ relation = $ this -> query -> getContent ( $ linkKey ) ; $ relatedKey = ( string ) $ relat... | Since relations can t be processed until we are sure all the individual records are saved this goes through the queue after an import and links up all the related ones . |
43,020 | private function validateContentTypes ( Bag $ importData ) { $ contentTypeNames = $ this -> contentTypes -> keys ( ) -> toArray ( ) ; $ importData -> filter ( function ( $ k , $ v ) use ( $ contentTypeNames ) { if ( ! in_array ( $ k , $ contentTypeNames ) ) { throw new RuntimeException ( sprintf ( 'ContentType "%s" is ... | Check that the import file s ContentTypes exists . |
43,021 | private function compareOptions ( $ a , $ b ) { $ comparison = $ b [ 'priority' ] - $ a [ 'priority' ] ; if ( $ comparison == 0 ) { return strcasecmp ( $ a [ 'path' ] , $ b [ 'path' ] ) ; } return $ comparison ; } | OmnisearchOption implements Comparable . |
43,022 | protected function addEntity ( $ type , $ id , Entity \ Content $ owner ) { $ newEntity = new Entity \ Relations ( [ 'from_contenttype' => ( string ) $ owner -> getContenttype ( ) , 'from_id' => $ owner -> getId ( ) , 'to_contenttype' => $ type , 'to_id' => $ id , ] ) ; $ this -> add ( $ newEntity ) ; } | Adds a related entity by type id and owner |
43,023 | public function associate ( $ type , array $ items = null ) { if ( $ this -> getOwner ( ) === null ) { throw new DomainException ( 'Unable to associate relations to a collection that does not have an owning entity!' ) ; } if ( $ type instanceof Entity \ Content ) { $ this -> addEntity ( ( string ) $ type -> getContentt... | Associate related items by type and identifiers |
43,024 | public function getGrouped ( ) { $ types = [ ] ; $ elements = $ this -> toArray ( ) ; foreach ( $ elements as $ element ) { $ type = $ element -> get ( 'to_contenttype' ) ; $ types [ $ type ] [ ] = $ element ; } return $ types ; } | Get the related types that are in the collection grouped by ContentType key . |
43,025 | public function getOriginal ( Entity \ Relations $ entity ) { foreach ( $ this as $ k => $ existing ) { if ( $ existing -> getFromId ( ) == $ entity -> getFromId ( ) && $ existing -> getFromContenttype ( ) === $ entity -> getFromContenttype ( ) && $ existing -> getToContenttype ( ) === $ entity -> getToContenttype ( ) ... | 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 four key properties if there s a match it returns the original otherwise it returns the new and adds the new one to the collection . |
43,026 | public function getField ( $ fieldName , $ biDirectional = false , $ contentTypeName = null , $ contentTypeId = null ) { if ( $ biDirectional ) { $ filter = function ( $ el ) use ( $ fieldName , $ contentTypeName , $ contentTypeId ) { if ( $ el -> getFromContenttype ( ) === $ fieldName && $ el -> getFromContenttype ( )... | Gets a specific relation type name from the overall collection . |
43,027 | public function incoming ( Entity \ Content $ entity ) { return $ this -> filter ( function ( $ el ) use ( $ entity ) { return $ el -> getToContenttype ( ) == ( string ) $ entity -> getContenttype ( ) && $ el -> getToId ( ) === $ entity -> getId ( ) ; } ) ; } | Identifies which relations are incoming to the given entity . |
43,028 | public function dumpBacktrace ( Environment $ env , $ context , $ depth ) { if ( ! $ this -> isEnabled ( $ env ) ) { return null ; } return $ this -> dump ( $ env , $ context , debug_backtrace ( DEBUG_BACKTRACE_PROVIDE_OBJECT , $ depth ) ) ; } | Output pretty - printed backtrace . |
43,029 | protected function normalizeData ( $ data , $ field , $ separator = ',' ) { $ normalized = [ ] ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , '_' ) === 0 && strpos ( $ key , $ field ) === 1 ) { $ path = explode ( '_' , str_replace ( '_' . $ field , '' , $ key ) ) ; $ normalized [ $ path [ 1 ] ] = $ va... | This method takes the flat underscore separated key - > value data that comes from the query result and turns it into a properly structured array . The second part of the method also removes duplicate values in the case where an aggregate query returns more than one copy of the row . |
43,030 | protected function rewriteQueryFilterParameters ( Filter $ filter , QueryInterface $ query , $ field , $ column ) { $ originalExpression = $ filter -> getExpressionObject ( ) ; $ reflected = new ReflectionProperty ( CompositeExpression :: class , 'parts' ) ; $ reflected -> setAccessible ( true ) ; $ reflected2 = new Re... | This method does an in - place modification of a generic contenttype . field query to the format actually used in the raw sql category . For instance a simple query might say entries . tags = movies but now we are in the context of entries the actual SQL fragment needs to be tags . slug = movies . We don t know this un... |
43,031 | public function edit ( Request $ request , $ namespace , $ file ) { $ file = $ this -> filesystem ( ) -> getFile ( "$namespace://$file" ) ; if ( ! $ file -> authorized ( ) ) { $ this -> flashes ( ) -> error ( Trans :: __ ( 'general.phrase.access-denied-permissions-edit-file' , [ '%s' => $ file -> getPath ( ) ] ) ) ; re... | File editor . |
43,032 | public function manage ( Request $ request , $ namespace , $ path ) { $ fullPath = "$namespace://$path" ; $ directory = $ this -> filesystem ( ) -> getDir ( $ fullPath ) ; $ listing = new Listing ( $ directory ) ; $ showHidden = $ this -> isAllowed ( 'files:hidden' ) ; if ( ! $ listing -> isAuthorized ( ) ) { $ this ->... | The file management browser . |
43,033 | private function handleEdit ( FormInterface $ form , FileInterface $ file ) { $ data = $ form -> getData ( ) ; $ contents = Input :: cleanPostedData ( $ data [ 'contents' ] ) . "\n" ; $ contents = str_ireplace ( "\x0D" , '' , $ contents ) ; if ( $ file -> getType ( ) === 'yaml' ) { $ yamlparser = new Parser ( ) ; try {... | Handle a file edit POST . |
43,034 | private function handleUpload ( FormInterface $ form , DirectoryInterface $ directory ) { $ files = $ form -> get ( 'select' ) -> getData ( ) ; $ permissions = $ this -> app [ 'filepermissions' ] ; foreach ( $ files as $ fileToProcess ) { $ fileToProcess = [ 'name' => $ fileToProcess -> getClientOriginalName ( ) , 'tmp... | Handle the upload POST . |
43,035 | private function processUpload ( DirectoryInterface $ directory , $ filename , array $ fileToProcess ) { $ this -> app [ 'upload.namespace' ] = $ directory -> getMountPoint ( ) ; $ handler = $ this -> app [ 'upload' ] ; $ handler -> setPrefix ( $ directory -> getPath ( ) . '/' ) ; try { $ result = $ handler -> process ... | Process an individual file upload . |
43,036 | public function before ( Request $ request ) { $ this -> app [ 'stopwatch' ] -> start ( 'bolt.async.before' ) ; $ authCookie = $ request -> cookies -> get ( $ this -> app [ 'token.authentication.name' ] ) ; if ( $ authCookie === null || ! $ this -> accessControl ( ) -> isValidSession ( $ authCookie ) ) { $ this -> abor... | Middleware function to do some tasks that should be done for all asynchronous requests . |
43,037 | public function isValidSession ( $ authCookie ) { if ( $ authCookie === null ) { throw new AccessControlException ( 'Can not validate session with an empty token.' ) ; } if ( $ this -> validSession !== null ) { return $ this -> validSession ; } $ check = false ; $ sessionAuth = null ; if ( $ this -> session -> isStarte... | We will not allow tampering with sessions so we make sure the current session is still valid for the device on which it was created and that the username and IP address are still the same . |
43,038 | public function revokeSession ( ) { try { if ( $ this -> getRepositoryUsers ( ) -> count ( ) > 0 ) { $ this -> flashLogger -> info ( Trans :: __ ( 'general.phrase.access-denied-logged-out' ) ) ; } } catch ( TableNotFoundException $ e ) { } if ( $ sessionAuth = $ this -> session -> get ( 'authentication' ) ) { try { $ t... | Log out the currently logged in user . |
43,039 | protected function checkSessionDatabase ( $ authCookie ) { $ userIp = $ this -> cookieOptions [ 'remoteaddr' ] ? $ this -> getClientIp ( ) : null ; $ userAgent = $ this -> cookieOptions [ 'browseragent' ] ? $ this -> getClientUserAgent ( ) : null ; try { if ( ! $ authTokenEntity = $ this -> getRepositoryAuthtoken ( ) -... | Check the user authentication cookie against what is stored in the database . |
43,040 | public function getActiveSessions ( ) { $ parser = UAParser \ Parser :: create ( ) ; $ this -> getRepositoryAuthtoken ( ) -> deleteExpiredTokens ( ) ; $ sessions = $ this -> getRepositoryAuthtoken ( ) -> getActiveSessions ( ) ? : [ ] ; foreach ( $ sessions as & $ session ) { $ ua = $ parser -> parse ( $ session -> getU... | Lookup active sessions . |
43,041 | protected function getClientHost ( ) { if ( $ this -> requestStack -> getCurrentRequest ( ) === null ) { throw new \ RuntimeException ( sprintf ( '%s can not be called outside of request cycle' , __METHOD__ ) ) ; } return $ this -> requestStack -> getCurrentRequest ( ) -> getHost ( ) ; } | Return the user s host name . |
43,042 | protected function getClientIp ( ) { if ( $ this -> requestStack -> getCurrentRequest ( ) === null ) { throw new \ RuntimeException ( sprintf ( '%s can not be called outside of request cycle' , __METHOD__ ) ) ; } return $ this -> requestStack -> getCurrentRequest ( ) -> getClientIp ( ) ? : '127.0.0.1' ; } | Return the user s IP address . |
43,043 | protected function getClientUserAgent ( ) { if ( $ this -> requestStack -> getCurrentRequest ( ) === null ) { throw new \ RuntimeException ( sprintf ( '%s can not be called outside of request cycle' , __METHOD__ ) ) ; } return $ this -> requestStack -> getCurrentRequest ( ) -> server -> get ( 'HTTP_USER_AGENT' ) ; } | Return the user s browser User Agent . |
43,044 | public function addAllowedMethod ( $ class , $ method ) { if ( ! isset ( $ this -> allowedMethods [ $ class ] ) ) { $ this -> allowedMethods [ $ class ] = [ ] ; } $ this -> allowedMethods [ $ class ] [ ] = strtolower ( $ method ) ; } | Add class method allowed by this policy . |
43,045 | public function addAllowedProperty ( $ class , $ property ) { if ( ! isset ( $ this -> allowedProperties [ $ class ] ) ) { $ this -> allowedProperties [ $ class ] = [ ] ; } $ this -> allowedProperties [ $ class ] [ ] = $ property ; } | Add class property allowed by this policy . |
43,046 | public function generate ( $ count ) { if ( ! is_int ( $ count ) || $ count < 1 ) { throw new \ InvalidArgumentException ( sprintf ( '%s requires a value greater than 1.' , __METHOD__ ) ) ; } $ ownerIds = $ this -> getValidOwnerIds ( ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ entity = $ this -> repository -> crea... | Generate n number of dummy records . |
43,047 | private function fillEntity ( Entity \ Content $ contentEntity ) { $ contentType = $ this -> repository -> getEntityManager ( ) -> getContentType ( $ contentEntity -> getContenttype ( ) ) ; foreach ( $ contentType [ 'fields' ] as $ field => $ values ) { $ this -> setFieldValue ( $ contentEntity , $ contentType , $ fiel... | Create a single ContentType entity . |
43,048 | private function setTaxonomyCollection ( Entity \ Content $ contentEntity , $ contentType ) { if ( empty ( $ contentType [ 'taxonomy' ] ) ) { return ; } $ taxonomies = $ this -> repository -> getEntityManager ( ) -> createCollection ( Entity \ Taxonomy :: class ) ; foreach ( $ contentType [ 'taxonomy' ] as $ key => $ t... | Add some random taxonomy entries on the record . |
43,049 | private function getTaxonomyEntity ( Entity \ Content $ contentEntity , $ taxonomy ) { return new Entity \ Taxonomy ( [ 'content_id' => $ contentEntity -> getId ( ) , 'contenttype' => ( string ) $ contentEntity -> getContentType ( ) , 'taxonomytype' => $ taxonomy , ] ) ; } | Get a base taxonomy entity object . |
43,050 | private function getValidOwnerIds ( ) { $ userRepo = $ this -> repository -> getEntityManager ( ) -> getRepository ( Entity \ Users :: class ) ; $ query = $ userRepo -> createQueryBuilder ( ) -> select ( 'id' ) -> where ( 'enabled = :enabled' ) -> setParameter ( 'enabled' , true ) ; $ userRecords = $ query -> execute (... | Return an array of enabled system IDs . |
43,051 | private function getImageFiles ( ) { if ( $ this -> imageFiles === null ) { $ this -> imageFiles = $ this -> filesystem -> find ( ) -> in ( 'files://' ) -> name ( '/\.jpe?g$/' ) -> name ( '*.png' ) -> toArray ( ) ; } return $ this -> imageFiles ; } | Return an array of file names in the files filesystem . |
43,052 | private function getReservedTitle ( $ contentTypeName ) { $ defaultTitles = $ this -> defaultTitles -> get ( $ contentTypeName ) ; $ title = array_shift ( $ defaultTitles ) ; $ existing = $ this -> repository -> findOneBy ( [ 'title' => $ title ] ) ; if ( $ existing || $ title === null ) { $ title = trim ( strip_tags (... | Get the title for a Block ContentType . Check if the desired ones aren t present in the database yet and return them in order . |
43,053 | private function getRandomTags ( $ count = 5 ) { $ tags = [ 'action' , 'adult' , 'adventure' , 'alpha' , 'animals' , 'animation' , 'anime' , 'architecture' , 'art' , 'astronomy' , 'baby' , 'batshitinsane' , 'biography' , 'biology' , 'book' , 'books' , 'business' , 'business' , 'camera' , 'cars' , 'cats' , 'cinema' , 'c... | Get an array of random tags |
43,054 | private function getRandomImage ( $ type , $ placeholder ) { $ pathKey = $ type === 'image' ? 'file' : 'filename' ; if ( $ placeholder && ( $ filename = $ this -> fetchPlaceholder ( $ placeholder ) ) ) { return [ $ pathKey => $ filename , 'title' => 'placeholder' , 'alt' => 'placeholder' ] ; } $ images = $ this -> getI... | Get a random image . |
43,055 | private function fetchPlaceholder ( $ placeholder ) { try { $ image = $ this -> imageClient -> get ( $ placeholder ) ; } catch ( RequestException $ e ) { return false ; } $ filename = sprintf ( 'placeholder_%s.jpg' , substr ( md5 ( microtime ( ) ) , 0 , 12 ) ) ; try { $ this -> filesystem -> put ( 'files://' . $ filena... | Attempt to fetch a placeholder image from a remote URL . |
43,056 | public function execute ( $ param = [ ] ) { $ this -> param = $ param ; $ this -> runtime = new \ DateTime ( ) ; $ this -> getRunTimes ( ) ; $ this -> getScheduleThreshold ( ) ; $ event = new CronEvent ( $ this -> app , $ this -> output ) ; foreach ( $ this -> jobs as $ name => $ data ) { $ this -> executeSingle ( $ ev... | Run the jobs . |
43,057 | private function executeSingle ( CronEvent $ event , $ interimName , array $ data ) { if ( $ this -> isExecutable ( $ interimName ) ) { $ this -> notify ( $ data [ 'message' ] ) ; $ cronEntity = $ this -> jobs [ $ interimName ] [ 'entity' ] ; try { $ this -> app [ 'dispatcher' ] -> dispatch ( $ interimName , $ event ) ... | Run a single cron dispatcher . |
43,058 | private function isExecutable ( $ interimName ) { if ( $ this -> param [ 'run' ] && $ this -> param [ 'event' ] === $ interimName ) { return true ; } elseif ( ! $ this -> app [ 'dispatcher' ] -> hasListeners ( $ interimName ) ) { return false ; } $ nextRun = $ this -> jobs [ $ interimName ] [ 'nextRunTime' ] ; if ( $ i... | Test whether or not to call dispatcher . |
43,059 | private function getScheduleThreshold ( ) { $ hour = $ this -> app [ 'config' ] -> get ( 'general/cron_hour' , '03:00' ) ; if ( is_numeric ( $ hour ) ) { $ hour .= ':00' ; } $ this -> cronHour = new \ DateTime ( $ hour ) ; } | Get our configured hour and convert it to UNIX time . |
43,060 | private function getRunTimes ( ) { foreach ( array_keys ( $ this -> jobs ) as $ interimName ) { if ( ! $ runEntity = $ this -> repository -> getNextRunTime ( $ interimName ) ) { $ epoch = new \ DateTime ( ) ; $ epoch -> setTimestamp ( 0 ) ; $ runEntity = new Entity \ Cron ( [ 'interim' => $ interimName , 'lastrun' => $... | Query table for last run time of each interim . |
43,061 | private function getNextRunTime ( $ interimName , Entity \ Cron $ runEntity ) { $ interval = new \ DateInterval ( $ this -> jobs [ $ interimName ] [ 'increment' ] ) ; $ nextRunTime = clone $ runEntity -> getLastrun ( ) ; $ nextRunTime -> add ( $ interval ) ; return $ nextRunTime ; } | Get the next run time for a given interim . |
43,062 | private function notify ( $ message ) { if ( $ this -> output !== null ) { $ this -> output -> writeln ( "<info>{$message}</info>" ) ; } $ this -> app [ 'logger.system' ] -> info ( $ message , [ 'event' => 'cron' ] ) ; } | If we re passed an OutputInterface we re called from Nut and can notify the end user . |
43,063 | private function handleError ( \ Exception $ e , $ interimName ) { $ this -> output -> writeln ( '<error>A ' . $ interimName . ' job failed. The exception returned was:</error>' ) ; $ this -> output -> writeln ( '<error> ' . $ e -> getMessage ( ) . '</error>' ) ; $ this -> output -> writeln ( '<error>Backtrace:</err... | Provide feedback on exceptions in cron jobs . |
43,064 | public function action ( $ contentTypeName , array $ changeRequest ) { foreach ( $ changeRequest as $ recordId => $ actionData ) { if ( $ actionData === null ) { continue ; } $ repo = $ this -> em -> getRepository ( $ contentTypeName ) ; foreach ( $ actionData as $ action => $ fieldData ) { if ( ! $ entity = $ repo -> ... | Modify an individual ContentType s records . |
43,065 | protected function deleteRecord ( Repository $ repo , Content $ entity ) { $ recordId = $ entity -> getId ( ) ; $ contentType = $ entity -> getContenttype ( ) ; $ contentTypeName = ( string ) $ contentType ; if ( ! $ this -> users -> isAllowed ( "contenttype:$contentTypeName:delete:$recordId" ) ) { $ this -> loggerFlas... | Execute the deletion of a record . |
43,066 | protected function modifyRecordValue ( Content $ entity , $ field , $ value ) { $ recordId = $ entity -> getId ( ) ; $ contentTypeName = ( string ) $ entity -> getContenttype ( ) ; $ canModify = $ this -> users -> isAllowed ( "contenttype:$contentTypeName:edit:$recordId" ) ; if ( ! $ canModify ) { $ this -> loggerFlash... | Modify a record s value if permitted . |
43,067 | protected function transistionRecordStatus ( Content $ entity , $ newStatus ) { $ contentTypeName = ( string ) $ entity -> getContenttype ( ) ; $ canTransition = $ this -> users -> isContentStatusTransitionAllowed ( $ entity -> getStatus ( ) , $ newStatus , $ contentTypeName , $ entity -> getId ( ) ) ; if ( ! $ canTran... | Transition a record s status if permitted . |
43,068 | protected function transistionRecordOwner ( Content $ entity , $ ownerId ) { $ recordId = $ entity -> getId ( ) ; $ contentTypeName = ( string ) $ entity -> getContenttype ( ) ; $ canChangeOwner = $ this -> users -> isAllowed ( "contenttype:$contentTypeName:change-ownership:$recordId" ) ; if ( ! $ canChangeOwner ) { $ ... | Transition a record s owner if permitted . |
43,069 | public function buildTable ( Schema $ schema , $ aliasName , $ charset , $ collate ) { $ tableName = $ this -> tablePrefix . $ aliasName ; $ this -> table = $ schema -> createTable ( $ tableName ) ; $ this -> table -> addOption ( 'alias' , $ aliasName ) ; $ this -> table -> addOption ( 'charset' , $ charset ) ; $ this ... | Get the table s schema object . |
43,070 | public function execute ( array $ packages = [ ] , array $ options = [ ] ) { foreach ( $ options as $ key => $ value ) { $ this -> getOptions ( ) -> set ( $ key , $ value ) ; } $ composer = $ this -> getComposer ( ) ; $ io = $ this -> getIO ( ) ; $ install = Installer :: create ( $ io , $ composer ) ; try { $ install -... | Update packages . |
43,071 | protected function getWyswigAllowedTags ( ) { $ allowedBecauseWysiwyg = [ 'div' , 'p' , 'br' , 'pre' , 'a' , 'h1' , 'h2' , 'h3' , 'h4' , 'h5' , 'h6' , 'li' , 'ul' , 'ol' , 'strong' , 'em' , 'i' , 'b' , ] ; if ( $ this -> isWysiwygEnabled ( 'images' ) ) { $ allowedBecauseWysiwyg [ ] = 'img' ; } if ( $ this -> isWysiwygE... | Return a list of allowed tags needed for WYSIWYG field types . |
43,072 | protected function isWysiwygEnabled ( $ name ) { return isset ( $ this -> allowedWyswig [ $ name ] ) && ( bool ) $ this -> allowedWyswig [ $ name ] ; } | Return a WYSIWYG configuration value . |
43,073 | public function execute ( ) { $ composer = $ this -> getComposer ( ) ; $ installationManager = $ composer -> getInstallationManager ( ) ; $ localRepo = $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) ; $ package = $ composer -> getPackage ( ) ; $ config = $ composer -> getConfig ( ) ; $ optimize = $ th... | Dump autoloaders . |
43,074 | public function add ( WidgetAssetInterface $ widget ) { $ widget -> setKey ( ) ; $ this -> queue [ $ widget -> getKey ( ) ] = $ widget ; } | Add a widget to the queue . |
43,075 | public function render ( $ location , $ zone = Zone :: FRONTEND , $ wrapperTemplate = 'widgetwrapper.twig' ) { $ widgets = [ ] ; foreach ( $ this -> sort ( $ this -> queue ) as $ widget ) { if ( $ widget -> getZone ( ) !== $ zone || $ widget -> getLocation ( ) !== $ location ) { continue ; } $ html = $ widget -> isDefe... | Render a location s widget . |
43,076 | protected function getHtml ( WidgetAssetInterface $ widget ) { $ key = 'widget_' . $ widget -> getKey ( ) ; if ( $ html = $ this -> cache -> fetch ( $ key ) ) { return $ html ; } $ html = Thrower :: call ( [ $ widget , '__toString' ] ) ; if ( $ widget -> getCacheDuration ( ) !== null ) { $ this -> cache -> save ( $ key... | Get the HTML content from the widget . |
43,077 | protected function addDeferredJavaScript ( WidgetAssetInterface $ widget , Response $ response ) { if ( $ this -> deferAdded ) { return ; } $ javaScript = $ this -> render -> render ( 'widgetjavascript.twig' , [ 'widget' => $ widget , ] ) ; $ snippet = ( new Snippet ( ) ) -> setLocation ( Target :: AFTER_BODY_JS ) -> s... | Insert a snippet of Javascript to fetch the actual widget s contents . |
43,078 | public function createTables ( array $ tableCreates , SchemaCheck $ response ) { foreach ( $ tableCreates as $ tableName => $ tableCreate ) { $ this -> createTable ( $ tableName , $ tableCreate , $ response ) ; } } | Process a group of tables create queries . |
43,079 | public function alterTables ( array $ tableAlters , SchemaCheck $ response ) { foreach ( $ tableAlters as $ tableName => $ tableAlter ) { $ this -> alterTable ( $ tableName , $ tableAlter , $ response ) ; } } | Process a group of tables alter queries . |
43,080 | protected function createTable ( $ tableName , array $ tableCreate , SchemaCheck $ response ) { foreach ( $ tableCreate as $ query ) { if ( $ this -> runQuery ( $ tableName , $ query ) ) { $ response -> addTitle ( $ tableName , sprintf ( 'Created table `%s`.' , $ tableName ) ) ; } } } | Process a single table create query . |
43,081 | protected function alterTable ( $ tableName , array $ tableAlter , SchemaCheck $ response ) { foreach ( $ tableAlter as $ query ) { if ( $ this -> runQuery ( $ tableName , $ query ) === null ) { return ; } $ response -> addTitle ( $ tableName , sprintf ( 'Updated `%s` table to match current schema.' , $ tableName ) ) ;... | Process a single table alter queries . |
43,082 | public static function isURL ( $ str ) { $ pattern = '~^(?:\b[a-z\d.-]+://[^<>\s]+|\b(?:(?:(?:[^\s!@#$%^&*()_=+[\]{}\|;:\'",.<>/?]+)\.)+(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr... | Check if a given string looks like it could be a URL with or without the protocol . |
43,083 | public static function providerLink ( $ providedby ) { if ( empty ( $ providedby ) || ! is_array ( $ providedby ) ) { return '' ; } if ( empty ( $ providedby [ 1 ] ) || empty ( strip_tags ( $ providedby [ 1 ] ) ) ) { $ providedby [ 1 ] = $ providedby [ 0 ] ; } $ scheme = parse_url ( $ providedby [ 0 ] , PHP_URL_SCHEME ... | Create provider link as used in the footer to link to either an email address or website URL . |
43,084 | public static function fromEvent ( Event $ event ) { $ io = NutStyle :: fromComposer ( $ event -> getIO ( ) ) ; $ options = Options :: fromEvent ( $ event ) ; return new static ( $ io , $ options ) ; } | Create from a Composer event object . |
43,085 | private function configureDirs ( ) { foreach ( $ this -> resolver -> names ( ) as $ name ) { $ default = $ this -> resolver -> raw ( $ name ) ; $ path = $ this -> options -> get ( $ name . '-dir' , $ default ) ; if ( $ path !== $ default ) { $ this -> verbose ( "Setting <info>$name</> path to <info>$path</>." ) ; $ thi... | Configure dirs from env composer extra values and via user input . |
43,086 | private function writeYamlConfig ( ) { $ customized = [ ] ; foreach ( $ this -> resolver -> names ( ) as $ name ) { $ raw = $ this -> resolver -> raw ( $ name ) ; if ( $ raw !== $ this -> defaults -> raw ( $ name ) ) { $ customized [ $ name ] = $ raw ; } } if ( ! $ customized ) { return ; } $ this -> io -> writeln ( 'W... | Writes the . bolt . yml file if paths are not the default . |
43,087 | private function moveSkeletonDirs ( ) { $ pathNames = ( new PathDependencySorter ( $ this -> resolver ) ) -> getSortedNames ( ) ; foreach ( $ pathNames as $ name ) { $ this -> moveSkeletonDir ( $ name ) ; } } | Move dirs from skeleton to match given paths . |
43,088 | private function moveSkeletonDir ( $ name ) { $ root = $ this -> resolver -> resolve ( 'root' ) ; $ target = $ this -> resolver -> resolve ( $ name ) ; $ target = Path :: makeRelative ( $ target , $ root ) ; $ origin = $ this -> defaults -> resolve ( $ name ) ; $ origin = Path :: makeRelative ( $ origin , $ root ) ; if... | Move given dir from skeleton to match PathResolver setting if needed . |
43,089 | private function updatePermissions ( ) { $ pathNames = $ this -> resolver -> names ( ) ; $ pathNames [ ] = '%web%/extensions' ; $ pathNames [ ] = '%web%/thumbs' ; $ dirMode = $ this -> options -> getDirMode ( ) ; foreach ( $ pathNames as $ name ) { $ path = $ this -> resolver -> resolve ( $ name ) ; if ( ! $ this -> fi... | Update all path resolver directories permissions . |
43,090 | public function handle ( $ path ) { $ file = $ this -> filesystem -> getFile ( $ path ) ; return $ this -> filePermissions -> authorized ( $ file -> getMountPoint ( ) , $ file -> getPath ( ) ) ; } | Returns whether you are authorized to do something with a file or directory . |
43,091 | public function weighSearchResult ( $ query ) { static $ contenttypeFields = null ; static $ contenttypeTaxonomies = null ; $ ct = $ this -> contenttype [ 'slug' ] ; if ( ( $ contenttypeFields === null ) || ( ! isset ( $ contenttypeFields [ $ ct ] ) ) ) { $ contenttypeFields [ $ ct ] = $ this -> getFieldWeights ( ) ; $... | Weigh this content against a query . |
43,092 | private function getFieldWeights ( ) { $ searchableTypes = [ 'text' , 'textarea' , 'html' , 'markdown' ] ; $ fields = [ ] ; $ slugFields = [ ] ; foreach ( $ this -> contenttype [ 'fields' ] as $ config ) { if ( $ config [ 'type' ] === 'slug' && isset ( $ config [ 'uses' ] ) ) { $ slugFields = ( array ) $ config [ 'uses... | Calculate the default field weights . |
43,093 | private function getTaxonomyWeights ( ) { $ taxonomies = [ ] ; if ( isset ( $ this -> contenttype [ 'taxonomy' ] ) ) { foreach ( $ this -> contenttype [ 'taxonomy' ] as $ key ) { if ( $ this -> app [ 'config' ] -> get ( 'taxonomy/' . $ key . '/behaves_like' ) === 'tags' ) { $ taxonomies [ $ key ] = $ this -> app [ 'con... | Calculate the default taxonomy weights . |
43,094 | private function weighQueryText ( $ subject , $ complete , array $ words , $ max ) { $ lowSubject = mb_strtolower ( trim ( $ subject ) ) ; if ( $ lowSubject === $ complete ) { return round ( ( 100 / 100 ) * $ max ) ; } if ( strpos ( $ lowSubject , $ complete ) !== false ) { return round ( ( 70 / 100 ) * $ max ) ; } $ w... | Weight a text part relative to some other part . |
43,095 | public static function getWidth ( ) { $ width = getenv ( 'COLUMNS' ) ; if ( $ width !== false ) { return ( int ) trim ( $ width ) ; } static :: updateDimensions ( ) ; return static :: $ width ; } | Returns the Terminal s width . |
43,096 | public static function getHeight ( ) { $ height = getenv ( 'LINES' ) ; if ( $ height !== false ) { return ( int ) trim ( $ height ) ; } static :: updateDimensions ( ) ; return static :: $ height ; } | Returns the Terminal s height . |
43,097 | private static function checkPcntl ( ) { if ( static :: $ pcntlEnabled === null ) { if ( ! extension_loaded ( 'pcntl' ) ) { static :: $ pcntlEnabled = false ; return true ; } static :: $ pcntlEnabled = true ; if ( version_compare ( PHP_VERSION , '7.1' , '>=' ) ) { pcntl_async_signals ( true ) ; static :: $ pcntlAsync =... | Initializes and checks if we have received a SIGWINCH signal . |
43,098 | private static function fetchDimensions ( ) { if ( DIRECTORY_SEPARATOR === '\\' ) { $ dimensions = static :: getAnsiCon ( ) ; if ( ! $ dimensions ) { $ dimensions = static :: getConsoleMode ( ) ; } } else { $ dimensions = static :: getSttyColumns ( ) ; } $ dimensions += [ 80 , 50 ] ; static :: $ width = $ dimensions [ ... | Fetch dimensions based on platform . |
43,099 | private static function getAnsiCon ( ) { if ( preg_match ( '/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/' , trim ( getenv ( 'ANSICON' ) ) , $ matches ) ) { return [ ( int ) $ matches [ 1 ] , isset ( $ matches [ 4 ] ) ? ( int ) $ matches [ 4 ] : ( int ) $ matches [ 2 ] , ] ; } return [ ] ; } | Parse width & height from ANSICON env var . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.