idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
25,300 | public function query ( $ sql ) { return $ this -> getDisconnectRetry ( ) -> run ( function ( ) use ( $ sql ) { $ statement = $ this -> prepare ( $ sql ) ; $ statement -> execute ( ) ; return $ statement ; } ) ; } | Executes a SQL statement and returns the Statement object as result . |
25,301 | public function getSchemaCollection ( ) { if ( $ this -> _schemaCollection !== null ) { return $ this -> _schemaCollection ; } if ( ! empty ( $ this -> _config [ 'cacheMetadata' ] ) ) { return $ this -> _schemaCollection = new CachedCollection ( $ this , $ this -> _config [ 'cacheMetadata' ] ) ; } return $ this -> _sch... | Gets a Schema \ Collection object for this connection . |
25,302 | public function schemaCollection ( SchemaCollection $ collection = null ) { deprecationWarning ( 'Connection::schemaCollection() is deprecated. ' . 'Use Connection::setSchemaCollection()/getSchemaCollection() instead.' ) ; if ( $ collection !== null ) { $ this -> setSchemaCollection ( $ collection ) ; } return $ this -... | Gets or sets a Schema \ Collection object for this connection . |
25,303 | public function insert ( $ table , array $ data , array $ types = [ ] ) { return $ this -> getDisconnectRetry ( ) -> run ( function ( ) use ( $ table , $ data , $ types ) { $ columns = array_keys ( $ data ) ; return $ this -> newQuery ( ) -> insert ( $ columns , $ types ) -> into ( $ table ) -> values ( $ data ) -> exe... | Executes an INSERT query on the specified table . |
25,304 | public function update ( $ table , array $ data , array $ conditions = [ ] , $ types = [ ] ) { return $ this -> getDisconnectRetry ( ) -> run ( function ( ) use ( $ table , $ data , $ conditions , $ types ) { return $ this -> newQuery ( ) -> update ( $ table ) -> set ( $ data , $ types ) -> where ( $ conditions , $ typ... | Executes an UPDATE statement on the specified table . |
25,305 | public function delete ( $ table , $ conditions = [ ] , $ types = [ ] ) { return $ this -> getDisconnectRetry ( ) -> run ( function ( ) use ( $ table , $ conditions , $ types ) { return $ this -> newQuery ( ) -> delete ( $ table ) -> where ( $ conditions , $ types ) -> execute ( ) ; } ) ; } | Executes a DELETE statement on the specified table . |
25,306 | public function commit ( ) { if ( ! $ this -> _transactionStarted ) { return false ; } if ( $ this -> _transactionLevel === 0 ) { if ( $ this -> wasNestedTransactionRolledback ( ) ) { $ e = $ this -> nestedTransactionRollbackException ; $ this -> nestedTransactionRollbackException = null ; throw $ e ; } $ this -> _tran... | Commits current transaction . |
25,307 | public function rollback ( $ toBeginning = null ) { if ( ! $ this -> _transactionStarted ) { return false ; } $ useSavePoint = $ this -> isSavePointsEnabled ( ) ; if ( $ toBeginning === null ) { $ toBeginning = ! $ useSavePoint ; } if ( $ this -> _transactionLevel === 0 || $ toBeginning ) { $ this -> _transactionLevel ... | Rollback current transaction . |
25,308 | public function disableForeignKeys ( ) { $ this -> getDisconnectRetry ( ) -> run ( function ( ) { $ this -> execute ( $ this -> _driver -> disableForeignKeySQL ( ) ) -> closeCursor ( ) ; } ) ; } | Run driver specific SQL to disable foreign key checks . |
25,309 | public function enableForeignKeys ( ) { $ this -> getDisconnectRetry ( ) -> run ( function ( ) { $ this -> execute ( $ this -> _driver -> enableForeignKeySQL ( ) ) -> closeCursor ( ) ; } ) ; } | Run driver specific SQL to enable foreign key checks . |
25,310 | public function quote ( $ value , $ type = null ) { list ( $ value , $ type ) = $ this -> cast ( $ value , $ type ) ; return $ this -> _driver -> quote ( $ value , $ type ) ; } | Quotes value to be used safely in database query . |
25,311 | public function log ( $ sql ) { $ query = new LoggedQuery ( ) ; $ query -> query = $ sql ; $ this -> getLogger ( ) -> log ( $ query ) ; } | Logs a Query string using the configured logger object . |
25,312 | protected function _newLogger ( StatementInterface $ statement ) { $ log = new LoggingStatement ( $ statement , $ this -> _driver ) ; $ log -> setLogger ( $ this -> getLogger ( ) ) ; return $ log ; } | Returns a new statement object that will log the activity for the passed original statement instance . |
25,313 | public function set ( $ property , $ value = null , array $ options = [ ] ) { if ( is_string ( $ property ) && $ property !== '' ) { $ guard = false ; $ property = [ $ property => $ value ] ; } else { $ guard = true ; $ options = ( array ) $ value ; } if ( ! is_array ( $ property ) ) { throw new InvalidArgumentExceptio... | Sets a single property inside this entity . |
25,314 | public function & get ( $ property ) { if ( ! strlen ( ( string ) $ property ) ) { throw new InvalidArgumentException ( 'Cannot get an empty property' ) ; } $ value = null ; $ method = static :: _accessor ( $ property , 'get' ) ; if ( isset ( $ this -> _properties [ $ property ] ) ) { $ value = & $ this -> _properties ... | Returns the value of a property by name |
25,315 | public function getOriginal ( $ property ) { if ( ! strlen ( ( string ) $ property ) ) { throw new InvalidArgumentException ( 'Cannot get an empty property' ) ; } if ( array_key_exists ( $ property , $ this -> _original ) ) { return $ this -> _original [ $ property ] ; } return $ this -> get ( $ property ) ; } | Returns the value of an original property by name |
25,316 | public function getOriginalValues ( ) { $ originals = $ this -> _original ; $ originalKeys = array_keys ( $ originals ) ; foreach ( $ this -> _properties as $ key => $ value ) { if ( ! in_array ( $ key , $ originalKeys ) ) { $ originals [ $ key ] = $ value ; } } return $ originals ; } | Gets all original values of the entity . |
25,317 | public function isEmpty ( $ property ) { $ value = $ this -> get ( $ property ) ; if ( $ value === null || ( is_array ( $ value ) && empty ( $ value ) || ( is_string ( $ value ) && empty ( $ value ) ) ) ) { return true ; } return false ; } | Checks that a property is empty |
25,318 | public function unsetProperty ( $ property ) { $ property = ( array ) $ property ; foreach ( $ property as $ p ) { unset ( $ this -> _properties [ $ p ] , $ this -> _dirty [ $ p ] ) ; } return $ this ; } | Removes a property or list of properties from this entity |
25,319 | public function setHidden ( array $ properties , $ merge = false ) { if ( $ merge === false ) { $ this -> _hidden = $ properties ; return $ this ; } $ properties = array_merge ( $ this -> _hidden , $ properties ) ; $ this -> _hidden = array_unique ( $ properties ) ; return $ this ; } | Sets hidden properties . |
25,320 | public function setVirtual ( array $ properties , $ merge = false ) { if ( $ merge === false ) { $ this -> _virtual = $ properties ; return $ this ; } $ properties = array_merge ( $ this -> _virtual , $ properties ) ; $ this -> _virtual = array_unique ( $ properties ) ; return $ this ; } | Sets the virtual properties on this entity . |
25,321 | public function visibleProperties ( ) { $ properties = array_keys ( $ this -> _properties ) ; $ properties = array_merge ( $ properties , $ this -> _virtual ) ; return array_diff ( $ properties , $ this -> _hidden ) ; } | Get the list of visible properties . |
25,322 | public function extract ( array $ properties , $ onlyDirty = false ) { $ result = [ ] ; foreach ( $ properties as $ property ) { if ( ! $ onlyDirty || $ this -> isDirty ( $ property ) ) { $ result [ $ property ] = $ this -> get ( $ property ) ; } } return $ result ; } | Returns an array with the requested properties stored in this entity indexed by property name |
25,323 | public function extractOriginal ( array $ properties ) { $ result = [ ] ; foreach ( $ properties as $ property ) { $ result [ $ property ] = $ this -> getOriginal ( $ property ) ; } return $ result ; } | Returns an array with the requested original properties stored in this entity indexed by property name . |
25,324 | public function extractOriginalChanged ( array $ properties ) { $ result = [ ] ; foreach ( $ properties as $ property ) { $ original = $ this -> getOriginal ( $ property ) ; if ( $ original !== $ this -> get ( $ property ) ) { $ result [ $ property ] = $ original ; } } return $ result ; } | Returns an array with only the original properties stored in this entity indexed by property name . |
25,325 | public function dirty ( $ property = null , $ isDirty = null ) { deprecationWarning ( get_called_class ( ) . '::dirty() is deprecated. ' . 'Use setDirty()/isDirty() instead.' ) ; if ( $ property === null ) { return $ this -> isDirty ( ) ; } if ( $ isDirty === null ) { return $ this -> isDirty ( $ property ) ; } $ this ... | Sets the dirty status of a single property . If called with no second argument it will return whether the property was modified or not after the object creation . |
25,326 | public function setDirty ( $ property , $ isDirty = true ) { if ( $ isDirty === false ) { unset ( $ this -> _dirty [ $ property ] ) ; return $ this ; } $ this -> _dirty [ $ property ] = true ; unset ( $ this -> _errors [ $ property ] , $ this -> _invalid [ $ property ] ) ; return $ this ; } | Sets the dirty status of a single property . |
25,327 | public function isDirty ( $ property = null ) { if ( $ property === null ) { return ! empty ( $ this -> _dirty ) ; } return isset ( $ this -> _dirty [ $ property ] ) ; } | Checks if the entity is dirty or if a single property of it is dirty . |
25,328 | public function isNew ( $ new = null ) { if ( $ new === null ) { return $ this -> _new ; } $ new = ( bool ) $ new ; if ( $ new ) { foreach ( $ this -> _properties as $ k => $ p ) { $ this -> _dirty [ $ k ] = true ; } } return $ this -> _new = $ new ; } | Returns whether or not this entity has already been persisted . This method can return null in the case there is no prior information on the status of this entity . |
25,329 | public function hasErrors ( $ includeNested = true ) { if ( Hash :: filter ( $ this -> _errors ) ) { return true ; } if ( $ includeNested === false ) { return false ; } foreach ( $ this -> _properties as $ property ) { if ( $ this -> _readHasErrors ( $ property ) ) { return true ; } } return false ; } | Returns whether this entity has errors . |
25,330 | public function getErrors ( ) { $ diff = array_diff_key ( $ this -> _properties , $ this -> _errors ) ; return $ this -> _errors + ( new Collection ( $ diff ) ) -> filter ( function ( $ value ) { return is_array ( $ value ) || $ value instanceof EntityInterface ; } ) -> map ( function ( $ value ) { return $ this -> _re... | Returns all validation errors . |
25,331 | public function getError ( $ field ) { $ errors = isset ( $ this -> _errors [ $ field ] ) ? $ this -> _errors [ $ field ] : [ ] ; if ( $ errors ) { return $ errors ; } return $ this -> _nestedErrors ( $ field ) ; } | Returns validation errors of a field |
25,332 | public function setErrors ( array $ fields , $ overwrite = false ) { if ( $ overwrite ) { foreach ( $ fields as $ f => $ error ) { $ this -> _errors [ $ f ] = ( array ) $ error ; } return $ this ; } foreach ( $ fields as $ f => $ error ) { $ this -> _errors += [ $ f => [ ] ] ; if ( is_string ( $ error ) ) { $ this -> _... | Sets error messages to the entity |
25,333 | public function setError ( $ field , $ errors , $ overwrite = false ) { if ( is_string ( $ errors ) ) { $ errors = [ $ errors ] ; } return $ this -> setErrors ( [ $ field => $ errors ] , $ overwrite ) ; } | Sets errors for a single field |
25,334 | public function errors ( $ field = null , $ errors = null , $ overwrite = false ) { deprecationWarning ( get_called_class ( ) . '::errors() is deprecated. ' . 'Use setError()/getError() or setErrors()/getErrors() instead.' ) ; if ( $ field === null ) { return $ this -> getErrors ( ) ; } if ( is_string ( $ field ) && $ ... | Sets the error messages for a field or a list of fields . When called without the second argument it returns the validation errors for the specified fields . If called with no arguments it returns all the validation error messages stored in this entity and any other nested entity . |
25,335 | protected function _nestedErrors ( $ field ) { $ path = explode ( '.' , $ field ) ; if ( count ( $ path ) === 1 ) { return $ this -> _readError ( $ this -> get ( $ path [ 0 ] ) ) ; } $ entity = $ this ; $ len = count ( $ path ) ; while ( $ len ) { $ part = array_shift ( $ path ) ; $ len = count ( $ path ) ; $ val = nul... | Auxiliary method for getting errors in nested entities |
25,336 | protected function _readHasErrors ( $ object ) { if ( $ object instanceof EntityInterface && $ object -> hasErrors ( ) ) { return true ; } if ( is_array ( $ object ) ) { foreach ( $ object as $ value ) { if ( $ this -> _readHasErrors ( $ value ) ) { return true ; } } } return false ; } | Reads if there are errors for one or many objects . |
25,337 | public function getInvalidField ( $ field ) { $ value = isset ( $ this -> _invalid [ $ field ] ) ? $ this -> _invalid [ $ field ] : null ; return $ value ; } | Get a single value of an invalid field . Returns null if not set . |
25,338 | public function setInvalid ( array $ fields , $ overwrite = false ) { foreach ( $ fields as $ field => $ value ) { if ( $ overwrite === true ) { $ this -> _invalid [ $ field ] = $ value ; continue ; } $ this -> _invalid += [ $ field => $ value ] ; } return $ this ; } | Set fields as invalid and not patchable into the entity . |
25,339 | public function invalid ( $ field = null , $ value = null , $ overwrite = false ) { deprecationWarning ( get_called_class ( ) . '::invalid() is deprecated. ' . 'Use setInvalid()/getInvalid()/getInvalidField() instead.' ) ; if ( $ field === null ) { return $ this -> _invalid ; } if ( is_string ( $ field ) && $ value ===... | Sets a field as invalid and not patchable into the entity . |
25,340 | public function isAccessible ( $ property ) { $ value = isset ( $ this -> _accessible [ $ property ] ) ? $ this -> _accessible [ $ property ] : null ; return ( $ value === null && ! empty ( $ this -> _accessible [ '*' ] ) ) || $ value ; } | Checks if a property is accessible |
25,341 | public function source ( $ alias = null ) { deprecationWarning ( get_called_class ( ) . '::source() is deprecated. ' . 'Use setSource()/getSource() instead.' ) ; if ( $ alias === null ) { return $ this -> getSource ( ) ; } $ this -> setSource ( $ alias ) ; return $ this ; } | Returns the alias of the repository from which this entity came from . |
25,342 | public function copy ( $ name = null ) { $ this -> _process ( $ this -> _list ( $ name ) , true , $ this -> param ( 'overwrite' ) ) ; } | Copying plugin assets to app s webroot . For vendor namespaced plugin parent folder for vendor name are created if required . |
25,343 | public function remove ( $ name = null ) { $ plugins = $ this -> _list ( $ name ) ; foreach ( $ plugins as $ plugin => $ config ) { $ this -> out ( ) ; $ this -> out ( 'For plugin: ' . $ plugin ) ; $ this -> hr ( ) ; $ this -> _remove ( $ config ) ; } $ this -> out ( ) ; $ this -> out ( 'Done' ) ; } | Remove plugin assets from app s webroot . |
25,344 | protected function _list ( $ name = null ) { if ( $ name === null ) { $ pluginsList = Plugin :: loaded ( ) ; } else { if ( ! Plugin :: isLoaded ( $ name ) ) { $ this -> err ( sprintf ( 'Plugin %s is not loaded.' , $ name ) ) ; return [ ] ; } $ pluginsList = [ $ name ] ; } $ plugins = [ ] ; foreach ( $ pluginsList as $ ... | Get list of plugins to process . Plugins without a webroot directory are skipped . |
25,345 | public function count ( ) { if ( $ this -> getInnerIterator ( ) instanceof Countable ) { return $ this -> getInnerIterator ( ) -> count ( ) ; } return count ( $ this -> toArray ( ) ) ; } | Make this object countable . |
25,346 | public function buildOptions ( Request $ request , array $ options ) { $ headers = [ ] ; foreach ( $ request -> getHeaders ( ) as $ key => $ values ) { $ headers [ ] = $ key . ': ' . implode ( ', ' , $ values ) ; } $ out = [ CURLOPT_URL => ( string ) $ request -> getUri ( ) , CURLOPT_HTTP_VERSION => $ request -> getPro... | Convert client options into curl options . |
25,347 | protected function createResponse ( $ handle , $ responseData ) { $ headerSize = curl_getinfo ( $ handle , CURLINFO_HEADER_SIZE ) ; $ headers = trim ( substr ( $ responseData , 0 , $ headerSize ) ) ; $ body = substr ( $ responseData , $ headerSize ) ; $ response = new Response ( explode ( "\r\n" , $ headers ) , $ body ... | Convert the raw curl response into an Http \ Client \ Response |
25,348 | public static function toCake ( PsrRequest $ request ) { $ post = $ request -> getParsedBody ( ) ; $ headers = [ ] ; foreach ( $ request -> getHeaders ( ) as $ k => $ value ) { $ name = sprintf ( 'HTTP_%s' , strtoupper ( str_replace ( '-' , '_' , $ k ) ) ) ; $ headers [ $ name ] = implode ( ',' , $ value ) ; } $ server... | Transform a PSR7 request into a CakePHP one . |
25,349 | protected static function getParams ( PsrRequest $ request ) { $ params = ( array ) $ request -> getAttribute ( 'params' , [ ] ) ; $ params += [ 'plugin' => null , 'controller' => null , 'action' => null , '_ext' => null , 'pass' => [ ] ] ; return $ params ; } | Extract the routing parameters out of the request object . |
25,350 | protected static function convertFiles ( $ data , $ files , $ path = '' ) { foreach ( $ files as $ key => $ file ) { $ newPath = $ path ; if ( $ newPath === '' ) { $ newPath = $ key ; } if ( $ newPath !== $ key ) { $ newPath .= '.' . $ key ; } if ( is_array ( $ file ) ) { $ data = static :: convertFiles ( $ data , $ fi... | Convert a nested array of files to arrays . |
25,351 | protected static function convertFile ( $ file ) { $ error = $ file -> getError ( ) ; $ tmpName = '' ; if ( $ error === UPLOAD_ERR_OK ) { $ tmpName = $ file -> getStream ( ) -> getMetadata ( 'uri' ) ; } return [ 'name' => $ file -> getClientFilename ( ) , 'type' => $ file -> getClientMediaType ( ) , 'tmp_name' => $ tmp... | Convert a single file back into an array . |
25,352 | public function isPresenceRequired ( $ validatePresent = null ) { if ( $ validatePresent === null ) { return $ this -> _validatePresent ; } deprecationWarning ( 'ValidationSet::isPresenceRequired() is deprecated as a setter. ' . 'Use ValidationSet::requirePresence() instead.' ) ; return $ this -> requirePresence ( $ va... | Sets whether a field is required to be present in data array . |
25,353 | public function isEmptyAllowed ( $ allowEmpty = null ) { if ( $ allowEmpty === null ) { return $ this -> _allowEmpty ; } deprecationWarning ( 'ValidationSet::isEmptyAllowed() is deprecated as a setter. ' . 'Use ValidationSet::allowEmpty() instead.' ) ; return $ this -> allowEmpty ( $ allowEmpty ) ; } | Sets whether a field value is allowed to be empty . |
25,354 | public function handle ( Event $ event ) { $ name = $ event -> getName ( ) ; list ( , $ method ) = explode ( '.' , $ name ) ; if ( empty ( $ this -> _config [ 'for' ] ) && empty ( $ this -> _config [ 'when' ] ) ) { return $ this -> { $ method } ( $ event ) ; } if ( $ this -> matches ( $ event ) ) { return $ this -> { $... | Handler method that applies conditions and resolves the correct method to call . |
25,355 | public function matches ( Event $ event ) { $ request = $ event -> getData ( 'request' ) ; $ pass = true ; if ( ! empty ( $ this -> _config [ 'for' ] ) ) { $ len = strlen ( 'preg:' ) ; $ for = $ this -> _config [ 'for' ] ; $ url = $ request -> getRequestTarget ( ) ; if ( substr ( $ for , 0 , $ len ) === 'preg:' ) { $ p... | Check to see if the incoming request matches this filter s criteria . |
25,356 | protected function _alias ( $ alias , $ conditions , $ multipleNulls ) { $ aliased = [ ] ; foreach ( $ conditions as $ key => $ value ) { if ( $ multipleNulls ) { $ aliased [ "$alias.$key" ] = $ value ; } else { $ aliased [ "$alias.$key IS" ] = $ value ; } } return $ aliased ; } | Add a model alias to all the keys in a set of conditions . |
25,357 | public function loadInto ( $ entities , array $ contain , Table $ source ) { $ returnSingle = false ; if ( $ entities instanceof EntityInterface ) { $ entities = [ $ entities ] ; $ returnSingle = true ; } $ entities = new Collection ( $ entities ) ; $ query = $ this -> _getQuery ( $ entities , $ contain , $ source ) ; ... | Loads the specified associations in the passed entity or list of entities by executing extra queries in the database and merging the results in the appropriate properties . |
25,358 | protected function _getPropertyMap ( $ source , $ associations ) { $ map = [ ] ; $ container = $ source -> associations ( ) ; foreach ( $ associations as $ assoc ) { $ map [ $ assoc ] = $ container -> get ( $ assoc ) -> getProperty ( ) ; } return $ map ; } | Returns a map of property names where the association results should be injected in the top level entities . |
25,359 | protected function _injectResults ( $ objects , $ results , $ associations , $ source ) { $ injected = [ ] ; $ properties = $ this -> _getPropertyMap ( $ source , $ associations ) ; $ primaryKey = ( array ) $ source -> getPrimaryKey ( ) ; $ results = $ results -> indexBy ( function ( $ e ) use ( $ primaryKey ) { return... | Injects the results of the eager loader query into the original list of entities . |
25,360 | public static function toCake ( PsrResponse $ response ) { $ body = static :: getBody ( $ response ) ; $ data = [ 'status' => $ response -> getStatusCode ( ) , 'body' => $ body [ 'body' ] , ] ; $ cake = new CakeResponse ( $ data ) ; if ( $ body [ 'file' ] ) { $ cake -> file ( $ body [ 'file' ] ) ; } $ cookies = static ... | Convert a PSR7 Response into a CakePHP one . |
25,361 | protected static function getBody ( PsrResponse $ response ) { $ stream = $ response -> getBody ( ) ; if ( $ stream -> getMetadata ( 'wrapper_type' ) === 'plainfile' ) { return [ 'body' => '' , 'file' => $ stream -> getMetadata ( 'uri' ) ] ; } if ( $ stream -> getSize ( ) === 0 ) { return [ 'body' => '' , 'file' => fal... | Get the response body from a PSR7 Response . |
25,362 | protected static function parseCookies ( array $ cookieHeader ) { $ cookies = [ ] ; foreach ( $ cookieHeader as $ cookie ) { if ( strpos ( $ cookie , '";"' ) !== false ) { $ cookie = str_replace ( '";"' , '{__cookie_replace__}' , $ cookie ) ; $ parts = preg_split ( '/\;[ \t]*/' , $ cookie ) ; $ parts = str_replace ( '{... | Parse the Set - Cookie headers in a PSR7 response into the format CakePHP expects . |
25,363 | protected static function collapseHeaders ( PsrResponse $ response ) { $ out = [ ] ; foreach ( $ response -> getHeaders ( ) as $ name => $ value ) { if ( count ( $ value ) === 1 ) { $ out [ $ name ] = $ value [ 0 ] ; } else { $ out [ $ name ] = $ value ; } } return $ out ; } | Convert a PSR7 Response headers into a flat array |
25,364 | public static function toPsr ( CakeResponse $ response ) { $ status = $ response -> statusCode ( ) ; $ headers = $ response -> header ( ) ; if ( ! isset ( $ headers [ 'Content-Type' ] ) ) { $ headers = static :: setContentType ( $ headers , $ response ) ; } $ cookies = $ response -> cookie ( ) ; if ( $ cookies ) { $ he... | Convert a CakePHP response into a PSR7 one . |
25,365 | protected static function setContentType ( $ headers , $ response ) { if ( isset ( $ headers [ 'Content-Type' ] ) ) { return $ headers ; } if ( in_array ( $ response -> statusCode ( ) , [ 204 , 304 ] ) ) { return $ headers ; } $ whitelist = [ 'application/javascript' , 'application/json' , 'application/xml' , 'applicat... | Add in the Content - Type header if necessary . |
25,366 | protected static function buildCookieHeader ( $ cookies ) { $ headers = [ ] ; foreach ( $ cookies as $ cookie ) { $ parts = [ sprintf ( '%s=%s' , urlencode ( $ cookie [ 'name' ] ) , urlencode ( $ cookie [ 'value' ] ) ) ] ; if ( $ cookie [ 'expire' ] ) { $ cookie [ 'expire' ] = gmdate ( 'D, d M Y H:i:s T' , $ cookie [ '... | Convert an array of cookies into header lines . |
25,367 | protected static function getStream ( $ response ) { $ stream = 'php://memory' ; $ body = $ response -> body ( ) ; if ( is_string ( $ body ) && strlen ( $ body ) ) { $ stream = new Stream ( 'php://memory' , 'wb' ) ; $ stream -> write ( $ body ) ; return $ stream ; } if ( is_callable ( $ body ) ) { $ stream = new Callba... | Get the stream for the new response . |
25,368 | public static function setConfig ( $ key , $ config = null ) { if ( is_array ( $ config ) ) { $ config [ 'name' ] = $ key ; } static :: _setConfig ( $ key , $ config ) ; } | Configure a new connection object . |
25,369 | public static function alias ( $ alias , $ source ) { if ( empty ( static :: $ _config [ $ source ] ) && empty ( static :: $ _config [ $ alias ] ) ) { throw new MissingDatasourceConfigException ( sprintf ( 'Cannot create alias of "%s" as it does not exist.' , $ alias ) ) ; } static :: $ _aliasMap [ $ source ] = $ alias... | Set one or more connection aliases . |
25,370 | public function output ( $ args ) { $ args += [ 'callback' => null ] ; if ( isset ( $ args [ 0 ] ) ) { $ args [ 'callback' ] = $ args [ 0 ] ; } if ( ! $ args [ 'callback' ] || ! is_callable ( $ args [ 'callback' ] ) ) { throw new RuntimeException ( 'Callback option must be a callable.' ) ; } $ this -> init ( $ args ) ;... | Output a progress bar . |
25,371 | public function init ( array $ args = [ ] ) { $ args += [ 'total' => 100 , 'width' => 80 ] ; $ this -> _progress = 0 ; $ this -> _width = $ args [ 'width' ] ; $ this -> _total = $ args [ 'total' ] ; return $ this ; } | Initialize the progress bar for use . |
25,372 | public function increment ( $ num = 1 ) { $ this -> _progress = min ( max ( 0 , $ this -> _progress + $ num ) , $ this -> _total ) ; return $ this ; } | Increment the progress bar . |
25,373 | public function draw ( ) { $ numberLen = strlen ( ' 100%' ) ; $ complete = round ( $ this -> _progress / $ this -> _total , 2 ) ; $ barLen = ( $ this -> _width - $ numberLen ) * ( $ this -> _progress / $ this -> _total ) ; $ bar = '' ; if ( $ barLen > 1 ) { $ bar = str_repeat ( '=' , $ barLen - 1 ) . '>' ; } $ pad = ce... | Render the progress bar based on the current state . |
25,374 | protected function _buildPropertyMap ( $ data , $ options ) { $ map = [ ] ; $ schema = $ this -> _table -> getSchema ( ) ; foreach ( array_keys ( $ data ) as $ prop ) { $ columnType = $ schema -> getColumnType ( $ prop ) ; if ( $ columnType ) { $ map [ $ prop ] = function ( $ value , $ entity ) use ( $ columnType ) { r... | Build the map of property = > marshalling callable . |
25,375 | public function one ( array $ data , array $ options = [ ] ) { list ( $ data , $ options ) = $ this -> _prepareDataAndOptions ( $ data , $ options ) ; $ primaryKey = ( array ) $ this -> _table -> getPrimaryKey ( ) ; $ entityClass = $ this -> _table -> getEntityClass ( ) ; $ entity = new $ entityClass ( ) ; $ entity -> ... | Hydrate one entity and its associated data . |
25,376 | protected function _marshalAssociation ( $ assoc , $ value , $ options ) { if ( ! is_array ( $ value ) ) { return null ; } $ targetTable = $ assoc -> getTarget ( ) ; $ marshaller = $ targetTable -> marshaller ( ) ; $ types = [ Association :: ONE_TO_ONE , Association :: MANY_TO_ONE ] ; if ( in_array ( $ assoc -> type ( ... | Create a new sub - marshaller and marshal the associated data . |
25,377 | public function many ( array $ data , array $ options = [ ] ) { $ output = [ ] ; foreach ( $ data as $ record ) { if ( ! is_array ( $ record ) ) { continue ; } $ output [ ] = $ this -> one ( $ record , $ options ) ; } return $ output ; } | Hydrate many entities and their associated data . |
25,378 | protected function _loadAssociatedByIds ( $ assoc , $ ids ) { if ( empty ( $ ids ) ) { return [ ] ; } $ target = $ assoc -> getTarget ( ) ; $ primaryKey = ( array ) $ target -> getPrimaryKey ( ) ; $ multi = count ( $ primaryKey ) > 1 ; $ primaryKey = array_map ( [ $ target , 'aliasField' ] , $ primaryKey ) ; if ( $ mul... | Loads a list of belongs to many from ids . |
25,379 | protected function _mergeAssociation ( $ original , $ assoc , $ value , $ options ) { if ( ! $ original ) { return $ this -> _marshalAssociation ( $ assoc , $ value , $ options ) ; } if ( ! is_array ( $ value ) ) { return null ; } $ targetTable = $ assoc -> getTarget ( ) ; $ marshaller = $ targetTable -> marshaller ( )... | Creates a new sub - marshaller and merges the associated data . |
25,380 | protected function _mergeBelongsToMany ( $ original , $ assoc , $ value , $ options ) { $ associated = isset ( $ options [ 'associated' ] ) ? $ options [ 'associated' ] : [ ] ; $ hasIds = array_key_exists ( '_ids' , $ value ) ; $ onlyIds = array_key_exists ( 'onlyIds' , $ options ) && $ options [ 'onlyIds' ] ; if ( $ h... | Creates a new sub - marshaller and merges the associated data for a BelongstoMany association . |
25,381 | protected function _mergeJoinData ( $ original , $ assoc , $ value , $ options ) { $ associated = isset ( $ options [ 'associated' ] ) ? $ options [ 'associated' ] : [ ] ; $ extra = [ ] ; foreach ( $ original as $ entity ) { $ entity -> setAccess ( '_joinData' , true ) ; $ joinData = $ entity -> get ( '_joinData' ) ; i... | Merge the special _joinData property into the entity set . |
25,382 | protected function _modelKey ( $ name ) { list ( , $ name ) = pluginSplit ( $ name ) ; return Inflector :: underscore ( Inflector :: singularize ( $ name ) ) . '_id' ; } | Creates the proper underscored model key for associations |
25,383 | protected function _modelNameFromKey ( $ key ) { $ key = str_replace ( '_id' , '' , $ key ) ; return Inflector :: camelize ( Inflector :: pluralize ( $ key ) ) ; } | Creates the proper model name from a foreign key |
25,384 | public function parse ( $ url , $ method = '' ) { $ decoded = urldecode ( $ url ) ; $ paths = array_keys ( $ this -> _paths ) ; rsort ( $ paths ) ; foreach ( $ paths as $ path ) { if ( strpos ( $ decoded , $ path ) !== 0 ) { continue ; } $ queryParameters = null ; if ( strpos ( $ url , '?' ) !== false ) { list ( $ url ... | Takes the URL string and iterates the routes until one is able to parse the route . |
25,385 | public function parseRequest ( ServerRequestInterface $ request ) { $ uri = $ request -> getUri ( ) ; $ urlPath = urldecode ( $ uri -> getPath ( ) ) ; $ paths = array_keys ( $ this -> _paths ) ; rsort ( $ paths ) ; foreach ( $ paths as $ path ) { if ( strpos ( $ urlPath , $ path ) !== 0 ) { continue ; } foreach ( $ thi... | Takes the ServerRequestInterface iterates the routes until one is able to parse the route . |
25,386 | public function setExtensions ( array $ extensions , $ merge = true ) { if ( $ merge ) { $ extensions = array_unique ( array_merge ( $ this -> _extensions , $ extensions ) ) ; } $ this -> _extensions = $ extensions ; return $ this ; } | Set the extensions that the route collection can handle . |
25,387 | public function middlewareGroup ( $ name , array $ middlewareNames ) { if ( $ this -> hasMiddleware ( $ name ) ) { $ message = "Cannot add middleware group '$name'. A middleware by this name has already been registered." ; throw new RuntimeException ( $ message ) ; } foreach ( $ middlewareNames as $ middlewareName ) { ... | Add middleware to a middleware group |
25,388 | public function getMiddleware ( array $ names ) { $ out = [ ] ; foreach ( $ names as $ name ) { if ( $ this -> hasMiddlewareGroup ( $ name ) ) { $ out = array_merge ( $ out , $ this -> getMiddleware ( $ this -> _middlewareGroups [ $ name ] ) ) ; continue ; } if ( ! $ this -> hasMiddleware ( $ name ) ) { $ message = "Th... | Get an array of middleware given a list of names |
25,389 | public static function connect ( $ route , $ defaults = [ ] , $ options = [ ] ) { static :: $ initialized = true ; static :: scope ( '/' , function ( $ routes ) use ( $ route , $ defaults , $ options ) { $ routes -> connect ( $ route , $ defaults , $ options ) ; } ) ; } | Connects a new Route in the router . |
25,390 | public static function parse ( $ url , $ method = '' ) { deprecationWarning ( 'Router::parse() is deprecated. ' . 'Use Router::parseRequest() instead. This will require adopting the Http\Server library.' ) ; if ( ! static :: $ initialized ) { static :: _loadRoutes ( ) ; } if ( strpos ( $ url , '/' ) !== 0 ) { $ url = '... | Parses given URL string . Returns routing parameters for that URL . |
25,391 | public static function setRequestInfo ( $ request ) { if ( $ request instanceof ServerRequest ) { static :: pushRequest ( $ request ) ; } else { deprecationWarning ( 'Passing an array into Router::setRequestInfo() is deprecated. ' . 'Pass an instance of ServerRequest instead.' ) ; $ requestData = $ request ; $ requestD... | Takes parameter and path information back from the Dispatcher sets these parameters as the current request parameters that are merged with URL arrays created later in the request . |
25,392 | public static function setRequestContext ( ServerRequestInterface $ request ) { $ uri = $ request -> getUri ( ) ; static :: $ _requestContext = [ '_base' => $ request -> getAttribute ( 'base' ) , '_port' => $ uri -> getPort ( ) , '_scheme' => $ uri -> getScheme ( ) , '_host' => $ uri -> getHost ( ) , ] ; } | Store the request context for a given request . |
25,393 | public static function popRequest ( ) { $ removed = array_pop ( static :: $ _requests ) ; $ last = end ( static :: $ _requests ) ; if ( $ last ) { static :: setRequestContext ( $ last ) ; reset ( static :: $ _requests ) ; } return $ removed ; } | Pops a request off of the request stack . Used when doing requestAction |
25,394 | public static function getRequest ( $ current = false ) { if ( $ current ) { $ request = end ( static :: $ _requests ) ; return $ request ? : null ; } return isset ( static :: $ _requests [ 0 ] ) ? static :: $ _requests [ 0 ] : null ; } | Get the current request object or the first one . |
25,395 | public static function reload ( ) { if ( empty ( static :: $ _initialState ) ) { static :: $ _collection = new RouteCollection ( ) ; static :: $ _initialState = get_class_vars ( get_called_class ( ) ) ; return ; } foreach ( static :: $ _initialState as $ key => $ val ) { if ( $ key !== '_initialState' ) { static :: $ {... | Reloads default Router settings . Resets all class variables and removes all connected routes . |
25,396 | protected static function _applyUrlFilters ( $ url ) { $ request = static :: getRequest ( true ) ; $ e = null ; foreach ( static :: $ _urlFilters as $ filter ) { try { $ url = $ filter ( $ url , $ request ) ; } catch ( Exception $ e ) { } catch ( Throwable $ e ) { } if ( $ e !== null ) { if ( is_array ( $ filter ) ) { ... | Applies all the connected URL filters to the URL . |
25,397 | public static function fullBaseUrl ( $ base = null ) { if ( $ base !== null ) { static :: $ _fullBaseUrl = $ base ; Configure :: write ( 'App.fullBaseUrl' , $ base ) ; } if ( empty ( static :: $ _fullBaseUrl ) ) { static :: $ _fullBaseUrl = Configure :: read ( 'App.fullBaseUrl' ) ; } return static :: $ _fullBaseUrl ; } | Sets the full base URL that will be used as a prefix for generating fully qualified URLs for this application . If no parameters are passed the currently configured value is returned . |
25,398 | public static function reverseToArray ( $ params ) { $ url = [ ] ; if ( $ params instanceof ServerRequest ) { $ url = $ params -> getQueryParams ( ) ; $ params = $ params -> getAttribute ( 'params' ) ; } elseif ( isset ( $ params [ 'url' ] ) ) { $ url = $ params [ 'url' ] ; } $ pass = isset ( $ params [ 'pass' ] ) ? $ ... | Reverses a parsed parameter array into an array . |
25,399 | public static function reverse ( $ params , $ full = false ) { $ params = static :: reverseToArray ( $ params ) ; return static :: url ( $ params , $ full ) ; } | Reverses a parsed parameter array into a string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.