idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
25,700 | public function valid ( ) { if ( ! parent :: valid ( ) ) { return false ; } $ current = $ this -> current ( ) ; $ key = $ this -> key ( ) ; $ condition = $ this -> _condition ; return ! $ condition ( $ current , $ key , $ this -> _innerIterator ) ; } | Evaluates the condition and returns its result this controls whether or not more results will be yielded . |
25,701 | public function connection ( $ connection = null ) { deprecationWarning ( get_called_class ( ) . '::connection() is deprecated. ' . 'Use setConnection()/getConnection() instead.' ) ; if ( $ connection !== null ) { $ this -> _connection = $ connection ; } return $ this -> _connection ; } | Returns correct connection resource or object that is internally used If first argument is passed it will set internal connection object or result to the value passed . |
25,702 | public function autoQuoting ( $ enable = null ) { deprecationWarning ( 'Driver::autoQuoting() is deprecated. ' . 'Use Driver::enableAutoQuoting()/isAutoQuotingEnabled() instead.' ) ; if ( $ enable !== null ) { $ this -> enableAutoQuoting ( $ enable ) ; } return $ this -> isAutoQuotingEnabled ( ) ; } | Returns whether or not this driver should automatically quote identifiers in queries |
25,703 | protected function _schemaDefault ( $ field ) { $ field = $ this -> _form -> schema ( ) -> field ( $ field ) ; if ( $ field ) { return $ field [ 'default' ] ; } return null ; } | Get default value from form schema for given field . |
25,704 | public function setVars ( $ data , $ merge = true ) { if ( $ merge ) { $ this -> _vars = $ data + $ this -> _vars ; } else { $ this -> _vars = $ data ; } return $ this ; } | Saves view vars for use inside templates . |
25,705 | public function autoLayout ( $ enable = null ) { deprecationWarning ( 'ViewBuilder::autoLayout() is deprecated. Use ViewBuilder::enableAutoLayout() or ViewBuilder::isAutoLayoutEnable() instead.' ) ; if ( $ enable !== null ) { return $ this -> enableAutoLayout ( $ enable ) ; } return $ this -> isAutoLayoutEnabled ( ) ; ... | Turns on or off CakePHP s conventional mode of applying layout files . On by default . Setting to off means that layouts will not be automatically applied to rendered views . |
25,706 | public function plugin ( $ name = null ) { deprecationWarning ( 'ViewBuilder::plugin() is deprecated. Use ViewBuilder::setPlugin() or ViewBuilder::getPlugin() instead.' ) ; if ( $ name !== null ) { return $ this -> setPlugin ( $ name ) ; } return $ this -> getPlugin ( ) ; } | The plugin name to use |
25,707 | public function setHelpers ( array $ helpers , $ merge = true ) { if ( $ merge ) { $ helpers = array_merge ( $ this -> _helpers , $ helpers ) ; } $ this -> _helpers = $ helpers ; return $ this ; } | Sets the helpers to use . |
25,708 | public function helpers ( array $ helpers = null , $ merge = true ) { deprecationWarning ( 'ViewBuilder::helpers() is deprecated. Use ViewBuilder::setHelpers() or ViewBuilder::getHelpers() instead.' ) ; if ( $ helpers !== null ) { return $ this -> setHelpers ( $ helpers , $ merge ) ; } return $ this -> getHelpers ( ) ;... | The helpers to use |
25,709 | public function setOptions ( array $ options , $ merge = true ) { if ( $ merge ) { $ options = array_merge ( $ this -> _options , $ options ) ; } $ this -> _options = $ options ; return $ this ; } | Sets additional options for the view . |
25,710 | public function options ( array $ options = null , $ merge = true ) { deprecationWarning ( 'ViewBuilder::options() is deprecated. Use ViewBuilder::setOptions() or ViewBuilder::getOptions() instead.' ) ; if ( $ options !== null ) { return $ this -> setOptions ( $ options , $ merge ) ; } return $ this -> getOptions ( ) ;... | Set additional options for the view . |
25,711 | public function build ( $ vars = [ ] , ServerRequest $ request = null , Response $ response = null , EventManager $ events = null ) { $ className = $ this -> _className ; if ( $ className === null ) { $ className = App :: className ( 'App' , 'View' , 'View' ) ? : 'Cake\View\View' ; } if ( $ className === 'View' ) { $ c... | Using the data in the builder create a view instance . |
25,712 | public function jsonSerialize ( ) { $ properties = [ '_templatePath' , '_template' , '_plugin' , '_theme' , '_layout' , '_autoLayout' , '_layoutPath' , '_name' , '_className' , '_options' , '_helpers' ] ; $ array = [ ] ; foreach ( $ properties as $ property ) { $ array [ $ property ] = $ this -> { $ property } ; } retu... | Serializes the view builder object to a value that can be natively serialized and re - used to clone this builder instance . |
25,713 | public function createFromArray ( $ config ) { foreach ( $ config as $ property => $ value ) { $ this -> { $ property } = $ value ; } return $ this ; } | Configures a view builder instance from serialized config . |
25,714 | public function find ( $ regexpPattern = '.*' , $ sort = false ) { list ( , $ files ) = $ this -> read ( $ sort ) ; return array_values ( preg_grep ( '/^' . $ regexpPattern . '$/i' , $ files ) ) ; } | Returns an array of all matching files in current directory . |
25,715 | public function findRecursive ( $ pattern = '.*' , $ sort = false ) { if ( ! $ this -> pwd ( ) ) { return [ ] ; } $ startsOn = $ this -> path ; $ out = $ this -> _findRecursive ( $ pattern , $ sort ) ; $ this -> cd ( $ startsOn ) ; return $ out ; } | Returns an array of all matching files in and below current directory . |
25,716 | public function inCakePath ( $ path = '' ) { deprecationWarning ( 'Folder::inCakePath() is deprecated. Use Folder::inPath() instead.' ) ; $ dir = substr ( Folder :: slashTerm ( ROOT ) , 0 , - 1 ) ; $ newdir = $ dir . $ path ; return $ this -> inPath ( $ newdir ) ; } | Returns true if the Folder is in the given Cake path . |
25,717 | public function subdirectories ( $ path = null , $ fullPath = true ) { if ( ! $ path ) { $ path = $ this -> path ; } $ subdirectories = [ ] ; try { $ iterator = new DirectoryIterator ( $ path ) ; } catch ( Exception $ e ) { return [ ] ; } foreach ( $ iterator as $ item ) { if ( ! $ item -> isDir ( ) || $ item -> isDot ... | Returns an array of subdirectories for the provided or current path . |
25,718 | public function create ( $ pathname , $ mode = false ) { if ( is_dir ( $ pathname ) || empty ( $ pathname ) ) { return true ; } if ( ! self :: isAbsolute ( $ pathname ) ) { $ pathname = self :: addPathElement ( $ this -> pwd ( ) , $ pathname ) ; } if ( ! $ mode ) { $ mode = $ this -> mode ; } if ( is_file ( $ pathname ... | Create a directory structure recursively . |
25,719 | public function dirsize ( ) { $ size = 0 ; $ directory = Folder :: slashTerm ( $ this -> path ) ; $ stack = [ $ directory ] ; $ count = count ( $ stack ) ; for ( $ i = 0 , $ j = $ count ; $ i < $ j ; $ i ++ ) { if ( is_file ( $ stack [ $ i ] ) ) { $ size += filesize ( $ stack [ $ i ] ) ; } elseif ( is_dir ( $ stack [ $... | Returns the size in bytes of this Folder and its contents . |
25,720 | public function delete ( $ path = null ) { if ( ! $ path ) { $ path = $ this -> pwd ( ) ; } if ( ! $ path ) { return false ; } $ path = Folder :: slashTerm ( $ path ) ; if ( is_dir ( $ path ) ) { try { $ directory = new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: CURRENT_AS_SELF ) ; $ iterator =... | Recursively Remove directories if the system allows . |
25,721 | public function move ( $ options ) { $ to = null ; if ( is_string ( $ options ) ) { $ to = $ options ; $ options = ( array ) $ options ; } $ options += [ 'to' => $ to , 'from' => $ this -> path , 'mode' => $ this -> mode , 'skip' => [ ] , 'recursive' => true ] ; if ( $ this -> copy ( $ options ) && $ this -> delete ( $... | Recursive directory move . |
25,722 | protected function flush ( $ maxBufferLevel = null ) { if ( null === $ maxBufferLevel ) { $ maxBufferLevel = ob_get_level ( ) ; } while ( ob_get_level ( ) > $ maxBufferLevel ) { ob_end_flush ( ) ; } } | Loops through the output buffer flushing each before emitting the response . |
25,723 | public function write ( $ message , $ newlines = 1 ) { if ( is_array ( $ message ) ) { $ message = implode ( static :: LF , $ message ) ; } return $ this -> _write ( $ this -> styleText ( $ message . str_repeat ( static :: LF , $ newlines ) ) ) ; } | Outputs a single or multiple messages to stdout or stderr . If no parameters are passed outputs just a newline . |
25,724 | public function styleText ( $ text ) { if ( $ this -> _outputAs == static :: RAW ) { return $ text ; } if ( $ this -> _outputAs == static :: PLAIN ) { $ tags = implode ( '|' , array_keys ( static :: $ _styles ) ) ; return preg_replace ( '#</?(?:' . $ tags . ')>#' , '' , $ text ) ; } return preg_replace_callback ( '/<(?... | Apply styling to text . |
25,725 | protected function _replaceTags ( $ matches ) { $ style = $ this -> styles ( $ matches [ 'tag' ] ) ; if ( empty ( $ style ) ) { return '<' . $ matches [ 'tag' ] . '>' . $ matches [ 'text' ] . '</' . $ matches [ 'tag' ] . '>' ; } $ styleInfo = [ ] ; if ( ! empty ( $ style [ 'text' ] ) && isset ( static :: $ _foregroundC... | Replace tags with color codes . |
25,726 | public function styles ( $ style = null , $ definition = null ) { if ( $ style === null && $ definition === null ) { return static :: $ _styles ; } if ( is_string ( $ style ) && $ definition === null ) { return isset ( static :: $ _styles [ $ style ] ) ? static :: $ _styles [ $ style ] : null ; } if ( $ definition === ... | Get the current styles offered or append new ones in . |
25,727 | public function setOutputAs ( $ type ) { if ( ! in_array ( $ type , [ self :: RAW , self :: PLAIN , self :: COLOR ] , true ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid output type "%s".' , $ type ) ) ; } $ this -> _outputAs = $ type ; } | Set the output type on how formatting tags are treated . |
25,728 | public function connect ( ) { if ( $ this -> _connection ) { return true ; } $ config = $ this -> _config ; if ( isset ( $ config [ 'persistent' ] ) && $ config [ 'persistent' ] ) { throw new \ InvalidArgumentException ( 'Config setting "persistent" cannot be set to true, as the Sqlserver PDO driver does not support PD... | Establishes a connection to the database server . |
25,729 | public function hasEvent ( $ name ) { foreach ( $ this -> _events as $ event ) { if ( $ event -> getName ( ) === $ name ) { return true ; } } return false ; } | Checks if an event is in the list . |
25,730 | public static function getInstance ( $ class = null ) { static $ instance = [ ] ; if ( ! empty ( $ class ) ) { if ( ! $ instance || strtolower ( $ class ) !== strtolower ( get_class ( $ instance [ 0 ] ) ) ) { $ instance [ 0 ] = new $ class ( ) ; } } if ( ! $ instance ) { $ instance [ 0 ] = new Debugger ( ) ; } return $... | Returns a reference to the Debugger singleton object instance . |
25,731 | public static function configInstance ( $ key = null , $ value = null , $ merge = true ) { if ( is_array ( $ key ) || func_num_args ( ) >= 2 ) { return static :: getInstance ( ) -> setConfig ( $ key , $ value , $ merge ) ; } return static :: getInstance ( ) -> getConfig ( $ key ) ; } | Read or write configuration options for the Debugger instance . |
25,732 | public static function log ( $ var , $ level = 'debug' , $ depth = 3 ) { $ source = static :: trace ( [ 'start' => 1 ] ) . "\n" ; Log :: write ( $ level , "\n" . $ source . static :: exportVar ( $ var , $ depth ) ) ; } | Creates an entry in the log file . The log entry will contain a stack trace from where it was called . as well as export the variable using exportVar . By default the log is written to the debug log . |
25,733 | public static function trimPath ( $ path ) { if ( defined ( 'APP' ) && strpos ( $ path , APP ) === 0 ) { return str_replace ( APP , 'APP/' , $ path ) ; } if ( defined ( 'CAKE_CORE_INCLUDE_PATH' ) && strpos ( $ path , CAKE_CORE_INCLUDE_PATH ) === 0 ) { return str_replace ( CAKE_CORE_INCLUDE_PATH , 'CORE' , $ path ) ; } ... | Shortens file paths by replacing the application base path with APP and the CakePHP core path with CORE . |
25,734 | public static function excerpt ( $ file , $ line , $ context = 2 ) { $ lines = [ ] ; if ( ! file_exists ( $ file ) ) { return [ ] ; } $ data = file_get_contents ( $ file ) ; if ( empty ( $ data ) ) { return $ lines ; } if ( strpos ( $ data , "\n" ) !== false ) { $ data = explode ( "\n" , $ data ) ; } $ line -- ; if ( !... | Grabs an excerpt from a file and highlights a given line of code . |
25,735 | protected static function _highlight ( $ str ) { if ( function_exists ( 'hphp_log' ) || function_exists ( 'hphp_gettid' ) ) { return htmlentities ( $ str ) ; } $ added = false ; if ( strpos ( $ str , '<?php' ) === false ) { $ added = true ; $ str = "<?php \n" . $ str ; } $ highlight = highlight_string ( $ str , true ) ... | Wraps the highlight_string function in case the server API does not implement the function as it is the case of the HipHop interpreter |
25,736 | protected static function _export ( $ var , $ depth , $ indent ) { switch ( static :: getType ( $ var ) ) { case 'boolean' : return $ var ? 'true' : 'false' ; case 'integer' : return '(int) ' . $ var ; case 'float' : return '(float) ' . $ var ; case 'string' : if ( trim ( $ var ) === '' && ctype_space ( $ var ) === fal... | Protected export function used to keep track of indentation and recursion . |
25,737 | public static function setOutputFormat ( $ format ) { $ self = Debugger :: getInstance ( ) ; if ( ! isset ( $ self -> _templates [ $ format ] ) ) { throw new InvalidArgumentException ( 'Invalid Debugger output format.' ) ; } $ self -> _outputFormat = $ format ; } | Set the output format for Debugger error rendering . |
25,738 | public static function addFormat ( $ format , array $ strings ) { $ self = Debugger :: getInstance ( ) ; if ( isset ( $ self -> _templates [ $ format ] ) ) { if ( isset ( $ strings [ 'links' ] ) ) { $ self -> _templates [ $ format ] [ 'links' ] = array_merge ( $ self -> _templates [ $ format ] [ 'links' ] , $ strings [... | Add an output format or update a format in Debugger . |
25,739 | public static function getType ( $ var ) { if ( is_object ( $ var ) ) { return get_class ( $ var ) ; } if ( $ var === null ) { return 'null' ; } if ( is_string ( $ var ) ) { return 'string' ; } if ( is_array ( $ var ) ) { return 'array' ; } if ( is_int ( $ var ) ) { return 'integer' ; } if ( is_bool ( $ var ) ) { retur... | Get the type of the given variable . Will return the class name for objects . |
25,740 | public static function printVar ( $ var , $ location = [ ] , $ showHtml = null ) { $ location += [ 'file' => null , 'line' => null ] ; $ file = $ location [ 'file' ] ; $ line = $ location [ 'line' ] ; $ lineInfo = '' ; if ( $ file ) { $ search = [ ] ; if ( defined ( 'ROOT' ) ) { $ search = [ ROOT ] ; } if ( defined ( '... | Prints out debug information about given variable . |
25,741 | protected function _headersToString ( $ headers , $ eol = "\r\n" ) { $ out = '' ; foreach ( $ headers as $ key => $ value ) { if ( $ value === false || $ value === null || $ value === '' ) { continue ; } $ out .= $ key . ': ' . $ value . $ eol ; } if ( ! empty ( $ out ) ) { $ out = substr ( $ out , 0 , - 1 * strlen ( $... | Help to convert headers in string |
25,742 | public static function engine ( $ config ) { if ( ! static :: $ _enabled ) { return new NullEngine ( ) ; } $ registry = static :: getRegistry ( ) ; if ( isset ( $ registry -> { $ config } ) ) { return $ registry -> { $ config } ; } static :: _buildEngine ( $ config ) ; return $ registry -> { $ config } ; } | Fetch the engine attached to a specific configuration name . |
25,743 | public static function writeMany ( $ data , $ config = 'default' ) { $ engine = static :: engine ( $ config ) ; $ return = $ engine -> writeMany ( $ data ) ; foreach ( $ return as $ key => $ success ) { if ( $ success === false && $ data [ $ key ] !== '' ) { throw new RuntimeException ( sprintf ( '%s cache was unable t... | Write data for many keys into cache . |
25,744 | public static function decrement ( $ key , $ offset = 1 , $ config = 'default' ) { $ engine = static :: pool ( $ config ) ; if ( ! is_int ( $ offset ) || $ offset < 0 ) { return false ; } return $ engine -> decrement ( $ key , $ offset ) ; } | Decrement a number under the key and return decremented value . |
25,745 | public static function deleteMany ( $ keys , $ config = 'default' ) { $ backend = static :: pool ( $ config ) ; $ return = [ ] ; foreach ( $ keys as $ key ) { $ return [ $ key ] = $ backend -> delete ( $ key ) ; } return $ return ; } | Delete many keys from the cache . |
25,746 | public static function clearAll ( $ check = false ) { $ status = [ ] ; foreach ( self :: configured ( ) as $ config ) { $ status [ $ config ] = self :: clear ( $ check , $ config ) ; } return $ status ; } | Delete all keys from the cache from all configurations . |
25,747 | public static function remember ( $ key , $ callable , $ config = 'default' ) { $ existing = self :: read ( $ key , $ config ) ; if ( $ existing !== false ) { return $ existing ; } $ results = call_user_func ( $ callable ) ; self :: write ( $ key , $ results , $ config ) ; return $ results ; } | Provides the ability to easily do read - through caching . |
25,748 | public static function add ( $ key , $ value , $ config = 'default' ) { $ pool = static :: pool ( $ config ) ; if ( is_resource ( $ value ) ) { return false ; } return $ pool -> add ( $ key , $ value ) ; } | Write data for key into a cache engine if it doesn t exist already . |
25,749 | protected function _checkCipher ( $ encrypt ) { if ( ! in_array ( $ encrypt , $ this -> _validCiphers ) ) { $ msg = sprintf ( 'Invalid encryption cipher. Must be one of %s or false.' , implode ( ', ' , $ this -> _validCiphers ) ) ; throw new RuntimeException ( $ msg ) ; } } | Helper method for validating encryption cipher names . |
25,750 | protected function _decode ( $ value , $ encrypt , $ key ) { if ( ! $ encrypt ) { return $ this -> _explode ( $ value ) ; } $ this -> _checkCipher ( $ encrypt ) ; $ prefix = 'Q2FrZQ==.' ; $ prefixLength = strlen ( $ prefix ) ; if ( strncmp ( $ value , $ prefix , $ prefixLength ) !== 0 ) { return '' ; } $ value = base64... | Decodes and decrypts a single value . |
25,751 | public static function createUri ( array $ server = [ ] ) { $ server += $ _SERVER ; $ server = static :: normalizeServer ( $ server ) ; $ headers = static :: marshalHeaders ( $ server ) ; return static :: marshalUriFromServer ( $ server , $ headers ) ; } | Create a new Uri instance from the provided server data . |
25,752 | public static function marshalUriFromServer ( array $ server , array $ headers ) { $ uri = parent :: marshalUriFromServer ( $ server , $ headers ) ; list ( $ base , $ webroot ) = static :: getBase ( $ uri , $ server ) ; $ pathInfo = Hash :: get ( $ server , 'PATH_INFO' ) ; if ( $ pathInfo ) { $ uri = $ uri -> withPath ... | Build a UriInterface object . |
25,753 | protected static function updatePath ( $ base , $ uri ) { $ path = $ uri -> getPath ( ) ; if ( strlen ( $ base ) > 0 && strpos ( $ path , $ base ) === 0 ) { $ path = substr ( $ path , strlen ( $ base ) ) ; } if ( $ path === '/index.php' && $ uri -> getQuery ( ) ) { $ path = $ uri -> getQuery ( ) ; } if ( empty ( $ path... | Updates the request URI to remove the base directory . |
25,754 | protected static function getBase ( $ uri , $ server ) { $ config = ( array ) Configure :: read ( 'App' ) + [ 'base' => null , 'webroot' => null , 'baseUrl' => null ] ; $ base = $ config [ 'base' ] ; $ baseUrl = $ config [ 'baseUrl' ] ; $ webroot = $ config [ 'webroot' ] ; if ( $ base !== false && $ base !== null ) { r... | Calculate the base directory and webroot directory . |
25,755 | protected function createValidator ( $ name ) { $ method = 'validation' . ucfirst ( $ name ) ; if ( ! $ this -> validationMethodExists ( $ method ) ) { $ message = sprintf ( 'The %s::%s() validation method does not exists.' , __CLASS__ , $ method ) ; throw new RuntimeException ( $ message ) ; } $ validator = new $ this... | Creates a validator using a custom method inside your class . |
25,756 | public function setValidator ( $ name , Validator $ validator ) { $ validator -> setProvider ( self :: VALIDATOR_PROVIDER_NAME , $ this ) ; $ this -> _validators [ $ name ] = $ validator ; return $ this ; } | This method stores a custom validator under the given name . |
25,757 | public function hasValidator ( $ name ) { $ method = 'validation' . ucfirst ( $ name ) ; if ( $ this -> validationMethodExists ( $ method ) ) { return true ; } return isset ( $ this -> _validators [ $ name ] ) ; } | Checks whether or not a validator has been set . |
25,758 | public function newInstance ( $ locale , Package $ package , FormatterInterface $ formatter , TranslatorInterface $ fallback = null ) { $ class = $ this -> class ; if ( $ fallback !== null && get_class ( $ fallback ) !== $ class ) { throw new RuntimeException ( sprintf ( 'Translator fallback class %s does not match Cak... | Returns a new Translator . |
25,759 | protected function _buildInsertPart ( $ parts , $ query , $ generator ) { $ table = $ parts [ 0 ] ; $ columns = $ this -> _stringifyExpressions ( $ parts [ 1 ] , $ generator ) ; $ modifiers = $ this -> _buildModifierPart ( $ query -> clause ( 'modifier' ) , $ query , $ generator ) ; return sprintf ( 'INSERT%s INTO %s (... | Generates the INSERT part of a SQL query |
25,760 | public function get ( $ index ) { if ( isset ( $ this -> callables [ $ index ] ) ) { return $ this -> callables [ $ index ] ; } return $ this -> resolve ( $ index ) ; } | Get the middleware at the provided index . |
25,761 | protected function resolve ( $ index ) { if ( ! isset ( $ this -> queue [ $ index ] ) ) { return null ; } if ( is_string ( $ this -> queue [ $ index ] ) ) { $ class = $ this -> queue [ $ index ] ; $ className = App :: className ( $ class , 'Middleware' , 'Middleware' ) ; if ( ! $ className || ! class_exists ( $ classNa... | Resolve middleware name to callable . |
25,762 | public function add ( $ middleware ) { if ( is_array ( $ middleware ) ) { $ this -> queue = array_merge ( $ this -> queue , $ middleware ) ; return $ this ; } $ this -> queue [ ] = $ middleware ; return $ this ; } | Append a middleware callable to the end of the queue . |
25,763 | public function prepend ( $ middleware ) { if ( is_array ( $ middleware ) ) { $ this -> queue = array_merge ( $ middleware , $ this -> queue ) ; return $ this ; } array_unshift ( $ this -> queue , $ middleware ) ; return $ this ; } | Prepend a middleware to the start of the queue . |
25,764 | public function insertBefore ( $ class , $ middleware ) { $ found = false ; $ i = null ; foreach ( $ this -> queue as $ i => $ object ) { if ( ( is_string ( $ object ) && $ object === $ class ) || is_a ( $ object , $ class ) ) { $ found = true ; break ; } } if ( $ found ) { return $ this -> insertAt ( $ i , $ middlewar... | Insert a middleware object before the first matching class . |
25,765 | public function insertAfter ( $ class , $ middleware ) { $ found = false ; $ i = null ; foreach ( $ this -> queue as $ i => $ object ) { if ( ( is_string ( $ object ) && $ object === $ class ) || is_a ( $ object , $ class ) ) { $ found = true ; break ; } } if ( $ found ) { return $ this -> insertAt ( $ i + 1 , $ middle... | Insert a middleware object after the first matching class . |
25,766 | public function listPrefixes ( ) { $ prefixes = Cache :: configured ( ) ; foreach ( $ prefixes as $ prefix ) { $ this -> out ( $ prefix ) ; } } | Show a list of all defined cache prefixes . |
25,767 | protected function _castToExpression ( $ value , $ type ) { if ( empty ( $ type ) ) { return $ value ; } $ baseType = str_replace ( '[]' , '' , $ type ) ; $ converter = Type :: build ( $ baseType ) ; if ( ! $ converter instanceof ExpressionTypeInterface ) { return $ value ; } $ multi = $ type !== $ baseType ; if ( $ mu... | Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface . Otherwise returns the value unmodified . |
25,768 | protected function _requiresToExpressionCasting ( $ types ) { $ result = [ ] ; $ types = array_filter ( $ types ) ; foreach ( $ types as $ k => $ type ) { $ object = Type :: build ( $ type ) ; if ( $ object instanceof ExpressionTypeInterface ) { $ result [ $ k ] = $ object ; } } return $ result ; } | Returns an array with the types that require values to be casted to expressions out of the list of type names passed as parameter . |
25,769 | public function toDatabase ( $ value , Driver $ driver ) { if ( $ value === true || $ value === false || $ value === null ) { return $ value ; } if ( in_array ( $ value , [ 1 , 0 , '1' , '0' ] , true ) ) { return ( bool ) $ value ; } throw new InvalidArgumentException ( sprintf ( 'Cannot convert value of type `%s` to b... | Convert bool data into the database format . |
25,770 | public function toPHP ( $ value , Driver $ driver ) { if ( $ value === null || $ value === true || $ value === false ) { return $ value ; } if ( ! is_numeric ( $ value ) ) { return strtolower ( $ value ) === 'true' ; } return ! empty ( $ value ) ; } | Convert bool values to PHP booleans |
25,771 | public function toStatement ( $ value , Driver $ driver ) { if ( $ value === null ) { return PDO :: PARAM_NULL ; } return PDO :: PARAM_BOOL ; } | Get the correct PDO binding type for bool data . |
25,772 | public function marshal ( $ value ) { if ( $ value === null ) { return null ; } if ( $ value === 'true' ) { return true ; } if ( $ value === 'false' ) { return false ; } if ( ! is_scalar ( $ value ) ) { return null ; } return ! empty ( $ value ) ; } | Marshalls request data into PHP booleans . |
25,773 | public function setController ( Controller $ controller ) { $ this -> _Controller = $ controller ; $ this -> setEventManager ( $ controller -> getEventManager ( ) ) ; } | Set the controller associated with the collection . |
25,774 | protected function _create ( $ class , $ alias , $ config ) { $ instance = new $ class ( $ this , $ config ) ; $ enable = isset ( $ config [ 'enabled' ] ) ? $ config [ 'enabled' ] : true ; if ( $ enable ) { $ this -> getEventManager ( ) -> on ( $ instance ) ; } return $ instance ; } | Create the component instance . |
25,775 | public function translationsFolders ( ) { $ locale = Locale :: parseLocale ( $ this -> _locale ) + [ 'region' => null ] ; $ folders = [ implode ( '_' , [ $ locale [ 'language' ] , $ locale [ 'region' ] ] ) , $ locale [ 'language' ] ] ; $ searchPaths = [ ] ; $ localePaths = App :: path ( 'Locale' ) ; if ( empty ( $ loca... | Returns the folders where the file should be looked for according to the locale and package name . |
25,776 | public function scanCore ( ) { $ coreShells = $ this -> scanDir ( dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . 'Shell' . DIRECTORY_SEPARATOR , 'Cake\Shell\\' , '' , [ 'command_list' ] ) ; $ coreCommands = $ this -> scanDir ( dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . 'Command' . DIRECTORY_SEPARATOR , 'Cake\Command\\' ,... | Scan CakePHP internals for shells & commands . |
25,777 | public function scanApp ( ) { $ appNamespace = Configure :: read ( 'App.namespace' ) ; $ appShells = $ this -> scanDir ( App :: path ( 'Shell' ) [ 0 ] , $ appNamespace . '\Shell\\' , '' , [ ] ) ; $ appCommands = $ this -> scanDir ( App :: path ( 'Command' ) [ 0 ] , $ appNamespace . '\Command\\' , '' , [ ] ) ; return ar... | Scan the application for shells & commands . |
25,778 | public function scanPlugin ( $ plugin ) { if ( ! Plugin :: isLoaded ( $ plugin ) ) { return [ ] ; } $ path = Plugin :: classPath ( $ plugin ) ; $ namespace = str_replace ( '/' , '\\' , $ plugin ) ; $ prefix = Inflector :: underscore ( $ plugin ) . '.' ; $ commands = $ this -> scanDir ( $ path . 'Command' , $ namespace ... | Scan the named plugin for shells and commands |
25,779 | public function parse ( $ url , $ method = '' ) { $ params = parent :: parse ( $ url , $ method ) ; if ( ! $ params ) { return false ; } if ( ! empty ( $ params [ 'controller' ] ) ) { $ params [ 'controller' ] = Inflector :: camelize ( $ params [ 'controller' ] , '-' ) ; } if ( ! empty ( $ params [ 'plugin' ] ) ) { $ p... | Parses a string URL into an array . If it matches it will convert the controller and plugin keys to their CamelCased form and action key to camelBacked form . |
25,780 | public function match ( array $ url , array $ context = [ ] ) { $ url = $ this -> _dasherize ( $ url ) ; if ( ! $ this -> _inflectedDefaults ) { $ this -> _inflectedDefaults = true ; $ this -> defaults = $ this -> _dasherize ( $ this -> defaults ) ; } return parent :: match ( $ url , $ context ) ; } | Dasherizes the controller action and plugin params before passing them on to the parent class . |
25,781 | protected function _dasherize ( $ url ) { foreach ( [ 'controller' , 'plugin' , 'action' ] as $ element ) { if ( ! empty ( $ url [ $ element ] ) ) { $ url [ $ element ] = Inflector :: dasherize ( $ url [ $ element ] ) ; } } return $ url ; } | Helper method for dasherizing keys in a URL array . |
25,782 | public function read ( ) { if ( $ this -> _canReadline ) { $ line = readline ( '' ) ; if ( strlen ( $ line ) > 0 ) { readline_add_history ( $ line ) ; } return $ line ; } return fgets ( $ this -> _input ) ; } | Read a value from the stream |
25,783 | public function dataAvailable ( $ timeout = 0 ) { $ readFds = [ $ this -> _input ] ; $ writeFds = null ; $ errorFds = null ; $ readyFds = stream_select ( $ readFds , $ writeFds , $ errorFds , $ timeout ) ; return ( $ readyFds > 0 ) ; } | Check if data is available on stdin |
25,784 | public function initialize ( array $ config ) { if ( ! $ this -> _config [ 'key' ] ) { $ this -> setConfig ( 'key' , Security :: getSalt ( ) ) ; } $ controller = $ this -> _registry -> getController ( ) ; if ( $ controller === null ) { $ this -> request = ServerRequestFactory :: fromGlobals ( ) ; } if ( empty ( $ this ... | Initialize config data and properties . |
25,785 | public function configKey ( $ keyname , $ option = null , $ value = null ) { if ( $ option === null ) { $ default = $ this -> _config ; $ local = isset ( $ this -> _keyConfig [ $ keyname ] ) ? $ this -> _keyConfig [ $ keyname ] : [ ] ; return $ local + $ default ; } if ( ! is_array ( $ option ) ) { $ option = [ $ optio... | Set the configuration for a specific top level key . |
25,786 | public function write ( $ key , $ value = null ) { if ( ! is_array ( $ key ) ) { $ key = [ $ key => $ value ] ; } $ keys = [ ] ; foreach ( $ key as $ name => $ value ) { $ this -> _load ( $ name ) ; $ this -> _values = Hash :: insert ( $ this -> _values , $ name , $ value ) ; $ parts = explode ( '.' , $ name ) ; $ keys... | Write a value to the response cookies . |
25,787 | public function read ( $ key = null ) { $ this -> _load ( $ key ) ; return Hash :: get ( $ this -> _values , $ key ) ; } | Read the value of key path from request cookies . |
25,788 | protected function _load ( $ key ) { $ parts = explode ( '.' , $ key ) ; $ first = array_shift ( $ parts ) ; if ( isset ( $ this -> _loaded [ $ first ] ) ) { return ; } $ cookie = $ this -> getController ( ) -> getRequest ( ) -> getCookie ( $ first ) ; if ( $ cookie === null ) { return ; } $ config = $ this -> configKe... | Load the cookie data from the request and response objects . |
25,789 | public function check ( $ key = null ) { if ( empty ( $ key ) ) { return false ; } return $ this -> read ( $ key ) !== null ; } | Returns true if given key is set in the cookie . |
25,790 | public function delete ( $ key ) { $ this -> _load ( $ key ) ; $ this -> _values = Hash :: remove ( $ this -> _values , $ key ) ; $ parts = explode ( '.' , $ key ) ; $ top = $ parts [ 0 ] ; if ( isset ( $ this -> _values [ $ top ] ) ) { $ this -> _write ( $ top , $ this -> _values [ $ top ] ) ; } else { $ this -> _dele... | Delete a cookie value |
25,791 | protected function _delete ( $ name ) { $ config = $ this -> configKey ( $ name ) ; $ expires = new Time ( 'now' ) ; $ controller = $ this -> getController ( ) ; $ cookie = new Cookie ( $ name , '' , $ expires , $ config [ 'path' ] , $ config [ 'domain' ] , ( bool ) $ config [ 'secure' ] , ( bool ) $ config [ 'httpOnly... | Sets a cookie expire time to remove cookie value . |
25,792 | public function next ( ) { parent :: next ( ) ; if ( $ this -> _validValues ) { $ this -> _values -> next ( ) ; } $ this -> _validValues = $ this -> _values -> valid ( ) ; } | Advances the cursor to the next record |
25,793 | public function current ( ) { $ row = parent :: current ( ) ; if ( ! $ this -> _validValues ) { return $ row ; } $ pointer = & $ row ; foreach ( $ this -> _path as $ step ) { if ( ! isset ( $ pointer [ $ step ] ) ) { return $ row ; } $ pointer = & $ pointer [ $ step ] ; } $ pointer [ $ this -> _target ] = $ this -> _va... | Returns the current element in the target collection after inserting the value from the source collection into the specified path . |
25,794 | public function rewind ( ) { parent :: rewind ( ) ; $ this -> _values -> rewind ( ) ; $ this -> _validValues = $ this -> _values -> valid ( ) ; } | Resets the collection pointer . |
25,795 | public function execute ( $ params = null ) { $ this -> _hasExecuted = true ; return $ this -> _statement -> execute ( $ params ) ; } | Executes the statement by sending the SQL query to the database . It can optionally take an array or arguments to be bound to the query variables . Please note that binding parameters from this method will not perform any custom type conversion as it would normally happen when calling bindValue . |
25,796 | public function bind ( $ params , $ types ) { if ( empty ( $ params ) ) { return ; } $ anonymousParams = is_int ( key ( $ params ) ) ? true : false ; $ offset = 1 ; foreach ( $ params as $ index => $ value ) { $ type = null ; if ( isset ( $ types [ $ index ] ) ) { $ type = $ types [ $ index ] ; } if ( $ anonymousParams... | Binds a set of values to statement object with corresponding type . |
25,797 | public function lastInsertId ( $ table = null , $ column = null ) { $ row = null ; if ( $ column && $ this -> columnCount ( ) ) { $ row = $ this -> fetch ( static :: FETCH_TYPE_ASSOC ) ; } if ( isset ( $ row [ $ column ] ) ) { return $ row [ $ column ] ; } return $ this -> _driver -> lastInsertId ( $ table , $ column )... | Returns the latest primary inserted using this statement . |
25,798 | public static function buildFromArray ( $ spec , $ defaultOptions = true ) { $ parser = new static ( $ spec [ 'command' ] , $ defaultOptions ) ; if ( ! empty ( $ spec [ 'arguments' ] ) ) { $ parser -> addArguments ( $ spec [ 'arguments' ] ) ; } if ( ! empty ( $ spec [ 'options' ] ) ) { $ parser -> addOptions ( $ spec [... | Build a parser from an array . Uses an array like |
25,799 | public function toArray ( ) { $ result = [ 'command' => $ this -> _command , 'arguments' => $ this -> _args , 'options' => $ this -> _options , 'subcommands' => $ this -> _subcommands , 'description' => $ this -> _description , 'epilog' => $ this -> _epilog ] ; return $ result ; } | Returns an array representation of this parser . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.