idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
57,800
public static function cache ( $ cache = null ) { if ( $ cache === false ) { static :: $ _cachedPages = [ ] ; } if ( is_array ( $ cache ) ) { static :: $ _cachedPages += $ cache ; } return static :: $ _cachedPages ; }
Returns or sets the page cache used for mapping message ids to translations .
57,801
public static function assets ( $ type = null , $ options = [ ] ) { $ defaults = [ 'suffix' => null , 'filter' => null , 'paths' => [ ] ] ; if ( ! $ type ) { return static :: _assets ( ) ; } if ( $ options === false ) { unset ( static :: $ _assets [ $ type ] ) ; } if ( ! $ options ) { return static :: _assets ( $ type ...
Gets or sets options for various asset types .
57,802
public static function asset ( $ path , $ type , array $ options = [ ] ) { $ options = static :: _assetOptions ( $ path , $ type , $ options ) ; $ params = compact ( 'path' , 'type' , 'options' ) ; return Filters :: run ( get_called_class ( ) , __FUNCTION__ , $ params , function ( $ params ) { $ path = $ params [ 'path...
Calculates the web - accessible path to a static asset usually a JavaScript CSS or image file .
57,803
public static function filterAssetPath ( $ asset , $ path , array $ config , array $ options = [ ] ) { $ config += [ 'assets' => null ] ; if ( $ options [ 'check' ] || $ options [ 'timestamp' ] ) { $ file = static :: path ( $ asset , $ options [ 'type' ] , $ options ) ; } if ( $ options [ 'check' ] && ! is_file ( $ fil...
Performs checks and applies transformations to asset paths including verifying that the virtual path exists on the filesystem appending a timestamp prepending an asset host or applying a user - defined filter .
57,804
public static function view ( $ handler , $ data , & $ response = null , array $ options = [ ] ) { $ params = [ 'response' => & $ response ] + compact ( 'handler' , 'data' , 'options' ) ; return Filters :: run ( get_called_class ( ) , __FUNCTION__ , $ params , function ( $ params ) { $ handler = $ params [ 'handler' ] ...
Configures a template object instance based on a media handler configuration .
57,805
protected static function _types ( $ type = null ) { $ types = static :: $ _types + [ 'html' => [ 'text/html' , 'application/xhtml+xml' , '*/*' ] , 'htm' => [ 'alias' => 'html' ] , 'form' => [ 'application/x-www-form-urlencoded' , 'multipart/form-data' ] , 'json' => [ 'application/json' ] , 'rss' => [ 'application/rss+...
Helper method for listing registered media types . Returns all types or a single content type if a specific type is specified .
57,806
public static function handlers ( $ type = null ) { $ handlers = static :: $ _handlers + [ 'default' => [ 'view' => 'lithium\template\View' , 'encode' => false , 'decode' => false , 'cast' => false , 'paths' => [ 'template' => '{:library}/views/{:controller}/{:template}.{:type}.php' , 'layout' => '{:library}/views/layo...
Helper method for listing registered type handlers . Returns all handlers or the handler for a specific media type if requested .
57,807
protected static function _assets ( $ type = null ) { $ assets = static :: $ _assets + [ 'js' => [ 'suffix' => '.js' , 'filter' => null , 'paths' => [ '{:base}/{:library}/js/{:path}' => [ 'base' , 'library' , 'path' ] , '{:base}/js/{:path}' => [ 'base' , 'path' ] ] ] , 'css' => [ 'suffix' => '.css' , 'filter' => null ,...
Helper method to list all asset paths or the path for a single type .
57,808
public static function attach ( $ name , $ config = null ) { if ( ! isset ( static :: $ _scopes ) ) { static :: _initScopes ( ) ; } if ( $ name === false ) { $ name = '__defaultScope__' ; } if ( is_array ( $ config ) || $ config === false ) { static :: $ _scopes -> set ( $ name , $ config ) ; } }
Attach a scope to a mount point .
57,809
protected function _init ( ) { if ( $ this -> isStarted ( ) ) { return true ; } $ config = $ this -> _config ; unset ( $ config [ 'adapter' ] , $ config [ 'strategies' ] , $ config [ 'filters' ] , $ config [ 'init' ] ) ; foreach ( $ config as $ key => $ value ) { if ( strpos ( $ key , 'session.' ) === false ) { continu...
Initialization of the session .
57,810
public function check ( $ key , array $ options = [ ] ) { if ( ! $ this -> isStarted ( ) && ! $ this -> _start ( ) ) { throw new RuntimeException ( 'Could not start session.' ) ; } return function ( $ params ) { return Set :: check ( $ _SESSION , $ params [ 'key' ] ) ; } ; }
Checks if a value has been set in the session .
57,811
public function overwrite ( & $ old , $ new ) { if ( ! empty ( $ old ) ) { foreach ( $ old as $ key => $ value ) { if ( ! isset ( $ new [ $ key ] ) ) { unset ( $ old [ $ key ] ) ; } } } foreach ( $ new as $ key => $ value ) { $ old [ $ key ] = $ value ; } return true ; }
Overwrites session keys and values .
57,812
public function template ( $ type , array $ params ) { $ library = Libraries :: get ( isset ( $ params [ 'library' ] ) ? $ params [ 'library' ] : true ) ; $ params [ 'library' ] = $ library [ 'path' ] ; $ path = $ this -> _paths ( $ type , $ params ) ; if ( $ this -> _compile ) { $ compiler = $ this -> _classes [ 'comp...
Returns a template file name
57,813
protected function _paths ( $ type , array $ params ) { if ( ! isset ( $ this -> _paths [ $ type ] ) ) { throw new TemplateException ( "Invalid template type '{$type}'." ) ; } foreach ( ( array ) $ this -> _paths [ $ type ] as $ path ) { if ( ! file_exists ( $ path = Text :: insert ( $ path , $ params ) ) ) { continue ...
Searches one or more path templates for a matching template file and returns the file name .
57,814
public static function enabled ( $ feature = null ) { if ( ! $ feature ) { return extension_loaded ( 'pdo_sqlite' ) ; } $ features = [ 'arrays' => false , 'transactions' => false , 'booleans' => true , 'schema' => true , 'relationships' => true , 'sources' => true ] ; return isset ( $ features [ $ feature ] ) ? $ featu...
Check for required PHP extension or supported database feature .
57,815
public function describe ( $ entity , $ fields = [ ] , array $ meta = [ ] ) { $ params = compact ( 'entity' , 'meta' , 'fields' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { extract ( $ params ) ; if ( $ fields ) { return $ this -> _instance ( 'schema' , compact ( 'fields' ) ) ;...
Gets the column schema for a given Sqlite3 table .
57,816
protected function _files ( $ category , $ locale , $ scope ) { $ path = $ this -> _config [ 'path' ] ; $ scope = $ scope ? : 'default' ; if ( ( $ pos = strpos ( $ category , 'Template' ) ) !== false ) { $ category = substr ( $ category , 0 , $ pos ) ; return [ "{$path}/{$category}_{$scope}.pot" ] ; } if ( $ category =...
Returns absolute paths to files according to configuration .
57,817
protected function _prepareForWrite ( array $ item ) { $ filter = function ( $ value ) use ( & $ filter ) { if ( is_array ( $ value ) ) { return array_map ( $ filter , $ value ) ; } $ value = strtr ( $ value , [ "\\'" => "'" , "\\\\" => "\\" , "\r\n" => "\n" ] ) ; $ value = addcslashes ( $ value , "\0..\37\\\"" ) ; ret...
Prepares an item before it is being written and escapes fields .
57,818
protected function _merge ( array $ data , array $ item ) { $ filter = function ( $ value ) use ( & $ filter ) { if ( is_array ( $ value ) ) { return array_map ( $ filter , $ value ) ; } return stripcslashes ( $ value ) ; } ; $ fields = [ 'id' , 'ids' , 'translated' , 'context' ] ; foreach ( $ fields as $ field ) { if ...
Merges an item into given data and unescapes fields .
57,819
public function parse ( $ request , array $ options = [ ] ) { $ defaults = [ 'url' => $ request -> url ] ; $ options += $ defaults ; $ url = '/' . trim ( $ options [ 'url' ] , '/' ) ; $ pattern = $ this -> _pattern ; if ( ! preg_match ( $ pattern , $ url , $ match ) ) { return false ; } foreach ( $ this -> _meta as $ k...
Attempts to parse a request object and determine its execution details .
57,820
public function match ( array $ options = [ ] ) { $ defaults = [ 'action' => 'index' , 'http:method' => 'GET' ] ; $ query = null ; if ( ! $ this -> _config [ 'continue' ] ) { $ options += $ defaults ; if ( isset ( $ options [ '?' ] ) ) { $ query = $ options [ '?' ] ; $ query = '?' . ( is_array ( $ query ) ? http_build_...
Matches a set of parameters against the route and returns a URL string if the route matches the parameters .
57,821
protected function _write ( $ options , $ defaults ) { $ template = $ this -> _template ; $ trimmed = true ; $ options += [ 'args' => '' ] ; foreach ( array_reverse ( $ this -> _keys , true ) as $ key ) { $ value = & $ options [ $ key ] ; $ pattern = isset ( $ this -> _subPatterns [ $ key ] ) ? ":{$this->_subPatterns[$...
Writes a set of URL options to this route s template string .
57,822
public function export ( ) { $ result = [ ] ; foreach ( $ this -> _autoConfig as $ key ) { if ( $ key === 'formatters' ) { continue ; } $ result [ $ key ] = $ this -> { '_' . $ key } ; } return $ result ; }
Exports the properties that make up the route to an array for debugging caching or introspection purposes .
57,823
public function compile ( ) { foreach ( $ this -> _params as $ key => $ value ) { if ( ! strpos ( $ key , ':' ) ) { continue ; } unset ( $ this -> _params [ $ key ] ) ; $ this -> _meta [ $ key ] = $ value ; } $ this -> _match = $ this -> _params ; if ( $ this -> _template === '/' || $ this -> _template === '' ) { $ thi...
Compiles URL templates into regular expression patterns for matching against request URLs and extracts template parameters into match - parameter arrays .
57,824
protected function _regex ( $ regex , $ param , $ token , $ prefix ) { if ( $ regex ) { $ this -> _subPatterns [ $ param ] = $ regex ; } elseif ( $ param == 'args' ) { $ regex = '.*' ; } else { $ regex = '[^\/]+' ; } $ req = $ param === 'args' || array_key_exists ( $ param , $ this -> _params ) ? '?' : '' ; if ( $ pref...
Generates a sub - expression capture group for a route regex using an optional user - supplied matching pattern .
57,825
protected function _basic ( $ request ) { $ users = $ this -> _config [ 'users' ] ; $ username = $ request -> env ( 'PHP_AUTH_USER' ) ; $ auth = $ this -> _classes [ 'auth' ] ; $ basic = $ auth :: encode ( $ username , $ request -> env ( 'PHP_AUTH_PW' ) ) ; $ encoded = [ 'response' => null ] ; if ( isset ( $ users [ $ ...
Handler for HTTP Basic Authentication
57,826
protected function _digest ( $ request ) { $ username = $ password = null ; $ auth = $ this -> _classes [ 'auth' ] ; $ data = $ auth :: decode ( $ request -> env ( 'PHP_AUTH_DIGEST' ) ) ; $ data [ 'realm' ] = $ this -> _config [ 'realm' ] ; $ data [ 'method' ] = $ request -> method ; $ users = $ this -> _config [ 'user...
Handler for HTTP Digest Authentication
57,827
public function first ( $ filter = null ) { if ( ! $ filter ) { return $ this -> rewind ( ) ; } foreach ( $ this as $ item ) { if ( $ filter ( $ item ) ) { return $ item ; } } }
Rewinds the collection and returns the first item or when a filter is used returns the first non - empty item after the filter is applied .
57,828
public function append ( $ value ) { is_object ( $ value ) ? $ this -> _data [ ] = & $ value : $ this -> _data [ ] = $ value ; }
Appends an item .
57,829
public function bind ( $ response ) { $ this -> _response = $ response ; $ this -> _response -> headers += $ this -> _headers ; foreach ( $ this -> _queue as $ message ) { $ this -> _write ( $ message ) ; } }
Binds the response object to the logger and sets the required Wildfire protocol headers .
57,830
public function write ( $ priority , $ message ) { return function ( $ params ) { $ priority = $ params [ 'priority' ] ; $ message = $ params [ 'message' ] ; $ message = $ this -> _format ( $ priority , $ message ) ; $ this -> _write ( $ message ) ; return true ; } ; }
Appends a log message to the response header for FirePHP .
57,831
protected function _write ( $ message ) { if ( ! $ this -> _response ) { return $ this -> _queue [ ] = $ message ; } $ this -> _response -> headers [ $ message [ 'key' ] ] = $ message [ 'content' ] ; }
Helper method that writes the message to the header of a bound Response object . If no Response object is bound when this method is called it is stored in a message queue .
57,832
protected function _format ( $ type , $ message ) { $ key = 'X-Wf-1-1-1-' . $ this -> _counter ++ ; $ content = [ [ 'Type' => $ this -> _levels [ $ type ] ] , $ message ] ; $ content = json_encode ( $ content ) ; $ content = strlen ( $ content ) . '|' . $ content . '|' ; return compact ( 'key' , 'content' ) ; }
Generates a string representation of the type and message suitable for FirePHP .
57,833
public static function diff ( array $ val1 , array $ val2 ) { if ( ! $ val1 || ! $ val2 ) { return $ val2 ? : $ val1 ; } $ out = [ ] ; foreach ( $ val1 as $ key => $ val ) { $ exists = isset ( $ val2 [ $ key ] ) ; if ( ( $ exists && $ val2 [ $ key ] !== $ val ) || ! $ exists ) { $ out [ $ key ] = $ val ; } unset ( $ va...
Computes the difference between two arrays .
57,834
public static function expand ( array $ data , array $ options = [ ] ) { $ defaults = [ 'separator' => '.' ] ; $ options += $ defaults ; $ result = [ ] ; foreach ( $ data as $ key => $ val ) { if ( strpos ( $ key , $ options [ 'separator' ] ) === false ) { if ( ! isset ( $ result [ $ key ] ) ) { $ result [ $ key ] = $ ...
Accepts a one - dimensional array where the keys are separated by a delimiter .
57,835
public static function format ( $ data , $ format , $ keys ) { $ extracted = [ ] ; $ count = count ( $ keys ) ; if ( ! $ count ) { return ; } for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { $ extracted [ ] = static :: extract ( $ data , $ keys [ $ i ] ) ; } $ out = [ ] ; $ data = $ extracted ; $ count = count ( $ data [ 0 ]...
Returns a series of values extracted from an array formatted in a format string .
57,836
public static function isNumeric ( $ array = null ) { if ( empty ( $ array ) ) { return null ; } if ( $ array === range ( 0 , count ( $ array ) - 1 ) ) { return true ; } $ numeric = true ; $ keys = array_keys ( $ array ) ; $ count = count ( $ keys ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( ! is_numeric ( $ arr...
Checks to see if all the values in the array are numeric .
57,837
public static function matches ( $ data , $ conditions , $ i = null , $ length = null ) { if ( ! $ conditions ) { return true ; } if ( is_string ( $ conditions ) ) { return ( boolean ) static :: extract ( $ data , $ conditions ) ; } foreach ( $ conditions as $ condition ) { if ( $ condition === ':last' ) { if ( $ i !==...
This function can be used to see if a single item or a given XPath match certain conditions .
57,838
public static function normalize ( $ list , $ assoc = true , $ sep = ',' , $ trim = true ) { if ( is_string ( $ list ) ) { $ list = explode ( $ sep , $ list ) ; $ list = ( $ trim ) ? array_map ( 'trim' , $ list ) : $ list ; return ( $ assoc ) ? static :: normalize ( $ list ) : $ list ; } if ( ! is_array ( $ list ) ) { ...
Normalizes a string or array list .
57,839
public static function sort ( $ data , $ path , $ dir = 'asc' ) { $ flatten = function ( $ flatten , $ results , $ key = null ) { $ stack = [ ] ; foreach ( ( array ) $ results as $ k => $ r ) { $ id = $ k ; if ( $ key !== null ) { $ id = $ key ; } if ( is_array ( $ r ) ) { $ stack = array_merge ( $ stack , $ flatten ( ...
Sorts an array by any value determined by a Set - compatible path .
57,840
public function open ( array $ options = [ ] ) { parent :: open ( $ options ) ; $ config = $ this -> _config ; if ( ! $ config [ 'scheme' ] || ! $ config [ 'host' ] ) { return false ; } $ scheme = ( $ config [ 'scheme' ] !== 'udp' ) ? 'tcp' : 'udp' ; $ port = $ config [ 'port' ] ? : 80 ; $ host = "{$scheme}://{$config[...
Opens a socket and initializes the internal resource handle .
57,841
public function read ( $ length = null , $ offset = null ) { if ( ! is_resource ( $ this -> _resource ) ) { return false ; } if ( ! $ length ) { return stream_get_contents ( $ this -> _resource ) ; } return stream_get_contents ( $ this -> _resource , $ length , $ offset ) ; }
Reads data from the stream resource
57,842
public function write ( $ data = null ) { if ( ! is_resource ( $ this -> _resource ) ) { return false ; } if ( ! is_object ( $ data ) ) { $ data = $ this -> _instance ( $ this -> _classes [ 'request' ] , ( array ) $ data + $ this -> _config ) ; } return fwrite ( $ this -> _resource , ( string ) $ data , strlen ( ( stri...
writes data to the stream resource
57,843
public function encoding ( $ charset ) { if ( ! function_exists ( 'stream_encoding' ) ) { return false ; } return is_resource ( $ this -> _resource ) ? stream_encoding ( $ this -> _resource , $ charset ) : false ; }
Sets the character set for stream encoding if possible . The stream_encoding function is not guaranteed to be available as it is seems as if it s experimental or just not officially documented . If the function is not available returns false .
57,844
public function sync ( $ id = null , array $ data = [ ] , array $ options = [ ] ) { $ defaults = [ 'recursive' => true ] ; $ options += $ defaults ; if ( ! $ options [ 'recursive' ] ) { return parent :: sync ( $ id , $ data , $ options ) ; } foreach ( $ this -> _updated as $ key => $ val ) { if ( is_object ( $ val ) &&...
Extends the parent implementation to ensure that child documents are properly synced as well .
57,845
protected function _relation ( $ classType , $ key , $ data , $ options = [ ] ) { return parent :: _relation ( $ classType , $ key , $ data , [ 'exists' => false ] + $ options ) ; }
Instantiates a new Document object as a descendant of the current object and sets all default values and internal state .
57,846
public function set ( array $ data , array $ options = [ ] ) { $ defaults = [ 'init' => false ] ; $ options += $ defaults ; $ cast = ( $ schema = $ this -> schema ( ) ) ; foreach ( $ data as $ key => $ val ) { unset ( $ this -> _increment [ $ key ] ) ; if ( strpos ( $ key , '.' ) ) { $ this -> _setNested ( $ key , $ va...
Allows several properties to be assigned at once .
57,847
public function rewind ( ) { reset ( $ this -> _data ) ; reset ( $ this -> _updated ) ; $ this -> _valid = ( count ( $ this -> _updated ) > 0 ) ; return current ( $ this -> _updated ) ; }
Rewinds to the first item .
57,848
protected function _init ( ) { parent :: _init ( ) ; $ this -> library = $ this -> library ? : true ; $ defaults = [ 'prefix' => null , 'path' => null ] ; $ this -> _library = ( array ) Libraries :: get ( $ this -> library ) + $ defaults ; }
Class initializer . Parses template and sets up params that need to be filled .
57,849
protected function _execute ( $ command ) { try { if ( ! $ class = $ this -> _instance ( $ command ) ) { return false ; } } catch ( ClassNotFoundException $ e ) { return false ; } $ data = [ ] ; $ params = $ class -> invokeMethod ( '_params' ) ; foreach ( $ params as $ param ) { $ data [ $ param ] = $ class -> invokeMe...
Execute the given sub - command for the current request .
57,850
protected function _default ( $ name ) { $ commands = [ [ 'model' , $ name ] , [ 'controller' , $ name ] , [ 'test' , 'model' , $ name ] , [ 'test' , 'controller' , $ name ] ] ; foreach ( $ commands as $ args ) { $ command = $ this -> template = $ this -> request -> params [ 'command' ] = array_shift ( $ args ) ; $ thi...
Run through the default set . model controller test model test controller
57,851
protected function _namespace ( $ request , $ options = [ ] ) { $ name = $ request -> command ; $ defaults = [ 'prefix' => $ this -> _library [ 'prefix' ] , 'prepend' => null , 'spaces' => [ 'model' => 'models' , 'view' => 'views' , 'controller' => 'controllers' , 'command' => 'extensions.command' , 'adapter' => 'exten...
Get the namespace .
57,852
protected function _template ( ) { $ file = Libraries :: locate ( 'command.create.template' , $ this -> template , [ 'filter' => false , 'type' => 'file' , 'suffix' => '.txt.php' ] ) ; if ( ! $ file || is_array ( $ file ) ) { return false ; } return file_get_contents ( $ file ) ; }
Returns the contents of the template .
57,853
protected function _instance ( $ name , array $ config = [ ] ) { if ( $ class = Libraries :: locate ( 'command.create' , Inflector :: camelize ( $ name ) ) ) { $ this -> request -> params [ 'template' ] = $ this -> template ; return new $ class ( [ 'request' => $ this -> request , 'classes' => $ this -> _classes ] ) ; ...
Get an instance of a sub - command
57,854
public function map ( $ map = null ) { if ( $ map !== null ) { $ this -> _map = $ map ; return $ this ; } return $ this -> _map ; }
Generates a schema map of the query s result set where the keys are aliases and the values are arrays of field names .
57,855
public function calculate ( $ calculate = null ) { if ( $ calculate ) { $ this -> _config [ 'calculate' ] = $ calculate ; return $ this ; } return $ this -> _config [ 'calculate' ] ; }
Accessor method for Query calculate values .
57,856
public function model ( $ model = null ) { if ( ! $ model ) { return $ this -> _config [ 'model' ] ; } $ this -> _config [ 'model' ] = $ model ; $ this -> _config [ 'source' ] = $ this -> _config [ 'source' ] ? : $ model :: meta ( 'source' ) ; return $ this ; }
Set or get the associated model .
57,857
public function conditions ( $ conditions = null ) { if ( ! $ conditions ) { return $ this -> _config [ 'conditions' ] ? : $ this -> _entityConditions ( ) ; } $ this -> _config [ 'conditions' ] = array_merge ( ( array ) $ this -> _config [ 'conditions' ] , ( array ) $ conditions ) ; return $ this ; }
Set or append to existing conditions or get current conditions .
57,858
public function having ( $ having = null ) { if ( ! $ having ) { return $ this -> _config [ 'having' ] ; } $ this -> _config [ 'having' ] = array_merge ( ( array ) $ this -> _config [ 'having' ] , ( array ) $ having ) ; return $ this ; }
Set and get _having_ .
57,859
public function fields ( $ fields = null , $ overwrite = false ) { if ( $ fields === false || $ overwrite ) { $ this -> _fields = [ 0 => [ ] , 1 => [ ] ] ; } if ( $ fields === null ) { return array_merge ( array_keys ( $ this -> _fields [ 1 ] ) , $ this -> _fields [ 0 ] ) ; } if ( ! $ fields ) { return $ this ; } forea...
Set get or reset fields option for query .
57,860
public function limit ( $ limit = null ) { if ( $ limit ) { $ this -> _config [ 'limit' ] = ( integer ) $ limit ; return $ this ; } if ( $ limit === false ) { $ this -> _config [ 'limit' ] = null ; return $ this ; } return $ this -> _config [ 'limit' ] ; }
Set or get the limit for the amount of results to return .
57,861
public function offset ( $ offset = null ) { if ( $ offset !== null ) { $ this -> _config [ 'offset' ] = ( integer ) $ offset ; return $ this ; } return $ this -> _config [ 'offset' ] ; }
Set and get method for query s offset i . e . which records to get
57,862
public function page ( $ page = null ) { if ( $ page ) { $ this -> _config [ 'page' ] = $ page = ( ( integer ) $ page ? : 1 ) ; $ this -> offset ( ( $ page - 1 ) * $ this -> _config [ 'limit' ] ) ; return $ this ; } return $ this -> _config [ 'page' ] ; }
Set and get method for page in relation to limit of which records to get
57,863
public function order ( $ order = null ) { if ( $ order ) { $ this -> _config [ 'order' ] = $ order ; return $ this ; } return $ this -> _config [ 'order' ] ; }
Set and get method for the query s order specification .
57,864
public function group ( $ group = null ) { if ( $ group ) { $ this -> _config [ 'group' ] = $ group ; return $ this ; } if ( $ group === false ) { $ this -> _config [ 'group' ] = null ; return $ this ; } return $ this -> _config [ 'group' ] ; }
Set and get method for the Query group config setting .
57,865
public function comment ( $ comment = null ) { if ( $ comment ) { $ this -> _config [ 'comment' ] = $ comment ; return $ this ; } return $ this -> _config [ 'comment' ] ; }
Set and get method for current query s comment .
57,866
public function data ( $ data = [ ] ) { $ bind = & $ this -> _entity ; if ( $ data ) { $ bind ? $ bind -> set ( $ data ) : $ this -> _data = array_merge ( $ this -> _data , $ data ) ; return $ this ; } $ data = $ bind ? $ bind -> data ( ) : $ this -> _data ; return ( $ list = $ this -> _config [ 'whitelist' ] ) ? array...
Set and get method for the query s record s data .
57,867
public function relationships ( $ relpath = null , $ config = null ) { if ( $ config ) { if ( ! $ relpath ) { throw new InvalidArgumentException ( "The relation dotted path is empty." ) ; } if ( isset ( $ config [ 'model' ] ) && isset ( $ config [ 'alias' ] ) ) { $ this -> _models [ $ config [ 'alias' ] ] = $ config [ ...
Set and get the relationships .
57,868
public function joins ( $ name = null , $ join = null ) { if ( is_array ( $ name ) ) { $ join = $ name ; $ name = null ; } if ( $ join ) { if ( ! $ name ) { $ this -> _config [ 'joins' ] [ ] = $ join ; } else { $ this -> _config [ 'joins' ] [ $ name ] = $ join ; } return $ this ; } if ( ! $ name ) { return $ this -> _c...
Set and get the joins
57,869
public function export ( Source $ source , array $ options = [ ] ) { $ defaults = [ 'keys' => [ ] ] ; $ options += $ defaults ; if ( $ options [ 'keys' ] ) { $ keys = array_flip ( $ options [ 'keys' ] ) ; } else { $ keys = & $ this -> _config ; } list ( $ copy , $ apply ) = Set :: slice ( $ keys , $ source -> methods (...
Convert the query s properties to the data sources syntax and return it as an array .
57,870
public function paths ( Source $ source = null ) { if ( $ source ) { $ this -> applyStrategy ( $ source ) ; } return $ this -> _paths ; }
Return the generated aliases mapped to their relation path
57,871
public function models ( Source $ source = null ) { if ( $ source ) { $ this -> applyStrategy ( $ source ) ; } return $ this -> _models ; }
Return the generated aliases mapped to their corresponding model
57,872
protected function _entityConditions ( ) { if ( ! $ this -> _entity || ! ( $ model = $ this -> _config [ 'model' ] ) ) { return [ ] ; } $ key = $ model :: key ( $ this -> _entity -> data ( ) ) ; if ( ! $ key && $ this -> type ( ) !== 'create' ) { throw new ConfigException ( 'No matching primary key found.' ) ; } if ( i...
Will return a find first condition on the associated model if a record is connected . Called by conditions when it is called as a get and no condition is set .
57,873
public function offsetExists ( $ offset ) { $ offset = ( ! $ offset || $ offset === true ) ? 0 : $ offset ; $ this -> offsetGet ( $ offset ) ; if ( in_array ( $ offset , $ this -> _index ) ) { return true ; } return false ; }
Checks to see if a record with the given index key is in the record set . If the record cannot be found and not all records have been loaded into the set it will continue loading records until either all available records have been loaded or a matching key has been found .
57,874
protected function _keyIndex ( ) { if ( ! ( $ model = $ this -> _model ) || ! isset ( $ this -> _columns [ '' ] ) ) { return [ ] ; } $ index = 0 ; foreach ( $ this -> _columns as $ name => $ fields ) { if ( $ name === '' ) { $ flip = array_flip ( $ fields ) ; $ keys = array_flip ( $ model :: meta ( 'key' ) ) ; $ keys =...
Extracts the numerical indices of the primary keys in numerical indexed row data . Works only for the main row data and not for relationship rows .
57,875
public static function token ( $ string , array $ options = [ ] ) { $ defaults = [ 'id' => false ] ; $ options += $ defaults ; if ( empty ( $ string ) && $ string !== '0' ) { return false ; } list ( $ token ) = static :: tokenize ( $ string ) ; return $ token [ ( $ options [ 'id' ] ) ? 'id' : 'name' ] ; }
Convenience method to get the token name of a PHP code string . If multiple tokens are present in the string only the first is returned .
57,876
public static function match ( $ code , $ parameters , array $ options = [ ] ) { $ defaults = [ 'ignore' => [ 'T_WHITESPACE' ] , 'return' => true ] ; $ options += $ defaults ; $ parameters = static :: _prepareMatchParams ( $ parameters ) ; $ tokens = is_array ( $ code ) ? $ code : static :: tokenize ( $ code , $ option...
Token pattern matching .
57,877
public static function matchToken ( $ pattern , $ token ) { if ( $ pattern [ 'name' ] !== $ token [ 'name' ] ) { return false ; } if ( ! isset ( $ pattern [ 'content' ] ) ) { return true ; } $ match = $ pattern [ 'content' ] ; $ content = $ token [ 'content' ] ; if ( $ pattern [ 'name' ] === 'T_VARIABLE' ) { $ match = ...
Compares two PHP language tokens .
57,878
protected static function _prepareMatchParams ( $ parameters ) { foreach ( Set :: normalize ( $ parameters ) as $ token => $ scope ) { if ( strpos ( $ token , 'T_' ) !== 0 ) { unset ( $ parameters [ $ token ] ) ; foreach ( [ 'before' , 'after' ] as $ key ) { if ( ! isset ( $ scope [ $ key ] ) ) { continue ; } $ items =...
Helper function to normalize parameters for token matching .
57,879
public static function info ( $ identifier , $ info = [ ] ) { $ info = $ info ? : array_keys ( static :: $ _methodMap ) ; $ type = static :: type ( $ identifier ) ; $ result = [ ] ; $ class = null ; if ( $ type === 'method' || $ type === 'property' ) { list ( $ class , $ identifier ) = explode ( '::' , $ identifier ) ;...
Detailed source code identifier analysis .
57,880
public static function executable ( $ class , array $ options = [ ] ) { $ defaults = [ 'self' => true , 'filter' => true , 'methods' => [ ] , 'empty' => [ ' ' , "\t" , '}' , ')' , ';' ] , 'pattern' => null , 'blockOpeners' => [ 'switch (' , 'try {' , '} else {' , 'do {' , '} while' ] ] ; $ options += $ defaults ; if ( ...
Gets the executable lines of a class by examining the start and end lines of each method .
57,881
public static function methods ( $ class , $ format = null , array $ options = [ ] ) { $ defaults = [ 'methods' => [ ] , 'group' => true , 'self' => true ] ; $ options += $ defaults ; if ( ! ( is_object ( $ class ) && $ class instanceof ReflectionClass ) ) { try { $ class = new ReflectionClass ( $ class ) ; } catch ( R...
Returns various information on the methods of an object in different formats .
57,882
public static function properties ( $ class , array $ options = [ ] ) { $ defaults = [ 'properties' => [ ] , 'self' => true ] ; $ options += $ defaults ; try { $ reflClass = new ReflectionClass ( $ class ) ; } catch ( ReflectionException $ e ) { return null ; } $ options += [ 'names' => $ options [ 'properties' ] ] ; r...
Returns various information on the properties of an object .
57,883
public static function parents ( $ class , array $ options = [ ] ) { $ defaults = [ 'autoLoad' => false ] ; $ options += $ defaults ; $ class = is_object ( $ class ) ? get_class ( $ class ) : $ class ; if ( ! class_exists ( $ class , $ options [ 'autoLoad' ] ) ) { return false ; } return class_parents ( $ class ) ; }
Gets the full inheritance list for the given class .
57,884
public static function classes ( array $ options = [ ] ) { $ defaults = [ 'group' => 'classes' , 'file' => null ] ; $ options += $ defaults ; $ list = get_declared_classes ( ) ; $ files = get_included_files ( ) ; $ classes = [ ] ; if ( $ file = $ options [ 'file' ] ) { $ loaded = static :: _instance ( 'collection' , [ ...
Gets an array of classes and their corresponding definition files or examines a file and returns the classes it defines .
57,885
public static function dependencies ( $ classes , array $ options = [ ] ) { $ defaults = [ 'type' => null ] ; $ options += $ defaults ; $ static = $ dynamic = [ ] ; $ trim = function ( $ c ) { return trim ( trim ( $ c , '\\' ) ) ; } ; $ join = function ( $ i ) { return join ( '' , $ i ) ; } ; foreach ( ( array ) $ clas...
Gets the static and dynamic dependencies for a class or group of classes .
57,886
protected static function _items ( $ class , $ method , $ options ) { $ defaults = [ 'names' => [ ] , 'self' => true , 'public' => true ] ; $ options += $ defaults ; $ params = [ 'getProperties' => ReflectionProperty :: IS_PUBLIC | ( $ options [ 'public' ] ? 0 : ReflectionProperty :: IS_PROTECTED ) ] ; $ data = isset (...
Helper method to get an array of ReflectionMethod or ReflectionProperty objects wrapped in a Collection object and filtered based on a set of options .
57,887
protected static function _modifiers ( $ inspector , $ list = [ ] ) { $ list = $ list ? : [ 'public' , 'private' , 'protected' , 'abstract' , 'final' , 'static' ] ; return array_filter ( $ list , function ( $ modifier ) use ( $ inspector ) { $ method = 'is' . ucfirst ( $ modifier ) ; return ( method_exists ( $ inspecto...
Helper method to determine if a class applies to a list of modifiers .
57,888
public static function config ( $ config = null ) { $ defaults = [ 'scope' => null ] ; if ( is_array ( $ config ) ) { foreach ( $ config as $ i => $ item ) { $ config [ $ i ] += $ defaults ; } } return parent :: config ( $ config ) ; }
Sets configurations for this Adaptable implementation .
57,889
public static function is ( $ string , array $ options = [ ] ) { $ defaults = [ 'quick' => false ] ; $ options += $ defaults ; if ( $ options [ 'quick' ] ) { $ regex = '/[^\x09\x0A\x0D\x20-\x7E]/m' ; } else { $ regex = '/\A(' ; $ regex .= '[\x09\x0A\x0D\x20-\x7E]' ; $ regex .= '|[\xC2-\xDF][\x80-\xBF]' ; $ regex .= '|\...
Checks if a given string is UTF - 8 encoded and is valid UTF - 8 .
57,890
public function offsetSet ( $ offset , $ data ) { $ this -> offsetGet ( $ offset ) ; return $ this -> _set ( $ data , $ offset ) ; }
Adds the specified object to the Collection instance and assigns associated metadata to the added object .
57,891
public function rewind ( ) { $ this -> _started = true ; reset ( $ this -> _data ) ; $ this -> _valid = ! empty ( $ this -> _data ) || $ this -> _populate ( ) !== null ; return current ( $ this -> _data ) ; }
Rewinds the collection to the beginning .
57,892
public function key ( $ full = false ) { if ( $ this -> _started === false ) { $ this -> current ( ) ; } if ( $ this -> _valid ) { $ key = key ( $ this -> _data ) ; return ( is_array ( $ key ) && ! $ full ) ? reset ( $ key ) : $ key ; } return null ; }
Returns the currently pointed to record s unique key .
57,893
public function reduce ( $ filter , $ initial = false ) { if ( ! $ this -> closed ( ) ) { while ( $ this -> next ( ) ) { } } return parent :: reduce ( $ filter , $ initial ) ; }
Reduce or fold a collection down to a single value
57,894
public function sort ( $ field = 'id' , array $ options = [ ] ) { $ this -> offsetGet ( null ) ; if ( is_string ( $ field ) ) { $ sorter = function ( $ a , $ b ) use ( $ field ) { if ( is_array ( $ a ) ) { $ a = ( object ) $ a ; } if ( is_array ( $ b ) ) { $ b = ( object ) $ b ; } return strcmp ( $ a -> $ field , $ b -...
Sorts the objects in the collection useful in situations where you are already using the underlying datastore to sort results .
57,895
public function stats ( $ name = null ) { if ( $ name ) { return isset ( $ this -> _stats [ $ name ] ) ? $ this -> _stats [ $ name ] : null ; } return $ this -> _stats ; }
Gets the stat or stats associated with this Collection .
57,896
public function serialize ( ) { $ this -> offsetGet ( null ) ; static :: __destruct ( ) ; $ vars = get_object_vars ( $ this ) ; unset ( $ vars [ '_result' ] ) ; unset ( $ vars [ '_handlers' ] ) ; return serialize ( $ vars ) ; }
Prepares enables and executes serialization of the object .
57,897
public function unserialize ( $ data ) { $ vars = unserialize ( $ data ) ; parent :: _init ( ) ; foreach ( $ vars as $ key => $ value ) { $ this -> { $ key } = $ value ; } }
Prepares enables and executes unserialization of the object .
57,898
protected function _namespace ( $ request , $ options = [ ] ) { $ request -> params [ 'command' ] = $ request -> action ; return parent :: _namespace ( $ request , [ 'prepend' => 'tests.mocks.' ] ) ; }
Get the namespace for the mock .
57,899
protected function _class ( $ request ) { $ type = $ request -> action ; $ name = $ request -> args ( ) ; if ( $ command = $ this -> _instance ( $ type ) ) { $ request -> params [ 'action' ] = $ name ; $ name = $ command -> invokeMethod ( '_class' , [ $ request ] ) ; } return "Mock{$name}" ; }
Get the class name for the mock .