idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
25,500
public function sameAs ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'sameAs' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_SAME ] ] ) ; }
Add a rule to compare two fields to each other .
25,501
public function notSameAs ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'notSameAs' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_NOT_SAME ] ] ) ; }
Add a rule to compare that two fields have different values .
25,502
public function equalToField ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'equalToField' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_EQUAL ] ] ) ; }
Add a rule to compare one field is equal to another .
25,503
public function notEqualToField ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'notEqualToField' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_NOT_EQUAL ] ] ) ;...
Add a rule to compare one field is not equal to another .
25,504
public function greaterThanField ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'greaterThanField' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_GREATER ] ] ) ;...
Add a rule to compare one field is greater than another .
25,505
public function greaterThanOrEqualToField ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'greaterThanOrEqualToField' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPA...
Add a rule to compare one field is greater than or equal to another .
25,506
public function lessThanField ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'lessThanField' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_LESS ] ] ) ; }
Add a rule to compare one field is less than another .
25,507
public function lessThanOrEqualToField ( $ field , $ secondField , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'lessThanOrEqualToField' , $ extra + [ 'rule' => [ 'compareFields' , $ secondField , Validation :: COMPARE_LES...
Add a rule to compare one field is less than or equal to another .
25,508
public function containsNonAlphaNumeric ( $ field , $ limit = 1 , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'containsNonAlphaNumeric' , $ extra + [ 'rule' => [ 'containsNonAlphaNumeric' , $ limit ] ] ) ; }
Add a rule to check if a field contains non alpha numeric characters .
25,509
public function date ( $ field , $ formats = [ 'ymd' ] , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'date' , $ extra + [ 'rule' => [ 'date' , $ formats ] ] ) ; }
Add a date format validation rule to a field .
25,510
public function localizedTime ( $ field , $ type = 'datetime' , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'localizedTime' , $ extra + [ 'rule' => [ 'localizedTime' , $ type ] ] ) ; }
Add a localized time date or datetime format validation rule to a field .
25,511
public function boolean ( $ field , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'boolean' , $ extra + [ 'rule' => 'boolean' ] ) ; }
Add a boolean validation rule to a field .
25,512
public function decimal ( $ field , $ places = null , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'decimal' , $ extra + [ 'rule' => [ 'decimal' , $ places ] ] ) ; }
Add a decimal validation rule to a field .
25,513
public function email ( $ field , $ checkMX = false , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'email' , $ extra + [ 'rule' => [ 'email' , $ checkMX ] ] ) ; }
Add an email validation rule to a field .
25,514
public function urlWithProtocol ( $ field , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'urlWithProtocol' , $ extra + [ 'rule' => [ 'url' , true ] ] ) ; }
Add a validation rule to ensure a field is a URL .
25,515
public function inList ( $ field , array $ list , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'inList' , $ extra + [ 'rule' => [ 'inList' , $ list ] ] ) ; }
Add a validation rule to ensure the field value is within a whitelist .
25,516
public function uploadedFile ( $ field , array $ options , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'uploadedFile' , $ extra + [ 'rule' => [ 'uploadedFile' , $ options ] ] ) ; }
Add a validation rule to ensure the field is an uploaded file
25,517
public function utf8 ( $ field , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'utf8' , $ extra + [ 'rule' => [ 'utf8' , [ 'extended' => false ] ] ] ) ; }
Add a validation rule to ensure a field contains only BMP utf8 bytes
25,518
public function multipleOptions ( $ field , array $ options = [ ] , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; $ caseInsensitive = isset ( $ options [ 'caseInsensitive' ] ) ? $ options [ 'caseInsensitive' ] : false ; unset ( $ options [ 'caseInsensitive...
Add a validation rule for a multiple select . Comparison is case sensitive by default .
25,519
public function hasAtLeast ( $ field , $ count , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'hasAtLeast' , $ extra + [ 'rule' => function ( $ value ) use ( $ count ) { if ( is_array ( $ value ) && isset ( $ value [ '_ids...
Add a validation rule to ensure that a field is an array containing at least the specified amount of elements
25,520
public function hasAtMost ( $ field , $ count , $ message = null , $ when = null ) { $ extra = array_filter ( [ 'on' => $ when , 'message' => $ message ] ) ; return $ this -> add ( $ field , 'hasAtMost' , $ extra + [ 'rule' => function ( $ value ) use ( $ count ) { if ( is_array ( $ value ) && isset ( $ value [ '_ids' ...
Add a validation rule to ensure that a field is an array containing at most the specified amount of elements
25,521
public function isEmptyAllowed ( $ field , $ newRecord ) { $ providers = $ this -> _providers ; $ data = [ ] ; $ context = compact ( 'data' , 'newRecord' , 'field' , 'providers' ) ; return $ this -> _canBeEmpty ( $ this -> field ( $ field ) , $ context ) ; }
Returns whether or not a field can be left empty for a new or already existing record .
25,522
public function isPresenceRequired ( $ field , $ newRecord ) { $ providers = $ this -> _providers ; $ data = [ ] ; $ context = compact ( 'data' , 'newRecord' , 'field' , 'providers' ) ; return ! $ this -> _checkPresence ( $ this -> field ( $ field ) , $ context ) ; }
Returns whether or not a field can be left out for a new or already existing record .
25,523
public function getRequiredMessage ( $ field ) { if ( ! isset ( $ this -> _fields [ $ field ] ) ) { return null ; } $ defaultMessage = 'This field is required' ; if ( $ this -> _useI18n ) { $ defaultMessage = __d ( 'cake' , 'This field is required' ) ; } return isset ( $ this -> _presenceMessages [ $ field ] ) ? $ this...
Gets the required message for a field
25,524
public function getNotEmptyMessage ( $ field ) { if ( ! isset ( $ this -> _fields [ $ field ] ) ) { return null ; } $ defaultMessage = 'This field cannot be left empty' ; if ( $ this -> _useI18n ) { $ defaultMessage = __d ( 'cake' , 'This field cannot be left empty' ) ; } $ notBlankMessage = null ; foreach ( $ this -> ...
Gets the notEmpty message for a field
25,525
protected function _checkPresence ( $ field , $ context ) { $ required = $ field -> isPresenceRequired ( ) ; if ( ! is_string ( $ required ) && is_callable ( $ required ) ) { return ! $ required ( $ context ) ; } $ newRecord = $ context [ 'newRecord' ] ; if ( in_array ( $ required , [ 'create' , 'update' ] , true ) ) {...
Returns false if any validation for the passed rule set should be stopped due to the field missing in the data array
25,526
protected function _canBeEmpty ( $ field , $ context ) { $ allowed = $ field -> isEmptyAllowed ( ) ; if ( ! is_string ( $ allowed ) && is_callable ( $ allowed ) ) { return $ allowed ( $ context ) ; } $ newRecord = $ context [ 'newRecord' ] ; if ( in_array ( $ allowed , [ 'create' , 'update' ] , true ) ) { $ allowed = (...
Returns whether the field can be left blank according to allowEmpty
25,527
protected function isEmpty ( $ data , $ flags ) { if ( $ data === null ) { return true ; } if ( $ data === '' && ( $ flags & self :: EMPTY_STRING ) ) { return true ; } $ arrayTypes = self :: EMPTY_ARRAY | self :: EMPTY_DATE | self :: EMPTY_TIME ; if ( $ data === [ ] && ( $ flags & $ arrayTypes ) ) { return true ; } if ...
Returns true if the field is empty in the passed data array
25,528
protected function _processRules ( $ field , ValidationSet $ rules , $ data , $ newRecord ) { $ errors = [ ] ; $ this -> getProvider ( 'default' ) ; $ message = 'The provided value is invalid' ; if ( $ this -> _useI18n ) { $ message = __d ( 'cake' , 'The provided value is invalid' ) ; } foreach ( $ rules as $ name => $...
Iterates over each rule in the validation set and collects the errors resulting from executing them
25,529
public static function translators ( ) { if ( static :: $ _collection !== null ) { return static :: $ _collection ; } static :: $ _collection = new TranslatorRegistry ( new PackageLocator , new FormatterLocator ( [ 'sprintf' => function ( ) { return new SprintfFormatter ( ) ; } , 'default' => function ( ) { return new ...
Returns the translators collection instance . It can be used for getting specific translators based of their name and locale or to configure some aspect of future translations that are not yet constructed .
25,530
public static function setTranslator ( $ name , callable $ loader , $ locale = null ) { $ locale = $ locale ? : static :: getLocale ( ) ; $ translators = static :: translators ( ) ; $ loader = $ translators -> setLoaderFallback ( $ name , $ loader ) ; $ packages = $ translators -> getPackages ( ) ; $ packages -> set ( ...
Sets a translator .
25,531
public static function getTranslator ( $ name = 'default' , $ locale = null ) { $ translators = static :: translators ( ) ; if ( $ locale ) { $ currentLocale = $ translators -> getLocale ( ) ; $ translators -> setLocale ( $ locale ) ; } $ translator = $ translators -> get ( $ name ) ; if ( isset ( $ currentLocale ) ) {...
Returns an instance of a translator that was configured for the name and locale .
25,532
public static function getLocale ( ) { static :: getDefaultLocale ( ) ; $ current = Locale :: getDefault ( ) ; if ( $ current === '' ) { $ current = static :: DEFAULT_LOCALE ; Locale :: setDefault ( $ current ) ; } return $ current ; }
Will return the currently configure locale as stored in the intl . default_locale PHP setting .
25,533
public function convertXml ( $ xml ) { try { $ xml = Xml :: build ( $ xml , [ 'return' => 'domdocument' , 'readFile' => false ] ) ; if ( ( int ) $ xml -> childNodes -> length > 0 ) { return Xml :: toArray ( $ xml ) ; } return [ ] ; } catch ( XmlException $ e ) { return [ ] ; } }
Helper method to parse xml input data due to lack of anonymous functions this lives here .
25,534
public function beforeRender ( Event $ event ) { $ controller = $ event -> getSubject ( ) ; $ response = $ controller -> getResponse ( ) ; $ request = $ controller -> getRequest ( ) ; if ( $ this -> ext && ! in_array ( $ this -> ext , [ 'html' , 'htm' ] ) ) { if ( ! $ response -> getMimeType ( $ this -> ext ) ) { throw...
Checks if the response can be considered different according to the request headers and the caching response headers . If it was not modified then the render process is skipped . And the client will get a blank response with a 304 Not Modified header .
25,535
public function isMobile ( ) { deprecationWarning ( 'RequestHandlerComponent::isMobile() is deprecated. Use ServerRequest::is(\'mobile\') instead.' ) ; $ request = $ this -> getController ( ) -> getRequest ( ) ; return $ request -> is ( 'mobile' ) || $ this -> accepts ( 'wap' ) ; }
Returns true if user agent string matches a mobile web browser or if the client accepts WAP content .
25,536
public function respondAs ( $ type , array $ options = [ ] ) { $ defaults = [ 'index' => null , 'charset' => null , 'attachment' => false ] ; $ options += $ defaults ; $ cType = $ type ; $ controller = $ this -> getController ( ) ; $ response = $ controller -> getResponse ( ) ; $ request = $ controller -> getRequest ( ...
Sets the response header based on type map index name . This wraps several methods available on Cake \ Http \ Response . It also allows you to use Content - Type aliases .
25,537
protected function _addMessage ( array & $ messages , array $ item ) { if ( empty ( $ item [ 'ids' ] [ 'singular' ] ) && empty ( $ item [ 'ids' ] [ 'plural' ] ) ) { return ; } $ singular = stripcslashes ( $ item [ 'ids' ] [ 'singular' ] ) ; $ context = isset ( $ item [ 'context' ] ) ? $ item [ 'context' ] : null ; $ tr...
Saves a translation item to the messages .
25,538
public function execute ( $ params = null ) { $ t = microtime ( true ) ; $ query = new LoggedQuery ( ) ; try { $ result = parent :: execute ( $ params ) ; } catch ( Exception $ e ) { $ e -> queryString = $ this -> queryString ; $ query -> error = $ e ; $ this -> _log ( $ query , $ params , $ t ) ; throw $ e ; } $ query...
Wrapper for the execute function to calculate time spent and log the query afterwards .
25,539
protected function _log ( $ query , $ params , $ startTime ) { $ query -> took = ( int ) round ( ( microtime ( true ) - $ startTime ) * 1000 , 0 ) ; $ query -> params = $ params ? : $ this -> _compiledParams ; $ query -> query = $ this -> queryString ; $ this -> getLogger ( ) -> log ( $ query ) ; }
Copies the logging data to the passed LoggedQuery and sends it to the logging system .
25,540
public function bindValue ( $ column , $ value , $ type = 'string' ) { parent :: bindValue ( $ column , $ value , $ type ) ; if ( $ type === null ) { $ type = 'string' ; } if ( ! ctype_digit ( $ type ) ) { $ value = $ this -> cast ( $ value , $ type ) [ 0 ] ; } $ this -> _compiledParams [ $ column ] = $ value ; }
Wrapper for bindValue function to gather each parameter to be later used in the logger function .
25,541
public function logger ( $ instance = null ) { deprecationWarning ( 'LoggingStatement::logger() is deprecated. ' . 'Use LoggingStatement::setLogger()/getLogger() instead.' ) ; if ( $ instance === null ) { return $ this -> getLogger ( ) ; } return $ this -> _logger = $ instance ; }
Sets the logger object instance . When called with no arguments it returns the currently setup logger instance
25,542
public function timestamp ( DateTime $ ts = null , $ refreshTimestamp = false ) { if ( $ ts ) { if ( $ this -> _config [ 'refreshTimestamp' ] ) { $ this -> _config [ 'refreshTimestamp' ] = false ; } $ this -> _ts = new Time ( $ ts ) ; } elseif ( $ this -> _ts === null || $ refreshTimestamp ) { $ this -> _ts = new Time ...
Get or set the timestamp to be used
25,543
public function touch ( EntityInterface $ entity , $ eventName = 'Model.beforeSave' ) { $ events = $ this -> _config [ 'events' ] ; if ( empty ( $ events [ $ eventName ] ) ) { return false ; } $ return = false ; $ refresh = $ this -> _config [ 'refreshTimestamp' ] ; foreach ( $ events [ $ eventName ] as $ field => $ wh...
Touch an entity
25,544
public function getChildren ( ) { $ current = $ this -> current ( ) ; $ key = $ this -> key ( ) ; $ unfolder = $ this -> _unfolder ; return new NoChildrenIterator ( $ unfolder ( $ current , $ key , $ this -> _innerIterator ) ) ; }
Returns an iterator containing the items generated by transforming the current value with the callable function .
25,545
protected function cell ( $ cell , array $ data = [ ] , array $ options = [ ] ) { $ parts = explode ( '::' , $ cell ) ; if ( count ( $ parts ) === 2 ) { list ( $ pluginAndCell , $ action ) = [ $ parts [ 0 ] , $ parts [ 1 ] ] ; } else { list ( $ pluginAndCell , $ action ) = [ $ parts [ 0 ] , 'display' ] ; } list ( $ plu...
Renders the given cell .
25,546
protected function _createCell ( $ className , $ action , $ plugin , $ options ) { $ instance = new $ className ( $ this -> request , $ this -> response , $ this -> getEventManager ( ) , $ options ) ; $ builder = $ instance -> viewBuilder ( ) ; $ builder -> setTemplate ( Inflector :: underscore ( $ action ) ) ; if ( ! ...
Create and configure the cell instance .
25,547
protected function _getServerInfo ( Request $ request , $ credentials ) { $ response = $ this -> _client -> get ( $ request -> getUri ( ) , [ ] , [ 'auth' => [ 'type' => null ] ] ) ; if ( ! $ response -> getHeader ( 'WWW-Authenticate' ) ) { return [ ] ; } preg_match_all ( '@(\w+)=(?:(?:")([^"]+)"|([^\s,$]+))@' , $ resp...
Retrieve information about the authentication
25,548
protected function _generateHeader ( Request $ request , $ credentials ) { $ path = $ request -> getUri ( ) -> getPath ( ) ; $ a1 = md5 ( $ credentials [ 'username' ] . ':' . $ credentials [ 'realm' ] . ':' . $ credentials [ 'password' ] ) ; $ a2 = md5 ( $ request -> getMethod ( ) . ':' . $ path ) ; $ nc = null ; if ( ...
Generate the header Authorization
25,549
public function rewind ( ) { if ( $ this -> _index === 0 && ! $ this -> _started ) { $ this -> _started = true ; parent :: rewind ( ) ; return ; } $ this -> _index = 0 ; }
Rewinds the collection
25,550
public function count ( ) { if ( ! $ this -> _started ) { $ this -> rewind ( ) ; } while ( $ this -> valid ( ) ) { $ this -> next ( ) ; } return $ this -> _buffer -> count ( ) ; }
Returns the number or items in this collection
25,551
public function unserialize ( $ buffer ) { $ this -> __construct ( [ ] ) ; $ this -> _buffer = unserialize ( $ buffer ) ; $ this -> _started = true ; $ this -> _finished = true ; }
Unserializes the passed string and rebuilds the BufferedIterator instance
25,552
public function cast ( $ value , $ type ) { if ( is_string ( $ type ) ) { $ type = Type :: build ( $ type ) ; } if ( $ type instanceof TypeInterface ) { $ value = $ type -> toDatabase ( $ value , $ this -> _driver ) ; $ type = $ type -> toStatement ( $ value , $ this -> _driver ) ; } return [ $ value , $ type ] ; }
Converts a give value to a suitable database value based on type and return relevant internal statement type
25,553
public function matchTypes ( $ columns , $ types ) { if ( ! is_int ( key ( $ types ) ) ) { $ positions = array_intersect_key ( array_flip ( $ columns ) , $ types ) ; $ types = array_intersect_key ( $ types , $ positions ) ; $ types = array_combine ( $ positions , $ types ) ; } return $ types ; }
Matches columns to corresponding types
25,554
public function help ( $ width = 0 ) { $ name = $ this -> _name ; if ( strlen ( $ name ) < $ width ) { $ name = str_pad ( $ name , $ width , ' ' ) ; } $ optional = '' ; if ( ! $ this -> isRequired ( ) ) { $ optional = ' <comment>(optional)</comment>' ; } if ( $ this -> _choices ) { $ optional .= sprintf ( ' <comment>(c...
Generate the help for this argument .
25,555
public function usage ( ) { $ name = $ this -> _name ; if ( $ this -> _choices ) { $ name = implode ( '|' , $ this -> _choices ) ; } $ name = '<' . $ name . '>' ; if ( ! $ this -> isRequired ( ) ) { $ name = '[' . $ name . ']' ; } return $ name ; }
Get the usage value for this argument
25,556
public function xml ( SimpleXMLElement $ parent ) { $ option = $ parent -> addChild ( 'argument' ) ; $ option -> addAttribute ( 'name' , $ this -> _name ) ; $ option -> addAttribute ( 'help' , $ this -> _help ) ; $ option -> addAttribute ( 'required' , ( int ) $ this -> isRequired ( ) ) ; $ choices = $ option -> addChi...
Append this arguments XML representation to the passed in SimpleXml object .
25,557
public function eventManager ( EventManager $ eventManager = null ) { deprecationWarning ( 'EventDispatcherTrait::eventManager() is deprecated. ' . 'Use EventDispatcherTrait::setEventManager()/getEventManager() instead.' ) ; if ( $ eventManager !== null ) { $ this -> setEventManager ( $ eventManager ) ; } return $ this...
Returns the Cake \ Event \ EventManager manager instance for this object .
25,558
protected function _resolveMethodAliases ( $ key , $ defaults , $ config ) { if ( ! isset ( $ defaults [ $ key ] , $ config [ $ key ] ) ) { return $ config ; } if ( isset ( $ config [ $ key ] ) && $ config [ $ key ] === [ ] ) { $ this -> setConfig ( $ key , [ ] , false ) ; unset ( $ config [ $ key ] ) ; return $ config...
Removes aliased methods that would otherwise be duplicated by userland configuration .
25,559
public function implementedEvents ( ) { $ eventMap = [ 'Model.beforeMarshal' => 'beforeMarshal' , 'Model.beforeFind' => 'beforeFind' , 'Model.beforeSave' => 'beforeSave' , 'Model.afterSave' => 'afterSave' , 'Model.afterSaveCommit' => 'afterSaveCommit' , 'Model.beforeDelete' => 'beforeDelete' , 'Model.afterDelete' => 'a...
Gets the Model callbacks this behavior is interested in .
25,560
protected function _reflectionCache ( ) { $ class = get_class ( $ this ) ; if ( isset ( self :: $ _reflectionCache [ $ class ] ) ) { return self :: $ _reflectionCache [ $ class ] ; } $ events = $ this -> implementedEvents ( ) ; $ eventMethods = [ ] ; foreach ( $ events as $ e => $ binding ) { if ( is_array ( $ binding ...
Gets the methods implemented by this behavior
25,561
public function add ( $ name , $ command ) { if ( ! is_subclass_of ( $ command , Shell :: class ) && ! is_subclass_of ( $ command , Command :: class ) ) { $ class = is_string ( $ command ) ? $ command : get_class ( $ command ) ; throw new InvalidArgumentException ( "Cannot use '$class' for command '$name' it is not a s...
Add a command to the collection
25,562
public function discoverPlugin ( $ plugin ) { $ scanner = new CommandScanner ( ) ; $ shells = $ scanner -> scanPlugin ( $ plugin ) ; return $ this -> resolveNames ( $ shells ) ; }
Auto - discover shell & commands from the named plugin .
25,563
protected function resolveNames ( array $ input ) { $ out = [ ] ; foreach ( $ input as $ info ) { $ name = $ info [ 'name' ] ; $ addLong = $ name !== $ info [ 'fullName' ] ; if ( $ this -> has ( $ name ) && $ addLong ) { $ name = $ info [ 'fullName' ] ; } $ out [ $ name ] = $ info [ 'class' ] ; if ( $ addLong ) { $ out...
Resolve names based on existing commands
25,564
public function autoDiscover ( ) { $ scanner = new CommandScanner ( ) ; $ core = $ this -> resolveNames ( $ scanner -> scanCore ( ) ) ; $ app = $ this -> resolveNames ( $ scanner -> scanApp ( ) ) ; return array_merge ( $ core , $ app ) ; }
Automatically discover shell commands in CakePHP the application and all plugins .
25,565
public function associated ( $ associated ) { $ associated = $ this -> _normalizeAssociations ( $ associated ) ; $ this -> _associated ( $ this -> _table , $ associated ) ; $ this -> _options [ 'associated' ] = $ associated ; return $ this ; }
Set associated options .
25,566
protected function _associated ( Table $ table , array $ associations ) { foreach ( $ associations as $ key => $ associated ) { if ( is_int ( $ key ) ) { $ this -> _checkAssociation ( $ table , $ associated ) ; continue ; } $ this -> _checkAssociation ( $ table , $ key ) ; if ( isset ( $ associated [ 'associated' ] ) )...
Checks that the associations exists recursively .
25,567
protected function _checkAssociation ( Table $ table , $ association ) { if ( ! $ table -> associations ( ) -> has ( $ association ) ) { throw new RuntimeException ( sprintf ( 'Table `%s` is not associated with `%s`' , get_class ( $ table ) , $ association ) ) ; } }
Checks if an association exists .
25,568
public function validate ( $ validate ) { $ this -> _table -> getValidator ( $ validate ) ; $ this -> _options [ 'validate' ] = $ validate ; return $ this ; }
Set the validation rule set to use .
25,569
public function set ( $ option , $ value ) { if ( method_exists ( $ this , $ option ) ) { return $ this -> { $ option } ( $ value ) ; } $ this -> _options [ $ option ] = $ value ; return $ this ; }
Setting custom options .
25,570
public static function setConfig ( $ key , $ config = null ) { if ( $ config === null ) { if ( ! is_array ( $ key ) ) { throw new LogicException ( 'If config is null, key must be an array.' ) ; } foreach ( $ key as $ name => $ settings ) { static :: setConfig ( $ name , $ settings ) ; } return ; } if ( isset ( static :...
This method can be used to define configuration adapters for an application .
25,571
public static function config ( $ key , $ config = null ) { deprecationWarning ( get_called_class ( ) . '::config() is deprecated. ' . 'Use setConfig()/getConfig() instead.' ) ; if ( $ config !== null || is_array ( $ key ) ) { static :: setConfig ( $ key , $ config ) ; return null ; } return static :: getConfig ( $ key...
This method can be used to define configuration adapters for an application or read existing configuration .
25,572
public static function drop ( $ config ) { if ( ! isset ( static :: $ _config [ $ config ] ) ) { return false ; } if ( isset ( static :: $ _registry ) ) { static :: $ _registry -> unload ( $ config ) ; } unset ( static :: $ _config [ $ config ] ) ; return true ; }
Drops a constructed adapter .
25,573
public static function dsnClassMap ( array $ map = null ) { deprecationWarning ( get_called_class ( ) . '::setDsnClassMap() is deprecated. ' . 'Use setDsnClassMap()/getDsnClassMap() instead.' ) ; if ( $ map !== null ) { static :: setDsnClassMap ( $ map ) ; } return static :: getDsnClassMap ( ) ; }
Returns or updates the DSN class map for this class .
25,574
protected function _evaluateCondition ( $ condition , Event $ event ) { if ( ! isset ( $ this -> _options [ $ condition ] ) ) { return $ condition !== 'unless' ; } if ( ! is_callable ( $ this -> _options [ $ condition ] ) ) { throw new RuntimeException ( self :: class . ' the `' . $ condition . '` condition is not a ca...
Evaluates the filter conditions
25,575
public function read ( ) { if ( $ this -> _user !== null ) { return $ this -> _user ? : null ; } $ this -> _user = $ this -> _session -> read ( $ this -> _config [ 'key' ] ) ? : false ; return $ this -> _user ? : null ; }
Read user record from session .
25,576
public function write ( $ user ) { $ this -> _user = $ user ; $ this -> _session -> renew ( ) ; $ this -> _session -> write ( $ this -> _config [ 'key' ] , $ user ) ; }
Write user record to session .
25,577
public function delete ( ) { $ this -> _user = false ; $ this -> _session -> delete ( $ this -> _config [ 'key' ] ) ; $ this -> _session -> renew ( ) ; }
Delete user record from session .
25,578
public static function add ( $ filter , array $ options = [ ] ) { if ( is_string ( $ filter ) ) { $ filter = static :: _createFilter ( $ filter , $ options ) ; } static :: $ _stack [ ] = $ filter ; return $ filter ; }
Add a new middleware object to the stack of middleware that will be executed .
25,579
protected static function _createFilter ( $ name , $ options ) { $ className = App :: className ( $ name , 'Routing/Filter' , 'Filter' ) ; if ( ! $ className ) { $ msg = sprintf ( 'Cannot locate dispatcher filter named "%s".' , $ name ) ; throw new MissingDispatcherFilterException ( $ msg ) ; } return new $ className (...
Create an instance of a filter .
25,580
public static function create ( ) { $ dispatcher = new Dispatcher ( ) ; foreach ( static :: $ _stack as $ middleware ) { $ dispatcher -> addFilter ( $ middleware ) ; } return $ dispatcher ; }
Create a dispatcher that has all the configured middleware applied .
25,581
public function toHeaderValue ( ) { $ value = $ this -> value ; if ( $ this -> isExpanded ) { $ value = $ this -> _flatten ( $ this -> value ) ; } $ headerValue [ ] = sprintf ( '%s=%s' , $ this -> name , rawurlencode ( $ value ) ) ; if ( $ this -> expiresAt ) { $ headerValue [ ] = sprintf ( 'expires=%s' , $ this -> get...
Returns a header value as string
25,582
protected function validateName ( $ name ) { if ( preg_match ( "/[=,;\t\r\n\013\014]/" , $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'The cookie name `%s` contains invalid characters.' , $ name ) ) ; } if ( empty ( $ name ) ) { throw new InvalidArgumentException ( 'The cookie name cannot be empty.' ) ; ...
Validates the cookie name
25,583
public function check ( $ path ) { if ( $ this -> isExpanded === false ) { $ this -> value = $ this -> _expand ( $ this -> value ) ; } return Hash :: check ( $ this -> value , $ path ) ; }
Checks if a value exists in the cookie data .
25,584
public function withAddedValue ( $ path , $ value ) { $ new = clone $ this ; if ( $ new -> isExpanded === false ) { $ new -> value = $ new -> _expand ( $ new -> value ) ; } $ new -> value = Hash :: insert ( $ new -> value , $ path , $ value ) ; return $ new ; }
Create a new cookie with updated data .
25,585
public function withoutAddedValue ( $ path ) { $ new = clone $ this ; if ( $ new -> isExpanded === false ) { $ new -> value = $ new -> _expand ( $ new -> value ) ; } $ new -> value = Hash :: remove ( $ new -> value , $ path ) ; return $ new ; }
Create a new cookie without a specific path
25,586
public function read ( $ path = null ) { if ( $ this -> isExpanded === false ) { $ this -> value = $ this -> _expand ( $ this -> value ) ; } if ( $ path === null ) { return $ this -> value ; } return Hash :: get ( $ this -> value , $ path ) ; }
Read data from the cookie
25,587
protected function _yearSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'start' => date ( 'Y' , strtotime ( '-5 years' ) ) , 'end' => date ( 'Y' , strtotime ( '+5 years' ) ) , 'order' => 'desc' , 'templateVars' => [ ] , 'options' => [ ] ] ; if ( ! empty ( $ options [ 'val' ] ) ) { $ opt...
Generates a year select
25,588
protected function _monthSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'names' => false , 'val' => null , 'leadingZeroKey' => true , 'leadingZeroValue' => false , 'templateVars' => [ ] , ] ; if ( empty ( $ options [ 'options' ] ) ) { if ( $ options [ 'names' ] === true ) { $ options [ 'options' ] = $...
Generates a month select
25,589
protected function _daySelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'leadingZeroKey' => true , 'leadingZeroValue' => false , 'templateVars' => [ ] , ] ; $ options [ 'options' ] = $ this -> _generateNumbers ( 1 , 31 , $ options ) ; unset ( $ options [ 'names' ] , $ options [ 'leadingZ...
Generates a day select
25,590
protected function _hourSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'format' => 24 , 'start' => null , 'end' => null , 'leadingZeroKey' => true , 'leadingZeroValue' => false , 'templateVars' => [ ] , ] ; $ is24 = $ options [ 'format' ] == 24 ; $ defaultStart = $ is24 ? 0 : 1 ; $ def...
Generates a hour select
25,591
protected function _minuteSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'interval' => 1 , 'round' => 'up' , 'leadingZeroKey' => true , 'leadingZeroValue' => true , 'templateVars' => [ ] , ] ; $ options [ 'interval' ] = max ( $ options [ 'interval' ] , 1 ) ; if ( empty ( $ options [ 'o...
Generates a minute select
25,592
protected function _secondSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'leadingZeroKey' => true , 'leadingZeroValue' => true , 'options' => $ this -> _generateNumbers ( 0 , 59 ) , 'templateVars' => [ ] , ] ; unset ( $ options [ 'leadingZeroKey' ] , $ options [ 'leadingZeroValue' ] ) ...
Generates a second select
25,593
protected function _meridianSelect ( $ options , $ context ) { $ options += [ 'name' => '' , 'val' => null , 'options' => [ 'am' => 'am' , 'pm' => 'pm' ] , 'templateVars' => [ ] , ] ; return $ this -> _select -> render ( $ options , $ context ) ; }
Generates a meridian select
25,594
protected function _getMonthNames ( $ leadingZero = false ) { $ months = [ '01' => __d ( 'cake' , 'January' ) , '02' => __d ( 'cake' , 'February' ) , '03' => __d ( 'cake' , 'March' ) , '04' => __d ( 'cake' , 'April' ) , '05' => __d ( 'cake' , 'May' ) , '06' => __d ( 'cake' , 'June' ) , '07' => __d ( 'cake' , 'July' ) ,...
Returns a translated list of month names
25,595
protected function _generateNumbers ( $ start , $ end , $ options = [ ] ) { $ options += [ 'leadingZeroKey' => true , 'leadingZeroValue' => true , 'interval' => 1 ] ; $ numbers = [ ] ; $ i = $ start ; while ( $ i <= $ end ) { $ key = ( string ) $ i ; $ value = ( string ) $ i ; if ( $ options [ 'leadingZeroKey' ] === tr...
Generates a range of numbers
25,596
public function secureFields ( array $ data ) { $ data = $ this -> _normalizeData ( $ data ) ; $ fields = [ ] ; foreach ( $ this -> _selects as $ select ) { if ( $ data [ $ select ] === false || $ data [ $ select ] === null ) { continue ; } $ fields [ ] = $ data [ 'name' ] . '[' . $ select . ']' ; } return $ fields ; }
Returns a list of fields that need to be secured for this widget .
25,597
public function render ( array $ data , ContextInterface $ context ) { $ data += [ 'name' => '' , 'escape' => true , 'options' => [ ] , 'disabled' => null , 'val' => null , 'idPrefix' => null , 'templateVars' => [ ] , 'label' => true ] ; $ this -> _idPrefix = $ data [ 'idPrefix' ] ; $ this -> _clearIds ( ) ; return imp...
Render multi - checkbox widget .
25,598
protected function _renderInputs ( $ data , $ context ) { $ out = [ ] ; foreach ( $ data [ 'options' ] as $ key => $ val ) { if ( is_string ( $ key ) && is_array ( $ val ) && ! isset ( $ val [ 'text' ] , $ val [ 'value' ] ) ) { $ inputs = $ this -> _renderInputs ( [ 'options' => $ val ] + $ data , $ context ) ; $ title...
Render the checkbox inputs .
25,599
protected function _renderInput ( $ checkbox , $ context ) { $ input = $ this -> _templates -> format ( 'checkbox' , [ 'name' => $ checkbox [ 'name' ] . '[]' , 'value' => $ checkbox [ 'escape' ] ? h ( $ checkbox [ 'value' ] ) : $ checkbox [ 'value' ] , 'templateVars' => $ checkbox [ 'templateVars' ] , 'attrs' => $ this...
Render a single checkbox & wrapper .