idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
57,900 | public function notify ( $ description = '' , $ options = [ ] ) { $ this -> _register ( ) ; $ defaults = [ 'sticky' => false , 'priority' => 0 , 'type' => 'Messages' ] ; $ options += $ defaults + [ 'title' => $ this -> _config [ 'title' ] ] ; $ type = $ options [ 'type' ] ; $ title = $ options [ 'title' ] ; $ message =... | Posts a new notification to the Growl server . |
57,901 | protected function _register ( ) { if ( $ this -> _registered ) { return true ; } $ ct = count ( $ this -> _config [ 'notifications' ] ) ; $ app = utf8_encode ( $ this -> _config [ 'name' ] ) ; $ nameEnc = $ defaultEnc = '' ; foreach ( $ this -> _config [ 'notifications' ] as $ i => $ name ) { $ name = utf8_encode ( $ ... | Growl server connection registration and initialization . |
57,902 | protected function _connection ( ) { if ( $ this -> _connection ) { return $ this -> _connection ; } $ host = "{$this->_config['protocol']}://{$this->_config['host']}" ; if ( $ this -> _connection = fsockopen ( $ host , $ this -> _config [ 'port' ] , $ message , $ code ) ) { return $ this -> _connection ; } throw new N... | Creates a connection to the Growl server using the protocol host and port configurations specified in the constructor . |
57,903 | protected function _send ( $ data ) { if ( fwrite ( $ this -> _connection ( ) , $ data , strlen ( $ data ) ) === false ) { throw new NetworkException ( 'Could not send registration to Growl Server.' ) ; } return true ; } | Sends binary data to the Growl server . |
57,904 | public function open ( array $ options = [ ] ) { $ this -> options = [ ] ; parent :: open ( $ options ) ; $ config = $ this -> _config ; if ( empty ( $ config [ 'scheme' ] ) || empty ( $ config [ 'host' ] ) ) { return false ; } if ( ! empty ( $ config [ 'options' ] ) ) { $ this -> set ( $ config [ 'options' ] ) ; } $ u... | Opens a curl connection and initializes the internal resource handle . |
57,905 | public function close ( ) { if ( ! is_resource ( $ this -> _resource ) ) { return true ; } curl_close ( $ this -> _resource ) ; return ! is_resource ( $ this -> _resource ) ; } | Closes the curl connection . |
57,906 | 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 ) ; } $ this -> set ( CURLOPT_URL , $ data -> to ( 'url' ) ) ; if ( $ data inst... | Writes data to curl options |
57,907 | public function timeout ( $ time ) { if ( ! is_resource ( $ this -> _resource ) ) { return false ; } return curl_setopt ( $ this -> _resource , CURLOPT_CONNECTTIMEOUT , $ time ) ; } | A convenience method to set the curl CURLOPT_CONNECTTIMEOUT setting for the current connection . This determines the number of seconds to wait while trying to connect . |
57,908 | public function set ( $ flags , $ value = null ) { if ( $ value !== null ) { $ flags = [ $ flags => $ value ] ; } $ this -> options = $ flags + $ this -> options ; } | Sets the options to be used in subsequent curl requests . |
57,909 | public function connect ( ) { if ( ! parent :: connect ( ) ) { return false ; } if ( $ this -> _config [ 'strict' ] !== null && ! $ this -> strict ( $ this -> _config [ 'strict' ] ) ) { return false ; } return true ; } | Connects to the database by creating a PDO intance using the constructed DSN string . Will set specific options on the connection as provided . |
57,910 | protected function _column ( $ real ) { if ( is_array ( $ real ) ) { return $ real [ 'type' ] . ( isset ( $ real [ 'length' ] ) ? "({$real['length']})" : '' ) ; } if ( ! preg_match ( '/(?P<type>\w+)(?:\((?P<length>[\d,]+)\))?/' , $ real , $ column ) ) { return $ real ; } $ column = array_intersect_key ( $ column , [ 't... | Converts database - layer column types to basic types . |
57,911 | protected function _addScopePrefix ( $ scope , array $ keys , $ separator = ':' ) { $ results = [ ] ; $ isMapped = ! is_int ( key ( $ keys ) ) ; foreach ( $ keys as $ key => $ value ) { if ( $ isMapped ) { $ results [ "{$scope}{$separator}{$key}" ] = $ value ; } else { $ results [ $ key ] = "{$scope}{$separator}{$value... | Adds scope prefix to keys using separator . |
57,912 | protected function _removeScopePrefix ( $ scope , array $ data , $ separator = ':' ) { $ results = [ ] ; $ prefix = strlen ( "{$scope}{$separator}" ) ; foreach ( $ data as $ key => $ value ) { $ results [ substr ( $ key , $ prefix ) ] = $ value ; } return $ results ; } | Removes scope prefix from keys . |
57,913 | public function run ( $ command = null ) { if ( ! $ command ) { $ this -> _renderCommands ( ) ; return true ; } if ( ! preg_match ( '/\\\\/' , $ command ) ) { $ command = Inflector :: camelize ( $ command ) ; } if ( ! $ class = Libraries :: locate ( 'command' , $ command ) ) { $ this -> error ( "Command `{$command}` no... | Auto run the help command . |
57,914 | public function api ( $ class = null , $ type = null , $ name = null ) { $ class = str_replace ( "." , "\\" , $ class ) ; switch ( $ type ) { default : $ info = Inspector :: info ( $ class ) ; $ result = [ 'class' => [ 'name' => $ info [ 'shortName' ] , 'description' => trim ( $ info [ 'description' ] . PHP_EOL . PHP_E... | Gets the API for the class . |
57,915 | protected function _methods ( $ class , $ options = [ ] ) { $ defaults = [ 'name' => null ] ; $ options += $ defaults ; $ map = function ( $ item ) { if ( $ item -> name [ 0 ] === '_' ) { return ; } $ modifiers = array_values ( Inspector :: invokeMethod ( '_modifiers' , [ $ item ] ) ) ; $ setAccess = array_intersect ( ... | Get the methods for the class . |
57,916 | protected function _properties ( $ class , $ options = [ ] ) { $ defaults = [ 'name' => null ] ; $ options += $ defaults ; $ properties = Inspector :: properties ( new $ class ( [ 'init' => false ] ) , [ 'self' => false ] ) ; $ results = [ ] ; foreach ( $ properties as & $ property ) { if ( $ property [ 'name' ] === 'r... | Get the properties for the class . |
57,917 | protected function _render ( $ params ) { foreach ( $ params as $ name => $ param ) { if ( $ name === 'run' || empty ( $ param [ 'name' ] ) ) { continue ; } $ usage = ( ! empty ( $ param [ 'usage' ] ) ) ? trim ( $ param [ 'usage' ] , ' []' ) : $ param [ 'name' ] ; $ this -> out ( $ this -> _pad ( $ usage ) , 'option' )... | Output the formatted properties or methods . |
57,918 | protected function _renderCommands ( ) { $ commands = Libraries :: locate ( 'command' , null , [ 'recursive' => false ] ) ; foreach ( $ commands as $ key => $ command ) { $ library = strtok ( $ command , '\\' ) ; if ( ! $ key || strtok ( $ commands [ $ key - 1 ] , '\\' ) != $ library ) { $ this -> out ( "{:heading}COMM... | Output the formatted available commands . |
57,919 | protected function _renderUsage ( $ command , $ method , $ properties = [ ] ) { $ params = array_reduce ( $ properties , function ( $ a , $ b ) { return "{$a} {$b['usage']}" ; } ) ; $ args = array_reduce ( $ method [ 'args' ] , function ( $ a , $ b ) { return "{$a} {$b['usage']}" ; } ) ; $ format = "{:command}li3 %s%s{... | Output the formatted usage . |
57,920 | protected function _renderDescription ( $ info ) { $ this -> out ( 'DESCRIPTION' , 'heading' ) ; $ break = PHP_EOL . PHP_EOL ; $ description = trim ( "{$info['description']}{$break}{$info['text']}" ) ; $ this -> out ( $ this -> _pad ( $ description ) , 2 ) ; } | Output the formatted command description . |
57,921 | protected function _init ( ) { parent :: _init ( ) ; if ( ! $ this -> _result ) { return ; } $ this -> _columns = $ this -> _columnMap ( ) ; if ( ! $ this -> _query ) { return ; } $ this -> _keyIndex = $ this -> _keyIndex ( ) ; $ this -> _dependencies = Set :: expand ( Set :: normalize ( array_filter ( array_keys ( $ t... | Initializes the record set and uses the database connection to get the column list contained in the query that created this object . |
57,922 | protected function _mapRecord ( $ row ) { $ main = array_intersect_key ( $ row , $ this -> _keyIndex ) ; if ( $ main ) { if ( in_array ( $ main , $ this -> _seen ) ) { $ message = 'Associated records hydrated out of order: ' ; $ message .= var_export ( $ this -> _seen , true ) ; throw new RuntimeException ( $ message )... | Converts a PDO Result array to a nested Record object . |
57,923 | protected function _hydrateRecord ( array $ relations , $ primary , array $ record , $ min , $ max , $ name ) { $ options = [ 'exists' => true , 'defaults' => false ] ; foreach ( $ relations as $ relation => $ subrelations ) { $ relName = $ name ? "{$name}.{$relation}" : $ relation ; $ relModel = $ this -> _relationshi... | Hydrates a 2 dimensional PDO row Result array recursively . |
57,924 | protected function _keyIndex ( ) { if ( ! ( $ model = $ this -> _model ) || ! isset ( $ this -> _columns [ '' ] ) ) { return [ ] ; } $ index = 0 ; foreach ( $ this -> _columns as $ name => $ fields ) { if ( $ name === '' ) { if ( ( $ offset = array_search ( $ model :: meta ( 'key' ) , $ fields ) ) === false ) { return ... | Extracts the numerical index of the primary key in numerical indexed row data . Works only for the main row data and not for relationship rows . |
57,925 | public function write ( $ data , array $ options = [ ] ) { $ class = $ options [ 'class' ] ; $ futureData = $ class :: read ( null , [ 'strategies' => false ] ) ; $ futureData = [ $ options [ 'key' ] => $ data ] + $ futureData ; unset ( $ futureData [ '__signature' ] ) ; $ signature = static :: _signature ( $ futureDat... | Write strategy method . |
57,926 | public function read ( $ data , array $ options = [ ] ) { if ( $ data === null ) { return $ data ; } $ class = $ options [ 'class' ] ; $ currentData = $ class :: read ( null , [ 'strategies' => false ] ) ; if ( ! isset ( $ currentData [ '__signature' ] ) ) { throw new MissingSignatureException ( 'HMAC signature not fou... | Read strategy method . |
57,927 | protected static function _signature ( $ data , $ secret = null ) { unset ( $ data [ '__signature' ] ) ; $ secret = ( $ secret ) ? : static :: $ _secret ; return hash_hmac ( 'sha1' , serialize ( $ data ) , $ secret ) ; } | Calculate the HMAC signature based on the data and a secret key . |
57,928 | public static function isStarted ( $ name = null ) { return is_object ( $ adapter = static :: adapter ( $ name ) ) ? $ adapter -> isStarted ( ) : false ; } | Indicates whether the the current request includes information on a previously started session . |
57,929 | public static function read ( $ key = null , array $ options = [ ] ) { $ defaults = [ 'name' => null , 'strategies' => true ] ; $ options += $ defaults ; $ method = ( $ name = $ options [ 'name' ] ) ? static :: adapter ( $ name ) -> read ( $ key , $ options ) : null ; $ settings = static :: _config ( $ name ) ; if ( ! ... | Reads a value from a persistent session store . |
57,930 | public static function adapter ( $ name = null ) { if ( ! $ name ) { if ( ! $ names = array_keys ( static :: $ _configurations ) ) { return ; } $ name = end ( $ names ) ; } return parent :: adapter ( $ name ) ; } | Returns the adapter object instance of the named configuration . |
57,931 | protected function _init ( ) { parent :: _init ( ) ; $ mobile = [ 'iPhone' , 'MIDP' , 'AvantGo' , 'BlackBerry' , 'J2ME' , 'Opera Mini' , 'DoCoMo' , 'NetFront' , 'Nokia' , 'PalmOS' , 'PalmSource' , 'portalmmm' , 'Plucker' , 'ReqwirelessWeb' , 'iPod' , 'SonyEricsson' , 'Symbian' , 'UP\.Browser' , 'Windows CE' , 'Xiino' ,... | Initializes request object by setting up mobile detectors determining method and populating the data property either by using i . e . form data or reading from STDIN in case binary data is streamed . Will merge any files posted in forms with parsed data . |
57,932 | public function accepts ( $ type = null ) { $ media = $ this -> _classes [ 'media' ] ; if ( $ type === true ) { return $ this -> _accept ? : ( $ this -> _accept = $ this -> _parseAccept ( ) ) ; } if ( $ type ) { return ( $ media :: negotiate ( $ this ) ? : 'html' ) === $ type ; } if ( isset ( $ this -> params [ 'type' ... | Returns information about the type of content that the client is requesting . |
57,933 | protected function _parseAccept ( ) { $ accept = $ this -> env ( 'HTTP_ACCEPT' ) ; $ accept = ( preg_match ( '/[a-z,-]/i' , $ accept ) ) ? explode ( ',' , $ accept ) : [ 'text/html' ] ; foreach ( array_reverse ( $ accept ) as $ i => $ type ) { unset ( $ accept [ $ i ] ) ; list ( $ type , $ q ) = ( explode ( ';q=' , $ t... | Parses the HTTP_ACCEPT information the requesting client sends and converts that data to an array for consumption by the rest of the framework . |
57,934 | public function referer ( $ default = null , $ local = false ) { if ( $ ref = $ this -> env ( 'HTTP_REFERER' ) ) { if ( ! $ local ) { return $ ref ; } $ url = parse_url ( $ ref ) + [ 'path' => '' ] ; if ( empty ( $ url [ 'host' ] ) || $ url [ 'host' ] === $ this -> env ( 'HTTP_HOST' ) ) { $ ref = $ url [ 'path' ] ; if ... | Gets the referring URL of this request . |
57,935 | protected function _base ( $ base = null ) { if ( $ base === null ) { $ base = preg_replace ( '/[^\/]+$/' , '' , $ this -> env ( 'PHP_SELF' ) ) ; } $ base = trim ( str_replace ( [ "/app/webroot" , '/webroot' ] , '' , $ base ) , '/' ) ; return $ base ? '/' . $ base : '' ; } | Find the base path of the current request . |
57,936 | protected function _url ( $ url = null ) { if ( $ url !== null ) { return '/' . trim ( $ url , '/' ) ; } elseif ( $ uri = $ this -> env ( 'REQUEST_URI' ) ) { list ( $ uri ) = explode ( '?' , $ uri , 2 ) ; $ base = '/^' . preg_quote ( $ this -> _base , '/' ) . '/' ; return '/' . trim ( preg_replace ( $ base , '' , $ uri... | Extract the url from REQUEST_URI && PHP_SELF environment variables . |
57,937 | public function requestToken ( array $ options = [ ] ) { $ defaults = [ 'name' => 'security.token' , 'id' => false ] ; $ options += $ defaults ; $ requestToken = $ this -> _classes [ 'requestToken' ] ; $ flags = array_intersect_key ( $ this -> _config , [ 'sessionKey' => '' , 'salt' => '' ] ) ; $ value = $ requestToken... | Generates a request key used to protect your forms against CSRF attacks . See the RequestToken class for examples and proper usage . |
57,938 | public function sign ( $ form = null ) { $ form = $ form ? : $ this -> _context -> form ; if ( isset ( $ state [ spl_object_hash ( $ form ) ] ) ) { return ; } Filters :: apply ( $ form , 'create' , function ( $ params , $ next ) use ( $ form ) { $ this -> _state [ spl_object_hash ( $ form ) ] = [ 'fields' => [ ] , 'loc... | Binds the Security helper to the Form helper to create a signature used to secure form fields against tampering . |
57,939 | protected function _init ( ) { $ config = [ 'classes' => $ this -> _classes ] + $ this -> _config ; try { $ this -> connection = Libraries :: instance ( 'socket' , $ config [ 'socket' ] , $ config ) ; } catch ( ClassNotFoundException $ e ) { $ this -> connection = null ; } $ this -> _responseTypes += [ 'headers' => fun... | Initialize connection . |
57,940 | public function post ( $ path = null , $ data = [ ] , array $ options = [ ] ) { return $ this -> send ( __FUNCTION__ , $ path , $ data , $ options ) ; } | Send POST request . |
57,941 | public function put ( $ path = null , $ data = [ ] , array $ options = [ ] ) { return $ this -> send ( __FUNCTION__ , $ path , $ data , $ options ) ; } | Send PUT request . |
57,942 | public function send ( $ method , $ path = null , $ data = [ ] , array $ options = [ ] ) { $ defaults = [ 'return' => 'body' ] ; $ options += $ defaults ; $ request = $ this -> _request ( $ method , $ path , $ data , $ options ) ; $ options += [ 'message' => $ request ] ; if ( ! $ this -> connection || ! $ this -> conn... | Send request and return response data . Will open the connection if needed and always close it after sending the request . |
57,943 | public function isConnected ( array $ options = [ ] ) { $ defaults = [ 'autoConnect' => false ] ; $ options += $ defaults ; if ( ! $ this -> _isConnected && $ options [ 'autoConnect' ] ) { try { $ this -> connect ( ) ; } catch ( NetworkException $ e ) { $ this -> _isConnected = false ; } } return $ this -> _isConnected... | Checks the connection status of this data source . If the autoConnect option is set to true and the source connection is not currently active a connection attempt will be made before returning the result of the connection status . |
57,944 | public function status ( $ key = null , $ status = null ) { if ( $ status === null ) { $ status = $ key ; } if ( $ status ) { $ this -> status = [ 'code' => null , 'message' => null ] ; if ( is_array ( $ status ) ) { $ key = null ; $ this -> status = $ status + $ this -> status ; } elseif ( is_numeric ( $ status ) && i... | Set and get the status for the response . |
57,945 | protected function _cookies ( ) { $ cookies = [ ] ; foreach ( $ this -> cookies ( ) as $ name => $ value ) { if ( ! isset ( $ value [ 'value' ] ) ) { foreach ( $ value as $ set ) { $ cookies [ ] = compact ( 'name' ) + $ set ; } } else { $ cookies [ ] = compact ( 'name' ) + $ value ; } } $ invalid = str_split ( ",; \+\t... | Render Set - Cookie headers urlencoding invalid characters . |
57,946 | protected function _parseMessage ( $ body ) { if ( ! ( $ parts = explode ( "\r\n\r\n" , $ body , 2 ) ) || count ( $ parts ) === 1 ) { return trim ( $ body ) ; } list ( $ headers , $ body ) = $ parts ; $ headers = str_replace ( "\r" , "" , explode ( "\n" , $ headers ) ) ; if ( array_filter ( $ headers ) === [ ] ) { retu... | Accepts an entire HTTP message including headers and body and parses it into a message body an array of headers and the HTTP status . |
57,947 | protected function _parseCookies ( $ headers ) { foreach ( ( array ) $ headers as $ header ) { $ parts = array_map ( 'trim' , array_filter ( explode ( '; ' , $ header ) ) ) ; $ cookie = array_shift ( $ parts ) ; list ( $ name , $ value ) = array_map ( 'urldecode' , explode ( '=' , $ cookie , 2 ) ) + [ '' , '' ] ; $ opt... | Parse Set - Cookie headers . |
57,948 | protected function _httpChunkedDecode ( $ body ) { if ( stripos ( $ this -> headers ( 'Transfer-Encoding' ) , 'chunked' ) === false ) { return $ body ; } $ stream = fopen ( 'data://text/plain;base64,' . base64_encode ( $ body ) , 'r' ) ; stream_filter_append ( $ stream , 'dechunk' ) ; return trim ( stream_get_contents ... | Decodes content bodies transferred with HTTP chunked encoding . |
57,949 | public function headers ( $ key = null , $ value = null , $ replace = true ) { if ( $ key === null && $ value === null ) { $ headers = [ ] ; foreach ( $ this -> headers as $ key => $ value ) { if ( is_scalar ( $ value ) ) { $ headers [ ] = "{$key}: {$value}" ; continue ; } foreach ( $ value as $ val ) { $ headers [ ] =... | Adds gets or removes one or multiple headers at the same time . |
57,950 | public function body ( $ data = null , $ options = [ ] ) { $ default = [ 'buffer' => null , 'encode' => false , 'decode' => false ] ; $ options += $ default ; if ( $ data !== null ) { $ this -> body = array_merge ( ( array ) $ this -> body , ( array ) $ data ) ; } $ body = $ this -> body ; if ( empty ( $ options [ 'buf... | Add data to and compile the HTTP message body optionally encoding or decoding its parts according to content type . |
57,951 | protected function _encode ( $ body ) { $ media = $ this -> _classes [ 'media' ] ; if ( $ media :: type ( $ this -> _type ) ) { $ encoded = $ media :: encode ( $ this -> _type , $ body ) ; $ body = $ encoded !== null ? $ encoded : $ body ; } return $ body ; } | Encode the body based on the content type |
57,952 | protected function _decode ( $ body ) { $ media = $ this -> _classes [ 'media' ] ; if ( $ media :: type ( $ this -> _type ) ) { $ decoded = $ media :: decode ( $ this -> _type , $ body ) ; $ body = $ decoded !== null ? $ decoded : $ body ; } return $ body ; } | Decode the body based on the content type |
57,953 | protected function _readMessageTemplate ( $ path ) { $ base = new RecursiveDirectoryIterator ( $ path ) ; $ iterator = new RecursiveIteratorIterator ( $ base ) ; $ data = [ ] ; foreach ( $ iterator as $ item ) { $ file = $ item -> getPathname ( ) ; switch ( pathinfo ( $ file , PATHINFO_EXTENSION ) ) { case 'php' : $ da... | Extracts data from files within configured path recursively . |
57,954 | protected function _merge ( array $ data , array $ item ) { $ filter = function ( $ value ) use ( & $ filter ) { if ( is_array ( $ value ) ) { return array_map ( $ filter , $ value ) ; } return substr ( $ value , 1 , - 1 ) ; } ; $ fields = [ 'id' , 'ids' , 'translated' , 'context' ] ; foreach ( $ fields as $ field ) { ... | Merges an item into given data and removes quotation marks from the beginning and end of message strings . |
57,955 | public function & __get ( $ name ) { if ( isset ( $ this -> _relationships [ $ name ] ) ) { return $ this -> _relationships [ $ name ] ; } if ( isset ( $ this -> _updated [ $ name ] ) ) { return $ this -> _updated [ $ name ] ; } $ null = null ; return $ null ; } | Overloading for reading inaccessible properties . |
57,956 | public function errors ( $ field = null , $ value = null ) { if ( $ field === false ) { return ( $ this -> _errors = [ ] ) ; } if ( $ field === null ) { return $ this -> _errors ; } if ( is_array ( $ field ) ) { return ( $ this -> _errors = array_merge_recursive ( $ this -> _errors , $ field ) ) ; } if ( $ value === nu... | Access the errors of the record . |
57,957 | public function modified ( $ field = null ) { if ( $ field ) { if ( ! isset ( $ this -> _updated [ $ field ] ) && ! isset ( $ this -> _data [ $ field ] ) ) { return null ; } if ( ! array_key_exists ( $ field , $ this -> _updated ) ) { return false ; } $ value = $ this -> _updated [ $ field ] ; if ( is_object ( $ value ... | Gets the current state for a given field or if no field is given gets the array of fields modified on this entity . |
57,958 | public function write ( $ priority , $ message ) { $ config = $ this -> _config + $ this -> _classes ; return function ( $ params ) use ( $ config ) { $ params += [ 'timestamp' => strtotime ( 'now' ) ] ; $ key = $ config [ 'key' ] ; $ key = is_callable ( $ key ) ? $ key ( $ params ) : Text :: insert ( $ key , $ params ... | Writes the message to the configured cache adapter . |
57,959 | protected function _init ( ) { parent :: _init ( ) ; $ req = & $ this -> _request ; $ ctx = & $ this -> _context ; $ classes = & $ this -> _classes ; $ h = $ this -> _view ? $ this -> _view -> outputFilters [ 'h' ] : null ; $ this -> _handlers += [ 'url' => function ( $ url , $ ref , array $ options = [ ] ) use ( & $ c... | Sets the default output handlers for string template inputs . |
57,960 | public function helper ( $ name , array $ config = [ ] ) { if ( isset ( $ this -> _helpers [ $ name ] ) ) { return $ this -> _helpers [ $ name ] ; } try { $ config += [ 'context' => $ this ] ; return $ this -> _helpers [ $ name ] = Libraries :: instance ( 'helper' , ucfirst ( $ name ) , $ config ) ; } catch ( ClassNotF... | Brokers access to helpers attached to this rendering context and loads helpers on - demand if they are not available . |
57,961 | public function strings ( $ strings = null ) { if ( is_array ( $ strings ) ) { return $ this -> _strings = $ this -> _strings + $ strings ; } if ( is_string ( $ strings ) ) { return isset ( $ this -> _strings [ $ strings ] ) ? $ this -> _strings [ $ strings ] : null ; } return $ this -> _strings ; } | Manages template strings . |
57,962 | public function context ( $ property = null ) { if ( $ property ) { return isset ( $ this -> _context [ $ property ] ) ? $ this -> _context [ $ property ] : null ; } return $ this -> _context ; } | Returns either one or all context values for this rendering context . Context values persist across all templates rendered in the current context and are usually outputted in a layout template . |
57,963 | public function set ( array $ data = [ ] ) { $ this -> _data = $ data + $ this -> _data ; $ this -> _vars = $ data + $ this -> _vars ; } | Allows variables to be set by one template and used in subsequent templates rendered using the same context . For example a variable can be set in a template and used in an element rendered within a template or an element or template could set a variable which would be made available in the layout . |
57,964 | protected function _render ( $ type , $ template , array $ data = [ ] , array $ options = [ ] ) { $ context = $ this -> _options ; $ options += $ this -> _options ; $ result = $ this -> _view -> render ( $ type , $ data + $ this -> _data , compact ( 'template' ) + $ options ) ; $ this -> _options = $ context ; return $... | Shortcut method used to render elements and other nested templates from inside the templating layer . |
57,965 | public function run ( ) { $ this -> header ( 'Message Extraction' ) ; if ( ! $ data = $ this -> _extract ( ) ) { $ this -> error ( 'Yielded no items.' ) ; return 1 ; } $ count = count ( $ data ) ; $ this -> out ( "Yielded {$count} item(s)." ) ; $ this -> out ( ) ; $ this -> header ( 'Message Template Creation' ) ; if (... | The main method of the command . |
57,966 | protected function _extract ( ) { $ message = [ ] ; $ message [ ] = 'A `Catalog` class configuration with an adapter that is capable of' ; $ message [ ] = 'handling read requests for the `messageTemplate` category is needed' ; $ message [ ] = 'in order to proceed. This may also be referred to as `extractor`.' ; $ this ... | Extracts translatable strings from multiple files . |
57,967 | protected function _writeTemplate ( $ data ) { $ message = [ ] ; $ message [ ] = 'In order to proceed you need to choose a `Catalog` configuration' ; $ message [ ] = 'which is used for writing the template. The adapter for the configuration' ; $ message [ ] = 'should be capable of handling write requests for the `messa... | Prompts for data source and writes template . |
57,968 | protected function _configuration ( array $ options = [ ] ) { $ configs = ( array ) Catalog :: config ( ) ; if ( isset ( $ configs [ 'temporary' ] ) ) { unset ( $ configs [ 'temporary' ] ) ; } if ( $ configs ) { $ this -> out ( 'Available `Catalog` Configurations:' ) ; $ prompt = 'Please choose a configuration or hit e... | Helps in selecting or - if required - adding a new Catalog collection used for extracting or writing the template . A special configuration with the name temporary may be created . Should a configuration with that same name exist prior to entering this method it will be unset . |
57,969 | public function read ( $ key = null , array $ options = [ ] ) { return function ( $ params ) { $ key = $ params [ 'key' ] ; if ( ! $ key ) { if ( isset ( $ _COOKIE [ $ this -> _config [ 'name' ] ] ) ) { return $ _COOKIE [ $ this -> _config [ 'name' ] ] ; } return [ ] ; } if ( strpos ( $ key , '.' ) !== false ) { $ key ... | Read a value from the cookie . |
57,970 | public function write ( $ key , $ value = null , array $ options = [ ] ) { $ expire = ( ! isset ( $ options [ 'expire' ] ) && empty ( $ this -> _config [ 'expire' ] ) ) ; $ cookieClass = __CLASS__ ; if ( $ expire && $ key !== $ this -> _config [ 'name' ] ) { return null ; } $ expires = ( isset ( $ options [ 'expire' ] ... | Write a value to the cookie store . |
57,971 | public function delete ( $ key , array $ options = [ ] ) { $ cookieClass = get_called_class ( ) ; return function ( $ params ) use ( $ cookieClass ) { $ key = $ params [ 'key' ] ; $ path = '/' . str_replace ( '.' , '/' , $ this -> _config [ 'name' ] . '.' . $ key ) . '/.' ; $ cookies = current ( Set :: extract ( $ _COO... | Delete a value from the cookie store . |
57,972 | public function clear ( array $ options = [ ] ) { $ options += [ 'destroySession' => true ] ; $ cookieClass = get_called_class ( ) ; return function ( $ params ) use ( $ options , $ cookieClass ) { if ( $ options [ 'destroySession' ] && session_id ( ) ) { session_destroy ( ) ; } if ( ! isset ( $ _COOKIE [ $ this -> _co... | Clears all cookies . |
57,973 | protected function _init ( ) { parent :: _init ( ) ; foreach ( $ this -> _fields as $ key => $ val ) { if ( is_int ( $ key ) ) { unset ( $ this -> _fields [ $ key ] ) ; $ this -> _fields [ $ val ] = $ val ; } } if ( ! class_exists ( $ model = Libraries :: locate ( 'models' , $ this -> _model ) ) ) { throw new ClassNotF... | Initializes values configured in the constructor . |
57,974 | protected function _validate ( $ user , array $ data ) { foreach ( $ this -> _validators as $ field => $ validator ) { if ( ! isset ( $ this -> _fields [ $ field ] ) || $ field === 0 ) { continue ; } if ( ! is_callable ( $ validator ) ) { $ message = "Authentication validator for `{$field}` is not callable." ; throw ne... | After an authentication query against the configured model class has occurred this method iterates over the configured validators and checks each one by passing the submitted form value as the first parameter and the corresponding database value as the second . The validator then returns a boolean to indicate success .... |
57,975 | protected function _data ( $ data ) { $ model = $ this -> _model ; $ index = strtolower ( Inflector :: singularize ( $ model :: meta ( 'name' ) ) ) ; return isset ( $ data [ $ index ] ) && is_array ( $ data [ $ index ] ) ? $ data [ $ index ] : $ data ; } | Checks if the data container values are inside indexed arrays from binding . Get the values from the binding coresponding to the model if such exists . |
57,976 | protected static function _update ( $ export ) { $ export += [ 'data' => [ ] , 'update' => [ ] , 'remove' => [ ] , 'rename' => [ ] , 'key' => '' ] ; $ path = $ export [ 'key' ] ? "{$export['key']}." : "" ; $ result = [ 'update' => [ ] , 'remove' => [ ] ] ; $ left = static :: _diff ( $ export [ 'data' ] , $ export [ 'up... | Calculates changesets for update operations and produces an array which can be converted to a set of native MongoDB update operations . |
57,977 | protected static function _diff ( $ left , $ right ) { $ result = [ ] ; foreach ( $ left as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ right ) || $ left [ $ key ] !== $ right [ $ key ] ) { $ result [ $ key ] = $ value ; } } return $ result ; } | Handle diffing operations between Document object states . Implemented because all of PHP s array comparison functions are broken when working with objects . |
57,978 | protected static function _append ( $ changes , $ key , $ value , $ change ) { $ options = [ 'finalize' => false ] ; if ( ! is_object ( $ value ) || ! method_exists ( $ value , 'export' ) ) { $ changes [ $ change ] [ $ key ] = ( $ change === 'update' ) ? $ value : true ; return $ changes ; } if ( ! $ value -> exists ( ... | Handles appending nested objects to document changesets . |
57,979 | protected static function _initConfig ( $ name , $ config ) { $ defaults = [ 'session' => [ 'key' => $ name , 'class' => static :: $ _classes [ 'session' ] , 'options' => [ ] , 'persist' => [ ] ] ] ; $ config = parent :: _initConfig ( $ name , $ config ) + $ defaults ; $ config [ 'session' ] += $ defaults [ 'session' ]... | Called when an adapter configuration is first accessed this method sets the default configuration for session handling . While each configuration can use its own session class and options this method initializes them to the default dependencies written into the class . For the session key name the default value is set ... |
57,980 | public static function check ( $ name , $ credentials = null , array $ options = [ ] ) { $ config = static :: config ( $ name ) ; $ defaults = [ 'checkSession' => true , 'writeSession' => true , 'persist' => $ config [ 'session' ] [ 'persist' ] ? : static :: _config ( 'persist' ) ] ; $ options += $ defaults ; $ params ... | Performs an authentication check against the specified configuration and writes the resulting user information to the session such that credentials are not required for subsequent authentication checks and user information is returned directly from the session . |
57,981 | public static function set ( $ name , $ data , array $ options = [ ] ) { $ params = compact ( 'name' , 'data' , 'options' ) ; return Filters :: run ( get_called_class ( ) , __FUNCTION__ , $ params , function ( $ params ) { extract ( $ params ) ; $ config = static :: _config ( $ name ) ; $ session = $ config [ 'session'... | Manually authenticate a user with the given set of data . Rather than checking a user s credentials this method allows you to manually specify a user for whom you d like to initialize an authenticated session . |
57,982 | public static function clear ( $ name , array $ options = [ ] ) { $ defaults = [ 'clearSession' => true ] ; $ options += $ defaults ; $ params = compact ( 'name' , 'options' ) ; return Filters :: run ( get_called_class ( ) , __FUNCTION__ , $ params , function ( $ params ) { extract ( $ params ) ; $ config = static :: _... | Removes session information for the given configuration and allows the configuration s adapter to perform any associated cleanup tasks . |
57,983 | public function write ( array $ keys , $ expiry = null ) { foreach ( $ keys as $ key => & $ value ) { $ this -> _cache [ $ key ] = $ value ; } return true ; } | Write values to the cache . |
57,984 | public function decrement ( $ key , $ offset = 1 ) { if ( ! array_key_exists ( $ key , $ this -> _cache ) ) { return false ; } return $ this -> _cache [ $ key ] -= $ offset ; } | Performs a decrement operation on specified numeric cache item . |
57,985 | public function increment ( $ key , $ offset = 1 ) { if ( ! array_key_exists ( $ key , $ this -> _cache ) ) { return false ; } return $ this -> _cache [ $ key ] += $ offset ; } | Performs an increment operation on specified numeric cache item . |
57,986 | public static function reset ( $ env = null ) { if ( $ env ) { unset ( static :: $ _configurations [ $ env ] ) ; return ; } static :: $ _current = '' ; static :: $ _detector = null ; static :: $ _configurations = [ 'production' => [ ] , 'development' => [ ] , 'test' => [ ] ] ; } | Resets the Environment class to its default state including unsetting the current environment removing any environment - specific configurations and removing the custom environment detector if any has been specified . |
57,987 | public static function get ( $ name = null ) { $ cur = static :: $ _current ; if ( ! $ name ) { return $ cur ; } if ( $ name === true ) { return isset ( static :: $ _configurations [ $ cur ] ) ? static :: $ _configurations [ $ cur ] : null ; } if ( isset ( static :: $ _configurations [ $ name ] ) ) { return static :: _... | Gets the current environment name a setting associated with the current environment or the entire configuration array for the current environment . |
57,988 | public function name ( $ name ) { if ( isset ( $ this -> _cachedNames [ $ name ] ) ) { return $ this -> _cachedNames [ $ name ] ; } list ( $ open , $ close ) = $ this -> _quotes ; list ( $ first , $ second ) = $ this -> _splitFieldname ( $ name ) ; if ( $ first ) { $ result = "{$open}{$first}{$close}.{$open}{$second}{$... | Field name handler to ensure proper escaping . |
57,989 | protected function _splitFieldname ( $ field ) { $ regex = '/^([a-z0-9_-]+)\.([a-z 0-9_-]+|\*)$/iS' ; if ( strpos ( $ field , '.' ) !== false && preg_match ( $ regex , $ field , $ matches ) ) { return [ $ matches [ 1 ] , $ matches [ 2 ] ] ; } return [ null , $ field ] ; } | Return the alias and the field name from an identifier name . |
57,990 | protected function _fieldName ( $ field ) { $ regex = '/^[a-z0-9_-]+\.[a-z0-9_-]+$/iS' ; if ( strpos ( $ field , '.' ) !== false && preg_match ( $ regex , $ field ) ) { list ( $ first , $ second ) = explode ( '.' , $ field , 2 ) ; return $ second ; } return $ field ; } | Return the field name from a conditions key . |
57,991 | public function create ( $ query , array $ options = [ ] ) { $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { $ query = $ params [ 'query' ] ; $ model = $ entity = $ object = $ id = null ; if ( is_object ( $ query ) ) { $ object = $ query ; ... | Inserts a new record into the database based on a the Query . The record is updated with the id of the insert . |
57,992 | public function read ( $ query , array $ options = [ ] ) { $ defaults = [ 'return' => is_string ( $ query ) ? 'array' : 'item' , 'schema' => null , 'quotes' => $ this -> _quotes ] ; $ options += $ defaults ; $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function... | Reads records from a database using a lithium \ data \ model \ Query object or raw SQL string . |
57,993 | public function update ( $ query , array $ options = [ ] ) { $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { $ query = $ params [ 'query' ] ; $ exportedQuery = $ query -> export ( $ this ) ; if ( $ exportedQuery [ 'fields' ] === null ) { re... | Updates a record in the database based on the given Query . |
57,994 | public function delete ( $ query , array $ options = [ ] ) { $ params = compact ( 'query' , 'options' ) ; return Filters :: run ( $ this , __FUNCTION__ , $ params , function ( $ params ) { $ query = $ params [ 'query' ] ; $ isObject = is_object ( $ query ) ; if ( $ isObject ) { $ sql = $ this -> renderCommand ( 'delete... | Deletes a record in the database based on the given Query . |
57,995 | public function calculation ( $ type , $ query , array $ options = [ ] ) { $ query -> calculate ( $ type ) ; switch ( $ type ) { case 'count' : if ( strpos ( $ fields = $ this -> fields ( $ query -> fields ( ) , $ query ) , ',' ) !== false ) { $ fields = "*" ; } $ query -> fields ( "COUNT({$fields}) as count" , true ) ... | Executes calculation - related queries such as those required for count and other aggregates . |
57,996 | public function schema ( $ query , $ resource = null , $ context = null ) { if ( is_object ( $ query ) ) { $ query -> applyStrategy ( $ this ) ; return $ this -> _schema ( $ query , $ this -> _fields ( $ query -> fields ( ) , $ query ) ) ; } $ result = [ ] ; if ( ! $ resource || ! $ resource -> resource ( ) ) { return ... | Builds an array of keyed on the fully - namespaced Model with array of fields as values for the given Query |
57,997 | protected function _conditions ( $ conditions , $ context , array $ options = [ ] ) { $ defaults = [ 'prepend' => false ] ; $ options += $ defaults ; switch ( true ) { case empty ( $ conditions ) : return '' ; case is_string ( $ conditions ) : return $ options [ 'prepend' ] ? $ options [ 'prepend' ] . " {$conditions}" ... | Returns a string of formatted conditions to be inserted into the query statement . |
57,998 | protected function _processOperator ( $ key , $ value , $ fieldMeta , $ glue ) { if ( ! is_string ( $ key ) || ! is_array ( $ value ) ) { return false ; } $ operator = strtoupper ( key ( $ value ) ) ; if ( ! is_numeric ( $ operator ) ) { if ( ! isset ( $ this -> _operators [ $ operator ] ) ) { throw new QueryException ... | Helper method used by _processConditions . |
57,999 | public function fields ( $ fields , $ context ) { $ type = $ context -> type ( ) ; $ schema = $ context -> schema ( ) -> fields ( ) ; $ alias = $ context -> alias ( ) ; if ( ! is_array ( $ fields ) ) { return $ this -> _fieldsReturn ( $ type , $ context , $ fields , $ schema ) ; } $ context -> applyStrategy ( $ this ) ... | Returns a string of formatted fields to be inserted into the query statement . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.