idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
26,200 | public function header ( $ name ) { deprecationWarning ( 'ServerRequest::header() is deprecated. ' . 'The automatic fallback to env() will be removed in 4.0.0, see getHeader()' ) ; $ name = $ this -> normalizeHeaderName ( $ name ) ; return $ this -> getEnv ( $ name ) ; } | Read an HTTP header from the Request information . |
26,201 | public function getHeaders ( ) { $ headers = [ ] ; foreach ( $ this -> _environment as $ key => $ value ) { $ name = null ; if ( strpos ( $ key , 'HTTP_' ) === 0 ) { $ name = substr ( $ key , 5 ) ; } if ( strpos ( $ key , 'CONTENT_' ) === 0 ) { $ name = $ key ; } if ( $ name !== null ) { $ name = str_replace ( '_' , ' ... | Get all headers in the request . |
26,202 | public function hasHeader ( $ name ) { $ name = $ this -> normalizeHeaderName ( $ name ) ; return isset ( $ this -> _environment [ $ name ] ) ; } | Check if a header is set in the request . |
26,203 | public function getHeader ( $ name ) { $ name = $ this -> normalizeHeaderName ( $ name ) ; if ( isset ( $ this -> _environment [ $ name ] ) ) { return ( array ) $ this -> _environment [ $ name ] ; } return [ ] ; } | Get a single header from the request . |
26,204 | public function withMethod ( $ method ) { $ new = clone $ this ; if ( ! is_string ( $ method ) || ! preg_match ( '/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i' , $ method ) ) { throw new InvalidArgumentException ( sprintf ( 'Unsupported HTTP method "%s" provided' , $ method ) ) ; } $ new -> _environment [ 'REQUEST_METHOD' ] = $ met... | Update the request method and get a new instance . |
26,205 | public function accepts ( $ type = null ) { $ raw = $ this -> parseAccept ( ) ; $ accept = [ ] ; foreach ( $ raw as $ types ) { $ accept = array_merge ( $ accept , $ types ) ; } if ( $ type === null ) { return $ accept ; } return in_array ( $ type , $ accept ) ; } | Find out which content types the client accepts or check if they accept a particular type of content . |
26,206 | public function acceptLanguage ( $ language = null ) { $ raw = $ this -> _parseAcceptWithQualifier ( $ this -> getHeaderLine ( 'Accept-Language' ) ) ; $ accept = [ ] ; foreach ( $ raw as $ languages ) { foreach ( $ languages as & $ lang ) { if ( strpos ( $ lang , '_' ) ) { $ lang = str_replace ( '_' , '-' , $ lang ) ; ... | Get the languages accepted by the client or check if a specific language is accepted . |
26,207 | public function getQuery ( $ name = null , $ default = null ) { if ( $ name === null ) { return $ this -> query ; } return Hash :: get ( $ this -> query , $ name , $ default ) ; } | Read a specific query value or dotted path . |
26,208 | public function cookie ( $ key ) { deprecationWarning ( 'ServerRequest::cookie() is deprecated. ' . 'Use getCookie() instead.' ) ; if ( isset ( $ this -> cookies [ $ key ] ) ) { return $ this -> cookies [ $ key ] ; } return null ; } | Read cookie data from the request s cookie data . |
26,209 | public function withCookieCollection ( CookieCollection $ cookies ) { $ new = clone $ this ; $ values = [ ] ; foreach ( $ cookies as $ cookie ) { $ values [ $ cookie -> getName ( ) ] = $ cookie -> getValue ( ) ; } $ new -> cookies = $ values ; return $ new ; } | Replace the cookies in the request with those contained in the provided CookieCollection . |
26,210 | public function allowMethod ( $ methods ) { $ methods = ( array ) $ methods ; foreach ( $ methods as $ method ) { if ( $ this -> is ( $ method ) ) { return true ; } } $ allowed = strtoupper ( implode ( ', ' , $ methods ) ) ; $ e = new MethodNotAllowedException ( ) ; $ e -> responseHeader ( 'Allow' , $ allowed ) ; throw... | Allow only certain HTTP request methods if the request method does not match a 405 error will be shown and the required Allow response header will be set . |
26,211 | public function withData ( $ name , $ value ) { $ copy = clone $ this ; $ copy -> data = Hash :: insert ( $ copy -> data , $ name , $ value ) ; return $ copy ; } | Update the request with a new request data element . |
26,212 | public function withoutData ( $ name ) { $ copy = clone $ this ; $ copy -> data = Hash :: remove ( $ copy -> data , $ name ) ; return $ copy ; } | Update the request removing a data element . |
26,213 | public function withParam ( $ name , $ value ) { $ copy = clone $ this ; $ copy -> params = Hash :: insert ( $ copy -> params , $ name , $ value ) ; return $ copy ; } | Update the request with a new routing parameter |
26,214 | public function withAttribute ( $ name , $ value ) { $ new = clone $ this ; if ( in_array ( $ name , $ this -> emulatedAttributes , true ) ) { $ new -> { $ name } = $ value ; } else { $ new -> attributes [ $ name ] = $ value ; } return $ new ; } | Return an instance with the specified request attribute . |
26,215 | public function withoutAttribute ( $ name ) { $ new = clone $ this ; if ( in_array ( $ name , $ this -> emulatedAttributes , true ) ) { throw new InvalidArgumentException ( "You cannot unset '$name'. It is a required CakePHP attribute." ) ; } unset ( $ new -> attributes [ $ name ] ) ; return $ new ; } | Return an instance without the specified request attribute . |
26,216 | public function getAttribute ( $ name , $ default = null ) { if ( in_array ( $ name , $ this -> emulatedAttributes , true ) ) { return $ this -> { $ name } ; } if ( array_key_exists ( $ name , $ this -> attributes ) ) { return $ this -> attributes [ $ name ] ; } return $ default ; } | Read an attribute from the request or get the default |
26,217 | public function getAttributes ( ) { $ emulated = [ 'params' => $ this -> params , 'webroot' => $ this -> webroot , 'base' => $ this -> base , 'here' => $ this -> here ] ; return $ this -> attributes + $ emulated ; } | Get all the attributes in the request . |
26,218 | public function getUploadedFile ( $ path ) { $ file = Hash :: get ( $ this -> uploadedFiles , $ path ) ; if ( ! $ file instanceof UploadedFile ) { return null ; } return $ file ; } | Get the uploaded file from a dotted path . |
26,219 | public function withUri ( UriInterface $ uri , $ preserveHost = false ) { $ new = clone $ this ; $ new -> uri = $ uri ; if ( $ preserveHost && $ this -> hasHeader ( 'Host' ) ) { return $ new ; } $ host = $ uri -> getHost ( ) ; if ( ! $ host ) { return $ new ; } if ( $ uri -> getPort ( ) ) { $ host .= ':' . $ uri -> get... | Return an instance with the specified uri |
26,220 | public function getPath ( ) { if ( $ this -> requestTarget === null ) { return $ this -> uri -> getPath ( ) ; } list ( $ path ) = explode ( '?' , $ this -> requestTarget ) ; return $ path ; } | Get the path of current request . |
26,221 | public function offsetGet ( $ name ) { deprecationWarning ( 'The ArrayAccess methods will be removed in 4.0.0.' . 'Use getParam(), getData() and getQuery() instead.' ) ; if ( isset ( $ this -> params [ $ name ] ) ) { return $ this -> params [ $ name ] ; } if ( $ name === 'url' ) { return $ this -> query ; } if ( $ name... | Array access read implementation |
26,222 | protected function _propertyExtractor ( $ callback ) { if ( ! is_string ( $ callback ) ) { return $ callback ; } $ path = explode ( '.' , $ callback ) ; if ( strpos ( $ callback , '{*}' ) !== false ) { return function ( $ element ) use ( $ path ) { return $ this -> _extract ( $ element , $ path ) ; } ; } return functio... | Returns a callable that can be used to extract a property or column from an array or object based on a dot separated path . |
26,223 | protected function _createMatcherFilter ( array $ conditions ) { $ matchers = [ ] ; foreach ( $ conditions as $ property => $ value ) { $ extractor = $ this -> _propertyExtractor ( $ property ) ; $ matchers [ ] = function ( $ v ) use ( $ extractor , $ value ) { return $ extractor ( $ v ) == $ value ; } ; } return funct... | Returns a callable that receives a value and will return whether or not it matches certain condition . |
26,224 | public function start ( $ name , $ mode = ViewBlock :: OVERRIDE ) { if ( array_key_exists ( $ name , $ this -> _active ) ) { throw new Exception ( sprintf ( "A view block with the name '%s' is already/still open." , $ name ) ) ; } $ this -> _active [ $ name ] = $ mode ; ob_start ( ) ; } | Start capturing output for a block |
26,225 | public function concat ( $ name , $ value = null , $ mode = ViewBlock :: APPEND ) { if ( $ value === null ) { $ this -> start ( $ name , $ mode ) ; return ; } if ( ! isset ( $ this -> _blocks [ $ name ] ) ) { $ this -> _blocks [ $ name ] = '' ; } if ( $ mode === ViewBlock :: PREPEND ) { $ this -> _blocks [ $ name ] = $... | Concat content to an existing or new block . Concating to a new block will create the block . |
26,226 | public function execute ( Arguments $ args , ConsoleIo $ io ) { $ io -> out ( Configure :: version ( ) ) ; return static :: CODE_SUCCESS ; } | Print out the version of CakePHP in use . |
26,227 | protected function _bufferResponseLines ( array $ responseLines ) { $ response = [ ] ; foreach ( $ responseLines as $ responseLine ) { if ( preg_match ( '/^(\d{3})(?:[ -]+(.*))?$/' , $ responseLine , $ match ) ) { $ response [ ] = [ 'code' => $ match [ 1 ] , 'message' => isset ( $ match [ 2 ] ) ? $ match [ 2 ] : null ]... | Parses and stores the response lines in code = > message format . |
26,228 | protected function _connect ( ) { $ this -> _generateSocket ( ) ; if ( ! $ this -> _socket -> connect ( ) ) { throw new SocketException ( 'Unable to connect to SMTP server.' ) ; } $ this -> _smtpSend ( null , '220' ) ; $ config = $ this -> _config ; if ( isset ( $ config [ 'client' ] ) ) { $ host = $ config [ 'client' ... | Connect to SMTP Server |
26,229 | protected function _prepareFromAddress ( $ email ) { $ from = $ email -> getReturnPath ( ) ; if ( empty ( $ from ) ) { $ from = $ email -> getFrom ( ) ; } return $ from ; } | Prepares the from email address . |
26,230 | protected function _prepareRecipientAddresses ( $ email ) { $ to = $ email -> getTo ( ) ; $ cc = $ email -> getCc ( ) ; $ bcc = $ email -> getBcc ( ) ; return array_merge ( array_keys ( $ to ) , array_keys ( $ cc ) , array_keys ( $ bcc ) ) ; } | Prepares the recipient email addresses . |
26,231 | protected function _prepareMessage ( $ email ) { $ lines = $ email -> message ( ) ; $ messages = [ ] ; foreach ( $ lines as $ line ) { if ( ! empty ( $ line ) && ( $ line [ 0 ] === '.' ) ) { $ messages [ ] = '.' . $ line ; } else { $ messages [ ] = $ line ; } } return implode ( "\r\n" , $ messages ) ; } | Prepares the message body . |
26,232 | protected function _smtpSend ( $ data , $ checkCode = '250' ) { $ this -> _lastResponse = [ ] ; if ( $ data !== null ) { $ this -> _socket -> write ( $ data . "\r\n" ) ; } $ timeout = $ this -> _config [ 'timeout' ] ; while ( $ checkCode !== false ) { $ response = '' ; $ startTime = time ( ) ; while ( substr ( $ respon... | Protected method for sending data to SMTP connection |
26,233 | public function out ( $ message = '' , $ newlines = 1 , $ level = self :: NORMAL ) { if ( $ level <= $ this -> _level ) { $ this -> _lastWritten = ( int ) $ this -> _out -> write ( $ message , $ newlines ) ; return $ this -> _lastWritten ; } return true ; } | Outputs a single or multiple messages to stdout . If no parameters are passed outputs just a newline . |
26,234 | public function overwrite ( $ message , $ newlines = 1 , $ size = null ) { $ size = $ size ? : $ this -> _lastWritten ; $ this -> out ( str_repeat ( "\x08" , $ size ) , 0 ) ; $ newBytes = $ this -> out ( $ message , 0 ) ; $ fill = $ size - $ newBytes ; if ( $ fill > 0 ) { $ this -> out ( str_repeat ( ' ' , $ fill ) , 0... | Overwrite some already output text . |
26,235 | public function hr ( $ newlines = 0 , $ width = 79 ) { $ this -> out ( null , $ newlines ) ; $ this -> out ( str_repeat ( '-' , $ width ) ) ; $ this -> out ( null , $ newlines ) ; } | Outputs a series of minus characters to the standard output acts as a visual separator . |
26,236 | public function styles ( $ style = null , $ definition = null ) { return $ this -> _out -> styles ( $ style , $ definition ) ; } | Add a new output style or get defined styles . |
26,237 | public function askChoice ( $ prompt , $ options , $ default = null ) { if ( $ options && is_string ( $ options ) ) { if ( strpos ( $ options , ',' ) ) { $ options = explode ( ',' , $ options ) ; } elseif ( strpos ( $ options , '/' ) ) { $ options = explode ( '/' , $ options ) ; } else { $ options = [ $ options ] ; } }... | Prompts the user for input based on a list of options and returns it . |
26,238 | public function setLoggers ( $ enable ) { Log :: drop ( 'stdout' ) ; Log :: drop ( 'stderr' ) ; if ( $ enable === false ) { return ; } $ outLevels = [ 'notice' , 'info' ] ; if ( $ enable === static :: VERBOSE || $ enable === true ) { $ outLevels [ ] = 'debug' ; } if ( $ enable !== static :: QUIET ) { $ stdout = new Con... | Connects or disconnects the loggers to the console output . |
26,239 | public function helper ( $ name , array $ settings = [ ] ) { $ name = ucfirst ( $ name ) ; return $ this -> _helpers -> load ( $ name , $ settings ) ; } | Render a Console Helper |
26,240 | public function createFile ( $ path , $ contents , $ forceOverwrite = false ) { $ this -> out ( ) ; $ forceOverwrite = $ forceOverwrite || $ this -> forceOverwrite ; if ( file_exists ( $ path ) && $ forceOverwrite === false ) { $ this -> warning ( "File `{$path}` exists" ) ; $ key = $ this -> askChoice ( 'Do you want t... | Create a file at the given path . |
26,241 | public function init ( array $ config = [ ] ) { parent :: init ( $ config ) ; if ( $ this -> _config [ 'path' ] === null ) { $ this -> _config [ 'path' ] = sys_get_temp_dir ( ) . DIRECTORY_SEPARATOR . 'cake_cache' . DIRECTORY_SEPARATOR ; } if ( DIRECTORY_SEPARATOR === '\\' ) { $ this -> _config [ 'isWindows' ] = true ;... | Initialize File Cache Engine |
26,242 | public function clear ( $ check ) { if ( ! $ this -> _init ) { return false ; } $ this -> _File = null ; $ threshold = $ now = false ; if ( $ check ) { $ now = time ( ) ; $ threshold = $ now - $ this -> _config [ 'duration' ] ; } $ this -> _clearDirectory ( $ this -> _config [ 'path' ] , $ now , $ threshold ) ; $ direc... | Delete all values from the cache |
26,243 | protected function _clearDirectory ( $ path , $ now , $ threshold ) { if ( ! is_dir ( $ path ) ) { return ; } $ prefixLength = strlen ( $ this -> _config [ 'prefix' ] ) ; $ dir = dir ( $ path ) ; while ( ( $ entry = $ dir -> read ( ) ) !== false ) { if ( substr ( $ entry , 0 , $ prefixLength ) !== $ this -> _config [ '... | Used to clear a directory of matching files . |
26,244 | protected function _setKey ( $ key , $ createKey = false ) { $ groups = null ; if ( $ this -> _groupPrefix ) { $ groups = vsprintf ( $ this -> _groupPrefix , $ this -> groups ( ) ) ; } $ dir = $ this -> _config [ 'path' ] . $ groups ; if ( ! is_dir ( $ dir ) ) { mkdir ( $ dir , 0775 , true ) ; } $ path = new SplFileInf... | Sets the current cache key this class is managing and creates a writable SplFileObject for the cache file the key is referring to . |
26,245 | protected function _active ( ) { $ dir = new SplFileInfo ( $ this -> _config [ 'path' ] ) ; $ path = $ dir -> getPathname ( ) ; $ success = true ; if ( ! is_dir ( $ path ) ) { $ success = @ mkdir ( $ path , 0775 , true ) ; } $ isWritableDir = ( $ dir -> isDir ( ) && $ dir -> isWritable ( ) ) ; if ( ! $ success || ( $ t... | Determine if cache directory is writable |
26,246 | public function parse ( $ url , $ method = '' ) { $ params = parent :: parse ( $ url , $ method ) ; if ( ! $ params ) { return false ; } $ redirect = $ this -> redirect ; if ( count ( $ this -> redirect ) === 1 && ! isset ( $ this -> redirect [ 'controller' ] ) ) { $ redirect = $ this -> redirect [ 0 ] ; } if ( isset (... | Parses a string URL into an array . Parsed URLs will result in an automatic redirection . |
26,247 | protected function _create ( $ class , $ alias , $ config ) { if ( is_object ( $ class ) ) { $ instance = $ class ; } unset ( $ config [ 'className' ] ) ; if ( ! isset ( $ instance ) ) { $ instance = new $ class ( $ config ) ; } if ( ! ( $ instance instanceof CacheEngine ) ) { throw new RuntimeException ( 'Cache engine... | Create the cache engine instance . |
26,248 | public function createView ( $ viewClass = null ) { $ builder = $ this -> viewBuilder ( ) ; if ( $ viewClass === null && $ builder -> getClassName ( ) === null ) { $ builder -> setClassName ( $ this -> viewClass ) ; $ this -> viewClass = null ; } if ( $ viewClass ) { $ builder -> setClassName ( $ viewClass ) ; } $ vali... | Constructs the view class instance based on the current configuration . |
26,249 | public function set ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { if ( is_array ( $ value ) ) { $ data = array_combine ( $ name , $ value ) ; } else { $ data = $ name ; } } else { $ data = [ $ name => $ value ] ; } $ this -> viewVars = $ data + $ this -> viewVars ; return $ this ; } | Saves a variable or an associative array of variables for use inside a template . |
26,250 | public function run ( callable $ action ) { $ retryCount = 0 ; $ lastException = null ; do { try { return $ action ( ) ; } catch ( Exception $ e ) { $ lastException = $ e ; if ( ! $ this -> strategy -> shouldRetry ( $ e , $ retryCount ) ) { throw $ e ; } } } while ( $ this -> retries > $ retryCount ++ ) ; if ( $ lastEx... | The number of retries to perform in case of failure |
26,251 | public function setExtensions ( array $ extensions ) { $ this -> _extensions = [ ] ; foreach ( $ extensions as $ ext ) { $ this -> _extensions [ ] = strtolower ( $ ext ) ; } return $ this ; } | Set the supported extensions for this route . |
26,252 | public function setMethods ( array $ methods ) { $ methods = array_map ( 'strtoupper' , $ methods ) ; $ diff = array_diff ( $ methods , static :: VALID_METHODS ) ; if ( $ diff !== [ ] ) { throw new InvalidArgumentException ( sprintf ( 'Invalid HTTP method received. %s is invalid.' , implode ( ', ' , $ diff ) ) ) ; } $ ... | Set the accepted HTTP methods for this route . |
26,253 | public function setPatterns ( array $ patterns ) { $ patternValues = implode ( "" , $ patterns ) ; if ( mb_strlen ( $ patternValues ) < strlen ( $ patternValues ) ) { $ this -> options [ 'multibytePattern' ] = true ; } $ this -> options = array_merge ( $ this -> options , $ patterns ) ; return $ this ; } | Set regexp patterns for routing parameters |
26,254 | public function hostMatches ( $ host ) { $ pattern = '@^' . str_replace ( '\*' , '.*' , preg_quote ( $ this -> options [ '_host' ] , '@' ) ) . '$@' ; return preg_match ( $ pattern , $ host ) !== 0 ; } | Check to see if the host matches the route requirements |
26,255 | protected function _parseArgs ( $ args , $ context ) { $ pass = [ ] ; $ args = explode ( '/' , $ args ) ; foreach ( $ args as $ param ) { if ( empty ( $ param ) && $ param !== '0' && $ param !== 0 ) { continue ; } $ pass [ ] = rawurldecode ( $ param ) ; } return $ pass ; } | Parse passed parameters into a list of passed args . |
26,256 | protected function _persistParams ( array $ url , array $ params ) { foreach ( $ this -> options [ 'persist' ] as $ persistKey ) { if ( array_key_exists ( $ persistKey , $ params ) && ! isset ( $ url [ $ persistKey ] ) ) { $ url [ $ persistKey ] = $ params [ $ persistKey ] ; } } return $ url ; } | Apply persistent parameters to a URL array . Persistent parameters are a special key used during route creation to force route parameters to persist when omitted from a URL array . |
26,257 | protected function _matchMethod ( $ url ) { if ( empty ( $ this -> defaults [ '_method' ] ) ) { return true ; } if ( isset ( $ url [ '[method]' ] ) ) { deprecationWarning ( 'The `[method]` key is deprecated. Use `_method` instead.' ) ; $ url [ '_method' ] = $ url [ '[method]' ] ; } if ( empty ( $ url [ '_method' ] ) ) ... | Check whether or not the URL s HTTP method matches . |
26,258 | protected function _writeUrl ( $ params , $ pass = [ ] , $ query = [ ] ) { $ pass = implode ( '/' , array_map ( 'rawurlencode' , $ pass ) ) ; $ out = $ this -> template ; $ search = $ replace = [ ] ; foreach ( $ this -> keys as $ key ) { $ string = null ; if ( isset ( $ params [ $ key ] ) ) { $ string = $ params [ $ ke... | Converts a matching route array into a URL string . |
26,259 | public function staticPath ( ) { $ routeKey = strpos ( $ this -> template , ':' ) ; if ( $ routeKey !== false ) { return substr ( $ this -> template , 0 , $ routeKey ) ; } $ routeKey = strpos ( $ this -> template , '{' ) ; if ( $ routeKey !== false && strpos ( $ this -> template , '}' ) !== false ) { return substr ( $ ... | Get the static path portion for this route . |
26,260 | public function findPath ( $ name ) { $ this -> loadConfig ( ) ; $ path = Configure :: read ( 'plugins.' . $ name ) ; if ( $ path ) { return $ path ; } $ pluginPath = str_replace ( '/' , DIRECTORY_SEPARATOR , $ name ) ; $ paths = App :: path ( 'Plugin' ) ; foreach ( $ paths as $ path ) { if ( is_dir ( $ path . $ plugin... | Locate a plugin path by looking at configuration data . |
26,261 | public function add ( PluginInterface $ plugin ) { $ name = $ plugin -> getName ( ) ; $ this -> plugins [ $ name ] = $ plugin ; $ this -> names = array_keys ( $ this -> plugins ) ; return $ this ; } | Add a plugin to the collection |
26,262 | public function remove ( $ name ) { unset ( $ this -> plugins [ $ name ] ) ; $ this -> names = array_keys ( $ this -> plugins ) ; return $ this ; } | Remove a plugin from the collection if it exists . |
26,263 | public function get ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new MissingPluginException ( [ 'plugin' => $ name ] ) ; } return $ this -> plugins [ $ name ] ; } | Get the a plugin by name |
26,264 | public function with ( $ hook ) { if ( ! in_array ( $ hook , PluginInterface :: VALID_HOOKS ) ) { throw new InvalidArgumentException ( "The `{$hook}` hook is not a known plugin hook." ) ; } foreach ( $ this as $ plugin ) { if ( $ plugin -> isEnabled ( $ hook ) ) { yield $ plugin ; } } } | Filter the plugins to those with the named hook enabled . |
26,265 | public function params ( $ model = null ) { $ request = $ this -> _View -> getRequest ( ) ; if ( empty ( $ model ) ) { $ model = $ this -> defaultModel ( ) ; } if ( ! $ request -> getParam ( 'paging' ) || ! $ request -> getParam ( 'paging.' . $ model ) ) { return [ ] ; } return $ request -> getParam ( 'paging.' . $ mod... | Gets the current paging parameters from the resultset for the given model |
26,266 | public function options ( array $ options = [ ] ) { $ request = $ this -> _View -> getRequest ( ) ; if ( ! empty ( $ options [ 'paging' ] ) ) { $ request = $ request -> withParam ( 'paging' , $ options [ 'paging' ] + $ request -> getParam ( 'paging' , [ ] ) ) ; unset ( $ options [ 'paging' ] ) ; } $ model = $ this -> d... | Sets default options for all pagination links |
26,267 | public function current ( $ model = null ) { $ params = $ this -> params ( $ model ) ; if ( isset ( $ params [ 'page' ] ) ) { return $ params [ 'page' ] ; } return 1 ; } | Gets the current page of the recordset for the given model |
26,268 | public function total ( $ model = null ) { $ params = $ this -> params ( $ model ) ; if ( isset ( $ params [ 'pageCount' ] ) ) { return $ params [ 'pageCount' ] ; } return 0 ; } | Gets the total number of pages in the recordset for the given model . |
26,269 | public function sortKey ( $ model = null , array $ options = [ ] ) { if ( empty ( $ options ) ) { $ options = $ this -> params ( $ model ) ; } if ( ! empty ( $ options [ 'sort' ] ) ) { return $ options [ 'sort' ] ; } return null ; } | Gets the current key by which the recordset is sorted |
26,270 | public function sortDir ( $ model = null , array $ options = [ ] ) { $ dir = null ; if ( empty ( $ options ) ) { $ options = $ this -> params ( $ model ) ; } if ( isset ( $ options [ 'direction' ] ) ) { $ dir = strtolower ( $ options [ 'direction' ] ) ; } if ( $ dir === 'desc' ) { return 'desc' ; } return 'asc' ; } | Gets the current direction the recordset is sorted |
26,271 | public function prev ( $ title = '<< Previous' , array $ options = [ ] ) { $ defaults = [ 'url' => [ ] , 'model' => $ this -> defaultModel ( ) , 'disabledTitle' => $ title , 'escape' => true , ] ; $ options += $ defaults ; $ options [ 'step' ] = - 1 ; $ enabled = $ this -> hasPrev ( $ options [ 'model' ] ) ; $ template... | Generates a previous link for a set of paged records |
26,272 | public function sort ( $ key , $ title = null , array $ options = [ ] ) { $ options += [ 'url' => [ ] , 'model' => null , 'escape' => true ] ; $ url = $ options [ 'url' ] ; unset ( $ options [ 'url' ] ) ; if ( empty ( $ title ) ) { $ title = $ key ; if ( strpos ( $ title , '.' ) !== false ) { $ title = str_replace ( '.... | Generates a sorting link . Sets named parameters for the sort and direction . Handles direction switching automatically . |
26,273 | public function defaultModel ( $ model = null ) { if ( $ model !== null ) { $ this -> _defaultModel = $ model ; } if ( $ this -> _defaultModel ) { return $ this -> _defaultModel ; } if ( ! $ this -> _View -> getRequest ( ) -> getParam ( 'paging' ) ) { return null ; } list ( $ this -> _defaultModel ) = array_keys ( $ th... | Gets or sets the default model of the paged sets |
26,274 | public function counter ( $ options = [ ] ) { if ( is_string ( $ options ) ) { $ options = [ 'format' => $ options ] ; } $ options += [ 'model' => $ this -> defaultModel ( ) , 'format' => 'pages' , ] ; $ paging = $ this -> params ( $ options [ 'model' ] ) ; if ( ! $ paging [ 'pageCount' ] ) { $ paging [ 'pageCount' ] =... | Returns a counter string for the paged result set |
26,275 | protected function _getNumbersStartAndEnd ( $ params , $ options ) { $ half = ( int ) ( $ options [ 'modulus' ] / 2 ) ; $ end = max ( 1 + $ options [ 'modulus' ] , $ params [ 'page' ] + $ half ) ; $ start = min ( $ params [ 'pageCount' ] - $ options [ 'modulus' ] , $ params [ 'page' ] - $ half - $ options [ 'modulus' ]... | Calculates the start and end for the pagination numbers . |
26,276 | protected function _formatNumber ( $ templater , $ options ) { $ url = array_merge ( $ options [ 'url' ] , [ 'page' => $ options [ 'page' ] ] ) ; $ vars = [ 'text' => $ options [ 'text' ] , 'url' => $ this -> generateUrl ( $ url , $ options [ 'model' ] ) , ] ; return $ templater -> format ( 'number' , $ vars ) ; } | Formats a number for the paginator number output . |
26,277 | public function meta ( array $ options = [ ] ) { $ options += [ 'model' => null , 'block' => false , 'prev' => true , 'next' => true , 'first' => false , 'last' => false ] ; $ model = isset ( $ options [ 'model' ] ) ? $ options [ 'model' ] : null ; $ params = $ this -> params ( $ model ) ; $ links = [ ] ; if ( $ option... | Returns the meta - links for a paginated result set . |
26,278 | public function limitControl ( array $ limits = [ ] , $ default = null , array $ options = [ ] ) { $ out = $ this -> Form -> create ( null , [ 'type' => 'get' ] ) ; if ( empty ( $ default ) || ! is_numeric ( $ default ) ) { $ default = $ this -> param ( 'perPage' ) ; } if ( empty ( $ limits ) ) { $ limits = [ '20' => '... | Dropdown select for pagination limit . This will generate a wrapping form . |
26,279 | public function queryTranslator ( $ type ) { return function ( $ query ) use ( $ type ) { if ( $ this -> isAutoQuotingEnabled ( ) ) { $ query = ( new IdentifierQuoter ( $ this ) ) -> quote ( $ query ) ; } $ query = $ this -> { '_' . $ type . 'QueryTranslator' } ( $ query ) ; $ translators = $ this -> _expressionTransla... | Returns a callable function that will be used to transform a passed Query object . This function in turn will return an instance of a Query object that has been transformed to accommodate any specificities of the SQL dialect in use . |
26,280 | protected function _deleteQueryTranslator ( $ query ) { $ hadAlias = false ; $ tables = [ ] ; foreach ( $ query -> clause ( 'from' ) as $ alias => $ table ) { if ( is_string ( $ alias ) ) { $ hadAlias = true ; } $ tables [ ] = $ table ; } if ( $ hadAlias ) { $ query -> from ( $ tables , true ) ; } if ( ! $ hadAlias ) {... | Apply translation steps to delete queries . |
26,281 | protected function _removeAliasesFromConditions ( $ query ) { if ( $ query -> clause ( 'join' ) ) { throw new \ RuntimeException ( 'Aliases are being removed from conditions for UPDATE/DELETE queries, ' . 'this can break references to joined tables.' ) ; } $ conditions = $ query -> clause ( 'where' ) ; if ( $ condition... | Removes aliases from the WHERE clause of a query . |
26,282 | public function add ( $ alias , Association $ association ) { list ( , $ alias ) = pluginSplit ( $ alias ) ; return $ this -> _items [ strtolower ( $ alias ) ] = $ association ; } | Add an association to the collection |
26,283 | public function load ( $ className , $ associated , array $ options = [ ] ) { $ options += [ 'tableLocator' => $ this -> getTableLocator ( ) ] ; $ association = new $ className ( $ associated , $ options ) ; if ( ! $ association instanceof Association ) { $ message = sprintf ( 'The association must extend `%s` class, `... | Creates and adds the Association object to this collection . |
26,284 | public function get ( $ alias ) { $ alias = strtolower ( $ alias ) ; if ( isset ( $ this -> _items [ $ alias ] ) ) { return $ this -> _items [ $ alias ] ; } return null ; } | Fetch an attached association by name . |
26,285 | public function getByProperty ( $ prop ) { foreach ( $ this -> _items as $ assoc ) { if ( $ assoc -> getProperty ( ) === $ prop ) { return $ assoc ; } } return null ; } | Fetch an association by property name . |
26,286 | public function getByType ( $ class ) { $ class = array_map ( 'strtolower' , ( array ) $ class ) ; $ out = array_filter ( $ this -> _items , function ( $ assoc ) use ( $ class ) { list ( , $ name ) = namespaceSplit ( get_class ( $ assoc ) ) ; return in_array ( strtolower ( $ name ) , $ class , true ) ; } ) ; return arr... | Get an array of associations matching a specific type . |
26,287 | public function saveParents ( Table $ table , EntityInterface $ entity , $ associations , array $ options = [ ] ) { if ( empty ( $ associations ) ) { return true ; } return $ this -> _saveAssociations ( $ table , $ entity , $ associations , $ options , false ) ; } | Save all the associations that are parents of the given entity . |
26,288 | public function saveChildren ( Table $ table , EntityInterface $ entity , array $ associations , array $ options ) { if ( empty ( $ associations ) ) { return true ; } return $ this -> _saveAssociations ( $ table , $ entity , $ associations , $ options , true ) ; } | Save all the associations that are children of the given entity . |
26,289 | public function cascadeDelete ( EntityInterface $ entity , array $ options ) { $ noCascade = $ this -> _getNoCascadeItems ( $ entity , $ options ) ; foreach ( $ noCascade as $ assoc ) { $ assoc -> cascadeDelete ( $ entity , $ options ) ; } } | Cascade a delete across the various associations . Cascade first across associations for which cascadeCallbacks is true . |
26,290 | protected function _getNoCascadeItems ( $ entity , $ options ) { $ noCascade = [ ] ; foreach ( $ this -> _items as $ assoc ) { if ( ! $ assoc -> getCascadeCallbacks ( ) ) { $ noCascade [ ] = $ assoc ; continue ; } $ assoc -> cascadeDelete ( $ entity , $ options ) ; } return $ noCascade ; } | Returns items that have no cascade callback . |
26,291 | public function normalizeKeys ( $ keys ) { if ( $ keys === true ) { $ keys = $ this -> keys ( ) ; } if ( empty ( $ keys ) ) { return [ ] ; } return $ this -> _normalizeAssociations ( $ keys ) ; } | Returns an associative array of association names out a mixed array . If true is passed then it returns all association names in this collection . |
26,292 | public function setEncoding ( $ encoding ) { $ this -> connect ( ) ; $ this -> _connection -> exec ( 'SET NAMES ' . $ this -> _connection -> quote ( $ encoding ) ) ; } | Sets connection encoding |
26,293 | public function setSchema ( $ schema ) { $ this -> connect ( ) ; $ this -> _connection -> exec ( 'SET search_path TO ' . $ this -> _connection -> quote ( $ schema ) ) ; } | Sets connection default schema if any relation defined in a query is not fully qualified postgres will fallback to looking the relation into defined default schema |
26,294 | protected function decodeCookies ( ServerRequestInterface $ request ) { $ cookies = $ request -> getCookieParams ( ) ; foreach ( $ this -> cookieNames as $ name ) { if ( isset ( $ cookies [ $ name ] ) ) { $ cookies [ $ name ] = $ this -> _decrypt ( $ cookies [ $ name ] , $ this -> cipherType , $ this -> key ) ; } } ret... | Decode cookies from the request . |
26,295 | protected function encodeCookies ( Response $ response ) { $ cookies = $ response -> getCookieCollection ( ) ; foreach ( $ cookies as $ cookie ) { if ( in_array ( $ cookie -> getName ( ) , $ this -> cookieNames , true ) ) { $ value = $ this -> _encrypt ( $ cookie -> getValue ( ) , $ this -> cipherType ) ; $ response = ... | Encode cookies from a response s CookieCollection . |
26,296 | protected function encodeSetCookieHeader ( ResponseInterface $ response ) { $ cookies = CookieCollection :: createFromHeader ( $ response -> getHeader ( 'Set-Cookie' ) ) ; $ header = [ ] ; foreach ( $ cookies as $ cookie ) { if ( in_array ( $ cookie -> getName ( ) , $ this -> cookieNames , true ) ) { $ value = $ this -... | Encode cookies from a response s Set - Cookie header |
26,297 | public static function alias ( $ short , $ original = null ) { $ short = Inflector :: camelize ( $ short ) ; if ( $ original ) { static :: $ _aliases [ $ short ] = $ original ; } return isset ( static :: $ _aliases [ $ short ] ) ? static :: $ _aliases [ $ short ] : false ; } | Add an alias for a shell command . |
26,298 | protected function _initEnvironment ( ) { if ( ! $ this -> _bootstrap ( ) ) { $ message = "Unable to load CakePHP core.\nMake sure Cake exists in " . CAKE_CORE_INCLUDE_PATH ; throw new Exception ( $ message ) ; } if ( function_exists ( 'ini_set' ) ) { ini_set ( 'html_errors' , '0' ) ; ini_set ( 'implicit_flush' , '1' )... | Defines current working environment . |
26,299 | public function dispatch ( $ extra = [ ] ) { try { $ result = $ this -> _dispatch ( $ extra ) ; } catch ( StopException $ e ) { return $ e -> getCode ( ) ; } if ( $ result === null || $ result === true ) { return Shell :: CODE_SUCCESS ; } if ( is_int ( $ result ) ) { return $ result ; } return Shell :: CODE_ERROR ; } | Dispatches a CLI request |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.