idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
26,500 | public static function configTransport ( $ key , $ config = null ) { deprecationWarning ( 'Email::configTransport() is deprecated. Use TransportFactory::setConfig() or TransportFactory::getConfig() instead.' ) ; if ( $ config === null && is_string ( $ key ) ) { return TransportFactory :: getConfig ( $ key ) ; } if ( $ ... | Add or read transport configuration . |
26,501 | public function setProfile ( $ config ) { if ( ! is_array ( $ config ) ) { $ config = ( string ) $ config ; } $ this -> _applyConfig ( $ config ) ; return $ this ; } | Sets the configuration profile to use for this instance . |
26,502 | public function send ( $ content = null ) { if ( empty ( $ this -> _from ) ) { throw new BadMethodCallException ( 'From is not specified.' ) ; } if ( empty ( $ this -> _to ) && empty ( $ this -> _cc ) && empty ( $ this -> _bcc ) ) { throw new BadMethodCallException ( 'You need specify one destination on to, cc or bcc.'... | Send an email using the specified content template and layout |
26,503 | protected function _logDelivery ( $ contents ) { if ( empty ( $ this -> _profile [ 'log' ] ) ) { return ; } $ config = [ 'level' => 'debug' , 'scope' => 'email' ] ; if ( $ this -> _profile [ 'log' ] !== true ) { if ( ! is_array ( $ this -> _profile [ 'log' ] ) ) { $ this -> _profile [ 'log' ] = [ 'level' => $ this -> _... | Log the email message delivery . |
26,504 | public static function deliver ( $ to = null , $ subject = null , $ message = null , $ config = 'default' , $ send = true ) { $ class = __CLASS__ ; if ( is_array ( $ config ) && ! isset ( $ config [ 'transport' ] ) ) { $ config [ 'transport' ] = 'default' ; } $ instance = new $ class ( $ config ) ; if ( $ to !== null )... | Static method to fast create an instance of \ Cake \ Mailer \ Email |
26,505 | protected function _applyConfig ( $ config ) { if ( is_string ( $ config ) ) { $ name = $ config ; $ config = static :: getConfig ( $ name ) ; if ( empty ( $ config ) ) { throw new InvalidArgumentException ( sprintf ( 'Unknown email configuration "%s".' , $ name ) ) ; } unset ( $ name ) ; } $ this -> _profile = array_m... | Apply the config to an instance |
26,506 | public function reset ( ) { $ this -> _to = [ ] ; $ this -> _from = [ ] ; $ this -> _sender = [ ] ; $ this -> _replyTo = [ ] ; $ this -> _readReceipt = [ ] ; $ this -> _returnPath = [ ] ; $ this -> _cc = [ ] ; $ this -> _bcc = [ ] ; $ this -> _messageId = true ; $ this -> _subject = '' ; $ this -> _headers = [ ] ; $ th... | Reset all the internal variables to be able to send out a new email . |
26,507 | protected function _encode ( $ text ) { $ restore = mb_internal_encoding ( ) ; mb_internal_encoding ( $ this -> _appCharset ) ; if ( empty ( $ this -> headerCharset ) ) { $ this -> headerCharset = $ this -> charset ; } $ return = mb_encode_mimeheader ( $ text , $ this -> headerCharset , 'B' ) ; mb_internal_encoding ( $... | Encode the specified string using the current charset |
26,508 | protected function _decode ( $ text ) { $ restore = mb_internal_encoding ( ) ; mb_internal_encoding ( $ this -> _appCharset ) ; $ return = mb_decode_mimeheader ( $ text ) ; mb_internal_encoding ( $ restore ) ; return $ return ; } | Decode the specified string |
26,509 | protected function _encodeString ( $ text , $ charset ) { if ( $ this -> _appCharset === $ charset ) { return $ text ; } return mb_convert_encoding ( $ text , $ charset , $ this -> _appCharset ) ; } | Translates a string for one charset to another if the App . encoding value differs and the mb_convert_encoding function exists |
26,510 | protected function _createBoundary ( ) { if ( $ this -> _attachments || $ this -> _emailFormat === 'both' ) { $ this -> _boundary = md5 ( Security :: randomBytes ( 16 ) ) ; } } | Create unique boundary identifier |
26,511 | protected function _attachFiles ( $ boundary = null ) { if ( $ boundary === null ) { $ boundary = $ this -> _boundary ; } $ msg = [ ] ; foreach ( $ this -> _attachments as $ filename => $ fileInfo ) { if ( ! empty ( $ fileInfo [ 'contentId' ] ) ) { continue ; } $ data = isset ( $ fileInfo [ 'data' ] ) ? $ fileInfo [ 'd... | Attach non - embedded files by adding file contents inside boundaries . |
26,512 | protected function _getContentTransferEncoding ( ) { if ( $ this -> transferEncoding ) { return $ this -> transferEncoding ; } $ charset = strtoupper ( $ this -> charset ) ; if ( in_array ( $ charset , $ this -> _charset8bit ) ) { return '8bit' ; } return '7bit' ; } | Return the Content - Transfer Encoding value based on the set transferEncoding or set charset . |
26,513 | protected function _getContentTypeCharset ( ) { $ charset = strtoupper ( $ this -> charset ) ; if ( array_key_exists ( $ charset , $ this -> _contentTypeCharset ) ) { return strtoupper ( $ this -> _contentTypeCharset [ $ charset ] ) ; } return strtoupper ( $ this -> charset ) ; } | Return charset value for Content - Type . |
26,514 | public function jsonSerialize ( ) { $ properties = [ '_to' , '_from' , '_sender' , '_replyTo' , '_cc' , '_bcc' , '_subject' , '_returnPath' , '_readReceipt' , '_emailFormat' , '_emailPattern' , '_domain' , '_attachments' , '_messageId' , '_headers' , '_appCharset' , 'viewVars' , 'charset' , 'headerCharset' ] ; $ array ... | Serializes the email object to a value that can be natively serialized and re - used to clone this email instance . |
26,515 | protected function _checkViewVars ( & $ item , $ key ) { if ( $ item instanceof Exception ) { $ item = ( string ) $ item ; } if ( is_resource ( $ item ) || $ item instanceof Closure || $ item instanceof PDO ) { throw new RuntimeException ( sprintf ( 'Failed serializing the `%s` %s in the `%s` view var' , is_resource ( ... | Iterates through hash to clean up and normalize . |
26,516 | public function createFromArray ( $ config ) { if ( isset ( $ config [ 'viewConfig' ] ) ) { $ this -> viewBuilder ( ) -> createFromArray ( $ config [ 'viewConfig' ] ) ; unset ( $ config [ 'viewConfig' ] ) ; } foreach ( $ config as $ property => $ value ) { $ this -> { $ property } = $ value ; } return $ this ; } | Configures an email instance object from serialized config . |
26,517 | public function serialize ( ) { $ array = $ this -> jsonSerialize ( ) ; array_walk_recursive ( $ array , function ( & $ item , $ key ) { if ( $ item instanceof SimpleXMLElement ) { $ item = json_decode ( json_encode ( ( array ) $ item ) , true ) ; } } ) ; return serialize ( $ array ) ; } | Serializes the Email object . |
26,518 | public function log ( $ level , $ message , array $ context = [ ] ) { if ( ! $ this -> _open ) { $ config = $ this -> _config ; $ this -> _open ( $ config [ 'prefix' ] , $ config [ 'flag' ] , $ config [ 'facility' ] ) ; $ this -> _open = true ; } $ priority = LOG_DEBUG ; if ( isset ( $ this -> _levelMap [ $ level ] ) )... | Writes a message to syslog |
26,519 | protected function _readLong ( $ stream , $ isBigEndian ) { $ result = unpack ( $ isBigEndian ? 'N1' : 'V1' , fread ( $ stream , 4 ) ) ; $ result = current ( $ result ) ; return ( int ) substr ( $ result , - 8 ) ; } | Reads an unsigned long from stream respecting endianess . |
26,520 | public function quote ( Query $ query ) { $ binder = $ query -> getValueBinder ( ) ; $ query -> setValueBinder ( false ) ; if ( $ query -> type ( ) === 'insert' ) { $ this -> _quoteInsert ( $ query ) ; } elseif ( $ query -> type ( ) === 'update' ) { $ this -> _quoteUpdate ( $ query ) ; } else { $ this -> _quoteParts ( ... | Iterates over each of the clauses in a query looking for identifiers and quotes them |
26,521 | public function quoteExpression ( $ expression ) { if ( $ expression instanceof FieldInterface ) { $ this -> _quoteComparison ( $ expression ) ; return ; } if ( $ expression instanceof OrderByExpression ) { $ this -> _quoteOrderBy ( $ expression ) ; return ; } if ( $ expression instanceof IdentifierExpression ) { $ thi... | Quotes identifiers inside expression objects |
26,522 | protected function _quoteParts ( $ query ) { foreach ( [ 'distinct' , 'select' , 'from' , 'group' ] as $ part ) { $ contents = $ query -> clause ( $ part ) ; if ( ! is_array ( $ contents ) ) { continue ; } $ result = $ this -> _basicQuoter ( $ contents ) ; if ( ! empty ( $ result ) ) { $ query -> { $ part } ( $ result ... | Quotes all identifiers in each of the clauses of a query |
26,523 | protected function _basicQuoter ( $ part ) { $ result = [ ] ; foreach ( ( array ) $ part as $ alias => $ value ) { $ value = ! is_string ( $ value ) ? $ value : $ this -> _driver -> quoteIdentifier ( $ value ) ; $ alias = is_numeric ( $ alias ) ? $ alias : $ this -> _driver -> quoteIdentifier ( $ alias ) ; $ result [ $... | A generic identifier quoting function used for various parts of the query |
26,524 | protected function _quoteJoins ( $ joins ) { $ result = [ ] ; foreach ( $ joins as $ value ) { $ alias = null ; if ( ! empty ( $ value [ 'alias' ] ) ) { $ alias = $ this -> _driver -> quoteIdentifier ( $ value [ 'alias' ] ) ; $ value [ 'alias' ] = $ alias ; } if ( is_string ( $ value [ 'table' ] ) ) { $ value [ 'table'... | Quotes both the table and alias for an array of joins as stored in a Query object |
26,525 | protected function _quoteInsert ( $ query ) { list ( $ table , $ columns ) = $ query -> clause ( 'insert' ) ; $ table = $ this -> _driver -> quoteIdentifier ( $ table ) ; foreach ( $ columns as & $ column ) { if ( is_scalar ( $ column ) ) { $ column = $ this -> _driver -> quoteIdentifier ( $ column ) ; } } $ query -> i... | Quotes the table name and columns for an insert query |
26,526 | protected function _quoteUpdate ( $ query ) { $ table = $ query -> clause ( 'update' ) [ 0 ] ; if ( is_string ( $ table ) ) { $ query -> update ( $ this -> _driver -> quoteIdentifier ( $ table ) ) ; } } | Quotes the table name for an update query |
26,527 | protected function _quoteComparison ( FieldInterface $ expression ) { $ field = $ expression -> getField ( ) ; if ( is_string ( $ field ) ) { $ expression -> setField ( $ this -> _driver -> quoteIdentifier ( $ field ) ) ; } elseif ( is_array ( $ field ) ) { $ quoted = [ ] ; foreach ( $ field as $ f ) { $ quoted [ ] = $... | Quotes identifiers in expression objects implementing the field interface |
26,528 | public function render ( $ template = null ) { $ cache = [ ] ; if ( $ this -> _cache ) { $ cache = $ this -> _cacheConfig ( $ this -> action , $ template ) ; } $ render = function ( ) use ( $ template ) { try { $ reflect = new ReflectionMethod ( $ this , $ this -> action ) ; $ reflect -> invokeArgs ( $ this , $ this ->... | Render the cell . |
26,529 | protected function _cacheConfig ( $ action , $ template = null ) { if ( empty ( $ this -> _cache ) ) { return [ ] ; } $ template = $ template ? : 'default' ; $ key = 'cell_' . Inflector :: underscore ( get_class ( $ this ) ) . '_' . $ action . '_' . $ template ; $ key = str_replace ( '\\' , '_' , $ key ) ; $ default = ... | Generate the cache key to use for this cell . |
26,530 | public function toDatabase ( $ value , Driver $ driver ) { if ( $ value === null || $ value === '' ) { return null ; } return parent :: toDatabase ( $ value , $ driver ) ; } | Casts given value from a PHP type to one acceptable by database |
26,531 | public function marshal ( $ value ) { if ( $ value === null || $ value === '' || is_array ( $ value ) ) { return null ; } return ( string ) $ value ; } | Marshals request data into a PHP string |
26,532 | protected function _connect ( ) { try { $ this -> _Redis = new Redis ( ) ; if ( ! empty ( $ this -> _config [ 'unix_socket' ] ) ) { $ return = $ this -> _Redis -> connect ( $ this -> _config [ 'unix_socket' ] ) ; } elseif ( empty ( $ this -> _config [ 'persistent' ] ) ) { $ return = $ this -> _Redis -> connect ( $ this... | Connects to a Redis server |
26,533 | public function increment ( $ key , $ offset = 1 ) { $ duration = $ this -> _config [ 'duration' ] ; $ key = $ this -> _key ( $ key ) ; $ value = ( int ) $ this -> _Redis -> incrBy ( $ key , $ offset ) ; if ( $ duration > 0 ) { $ this -> _Redis -> setTimeout ( $ key , $ duration ) ; } return $ value ; } | Increments the value of an integer cached key & update the expiry time |
26,534 | public function decrement ( $ key , $ offset = 1 ) { $ duration = $ this -> _config [ 'duration' ] ; $ key = $ this -> _key ( $ key ) ; $ value = ( int ) $ this -> _Redis -> decrBy ( $ key , $ offset ) ; if ( $ duration > 0 ) { $ this -> _Redis -> setTimeout ( $ key , $ duration ) ; } return $ value ; } | Decrements the value of an integer cached key & update the expiry time |
26,535 | public function connect ( ) { if ( $ this -> connection ) { $ this -> disconnect ( ) ; } $ hasProtocol = strpos ( $ this -> _config [ 'host' ] , '://' ) !== false ; if ( $ hasProtocol ) { list ( $ this -> _config [ 'protocol' ] , $ this -> _config [ 'host' ] ) = explode ( '://' , $ this -> _config [ 'host' ] ) ; } $ sc... | Connect the socket to the given host and port . |
26,536 | protected function _setSslContext ( $ host ) { foreach ( $ this -> _config as $ key => $ value ) { if ( substr ( $ key , 0 , 4 ) !== 'ssl_' ) { continue ; } $ contextKey = substr ( $ key , 4 ) ; if ( empty ( $ this -> _config [ 'context' ] [ 'ssl' ] [ $ contextKey ] ) ) { $ this -> _config [ 'context' ] [ 'ssl' ] [ $ c... | Configure the SSL context options . |
26,537 | public function host ( ) { if ( Validation :: ip ( $ this -> _config [ 'host' ] ) ) { return gethostbyaddr ( $ this -> _config [ 'host' ] ) ; } return gethostbyaddr ( $ this -> address ( ) ) ; } | Get the host name of the current connection . |
26,538 | public function address ( ) { if ( Validation :: ip ( $ this -> _config [ 'host' ] ) ) { return $ this -> _config [ 'host' ] ; } return gethostbyname ( $ this -> _config [ 'host' ] ) ; } | Get the IP address of the current connection . |
26,539 | public function addresses ( ) { if ( Validation :: ip ( $ this -> _config [ 'host' ] ) ) { return [ $ this -> _config [ 'host' ] ] ; } return gethostbynamel ( $ this -> _config [ 'host' ] ) ; } | Get all IP addresses associated with the current connection . |
26,540 | public function write ( $ data ) { if ( ! $ this -> connected && ! $ this -> connect ( ) ) { return false ; } $ totalBytes = strlen ( $ data ) ; $ written = 0 ; while ( $ written < $ totalBytes ) { $ rv = fwrite ( $ this -> connection , substr ( $ data , $ written ) ) ; if ( $ rv === false || $ rv === 0 ) { return $ wr... | Write data to the socket . |
26,541 | public function read ( $ length = 1024 ) { if ( ! $ this -> connected && ! $ this -> connect ( ) ) { return false ; } if ( ! feof ( $ this -> connection ) ) { $ buffer = fread ( $ this -> connection , $ length ) ; $ info = stream_get_meta_data ( $ this -> connection ) ; if ( $ info [ 'timed_out' ] ) { $ this -> setLast... | Read data from the socket . Returns false if no data is available or no connection could be established . |
26,542 | public function disconnect ( ) { if ( ! is_resource ( $ this -> connection ) ) { $ this -> connected = false ; return true ; } $ this -> connected = ! fclose ( $ this -> connection ) ; if ( ! $ this -> connected ) { $ this -> connection = null ; } return ! $ this -> connected ; } | Disconnect the socket from the current connection . |
26,543 | public function enableCrypto ( $ type , $ clientOrServer = 'client' , $ enable = true ) { if ( ! array_key_exists ( $ type . '_' . $ clientOrServer , $ this -> _encryptMethods ) ) { throw new InvalidArgumentException ( 'Invalid encryption scheme chosen' ) ; } $ method = $ this -> _encryptMethods [ $ type . '_' . $ clie... | Encrypts current stream socket using one of the defined encryption methods |
26,544 | public function supportsNativeJson ( ) { if ( $ this -> _supportsNativeJson !== null ) { return $ this -> _supportsNativeJson ; } if ( $ this -> _version === null ) { $ this -> _version = $ this -> _connection -> getAttribute ( PDO :: ATTR_SERVER_VERSION ) ; } return $ this -> _supportsNativeJson = version_compare ( $ ... | Returns true if the server supports native JSON columns |
26,545 | protected function _checkDuplicate ( $ name , $ config ) { $ existing = $ this -> _loaded [ $ name ] ; $ msg = sprintf ( 'The "%s" alias has already been loaded' , $ name ) ; $ hasConfig = method_exists ( $ existing , 'config' ) ; if ( ! $ hasConfig ) { throw new RuntimeException ( $ msg ) ; } if ( empty ( $ config ) )... | Check for duplicate object loading . |
26,546 | public function get ( $ name ) { if ( isset ( $ this -> _loaded [ $ name ] ) ) { return $ this -> _loaded [ $ name ] ; } return null ; } | Get loaded object instance . |
26,547 | public function normalizeArray ( $ objects ) { $ normal = [ ] ; foreach ( $ objects as $ i => $ objectName ) { $ config = [ ] ; if ( ! is_int ( $ i ) ) { $ config = ( array ) $ objectName ; $ objectName = $ i ; } list ( , $ name ) = pluginSplit ( $ objectName ) ; if ( isset ( $ config [ 'class' ] ) ) { $ normal [ $ nam... | Normalizes an object array creates an array that makes lazy loading easier |
26,548 | public function reset ( ) { foreach ( array_keys ( $ this -> _loaded ) as $ name ) { $ this -> unload ( $ name ) ; } return $ this ; } | Clear loaded instances in the registry . |
26,549 | public function set ( $ objectName , $ object ) { list ( , $ name ) = pluginSplit ( $ objectName ) ; if ( array_key_exists ( $ objectName , $ this -> _loaded ) ) { $ this -> unload ( $ objectName ) ; } if ( $ this instanceof EventDispatcherInterface && $ object instanceof EventListenerInterface ) { $ this -> getEventMa... | Set an object directly into the registry by name . |
26,550 | public function unload ( $ objectName ) { if ( empty ( $ this -> _loaded [ $ objectName ] ) ) { list ( $ plugin , $ objectName ) = pluginSplit ( $ objectName ) ; $ this -> _throwMissingClassError ( $ objectName , $ plugin ) ; } $ object = $ this -> _loaded [ $ objectName ] ; if ( $ this instanceof EventDispatcherInterf... | Remove an object from the registry . |
26,551 | protected function _transformTupleComparison ( TupleComparison $ expression , $ query ) { $ fields = $ expression -> getField ( ) ; if ( ! is_array ( $ fields ) ) { return ; } $ value = $ expression -> getValue ( ) ; $ op = $ expression -> getOperator ( ) ; $ true = new QueryExpression ( '1' ) ; if ( $ value instanceof... | Receives a TupleExpression and changes it so that it conforms to this SQL dialect . |
26,552 | public static function createFromServerRequest ( ServerRequestInterface $ request ) { $ data = $ request -> getCookieParams ( ) ; $ cookies = [ ] ; foreach ( $ data as $ name => $ value ) { $ cookies [ ] = new Cookie ( $ name , $ value ) ; } return new static ( $ cookies ) ; } | Create a new collection from the cookies in a ServerRequest |
26,553 | public function get ( $ name ) { $ key = mb_strtolower ( $ name ) ; foreach ( $ this -> cookies as $ cookie ) { if ( mb_strtolower ( $ cookie -> getName ( ) ) === $ key ) { return $ cookie ; } } return null ; } | Get the first cookie by name . |
26,554 | public function has ( $ name ) { $ key = mb_strtolower ( $ name ) ; foreach ( $ this -> cookies as $ cookie ) { if ( mb_strtolower ( $ cookie -> getName ( ) ) === $ key ) { return true ; } } return false ; } | Check if a cookie with the given name exists |
26,555 | protected function checkCookies ( array $ cookies ) { foreach ( $ cookies as $ index => $ cookie ) { if ( ! $ cookie instanceof CookieInterface ) { throw new InvalidArgumentException ( sprintf ( 'Expected `%s[]` as $cookies but instead got `%s` at index %d' , static :: class , getTypeName ( $ cookie ) , $ index ) ) ; }... | Checks if only valid cookie objects are in the array |
26,556 | protected function findMatchingCookies ( $ scheme , $ host , $ path ) { $ out = [ ] ; $ now = new DateTimeImmutable ( 'now' , new DateTimeZone ( 'UTC' ) ) ; foreach ( $ this -> cookies as $ cookie ) { if ( $ scheme === 'http' && $ cookie -> isSecure ( ) ) { continue ; } if ( strpos ( $ path , $ cookie -> getPath ( ) ) ... | Find cookies matching the scheme host and path |
26,557 | public function addFromResponse ( ResponseInterface $ response , RequestInterface $ request ) { $ uri = $ request -> getUri ( ) ; $ host = $ uri -> getHost ( ) ; $ path = $ uri -> getPath ( ) ? : '/' ; $ cookies = static :: parseSetCookieHeader ( $ response -> getHeader ( 'Set-Cookie' ) ) ; $ cookies = $ this -> setReq... | Create a new collection that includes cookies from the response . |
26,558 | protected function setRequestDefaults ( array $ cookies , $ host , $ path ) { $ out = [ ] ; foreach ( $ cookies as $ name => $ cookie ) { if ( ! $ cookie -> getDomain ( ) ) { $ cookie = $ cookie -> withDomain ( $ host ) ; } if ( ! $ cookie -> getPath ( ) ) { $ cookie = $ cookie -> withPath ( $ path ) ; } $ out [ ] = $ ... | Apply path and host to the set of cookies if they are not set . |
26,559 | protected static function parseSetCookieHeader ( $ values ) { $ cookies = [ ] ; foreach ( $ values as $ value ) { $ value = rtrim ( $ value , ';' ) ; $ parts = preg_split ( '/\;[ \t]*/' , $ value ) ; $ name = false ; $ cookie = [ 'value' => '' , 'path' => '' , 'domain' => '' , 'secure' => false , 'httponly' => false , ... | Parse Set - Cookie headers into array |
26,560 | protected function removeExpiredCookies ( $ host , $ path ) { $ time = new DateTimeImmutable ( 'now' , new DateTimeZone ( 'UTC' ) ) ; $ hostPattern = '/' . preg_quote ( $ host , '/' ) . '$/' ; foreach ( $ this -> cookies as $ i => $ cookie ) { $ expired = $ cookie -> isExpired ( $ time ) ; $ pathMatches = strpos ( $ pa... | Remove expired cookies from the collection . |
26,561 | protected function _isChecked ( $ data ) { if ( array_key_exists ( 'checked' , $ data ) ) { return ( bool ) $ data [ 'checked' ] ; } return ( string ) $ data [ 'val' ] === ( string ) $ data [ 'value' ] ; } | Check whether or not the checkbox should be checked . |
26,562 | public static function write ( $ config , $ value = null ) { if ( ! is_array ( $ config ) ) { $ config = [ $ config => $ value ] ; } foreach ( $ config as $ name => $ value ) { static :: $ _values = Hash :: insert ( static :: $ _values , $ name , $ value ) ; } if ( isset ( $ config [ 'debug' ] ) ) { if ( static :: $ _h... | Used to store a dynamic variable in Configure . |
26,563 | public static function consume ( $ var ) { if ( strpos ( $ var , '.' ) === false ) { if ( ! isset ( static :: $ _values [ $ var ] ) ) { return null ; } $ value = static :: $ _values [ $ var ] ; unset ( static :: $ _values [ $ var ] ) ; return $ value ; } $ value = Hash :: get ( static :: $ _values , $ var ) ; static ::... | Used to read and delete a variable from Configure . |
26,564 | public static function configured ( $ name = null ) { if ( $ name !== null ) { deprecationWarning ( 'Checking for a named engine with configured() is deprecated. ' . 'Use Configure::isConfigured() instead.' ) ; return isset ( static :: $ _engines [ $ name ] ) ; } return array_keys ( static :: $ _engines ) ; } | Gets the names of the configured Engine objects . |
26,565 | public static function restore ( $ name , $ cacheConfig = 'default' ) { if ( ! class_exists ( Cache :: class ) ) { throw new RuntimeException ( 'You must install cakephp/cache to use Configure::restore()' ) ; } $ values = Cache :: read ( $ name , $ cacheConfig ) ; if ( $ values ) { return static :: write ( $ values ) ;... | Restores configuration data stored in the Cache into configure . Restored values will overwrite existing ones . |
26,566 | protected function _normalizeAssociations ( $ associations ) { $ result = [ ] ; foreach ( ( array ) $ associations as $ table => $ options ) { $ pointer = & $ result ; if ( is_int ( $ table ) ) { $ table = $ options ; $ options = [ ] ; } if ( ! strpos ( $ table , '.' ) ) { $ result [ $ table ] = $ options ; continue ; ... | Returns an array out of the original passed associations list where dot notation is transformed into nested arrays so that they can be parsed by other routines |
26,567 | public function fetch ( $ type = parent :: FETCH_TYPE_NUM ) { if ( $ type === static :: FETCH_TYPE_NUM ) { return $ this -> _statement -> fetch ( PDO :: FETCH_NUM ) ; } if ( $ type === static :: FETCH_TYPE_ASSOC ) { return $ this -> _statement -> fetch ( PDO :: FETCH_ASSOC ) ; } if ( $ type === static :: FETCH_TYPE_OBJ... | Returns the next row for the result set after executing this statement . Rows can be fetched to contain columns as names or positions . If no rows are left in result set this method will return false |
26,568 | protected function optimizeUnwrap ( ) { $ iterator = $ this -> unwrap ( ) ; if ( get_class ( $ iterator ) === ArrayIterator :: class ) { $ iterator = $ iterator -> getArrayCopy ( ) ; } return $ iterator ; } | Unwraps this iterator and returns the simplest traversable that can be used for getting the data out |
26,569 | public function widgetRegistry ( WidgetRegistry $ instance = null , $ widgets = [ ] ) { deprecationWarning ( 'widgetRegistry is deprecated, use widgetLocator instead.' ) ; if ( $ instance ) { $ instance -> add ( $ widgets ) ; $ this -> setWidgetLocator ( $ instance ) ; } return $ this -> getWidgetLocator ( ) ; } | Set the widget registry the helper will use . |
26,570 | public function contextFactory ( ContextFactory $ instance = null , array $ contexts = [ ] ) { if ( $ instance === null ) { if ( $ this -> _contextFactory === null ) { $ this -> _contextFactory = ContextFactory :: createWithDefaults ( $ contexts ) ; } return $ this -> _contextFactory ; } $ this -> _contextFactory = $ i... | Set the context factory the helper will use . |
26,571 | protected function _formUrl ( $ context , $ options ) { $ request = $ this -> _View -> getRequest ( ) ; if ( $ options [ 'action' ] === null && $ options [ 'url' ] === null ) { return $ request -> getRequestTarget ( ) ; } if ( is_string ( $ options [ 'url' ] ) || ( is_array ( $ options [ 'url' ] ) && isset ( $ options ... | Create the URL for a form based on the options . |
26,572 | protected function _lastAction ( $ url ) { $ action = Router :: url ( $ url , true ) ; $ query = parse_url ( $ action , PHP_URL_QUERY ) ; $ query = $ query ? '?' . $ query : '' ; $ this -> _lastAction = parse_url ( $ action , PHP_URL_PATH ) . $ query ; } | Correctly store the last created form action URL . |
26,573 | protected function _csrfField ( ) { $ request = $ this -> _View -> getRequest ( ) ; if ( $ request -> getParam ( '_Token.unlockedFields' ) ) { foreach ( ( array ) $ request -> getParam ( '_Token.unlockedFields' ) as $ unlocked ) { $ this -> _unlockedFields [ ] = $ unlocked ; } } if ( ! $ request -> getParam ( '_csrfTok... | Return a CSRF input if the request data is present . Used to secure forms in conjunction with CsrfComponent & SecurityComponent |
26,574 | public function secure ( array $ fields = [ ] , array $ secureAttributes = [ ] ) { if ( ! $ this -> _View -> getRequest ( ) -> getParam ( '_Token' ) ) { return '' ; } $ debugSecurity = Configure :: read ( 'debug' ) ; if ( isset ( $ secureAttributes [ 'debugSecurity' ] ) ) { $ debugSecurity = $ debugSecurity && $ secure... | Generates a hidden field with a security hash based on the fields used in the form . |
26,575 | public function unlockField ( $ name = null ) { if ( $ name === null ) { return $ this -> _unlockedFields ; } if ( ! in_array ( $ name , $ this -> _unlockedFields ) ) { $ this -> _unlockedFields [ ] = $ name ; } $ index = array_search ( $ name , $ this -> fields ) ; if ( $ index !== false ) { unset ( $ this -> fields [... | Add to or get the list of fields that are currently unlocked . Unlocked fields are not included in the field hash used by SecurityComponent unlocking a field once its been added to the list of secured fields will remove it from the list of fields . |
26,576 | public function error ( $ field , $ text = null , array $ options = [ ] ) { if ( substr ( $ field , - 5 ) === '._ids' ) { $ field = substr ( $ field , 0 , - 5 ) ; } $ options += [ 'escape' => true ] ; $ context = $ this -> _getContext ( ) ; if ( ! $ context -> hasError ( $ field ) ) { return '' ; } $ error = $ context ... | Returns a formatted error message for given form field if no errors . |
26,577 | public function label ( $ fieldName , $ text = null , array $ options = [ ] ) { if ( $ text === null ) { $ text = $ fieldName ; if ( substr ( $ text , - 5 ) === '._ids' ) { $ text = substr ( $ text , 0 , - 5 ) ; } if ( strpos ( $ text , '.' ) !== false ) { $ fieldElements = explode ( '.' , $ text ) ; $ text = array_pop... | Returns a formatted LABEL element for HTML forms . |
26,578 | public function fieldset ( $ fields = '' , array $ options = [ ] ) { $ fieldset = $ legend = true ; $ context = $ this -> _getContext ( ) ; $ out = $ fields ; if ( isset ( $ options [ 'legend' ] ) ) { $ legend = $ options [ 'legend' ] ; } if ( isset ( $ options [ 'fieldset' ] ) ) { $ fieldset = $ options [ 'fieldset' ]... | Wrap a set of inputs in a fieldset |
26,579 | protected function _getInput ( $ fieldName , $ options ) { $ label = $ options [ 'labelOptions' ] ; unset ( $ options [ 'labelOptions' ] ) ; switch ( strtolower ( $ options [ 'type' ] ) ) { case 'select' : $ opts = $ options [ 'options' ] ; unset ( $ options [ 'options' ] ) ; return $ this -> select ( $ fieldName , $ o... | Generates an input element |
26,580 | protected function _inputType ( $ fieldName , $ options ) { $ context = $ this -> _getContext ( ) ; if ( $ context -> isPrimaryKey ( $ fieldName ) ) { return 'hidden' ; } if ( substr ( $ fieldName , - 3 ) === '_id' ) { return 'select' ; } $ internalType = $ context -> type ( $ fieldName ) ; $ map = $ this -> _config [ ... | Returns the input type that was guessed for the provided fieldName based on the internal type it is associated too its name and the variables that can be found in the view template |
26,581 | protected function _optionsOptions ( $ fieldName , $ options ) { if ( isset ( $ options [ 'options' ] ) ) { return $ options ; } $ pluralize = true ; if ( substr ( $ fieldName , - 5 ) === '._ids' ) { $ fieldName = substr ( $ fieldName , 0 , - 5 ) ; $ pluralize = false ; } elseif ( substr ( $ fieldName , - 3 ) === '_id'... | Selects the variable containing the options for a select field if present and sets the value to the options key in the options array . |
26,582 | public function radio ( $ fieldName , $ options = [ ] , array $ attributes = [ ] ) { $ attributes [ 'options' ] = $ options ; $ attributes [ 'idPrefix' ] = $ this -> _idPrefix ; $ attributes = $ this -> _initInputField ( $ fieldName , $ attributes ) ; $ hiddenField = isset ( $ attributes [ 'hiddenField' ] ) ? $ attribu... | Creates a set of radio widgets . |
26,583 | public function textarea ( $ fieldName , array $ options = [ ] ) { $ options = $ this -> _initInputField ( $ fieldName , $ options ) ; unset ( $ options [ 'type' ] ) ; return $ this -> widget ( 'textarea' , $ options ) ; } | Creates a textarea widget . |
26,584 | public function hidden ( $ fieldName , array $ options = [ ] ) { $ options += [ 'required' => false , 'secure' => true ] ; $ secure = $ options [ 'secure' ] ; unset ( $ options [ 'secure' ] ) ; $ options = $ this -> _initInputField ( $ fieldName , array_merge ( $ options , [ 'secure' => static :: SECURE_SKIP ] ) ) ; if... | Creates a hidden input field . |
26,585 | public function multiCheckbox ( $ fieldName , $ options , array $ attributes = [ ] ) { $ attributes += [ 'disabled' => null , 'escape' => true , 'hiddenField' => true , 'secure' => true , ] ; $ attributes = $ this -> _initInputField ( $ fieldName , $ attributes ) ; $ attributes [ 'options' ] = $ options ; $ attributes ... | Creates a set of checkboxes out of options . |
26,586 | protected function _singleDatetime ( $ options , $ keep ) { $ off = array_diff ( $ this -> _datetimeParts , [ $ keep ] ) ; $ off = array_combine ( $ off , array_fill ( 0 , count ( $ off ) , false ) ) ; $ attributes = array_diff_key ( $ options , array_flip ( array_merge ( $ this -> _datetimeOptions , [ 'value' , 'empty... | Helper method for the various single datetime component methods . |
26,587 | public function day ( $ fieldName = null , array $ options = [ ] ) { $ options = $ this -> _singleDatetime ( $ options , 'day' ) ; if ( isset ( $ options [ 'val' ] ) && $ options [ 'val' ] > 0 && $ options [ 'val' ] <= 31 ) { $ options [ 'val' ] = [ 'year' => date ( 'Y' ) , 'month' => date ( 'm' ) , 'day' => ( int ) $ ... | Returns a SELECT element for days . |
26,588 | public function year ( $ fieldName , array $ options = [ ] ) { $ options = $ this -> _singleDatetime ( $ options , 'year' ) ; $ len = isset ( $ options [ 'val' ] ) ? strlen ( $ options [ 'val' ] ) : 0 ; if ( isset ( $ options [ 'val' ] ) && $ len > 0 && $ len < 5 ) { $ options [ 'val' ] = [ 'year' => ( int ) $ options ... | Returns a SELECT element for years |
26,589 | public function month ( $ fieldName , array $ options = [ ] ) { $ options = $ this -> _singleDatetime ( $ options , 'month' ) ; if ( isset ( $ options [ 'val' ] ) && $ options [ 'val' ] > 0 && $ options [ 'val' ] <= 12 ) { $ options [ 'val' ] = [ 'year' => date ( 'Y' ) , 'month' => ( int ) $ options [ 'val' ] , 'day' =... | Returns a SELECT element for months . |
26,590 | public function meridian ( $ fieldName , array $ options = [ ] ) { $ options = $ this -> _singleDatetime ( $ options , 'meridian' ) ; if ( isset ( $ options [ 'val' ] ) ) { $ hour = date ( 'H' ) ; $ options [ 'val' ] = [ 'hour' => $ hour , 'minute' => ( int ) $ options [ 'val' ] , 'meridian' => $ hour > 11 ? 'pm' : 'am... | Returns a SELECT element for AM or PM . |
26,591 | protected function _isDisabled ( array $ options ) { if ( ! isset ( $ options [ 'disabled' ] ) ) { return false ; } if ( is_scalar ( $ options [ 'disabled' ] ) ) { return ( $ options [ 'disabled' ] === true || $ options [ 'disabled' ] === 'disabled' ) ; } if ( ! isset ( $ options [ 'options' ] ) ) { return false ; } if... | Determine if a field is disabled . |
26,592 | public function context ( $ context = null ) { if ( $ context instanceof ContextInterface ) { $ this -> _context = $ context ; } return $ this -> _getContext ( ) ; } | Get the context instance for the current form set . |
26,593 | protected function _getContext ( $ data = [ ] ) { if ( isset ( $ this -> _context ) && empty ( $ data ) ) { return $ this -> _context ; } $ data += [ 'entity' => null ] ; return $ this -> _context = $ this -> contextFactory ( ) -> get ( $ this -> _View -> getRequest ( ) , $ data ) ; } | Find the matching context provider for the data . |
26,594 | public function widget ( $ name , array $ data = [ ] ) { $ secure = null ; if ( isset ( $ data [ 'secure' ] ) ) { $ secure = $ data [ 'secure' ] ; unset ( $ data [ 'secure' ] ) ; } $ widget = $ this -> _locator -> get ( $ name ) ; $ out = $ widget -> render ( $ data , $ this -> context ( ) ) ; if ( isset ( $ data [ 'na... | Render a named widget . |
26,595 | public function getSourceValue ( $ fieldname , $ options = [ ] ) { $ valueMap = [ 'data' => 'getData' , 'query' => 'getQuery' ] ; foreach ( $ this -> getValueSources ( ) as $ valuesSource ) { if ( $ valuesSource === 'context' ) { $ val = $ this -> _getContext ( ) -> val ( $ fieldname , $ options ) ; if ( $ val !== null... | Gets a single field value from the sources available . |
26,596 | public function getShellList ( ) { $ skipFiles = [ 'app' ] ; $ hiddenCommands = [ 'command_list' , 'completion' ] ; $ plugins = Plugin :: loaded ( ) ; $ shellList = array_fill_keys ( $ plugins , null ) + [ 'CORE' => null , 'app' => null ] ; $ appPath = App :: path ( 'Shell' ) ; $ shellList = $ this -> _findShells ( $ s... | Gets the shell command listing . |
26,597 | public function commands ( ) { $ shellList = $ this -> getShellList ( ) ; $ flatten = Hash :: flatten ( $ shellList ) ; $ duplicates = array_intersect ( $ flatten , array_unique ( array_diff_key ( $ flatten , array_unique ( $ flatten ) ) ) ) ; $ duplicates = Hash :: expand ( $ duplicates ) ; $ options = [ ] ; foreach (... | Return a list of all commands |
26,598 | public function subCommands ( $ commandName ) { $ Shell = $ this -> getShell ( $ commandName ) ; if ( ! $ Shell ) { return [ ] ; } $ taskMap = $ this -> Tasks -> normalizeArray ( ( array ) $ Shell -> tasks ) ; $ return = array_keys ( $ taskMap ) ; $ return = array_map ( 'Cake\Utility\Inflector::underscore' , $ return )... | Return a list of subcommands for a given command |
26,599 | public function getShell ( $ commandName ) { list ( $ pluginDot , $ name ) = pluginSplit ( $ commandName , true ) ; if ( in_array ( strtolower ( $ pluginDot ) , [ 'app.' , 'core.' ] ) ) { $ commandName = $ name ; $ pluginDot = '' ; } if ( ! in_array ( $ commandName , $ this -> commands ( ) ) && ( empty ( $ pluginDot ) ... | Get Shell instance for the given command |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.