idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
26,300
public function addShortPluginAliases ( ) { $ plugins = Plugin :: loaded ( ) ; $ io = new ConsoleIo ( ) ; $ task = new CommandTask ( $ io ) ; $ io -> setLoggers ( false ) ; $ list = $ task -> getShellList ( ) + [ 'app' => [ ] ] ; $ fixed = array_flip ( $ list [ 'app' ] ) + array_flip ( $ list [ 'CORE' ] ) ; $ aliases =...
For all loaded plugins add a short alias
26,301
public function findShell ( $ shell ) { $ className = $ this -> _shellExists ( $ shell ) ; if ( ! $ className ) { $ shell = $ this -> _handleAlias ( $ shell ) ; $ className = $ this -> _shellExists ( $ shell ) ; } if ( ! $ className ) { throw new MissingShellException ( [ 'class' => $ shell , ] ) ; } return $ this -> _...
Get shell to use either plugin shell or application shell
26,302
protected function _handleAlias ( $ shell ) { $ aliased = static :: alias ( $ shell ) ; if ( $ aliased ) { $ shell = $ aliased ; } $ class = array_map ( 'Cake\Utility\Inflector::camelize' , explode ( '.' , $ shell ) ) ; return implode ( '.' , $ class ) ; }
If the input matches an alias return the aliased shell name
26,303
protected function _createShell ( $ className , $ shortName ) { list ( $ plugin ) = pluginSplit ( $ shortName ) ; $ instance = new $ className ( ) ; $ instance -> plugin = trim ( $ plugin , '.' ) ; return $ instance ; }
Create the given shell name and set the plugin property
26,304
public function clear ( $ check ) { if ( $ check ) { return true ; } if ( class_exists ( 'APCuIterator' , false ) ) { $ iterator = new APCuIterator ( '/^' . preg_quote ( $ this -> _config [ 'prefix' ] , '/' ) . '/' , APC_ITER_NONE ) ; apcu_delete ( $ iterator ) ; return true ; } $ cache = apcu_cache_info ( ) ; foreach ...
Delete all keys from the cache . This will clear every cache config using APC .
26,305
public function types ( array $ types = null ) { deprecationWarning ( 'TypeMap::types() is deprecated. ' . 'Use TypeMap::setTypes()/getTypes() instead.' ) ; if ( $ types !== null ) { return $ this -> setTypes ( $ types ) ; } return $ this -> getTypes ( ) ; }
Sets a map of fields and their associated types for single - use .
26,306
public function type ( $ column ) { if ( isset ( $ this -> _types [ $ column ] ) ) { return $ this -> _types [ $ column ] ; } if ( isset ( $ this -> _defaults [ $ column ] ) ) { return $ this -> _defaults [ $ column ] ; } return null ; }
Returns the type of the given column . If there is no single use type is configured the column type will be looked for inside the default mapping . If neither exist null will be returned .
26,307
public function cascadeDelete ( Association $ association , EntityInterface $ entity , array $ options = [ ] ) { if ( ! $ association -> getDependent ( ) ) { return true ; } $ table = $ association -> getTarget ( ) ; $ foreignKey = array_map ( [ $ association , 'aliasField' ] , ( array ) $ association -> getForeignKey ...
Cascade a delete to remove dependent records .
26,308
protected function _assertFieldsPresent ( $ fetchQuery , $ key ) { $ select = $ fetchQuery -> aliasFields ( $ fetchQuery -> clause ( 'select' ) ) ; if ( empty ( $ select ) ) { return ; } $ missingKey = function ( $ fieldList , $ key ) { foreach ( $ key as $ keyField ) { if ( ! in_array ( $ keyField , $ fieldList , true...
Checks that the fetching query either has auto fields on or has the foreignKey fields selected . If the required fields are missing throws an exception .
26,309
protected function _addFilteringJoin ( $ query , $ key , $ subquery ) { $ filter = [ ] ; $ aliasedTable = $ this -> sourceAlias ; foreach ( $ subquery -> clause ( 'select' ) as $ aliasedField => $ field ) { if ( is_int ( $ aliasedField ) ) { $ filter [ ] = new IdentifierExpression ( $ field ) ; } else { $ filter [ $ al...
Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values when the filtering needs to be done using a subquery .
26,310
protected function _addFilteringCondition ( $ query , $ key , $ filter ) { if ( is_array ( $ key ) ) { $ conditions = $ this -> _createTupleCondition ( $ query , $ key , $ filter , 'IN' ) ; } $ conditions = isset ( $ conditions ) ? $ conditions : [ $ key . ' IN' => $ filter ] ; return $ query -> andWhere ( $ conditions...
Appends any conditions required to load the relevant set of records in the target table query given a filter key and some filtering values .
26,311
protected function _buildSubquery ( $ query ) { $ filterQuery = clone $ query ; $ filterQuery -> disableAutoFields ( ) ; $ filterQuery -> mapReduce ( null , null , true ) ; $ filterQuery -> formatResults ( null , true ) ; $ filterQuery -> contain ( [ ] , true ) ; $ filterQuery -> setValueBinder ( new ValueBinder ( ) ) ...
Builds a query to be used as a condition for filtering records in the target table it is constructed by cloning the original query that was used to load records in the source table .
26,312
protected function _subqueryFields ( $ query ) { $ keys = ( array ) $ this -> bindingKey ; if ( $ this -> associationType === Association :: MANY_TO_ONE ) { $ keys = ( array ) $ this -> foreignKey ; } $ fields = $ query -> aliasFields ( $ keys , $ this -> sourceAlias ) ; $ group = $ fields = array_values ( $ fields ) ;...
Calculate the fields that need to participate in a subquery .
26,313
protected function _resultInjector ( $ fetchQuery , $ resultMap , $ options ) { $ keys = $ this -> associationType === Association :: MANY_TO_ONE ? $ this -> foreignKey : $ this -> bindingKey ; $ sourceKeys = [ ] ; foreach ( ( array ) $ keys as $ key ) { $ f = $ fetchQuery -> aliasField ( $ key , $ this -> sourceAlias ...
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows
26,314
protected function _multiKeysInjector ( $ resultMap , $ sourceKeys , $ nestKey ) { return function ( $ row ) use ( $ resultMap , $ sourceKeys , $ nestKey ) { $ values = [ ] ; foreach ( $ sourceKeys as $ key ) { $ values [ ] = $ row [ $ key ] ; } $ key = implode ( ';' , $ values ) ; if ( isset ( $ resultMap [ $ key ] ) ...
Returns a callable to be used for each row in a query result set for injecting the eager loaded rows when the matching needs to be done with multiple foreign keys
26,315
protected static function _defaultConfig ( $ name ) { $ defaults = [ 'php' => [ 'cookie' => 'CAKEPHP' , 'ini' => [ 'session.use_trans_sid' => 0 , ] ] , 'cake' => [ 'cookie' => 'CAKEPHP' , 'ini' => [ 'session.use_trans_sid' => 0 , 'session.serialize_handler' => 'php' , 'session.use_cookies' => 1 , 'session.save_path' =>...
Get one of the prebaked default session configurations .
26,316
public function engine ( $ class = null , array $ options = [ ] ) { if ( $ class === null ) { return $ this -> _engine ; } if ( $ class instanceof SessionHandlerInterface ) { return $ this -> setEngine ( $ class ) ; } $ className = App :: className ( $ class , 'Http/Session' ) ; if ( ! $ className ) { $ className = App...
Sets the session handler instance to use for this session . If a string is passed for the first argument it will be treated as the class name and the second argument will be passed as the first argument in the constructor .
26,317
protected function setEngine ( SessionHandlerInterface $ handler ) { if ( ! headers_sent ( ) && session_status ( ) !== \ PHP_SESSION_ACTIVE ) { session_set_save_handler ( $ handler , false ) ; } return $ this -> _engine = $ handler ; }
Set the engine property and update the session handler in PHP .
26,318
public function close ( ) { if ( ! $ this -> _started ) { return true ; } if ( ! session_write_close ( ) ) { throw new RuntimeException ( 'Could not close the session' ) ; } $ this -> _started = false ; return true ; }
Write data and close the session
26,319
public function check ( $ name = null ) { if ( $ this -> _hasSession ( ) && ! $ this -> started ( ) ) { $ this -> start ( ) ; } if ( ! isset ( $ _SESSION ) ) { return false ; } return Hash :: get ( $ _SESSION , $ name ) !== null ; }
Returns true if given variable name is set in session .
26,320
public function consume ( $ name ) { if ( empty ( $ name ) ) { return null ; } $ value = $ this -> read ( $ name ) ; if ( $ value !== null ) { $ this -> _overwrite ( $ _SESSION , Hash :: remove ( $ _SESSION , $ name ) ) ; } return $ value ; }
Reads and deletes a variable from session .
26,321
public function write ( $ name , $ value = null ) { if ( ! $ this -> started ( ) ) { $ this -> start ( ) ; } $ write = $ name ; if ( ! is_array ( $ name ) ) { $ write = [ $ name => $ value ] ; } $ data = isset ( $ _SESSION ) ? $ _SESSION : [ ] ; foreach ( $ write as $ key => $ val ) { $ data = Hash :: insert ( $ data ,...
Writes value to given session variable name .
26,322
public function delete ( $ name ) { if ( $ this -> check ( $ name ) ) { $ this -> _overwrite ( $ _SESSION , Hash :: remove ( $ _SESSION , $ name ) ) ; } }
Removes a variable from session .
26,323
protected function _overwrite ( & $ old , $ new ) { if ( ! empty ( $ old ) ) { foreach ( $ old as $ key => $ var ) { if ( ! isset ( $ new [ $ key ] ) ) { unset ( $ old [ $ key ] ) ; } } } foreach ( $ new as $ key => $ var ) { $ old [ $ key ] = $ var ; } }
Used to write new data to _SESSION since PHP doesn t like us setting the _SESSION var itself .
26,324
public function destroy ( ) { if ( $ this -> _hasSession ( ) && ! $ this -> started ( ) ) { $ this -> start ( ) ; } if ( ! $ this -> _isCLI && session_status ( ) === \ PHP_SESSION_ACTIVE ) { session_destroy ( ) ; } $ _SESSION = [ ] ; $ this -> _started = false ; }
Helper method to destroy invalid sessions .
26,325
protected function _hasSession ( ) { return ! ini_get ( 'session.use_cookies' ) || isset ( $ _COOKIE [ session_name ( ) ] ) || $ this -> _isCLI || ( ini_get ( 'session.use_trans_sid' ) && isset ( $ _GET [ session_name ( ) ] ) ) ; }
Returns whether a session exists
26,326
public function renew ( ) { if ( ! $ this -> _hasSession ( ) || $ this -> _isCLI ) { return ; } $ this -> start ( ) ; $ params = session_get_cookie_params ( ) ; setcookie ( session_name ( ) , '' , time ( ) - 42000 , $ params [ 'path' ] , $ params [ 'domain' ] , $ params [ 'secure' ] , $ params [ 'httponly' ] ) ; if ( s...
Restarts this session .
26,327
protected function _timedOut ( ) { $ time = $ this -> read ( 'Config.time' ) ; $ result = false ; $ checkTime = $ time !== null && $ this -> _lifetime > 0 ; if ( $ checkTime && ( time ( ) - ( int ) $ time > $ this -> _lifetime ) ) { $ result = true ; } $ this -> write ( 'Config.time' , time ( ) ) ; return $ result ; }
Returns true if the session is no longer valid because the last time it was accessed was after the configured timeout .
26,328
public function addCrumb ( $ name , $ link = null , array $ options = [ ] ) { deprecationWarning ( 'HtmlHelper::addCrumb() is deprecated. ' . 'Use the BreadcrumbsHelper instead.' ) ; $ this -> _crumbs [ ] = [ $ name , $ link , $ options ] ; return $ this ; }
Adds a link to the breadcrumbs array .
26,329
public function docType ( $ type = 'html5' ) { if ( isset ( $ this -> _docTypes [ $ type ] ) ) { return $ this -> _docTypes [ $ type ] ; } return null ; }
Returns a doctype string .
26,330
public function charset ( $ charset = null ) { if ( empty ( $ charset ) ) { $ charset = strtolower ( Configure :: read ( 'App.encoding' ) ) ; } return $ this -> formatTemplate ( 'charset' , [ 'charset' => ! empty ( $ charset ) ? $ charset : 'utf-8' ] ) ; }
Returns a charset META - tag .
26,331
public function css ( $ path , array $ options = [ ] ) { $ options += [ 'once' => true , 'block' => null , 'rel' => 'stylesheet' ] ; if ( is_array ( $ path ) ) { $ out = '' ; foreach ( $ path as $ i ) { $ out .= "\n\t" . $ this -> css ( $ i , $ options ) ; } if ( empty ( $ options [ 'block' ] ) ) { return $ out . "\n" ...
Creates a link element for CSS stylesheets .
26,332
public function scriptEnd ( ) { $ buffer = ob_get_clean ( ) ; $ options = $ this -> _scriptBlockOptions ; $ this -> _scriptBlockOptions = [ ] ; return $ this -> scriptBlock ( $ buffer , $ options ) ; }
End a Buffered section of JavaScript capturing . Generates a script tag inline or appends to specified view block depending on the settings used when the scriptBlock was started
26,333
public function style ( array $ data , $ oneLine = true ) { $ out = [ ] ; foreach ( $ data as $ key => $ value ) { $ out [ ] = $ key . ':' . $ value . ';' ; } if ( $ oneLine ) { return implode ( ' ' , $ out ) ; } return implode ( "\n" , $ out ) ; }
Builds CSS style data from an array of CSS properties
26,334
public function getCrumbs ( $ separator = '»' , $ startText = false ) { deprecationWarning ( 'HtmlHelper::getCrumbs() is deprecated. ' . 'Use the BreadcrumbsHelper instead.' ) ; $ crumbs = $ this -> _prepareCrumbs ( $ startText ) ; if ( ! empty ( $ crumbs ) ) { $ out = [ ] ; foreach ( $ crumbs as $ crumb ) { if (...
Returns the breadcrumb trail as a sequence of &raquo ; - separated links .
26,335
protected function _prepareCrumbs ( $ startText , $ escape = true ) { deprecationWarning ( 'HtmlHelper::_prepareCrumbs() is deprecated. ' . 'Use the BreadcrumbsHelper instead.' ) ; $ crumbs = $ this -> _crumbs ; if ( $ startText ) { if ( ! is_array ( $ startText ) ) { $ startText = [ 'url' => '/' , 'text' => $ startTex...
Prepends startText to crumbs array if set
26,336
public function tableHeaders ( array $ names , array $ trOptions = null , array $ thOptions = null ) { $ out = [ ] ; foreach ( $ names as $ arg ) { if ( ! is_array ( $ arg ) ) { $ out [ ] = $ this -> formatTemplate ( 'tableheader' , [ 'attrs' => $ this -> templater ( ) -> formatAttributes ( $ thOptions ) , 'content' =>...
Returns a row of formatted and named TABLE headers .
26,337
protected function _renderCells ( $ line , $ useCount = false ) { $ i = 0 ; $ cellsOut = [ ] ; foreach ( $ line as $ cell ) { $ cellOptions = [ ] ; if ( is_array ( $ cell ) ) { $ cellOptions = $ cell [ 1 ] ; $ cell = $ cell [ 0 ] ; } if ( $ useCount ) { $ i += 1 ; if ( isset ( $ cellOptions [ 'class' ] ) ) { $ cellOpti...
Renders cells for a row of a table .
26,338
public function div ( $ class = null , $ text = null , array $ options = [ ] ) { if ( ! empty ( $ class ) ) { $ options [ 'class' ] = $ class ; } return $ this -> tag ( 'div' , $ text , $ options ) ; }
Returns a formatted DIV tag for HTML FORMs .
26,339
public function para ( $ class , $ text , array $ options = [ ] ) { if ( ! empty ( $ options [ 'escape' ] ) ) { $ text = h ( $ text ) ; } if ( $ class && ! empty ( $ class ) ) { $ options [ 'class' ] = $ class ; } $ tag = 'para' ; if ( $ text === null ) { $ tag = 'parastart' ; } return $ this -> formatTemplate ( $ tag ...
Returns a formatted P tag .
26,340
public function autoLayout ( $ autoLayout = null ) { deprecationWarning ( 'View::autoLayout() is deprecated. ' . 'Use isAutoLayoutEnabled()/enableAutoLayout() instead.' ) ; if ( $ autoLayout === null ) { return $ this -> autoLayout ; } $ this -> autoLayout = $ autoLayout ; }
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 templates .
26,341
public function theme ( $ theme = null ) { deprecationWarning ( 'View::theme() is deprecated. ' . 'Use getTheme()/setTheme() instead.' ) ; if ( $ theme === null ) { return $ this -> theme ; } $ this -> theme = $ theme ; }
The view theme to use .
26,342
public function element ( $ name , array $ data = [ ] , array $ options = [ ] ) { $ options += [ 'callbacks' => false , 'cache' => null , 'plugin' => null ] ; if ( isset ( $ options [ 'cache' ] ) ) { $ options [ 'cache' ] = $ this -> _elementCache ( $ name , $ data , $ options ) ; } $ pluginCheck = $ options [ 'plugin'...
Renders a piece of PHP with provided parameters and returns HTML XML or any other string .
26,343
public function cache ( callable $ block , array $ options = [ ] ) { $ options += [ 'key' => '' , 'config' => $ this -> elementCache ] ; if ( empty ( $ options [ 'key' ] ) ) { throw new RuntimeException ( 'Cannot cache content with an empty key' ) ; } $ result = Cache :: read ( $ options [ 'key' ] , $ options [ 'config...
Create a cached block of view logic .
26,344
public function append ( $ name , $ value = null ) { $ this -> Blocks -> concat ( $ name , $ value ) ; return $ this ; }
Append to an existing or new block .
26,345
public function prepend ( $ name , $ value ) { $ this -> Blocks -> concat ( $ name , $ value , ViewBlock :: PREPEND ) ; return $ this ; }
Prepend to an existing or new block .
26,346
public function uuid ( $ object , $ url ) { deprecationWarning ( 'View::uuid() is deprecated and will be removed in 4.0.0.' ) ; $ c = 1 ; $ url = Router :: url ( $ url ) ; $ hash = $ object . substr ( md5 ( $ object . $ url ) , 0 , 10 ) ; while ( in_array ( $ hash , $ this -> uuids ) ) { $ hash = $ object . substr ( md...
Generates a unique non - random DOM ID for an object based on the object type and the target URL .
26,347
public function loadHelpers ( ) { $ registry = $ this -> helpers ( ) ; $ helpers = $ registry -> normalizeArray ( $ this -> helpers ) ; foreach ( $ helpers as $ properties ) { $ this -> loadHelper ( $ properties [ 'class' ] , $ properties [ 'config' ] ) ; } return $ this ; }
Interact with the HelperRegistry to load all the helpers .
26,348
public function helpers ( ) { if ( $ this -> _helpers === null ) { $ this -> _helpers = new HelperRegistry ( $ this ) ; } return $ this -> _helpers ; }
Get the helper registry in use by this View class .
26,349
protected function _checkFilePath ( $ file , $ path ) { if ( strpos ( $ file , '..' ) === false ) { return $ file ; } $ absolute = realpath ( $ file ) ; if ( strpos ( $ absolute , $ path ) !== 0 ) { throw new InvalidArgumentException ( sprintf ( 'Cannot use "%s" as a template, it is not within any view template path.' ...
Check that a view file path does not go outside of the defined template paths .
26,350
protected function _getLayoutFileName ( $ name = null ) { if ( $ name === null ) { $ name = $ this -> layout ; } $ subDir = null ; if ( $ this -> layoutPath ) { $ subDir = $ this -> layoutPath . DIRECTORY_SEPARATOR ; } list ( $ plugin , $ name ) = $ this -> pluginSplit ( $ name ) ; $ layoutPaths = $ this -> _getSubPath...
Returns layout filename for this template as a string .
26,351
protected function _getElementFileName ( $ name , $ pluginCheck = true ) { list ( $ plugin , $ name ) = $ this -> pluginSplit ( $ name , $ pluginCheck ) ; $ paths = $ this -> _paths ( $ plugin ) ; $ elementPaths = $ this -> _getSubPaths ( static :: NAME_ELEMENT ) ; foreach ( $ paths as $ path ) { foreach ( $ elementPat...
Finds an element filename returns false on failure .
26,352
protected function _paths ( $ plugin = null , $ cached = true ) { if ( $ cached === true ) { if ( $ plugin === null && ! empty ( $ this -> _paths ) ) { return $ this -> _paths ; } if ( $ plugin !== null && isset ( $ this -> _pathsForPlugin [ $ plugin ] ) ) { return $ this -> _pathsForPlugin [ $ plugin ] ; } } $ templat...
Return all possible paths to find view files in order
26,353
protected function _elementCache ( $ name , $ data , $ options ) { if ( isset ( $ options [ 'cache' ] [ 'key' ] , $ options [ 'cache' ] [ 'config' ] ) ) { $ cache = $ options [ 'cache' ] ; $ cache [ 'key' ] = 'element_' . $ cache [ 'key' ] ; return $ cache ; } $ plugin = null ; list ( $ plugin , $ name ) = $ this -> pl...
Generate the cache configuration options for an element .
26,354
protected function _renderElement ( $ file , $ data , $ options ) { $ current = $ this -> _current ; $ restore = $ this -> _currentType ; $ this -> _currentType = static :: TYPE_ELEMENT ; if ( $ options [ 'callbacks' ] ) { $ this -> dispatchEvent ( 'View.beforeRender' , [ $ file ] ) ; } $ element = $ this -> _render ( ...
Renders an element and fires the before and afterRender callbacks for it and writes to the cache if a cache is used
26,355
public static function createWithDefaults ( array $ providers = [ ] ) { $ providers = [ [ 'type' => 'orm' , 'callable' => function ( $ request , $ data ) { if ( is_array ( $ data [ 'entity' ] ) || $ data [ 'entity' ] instanceof Traversable ) { $ pass = ( new Collection ( $ data [ 'entity' ] ) ) -> first ( ) !== null ; ...
Create factory instance with providers array form and orm .
26,356
public function addProvider ( $ type , callable $ check ) { $ this -> providers = [ $ type => [ 'type' => $ type , 'callable' => $ check ] ] + $ this -> providers ; return $ this ; }
Add a new context type .
26,357
public function get ( ServerRequest $ request , array $ data = [ ] ) { $ data += [ 'entity' => null ] ; foreach ( $ this -> providers as $ provider ) { $ check = $ provider [ 'callable' ] ; $ context = $ check ( $ request , $ data ) ; if ( $ context ) { break ; } } if ( ! isset ( $ context ) ) { $ context = new NullCon...
Find the matching context for the data .
26,358
public function hasAutoincrement ( ) { foreach ( $ this -> _columns as $ column ) { if ( isset ( $ column [ 'autoIncrement' ] ) && $ column [ 'autoIncrement' ] ) { return true ; } } return false ; }
Check whether or not a table has an autoIncrement column defined .
26,359
protected function _getSchemaCache ( ) { try { $ connection = ConnectionManager :: get ( $ this -> params [ 'connection' ] ) ; return new SchemaCache ( $ connection ) ; } catch ( RuntimeException $ e ) { $ this -> abort ( $ e -> getMessage ( ) ) ; } }
Gets the Schema Cache instance
26,360
public function init ( array $ config = [ ] ) { $ this -> setConfig ( $ config ) ; if ( ! empty ( $ this -> _config [ 'groups' ] ) ) { sort ( $ this -> _config [ 'groups' ] ) ; $ this -> _groupPrefix = str_repeat ( '%s_' , count ( $ this -> _config [ 'groups' ] ) ) ; } if ( ! is_numeric ( $ this -> _config [ 'duration'...
Initialize the cache engine
26,361
public function writeMany ( $ data ) { $ return = [ ] ; foreach ( $ data as $ key => $ value ) { $ return [ $ key ] = $ this -> write ( $ key , $ value ) ; } return $ return ; }
Write data for many keys into cache
26,362
protected function _key ( $ key ) { $ key = $ this -> key ( $ key ) ; if ( $ key === false ) { throw new InvalidArgumentException ( 'An empty value is not valid as a cache key' ) ; } return $ this -> _config [ 'prefix' ] . $ key ; }
Generates a safe key taking account of the configured key prefix
26,363
public function init ( $ language = null ) { if ( ! $ language ) { $ language = $ this -> in ( 'Please specify language code, e.g. `en`, `eng`, `en_US` etc.' ) ; } if ( strlen ( $ language ) < 2 ) { $ this -> abort ( 'Invalid language code. Valid is `en`, `eng`, `en_US` etc.' ) ; } $ this -> _paths = App :: path ( 'Loc...
Inits PO file from POT file .
26,364
public function createResponses ( $ headers , $ content ) { $ indexes = $ responses = [ ] ; foreach ( $ headers as $ i => $ header ) { if ( strtoupper ( substr ( $ header , 0 , 5 ) ) === 'HTTP/' ) { $ indexes [ ] = $ i ; } } $ last = count ( $ indexes ) - 1 ; foreach ( $ indexes as $ i => $ start ) { $ end = isset ( $ ...
Create the response list based on the headers & content
26,365
protected function _buildContext ( Request $ request , $ options ) { $ this -> _buildContent ( $ request , $ options ) ; $ this -> _buildHeaders ( $ request , $ options ) ; $ this -> _buildOptions ( $ request , $ options ) ; $ url = $ request -> getUri ( ) ; $ scheme = parse_url ( $ url , PHP_URL_SCHEME ) ; if ( $ sche...
Build the stream context out of the request object .
26,366
protected function _buildHeaders ( Request $ request , $ options ) { $ headers = [ ] ; foreach ( $ request -> getHeaders ( ) as $ name => $ values ) { $ headers [ ] = sprintf ( '%s: %s' , $ name , implode ( ', ' , $ values ) ) ; } $ this -> _contextOptions [ 'header' ] = implode ( "\r\n" , $ headers ) ; }
Build the header context for the request .
26,367
protected function _buildContent ( Request $ request , $ options ) { $ body = $ request -> getBody ( ) ; if ( empty ( $ body ) ) { $ this -> _contextOptions [ 'content' ] = '' ; return ; } $ body -> rewind ( ) ; $ this -> _contextOptions [ 'content' ] = $ body -> getContents ( ) ; }
Builds the request content based on the request object .
26,368
protected function _buildOptions ( Request $ request , $ options ) { $ this -> _contextOptions [ 'method' ] = $ request -> getMethod ( ) ; $ this -> _contextOptions [ 'protocol_version' ] = $ request -> getProtocolVersion ( ) ; $ this -> _contextOptions [ 'ignore_errors' ] = true ; if ( isset ( $ options [ 'timeout' ] ...
Build miscellaneous options for the request .
26,369
protected function _buildSslContext ( Request $ request , $ options ) { $ sslOptions = [ 'ssl_verify_peer' , 'ssl_verify_peer_name' , 'ssl_verify_depth' , 'ssl_allow_self_signed' , 'ssl_cafile' , 'ssl_local_cert' , 'ssl_passphrase' , ] ; if ( empty ( $ options [ 'ssl_cafile' ] ) ) { $ options [ 'ssl_cafile' ] = CORE_PA...
Build SSL options for the request .
26,370
protected function _send ( Request $ request ) { $ deadline = false ; if ( isset ( $ this -> _contextOptions [ 'timeout' ] ) && $ this -> _contextOptions [ 'timeout' ] > 0 ) { $ deadline = time ( ) + $ this -> _contextOptions [ 'timeout' ] ; } $ url = $ request -> getUri ( ) ; $ this -> _open ( $ url ) ; $ content = ''...
Open the stream and send the request .
26,371
protected function _open ( $ url ) { set_error_handler ( function ( $ code , $ message ) { $ this -> _connectionErrors [ ] = $ message ; } ) ; try { $ this -> _stream = fopen ( $ url , 'rb' , false , $ this -> _context ) ; } finally { restore_error_handler ( ) ; } if ( ! $ this -> _stream || ! empty ( $ this -> _connec...
Open the socket and handle any connection errors .
26,372
public function render ( $ view = null , $ layout = null ) { $ serialize = false ; if ( isset ( $ this -> viewVars [ '_serialize' ] ) ) { $ serialize = $ this -> viewVars [ '_serialize' ] ; } if ( $ serialize !== false ) { $ result = $ this -> _serialize ( $ serialize ) ; if ( $ result === false ) { throw new RuntimeEx...
Render view template or return serialized data .
26,373
public function increment ( $ key , $ offset = 1 ) { $ key = $ this -> _key ( $ key ) ; return xcache_inc ( $ key , $ offset ) ; }
Increments the value of an integer cached key If the cache key is not an integer it will be treated as 0
26,374
public function decrement ( $ key , $ offset = 1 ) { $ key = $ this -> _key ( $ key ) ; return xcache_dec ( $ key , $ offset ) ; }
Decrements the value of an integer cached key . If the cache key is not an integer it will be treated as 0
26,375
public function primaryKey ( ) { if ( empty ( $ this -> _context [ 'schema' ] [ '_constraints' ] ) || ! is_array ( $ this -> _context [ 'schema' ] [ '_constraints' ] ) ) { return [ ] ; } foreach ( $ this -> _context [ 'schema' ] [ '_constraints' ] as $ data ) { if ( isset ( $ data [ 'type' ] ) && $ data [ 'type' ] === ...
Get the fields used in the context as a primary key .
26,376
public function isCreate ( ) { $ primary = $ this -> primaryKey ( ) ; foreach ( $ primary as $ column ) { if ( ! empty ( $ this -> _context [ 'defaults' ] [ $ column ] ) ) { return false ; } } return true ; }
Returns whether or not this form is for a create operation .
26,377
public function val ( $ field , $ options = [ ] ) { $ options += [ 'default' => null , 'schemaDefault' => true ] ; $ val = $ this -> _request -> getData ( $ field ) ; if ( $ val !== null ) { return $ val ; } if ( $ options [ 'default' ] !== null || ! $ options [ 'schemaDefault' ] ) { return $ options [ 'default' ] ; } ...
Get the current value for a given field .
26,378
public function hasError ( $ field ) { if ( empty ( $ this -> _context [ 'errors' ] ) ) { return false ; } return ( bool ) Hash :: check ( $ this -> _context [ 'errors' ] , $ field ) ; }
Check whether or not a field has an error attached to it
26,379
public static function shortName ( $ class , $ type , $ suffix = '' ) { $ class = str_replace ( '\\' , '/' , $ class ) ; $ type = '/' . $ type . '/' ; $ pos = strrpos ( $ class , $ type ) ; $ pluginName = substr ( $ class , 0 , $ pos ) ; $ name = substr ( $ class , $ pos + strlen ( $ type ) ) ; if ( $ suffix ) { $ name...
Returns the plugin split name of a class
26,380
public static function path ( $ type , $ plugin = null ) { if ( $ type === 'Plugin' ) { return ( array ) Configure :: read ( 'App.paths.plugins' ) ; } if ( empty ( $ plugin ) && $ type === 'Locale' ) { return ( array ) Configure :: read ( 'App.paths.locales' ) ; } if ( empty ( $ plugin ) && $ type === 'Template' ) { re...
Used to read information stored path
26,381
public function fetch ( $ query ) { $ key = $ this -> _resolveKey ( $ query ) ; $ storage = $ this -> _resolveCacher ( ) ; $ result = $ storage -> read ( $ key ) ; if ( empty ( $ result ) ) { return null ; } return $ result ; }
Load the cached results from the cache or run the query .
26,382
public function store ( $ query , Traversable $ results ) { $ key = $ this -> _resolveKey ( $ query ) ; $ storage = $ this -> _resolveCacher ( ) ; return $ storage -> write ( $ key , $ results ) ; }
Store the result set into the cache .
26,383
protected function _resolveCacher ( ) { if ( is_string ( $ this -> _config ) ) { return Cache :: engine ( $ this -> _config ) ; } return $ this -> _config ; }
Get the cache engine .
26,384
public function getTable ( ) { if ( $ this -> _table === null ) { $ table = namespaceSplit ( get_class ( $ this ) ) ; $ table = substr ( end ( $ table ) , 0 , - 5 ) ; if ( ! $ table ) { $ table = $ this -> getAlias ( ) ; } $ this -> _table = Inflector :: underscore ( $ table ) ; } return $ this -> _table ; }
Returns the database table name .
26,385
public function table ( $ table = null ) { deprecationWarning ( get_called_class ( ) . '::table() is deprecated. ' . 'Use setTable()/getTable() instead.' ) ; if ( $ table !== null ) { $ this -> setTable ( $ table ) ; } return $ this -> getTable ( ) ; }
Returns the database table name or sets a new one .
26,386
public function getAlias ( ) { if ( $ this -> _alias === null ) { $ alias = namespaceSplit ( get_class ( $ this ) ) ; $ alias = substr ( end ( $ alias ) , 0 , - 5 ) ? : $ this -> _table ; $ this -> _alias = $ alias ; } return $ this -> _alias ; }
Returns the table alias .
26,387
public function getRegistryAlias ( ) { if ( $ this -> _registryAlias === null ) { $ this -> _registryAlias = $ this -> getAlias ( ) ; } return $ this -> _registryAlias ; }
Returns the table registry key used to create this table instance .
26,388
public function registryAlias ( $ registryAlias = null ) { deprecationWarning ( get_called_class ( ) . '::registryAlias() is deprecated. ' . 'Use setRegistryAlias()/getRegistryAlias() instead.' ) ; if ( $ registryAlias !== null ) { $ this -> setRegistryAlias ( $ registryAlias ) ; } return $ this -> getRegistryAlias ( )...
Returns the table registry key used to create this table instance or sets one .
26,389
public function connection ( ConnectionInterface $ connection = null ) { deprecationWarning ( get_called_class ( ) . '::connection() is deprecated. ' . 'Use setConnection()/getConnection() instead.' ) ; if ( $ connection !== null ) { $ this -> setConnection ( $ connection ) ; } return $ this -> getConnection ( ) ; }
Returns the connection instance or sets a new one
26,390
public function setSchema ( $ schema ) { if ( is_array ( $ schema ) ) { $ constraints = [ ] ; if ( isset ( $ schema [ '_constraints' ] ) ) { $ constraints = $ schema [ '_constraints' ] ; unset ( $ schema [ '_constraints' ] ) ; } $ schema = new TableSchema ( $ this -> getTable ( ) , $ schema ) ; foreach ( $ constraints ...
Sets the schema table object describing this table s properties .
26,391
public function getPrimaryKey ( ) { if ( $ this -> _primaryKey === null ) { $ key = ( array ) $ this -> getSchema ( ) -> primaryKey ( ) ; if ( count ( $ key ) === 1 ) { $ key = $ key [ 0 ] ; } $ this -> _primaryKey = $ key ; } return $ this -> _primaryKey ; }
Returns the primary key field name .
26,392
public function getDisplayField ( ) { if ( $ this -> _displayField === null ) { $ schema = $ this -> getSchema ( ) ; $ primary = ( array ) $ this -> getPrimaryKey ( ) ; $ this -> _displayField = array_shift ( $ primary ) ; if ( $ schema -> getColumn ( 'title' ) ) { $ this -> _displayField = 'title' ; } if ( $ schema ->...
Returns the display field .
26,393
public function getEntityClass ( ) { if ( ! $ this -> _entityClass ) { $ default = Entity :: class ; $ self = get_called_class ( ) ; $ parts = explode ( '\\' , $ self ) ; if ( $ self === __CLASS__ || count ( $ parts ) < 3 ) { return $ this -> _entityClass = $ default ; } $ alias = Inflector :: classify ( Inflector :: u...
Returns the class used to hydrate rows for this table .
26,394
public function setEntityClass ( $ name ) { $ class = App :: className ( $ name , 'Model/Entity' ) ; if ( ! $ class ) { throw new MissingEntityException ( [ $ name ] ) ; } $ this -> _entityClass = $ class ; return $ this ; }
Sets the class used to hydrate rows for this table .
26,395
public function entityClass ( $ name = null ) { deprecationWarning ( get_called_class ( ) . '::entityClass() is deprecated. ' . 'Use setEntityClass()/getEntityClass() instead.' ) ; if ( $ name !== null ) { $ this -> setEntityClass ( $ name ) ; } return $ this -> getEntityClass ( ) ; }
Returns the class used to hydrate rows for this table or sets a new one
26,396
public function addBehaviors ( array $ behaviors ) { foreach ( $ behaviors as $ name => $ options ) { if ( is_int ( $ name ) ) { $ name = $ options ; $ options = [ ] ; } $ this -> addBehavior ( $ name , $ options ) ; } return $ this ; }
Adds an array of behaviors to the table s behavior collection .
26,397
public function getBehavior ( $ name ) { $ behavior = $ this -> _behaviors -> get ( $ name ) ; if ( $ behavior === null ) { throw new InvalidArgumentException ( sprintf ( 'The %s behavior is not defined on %s.' , $ name , get_class ( $ this ) ) ) ; } return $ behavior ; }
Get a behavior from the registry .
26,398
protected function findAssociation ( $ name ) { if ( strpos ( $ name , '.' ) === false ) { return $ this -> _associations -> get ( $ name ) ; } list ( $ name , $ next ) = array_pad ( explode ( '.' , $ name , 2 ) , 2 , null ) ; $ result = $ this -> _associations -> get ( $ name ) ; if ( $ result !== null && $ next !== n...
Returns an association object configured for the specified alias if any .
26,399
public function addAssociations ( array $ params ) { foreach ( $ params as $ assocType => $ tables ) { foreach ( $ tables as $ associated => $ options ) { if ( is_numeric ( $ associated ) ) { $ associated = $ options ; $ options = [ ] ; } $ this -> { $ assocType } ( $ associated , $ options ) ; } } return $ this ; }
Setup multiple associations .